orbital-command 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -42
- package/bin/commands/config.js +19 -0
- package/bin/commands/events.js +40 -0
- package/bin/commands/launch.js +126 -0
- package/bin/commands/manifest.js +283 -0
- package/bin/commands/registry.js +104 -0
- package/bin/commands/update.js +24 -0
- package/bin/lib/helpers.js +229 -0
- package/bin/orbital.js +147 -319
- package/dist/assets/Landing-CfQdHR0N.js +11 -0
- package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
- package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
- package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
- package/dist/assets/Settings-DLcZwbCT.js +12 -0
- package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
- package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
- package/dist/assets/arrow-down-DVPp6_qp.js +6 -0
- package/dist/assets/bot-NFaJBDn_.js +6 -0
- package/dist/assets/charts-LGLb8hyU.js +68 -0
- package/dist/assets/circle-x-IsFCkBZu.js +6 -0
- package/dist/assets/file-text-J1cebZXF.js +6 -0
- package/dist/assets/globe-WzeyHsUc.js +6 -0
- package/dist/assets/index-BdJ57EhC.css +1 -0
- package/dist/assets/index-o4ScMAuR.js +349 -0
- package/dist/assets/key-CKR8JJSj.js +6 -0
- package/dist/assets/minus-CHBsJyjp.js +6 -0
- package/dist/assets/radio-xqZaR-Uk.js +6 -0
- package/dist/assets/rocket-D_xvvNG6.js +6 -0
- package/dist/assets/shield-TdB1yv_a.js +6 -0
- package/dist/assets/ui-BmsSg9jU.js +53 -0
- package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
- package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
- package/dist/assets/{vendor-Dzv9lrRc.js → vendor-Bqt8AJn2.js} +1 -1
- package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
- package/dist/assets/zap-C9wqYMpl.js +6 -0
- package/dist/favicon.svg +1 -0
- package/dist/index.html +6 -5
- package/dist/server/server/__tests__/data-routes.test.js +126 -0
- package/dist/server/server/__tests__/helpers/db.js +17 -0
- package/dist/server/server/__tests__/helpers/mock-emitter.js +8 -0
- package/dist/server/server/__tests__/scope-routes.test.js +138 -0
- package/dist/server/server/__tests__/sprint-routes.test.js +102 -0
- package/dist/server/server/__tests__/workflow-routes.test.js +107 -0
- package/dist/server/server/config-migrator.js +135 -0
- package/dist/server/server/config.js +51 -7
- package/dist/server/server/database.js +21 -28
- package/dist/server/server/global-config.js +143 -0
- package/dist/server/server/index.js +118 -276
- package/dist/server/server/init.js +243 -225
- package/dist/server/server/launch.js +29 -0
- package/dist/server/server/manifest-types.js +8 -0
- package/dist/server/server/manifest.js +454 -0
- package/dist/server/server/migrate-legacy.js +229 -0
- package/dist/server/server/parsers/event-parser.js +4 -1
- package/dist/server/server/parsers/event-parser.test.js +117 -0
- package/dist/server/server/parsers/scope-parser.js +74 -28
- package/dist/server/server/parsers/scope-parser.test.js +230 -0
- package/dist/server/server/project-context.js +265 -0
- package/dist/server/server/project-emitter.js +41 -0
- package/dist/server/server/project-manager.js +297 -0
- package/dist/server/server/routes/aggregate-routes.js +871 -0
- package/dist/server/server/routes/config-routes.js +41 -90
- package/dist/server/server/routes/data-routes.js +25 -123
- package/dist/server/server/routes/dispatch-routes.js +37 -15
- package/dist/server/server/routes/git-routes.js +74 -0
- package/dist/server/server/routes/manifest-routes.js +319 -0
- package/dist/server/server/routes/scope-routes.js +45 -28
- package/dist/server/server/routes/sync-routes.js +134 -0
- package/dist/server/server/routes/version-routes.js +1 -15
- package/dist/server/server/routes/workflow-routes.js +9 -3
- package/dist/server/server/schema.js +3 -0
- package/dist/server/server/services/batch-orchestrator.js +41 -17
- package/dist/server/server/services/claude-session-service.js +17 -14
- package/dist/server/server/services/config-service.js +10 -1
- package/dist/server/server/services/deploy-service.test.js +119 -0
- package/dist/server/server/services/event-service.js +64 -1
- package/dist/server/server/services/event-service.test.js +191 -0
- package/dist/server/server/services/gate-service.test.js +105 -0
- package/dist/server/server/services/git-service.js +108 -4
- package/dist/server/server/services/github-service.js +110 -2
- package/dist/server/server/services/readiness-service.test.js +190 -0
- package/dist/server/server/services/scope-cache.js +5 -1
- package/dist/server/server/services/scope-cache.test.js +142 -0
- package/dist/server/server/services/scope-service.js +222 -131
- package/dist/server/server/services/scope-service.test.js +137 -0
- package/dist/server/server/services/sprint-orchestrator.js +29 -15
- package/dist/server/server/services/sprint-service.js +23 -3
- package/dist/server/server/services/sprint-service.test.js +238 -0
- package/dist/server/server/services/sync-service.js +434 -0
- package/dist/server/server/services/sync-types.js +2 -0
- package/dist/server/server/services/workflow-service.js +26 -5
- package/dist/server/server/services/workflow-service.test.js +159 -0
- package/dist/server/server/settings-sync.js +284 -0
- package/dist/server/server/uninstall.js +195 -0
- package/dist/server/server/update-planner.js +279 -0
- package/dist/server/server/update.js +212 -0
- package/dist/server/server/utils/cc-hooks-parser.js +3 -0
- package/dist/server/server/utils/cc-hooks-parser.test.js +86 -0
- package/dist/server/server/utils/dispatch-utils.js +83 -24
- package/dist/server/server/utils/dispatch-utils.test.js +182 -0
- package/dist/server/server/utils/flag-builder.js +54 -0
- package/dist/server/server/utils/json-fields.js +14 -0
- package/dist/server/server/utils/json-fields.test.js +73 -0
- package/dist/server/server/utils/logger.js +37 -3
- package/dist/server/server/utils/package-info.js +30 -0
- package/dist/server/server/utils/route-helpers.js +47 -0
- package/dist/server/server/utils/route-helpers.test.js +115 -0
- package/dist/server/server/utils/terminal-launcher.js +79 -25
- package/dist/server/server/utils/worktree-manager.js +13 -4
- package/dist/server/server/validator.js +230 -0
- package/dist/server/server/watchers/event-watcher.js +28 -13
- package/dist/server/server/watchers/global-watcher.js +63 -0
- package/dist/server/server/watchers/scope-watcher.js +27 -12
- package/dist/server/server/wizard/config-editor.js +237 -0
- package/dist/server/server/wizard/detect.js +96 -0
- package/dist/server/server/wizard/doctor.js +115 -0
- package/dist/server/server/wizard/index.js +340 -0
- package/dist/server/server/wizard/phases/confirm.js +39 -0
- package/dist/server/server/wizard/phases/project-setup.js +90 -0
- package/dist/server/server/wizard/phases/setup-wizard.js +66 -0
- package/dist/server/server/wizard/phases/welcome.js +32 -0
- package/dist/server/server/wizard/phases/workflow-setup.js +22 -0
- package/dist/server/server/wizard/types.js +29 -0
- package/dist/server/server/wizard/ui.js +73 -0
- package/dist/server/shared/__fixtures__/workflow-configs.js +75 -0
- package/dist/server/shared/api-types.js +80 -1
- package/dist/server/shared/default-workflow.json +65 -0
- package/dist/server/shared/onboarding-tour.test.js +81 -0
- package/dist/server/shared/project-colors.js +24 -0
- package/dist/server/shared/workflow-config.test.js +84 -0
- package/dist/server/shared/workflow-engine.js +1 -1
- package/dist/server/shared/workflow-engine.test.js +302 -0
- package/dist/server/shared/workflow-normalizer.js +101 -0
- package/dist/server/shared/workflow-normalizer.test.js +100 -0
- package/dist/server/src/components/onboarding/tour-steps.js +84 -0
- package/package.json +34 -29
- package/schemas/orbital.config.schema.json +2 -5
- package/scripts/postinstall.js +18 -6
- package/scripts/release.sh +53 -0
- package/server/__tests__/data-routes.test.ts +151 -0
- package/server/__tests__/helpers/db.ts +19 -0
- package/server/__tests__/helpers/mock-emitter.ts +10 -0
- package/server/__tests__/scope-routes.test.ts +158 -0
- package/server/__tests__/sprint-routes.test.ts +118 -0
- package/server/__tests__/workflow-routes.test.ts +120 -0
- package/server/config-migrator.ts +160 -0
- package/server/config.ts +64 -12
- package/server/database.ts +22 -31
- package/server/global-config.ts +204 -0
- package/server/index.ts +139 -316
- package/server/init.ts +266 -234
- package/server/launch.ts +32 -0
- package/server/manifest-types.ts +145 -0
- package/server/manifest.ts +494 -0
- package/server/migrate-legacy.ts +290 -0
- package/server/parsers/event-parser.test.ts +135 -0
- package/server/parsers/event-parser.ts +4 -1
- package/server/parsers/scope-parser.test.ts +270 -0
- package/server/parsers/scope-parser.ts +79 -31
- package/server/project-context.ts +325 -0
- package/server/project-emitter.ts +50 -0
- package/server/project-manager.ts +368 -0
- package/server/routes/aggregate-routes.ts +968 -0
- package/server/routes/config-routes.ts +43 -85
- package/server/routes/data-routes.ts +34 -156
- package/server/routes/dispatch-routes.ts +46 -17
- package/server/routes/git-routes.ts +77 -0
- package/server/routes/manifest-routes.ts +388 -0
- package/server/routes/scope-routes.ts +39 -30
- package/server/routes/sync-routes.ts +175 -0
- package/server/routes/version-routes.ts +1 -16
- package/server/routes/workflow-routes.ts +9 -3
- package/server/schema.ts +3 -0
- package/server/services/batch-orchestrator.ts +41 -17
- package/server/services/claude-session-service.ts +16 -14
- package/server/services/config-service.ts +10 -1
- package/server/services/deploy-service.test.ts +145 -0
- package/server/services/deploy-service.ts +2 -2
- package/server/services/event-service.test.ts +242 -0
- package/server/services/event-service.ts +92 -3
- package/server/services/gate-service.test.ts +131 -0
- package/server/services/gate-service.ts +2 -2
- package/server/services/git-service.ts +137 -4
- package/server/services/github-service.ts +120 -2
- package/server/services/readiness-service.test.ts +217 -0
- package/server/services/scope-cache.test.ts +167 -0
- package/server/services/scope-cache.ts +4 -1
- package/server/services/scope-service.test.ts +169 -0
- package/server/services/scope-service.ts +224 -130
- package/server/services/sprint-orchestrator.ts +30 -15
- package/server/services/sprint-service.test.ts +271 -0
- package/server/services/sprint-service.ts +29 -5
- package/server/services/sync-service.ts +482 -0
- package/server/services/sync-types.ts +77 -0
- package/server/services/workflow-service.test.ts +190 -0
- package/server/services/workflow-service.ts +29 -9
- package/server/settings-sync.ts +359 -0
- package/server/uninstall.ts +214 -0
- package/server/update-planner.ts +346 -0
- package/server/update.ts +263 -0
- package/server/utils/cc-hooks-parser.test.ts +96 -0
- package/server/utils/cc-hooks-parser.ts +4 -0
- package/server/utils/dispatch-utils.test.ts +245 -0
- package/server/utils/dispatch-utils.ts +102 -30
- package/server/utils/flag-builder.ts +56 -0
- package/server/utils/json-fields.test.ts +83 -0
- package/server/utils/json-fields.ts +14 -0
- package/server/utils/logger.ts +40 -3
- package/server/utils/package-info.ts +32 -0
- package/server/utils/route-helpers.test.ts +144 -0
- package/server/utils/route-helpers.ts +50 -0
- package/server/utils/terminal-launcher.ts +85 -25
- package/server/utils/worktree-manager.ts +9 -4
- package/server/validator.ts +270 -0
- package/server/watchers/event-watcher.ts +24 -12
- package/server/watchers/global-watcher.ts +77 -0
- package/server/watchers/scope-watcher.ts +21 -9
- package/server/wizard/config-editor.ts +248 -0
- package/server/wizard/detect.ts +104 -0
- package/server/wizard/doctor.ts +114 -0
- package/server/wizard/index.ts +438 -0
- package/server/wizard/phases/confirm.ts +45 -0
- package/server/wizard/phases/project-setup.ts +106 -0
- package/server/wizard/phases/setup-wizard.ts +78 -0
- package/server/wizard/phases/welcome.ts +39 -0
- package/server/wizard/phases/workflow-setup.ts +28 -0
- package/server/wizard/types.ts +56 -0
- package/server/wizard/ui.ts +92 -0
- package/shared/__fixtures__/workflow-configs.ts +80 -0
- package/shared/api-types.ts +106 -0
- package/shared/onboarding-tour.test.ts +94 -0
- package/shared/project-colors.ts +24 -0
- package/shared/workflow-config.test.ts +111 -0
- package/shared/workflow-config.ts +7 -0
- package/shared/workflow-engine.test.ts +388 -0
- package/shared/workflow-engine.ts +1 -1
- package/shared/workflow-normalizer.test.ts +119 -0
- package/shared/workflow-normalizer.ts +118 -0
- package/templates/agents/QUICK-REFERENCE.md +1 -0
- package/templates/agents/README.md +1 -0
- package/templates/agents/SKILL-TRIGGERS.md +11 -0
- package/templates/agents/green-team/deep-dive.md +361 -0
- package/templates/hooks/end-session.sh +4 -1
- package/templates/hooks/init-session.sh +1 -0
- package/templates/hooks/orbital-emit.sh +2 -2
- package/templates/hooks/orbital-report-deploy.sh +4 -4
- package/templates/hooks/orbital-report-gates.sh +4 -4
- package/templates/hooks/orbital-scope-update.sh +1 -1
- package/templates/hooks/scope-commit-logger.sh +2 -2
- package/templates/hooks/scope-create-cleanup.sh +2 -2
- package/templates/hooks/scope-create-gate.sh +2 -5
- package/templates/hooks/scope-gate.sh +4 -6
- package/templates/hooks/scope-helpers.sh +28 -1
- package/templates/hooks/scope-lifecycle-gate.sh +14 -5
- package/templates/hooks/scope-prepare.sh +67 -12
- package/templates/hooks/scope-transition.sh +14 -6
- package/templates/hooks/time-tracker.sh +2 -5
- package/templates/migrations/renames.json +1 -0
- package/templates/orbital.config.json +8 -6
- package/{shared/default-workflow.json → templates/presets/default.json} +65 -0
- package/templates/presets/development.json +4 -4
- package/templates/presets/gitflow.json +7 -0
- package/templates/prompts/README.md +23 -0
- package/templates/prompts/deep-dive-audit.md +94 -0
- package/templates/quick/rules.md +56 -5
- package/templates/settings-hooks.json +1 -1
- package/templates/skills/git-commit/SKILL.md +27 -7
- package/templates/skills/git-dev/SKILL.md +13 -4
- package/templates/skills/git-main/SKILL.md +13 -3
- package/templates/skills/git-production/SKILL.md +9 -2
- package/templates/skills/git-staging/SKILL.md +11 -3
- package/templates/skills/scope-create/SKILL.md +17 -3
- package/templates/skills/scope-fix-review/SKILL.md +14 -7
- package/templates/skills/scope-implement/SKILL.md +15 -4
- package/templates/skills/scope-post-review/SKILL.md +77 -7
- package/templates/skills/scope-pre-review/SKILL.md +11 -4
- package/templates/skills/scope-verify/SKILL.md +5 -3
- package/templates/skills/test-code-review/SKILL.md +41 -33
- package/templates/skills/test-scaffold/SKILL.md +222 -0
- package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +0 -84
- package/dist/assets/charts-D__PA1zp.js +0 -72
- package/dist/assets/index-D1G6i0nS.css +0 -1
- package/dist/assets/index-DpItvKpf.js +0 -419
- package/dist/assets/ui-BvF022GT.js +0 -53
- package/index.html +0 -15
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -33
- package/src/components/AgentBadge.tsx +0 -40
- package/src/components/BatchPreflightModal.tsx +0 -115
- package/src/components/CardDisplayToggle.tsx +0 -74
- package/src/components/ColumnHeaderActions.tsx +0 -55
- package/src/components/ColumnMenu.tsx +0 -99
- package/src/components/DeployHistory.tsx +0 -141
- package/src/components/DispatchModal.tsx +0 -164
- package/src/components/DispatchPopover.tsx +0 -139
- package/src/components/DragOverlay.tsx +0 -25
- package/src/components/DriftSidebar.tsx +0 -140
- package/src/components/EnvironmentStrip.tsx +0 -88
- package/src/components/ErrorBoundary.tsx +0 -62
- package/src/components/FilterChip.tsx +0 -105
- package/src/components/GateIndicator.tsx +0 -33
- package/src/components/IdeaDetailModal.tsx +0 -190
- package/src/components/IdeaFormDialog.tsx +0 -113
- package/src/components/KanbanColumn.tsx +0 -201
- package/src/components/MarkdownRenderer.tsx +0 -114
- package/src/components/NeonGrid.tsx +0 -128
- package/src/components/PromotionQueue.tsx +0 -89
- package/src/components/ScopeCard.tsx +0 -234
- package/src/components/ScopeDetailModal.tsx +0 -255
- package/src/components/ScopeFilterBar.tsx +0 -152
- package/src/components/SearchInput.tsx +0 -102
- package/src/components/SessionPanel.tsx +0 -335
- package/src/components/SprintContainer.tsx +0 -303
- package/src/components/SprintDependencyDialog.tsx +0 -78
- package/src/components/SprintPreflightModal.tsx +0 -138
- package/src/components/StatusBar.tsx +0 -168
- package/src/components/SwimCell.tsx +0 -67
- package/src/components/SwimLaneRow.tsx +0 -94
- package/src/components/SwimlaneBoardView.tsx +0 -108
- package/src/components/VersionBadge.tsx +0 -139
- package/src/components/ViewModeSelector.tsx +0 -114
- package/src/components/config/AgentChip.tsx +0 -53
- package/src/components/config/AgentCreateDialog.tsx +0 -321
- package/src/components/config/AgentEditor.tsx +0 -175
- package/src/components/config/DirectoryTree.tsx +0 -582
- package/src/components/config/FileEditor.tsx +0 -550
- package/src/components/config/HookChip.tsx +0 -50
- package/src/components/config/StageCard.tsx +0 -198
- package/src/components/config/TransitionZone.tsx +0 -173
- package/src/components/config/UnifiedWorkflowPipeline.tsx +0 -216
- package/src/components/config/WorkflowPipeline.tsx +0 -161
- package/src/components/source-control/BranchList.tsx +0 -93
- package/src/components/source-control/BranchPanel.tsx +0 -105
- package/src/components/source-control/CommitLog.tsx +0 -100
- package/src/components/source-control/CommitRow.tsx +0 -47
- package/src/components/source-control/GitHubPanel.tsx +0 -110
- package/src/components/source-control/GitHubSetupGuide.tsx +0 -52
- package/src/components/source-control/GitOverviewBar.tsx +0 -101
- package/src/components/source-control/PullRequestList.tsx +0 -69
- package/src/components/source-control/WorktreeList.tsx +0 -80
- package/src/components/ui/badge.tsx +0 -41
- package/src/components/ui/button.tsx +0 -55
- package/src/components/ui/card.tsx +0 -78
- package/src/components/ui/dialog.tsx +0 -94
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -52
- package/src/components/ui/toggle-switch.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -27
- package/src/components/workflow/AddEdgeDialog.tsx +0 -217
- package/src/components/workflow/AddListDialog.tsx +0 -201
- package/src/components/workflow/ChecklistEditor.tsx +0 -239
- package/src/components/workflow/CommandPrefixManager.tsx +0 -118
- package/src/components/workflow/ConfigSettingsPanel.tsx +0 -189
- package/src/components/workflow/DirectionSelector.tsx +0 -133
- package/src/components/workflow/DispatchConfigPanel.tsx +0 -180
- package/src/components/workflow/EdgeDetailPanel.tsx +0 -236
- package/src/components/workflow/EdgePropertyEditor.tsx +0 -251
- package/src/components/workflow/EditToolbar.tsx +0 -138
- package/src/components/workflow/HookDetailPanel.tsx +0 -250
- package/src/components/workflow/HookExecutionLog.tsx +0 -24
- package/src/components/workflow/HookSourceModal.tsx +0 -129
- package/src/components/workflow/HooksDashboard.tsx +0 -363
- package/src/components/workflow/ListPropertyEditor.tsx +0 -251
- package/src/components/workflow/MigrationPreviewDialog.tsx +0 -237
- package/src/components/workflow/MovementRulesPanel.tsx +0 -188
- package/src/components/workflow/NodeDetailPanel.tsx +0 -245
- package/src/components/workflow/PresetSelector.tsx +0 -414
- package/src/components/workflow/SkillCommandBuilder.tsx +0 -174
- package/src/components/workflow/WorkflowEdgeComponent.tsx +0 -145
- package/src/components/workflow/WorkflowNode.tsx +0 -147
- package/src/components/workflow/graphLayout.ts +0 -186
- package/src/components/workflow/mergeHooks.ts +0 -85
- package/src/components/workflow/useEditHistory.ts +0 -88
- package/src/components/workflow/useWorkflowEditor.ts +0 -262
- package/src/components/workflow/validateConfig.ts +0 -70
- package/src/hooks/useActiveDispatches.ts +0 -198
- package/src/hooks/useBoardSettings.ts +0 -170
- package/src/hooks/useCardDisplay.ts +0 -57
- package/src/hooks/useCcHooks.ts +0 -24
- package/src/hooks/useConfigTree.ts +0 -51
- package/src/hooks/useEnforcementRules.ts +0 -46
- package/src/hooks/useEvents.ts +0 -59
- package/src/hooks/useFileEditor.ts +0 -165
- package/src/hooks/useGates.ts +0 -57
- package/src/hooks/useIdeaActions.ts +0 -53
- package/src/hooks/useKanbanDnd.ts +0 -410
- package/src/hooks/useOrbitalConfig.ts +0 -54
- package/src/hooks/usePipeline.ts +0 -47
- package/src/hooks/usePipelineData.ts +0 -338
- package/src/hooks/useReconnect.ts +0 -25
- package/src/hooks/useScopeFilters.ts +0 -125
- package/src/hooks/useScopeSessions.ts +0 -44
- package/src/hooks/useScopes.ts +0 -67
- package/src/hooks/useSearch.ts +0 -67
- package/src/hooks/useSettings.tsx +0 -187
- package/src/hooks/useSocket.ts +0 -25
- package/src/hooks/useSourceControl.ts +0 -105
- package/src/hooks/useSprintPreflight.ts +0 -55
- package/src/hooks/useSprints.ts +0 -154
- package/src/hooks/useStatusBarHighlight.ts +0 -18
- package/src/hooks/useSwimlaneBoardSettings.ts +0 -104
- package/src/hooks/useTheme.ts +0 -9
- package/src/hooks/useTransitionReadiness.ts +0 -53
- package/src/hooks/useVersion.ts +0 -155
- package/src/hooks/useViolations.ts +0 -65
- package/src/hooks/useWorkflow.tsx +0 -125
- package/src/hooks/useZoomModifier.ts +0 -19
- package/src/index.css +0 -797
- package/src/layouts/DashboardLayout.tsx +0 -113
- package/src/lib/collisionDetection.ts +0 -20
- package/src/lib/scope-fields.ts +0 -61
- package/src/lib/swimlane.ts +0 -146
- package/src/lib/utils.ts +0 -15
- package/src/main.tsx +0 -19
- package/src/socket.ts +0 -11
- package/src/types/index.ts +0 -497
- package/src/views/AgentFeed.tsx +0 -339
- package/src/views/DeployPipeline.tsx +0 -59
- package/src/views/EnforcementView.tsx +0 -378
- package/src/views/PrimitivesConfig.tsx +0 -500
- package/src/views/QualityGates.tsx +0 -1012
- package/src/views/ScopeBoard.tsx +0 -454
- package/src/views/SessionTimeline.tsx +0 -516
- package/src/views/Settings.tsx +0 -183
- package/src/views/SourceControl.tsx +0 -95
- package/src/views/WorkflowVisualizer.tsx +0 -382
- package/tailwind.config.js +0 -161
- package/tsconfig.json +0 -25
- package/vite.config.ts +0 -38
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import{j as o,x as ss,t as rs,O as os,v as is,y as as,w as Ke}from"./ui-BvF022GT.js";import{r as Wr,g as ec,d as cs,a as N,b as tc}from"./vendor-Dzv9lrRc.js";import{i as nc,f as Os,g as Hs,h as sc,j as rc,k as oc,l as qt,m as Mn}from"./charts-D__PA1zp.js";import{c as le,S as Xr,P as qr,Z as rt,X as pe,G as Ur,E as Ct,C as hn,T as be,a as pn,b as ls,d as ye,g as ds,A as Le,e as Jt,f as ic,D as ac,h as us,i as Kr,M as Zr,j as Te,k as cc,l as lc,m as dc,n as uc,o as fc,p as hc,L as Qr,q as Jr,r as xn,B as en,s as eo,t as pc,u as to,v as no,w as xc,x as mc,y as so,K as $e,z as gc,F as bc,H as yc,I as wc,J as vc,N as Nc,O as jc,Q as Cc,R as fs,U as zc,V as kc,W as Fs,Y as Sc,_ as _c,$ as Ec,a0 as Mc,a1 as Ic,a2 as ro,a3 as $c,a4 as Tc,a5 as Ac,a6 as Pc,a7 as Dc,a8 as Lc,a9 as Rc}from"./index-DpItvKpf.js";/**
|
|
2
|
-
* @license lucide-react v0.577.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Oc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Hc=le("clipboard-check",Oc);/**
|
|
7
|
-
* @license lucide-react v0.577.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Fc=[["path",{d:"m10 15 5 5 5-5",key:"1hpjnr"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]],oo=le("corner-right-down",Fc);/**
|
|
12
|
-
* @license lucide-react v0.577.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Bc=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],tn=le("file-code-corner",Bc);/**
|
|
17
|
-
* @license lucide-react v0.577.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Vc=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Yc=le("folder-input",Vc);/**
|
|
22
|
-
* @license lucide-react v0.577.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Gc=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Wc=le("grip-vertical",Gc);/**
|
|
27
|
-
* @license lucide-react v0.577.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Xc=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],qc=le("key",Xc);/**
|
|
32
|
-
* @license lucide-react v0.577.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Uc=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Kc=le("layout-grid",Uc);/**
|
|
37
|
-
* @license lucide-react v0.577.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Zc=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],hs=le("radio",Zc);/**
|
|
42
|
-
* @license lucide-react v0.577.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Qc=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Jc=le("redo-2",Qc);/**
|
|
47
|
-
* @license lucide-react v0.577.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const el=[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],tl=le("server-off",el);/**
|
|
52
|
-
* @license lucide-react v0.577.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const nl=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],sl=le("square-check-big",nl);/**
|
|
57
|
-
* @license lucide-react v0.577.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const rl=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ol=le("user",rl);function oe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=oe(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var il={value:()=>{}};function mn(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Ut(n)}function Ut(e){this._=e}function al(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",r=n.indexOf(".");if(r>=0&&(s=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}Ut.prototype=mn.prototype={constructor:Ut,on:function(e,t){var n=this._,s=al(e+"",n),r,i=-1,a=s.length;if(arguments.length<2){for(;++i<a;)if((r=(e=s[i]).type)&&(r=cl(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=s[i]).type)n[r]=Bs(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Bs(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ut(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),s=0,r,i;s<r;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,r=i.length;s<r;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)}};function cl(e,t){for(var n=0,s=e.length,r;n<s;++n)if((r=e[n]).name===t)return r.value}function Bs(e,t,n){for(var s=0,r=e.length;s<r;++s)if(e[s].name===t){e[s]=il,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xn="http://www.w3.org/1999/xhtml";const Vs={svg:"http://www.w3.org/2000/svg",xhtml:Xn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Vs.hasOwnProperty(t)?{space:Vs[t],local:e}:e}function ll(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xn&&t.documentElement.namespaceURI===Xn?t.createElement(e):t.createElementNS(n,e)}}function dl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function io(e){var t=gn(e);return(t.local?dl:ll)(t)}function ul(){}function ps(e){return e==null?ul:function(){return this.querySelector(e)}}function fl(e){typeof e!="function"&&(e=ps(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],a=i.length,c=s[r]=new Array(a),l,f,h=0;h<a;++h)(l=i[h])&&(f=e.call(l,l.__data__,h,i))&&("__data__"in l&&(f.__data__=l.__data__),c[h]=f);return new ce(s,this._parents)}function hl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function pl(){return[]}function ao(e){return e==null?pl:function(){return this.querySelectorAll(e)}}function xl(e){return function(){return hl(e.apply(this,arguments))}}function ml(e){typeof e=="function"?e=xl(e):e=ao(e);for(var t=this._groups,n=t.length,s=[],r=[],i=0;i<n;++i)for(var a=t[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&(s.push(e.call(l,l.__data__,f,a)),r.push(l));return new ce(s,r)}function co(e){return function(){return this.matches(e)}}function lo(e){return function(t){return t.matches(e)}}var gl=Array.prototype.find;function bl(e){return function(){return gl.call(this.children,e)}}function yl(){return this.firstElementChild}function wl(e){return this.select(e==null?yl:bl(typeof e=="function"?e:lo(e)))}var vl=Array.prototype.filter;function Nl(){return Array.from(this.children)}function jl(e){return function(){return vl.call(this.children,e)}}function Cl(e){return this.selectAll(e==null?Nl:jl(typeof e=="function"?e:lo(e)))}function zl(e){typeof e!="function"&&(e=co(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],a=i.length,c=s[r]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new ce(s,this._parents)}function uo(e){return new Array(e.length)}function kl(){return new ce(this._enter||this._groups.map(uo),this._parents)}function nn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}nn.prototype={constructor:nn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Sl(e){return function(){return e}}function _l(e,t,n,s,r,i){for(var a=0,c,l=t.length,f=i.length;a<f;++a)(c=t[a])?(c.__data__=i[a],s[a]=c):n[a]=new nn(e,i[a]);for(;a<l;++a)(c=t[a])&&(r[a]=c)}function El(e,t,n,s,r,i,a){var c,l,f=new Map,h=t.length,d=i.length,u=new Array(h),p;for(c=0;c<h;++c)(l=t[c])&&(u[c]=p=a.call(l,l.__data__,c,t)+"",f.has(p)?r[c]=l:f.set(p,l));for(c=0;c<d;++c)p=a.call(e,i[c],c,i)+"",(l=f.get(p))?(s[c]=l,l.__data__=i[c],f.delete(p)):n[c]=new nn(e,i[c]);for(c=0;c<h;++c)(l=t[c])&&f.get(u[c])===l&&(r[c]=l)}function Ml(e){return e.__data__}function Il(e,t){if(!arguments.length)return Array.from(this,Ml);var n=t?El:_l,s=this._parents,r=this._groups;typeof e!="function"&&(e=Sl(e));for(var i=r.length,a=new Array(i),c=new Array(i),l=new Array(i),f=0;f<i;++f){var h=s[f],d=r[f],u=d.length,p=$l(e.call(h,h&&h.__data__,f,s)),x=p.length,y=c[f]=new Array(x),v=a[f]=new Array(x),w=l[f]=new Array(u);n(h,d,y,v,w,p,t);for(var b=0,g=0,m,z;b<x;++b)if(m=y[b]){for(b>=g&&(g=b+1);!(z=v[g])&&++g<x;);m._next=z||null}}return a=new ce(a,s),a._enter=c,a._exit=l,a}function $l(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Tl(){return new ce(this._exit||this._groups.map(uo),this._parents)}function Al(e,t,n){var s=this.enter(),r=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),s&&r?s.merge(r).order():r}function Pl(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,r=n.length,i=s.length,a=Math.min(r,i),c=new Array(r),l=0;l<a;++l)for(var f=n[l],h=s[l],d=f.length,u=c[l]=new Array(d),p,x=0;x<d;++x)(p=f[x]||h[x])&&(u[x]=p);for(;l<r;++l)c[l]=n[l];return new ce(c,this._parents)}function Dl(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],r=s.length-1,i=s[r],a;--r>=0;)(a=s[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Ll(e){e||(e=Rl);function t(d,u){return d&&u?e(d.__data__,u.__data__):!d-!u}for(var n=this._groups,s=n.length,r=new Array(s),i=0;i<s;++i){for(var a=n[i],c=a.length,l=r[i]=new Array(c),f,h=0;h<c;++h)(f=a[h])&&(l[h]=f);l.sort(t)}return new ce(r,this._parents).order()}function Rl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ol(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hl(){return Array.from(this)}function Fl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length;r<i;++r){var a=s[r];if(a)return a}return null}function Bl(){let e=0;for(const t of this)++e;return e}function Vl(){return!this.node()}function Yl(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var r=t[n],i=0,a=r.length,c;i<a;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function Gl(e){return function(){this.removeAttribute(e)}}function Wl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Xl(e,t){return function(){this.setAttribute(e,t)}}function ql(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Ul(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Kl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Zl(e,t){var n=gn(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?Wl:Gl:typeof t=="function"?n.local?Kl:Ul:n.local?ql:Xl)(n,t))}function fo(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ql(e){return function(){this.style.removeProperty(e)}}function Jl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ed(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function td(e,t,n){return arguments.length>1?this.each((t==null?Ql:typeof t=="function"?ed:Jl)(e,t,n??"")):Ze(this.node(),e)}function Ze(e,t){return e.style.getPropertyValue(t)||fo(e).getComputedStyle(e,null).getPropertyValue(t)}function nd(e){return function(){delete this[e]}}function sd(e,t){return function(){this[e]=t}}function rd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function od(e,t){return arguments.length>1?this.each((t==null?nd:typeof t=="function"?rd:sd)(e,t)):this.node()[e]}function ho(e){return e.trim().split(/^|\s+/)}function xs(e){return e.classList||new po(e)}function po(e){this._node=e,this._names=ho(e.getAttribute("class")||"")}po.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xo(e,t){for(var n=xs(e),s=-1,r=t.length;++s<r;)n.add(t[s])}function mo(e,t){for(var n=xs(e),s=-1,r=t.length;++s<r;)n.remove(t[s])}function id(e){return function(){xo(this,e)}}function ad(e){return function(){mo(this,e)}}function cd(e,t){return function(){(t.apply(this,arguments)?xo:mo)(this,e)}}function ld(e,t){var n=ho(e+"");if(arguments.length<2){for(var s=xs(this.node()),r=-1,i=n.length;++r<i;)if(!s.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?cd:t?id:ad)(n,t))}function dd(){this.textContent=""}function ud(e){return function(){this.textContent=e}}function fd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function hd(e){return arguments.length?this.each(e==null?dd:(typeof e=="function"?fd:ud)(e)):this.node().textContent}function pd(){this.innerHTML=""}function xd(e){return function(){this.innerHTML=e}}function md(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function gd(e){return arguments.length?this.each(e==null?pd:(typeof e=="function"?md:xd)(e)):this.node().innerHTML}function bd(){this.nextSibling&&this.parentNode.appendChild(this)}function yd(){return this.each(bd)}function wd(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function vd(){return this.each(wd)}function Nd(e){var t=typeof e=="function"?e:io(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function jd(){return null}function Cd(e,t){var n=typeof e=="function"?e:io(e),s=t==null?jd:typeof t=="function"?t:ps(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function zd(){var e=this.parentNode;e&&e.removeChild(this)}function kd(){return this.each(zd)}function Sd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _d(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ed(e){return this.select(e?_d:Sd)}function Md(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Id(e){return function(t){e.call(this,t,this.__data__)}}function $d(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function Td(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function Ad(e,t,n){return function(){var s=this.__on,r,i=Id(t);if(s){for(var a=0,c=s.length;a<c;++a)if((r=s[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(r):this.__on=[r]}}function Pd(e,t,n){var s=$d(e+""),r,i=s.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,f=c.length,h;l<f;++l)for(r=0,h=c[l];r<i;++r)if((a=s[r]).type===h.type&&a.name===h.name)return h.value}return}for(c=t?Ad:Td,r=0;r<i;++r)this.each(c(s[r],t,n));return this}function go(e,t,n){var s=fo(e),r=s.CustomEvent;typeof r=="function"?r=new r(t,n):(r=s.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Dd(e,t){return function(){return go(this,e,t)}}function Ld(e,t){return function(){return go(this,e,t.apply(this,arguments))}}function Rd(e,t){return this.each((typeof t=="function"?Ld:Dd)(e,t))}function*Od(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],r=0,i=s.length,a;r<i;++r)(a=s[r])&&(yield a)}var bo=[null];function ce(e,t){this._groups=e,this._parents=t}function zt(){return new ce([[document.documentElement]],bo)}function Hd(){return this}ce.prototype=zt.prototype={constructor:ce,select:fl,selectAll:ml,selectChild:wl,selectChildren:Cl,filter:zl,data:Il,enter:kl,exit:Tl,join:Al,merge:Pl,selection:Hd,order:Dl,sort:Ll,call:Ol,nodes:Hl,node:Fl,size:Bl,empty:Vl,each:Yl,attr:Zl,style:td,property:od,classed:ld,text:hd,html:gd,raise:yd,lower:vd,append:Nd,insert:Cd,remove:kd,clone:Ed,datum:Md,on:Pd,dispatch:Rd,[Symbol.iterator]:Od};function ae(e){return typeof e=="string"?new ce([[document.querySelector(e)]],[document.documentElement]):new ce([[e]],bo)}function Fd(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=Fd(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Bd={passive:!1},gt={capture:!0,passive:!1};function In(e){e.stopImmediatePropagation()}function Ue(e){e.preventDefault(),e.stopImmediatePropagation()}function yo(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",Ue,gt);"onselectstart"in t?n.on("selectstart.drag",Ue,gt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function wo(e,t){var n=e.document.documentElement,s=ae(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ue,gt),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Tt=e=>()=>e;function qn(e,{sourceEvent:t,subject:n,target:s,identifier:r,active:i,x:a,y:c,dx:l,dy:f,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:h}})}qn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Vd(e){return!e.ctrlKey&&!e.button}function Yd(){return this.parentNode}function Gd(e,t){return t??{x:e.x,y:e.y}}function Wd(){return navigator.maxTouchPoints||"ontouchstart"in this}function vo(){var e=Vd,t=Yd,n=Gd,s=Wd,r={},i=mn("start","drag","end"),a=0,c,l,f,h,d=0;function u(m){m.on("mousedown.drag",p).filter(s).on("touchstart.drag",v).on("touchmove.drag",w,Bd).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(m,z){if(!(h||!e.call(this,m,z))){var C=g(this,t.call(this,m,z),m,z,"mouse");C&&(ae(m.view).on("mousemove.drag",x,gt).on("mouseup.drag",y,gt),yo(m.view),In(m),f=!1,c=m.clientX,l=m.clientY,C("start",m))}}function x(m){if(Ue(m),!f){var z=m.clientX-c,C=m.clientY-l;f=z*z+C*C>d}r.mouse("drag",m)}function y(m){ae(m.view).on("mousemove.drag mouseup.drag",null),wo(m.view,f),Ue(m),r.mouse("end",m)}function v(m,z){if(e.call(this,m,z)){var C=m.changedTouches,S=t.call(this,m,z),P=C.length,D,H;for(D=0;D<P;++D)(H=g(this,S,m,z,C[D].identifier,C[D]))&&(In(m),H("start",m,C[D]))}}function w(m){var z=m.changedTouches,C=z.length,S,P;for(S=0;S<C;++S)(P=r[z[S].identifier])&&(Ue(m),P("drag",m,z[S]))}function b(m){var z=m.changedTouches,C=z.length,S,P;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),S=0;S<C;++S)(P=r[z[S].identifier])&&(In(m),P("end",m,z[S]))}function g(m,z,C,S,P,D){var H=i.copy(),M=de(D||C,z),$,L,j;if((j=n.call(m,new qn("beforestart",{sourceEvent:C,target:u,identifier:P,active:a,x:M[0],y:M[1],dx:0,dy:0,dispatch:H}),S))!=null)return $=j.x-M[0]||0,L=j.y-M[1]||0,function A(k,I,E){var _=M,R;switch(k){case"start":r[P]=A,R=a++;break;case"end":delete r[P],--a;case"drag":M=de(E||I,z),R=a;break}H.call(k,m,new qn(k,{sourceEvent:I,subject:j,target:u,identifier:P,active:R,x:M[0]+$,y:M[1]+L,dx:M[0]-_[0],dy:M[1]-_[1],dispatch:H}),S)}}return u.filter=function(m){return arguments.length?(e=typeof m=="function"?m:Tt(!!m),u):e},u.container=function(m){return arguments.length?(t=typeof m=="function"?m:Tt(m),u):t},u.subject=function(m){return arguments.length?(n=typeof m=="function"?m:Tt(m),u):n},u.touchable=function(m){return arguments.length?(s=typeof m=="function"?m:Tt(!!m),u):s},u.on=function(){var m=i.on.apply(i,arguments);return m===i?u:m},u.clickDistance=function(m){return arguments.length?(d=(m=+m)*m,u):Math.sqrt(d)},u}var Qe=0,pt=0,lt=0,No=1e3,sn,xt,rn=0,Re=0,bn=0,bt=typeof performance=="object"&&performance.now?performance:Date,jo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ms(){return Re||(jo(Xd),Re=bt.now()+bn)}function Xd(){Re=0}function on(){this._call=this._time=this._next=null}on.prototype=Co.prototype={constructor:on,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ms():+n)+(t==null?0:+t),!this._next&&xt!==this&&(xt?xt._next=this:sn=this,xt=this),this._call=e,this._time=n,Un()},stop:function(){this._call&&(this._call=null,this._time=1/0,Un())}};function Co(e,t,n){var s=new on;return s.restart(e,t,n),s}function qd(){ms(),++Qe;for(var e=sn,t;e;)(t=Re-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Qe}function Ys(){Re=(rn=bt.now())+bn,Qe=pt=0;try{qd()}finally{Qe=0,Kd(),Re=0}}function Ud(){var e=bt.now(),t=e-rn;t>No&&(bn-=t,rn=e)}function Kd(){for(var e,t=sn,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:sn=n);xt=e,Un(s)}function Un(e){if(!Qe){pt&&(pt=clearTimeout(pt));var t=e-Re;t>24?(e<1/0&&(pt=setTimeout(Ys,e-bt.now()-bn)),lt&&(lt=clearInterval(lt))):(lt||(rn=bt.now(),lt=setInterval(Ud,No)),Qe=1,jo(Ys))}}function Gs(e,t,n){var s=new on;return t=t==null?0:+t,s.restart(r=>{s.stop(),e(r+t)},t,n),s}var Zd=mn("start","end","cancel","interrupt"),Qd=[],zo=0,Ws=1,Kn=2,Kt=3,Xs=4,Zn=5,Zt=6;function yn(e,t,n,s,r,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Jd(e,n,{name:t,index:s,group:r,on:Zd,tween:Qd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zo})}function gs(e,t){var n=xe(e,t);if(n.state>zo)throw new Error("too late; already scheduled");return n}function we(e,t){var n=xe(e,t);if(n.state>Kt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Jd(e,t,n){var s=e.__transition,r;s[t]=n,n.timer=Co(i,0,n.time);function i(f){n.state=Ws,n.timer.restart(a,n.delay,n.time),n.delay<=f&&a(f-n.delay)}function a(f){var h,d,u,p;if(n.state!==Ws)return l();for(h in s)if(p=s[h],p.name===n.name){if(p.state===Kt)return Gs(a);p.state===Xs?(p.state=Zt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[h]):+h<t&&(p.state=Zt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[h])}if(Gs(function(){n.state===Kt&&(n.state=Xs,n.timer.restart(c,n.delay,n.time),c(f))}),n.state=Kn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Kn){for(n.state=Kt,r=new Array(u=n.tween.length),h=0,d=-1;h<u;++h)(p=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(r[++d]=p);r.length=d+1}}function c(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(l),n.state=Zn,1),d=-1,u=r.length;++d<u;)r[d].call(e,h);n.state===Zn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Zt,n.timer.stop(),delete s[t];for(var f in s)return;delete e.__transition}}function Qt(e,t){var n=e.__transition,s,r,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((s=n[a]).name!==t){i=!1;continue}r=s.state>Kn&&s.state<Zn,s.state=Zt,s.timer.stop(),s.on.call(r?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[a]}i&&delete e.__transition}}function eu(e){return this.each(function(){Qt(this,e)})}function tu(e,t){var n,s;return function(){var r=we(this,e),i=r.tween;if(i!==n){s=n=i;for(var a=0,c=s.length;a<c;++a)if(s[a].name===t){s=s.slice(),s.splice(a,1);break}}r.tween=s}}function nu(e,t,n){var s,r;if(typeof n!="function")throw new Error;return function(){var i=we(this,e),a=i.tween;if(a!==s){r=(s=a).slice();for(var c={name:t,value:n},l=0,f=r.length;l<f;++l)if(r[l].name===t){r[l]=c;break}l===f&&r.push(c)}i.tween=r}}function su(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=xe(this.node(),n).tween,r=0,i=s.length,a;r<i;++r)if((a=s[r]).name===e)return a.value;return null}return this.each((t==null?tu:nu)(n,e,t))}function bs(e,t,n){var s=e._id;return e.each(function(){var r=we(this,s);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,s).value[t]}}function ko(e,t){var n;return(typeof t=="number"?nc:t instanceof Os?Hs:(n=Os(t))?(t=n,Hs):sc)(e,t)}function ru(e){return function(){this.removeAttribute(e)}}function ou(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iu(e,t,n){var s,r=n+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===s?i:i=t(s=a,n)}}function au(e,t,n){var s,r=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===s?i:i=t(s=a,n)}}function cu(e,t,n){var s,r,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=c+"",a===l?null:a===s&&l===r?i:(r=l,i=t(s=a,c)))}}function lu(e,t,n){var s,r,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=c+"",a===l?null:a===s&&l===r?i:(r=l,i=t(s=a,c)))}}function du(e,t){var n=gn(e),s=n==="transform"?rc:ko;return this.attrTween(e,typeof t=="function"?(n.local?lu:cu)(n,s,bs(this,"attr."+e,t)):t==null?(n.local?ou:ru)(n):(n.local?au:iu)(n,s,t))}function uu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function fu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hu(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&fu(e,i)),n}return r._value=t,r}function pu(e,t){var n,s;function r(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&uu(e,i)),n}return r._value=t,r}function xu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=gn(e);return this.tween(n,(s.local?hu:pu)(s,t))}function mu(e,t){return function(){gs(this,e).delay=+t.apply(this,arguments)}}function gu(e,t){return t=+t,function(){gs(this,e).delay=t}}function bu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mu:gu)(t,e)):xe(this.node(),t).delay}function yu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function wu(e,t){return t=+t,function(){we(this,e).duration=t}}function vu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yu:wu)(t,e)):xe(this.node(),t).duration}function Nu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function ju(e){var t=this._id;return arguments.length?this.each(Nu(t,e)):xe(this.node(),t).ease}function Cu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function zu(e){if(typeof e!="function")throw new Error;return this.each(Cu(this._id,e))}function ku(e){typeof e!="function"&&(e=co(e));for(var t=this._groups,n=t.length,s=new Array(n),r=0;r<n;++r)for(var i=t[r],a=i.length,c=s[r]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new ze(s,this._parents,this._name,this._id)}function Su(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,r=n.length,i=Math.min(s,r),a=new Array(s),c=0;c<i;++c)for(var l=t[c],f=n[c],h=l.length,d=a[c]=new Array(h),u,p=0;p<h;++p)(u=l[p]||f[p])&&(d[p]=u);for(;c<s;++c)a[c]=t[c];return new ze(a,this._parents,this._name,this._id)}function _u(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Eu(e,t,n){var s,r,i=_u(t)?gs:we;return function(){var a=i(this,e),c=a.on;c!==s&&(r=(s=c).copy()).on(t,n),a.on=r}}function Mu(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(Eu(n,e,t))}function Iu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function $u(){return this.on("end.remove",Iu(this._id))}function Tu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ps(e));for(var s=this._groups,r=s.length,i=new Array(r),a=0;a<r;++a)for(var c=s[a],l=c.length,f=i[a]=new Array(l),h,d,u=0;u<l;++u)(h=c[u])&&(d=e.call(h,h.__data__,u,c))&&("__data__"in h&&(d.__data__=h.__data__),f[u]=d,yn(f[u],t,n,u,f,xe(h,n)));return new ze(i,this._parents,t,n)}function Au(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ao(e));for(var s=this._groups,r=s.length,i=[],a=[],c=0;c<r;++c)for(var l=s[c],f=l.length,h,d=0;d<f;++d)if(h=l[d]){for(var u=e.call(h,h.__data__,d,l),p,x=xe(h,n),y=0,v=u.length;y<v;++y)(p=u[y])&&yn(p,t,n,y,u,x);i.push(u),a.push(h)}return new ze(i,a,t,n)}var Pu=zt.prototype.constructor;function Du(){return new Pu(this._groups,this._parents)}function Lu(e,t){var n,s,r;return function(){var i=Ze(this,e),a=(this.style.removeProperty(e),Ze(this,e));return i===a?null:i===n&&a===s?r:r=t(n=i,s=a)}}function So(e){return function(){this.style.removeProperty(e)}}function Ru(e,t,n){var s,r=n+"",i;return function(){var a=Ze(this,e);return a===r?null:a===s?i:i=t(s=a,n)}}function Ou(e,t,n){var s,r,i;return function(){var a=Ze(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),Ze(this,e))),a===l?null:a===s&&l===r?i:(r=l,i=t(s=a,c))}}function Hu(e,t){var n,s,r,i="style."+t,a="end."+i,c;return function(){var l=we(this,e),f=l.on,h=l.value[i]==null?c||(c=So(t)):void 0;(f!==n||r!==h)&&(s=(n=f).copy()).on(a,r=h),l.on=s}}function Fu(e,t,n){var s=(e+="")=="transform"?oc:ko;return t==null?this.styleTween(e,Lu(e,s)).on("end.style."+e,So(e)):typeof t=="function"?this.styleTween(e,Ou(e,s,bs(this,"style."+e,t))).each(Hu(this._id,e)):this.styleTween(e,Ru(e,s,t),n).on("end.style."+e,null)}function Bu(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Vu(e,t,n){var s,r;function i(){var a=t.apply(this,arguments);return a!==r&&(s=(r=a)&&Bu(e,a,n)),s}return i._value=t,i}function Yu(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Vu(e,t,n??""))}function Gu(e){return function(){this.textContent=e}}function Wu(e){return function(){var t=e(this);this.textContent=t??""}}function Xu(e){return this.tween("text",typeof e=="function"?Wu(bs(this,"text",e)):Gu(e==null?"":e+""))}function qu(e){return function(t){this.textContent=e.call(this,t)}}function Uu(e){var t,n;function s(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&qu(r)),t}return s._value=e,s}function Ku(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Uu(e))}function Zu(){for(var e=this._name,t=this._id,n=_o(),s=this._groups,r=s.length,i=0;i<r;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)if(l=a[f]){var h=xe(l,t);yn(l,e,n,f,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new ze(s,this._parents,e,n)}function Qu(){var e,t,n=this,s=n._id,r=n.size();return new Promise(function(i,a){var c={value:a},l={value:function(){--r===0&&i()}};n.each(function(){var f=we(this,s),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),f.on=t}),r===0&&i()})}var Ju=0;function ze(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function _o(){return++Ju}var Ne=zt.prototype;ze.prototype={constructor:ze,select:Tu,selectAll:Au,selectChild:Ne.selectChild,selectChildren:Ne.selectChildren,filter:ku,merge:Su,selection:Du,transition:Zu,call:Ne.call,nodes:Ne.nodes,node:Ne.node,size:Ne.size,empty:Ne.empty,each:Ne.each,on:Mu,attr:du,attrTween:xu,style:Fu,styleTween:Yu,text:Xu,textTween:Ku,remove:$u,tween:su,delay:bu,duration:vu,ease:ju,easeVarying:zu,end:Qu,[Symbol.iterator]:Ne[Symbol.iterator]};function ef(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tf={time:null,delay:0,duration:250,ease:ef};function nf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function sf(e){var t,n;e instanceof ze?(t=e._id,e=e._name):(t=_o(),(n=tf).time=ms(),e=e==null?null:e+"");for(var s=this._groups,r=s.length,i=0;i<r;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&yn(l,e,t,f,a,n||nf(l,t));return new ze(s,this._parents,e,t)}zt.prototype.interrupt=eu;zt.prototype.transition=sf;const At=e=>()=>e;function rf(e,{sourceEvent:t,target:n,transform:s,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:r}})}function je(e,t,n){this.k=e,this.x=t,this.y=n}je.prototype={constructor:je,scale:function(e){return e===1?this:new je(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new je(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var wn=new je(1,0,0);Eo.prototype=je.prototype;function Eo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wn;return e.__zoom}function $n(e){e.stopImmediatePropagation()}function dt(e){e.preventDefault(),e.stopImmediatePropagation()}function of(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function af(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function qs(){return this.__zoom||wn}function cf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lf(){return navigator.maxTouchPoints||"ontouchstart"in this}function df(e,t,n){var s=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function Mo(){var e=of,t=af,n=df,s=cf,r=lf,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,l=qt,f=mn("start","zoom","end"),h,d,u,p=500,x=150,y=0,v=10;function w(j){j.property("__zoom",qs).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",H).filter(r).on("touchstart.zoom",M).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(j,A,k,I){var E=j.selection?j.selection():j;E.property("__zoom",qs),j!==E?z(j,A,k,I):E.interrupt().each(function(){C(this,arguments).event(I).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},w.scaleBy=function(j,A,k,I){w.scaleTo(j,function(){var E=this.__zoom.k,_=typeof A=="function"?A.apply(this,arguments):A;return E*_},k,I)},w.scaleTo=function(j,A,k,I){w.transform(j,function(){var E=t.apply(this,arguments),_=this.__zoom,R=k==null?m(E):typeof k=="function"?k.apply(this,arguments):k,O=_.invert(R),T=typeof A=="function"?A.apply(this,arguments):A;return n(g(b(_,T),R,O),E,a)},k,I)},w.translateBy=function(j,A,k,I){w.transform(j,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),a)},null,I)},w.translateTo=function(j,A,k,I,E){w.transform(j,function(){var _=t.apply(this,arguments),R=this.__zoom,O=I==null?m(_):typeof I=="function"?I.apply(this,arguments):I;return n(wn.translate(O[0],O[1]).scale(R.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof k=="function"?-k.apply(this,arguments):-k),_,a)},I,E)};function b(j,A){return A=Math.max(i[0],Math.min(i[1],A)),A===j.k?j:new je(A,j.x,j.y)}function g(j,A,k){var I=A[0]-k[0]*j.k,E=A[1]-k[1]*j.k;return I===j.x&&E===j.y?j:new je(j.k,I,E)}function m(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function z(j,A,k,I){j.on("start.zoom",function(){C(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(I).end()}).tween("zoom",function(){var E=this,_=arguments,R=C(E,_).event(I),O=t.apply(E,_),T=k==null?m(O):typeof k=="function"?k.apply(E,_):k,F=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),V=E.__zoom,W=typeof A=="function"?A.apply(E,_):A,Z=l(V.invert(T).concat(F/V.k),W.invert(T).concat(F/W.k));return function(U){if(U===1)U=W;else{var B=Z(U),G=F/B[2];U=new je(G,T[0]-B[0]*G,T[1]-B[1]*G)}R.zoom(null,U)}})}function C(j,A,k){return!k&&j.__zooming||new S(j,A)}function S(j,A){this.that=j,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,A),this.taps=0}S.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,A){return this.mouse&&j!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var A=ae(this.that).datum();f.call(j,this.that,new rf(j,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:f}),A)}};function P(j,...A){if(!e.apply(this,arguments))return;var k=C(this,A).event(j),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,s.apply(this,arguments)))),_=de(j);if(k.wheel)(k.mouse[0][0]!==_[0]||k.mouse[0][1]!==_[1])&&(k.mouse[1]=I.invert(k.mouse[0]=_)),clearTimeout(k.wheel);else{if(I.k===E)return;k.mouse=[_,I.invert(_)],Qt(this),k.start()}dt(j),k.wheel=setTimeout(R,x),k.zoom("mouse",n(g(b(I,E),k.mouse[0],k.mouse[1]),k.extent,a));function R(){k.wheel=null,k.end()}}function D(j,...A){if(u||!e.apply(this,arguments))return;var k=j.currentTarget,I=C(this,A,!0).event(j),E=ae(j.view).on("mousemove.zoom",T,!0).on("mouseup.zoom",F,!0),_=de(j,k),R=j.clientX,O=j.clientY;yo(j.view),$n(j),I.mouse=[_,this.__zoom.invert(_)],Qt(this),I.start();function T(V){if(dt(V),!I.moved){var W=V.clientX-R,Z=V.clientY-O;I.moved=W*W+Z*Z>y}I.event(V).zoom("mouse",n(g(I.that.__zoom,I.mouse[0]=de(V,k),I.mouse[1]),I.extent,a))}function F(V){E.on("mousemove.zoom mouseup.zoom",null),wo(V.view,I.moved),dt(V),I.event(V).end()}}function H(j,...A){if(e.apply(this,arguments)){var k=this.__zoom,I=de(j.changedTouches?j.changedTouches[0]:j,this),E=k.invert(I),_=k.k*(j.shiftKey?.5:2),R=n(g(b(k,_),I,E),t.apply(this,A),a);dt(j),c>0?ae(this).transition().duration(c).call(z,R,I,j):ae(this).call(w.transform,R,I,j)}}function M(j,...A){if(e.apply(this,arguments)){var k=j.touches,I=k.length,E=C(this,A,j.changedTouches.length===I).event(j),_,R,O,T;for($n(j),R=0;R<I;++R)O=k[R],T=de(O,this),T=[T,this.__zoom.invert(T),O.identifier],E.touch0?!E.touch1&&E.touch0[2]!==T[2]&&(E.touch1=T,E.taps=0):(E.touch0=T,_=!0,E.taps=1+!!h);h&&(h=clearTimeout(h)),_&&(E.taps<2&&(d=T[0],h=setTimeout(function(){h=null},p)),Qt(this),E.start())}}function $(j,...A){if(this.__zooming){var k=C(this,A).event(j),I=j.changedTouches,E=I.length,_,R,O,T;for(dt(j),_=0;_<E;++_)R=I[_],O=de(R,this),k.touch0&&k.touch0[2]===R.identifier?k.touch0[0]=O:k.touch1&&k.touch1[2]===R.identifier&&(k.touch1[0]=O);if(R=k.that.__zoom,k.touch1){var F=k.touch0[0],V=k.touch0[1],W=k.touch1[0],Z=k.touch1[1],U=(U=W[0]-F[0])*U+(U=W[1]-F[1])*U,B=(B=Z[0]-V[0])*B+(B=Z[1]-V[1])*B;R=b(R,Math.sqrt(U/B)),O=[(F[0]+W[0])/2,(F[1]+W[1])/2],T=[(V[0]+Z[0])/2,(V[1]+Z[1])/2]}else if(k.touch0)O=k.touch0[0],T=k.touch0[1];else return;k.zoom("touch",n(g(R,O,T),k.extent,a))}}function L(j,...A){if(this.__zooming){var k=C(this,A).event(j),I=j.changedTouches,E=I.length,_,R;for($n(j),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),_=0;_<E;++_)R=I[_],k.touch0&&k.touch0[2]===R.identifier?delete k.touch0:k.touch1&&k.touch1[2]===R.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(R=de(R,this),Math.hypot(d[0]-R[0],d[1]-R[1])<v)){var O=ae(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return w.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:At(+j),w):s},w.filter=function(j){return arguments.length?(e=typeof j=="function"?j:At(!!j),w):e},w.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:At(!!j),w):r},w.extent=function(j){return arguments.length?(t=typeof j=="function"?j:At([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),w):t},w.scaleExtent=function(j){return arguments.length?(i[0]=+j[0],i[1]=+j[1],w):[i[0],i[1]]},w.translateExtent=function(j){return arguments.length?(a[0][0]=+j[0][0],a[1][0]=+j[1][0],a[0][1]=+j[0][1],a[1][1]=+j[1][1],w):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},w.constrain=function(j){return arguments.length?(n=j,w):n},w.duration=function(j){return arguments.length?(c=+j,w):c},w.interpolate=function(j){return arguments.length?(l=j,w):l},w.on=function(){var j=f.on.apply(f,arguments);return j===f?w:j},w.clickDistance=function(j){return arguments.length?(y=(j=+j)*j,w):Math.sqrt(y)},w.tapDistance=function(j){return arguments.length?(v=+j,w):v},w}const ge={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},yt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Io=["Enter"," ","Escape"],$o={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Je;(function(e){e.Strict="strict",e.Loose="loose"})(Je||(Je={}));var De;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(De||(De={}));var wt;(function(e){e.Partial="partial",e.Full="full"})(wt||(wt={}));const To={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var an;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(an||(an={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const Us={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Ao(e){return e===null?null:e?"valid":"invalid"}const Po=e=>"id"in e&&"source"in e&&"target"in e,uf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ys=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:s}=ke(e),r=e.origin??t,i=n*r[0],a=s*r[1];return{x:e.position.x-i,y:e.position.y-a}},ff=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,r)=>{const i=typeof r=="string";let a=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(r):ys(r)?r:t.nodeLookup.get(r.id));const c=a?cn(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return vn(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Nn(n)},St=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=vn(n,cn(r)),s=!0)}),s?Nn(n):{x:0,y:0,width:0,height:0}},ws=(e,t,[n,s,r]=[0,0,1],i=!1,a=!1)=>{const c={...Et(t,[n,s,r]),width:t.width/r,height:t.height/r},l=[];for(const f of e.values()){const{measured:h,selectable:d=!0,hidden:u=!1}=f;if(a&&!d||u)continue;const p=h.width??f.width??f.initialWidth??null,x=h.height??f.height??f.initialHeight??null,y=vt(c,tt(f)),v=(p??0)*(x??0),w=i&&y>0;(!f.internals.handleBounds||w||y>=v||f.dragging)&&l.push(f)}return l},hf=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function pf(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!s||s.has(r.id))&&n.set(r.id,r)}),n}async function xf({nodes:e,width:t,height:n,panZoom:s,minZoom:r,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const c=pf(e,a),l=St(c),f=vs(l,t,n,(a==null?void 0:a.minZoom)??r,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await s.setViewport(f,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function Do({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:r,onError:i}){const a=n.get(e),c=a.parentId?n.get(a.parentId):void 0,{x:l,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??s;let d=a.extent||r;if(a.extent==="parent"&&!a.expandParent)if(!c)i==null||i("005",ge.error005());else{const p=c.measured.width,x=c.measured.height;p&&x&&(d=[[l,f],[l+p,f+x]])}else c&&nt(a.extent)&&(d=[[a.extent[0][0]+l,a.extent[0][1]+f],[a.extent[1][0]+l,a.extent[1][1]+f]]);const u=nt(d)?Oe(t,d,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",ge.error015())),{position:{x:u.x-l+(a.measured.width??0)*h[0],y:u.y-f+(a.measured.height??0)*h[1]},positionAbsolute:u}}async function mf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:r}){const i=new Set(e.map(u=>u.id)),a=[];for(const u of n){if(u.deletable===!1)continue;const p=i.has(u.id),x=!p&&u.parentId&&a.find(y=>y.id===u.parentId);(p||x)&&a.push(u)}const c=new Set(t.map(u=>u.id)),l=s.filter(u=>u.deletable!==!1),h=hf(a,l);for(const u of l)c.has(u.id)&&!h.find(x=>x.id===u.id)&&h.push(u);if(!r)return{edges:h,nodes:a};const d=await r({nodes:a,edges:h});return typeof d=="boolean"?d?{edges:h,nodes:a}:{edges:[],nodes:[]}:d}const et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oe=(e={x:0,y:0},t,n)=>({x:et(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:et(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Lo(e,t,n){const{width:s,height:r}=ke(n),{x:i,y:a}=n.internals.positionAbsolute;return Oe(e,[[i,a],[i+s,a+r]],t)}const Ks=(e,t,n)=>e<t?et(Math.abs(e-t),1,t)/t:e>n?-et(Math.abs(e-n),1,t)/t:0,Ro=(e,t,n=15,s=40)=>{const r=Ks(e.x,s,t.width-s)*n,i=Ks(e.y,s,t.height-s)*n;return[r,i]},vn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Qn=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),Nn=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),tt=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ys(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},cn=(e,t=[0,0])=>{var r,i;const{x:n,y:s}=ys(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Oo=(e,t)=>Nn(vn(Qn(e),Qn(t))),vt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},Zs=e=>fe(e.width)&&fe(e.height)&&fe(e.x)&&fe(e.y),fe=e=>!isNaN(e)&&isFinite(e),gf=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,s,r],i=!1,a=[1,1])=>{const c={x:(e-n)/r,y:(t-s)/r};return i?_t(c,a):c},ln=({x:e,y:t},[n,s,r])=>({x:e*r+n,y:t*r+s});function Be(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function bf(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Be(e,n),r=Be(e,t);return{top:s,right:r,bottom:s,left:r,x:r*2,y:s*2}}if(typeof e=="object"){const s=Be(e.top??e.y??0,n),r=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),a=Be(e.right??e.x??0,t);return{top:s,right:a,bottom:r,left:i,x:i+a,y:s+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function yf(e,t,n,s,r,i){const{x:a,y:c}=ln(e,[t,n,s]),{x:l,y:f}=ln({x:e.x+e.width,y:e.y+e.height},[t,n,s]),h=r-l,d=i-f;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(d)}}const vs=(e,t,n,s,r,i)=>{const a=bf(i,t,n),c=(t-a.x)/e.width,l=(n-a.y)/e.height,f=Math.min(c,l),h=et(f,s,r),d=e.x+e.width/2,u=e.y+e.height/2,p=t/2-d*h,x=n/2-u*h,y=yf(e,p,x,h,t,n),v={left:Math.min(y.left-a.left,0),top:Math.min(y.top-a.top,0),right:Math.min(y.right-a.right,0),bottom:Math.min(y.bottom-a.bottom,0)};return{x:p-v.left+v.right,y:x-v.top+v.bottom,zoom:h}},Nt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function nt(e){return e!=null&&e!=="parent"}function ke(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Ho(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Fo(e,t={width:0,height:0},n,s,r){const i={...e},a=s.get(n);if(a){const c=a.origin||r;i.x+=a.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Qs(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function wf(){let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}}function vf(e){return{...$o,...e||{}}}function mt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:r}){const{x:i,y:a}=he(e),c=Et({x:i-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)},s),{x:l,y:f}=n?_t(c,t):c;return{xSnapped:l,ySnapped:f,...c}}const Ns=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bo=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Nf=["INPUT","SELECT","TEXTAREA"];function Vo(e){var s,r;const t=((r=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Nf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Yo=e=>"clientX"in e,he=(e,t)=>{var i,a;const n=Yo(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,r=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Js=(e,t,n,s,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:r,position:a.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Ns(a)}})};function Go({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:c}){const l=e*.125+r*.375+a*.375+n*.125,f=t*.125+i*.375+c*.375+s*.125,h=Math.abs(l-e),d=Math.abs(f-t);return[l,f,h,d]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function er({pos:e,x1:t,y1:n,x2:s,y2:r,c:i}){switch(e){case Y.Left:return[t-Pt(t-s,i),n];case Y.Right:return[t+Pt(s-t,i),n];case Y.Top:return[t,n-Pt(n-r,i)];case Y.Bottom:return[t,n+Pt(r-n,i)]}}function Wo({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:s,targetY:r,targetPosition:i=Y.Top,curvature:a=.25}){const[c,l]=er({pos:n,x1:e,y1:t,x2:s,y2:r,c:a}),[f,h]=er({pos:i,x1:s,y1:r,x2:e,y2:t,c:a}),[d,u,p,x]=Go({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:c,sourceControlY:l,targetControlX:f,targetControlY:h});return[`M${e},${t} C${c},${l} ${f},${h} ${s},${r}`,d,u,p,x]}function Xo({sourceX:e,sourceY:t,targetX:n,targetY:s}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,a=Math.abs(s-t)/2,c=s<t?s+a:s-a;return[i,c,r,a]}function jf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return s;const a=r&&n?s+1e3:s,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return a+c}function Cf({sourceNode:e,targetNode:t,width:n,height:s,transform:r}){const i=vn(cn(e),cn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:s/r[2]};return vt(a,Nn(i))>0}const zf=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,kf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Sf=(e,t,n={})=>{if(!e.source||!e.target)return t;const s=n.getEdgeId||zf;let r;return Po(e)?r={...e}:r={...e,id:s(e)},kf(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function qo({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[r,i,a,c]=Xo({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,r,i,a,c]}const tr={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},_f=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ef({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:s=Y.Top,center:r,offset:i,stepPosition:a}){const c=tr[t],l=tr[s],f={x:e.x+c.x*i,y:e.y+c.y*i},h={x:n.x+l.x*i,y:n.y+l.y*i},d=_f({source:f,sourcePosition:t,target:h}),u=d.x!==0?"x":"y",p=d[u];let x=[],y,v;const w={x:0,y:0},b={x:0,y:0},[,,g,m]=Xo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[u]*l[u]===-1){u==="x"?(y=r.x??f.x+(h.x-f.x)*a,v=r.y??(f.y+h.y)/2):(y=r.x??(f.x+h.x)/2,v=r.y??f.y+(h.y-f.y)*a);const C=[{x:y,y:f.y},{x:y,y:h.y}],S=[{x:f.x,y:v},{x:h.x,y:v}];c[u]===p?x=u==="x"?C:S:x=u==="x"?S:C}else{const C=[{x:f.x,y:h.y}],S=[{x:h.x,y:f.y}];if(u==="x"?x=c.x===p?S:C:x=c.y===p?C:S,t===s){const $=Math.abs(e[u]-n[u]);if($<=i){const L=Math.min(i-1,i-$);c[u]===p?w[u]=(f[u]>e[u]?-1:1)*L:b[u]=(h[u]>n[u]?-1:1)*L}}if(t!==s){const $=u==="x"?"y":"x",L=c[u]===l[$],j=f[$]>h[$],A=f[$]<h[$];(c[u]===1&&(!L&&j||L&&A)||c[u]!==1&&(!L&&A||L&&j))&&(x=u==="x"?C:S)}const P={x:f.x+w.x,y:f.y+w.y},D={x:h.x+b.x,y:h.y+b.y},H=Math.max(Math.abs(P.x-x[0].x),Math.abs(D.x-x[0].x)),M=Math.max(Math.abs(P.y-x[0].y),Math.abs(D.y-x[0].y));H>=M?(y=(P.x+D.x)/2,v=x[0].y):(y=x[0].x,v=(P.y+D.y)/2)}return[[e,{x:f.x+w.x,y:f.y+w.y},...x,{x:h.x+b.x,y:h.y+b.y},n],y,v,g,m]}function Mf(e,t,n,s){const r=Math.min(nr(e,t)/2,nr(t,n)/2,s),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${i+r*f},${a}Q ${i},${a} ${i},${a+r*h}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${a+r*l}Q ${i},${a} ${i+r*c},${a}`}function dn({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:s,targetY:r,targetPosition:i=Y.Top,borderRadius:a=5,centerX:c,centerY:l,offset:f=20,stepPosition:h=.5}){const[d,u,p,x,y]=Ef({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:r},targetPosition:i,center:{x:c,y:l},offset:f,stepPosition:h});return[d.reduce((w,b,g)=>{let m="";return g>0&&g<d.length-1?m=Mf(d[g-1],b,d[g+1],a):m=`${g===0?"M":"L"}${b.x} ${b.y}`,w+=m,w},""),u,p,x,y]}function sr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function If(e){var d;const{sourceNode:t,targetNode:n}=e;if(!sr(t)||!sr(n))return null;const s=t.internals.handleBounds||rr(t.handles),r=n.internals.handleBounds||rr(n.handles),i=or((s==null?void 0:s.source)??[],e.sourceHandle),a=or(e.connectionMode===Je.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!i||!a)return(d=e.onError)==null||d.call(e,"008",ge.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||Y.Bottom,l=(a==null?void 0:a.position)||Y.Top,f=He(t,i,c),h=He(n,a,l);return{sourceX:f.x,sourceY:f.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:l}}function rr(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function He(e,t,n=Y.Left,s=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:c}=t??ke(e);if(s)return{x:r+a/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+a/2,y:i};case Y.Right:return{x:r+a,y:i+c/2};case Y.Bottom:return{x:r+a/2,y:i+c};case Y.Left:return{x:r,y:i+c/2}}}function or(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Jn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function $f(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:r}){const i=new Set;return e.reduce((a,c)=>([c.markerStart||s,c.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const f=Jn(l,t);i.has(f)||(a.push({id:f,color:l.color||n,...l}),i.add(f))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const Uo=1e3,Tf=10,js={nodeOrigin:[0,0],nodeExtent:yt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Af={...js,checkEquality:!0};function Cs(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function Pf(e,t,n){const s=Cs(js,n);for(const r of e.values())if(r.parentId)ks(r,e,t,s);else{const i=kt(r,s.nodeOrigin),a=nt(r.extent)?r.extent:s.nodeExtent,c=Oe(i,a,ke(r));r.internals.positionAbsolute=c}}function Df(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],s=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&s.push(i)}return{source:n,target:s}}function zs(e){return e==="manual"}function es(e,t,n,s={}){var f,h;const r=Cs(Af,s),i={i:0},a=new Map(t),c=r!=null&&r.elevateNodesOnSelect&&!zs(r.zIndexMode)?Uo:0;let l=e.length>0;t.clear(),n.clear();for(const d of e){let u=a.get(d.id);if(r.checkEquality&&d===(u==null?void 0:u.internals.userNode))t.set(d.id,u);else{const p=kt(d,r.nodeOrigin),x=nt(d.extent)?d.extent:r.nodeExtent,y=Oe(p,x,ke(d));u={...r.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(h=d.measured)==null?void 0:h.height},internals:{positionAbsolute:y,handleBounds:Df(d,u),z:Ko(d,c,r.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&ks(u,t,n,s,i)}return l}function Lf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function ks(e,t,n,s,r){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:c,zIndexMode:l}=Cs(js,s),f=e.parentId,h=t.get(f);if(!h){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Lf(e,n),r&&!h.parentId&&h.internals.rootParentIndex===void 0&&l==="auto"&&(h.internals.rootParentIndex=++r.i,h.internals.z=h.internals.z+r.i*Tf),r&&h.internals.rootParentIndex!==void 0&&(r.i=h.internals.rootParentIndex);const d=i&&!zs(l)?Uo:0,{x:u,y:p,z:x}=Rf(e,h,a,c,d,l),{positionAbsolute:y}=e.internals,v=u!==y.x||p!==y.y;(v||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:u,y:p}:y,z:x}})}function Ko(e,t,n){const s=fe(e.zIndex)?e.zIndex:0;return zs(n)?s:s+(e.selected?t:0)}function Rf(e,t,n,s,r,i){const{x:a,y:c}=t.internals.positionAbsolute,l=ke(e),f=kt(e,n),h=nt(e.extent)?Oe(f,e.extent,l):f;let d=Oe({x:a+h.x,y:c+h.y},s,l);e.extent==="parent"&&(d=Lo(d,l,t));const u=Ko(e,r,i),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}function Ss(e,t,n,s=[0,0]){var a;const r=[],i=new Map;for(const c of e){const l=t.get(c.parentId);if(!l)continue;const f=((a=i.get(c.parentId))==null?void 0:a.expandedRect)??tt(l),h=Oo(f,c.rect);i.set(c.parentId,{expandedRect:h,parent:l})}return i.size>0&&i.forEach(({expandedRect:c,parent:l},f)=>{var g;const h=l.internals.positionAbsolute,d=ke(l),u=l.origin??s,p=c.x<h.x?Math.round(Math.abs(h.x-c.x)):0,x=c.y<h.y?Math.round(Math.abs(h.y-c.y)):0,y=Math.max(d.width,Math.round(c.width)),v=Math.max(d.height,Math.round(c.height)),w=(y-d.width)*u[0],b=(v-d.height)*u[1];(p>0||x>0||w||b)&&(r.push({id:f,type:"position",position:{x:l.position.x-p+w,y:l.position.y-x+b}}),(g=n.get(f))==null||g.forEach(m=>{e.some(z=>z.id===m.id)||r.push({id:m.id,type:"position",position:{x:m.position.x+p,y:m.position.y+x}})})),(d.width<c.width||d.height<c.height||p||x)&&r.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:y+(p?u[0]*p-w:0),height:v+(x?u[1]*x-b:0)}})}),r}function Of(e,t,n,s,r,i,a){const c=s==null?void 0:s.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const f=[],h=window.getComputedStyle(c),{m22:d}=new window.DOMMatrixReadOnly(h.transform),u=[];for(const p of e.values()){const x=t.get(p.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),l=!0;continue}const y=Ns(p.nodeElement),v=x.measured.width!==y.width||x.measured.height!==y.height;if(!!(y.width&&y.height&&(v||!x.internals.handleBounds||p.force))){const b=p.nodeElement.getBoundingClientRect(),g=nt(x.extent)?x.extent:i;let{positionAbsolute:m}=x.internals;x.parentId&&x.extent==="parent"?m=Lo(m,y,t.get(x.parentId)):g&&(m=Oe(m,g,y));const z={...x,measured:y,internals:{...x.internals,positionAbsolute:m,handleBounds:{source:Js("source",p.nodeElement,b,d,x.id),target:Js("target",p.nodeElement,b,d,x.id)}}};t.set(x.id,z),x.parentId&&ks(z,t,n,{nodeOrigin:r,zIndexMode:a}),l=!0,v&&(f.push({id:x.id,type:"dimensions",dimensions:y}),x.expandParent&&x.parentId&&u.push({id:x.id,parentId:x.parentId,rect:tt(z,r)}))}}if(u.length>0){const p=Ss(u,t,n,r);f.push(...p)}return{changes:f,updatedInternals:l}}async function Hf({delta:e,panZoom:t,transform:n,translateExtent:s,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],s),c=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(c)}function ir(e,t,n,s,r,i){let a=r;const c=s.get(a)||new Map;s.set(a,c.set(n,t)),a=`${r}-${e}`;const l=s.get(a)||new Map;if(s.set(a,l.set(n,t)),i){a=`${r}-${e}-${i}`;const f=s.get(a)||new Map;s.set(a,f.set(n,t))}}function Zo(e,t,n){e.clear(),t.clear();for(const s of n){const{source:r,target:i,sourceHandle:a=null,targetHandle:c=null}=s,l={edgeId:s.id,source:r,target:i,sourceHandle:a,targetHandle:c},f=`${r}-${a}--${i}-${c}`,h=`${i}-${c}--${r}-${a}`;ir("source",l,h,e,r,a),ir("target",l,f,e,i,c),t.set(s.id,s)}}function Qo(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Qo(n,t):!1}function ar(e,t,n){var r;let s=e;do{if((r=s==null?void 0:s.matches)!=null&&r.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function Ff(e,t,n,s){const r=new Map;for(const[i,a]of e)if((a.selected||a.id===s)&&(!a.parentId||!Qo(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function Tn({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var a,c,l;const r=[];for(const[f,h]of t){const d=(a=n.get(f))==null?void 0:a.internals.userNode;d&&r.push({...d,position:h.position,dragging:s})}if(!e)return[r[0],r];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((l=t.get(e))==null?void 0:l.position)||i.position,dragging:s}:r[0],r]}function Bf({dragItems:e,snapGrid:t,x:n,y:s}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:s-r.distance.y},a=_t(i,t);return{x:a.x-i.x,y:a.y-i.y}}function Vf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:r}){let i={x:null,y:null},a=0,c=new Map,l=!1,f={x:0,y:0},h=null,d=!1,u=null,p=!1,x=!1,y=null;function v({noDragClassName:b,handleSelector:g,domNode:m,isSelectable:z,nodeId:C,nodeClickDistance:S=0}){u=ae(m);function P({x:$,y:L}){const{nodeLookup:j,nodeExtent:A,snapGrid:k,snapToGrid:I,nodeOrigin:E,onNodeDrag:_,onSelectionDrag:R,onError:O,updateNodePositions:T}=t();i={x:$,y:L};let F=!1;const V=c.size>1,W=V&&A?Qn(St(c)):null,Z=V&&I?Bf({dragItems:c,snapGrid:k,x:$,y:L}):null;for(const[U,B]of c){if(!j.has(U))continue;let G={x:$-B.distance.x,y:L-B.distance.y};I&&(G=Z?{x:Math.round(G.x+Z.x),y:Math.round(G.y+Z.y)}:_t(G,k));let X=null;if(V&&A&&!B.extent&&W){const{positionAbsolute:q}=B.internals,ee=q.x-W.x+A[0][0],ne=q.x+B.measured.width-W.x2+A[1][0],te=q.y-W.y+A[0][1],ie=q.y+B.measured.height-W.y2+A[1][1];X=[[ee,te],[ne,ie]]}const{position:Q,positionAbsolute:K}=Do({nodeId:U,nextPosition:G,nodeLookup:j,nodeExtent:X||A,nodeOrigin:E,onError:O});F=F||B.position.x!==Q.x||B.position.y!==Q.y,B.position=Q,B.internals.positionAbsolute=K}if(x=x||F,!!F&&(T(c,!0),y&&(s||_||!C&&R))){const[U,B]=Tn({nodeId:C,dragItems:c,nodeLookup:j});s==null||s(y,c,U,B),_==null||_(y,U,B),C||R==null||R(y,B)}}async function D(){if(!h)return;const{transform:$,panBy:L,autoPanSpeed:j,autoPanOnNodeDrag:A}=t();if(!A){l=!1,cancelAnimationFrame(a);return}const[k,I]=Ro(f,h,j);(k!==0||I!==0)&&(i.x=(i.x??0)-k/$[2],i.y=(i.y??0)-I/$[2],await L({x:k,y:I})&&P(i)),a=requestAnimationFrame(D)}function H($){var V;const{nodeLookup:L,multiSelectionActive:j,nodesDraggable:A,transform:k,snapGrid:I,snapToGrid:E,selectNodesOnDrag:_,onNodeDragStart:R,onSelectionDragStart:O,unselectNodesAndEdges:T}=t();d=!0,(!_||!z)&&!j&&C&&((V=L.get(C))!=null&&V.selected||T()),z&&_&&C&&(e==null||e(C));const F=mt($.sourceEvent,{transform:k,snapGrid:I,snapToGrid:E,containerBounds:h});if(i=F,c=Ff(L,A,F,C),c.size>0&&(n||R||!C&&O)){const[W,Z]=Tn({nodeId:C,dragItems:c,nodeLookup:L});n==null||n($.sourceEvent,c,W,Z),R==null||R($.sourceEvent,W,Z),C||O==null||O($.sourceEvent,Z)}}const M=vo().clickDistance(S).on("start",$=>{const{domNode:L,nodeDragThreshold:j,transform:A,snapGrid:k,snapToGrid:I}=t();h=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,x=!1,y=$.sourceEvent,j===0&&H($),i=mt($.sourceEvent,{transform:A,snapGrid:k,snapToGrid:I,containerBounds:h}),f=he($.sourceEvent,h)}).on("drag",$=>{const{autoPanOnNodeDrag:L,transform:j,snapGrid:A,snapToGrid:k,nodeDragThreshold:I,nodeLookup:E}=t(),_=mt($.sourceEvent,{transform:j,snapGrid:A,snapToGrid:k,containerBounds:h});if(y=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||C&&!E.has(C))&&(p=!0),!p){if(!l&&L&&d&&(l=!0,D()),!d){const R=he($.sourceEvent,h),O=R.x-f.x,T=R.y-f.y;Math.sqrt(O*O+T*T)>I&&H($)}(i.x!==_.xSnapped||i.y!==_.ySnapped)&&c&&d&&(f=he($.sourceEvent,h),P(_))}}).on("end",$=>{if(!(!d||p)&&(l=!1,d=!1,cancelAnimationFrame(a),c.size>0)){const{nodeLookup:L,updateNodePositions:j,onNodeDragStop:A,onSelectionDragStop:k}=t();if(x&&(j(c,!1),x=!1),r||A||!C&&k){const[I,E]=Tn({nodeId:C,dragItems:c,nodeLookup:L,dragging:!1});r==null||r($.sourceEvent,c,I,E),A==null||A($.sourceEvent,I,E),C||k==null||k($.sourceEvent,E)}}}).filter($=>{const L=$.target;return!$.button&&(!b||!ar(L,`.${b}`,m))&&(!g||ar(L,g,m))});u.call(M)}function w(){u==null||u.on(".drag",null)}return{update:v,destroy:w}}function Yf(e,t,n){const s=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())vt(r,tt(i))>0&&s.push(i);return s}const Gf=250;function Wf(e,t,n,s){var c,l;let r=[],i=1/0;const a=Yf(e,n,t+Gf);for(const f of a){const h=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((l=f.internals.handleBounds)==null?void 0:l.target)??[]];for(const d of h){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:p}=He(f,d,d.position,!0),x=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));x>t||(x<i?(r=[{...d,x:u,y:p}],i=x):x===i&&r.push({...d,x:u,y:p}))}}if(!r.length)return null;if(r.length>1){const f=s.type==="source"?"target":"source";return r.find(h=>h.type===f)??r[0]}return r[0]}function Jo(e,t,n,s,r,i=!1){var f,h,d;const a=s.get(e);if(!a)return null;const c=r==="strict"?(f=a.internals.handleBounds)==null?void 0:f[t]:[...((h=a.internals.handleBounds)==null?void 0:h.source)??[],...((d=a.internals.handleBounds)==null?void 0:d.target)??[]],l=(n?c==null?void 0:c.find(u=>u.id===n):c==null?void 0:c[0])??null;return l&&i?{...l,...He(a,l,l.position,!0)}:l}function ei(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Xf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ti=()=>!0;function qf(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:r,edgeUpdaterType:i,isTarget:a,domNode:c,nodeLookup:l,lib:f,autoPanOnConnect:h,flowId:d,panBy:u,cancelConnection:p,onConnectStart:x,onConnect:y,onConnectEnd:v,isValidConnection:w=ti,onReconnectEnd:b,updateConnection:g,getTransform:m,getFromHandle:z,autoPanSpeed:C,dragThreshold:S=1,handleDomNode:P}){const D=Bo(e.target);let H=0,M;const{x:$,y:L}=he(e),j=ei(i,P),A=c==null?void 0:c.getBoundingClientRect();let k=!1;if(!A||!j)return;const I=Jo(r,j,s,l,t);if(!I)return;let E=he(e,A),_=!1,R=null,O=!1,T=null;function F(){if(!h||!A)return;const[Q,K]=Ro(E,A,C);u({x:Q,y:K}),H=requestAnimationFrame(F)}const V={...I,nodeId:r,type:j,position:I.position},W=l.get(r);let U={inProgress:!0,isValid:null,from:He(W,V,Y.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:W,to:E,toHandle:null,toPosition:Us[V.position],toNode:null,pointer:E};function B(){k=!0,g(U),x==null||x(e,{nodeId:r,handleId:s,handleType:j})}S===0&&B();function G(Q){if(!k){const{x:ie,y:Se}=he(Q),ve=ie-$,Ae=Se-L;if(!(ve*ve+Ae*Ae>S*S))return;B()}if(!z()||!V){X(Q);return}const K=m();E=he(Q,A),M=Wf(Et(E,K,!1,[1,1]),n,l,V),_||(F(),_=!0);const q=ni(Q,{handle:M,connectionMode:t,fromNodeId:r,fromHandleId:s,fromType:a?"target":"source",isValidConnection:w,doc:D,lib:f,flowId:d,nodeLookup:l});T=q.handleDomNode,R=q.connection,O=Xf(!!M,q.isValid);const ee=l.get(r),ne=ee?He(ee,V,Y.Left,!0):U.from,te={...U,from:ne,isValid:O,to:q.toHandle&&O?ln({x:q.toHandle.x,y:q.toHandle.y},K):E,toHandle:q.toHandle,toPosition:O&&q.toHandle?q.toHandle.position:Us[V.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:E};g(te),U=te}function X(Q){if(!("touches"in Q&&Q.touches.length>0)){if(k){(M||T)&&R&&O&&(y==null||y(R));const{inProgress:K,...q}=U,ee={...q,toPosition:U.toHandle?U.toPosition:null};v==null||v(Q,ee),i&&(b==null||b(Q,ee))}p(),cancelAnimationFrame(H),_=!1,O=!1,R=null,T=null,D.removeEventListener("mousemove",G),D.removeEventListener("mouseup",X),D.removeEventListener("touchmove",G),D.removeEventListener("touchend",X)}}D.addEventListener("mousemove",G),D.addEventListener("mouseup",X),D.addEventListener("touchmove",G),D.addEventListener("touchend",X)}function ni(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:r,fromType:i,doc:a,lib:c,flowId:l,isValidConnection:f=ti,nodeLookup:h}){const d=i==="target",u=t?a.querySelector(`.${c}-flow__handle[data-id="${l}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:x}=he(e),y=a.elementFromPoint(p,x),v=y!=null&&y.classList.contains(`${c}-flow__handle`)?y:u,w={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const b=ei(void 0,v),g=v.getAttribute("data-nodeid"),m=v.getAttribute("data-handleid"),z=v.classList.contains("connectable"),C=v.classList.contains("connectableend");if(!g||!b)return w;const S={source:d?g:s,sourceHandle:d?m:r,target:d?s:g,targetHandle:d?r:m};w.connection=S;const D=z&&C&&(n===Je.Strict?d&&b==="source"||!d&&b==="target":g!==s||m!==r);w.isValid=D&&f(S),w.toHandle=Jo(g,b,m,h,n,!0)}return w}const ts={onPointerDown:qf,isValid:ni};function Uf({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const r=ae(e);function i({translateExtent:c,width:l,height:f,zoomStep:h=1,pannable:d=!0,zoomable:u=!0,inversePan:p=!1}){const x=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const m=n(),z=g.sourceEvent.ctrlKey&&Nt()?10:1,C=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,S=m[2]*Math.pow(2,C*z);t.scaleTo(S)};let y=[0,0];const v=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(y=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},w=g=>{const m=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const z=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],C=[z[0]-y[0],z[1]-y[1]];y=z;const S=s()*Math.max(m[2],Math.log(m[2]))*(p?-1:1),P={x:m[0]-C[0]*S,y:m[1]-C[1]*S},D=[[0,0],[l,f]];t.setViewportConstrained({x:P.x,y:P.y,zoom:m[2]},D,c)},b=Mo().on("start",v).on("zoom",d?w:null).on("zoom.wheel",u?x:null);r.call(b,{})}function a(){r.on("zoom",null)}return{update:i,destroy:a,pointer:de}}const jn=e=>({x:e.x,y:e.y,zoom:e.k}),An=({x:e,y:t,zoom:n})=>wn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),si=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Pn=(e,t=0,n=Kf,s=()=>{})=>{const r=typeof t=="number"&&t>0;return r||s(),r?e.transition().duration(t).ease(n).on("end",s):e},ri=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Zf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:f}){return h=>{if(Xe(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(h.ctrlKey&&a){const v=de(h),w=ri(h),b=d*Math.pow(2,w);s.scaleTo(n,b,v,h);return}const u=h.deltaMode===1?20:1;let p=r===De.Vertical?0:h.deltaX*u,x=r===De.Horizontal?0:h.deltaY*u;!Nt()&&h.shiftKey&&r!==De.Vertical&&(p=h.deltaY*u,x=0),s.translateBy(n,-(p/d)*i,-(x/d)*i,{internal:!0});const y=jn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l==null||l(h,y),e.panScrollTimeout=setTimeout(()=>{f==null||f(h,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(h,y))}}function Qf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,r){const i=s.type==="wheel",a=!t&&i&&!s.ctrlKey,c=Xe(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),a||c)return null;s.preventDefault(),n.call(this,s,r)}}function Jf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,a,c;if((i=s.sourceEvent)!=null&&i.internal)return;const r=jn(s.transform);e.mouseButton=((a=s.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,r))}}function eh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:r}){return i=>{var a,c;e.usedRightMouseButton=!!(n&&si(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||s([i.transform.x,i.transform.y,i.transform.k]),r&&!((c=i.sourceEvent)!=null&&c.internal)&&(r==null||r(i.sourceEvent,jn(i.transform)))}}function th({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:r,onPaneContextMenu:i}){return a=>{var c;if(!((c=a.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&si(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,s(!1),r)){const l=jn(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(a.sourceEvent,l)},n?150:0)}}}function nh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:f,connectionInProgress:h}){return d=>{var v;const u=e||t,p=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${f}-flow__node`)||Xe(d,`${f}-flow__edge`)))return!0;if(!s&&!u&&!r&&!i&&!n||a||h&&!x||Xe(d,c)&&x||Xe(d,l)&&(!x||r&&x&&!e)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((v=d.touches)==null?void 0:v.length)>1)return d.preventDefault(),!1;if(!u&&!r&&!p&&x||!s&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(s)&&!s.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&y}}function sh({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:r,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),d=Mo().scaleExtent([t,n]).translateExtent(s),u=ae(e).call(d);b({x:r.x,y:r.y,zoom:et(r.zoom,t,n)},[[0,0],[h.width,h.height]],s);const p=u.on("wheel.zoom"),x=u.on("dblclick.zoom");d.wheelDelta(ri);function y(M,$){return u?new Promise(L=>{d==null||d.interpolate(($==null?void 0:$.interpolate)==="linear"?Mn:qt).transform(Pn(u,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>L(!0)),M)}):Promise.resolve(!1)}function v({noWheelClassName:M,noPanClassName:$,onPaneContextMenu:L,userSelectionActive:j,panOnScroll:A,panOnDrag:k,panOnScrollMode:I,panOnScrollSpeed:E,preventScrolling:_,zoomOnPinch:R,zoomOnScroll:O,zoomOnDoubleClick:T,zoomActivationKeyPressed:F,lib:V,onTransformChange:W,connectionInProgress:Z,paneClickDistance:U,selectionOnDrag:B}){j&&!f.isZoomingOrPanning&&w();const G=A&&!F&&!j;d.clickDistance(B?1/0:!fe(U)||U<0?0:U);const X=G?Zf({zoomPanValues:f,noWheelClassName:M,d3Selection:u,d3Zoom:d,panOnScrollMode:I,panOnScrollSpeed:E,zoomOnPinch:R,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:c}):Qf({noWheelClassName:M,preventScrolling:_,d3ZoomHandler:p});if(u.on("wheel.zoom",X,{passive:!1}),!j){const K=Jf({zoomPanValues:f,onDraggingChange:l,onPanZoomStart:a});d.on("start",K);const q=eh({zoomPanValues:f,panOnDrag:k,onPaneContextMenu:!!L,onPanZoom:i,onTransformChange:W});d.on("zoom",q);const ee=th({zoomPanValues:f,panOnDrag:k,panOnScroll:A,onPaneContextMenu:L,onPanZoomEnd:c,onDraggingChange:l});d.on("end",ee)}const Q=nh({zoomActivationKeyPressed:F,panOnDrag:k,zoomOnScroll:O,panOnScroll:A,zoomOnDoubleClick:T,zoomOnPinch:R,userSelectionActive:j,noPanClassName:$,noWheelClassName:M,lib:V,connectionInProgress:Z});d.filter(Q),T?u.on("dblclick.zoom",x):u.on("dblclick.zoom",null)}function w(){d.on("zoom",null)}async function b(M,$,L){const j=An(M),A=d==null?void 0:d.constrain()(j,$,L);return A&&await y(A),new Promise(k=>k(A))}async function g(M,$){const L=An(M);return await y(L,$),new Promise(j=>j(L))}function m(M){if(u){const $=An(M),L=u.property("__zoom");(L.k!==M.zoom||L.x!==M.x||L.y!==M.y)&&(d==null||d.transform(u,$,null,{sync:!0}))}}function z(){const M=u?Eo(u.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}function C(M,$){return u?new Promise(L=>{d==null||d.interpolate(($==null?void 0:$.interpolate)==="linear"?Mn:qt).scaleTo(Pn(u,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>L(!0)),M)}):Promise.resolve(!1)}function S(M,$){return u?new Promise(L=>{d==null||d.interpolate(($==null?void 0:$.interpolate)==="linear"?Mn:qt).scaleBy(Pn(u,$==null?void 0:$.duration,$==null?void 0:$.ease,()=>L(!0)),M)}):Promise.resolve(!1)}function P(M){d==null||d.scaleExtent(M)}function D(M){d==null||d.translateExtent(M)}function H(M){const $=!fe(M)||M<0?0:M;d==null||d.clickDistance($)}return{update:v,destroy:w,setViewport:g,setViewportConstrained:b,getViewport:z,scaleTo:C,scaleBy:S,setScaleExtent:P,setTranslateExtent:D,syncViewport:m,setClickDistance:H}}var st;(function(e){e.Line="line",e.Handle="handle"})(st||(st={}));function rh({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:r,affectsY:i}){const a=e-t,c=n-s,l=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&r&&(l[0]=l[0]*-1),c&&i&&(l[1]=l[1]*-1),l}function cr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:r}}function _e(e,t){return Math.max(0,t-e)}function Ee(e,t){return Math.max(0,e-t)}function Dt(e,t,n){return Math.max(0,t-e,e-n)}function lr(e,t){return e?!t:t}function oh(e,t,n,s,r,i,a,c){let{affectsX:l,affectsY:f}=t;const{isHorizontal:h,isVertical:d}=t,u=h&&d,{xSnapped:p,ySnapped:x}=n,{minWidth:y,maxWidth:v,minHeight:w,maxHeight:b}=s,{x:g,y:m,width:z,height:C,aspectRatio:S}=e;let P=Math.floor(h?p-e.pointerX:0),D=Math.floor(d?x-e.pointerY:0);const H=z+(l?-P:P),M=C+(f?-D:D),$=-i[0]*z,L=-i[1]*C;let j=Dt(H,y,v),A=Dt(M,w,b);if(a){let E=0,_=0;l&&P<0?E=_e(g+P+$,a[0][0]):!l&&P>0&&(E=Ee(g+H+$,a[1][0])),f&&D<0?_=_e(m+D+L,a[0][1]):!f&&D>0&&(_=Ee(m+M+L,a[1][1])),j=Math.max(j,E),A=Math.max(A,_)}if(c){let E=0,_=0;l&&P>0?E=Ee(g+P,c[0][0]):!l&&P<0&&(E=_e(g+H,c[1][0])),f&&D>0?_=Ee(m+D,c[0][1]):!f&&D<0&&(_=_e(m+M,c[1][1])),j=Math.max(j,E),A=Math.max(A,_)}if(r){if(h){const E=Dt(H/S,w,b)*S;if(j=Math.max(j,E),a){let _=0;!l&&!f||l&&!f&&u?_=Ee(m+L+H/S,a[1][1])*S:_=_e(m+L+(l?P:-P)/S,a[0][1])*S,j=Math.max(j,_)}if(c){let _=0;!l&&!f||l&&!f&&u?_=_e(m+H/S,c[1][1])*S:_=Ee(m+(l?P:-P)/S,c[0][1])*S,j=Math.max(j,_)}}if(d){const E=Dt(M*S,y,v)/S;if(A=Math.max(A,E),a){let _=0;!l&&!f||f&&!l&&u?_=Ee(g+M*S+$,a[1][0])/S:_=_e(g+(f?D:-D)*S+$,a[0][0])/S,A=Math.max(A,_)}if(c){let _=0;!l&&!f||f&&!l&&u?_=_e(g+M*S,c[1][0])/S:_=Ee(g+(f?D:-D)*S,c[0][0])/S,A=Math.max(A,_)}}}D=D+(D<0?A:-A),P=P+(P<0?j:-j),r&&(u?H>M*S?D=(lr(l,f)?-P:P)/S:P=(lr(l,f)?-D:D)*S:h?(D=P/S,f=l):(P=D*S,l=f));const k=l?g+P:g,I=f?m+D:m;return{width:z+(l?-P:P),height:C+(f?-D:D),x:i[0]*P*(l?-1:1)+k,y:i[1]*D*(f?-1:1)+I}}const oi={width:0,height:0,x:0,y:0},ih={...oi,pointerX:0,pointerY:0,aspectRatio:1};function ah(e){return[[0,0],[e.measured.width,e.measured.height]]}function ch(e,t,n){const s=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,c=n[0]*i,l=n[1]*a;return[[s-c,r-l],[s+i-c,r+a-l]]}function lh({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:r}){const i=ae(e);let a={controlDirection:cr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:h,keepAspectRatio:d,resizeDirection:u,onResizeStart:p,onResize:x,onResizeEnd:y,shouldResize:v}){let w={...oi},b={...ih};a={boundaries:h,resizeDirection:u,keepAspectRatio:d,controlDirection:cr(f)};let g,m=null,z=[],C,S,P,D=!1;const H=vo().on("start",M=>{const{nodeLookup:$,transform:L,snapGrid:j,snapToGrid:A,nodeOrigin:k,paneDomNode:I}=n();if(g=$.get(t),!g)return;m=(I==null?void 0:I.getBoundingClientRect())??null;const{xSnapped:E,ySnapped:_}=mt(M.sourceEvent,{transform:L,snapGrid:j,snapToGrid:A,containerBounds:m});w={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},b={...w,pointerX:E,pointerY:_,aspectRatio:w.width/w.height},C=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(C=$.get(g.parentId),S=C&&g.extent==="parent"?ah(C):void 0),z=[],P=void 0;for(const[R,O]of $)if(O.parentId===t&&(z.push({id:R,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const T=ch(O,g,O.origin??k);P?P=[[Math.min(T[0][0],P[0][0]),Math.min(T[0][1],P[0][1])],[Math.max(T[1][0],P[1][0]),Math.max(T[1][1],P[1][1])]]:P=T}p==null||p(M,{...w})}).on("drag",M=>{const{transform:$,snapGrid:L,snapToGrid:j,nodeOrigin:A}=n(),k=mt(M.sourceEvent,{transform:$,snapGrid:L,snapToGrid:j,containerBounds:m}),I=[];if(!g)return;const{x:E,y:_,width:R,height:O}=w,T={},F=g.origin??A,{width:V,height:W,x:Z,y:U}=oh(b,a.controlDirection,k,a.boundaries,a.keepAspectRatio,F,S,P),B=V!==R,G=W!==O,X=Z!==E&&B,Q=U!==_&&G;if(!X&&!Q&&!B&&!G)return;if((X||Q||F[0]===1||F[1]===1)&&(T.x=X?Z:w.x,T.y=Q?U:w.y,w.x=T.x,w.y=T.y,z.length>0)){const ne=Z-E,te=U-_;for(const ie of z)ie.position={x:ie.position.x-ne+F[0]*(V-R),y:ie.position.y-te+F[1]*(W-O)},I.push(ie)}if((B||G)&&(T.width=B&&(!a.resizeDirection||a.resizeDirection==="horizontal")?V:w.width,T.height=G&&(!a.resizeDirection||a.resizeDirection==="vertical")?W:w.height,w.width=T.width,w.height=T.height),C&&g.expandParent){const ne=F[0]*(T.width??0);T.x&&T.x<ne&&(w.x=ne,b.x=b.x-(T.x-ne));const te=F[1]*(T.height??0);T.y&&T.y<te&&(w.y=te,b.y=b.y-(T.y-te))}const K=rh({width:w.width,prevWidth:R,height:w.height,prevHeight:O,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),q={...w,direction:K};(v==null?void 0:v(M,q))!==!1&&(D=!0,x==null||x(M,q),s(T,I))}).on("end",M=>{D&&(y==null||y(M,{...w}),r==null||r({...w}),D=!1)});i.call(H)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var Dn={exports:{}},Ln={},Rn={exports:{}},On={};/**
|
|
62
|
-
* @license React
|
|
63
|
-
* use-sync-external-store-shim.production.js
|
|
64
|
-
*
|
|
65
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
66
|
-
*
|
|
67
|
-
* This source code is licensed under the MIT license found in the
|
|
68
|
-
* LICENSE file in the root directory of this source tree.
|
|
69
|
-
*/var dr;function dh(){if(dr)return On;dr=1;var e=Wr();function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,r=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function c(d,u){var p=u(),x=s({inst:{value:p,getSnapshot:u}}),y=x[0].inst,v=x[1];return i(function(){y.value=p,y.getSnapshot=u,l(y)&&v({inst:y})},[d,p,u]),r(function(){return l(y)&&v({inst:y}),d(function(){l(y)&&v({inst:y})})},[d]),a(p),p}function l(d){var u=d.getSnapshot;d=d.value;try{var p=u();return!n(d,p)}catch{return!0}}function f(d,u){return u()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return On.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,On}var ur;function uh(){return ur||(ur=1,Rn.exports=dh()),Rn.exports}/**
|
|
70
|
-
* @license React
|
|
71
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
72
|
-
*
|
|
73
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
74
|
-
*
|
|
75
|
-
* This source code is licensed under the MIT license found in the
|
|
76
|
-
* LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/var fr;function fh(){if(fr)return Ln;fr=1;var e=Wr(),t=uh();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var s=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,c=e.useMemo,l=e.useDebugValue;return Ln.useSyncExternalStoreWithSelector=function(f,h,d,u,p){var x=i(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=c(function(){function w(C){if(!b){if(b=!0,g=C,C=u(C),p!==void 0&&y.hasValue){var S=y.value;if(p(S,C))return m=S}return m=C}if(S=m,s(g,C))return S;var P=u(C);return p!==void 0&&p(S,P)?(g=C,S):(g=C,m=P)}var b=!1,g,m,z=d===void 0?null:d;return[function(){return w(h())},z===null?void 0:function(){return w(z())}]},[h,d,u,p]);var v=r(f,x[0],x[1]);return a(function(){y.hasValue=!0,y.value=v},[v]),l(v),v},Ln}var hr;function hh(){return hr||(hr=1,Dn.exports=fh()),Dn.exports}var ph=hh();const xh=ec(ph),mh={},pr=e=>{let t;const n=new Set,s=(h,d)=>{const u=typeof h=="function"?h(t):h;if(!Object.is(u,t)){const p=t;t=d??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(x=>x(t,p))}},r=()=>t,l={setState:s,getState:r,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(mh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(s,r,l);return l},gh=e=>e?pr(e):pr,{useDebugValue:bh}=cs,{useSyncExternalStoreWithSelector:yh}=xh,wh=e=>e;function ii(e,t=wh,n){const s=yh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return bh(s),s}const xr=(e,t)=>{const n=gh(e),s=(r,i=t)=>ii(n,r,i);return Object.assign(s,n),s},vh=(e,t)=>e?xr(e,t):xr;function se(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,r]of e)if(!Object.is(r,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}const Cn=N.createContext(null),Nh=Cn.Provider,ai=ge.error001();function J(e,t){const n=N.useContext(Cn);if(n===null)throw new Error(ai);return ii(n,e,t)}function re(){const e=N.useContext(Cn);if(e===null)throw new Error(ai);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const mr={display:"none"},jh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ci="react-flow__node-desc",li="react-flow__edge-desc",Ch="react-flow__aria-live",zh=e=>e.ariaLiveMessage,kh=e=>e.ariaLabelConfig;function Sh({rfId:e}){const t=J(zh);return o.jsx("div",{id:`${Ch}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:jh,children:t})}function _h({rfId:e,disableKeyboardA11y:t}){const n=J(kh);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${ci}-${e}`,style:mr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${li}-${e}`,style:mr,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(Sh,{rfId:e})]})}const zn=N.forwardRef(({position:e="top-left",children:t,className:n,style:s,...r},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:oe(["react-flow__panel",n,...a]),style:s,ref:i,...r,children:t})});zn.displayName="Panel";function Eh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(zn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Mh=e=>{const t=[],n=[];for(const[,s]of e.nodeLookup)s.selected&&t.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&n.push(s);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function Ih(e,t){return se(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&se(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function $h({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:s}=J(Mh,Ih);return N.useEffect(()=>{const r={nodes:n,edges:s};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,s,e]),null}const Th=e=>!!e.onSelectionChangeHandlers;function Ah({onSelectionChange:e}){const t=J(Th);return e||t?o.jsx($h,{onSelectionChange:e}):null}const di=[0,0],Ph={x:0,y:0,zoom:1},Dh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],gr=[...Dh,"rfId"],Lh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),br={translateExtent:yt,nodeOrigin:di,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Rh(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:l}=J(Lh,se),f=re();N.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=br,c()}),[]);const h=N.useRef(br);return N.useEffect(()=>{for(const d of gr){const u=e[d],p=h.current[d];u!==p&&(typeof e[d]>"u"||(d==="nodes"?t(u):d==="edges"?n(u):d==="minZoom"?s(u):d==="maxZoom"?r(u):d==="translateExtent"?i(u):d==="nodeExtent"?a(u):d==="ariaLabelConfig"?f.setState({ariaLabelConfig:vf(u)}):d==="fitView"?f.setState({fitViewQueued:u}):d==="fitViewOptions"?f.setState({fitViewOptions:u}):f.setState({[d]:u})))}h.current=e},gr.map(d=>e[d])),null}function yr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Oh(e){var s;const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const r=yr(),i=()=>n(r!=null&&r.matches?"dark":"light");return i(),r==null||r.addEventListener("change",i),()=>{r==null||r.removeEventListener("change",i)}},[e]),t!==null?t:(s=yr())!=null&&s.matches?"dark":"light"}const wr=typeof document<"u"?document:null;function jt(e=null,t={target:wr,actInsideInputWithModifier:!0}){const[n,s]=N.useState(!1),r=N.useRef(!1),i=N.useRef(new Set([])),[a,c]=N.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
78
|
-
`).replace(`
|
|
79
|
-
|
|
80
|
-
`,`
|
|
81
|
-
+`).split(`
|
|
82
|
-
`)),h=f.reduce((d,u)=>d.concat(...u),[]);return[f,h]}return[[],[]]},[e]);return N.useEffect(()=>{const l=(t==null?void 0:t.target)??wr,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=p=>{var v,w;if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!f)&&Vo(p))return!1;const y=Nr(p.code,c);if(i.current.add(p[y]),vr(a,i.current,!1)){const b=((w=(v=p.composedPath)==null?void 0:v.call(p))==null?void 0:w[0])||p.target,g=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(r.current||!g)&&p.preventDefault(),s(!0)}},d=p=>{const x=Nr(p.code,c);vr(a,i.current,!0)?(s(!1),i.current.clear()):i.current.delete(p[x]),p.key==="Meta"&&i.current.clear(),r.current=!1},u=()=>{i.current.clear(),s(!1)};return l==null||l.addEventListener("keydown",h),l==null||l.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{l==null||l.removeEventListener("keydown",h),l==null||l.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,s]),n}function vr(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(r=>t.has(r)))}function Nr(e,t){return t.includes(e)?"code":"key"}const Hh=()=>{const e=re();return N.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,r,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??s,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{const{width:s,height:r,minZoom:i,maxZoom:a,panZoom:c}=e.getState(),l=vs(t,s,r,i,a,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:r,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:c,y:l}=a.getBoundingClientRect(),f={x:t.x-c,y:t.y-l},h=n.snapGrid??r,d=n.snapToGrid??i;return Et(f,s,d,h)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:r,y:i}=s.getBoundingClientRect(),a=ln(t,n);return{x:a.x+r,y:a.y+i}}}),[])};function ui(e,t){const n=[],s=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")s.set(i.id,[i]);else{const a=s.get(i.id);a?a.push(i):s.set(i.id,[i])}for(const i of t){const a=s.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const c={...i};for(const l of a)Fh(l,c);n.push(c)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Fh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function fi(e,t){return ui(e,t)}function hi(e,t){return ui(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function qe(e,t=new Set,n=!1){const s=[];for(const[r,i]of e){const a=t.has(r);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),s.push(Pe(i.id,a)))}return s}function jr({items:e=[],lookup:t}){var r;const n=[],s=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const c=t.get(a.id),l=((r=c==null?void 0:c.internals)==null?void 0:r.userNode)??c;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)s.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Cr(e){return{id:e.id,type:"remove"}}const zr=e=>uf(e),Bh=e=>Po(e);function pi(e){return N.forwardRef(e)}const Vh=typeof window<"u"?N.useLayoutEffect:N.useEffect;function kr(e){const[t,n]=N.useState(BigInt(0)),[s]=N.useState(()=>Yh(()=>n(r=>r+BigInt(1))));return Vh(()=>{const r=s.get();r.length&&(e(r),s.reset())},[t]),s}function Yh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const xi=N.createContext(null);function Gh({children:e}){const t=re(),n=N.useCallback(c=>{const{nodes:l=[],setNodes:f,hasDefaultNodes:h,onNodesChange:d,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:x}=t.getState();let y=l;for(const w of c)y=typeof w=="function"?w(y):w;let v=jr({items:y,lookup:u});for(const w of x.values())v=w(v);h&&f(y),v.length>0?d==null||d(v):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:b,setNodes:g}=t.getState();w&&g(b)})},[]),s=kr(n),r=N.useCallback(c=>{const{edges:l=[],setEdges:f,hasDefaultEdges:h,onEdgesChange:d,edgeLookup:u}=t.getState();let p=l;for(const x of c)p=typeof x=="function"?x(p):x;h?f(p):d&&d(jr({items:p,lookup:u}))},[]),i=kr(r),a=N.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return o.jsx(xi.Provider,{value:a,children:e})}function Wh(){const e=N.useContext(xi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Xh=e=>!!e.panZoom;function _s(){const e=Hh(),t=re(),n=Wh(),s=J(Xh),r=N.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),a=d=>{n.nodeQueue.push(d)},c=d=>{n.edgeQueue.push(d)},l=d=>{var w,b;const{nodeLookup:u,nodeOrigin:p}=t.getState(),x=zr(d)?d:u.get(d.id),y=x.parentId?Fo(x.position,x.measured,x.parentId,u,p):x.position,v={...x,position:y,width:((w=x.measured)==null?void 0:w.width)??x.width,height:((b=x.measured)==null?void 0:b.height)??x.height};return tt(v)},f=(d,u,p={replace:!1})=>{a(x=>x.map(y=>{if(y.id===d){const v=typeof u=="function"?u(y):u;return p.replace&&zr(v)?v:{...y,...v}}return y}))},h=(d,u,p={replace:!1})=>{c(x=>x.map(y=>{if(y.id===d){const v=typeof u=="function"?u(y):u;return p.replace&&Bh(v)?v:{...y,...v}}return y}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var u;return(u=i(d))==null?void 0:u.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(u=>({...u}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:a,setEdges:c,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:p}=t.getState(),[x,y,v]=p;return{nodes:d.map(w=>({...w})),edges:u.map(w=>({...w})),viewport:{x,y,zoom:v}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:p,edges:x,onNodesDelete:y,onEdgesDelete:v,triggerNodeChanges:w,triggerEdgeChanges:b,onDelete:g,onBeforeDelete:m}=t.getState(),{nodes:z,edges:C}=await mf({nodesToRemove:d,edgesToRemove:u,nodes:p,edges:x,onBeforeDelete:m}),S=C.length>0,P=z.length>0;if(S){const D=C.map(Cr);v==null||v(C),b(D)}if(P){const D=z.map(Cr);y==null||y(z),w(D)}return(P||S)&&(g==null||g({nodes:z,edges:C})),{deletedNodes:z,deletedEdges:C}},getIntersectingNodes:(d,u=!0,p)=>{const x=Zs(d),y=x?d:l(d),v=p!==void 0;return y?(p||t.getState().nodes).filter(w=>{const b=t.getState().nodeLookup.get(w.id);if(b&&!x&&(w.id===d.id||!b.internals.positionAbsolute))return!1;const g=tt(v?w:b),m=vt(g,y);return u&&m>0||m>=g.width*g.height||m>=y.width*y.height}):[]},isNodeIntersecting:(d,u,p=!0)=>{const y=Zs(d)?d:l(d);if(!y)return!1;const v=vt(y,u);return p&&v>0||v>=u.width*u.height||v>=y.width*y.height},updateNode:f,updateNodeData:(d,u,p={replace:!1})=>{f(d,x=>{const y=typeof u=="function"?u(x):u;return p.replace?{...x,data:y}:{...x,data:{...x.data,...y}}},p)},updateEdge:h,updateEdgeData:(d,u,p={replace:!1})=>{h(d,x=>{const y=typeof u=="function"?u(x):u;return p.replace?{...x,data:y}:{...x,data:{...x.data,...y}}},p)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:p}=t.getState();return ff(d,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:d,id:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}-${d}${u?`-${u}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}${d?u?`-${d}-${u}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const u=t.getState().fitViewResolver??wf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return N.useMemo(()=>({...r,...e,viewportInitialized:s}),[s])}const Sr=e=>e.selected,qh=typeof window<"u"?window:void 0;function Uh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:s}=_s(),r=jt(e,{actInsideInputWithModifier:!1}),i=jt(t,{target:qh});N.useEffect(()=>{if(r){const{edges:a,nodes:c}=n.getState();s({nodes:c.filter(Sr),edges:a.filter(Sr)}),n.setState({nodesSelectionActive:!1})}},[r]),N.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Kh(e){const t=re();N.useEffect(()=>{const n=()=>{var r,i,a,c;if(!e.current||!(((i=(r=e.current).checkVisibility)==null?void 0:i.call(r))??!0))return!1;const s=Ns(e.current);(s.height===0||s.width===0)&&((c=(a=t.getState()).onError)==null||c.call(a,"004",ge.error004())),t.setState({width:s.width||500,height:s.height||500})};if(e.current){n(),window.addEventListener("resize",n);const s=new ResizeObserver(()=>n());return s.observe(e.current),()=>{window.removeEventListener("resize",n),s&&e.current&&s.unobserve(e.current)}}},[])}const kn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Zh=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Qh({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=De.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:f,minZoom:h,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:x,noWheelClassName:y,noPanClassName:v,onViewportChange:w,isControlledViewport:b,paneClickDistance:g,selectionOnDrag:m}){const z=re(),C=N.useRef(null),{userSelectionActive:S,lib:P,connectionInProgress:D}=J(Zh,se),H=jt(u),M=N.useRef();Kh(C);const $=N.useCallback(L=>{w==null||w({x:L[0],y:L[1],zoom:L[2]}),b||z.setState({transform:L})},[w,b]);return N.useEffect(()=>{if(C.current){M.current=sh({domNode:C.current,minZoom:h,maxZoom:d,translateExtent:f,viewport:l,onDraggingChange:k=>z.setState(I=>I.paneDragging===k?I:{paneDragging:k}),onPanZoomStart:(k,I)=>{const{onViewportChangeStart:E,onMoveStart:_}=z.getState();_==null||_(k,I),E==null||E(I)},onPanZoom:(k,I)=>{const{onViewportChange:E,onMove:_}=z.getState();_==null||_(k,I),E==null||E(I)},onPanZoomEnd:(k,I)=>{const{onViewportChangeEnd:E,onMoveEnd:_}=z.getState();_==null||_(k,I),E==null||E(I)}});const{x:L,y:j,zoom:A}=M.current.getViewport();return z.setState({panZoom:M.current,transform:[L,j,A],domNode:C.current.closest(".react-flow")}),()=>{var k;(k=M.current)==null||k.destroy()}}},[]),N.useEffect(()=>{var L;(L=M.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:p,noPanClassName:v,userSelectionActive:S,noWheelClassName:y,lib:P,onTransformChange:$,connectionInProgress:D,selectionOnDrag:m,paneClickDistance:g})},[e,t,n,s,r,i,a,c,H,p,v,S,y,P,$,D,m,g]),o.jsx("div",{className:"react-flow__renderer",ref:C,style:kn,children:x})}const Jh=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ep(){const{userSelectionActive:e,userSelectionRect:t}=J(Jh,se);return e&&t?o.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Hn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},tp=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function np({isSelecting:e,selectionKeyPressed:t,selectionMode:n=wt.Full,panOnDrag:s,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:f,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:u,onPaneMouseLeave:p,children:x}){const y=re(),{userSelectionActive:v,elementsSelectable:w,dragging:b,connectionInProgress:g}=J(tp,se),m=w&&(e||v),z=N.useRef(null),C=N.useRef(),S=N.useRef(new Set),P=N.useRef(new Set),D=N.useRef(!1),H=E=>{if(D.current||g){D.current=!1;return}l==null||l(E),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},M=E=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){E.preventDefault();return}f==null||f(E)},$=h?E=>h(E):void 0,L=E=>{D.current&&(E.stopPropagation(),D.current=!1)},j=E=>{var W,Z;const{domNode:_}=y.getState();if(C.current=_==null?void 0:_.getBoundingClientRect(),!C.current)return;const R=E.target===z.current;if(!R&&!!E.target.closest(".nokey")||!e||!(i&&R||t)||E.button!==0||!E.isPrimary)return;(Z=(W=E.target)==null?void 0:W.setPointerCapture)==null||Z.call(W,E.pointerId),D.current=!1;const{x:F,y:V}=he(E.nativeEvent,C.current);y.setState({userSelectionRect:{width:0,height:0,startX:F,startY:V,x:F,y:V}}),R||(E.stopPropagation(),E.preventDefault())},A=E=>{const{userSelectionRect:_,transform:R,nodeLookup:O,edgeLookup:T,connectionLookup:F,triggerNodeChanges:V,triggerEdgeChanges:W,defaultEdgeOptions:Z,resetSelectedElements:U}=y.getState();if(!C.current||!_)return;const{x:B,y:G}=he(E.nativeEvent,C.current),{startX:X,startY:Q}=_;if(!D.current){const te=t?0:r;if(Math.hypot(B-X,G-Q)<=te)return;U(),a==null||a(E)}D.current=!0;const K={startX:X,startY:Q,x:B<X?B:X,y:G<Q?G:Q,width:Math.abs(B-X),height:Math.abs(G-Q)},q=S.current,ee=P.current;S.current=new Set(ws(O,K,R,n===wt.Partial,!0).map(te=>te.id)),P.current=new Set;const ne=(Z==null?void 0:Z.selectable)??!0;for(const te of S.current){const ie=F.get(te);if(ie)for(const{edgeId:Se}of ie.values()){const ve=T.get(Se);ve&&(ve.selectable??ne)&&P.current.add(Se)}}if(!Qs(q,S.current)){const te=qe(O,S.current,!0);V(te)}if(!Qs(ee,P.current)){const te=qe(T,P.current);W(te)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},k=E=>{var _,R;E.button===0&&((R=(_=E.target)==null?void 0:_.releasePointerCapture)==null||R.call(_,E.pointerId),!v&&E.target===z.current&&y.getState().userSelectionRect&&(H==null||H(E)),y.setState({userSelectionActive:!1,userSelectionRect:null}),D.current&&(c==null||c(E),y.setState({nodesSelectionActive:S.current.size>0})))},I=s===!0||Array.isArray(s)&&s.includes(0);return o.jsxs("div",{className:oe(["react-flow__pane",{draggable:I,dragging:b,selection:e}]),onClick:m?void 0:Hn(H,z),onContextMenu:Hn(M,z),onWheel:Hn($,z),onPointerEnter:m?void 0:d,onPointerMove:m?A:u,onPointerUp:m?k:void 0,onPointerDownCapture:m?j:void 0,onClickCapture:m?L:void 0,onPointerLeave:p,ref:z,style:kn,children:[x,o.jsx(ep,{})]})}function ns({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:c,onError:l}=t.getState(),f=c.get(e);if(!f){l==null||l("012",ge.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&a)&&(i({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var h;return(h=s==null?void 0:s.current)==null?void 0:h.blur()})):r([e])}function mi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:r,isSelectable:i,nodeClickDistance:a}){const c=re(),[l,f]=N.useState(!1),h=N.useRef();return N.useEffect(()=>{h.current=Vf({getStoreItems:()=>c.getState(),onNodeMouseDown:d=>{ns({id:d,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),N.useEffect(()=>{if(!(t||!e.current||!h.current))return h.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:a}),()=>{var d;(d=h.current)==null||d.destroy()}},[n,s,t,i,e,r,a]),l}const sp=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function gi(){const e=re();return N.useCallback(n=>{const{nodeExtent:s,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:c,updateNodePositions:l,nodeLookup:f,nodeOrigin:h}=e.getState(),d=new Map,u=sp(a),p=r?i[0]:5,x=r?i[1]:5,y=n.direction.x*p*n.factor,v=n.direction.y*x*n.factor;for(const[,w]of f){if(!u(w))continue;let b={x:w.internals.positionAbsolute.x+y,y:w.internals.positionAbsolute.y+v};r&&(b=_t(b,i));const{position:g,positionAbsolute:m}=Do({nodeId:w.id,nextPosition:b,nodeLookup:f,nodeExtent:s,nodeOrigin:h,onError:c});w.position=g,w.internals.positionAbsolute=m,d.set(w.id,w)}l(d)},[])}const Es=N.createContext(null),rp=Es.Provider;Es.Consumer;const bi=()=>N.useContext(Es),op=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ip=(e,t,n)=>s=>{const{connectionClickStartHandle:r,connectionMode:i,connection:a}=s,{fromHandle:c,toHandle:l,isValid:f}=a,h=(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:h,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:i===Je.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!r,valid:h&&f}};function ap({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:a,onConnect:c,children:l,className:f,onMouseDown:h,onTouchStart:d,...u},p){var A,k;const x=a||null,y=e==="target",v=re(),w=bi(),{connectOnClick:b,noPanClassName:g,rfId:m}=J(op,se),{connectingFrom:z,connectingTo:C,clickConnecting:S,isPossibleEndHandle:P,connectionInProcess:D,clickConnectionInProcess:H,valid:M}=J(ip(w,x,e),se);w||(k=(A=v.getState()).onError)==null||k.call(A,"010",ge.error010());const $=I=>{const{defaultEdgeOptions:E,onConnect:_,hasDefaultEdges:R}=v.getState(),O={...E,...I};if(R){const{edges:T,setEdges:F}=v.getState();F(Sf(O,T))}_==null||_(O),c==null||c(O)},L=I=>{if(!w)return;const E=Yo(I.nativeEvent);if(r&&(E&&I.button===0||!E)){const _=v.getState();ts.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:_.autoPanOnConnect,connectionMode:_.connectionMode,connectionRadius:_.connectionRadius,domNode:_.domNode,nodeLookup:_.nodeLookup,lib:_.lib,isTarget:y,handleId:x,nodeId:w,flowId:_.rfId,panBy:_.panBy,cancelConnection:_.cancelConnection,onConnectStart:_.onConnectStart,onConnectEnd:(...R)=>{var O,T;return(T=(O=v.getState()).onConnectEnd)==null?void 0:T.call(O,...R)},updateConnection:_.updateConnection,onConnect:$,isValidConnection:n||((...R)=>{var O,T;return((T=(O=v.getState()).isValidConnection)==null?void 0:T.call(O,...R))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:_.autoPanSpeed,dragThreshold:_.connectionDragThreshold})}E?h==null||h(I):d==null||d(I)},j=I=>{const{onClickConnectStart:E,onClickConnectEnd:_,connectionClickStartHandle:R,connectionMode:O,isValidConnection:T,lib:F,rfId:V,nodeLookup:W,connection:Z}=v.getState();if(!w||!R&&!r)return;if(!R){E==null||E(I.nativeEvent,{nodeId:w,handleId:x,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:w,type:e,id:x}});return}const U=Bo(I.target),B=n||T,{connection:G,isValid:X}=ts.isValid(I.nativeEvent,{handle:{nodeId:w,id:x,type:e},connectionMode:O,fromNodeId:R.nodeId,fromHandleId:R.id||null,fromType:R.type,isValidConnection:B,flowId:V,doc:U,lib:F,nodeLookup:W});X&&G&&$(G);const Q=structuredClone(Z);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,_==null||_(I,Q),v.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":x,"data-nodeid":w,"data-handlepos":t,"data-id":`${m}-${w}-${x}-${e}`,className:oe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,f,{source:!y,target:y,connectable:s,connectablestart:r,connectableend:i,clickconnecting:S,connectingfrom:z,connectingto:C,valid:M,connectionindicator:s&&(!D||P)&&(D||H?i:r)}]),onMouseDown:L,onTouchStart:L,onClick:b?j:void 0,ref:p,...u,children:l})}const ue=N.memo(pi(ap));function cp({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(ue,{type:"source",position:n,isConnectable:t})]})}function lp({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:s=Y.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(ue,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(ue,{type:"source",position:s,isConnectable:t})]})}function dp(){return null}function up({data:e,isConnectable:t,targetPosition:n=Y.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(ue,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},_r={input:cp,default:lp,output:up,group:dp};function fp(e){var t,n,s,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((s=e.style)==null?void 0:s.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const hp=e=>{const{width:t,height:n,x:s,y:r}=St(e.nodeLookup,{filter:i=>!!i.selected});return{width:fe(t)?t:null,height:fe(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${r}px)`}};function pp({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=re(),{width:r,height:i,transformString:a,userSelectionActive:c}=J(hp,se),l=gi(),f=N.useRef(null);N.useEffect(()=>{var p;n||(p=f.current)==null||p.focus({preventScroll:!0})},[n]);const h=!c&&r!==null&&i!==null;if(mi({nodeRef:f,disabled:!h}),!h)return null;const d=e?p=>{const x=s.getState().nodes.filter(y=>y.selected);e(p,x)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(un,p.key)&&(p.preventDefault(),l({direction:un[p.key],factor:p.shiftKey?4:1}))};return o.jsx("div",{className:oe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:r,height:i}})})}const Er=typeof window<"u"?window:void 0,xp=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function yi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:f,selectionOnDrag:h,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:y,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:m,panOnScrollSpeed:z,panOnScrollMode:C,zoomOnDoubleClick:S,panOnDrag:P,defaultViewport:D,translateExtent:H,minZoom:M,maxZoom:$,preventScrolling:L,onSelectionContextMenu:j,noWheelClassName:A,noPanClassName:k,disableKeyboardA11y:I,onViewportChange:E,isControlledViewport:_}){const{nodesSelectionActive:R,userSelectionActive:O}=J(xp,se),T=jt(f,{target:Er}),F=jt(y,{target:Er}),V=F||P,W=F||m,Z=h&&V!==!0,U=T||O||Z;return Uh({deleteKeyCode:l,multiSelectionKeyCode:x}),o.jsx(Qh,{onPaneContextMenu:i,elementsSelectable:w,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:W,panOnScrollSpeed:z,panOnScrollMode:C,zoomOnDoubleClick:S,panOnDrag:!T&&V,defaultViewport:D,translateExtent:H,minZoom:M,maxZoom:$,zoomActivationKeyCode:v,preventScrolling:L,noWheelClassName:A,noPanClassName:k,onViewportChange:E,isControlledViewport:_,paneClickDistance:c,selectionOnDrag:Z,children:o.jsxs(np,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:V,isSelecting:!!U,selectionMode:d,selectionKeyPressed:T,paneClickDistance:c,selectionOnDrag:Z,children:[e,R&&o.jsx(pp,{onSelectionContextMenu:j,noPanClassName:k,disableKeyboardA11y:I})]})})}yi.displayName="FlowRenderer";const mp=N.memo(yi),gp=e=>t=>e?ws(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function bp(e){return J(N.useCallback(gp(e),[e]),se)}const yp=e=>e.updateNodeInternals;function wp(){const e=J(yp),[t]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");s.set(i,{id:i,nodeElement:r.target,force:!0})}),e(s)}));return N.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function vp({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const r=re(),i=N.useRef(null),a=N.useRef(null),c=N.useRef(e.sourcePosition),l=N.useRef(e.targetPosition),f=N.useRef(t),h=n&&!!e.internals.handleBounds;return N.useEffect(()=>{i.current&&!e.hidden&&(!h||a.current!==i.current)&&(a.current&&(s==null||s.unobserve(a.current)),s==null||s.observe(i.current),a.current=i.current)},[h,e.hidden]),N.useEffect(()=>()=>{a.current&&(s==null||s.unobserve(a.current),a.current=null)},[]),N.useEffect(()=>{if(i.current){const d=f.current!==t,u=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(d||u||p)&&(f.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function Np({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:r,onContextMenu:i,onDoubleClick:a,nodesDraggable:c,elementsSelectable:l,nodesConnectable:f,nodesFocusable:h,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:x,rfId:y,nodeTypes:v,nodeClickDistance:w,onError:b}){const{node:g,internals:m,isParent:z}=J(B=>{const G=B.nodeLookup.get(e),X=B.parentLookup.has(e);return{node:G,internals:G.internals,isParent:X}},se);let C=g.type||"default",S=(v==null?void 0:v[C])||_r[C];S===void 0&&(b==null||b("003",ge.error003(C)),C="default",S=(v==null?void 0:v.default)||_r.default);const P=!!(g.draggable||c&&typeof g.draggable>"u"),D=!!(g.selectable||l&&typeof g.selectable>"u"),H=!!(g.connectable||f&&typeof g.connectable>"u"),M=!!(g.focusable||h&&typeof g.focusable>"u"),$=re(),L=Ho(g),j=vp({node:g,nodeType:C,hasDimensions:L,resizeObserver:d}),A=mi({nodeRef:j,disabled:g.hidden||!P,noDragClassName:u,handleSelector:g.dragHandle,nodeId:e,isSelectable:D,nodeClickDistance:w}),k=gi();if(g.hidden)return null;const I=ke(g),E=fp(g),_=D||P||t||n||s||r,R=n?B=>n(B,{...m.userNode}):void 0,O=s?B=>s(B,{...m.userNode}):void 0,T=r?B=>r(B,{...m.userNode}):void 0,F=i?B=>i(B,{...m.userNode}):void 0,V=a?B=>a(B,{...m.userNode}):void 0,W=B=>{const{selectNodesOnDrag:G,nodeDragThreshold:X}=$.getState();D&&(!G||!P||X>0)&&ns({id:e,store:$,nodeRef:j}),t&&t(B,{...m.userNode})},Z=B=>{if(!(Vo(B.nativeEvent)||x)){if(Io.includes(B.key)&&D){const G=B.key==="Escape";ns({id:e,store:$,unselect:G,nodeRef:j})}else if(P&&g.selected&&Object.prototype.hasOwnProperty.call(un,B.key)){B.preventDefault();const{ariaLabelConfig:G}=$.getState();$.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~m.positionAbsolute.x,y:~~m.positionAbsolute.y})}),k({direction:un[B.key],factor:B.shiftKey?4:1})}}},U=()=>{var ee;if(x||!((ee=j.current)!=null&&ee.matches(":focus-visible")))return;const{transform:B,width:G,height:X,autoPanOnNodeFocus:Q,setCenter:K}=$.getState();if(!Q)return;ws(new Map([[e,g]]),{x:0,y:0,width:G,height:X},B,!0).length>0||K(g.position.x+I.width/2,g.position.y+I.height/2,{zoom:B[2]})};return o.jsx("div",{className:oe(["react-flow__node",`react-flow__node-${C}`,{[p]:P},g.className,{selected:g.selected,selectable:D,parent:z,draggable:P,dragging:A}]),ref:j,style:{zIndex:m.z,transform:`translate(${m.positionAbsolute.x}px,${m.positionAbsolute.y}px)`,pointerEvents:_?"all":"none",visibility:L?"visible":"hidden",...g.style,...E},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:O,onMouseLeave:T,onContextMenu:F,onClick:W,onDoubleClick:V,onKeyDown:M?Z:void 0,tabIndex:M?0:void 0,onFocus:M?U:void 0,role:g.ariaRole??(M?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${ci}-${y}`,"aria-label":g.ariaLabel,...g.domAttributes,children:o.jsx(rp,{value:e,children:o.jsx(S,{id:e,data:g.data,type:C,positionAbsoluteX:m.positionAbsolute.x,positionAbsoluteY:m.positionAbsolute.y,selected:g.selected??!1,selectable:D,draggable:P,deletable:g.deletable??!0,isConnectable:H,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:A,dragHandle:g.dragHandle,zIndex:m.z,parentId:g.parentId,...I})})})}var jp=N.memo(Np);const Cp=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function wi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:r,onError:i}=J(Cp,se),a=bp(e.onlyRenderVisibleElements),c=wp();return o.jsx("div",{className:"react-flow__nodes",style:kn,children:a.map(l=>o.jsx(jp,{id:l,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},l))})}wi.displayName="NodeRenderer";const zp=N.memo(wi);function kp(e){return J(N.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const s=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),a=n.nodeLookup.get(r.target);i&&a&&Cf({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&s.push(r.id)}return s},[e]),se)}const Sp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},_p=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Mr={[an.Arrow]:Sp,[an.ArrowClosed]:_p};function Ep(e){const t=re();return N.useMemo(()=>{var r,i;return Object.prototype.hasOwnProperty.call(Mr,e)?Mr[e]:((i=(r=t.getState()).onError)==null||i.call(r,"009",ge.error009(e)),null)},[e])}const Mp=({id:e,type:t,color:n,width:s=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:c="auto-start-reverse"})=>{const l=Ep(t);return l?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:o.jsx(l,{color:n,strokeWidth:a})}):null},vi=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),s=J(i=>i.defaultEdgeOptions),r=N.useMemo(()=>$f(n,{id:t,defaultColor:e,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[n,s,t,e]);return r.length?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:r.map(i=>o.jsx(Mp,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};vi.displayName="MarkerDefinitions";var Ip=N.memo(vi);function Ni({x:e,y:t,label:n,labelStyle:s,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:c=2,children:l,className:f,...h}){const[d,u]=N.useState({x:1,y:0,width:0,height:0}),p=oe(["react-flow__edge-textwrapper",f]),x=N.useRef(null);return N.useEffect(()=>{if(x.current){const y=x.current.getBBox();u({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...h,children:[r&&o.jsx("rect",{width:d.width+2*a[0],x:-a[0],y:-a[1],height:d.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),o.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:s,children:n}),l]}):null}Ni.displayName="EdgeText";const $p=N.memo(Ni);function Mt({path:e,labelX:t,labelY:n,label:s,labelStyle:r,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:f=20,...h}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...h,d:e,fill:"none",className:oe(["react-flow__edge-path",h.className])}),f?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,s&&fe(t)&&fe(n)?o.jsx($p,{x:t,y:n,label:s,labelStyle:r,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function Ir({pos:e,x1:t,y1:n,x2:s,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+s),n]:[t,.5*(n+r)]}function ji({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:s,targetY:r,targetPosition:i=Y.Top}){const[a,c]=Ir({pos:n,x1:e,y1:t,x2:s,y2:r}),[l,f]=Ir({pos:i,x1:s,y1:r,x2:e,y2:t}),[h,d,u,p]=Go({sourceX:e,sourceY:t,targetX:s,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${s},${r}`,h,d,u,p]}function Ci(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:r,targetY:i,sourcePosition:a,targetPosition:c,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:y,markerStart:v,interactionWidth:w})=>{const[b,g,m]=ji({sourceX:n,sourceY:s,sourcePosition:a,targetX:r,targetY:i,targetPosition:c}),z=e.isInternal?void 0:t;return o.jsx(Mt,{id:z,path:b,labelX:g,labelY:m,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:y,markerStart:v,interactionWidth:w})})}const Tp=Ci({isInternal:!1}),zi=Ci({isInternal:!0});Tp.displayName="SimpleBezierEdge";zi.displayName="SimpleBezierEdgeInternal";function ki(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:r,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,sourcePosition:p=Y.Bottom,targetPosition:x=Y.Top,markerEnd:y,markerStart:v,pathOptions:w,interactionWidth:b})=>{const[g,m,z]=dn({sourceX:n,sourceY:s,sourcePosition:p,targetX:r,targetY:i,targetPosition:x,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),C=e.isInternal?void 0:t;return o.jsx(Mt,{id:C,path:g,labelX:m,labelY:z,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:y,markerStart:v,interactionWidth:b})})}const Si=ki({isInternal:!1}),_i=ki({isInternal:!0});Si.displayName="SmoothStepEdge";_i.displayName="SmoothStepEdgeInternal";function Ei(e){return N.memo(({id:t,...n})=>{var r;const s=e.isInternal?void 0:t;return o.jsx(Si,{...n,id:s,pathOptions:N.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const Ap=Ei({isInternal:!1}),Mi=Ei({isInternal:!0});Ap.displayName="StepEdge";Mi.displayName="StepEdgeInternal";function Ii(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:r,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:y})=>{const[v,w,b]=qo({sourceX:n,sourceY:s,targetX:r,targetY:i}),g=e.isInternal?void 0:t;return o.jsx(Mt,{id:g,path:v,labelX:w,labelY:b,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:y})})}const Pp=Ii({isInternal:!1}),$i=Ii({isInternal:!0});Pp.displayName="StraightEdge";$i.displayName="StraightEdgeInternal";function Ti(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:r,targetY:i,sourcePosition:a=Y.Bottom,targetPosition:c=Y.Top,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:y,markerStart:v,pathOptions:w,interactionWidth:b})=>{const[g,m,z]=Wo({sourceX:n,sourceY:s,sourcePosition:a,targetX:r,targetY:i,targetPosition:c,curvature:w==null?void 0:w.curvature}),C=e.isInternal?void 0:t;return o.jsx(Mt,{id:C,path:g,labelX:m,labelY:z,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:y,markerStart:v,interactionWidth:b})})}const Dp=Ti({isInternal:!1}),Ai=Ti({isInternal:!0});Dp.displayName="BezierEdge";Ai.displayName="BezierEdgeInternal";const $r={default:Ai,straight:$i,step:Mi,smoothstep:_i,simplebezier:zi},Tr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Lp=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Rp=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Ar="react-flow__edgeupdater";function Pr({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:r,onMouseEnter:i,onMouseOut:a,type:c}){return o.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:a,className:oe([Ar,`${Ar}-${c}`]),cx:Lp(t,s,e),cy:Rp(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function Op({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:r,targetX:i,targetY:a,sourcePosition:c,targetPosition:l,onReconnect:f,onReconnectStart:h,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){const x=re(),y=(m,z)=>{if(m.button!==0)return;const{autoPanOnConnect:C,domNode:S,connectionMode:P,connectionRadius:D,lib:H,onConnectStart:M,cancelConnection:$,nodeLookup:L,rfId:j,panBy:A,updateConnection:k}=x.getState(),I=z.type==="target",E=(O,T)=>{u(!1),d==null||d(O,n,z.type,T)},_=O=>f==null?void 0:f(n,O),R=(O,T)=>{u(!0),h==null||h(m,n,z.type),M==null||M(O,T)};ts.onPointerDown(m.nativeEvent,{autoPanOnConnect:C,connectionMode:P,connectionRadius:D,domNode:S,handleId:z.id,nodeId:z.nodeId,nodeLookup:L,isTarget:I,edgeUpdaterType:z.type,lib:H,flowId:j,cancelConnection:$,panBy:A,isValidConnection:(...O)=>{var T,F;return((F=(T=x.getState()).isValidConnection)==null?void 0:F.call(T,...O))??!0},onConnect:_,onConnectStart:R,onConnectEnd:(...O)=>{var T,F;return(F=(T=x.getState()).onConnectEnd)==null?void 0:F.call(T,...O)},onReconnectEnd:E,updateConnection:k,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:m.currentTarget})},v=m=>y(m,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=m=>y(m,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>p(!0),g=()=>p(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(Pr,{position:c,centerX:s,centerY:r,radius:t,onMouseDown:v,onMouseEnter:b,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&o.jsx(Pr,{position:l,centerX:i,centerY:a,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:g,type:"target"})]})}function Hp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:r,onDoubleClick:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,rfId:x,edgeTypes:y,noPanClassName:v,onError:w,disableKeyboardA11y:b}){let g=J(K=>K.edgeLookup.get(e));const m=J(K=>K.defaultEdgeOptions);g=m?{...m,...g}:g;let z=g.type||"default",C=(y==null?void 0:y[z])||$r[z];C===void 0&&(w==null||w("011",ge.error011(z)),z="default",C=(y==null?void 0:y.default)||$r.default);const S=!!(g.focusable||t&&typeof g.focusable>"u"),P=typeof d<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),D=!!(g.selectable||s&&typeof g.selectable>"u"),H=N.useRef(null),[M,$]=N.useState(!1),[L,j]=N.useState(!1),A=re(),{zIndex:k,sourceX:I,sourceY:E,targetX:_,targetY:R,sourcePosition:O,targetPosition:T}=J(N.useCallback(K=>{const q=K.nodeLookup.get(g.source),ee=K.nodeLookup.get(g.target);if(!q||!ee)return{zIndex:g.zIndex,...Tr};const ne=If({id:e,sourceNode:q,targetNode:ee,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:K.connectionMode,onError:w});return{zIndex:jf({selected:g.selected,zIndex:g.zIndex,sourceNode:q,targetNode:ee,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...ne||Tr}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),se),F=N.useMemo(()=>g.markerStart?`url('#${Jn(g.markerStart,x)}')`:void 0,[g.markerStart,x]),V=N.useMemo(()=>g.markerEnd?`url('#${Jn(g.markerEnd,x)}')`:void 0,[g.markerEnd,x]);if(g.hidden||I===null||E===null||_===null||R===null)return null;const W=K=>{var te;const{addSelectedEdges:q,unselectNodesAndEdges:ee,multiSelectionActive:ne}=A.getState();D&&(A.setState({nodesSelectionActive:!1}),g.selected&&ne?(ee({nodes:[],edges:[g]}),(te=H.current)==null||te.blur()):q([e])),r&&r(K,g)},Z=i?K=>{i(K,{...g})}:void 0,U=a?K=>{a(K,{...g})}:void 0,B=c?K=>{c(K,{...g})}:void 0,G=l?K=>{l(K,{...g})}:void 0,X=f?K=>{f(K,{...g})}:void 0,Q=K=>{var q;if(!b&&Io.includes(K.key)&&D){const{unselectNodesAndEdges:ee,addSelectedEdges:ne}=A.getState();K.key==="Escape"?((q=H.current)==null||q.blur(),ee({edges:[g]})):ne([e])}};return o.jsx("svg",{style:{zIndex:k},children:o.jsxs("g",{className:oe(["react-flow__edge",`react-flow__edge-${z}`,g.className,v,{selected:g.selected,animated:g.animated,inactive:!D&&!r,updating:M,selectable:D}]),onClick:W,onDoubleClick:Z,onContextMenu:U,onMouseEnter:B,onMouseMove:G,onMouseLeave:X,onKeyDown:S?Q:void 0,tabIndex:S?0:void 0,role:g.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":S?`${li}-${x}`:void 0,ref:H,...g.domAttributes,children:[!L&&o.jsx(C,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:D,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:I,sourceY:E,targetX:_,targetY:R,sourcePosition:O,targetPosition:T,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:F,markerEnd:V,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),P&&o.jsx(Op,{edge:g,isReconnectable:P,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,sourceX:I,sourceY:E,targetX:_,targetY:R,sourcePosition:O,targetPosition:T,setUpdateHover:$,setReconnecting:j})]})})}var Fp=N.memo(Hp);const Bp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Pi({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:r,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:f,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,disableKeyboardA11y:y}){const{edgesFocusable:v,edgesReconnectable:w,elementsSelectable:b,onError:g}=J(Bp,se),m=kp(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(Ip,{defaultColor:e,rfId:n}),m.map(z=>o.jsx(Fp,{id:z,edgesFocusable:v,edgesReconnectable:w,elementsSelectable:b,noPanClassName:r,onReconnect:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,onClick:h,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:y},z))]})}Pi.displayName="EdgeRenderer";const Vp=N.memo(Pi),Yp=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Gp({children:e}){const t=J(Yp);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Wp(e){const t=_s(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Xp=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function qp(e){const t=J(Xp),n=re();return N.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Up(e){return e.connection.inProgress?{...e.connection,to:Et(e.connection.to,e.transform)}:{...e.connection}}function Kp(e){return Up}function Zp(e){const t=Kp();return J(t,se)}const Qp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Jp({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:r,width:i,height:a,isValid:c,inProgress:l}=J(Qp,se);return!(i&&r&&l)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:oe(["react-flow__connection",Ao(c)]),children:o.jsx(Di,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Di=({style:e,type:t=Ie.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:r,from:i,fromNode:a,fromHandle:c,fromPosition:l,to:f,toNode:h,toHandle:d,toPosition:u,pointer:p}=Zp();if(!r)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:c,fromX:i.x,fromY:i.y,toX:f.x,toY:f.y,fromPosition:l,toPosition:u,connectionStatus:Ao(s),toNode:h,toHandle:d,pointer:p});let x="";const y={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:f.x,targetY:f.y,targetPosition:u};switch(t){case Ie.Bezier:[x]=Wo(y);break;case Ie.SimpleBezier:[x]=ji(y);break;case Ie.Step:[x]=dn({...y,borderRadius:0});break;case Ie.SmoothStep:[x]=dn(y);break;default:[x]=qo(y)}return o.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};Di.displayName="ConnectionLine";const e0={};function Dr(e=e0){N.useRef(e),re(),N.useEffect(()=>{},[e])}function t0(){re(),N.useRef(!1),N.useEffect(()=>{},[])}function Li({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:x,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:w,selectionKeyCode:b,selectionOnDrag:g,selectionMode:m,multiSelectionKeyCode:z,panActivationKeyCode:C,zoomActivationKeyCode:S,deleteKeyCode:P,onlyRenderVisibleElements:D,elementsSelectable:H,defaultViewport:M,translateExtent:$,minZoom:L,maxZoom:j,preventScrolling:A,defaultMarkerColor:k,zoomOnScroll:I,zoomOnPinch:E,panOnScroll:_,panOnScrollSpeed:R,panOnScrollMode:O,zoomOnDoubleClick:T,panOnDrag:F,onPaneClick:V,onPaneMouseEnter:W,onPaneMouseMove:Z,onPaneMouseLeave:U,onPaneScroll:B,onPaneContextMenu:G,paneClickDistance:X,nodeClickDistance:Q,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:ie,onReconnectStart:Se,onReconnectEnd:ve,noDragClassName:Ae,noWheelClassName:ot,noPanClassName:it,disableKeyboardA11y:at,nodeExtent:Sn,rfId:It,viewport:Fe,onViewportChange:ct}){return Dr(e),Dr(t),t0(),Wp(n),qp(Fe),o.jsx(mp,{onPaneClick:V,onPaneMouseEnter:W,onPaneMouseMove:Z,onPaneMouseLeave:U,onPaneContextMenu:G,onPaneScroll:B,paneClickDistance:X,deleteKeyCode:P,selectionKeyCode:b,selectionOnDrag:g,selectionMode:m,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:z,panActivationKeyCode:C,zoomActivationKeyCode:S,elementsSelectable:H,zoomOnScroll:I,zoomOnPinch:E,zoomOnDoubleClick:T,panOnScroll:_,panOnScrollSpeed:R,panOnScrollMode:O,panOnDrag:F,defaultViewport:M,translateExtent:$,minZoom:L,maxZoom:j,onSelectionContextMenu:d,preventScrolling:A,noDragClassName:Ae,noWheelClassName:ot,noPanClassName:it,disableKeyboardA11y:at,onViewportChange:ct,isControlledViewport:!!Fe,children:o.jsxs(Gp,{children:[o.jsx(Vp,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:a,onReconnect:ie,onReconnectStart:Se,onReconnectEnd:ve,onlyRenderVisibleElements:D,onEdgeContextMenu:K,onEdgeMouseEnter:q,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:k,noPanClassName:it,disableKeyboardA11y:at,rfId:It}),o.jsx(Jp,{style:y,type:x,component:v,containerStyle:w}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(zp,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,nodeClickDistance:Q,onlyRenderVisibleElements:D,noPanClassName:it,noDragClassName:Ae,disableKeyboardA11y:at,nodeExtent:Sn,rfId:It}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}Li.displayName="GraphView";const n0=N.memo(Li),Lr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:r,height:i,fitView:a,fitViewOptions:c,minZoom:l=.5,maxZoom:f=2,nodeOrigin:h,nodeExtent:d,zIndexMode:u="basic"}={})=>{const p=new Map,x=new Map,y=new Map,v=new Map,w=s??t??[],b=n??e??[],g=h??[0,0],m=d??yt;Zo(y,v,w);const z=es(b,p,x,{nodeOrigin:g,nodeExtent:m,zIndexMode:u});let C=[0,0,1];if(a&&r&&i){const S=St(p,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:P,y:D,zoom:H}=vs(S,r,i,l,f,(c==null?void 0:c.padding)??.1);C=[P,D,H]}return{rfId:"1",width:r??0,height:i??0,transform:C,nodes:b,nodesInitialized:z,nodeLookup:p,parentLookup:x,edges:w,edgeLookup:v,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:f,translateExtent:yt,nodeExtent:m,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Je.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:c,fitViewResolver:null,connection:{...To},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:gf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:$o,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},s0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:r,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u})=>vh((p,x)=>{async function y(){const{nodeLookup:v,panZoom:w,fitViewOptions:b,fitViewResolver:g,width:m,height:z,minZoom:C,maxZoom:S}=x();w&&(await xf({nodes:v,width:m,height:z,panZoom:w,minZoom:C,maxZoom:S},b),g==null||g.resolve(!0),p({fitViewResolver:null}))}return{...Lr({nodes:e,edges:t,width:r,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:s,zIndexMode:u}),setNodes:v=>{const{nodeLookup:w,parentLookup:b,nodeOrigin:g,elevateNodesOnSelect:m,fitViewQueued:z,zIndexMode:C}=x(),S=es(v,w,b,{nodeOrigin:g,nodeExtent:d,elevateNodesOnSelect:m,checkEquality:!0,zIndexMode:C});z&&S?(y(),p({nodes:v,nodesInitialized:S,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:v,nodesInitialized:S})},setEdges:v=>{const{connectionLookup:w,edgeLookup:b}=x();Zo(w,b,v),p({edges:v})},setDefaultNodesAndEdges:(v,w)=>{if(v){const{setNodes:b}=x();b(v),p({hasDefaultNodes:!0})}if(w){const{setEdges:b}=x();b(w),p({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:w,nodeLookup:b,parentLookup:g,domNode:m,nodeOrigin:z,nodeExtent:C,debug:S,fitViewQueued:P,zIndexMode:D}=x(),{changes:H,updatedInternals:M}=Of(v,b,g,m,z,C,D);M&&(Pf(b,g,{nodeOrigin:z,nodeExtent:C,zIndexMode:D}),P?(y(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(H==null?void 0:H.length)>0&&(S&&console.log("React Flow: trigger node changes",H),w==null||w(H)))},updateNodePositions:(v,w=!1)=>{const b=[];let g=[];const{nodeLookup:m,triggerNodeChanges:z,connection:C,updateConnection:S,onNodesChangeMiddlewareMap:P}=x();for(const[D,H]of v){const M=m.get(D),$=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(H!=null&&H.position)),L={id:D,type:"position",position:$?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:w};if(M&&C.inProgress&&C.fromNode.id===M.id){const j=He(M,C.fromHandle,Y.Left,!0);S({...C,from:j})}$&&M.parentId&&b.push({id:D,parentId:M.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),g.push(L)}if(b.length>0){const{parentLookup:D,nodeOrigin:H}=x(),M=Ss(b,m,D,H);g.push(...M)}for(const D of P.values())g=D(g);z(g)},triggerNodeChanges:v=>{const{onNodesChange:w,setNodes:b,nodes:g,hasDefaultNodes:m,debug:z}=x();if(v!=null&&v.length){if(m){const C=fi(v,g);b(C)}z&&console.log("React Flow: trigger node changes",v),w==null||w(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:w,setEdges:b,edges:g,hasDefaultEdges:m,debug:z}=x();if(v!=null&&v.length){if(m){const C=hi(v,g);b(C)}z&&console.log("React Flow: trigger edge changes",v),w==null||w(v)}},addSelectedNodes:v=>{const{multiSelectionActive:w,edgeLookup:b,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:z}=x();if(w){const C=v.map(S=>Pe(S,!0));m(C);return}m(qe(g,new Set([...v]),!0)),z(qe(b))},addSelectedEdges:v=>{const{multiSelectionActive:w,edgeLookup:b,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:z}=x();if(w){const C=v.map(S=>Pe(S,!0));z(C);return}z(qe(b,new Set([...v]))),m(qe(g,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:w}={})=>{const{edges:b,nodes:g,nodeLookup:m,triggerNodeChanges:z,triggerEdgeChanges:C}=x(),S=v||g,P=w||b,D=[];for(const M of S){if(!M.selected)continue;const $=m.get(M.id);$&&($.selected=!1),D.push(Pe(M.id,!1))}const H=[];for(const M of P)M.selected&&H.push(Pe(M.id,!1));z(D),C(H)},setMinZoom:v=>{const{panZoom:w,maxZoom:b}=x();w==null||w.setScaleExtent([v,b]),p({minZoom:v})},setMaxZoom:v=>{const{panZoom:w,minZoom:b}=x();w==null||w.setScaleExtent([b,v]),p({maxZoom:v})},setTranslateExtent:v=>{var w;(w=x().panZoom)==null||w.setTranslateExtent(v),p({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:w,triggerNodeChanges:b,triggerEdgeChanges:g,elementsSelectable:m}=x();if(!m)return;const z=w.reduce((S,P)=>P.selected?[...S,Pe(P.id,!1)]:S,[]),C=v.reduce((S,P)=>P.selected?[...S,Pe(P.id,!1)]:S,[]);b(z),g(C)},setNodeExtent:v=>{const{nodes:w,nodeLookup:b,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:z,nodeExtent:C,zIndexMode:S}=x();v[0][0]===C[0][0]&&v[0][1]===C[0][1]&&v[1][0]===C[1][0]&&v[1][1]===C[1][1]||(es(w,b,g,{nodeOrigin:m,nodeExtent:v,elevateNodesOnSelect:z,checkEquality:!1,zIndexMode:S}),p({nodeExtent:v}))},panBy:v=>{const{transform:w,width:b,height:g,panZoom:m,translateExtent:z}=x();return Hf({delta:v,panZoom:m,transform:w,translateExtent:z,width:b,height:g})},setCenter:async(v,w,b)=>{const{width:g,height:m,maxZoom:z,panZoom:C}=x();if(!C)return Promise.resolve(!1);const S=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:z;return await C.setViewport({x:g/2-v*S,y:m/2-w*S,zoom:S},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...To}})},updateConnection:v=>{p({connection:v})},reset:()=>p({...Lr()})}},Object.is);function r0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:r,initialHeight:i,initialMinZoom:a,initialMaxZoom:c,initialFitViewOptions:l,fitView:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u,children:p}){const[x]=N.useState(()=>s0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:r,height:i,fitView:f,minZoom:a,maxZoom:c,fitViewOptions:l,nodeOrigin:h,nodeExtent:d,zIndexMode:u}));return o.jsx(Nh,{value:x,children:o.jsx(Gh,{children:p})})}function o0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:r,width:i,height:a,fitView:c,fitViewOptions:l,minZoom:f,maxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return N.useContext(Cn)?o.jsx(o.Fragment,{children:e}):o.jsx(r0,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:r,initialWidth:i,initialHeight:a,fitView:c,initialFitViewOptions:l,initialMinZoom:f,initialMaxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:e})}const i0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function a0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:r,nodeTypes:i,edgeTypes:a,onNodeClick:c,onEdgeClick:l,onInit:f,onMove:h,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:w,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:z,onNodeDoubleClick:C,onNodeDragStart:S,onNodeDrag:P,onNodeDragStop:D,onNodesDelete:H,onEdgesDelete:M,onDelete:$,onSelectionChange:L,onSelectionDragStart:j,onSelectionDrag:A,onSelectionDragStop:k,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onBeforeDelete:R,connectionMode:O,connectionLineType:T=Ie.Bezier,connectionLineStyle:F,connectionLineComponent:V,connectionLineContainerStyle:W,deleteKeyCode:Z="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:B=!1,selectionMode:G=wt.Full,panActivationKeyCode:X="Space",multiSelectionKeyCode:Q=Nt()?"Meta":"Control",zoomActivationKeyCode:K=Nt()?"Meta":"Control",snapToGrid:q,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:ie,autoPanOnNodeFocus:Se,nodesConnectable:ve,nodesFocusable:Ae,nodeOrigin:ot=di,edgesFocusable:it,edgesReconnectable:at,elementsSelectable:Sn=!0,defaultViewport:It=Ph,minZoom:Fe=.5,maxZoom:ct=2,translateExtent:Is=yt,preventScrolling:Zi=!0,nodeExtent:_n,defaultMarkerColor:Qi="#b1b1b7",zoomOnScroll:Ji=!0,zoomOnPinch:ea=!0,panOnScroll:ta=!1,panOnScrollSpeed:na=.5,panOnScrollMode:sa=De.Free,zoomOnDoubleClick:ra=!0,panOnDrag:oa=!0,onPaneClick:ia,onPaneMouseEnter:aa,onPaneMouseMove:ca,onPaneMouseLeave:la,onPaneScroll:da,onPaneContextMenu:ua,paneClickDistance:fa=1,nodeClickDistance:ha=0,children:pa,onReconnect:xa,onReconnectStart:ma,onReconnectEnd:ga,onEdgeContextMenu:ba,onEdgeDoubleClick:ya,onEdgeMouseEnter:wa,onEdgeMouseMove:va,onEdgeMouseLeave:Na,reconnectRadius:ja=10,onNodesChange:Ca,onEdgesChange:za,noDragClassName:ka="nodrag",noWheelClassName:Sa="nowheel",noPanClassName:$s="nopan",fitView:Ts,fitViewOptions:As,connectOnClick:_a,attributionPosition:Ea,proOptions:Ma,defaultEdgeOptions:Ia,elevateNodesOnSelect:$a=!0,elevateEdgesOnSelect:Ta=!1,disableKeyboardA11y:Ps=!1,autoPanOnConnect:Aa,autoPanOnNodeDrag:Pa,autoPanSpeed:Da,connectionRadius:La,isValidConnection:Ra,onError:Oa,style:Ha,id:Ds,nodeDragThreshold:Fa,connectionDragThreshold:Ba,viewport:Va,onViewportChange:Ya,width:Ga,height:Wa,colorMode:Xa="light",debug:qa,onScroll:$t,ariaLabelConfig:Ua,zIndexMode:Ls="basic",...Ka},Za){const En=Ds||"1",Qa=Oh(Xa),Ja=N.useCallback(Rs=>{Rs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),$t==null||$t(Rs)},[$t]);return o.jsx("div",{"data-testid":"rf__wrapper",...Ka,onScroll:Ja,style:{...Ha,...i0},ref:Za,className:oe(["react-flow",r,Qa]),id:Ds,role:"application",children:o.jsxs(o0,{nodes:e,edges:t,width:Ga,height:Wa,fitView:Ts,fitViewOptions:As,minZoom:Fe,maxZoom:ct,nodeOrigin:ot,nodeExtent:_n,zIndexMode:Ls,children:[o.jsx(n0,{onInit:f,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:z,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:a,connectionLineType:T,connectionLineStyle:F,connectionLineComponent:V,connectionLineContainerStyle:W,selectionKeyCode:U,selectionOnDrag:B,selectionMode:G,deleteKeyCode:Z,multiSelectionKeyCode:Q,panActivationKeyCode:X,zoomActivationKeyCode:K,onlyRenderVisibleElements:ne,defaultViewport:It,translateExtent:Is,minZoom:Fe,maxZoom:ct,preventScrolling:Zi,zoomOnScroll:Ji,zoomOnPinch:ea,zoomOnDoubleClick:ra,panOnScroll:ta,panOnScrollSpeed:na,panOnScrollMode:sa,panOnDrag:oa,onPaneClick:ia,onPaneMouseEnter:aa,onPaneMouseMove:ca,onPaneMouseLeave:la,onPaneScroll:da,onPaneContextMenu:ua,paneClickDistance:fa,nodeClickDistance:ha,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onReconnect:xa,onReconnectStart:ma,onReconnectEnd:ga,onEdgeContextMenu:ba,onEdgeDoubleClick:ya,onEdgeMouseEnter:wa,onEdgeMouseMove:va,onEdgeMouseLeave:Na,reconnectRadius:ja,defaultMarkerColor:Qi,noDragClassName:ka,noWheelClassName:Sa,noPanClassName:$s,rfId:En,disableKeyboardA11y:Ps,nodeExtent:_n,viewport:Va,onViewportChange:Ya}),o.jsx(Rh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:x,onConnectEnd:y,onClickConnectStart:v,onClickConnectEnd:w,nodesDraggable:ie,autoPanOnNodeFocus:Se,nodesConnectable:ve,nodesFocusable:Ae,edgesFocusable:it,edgesReconnectable:at,elementsSelectable:Sn,elevateNodesOnSelect:$a,elevateEdgesOnSelect:Ta,minZoom:Fe,maxZoom:ct,nodeExtent:_n,onNodesChange:Ca,onEdgesChange:za,snapToGrid:q,snapGrid:ee,connectionMode:O,translateExtent:Is,connectOnClick:_a,defaultEdgeOptions:Ia,fitView:Ts,fitViewOptions:As,onNodesDelete:H,onEdgesDelete:M,onDelete:$,onNodeDragStart:S,onNodeDrag:P,onNodeDragStop:D,onSelectionDrag:A,onSelectionDragStart:j,onSelectionDragStop:k,onMove:h,onMoveStart:d,onMoveEnd:u,noPanClassName:$s,nodeOrigin:ot,rfId:En,autoPanOnConnect:Aa,autoPanOnNodeDrag:Pa,autoPanSpeed:Da,onError:Oa,connectionRadius:La,isValidConnection:Ra,selectNodesOnDrag:te,nodeDragThreshold:Fa,connectionDragThreshold:Ba,onBeforeDelete:R,debug:qa,ariaLabelConfig:Ua,zIndexMode:Ls}),o.jsx(Ah,{onSelectionChange:L}),pa,o.jsx(Eh,{proOptions:Ma,position:Ea}),o.jsx(_h,{rfId:En,disableKeyboardA11y:Ps})]})})}var c0=pi(a0);const l0=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function d0({children:e}){const t=J(l0);return t?tc.createPortal(e,t):null}function u0(e){const[t,n]=N.useState(e),s=N.useCallback(r=>n(i=>fi(r,i)),[]);return[t,n,s]}function f0(e){const[t,n]=N.useState(e),s=N.useCallback(r=>n(i=>hi(r,i)),[]);return[t,n,s]}function h0({dimensions:e,lineWidth:t,variant:n,className:s}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:oe(["react-flow__background-pattern",n,s])})}function p0({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:oe(["react-flow__background-pattern","dots",t])})}var Ce;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ce||(Ce={}));const x0={[Ce.Dots]:1,[Ce.Lines]:1,[Ce.Cross]:6},m0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ri({id:e,variant:t=Ce.Dots,gap:n=20,size:s,lineWidth:r=1,offset:i=0,color:a,bgColor:c,style:l,className:f,patternClassName:h}){const d=N.useRef(null),{transform:u,patternId:p}=J(m0,se),x=s||x0[t],y=t===Ce.Dots,v=t===Ce.Cross,w=Array.isArray(n)?n:[n,n],b=[w[0]*u[2]||1,w[1]*u[2]||1],g=x*u[2],m=Array.isArray(i)?i:[i,i],z=v?[g,g]:b,C=[m[0]*u[2]||1+z[0]/2,m[1]*u[2]||1+z[1]/2],S=`${p}${e||""}`;return o.jsxs("svg",{className:oe(["react-flow__background",f]),style:{...l,...kn,"--xy-background-color-props":c,"--xy-background-pattern-color-props":a},ref:d,"data-testid":"rf__background",children:[o.jsx("pattern",{id:S,x:u[0]%b[0],y:u[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:y?o.jsx(p0,{radius:g/2,className:h}):o.jsx(h0,{dimensions:z,lineWidth:r,variant:t,className:h})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}Ri.displayName="Background";const g0=N.memo(Ri);function b0(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function y0(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function w0(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function v0(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function N0(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Rt({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:oe(["react-flow__controls-button",t]),...n,children:e})}const j0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Oi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:a,onFitView:c,onInteractiveChange:l,className:f,children:h,position:d="bottom-left",orientation:u="vertical","aria-label":p}){const x=re(),{isInteractive:y,minZoomReached:v,maxZoomReached:w,ariaLabelConfig:b}=J(j0,se),{zoomIn:g,zoomOut:m,fitView:z}=_s(),C=()=>{g(),i==null||i()},S=()=>{m(),a==null||a()},P=()=>{z(r),c==null||c()},D=()=>{x.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),l==null||l(!y)},H=u==="horizontal"?"horizontal":"vertical";return o.jsxs(zn,{className:oe(["react-flow__controls",H,f]),position:d,style:e,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(Rt,{onClick:C,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:w,children:o.jsx(b0,{})}),o.jsx(Rt,{onClick:S,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:v,children:o.jsx(y0,{})})]}),n&&o.jsx(Rt,{className:"react-flow__controls-fitview",onClick:P,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:o.jsx(w0,{})}),s&&o.jsx(Rt,{className:"react-flow__controls-interactive",onClick:D,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:y?o.jsx(N0,{}):o.jsx(v0,{})}),h]})}Oi.displayName="Controls";const C0=N.memo(Oi);function z0({id:e,x:t,y:n,width:s,height:r,style:i,color:a,strokeColor:c,strokeWidth:l,className:f,borderRadius:h,shapeRendering:d,selected:u,onClick:p}){const{background:x,backgroundColor:y}=i||{},v=a||x||y;return o.jsx("rect",{className:oe(["react-flow__minimap-node",{selected:u},f]),x:t,y:n,rx:h,ry:h,width:s,height:r,style:{fill:v,stroke:c,strokeWidth:l},shapeRendering:d,onClick:p?w=>p(w,e):void 0})}const k0=N.memo(z0),S0=e=>e.nodes.map(t=>t.id),Fn=e=>e instanceof Function?e:()=>e;function _0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:r,nodeComponent:i=k0,onClick:a}){const c=J(S0,se),l=Fn(t),f=Fn(e),h=Fn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:c.map(u=>o.jsx(M0,{id:u,nodeColorFunc:l,nodeStrokeColorFunc:f,nodeClassNameFunc:h,nodeBorderRadius:s,nodeStrokeWidth:r,NodeComponent:i,onClick:a,shapeRendering:d},u))})}function E0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:c,onClick:l}){const{node:f,x:h,y:d,width:u,height:p}=J(x=>{const y=x.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const v=y.internals.userNode,{x:w,y:b}=y.internals.positionAbsolute,{width:g,height:m}=ke(v);return{node:v,x:w,y:b,width:g,height:m}},se);return!f||f.hidden||!Ho(f)?null:o.jsx(c,{x:h,y:d,width:u,height:p,style:f.style,selected:!!f.selected,className:s(f),color:t(f),borderRadius:r,strokeColor:n(f),strokeWidth:i,shapeRendering:a,onClick:l,id:f.id})}const M0=N.memo(E0);var I0=N.memo(_0);const $0=200,T0=150,A0=e=>!e.hidden,P0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Oo(St(e.nodeLookup,{filter:A0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},D0="react-flow__minimap-desc";function Hi({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:c,bgColor:l,maskColor:f,maskStrokeColor:h,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:x,pannable:y=!1,zoomable:v=!1,ariaLabel:w,inversePan:b,zoomStep:g=1,offsetScale:m=5}){const z=re(),C=N.useRef(null),{boundingRect:S,viewBB:P,rfId:D,panZoom:H,translateExtent:M,flowWidth:$,flowHeight:L,ariaLabelConfig:j}=J(P0,se),A=(e==null?void 0:e.width)??$0,k=(e==null?void 0:e.height)??T0,I=S.width/A,E=S.height/k,_=Math.max(I,E),R=_*A,O=_*k,T=m*_,F=S.x-(R-S.width)/2-T,V=S.y-(O-S.height)/2-T,W=R+T*2,Z=O+T*2,U=`${D0}-${D}`,B=N.useRef(0),G=N.useRef();B.current=_,N.useEffect(()=>{if(C.current&&H)return G.current=Uf({domNode:C.current,panZoom:H,getTransform:()=>z.getState().transform,getViewScale:()=>B.current}),()=>{var q;(q=G.current)==null||q.destroy()}},[H]),N.useEffect(()=>{var q;(q=G.current)==null||q.update({translateExtent:M,width:$,height:L,inversePan:b,pannable:y,zoomStep:g,zoomable:v})},[y,v,b,g,M,$,L]);const X=p?q=>{var te;const[ee,ne]=((te=G.current)==null?void 0:te.pointer(q))||[0,0];p(q,{x:ee,y:ne})}:void 0,Q=x?N.useCallback((q,ee)=>{const ne=z.getState().nodeLookup.get(ee).internals.userNode;x(q,ne)},[]):void 0,K=w??j["minimap.ariaLabel"];return o.jsx(zn,{position:u,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*_:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:oe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:A,height:k,viewBox:`${F} ${V} ${W} ${Z}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":U,ref:C,onClick:X,children:[K&&o.jsx("title",{id:U,children:K}),o.jsx(I0,{onClick:Q,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:a,nodeComponent:c}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${F-T},${V-T}h${W+T*2}v${Z+T*2}h${-W-T*2}z
|
|
83
|
-
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Hi.displayName="MiniMap";N.memo(Hi);const L0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,R0={[st.Line]:"right",[st.Handle]:"bottom-right"};function O0({nodeId:e,position:t,variant:n=st.Handle,className:s,style:r=void 0,children:i,color:a,minWidth:c=10,minHeight:l=10,maxWidth:f=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:x,onResizeStart:y,onResize:v,onResizeEnd:w}){const b=bi(),g=typeof e=="string"?e:b,m=re(),z=N.useRef(null),C=n===st.Handle,S=J(N.useCallback(L0(C&&p),[C,p]),se),P=N.useRef(null),D=t??R0[n];N.useEffect(()=>{if(!(!z.current||!g))return P.current||(P.current=lh({domNode:z.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:M,transform:$,snapGrid:L,snapToGrid:j,nodeOrigin:A,domNode:k}=m.getState();return{nodeLookup:M,transform:$,snapGrid:L,snapToGrid:j,nodeOrigin:A,paneDomNode:k}},onChange:(M,$)=>{const{triggerNodeChanges:L,nodeLookup:j,parentLookup:A,nodeOrigin:k}=m.getState(),I=[],E={x:M.x,y:M.y},_=j.get(g);if(_&&_.expandParent&&_.parentId){const R=_.origin??k,O=M.width??_.measured.width??0,T=M.height??_.measured.height??0,F={id:_.id,parentId:_.parentId,rect:{width:O,height:T,...Fo({x:M.x??_.position.x,y:M.y??_.position.y},{width:O,height:T},_.parentId,j,R)}},V=Ss([F],j,A,k);I.push(...V),E.x=M.x?Math.max(R[0]*O,M.x):void 0,E.y=M.y?Math.max(R[1]*T,M.y):void 0}if(E.x!==void 0&&E.y!==void 0){const R={id:g,type:"position",position:{...E}};I.push(R)}if(M.width!==void 0&&M.height!==void 0){const O={id:g,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};I.push(O)}for(const R of $){const O={...R,type:"position"};I.push(O)}L(I)},onEnd:({width:M,height:$})=>{const L={id:g,type:"dimensions",resizing:!1,dimensions:{width:M,height:$}};m.getState().triggerNodeChanges([L])}})),P.current.update({controlPosition:D,boundaries:{minWidth:c,minHeight:l,maxWidth:f,maxHeight:h},keepAspectRatio:d,resizeDirection:u,onResizeStart:y,onResize:v,onResizeEnd:w,shouldResize:x}),()=>{var M;(M=P.current)==null||M.destroy()}},[D,c,l,f,h,d,y,v,w,x]);const H=D.split("-");return o.jsx("div",{className:oe(["react-flow__resize-control","nodrag",...H,n,s]),ref:z,style:{...r,scale:S,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:i})}N.memo(O0);function H0(){const[e,t]=N.useState([]),[n,s]=N.useState(!0);return N.useEffect(()=>{let r=!1;return fetch("/api/orbital/workflow/claude-hooks").then(async i=>{if(!r&&i.ok){const a=await i.json();t(a.data)}}).catch(()=>{}).finally(()=>{r||s(!1)}),()=>{r=!0}},[]),{ccHooks:e,loading:n}}function F0({data:e,selected:t}){const{list:n,scopeCount:s,activeHandles:r}=e,i=c=>!r||r.has(c),a=c=>(r==null?void 0:r.get(c))??n.hex;return o.jsxs("div",{className:"group relative rounded-lg border px-4 py-3 transition-all duration-200",style:{borderColor:t?n.hex:`${n.hex}66`,backgroundColor:`${n.hex}12`,boxShadow:t?`0 0 16px ${n.hex}40`:"none",minWidth:180},children:[i("left")&&o.jsx(ue,{type:"target",id:"left",position:Y.Left,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("left")}}),i("top")&&o.jsx(ue,{type:"target",id:"top",position:Y.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top"),left:"35%"}}),i("bottom-in")&&o.jsx(ue,{type:"target",id:"bottom-in",position:Y.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-in"),left:"65%"}}),o.jsxs("div",{className:"flex items-center gap-2",children:[n.isEntryPoint&&o.jsx(Xr,{className:"h-3.5 w-3.5 shrink-0 fill-current",style:{color:n.hex}}),o.jsx("span",{className:"text-sm font-medium text-foreground",children:n.label}),s>0&&o.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[10px] font-semibold leading-none",style:{backgroundColor:`${n.hex}25`,color:n.hex},children:s})]}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",style:{minHeight:18},children:[n.supportsBatch&&o.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[o.jsx(qr,{className:"h-2.5 w-2.5"}),"batch"]}),n.supportsSprint&&o.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[o.jsx(rt,{className:"h-2.5 w-2.5"}),"sprint"]})]}),i("top-out")&&o.jsx(ue,{type:"source",id:"top-out",position:Y.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top-out"),left:"65%"}}),i("right")&&o.jsx(ue,{type:"source",id:"right",position:Y.Right,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("right")}}),i("bottom-fwd")&&o.jsx(ue,{type:"source",id:"bottom-fwd",position:Y.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-fwd"),left:"65%"}}),i("bottom")&&o.jsx(ue,{type:"source",id:"bottom",position:Y.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom"),left:"35%"}})]})}const B0=N.memo(F0),V0={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},Y0={guard:{bg:"#ef4444",border:"#dc2626"},gate:{bg:"#f59e0b",border:"#d97706"},lifecycle:{bg:"#3b82f6",border:"#2563eb"},observer:{bg:"#6b7280",border:"#4b5563"}};function G0({id:e,sourceX:t,sourceY:n,targetX:s,targetY:r,sourcePosition:i,targetPosition:a,data:c,selected:l}){const f=c==null?void 0:c.edge,h=(c==null?void 0:c.hookCount)??0,d=c==null?void 0:c.highestCategory,u=(c==null?void 0:c.showHookOverlay)??!1,p=V0[(f==null?void 0:f.direction)??"forward"]??"#22c55e",[x,y,v]=dn({sourceX:t,sourceY:n,targetX:s,targetY:r,sourcePosition:i,targetPosition:a,borderRadius:12,offset:25}),w=d?Y0[d]:{bg:"#3b82f6",border:"#2563eb"};return o.jsxs(o.Fragment,{children:[o.jsx(Mt,{id:e,path:x,style:{stroke:p,strokeWidth:l?2.5:1.5,strokeDasharray:(f==null?void 0:f.direction)==="shortcut"?"6 4":void 0,opacity:l?1:.6,filter:l?`drop-shadow(0 0 4px ${p}80)`:void 0}}),o.jsx("defs",{children:o.jsxs("filter",{id:`glow-${e}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[o.jsx("feGaussianBlur",{stdDeviation:"5",result:"blur"}),o.jsxs("feMerge",{children:[o.jsx("feMergeNode",{in:"blur"}),o.jsx("feMergeNode",{in:"blur"})]})]})}),o.jsxs("circle",{fill:p,filter:`url(#glow-${e})`,opacity:.35,children:[o.jsx("animate",{attributeName:"r",values:"3;7;3",dur:"1.5s",repeatCount:"indefinite"}),o.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})]}),o.jsx("circle",{r:"2.5",fill:p,opacity:1,children:o.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})}),o.jsxs(d0,{children:[o.jsx("div",{className:"nodrag nopan pointer-events-auto cursor-pointer rounded px-1.5 py-0.5 text-[9px] font-medium transition-opacity",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${y}px,${v}px)`,color:p,backgroundColor:"rgb(9 9 11 / 0.85)",border:`1px solid ${p}33`,opacity:l?1:0},children:(f==null?void 0:f.label)??""}),u&&h>0&&o.jsx("div",{className:"nodrag nopan pointer-events-none flex items-center justify-center rounded-full text-[8px] font-bold",style:{position:"absolute",transform:`translate(-50%, -120%) translate(${y}px,${v}px)`,width:18,height:18,backgroundColor:w.bg,color:"#fff",border:`2px solid ${w.border}`,boxShadow:`0 0 6px ${w.bg}80`},children:h})]})]})}const W0=N.memo(G0),Fi={guard:{icon:pn,color:"#ef4444",label:"Guards"},gate:{icon:be,color:"#f59e0b",label:"Gates"},lifecycle:{icon:hn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},X0=["guard","gate","lifecycle","observer"],q0={blocker:"#ef4444",advisor:"#f59e0b",operator:"#3b82f6",silent:"#6b7280"};function U0({list:e,hooks:t,connectedEdges:n,onClose:s,onHookClick:r}){if(!e)return null;const i=n.filter(l=>l.to===e.id),a=n.filter(l=>l.from===e.id),c=N.useMemo(()=>{const l=new Map;for(const f of t){const h=l.get(f.category);h?h.push(f):l.set(f.category,[f])}return l},[t]);return o.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:e.hex}}),o.jsx("span",{className:"text-sm font-medium",children:e.label})]}),o.jsx("button",{onClick:s,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[o.jsxs(ut,{title:"Properties",children:[o.jsx(Ot,{label:"ID",value:e.id}),o.jsx(Ot,{label:"Order",value:String(e.order)}),e.group&&o.jsx(Ot,{label:"Group",value:e.group}),o.jsx(Ot,{label:"Color",value:e.hex})]}),o.jsxs(ut,{title:"Flags",children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.isEntryPoint&&o.jsx(ft,{icon:Xr,label:"Entry Point",color:e.hex}),e.supportsBatch&&o.jsx(ft,{icon:qr,label:"Batch",color:"#22c55e"}),e.supportsSprint&&o.jsx(ft,{icon:rt,label:"Sprint",color:"#6366f1"}),e.gitBranch&&o.jsx(ft,{icon:Ur,label:e.gitBranch,color:"#f59e0b"}),e.sessionKey&&o.jsx(ft,{icon:qc,label:e.sessionKey,color:"#8b5cf6"})]}),!e.isEntryPoint&&!e.supportsBatch&&!e.supportsSprint&&!e.gitBranch&&!e.sessionKey&&o.jsx("span",{className:"text-zinc-600",children:"None"})]}),o.jsx(ut,{title:`Inbound (${i.length})`,children:i.length===0?o.jsx("span",{className:"text-zinc-600",children:"None"}):i.map(l=>o.jsx(Rr,{edge:l,showField:"from"},`${l.from}:${l.to}`))}),o.jsx(ut,{title:`Outbound (${a.length})`,children:a.length===0?o.jsx("span",{className:"text-zinc-600",children:"None"}):a.map(l=>o.jsx(Rr,{edge:l,showField:"to"},`${l.from}:${l.to}`))}),t.length>0&&o.jsx(ut,{title:`Hooks (${t.length})`,children:o.jsx("div",{className:"space-y-3",children:X0.map(l=>{const f=c.get(l);if(!(f!=null&&f.length))return null;const h=Fi[l],d=h.icon;return o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[o.jsx(d,{className:"h-2.5 w-2.5",style:{color:h.color}}),o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:h.color},children:h.label})]}),f.map(u=>o.jsx(J0,{hook:u,onClick:r},u.id))]},l)})})})]})]})}function ut({title:e,children:t}){return o.jsxs("div",{children:[o.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),o.jsx("div",{className:"space-y-1.5",children:t})]})}function Ot({label:e,value:t}){return o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-zinc-500",children:e}),o.jsx("span",{className:"font-mono text-zinc-300",children:t})]})}function ft({icon:e,label:t,color:n}){return o.jsxs("span",{className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px]",style:{backgroundColor:`${n}15`,color:n},children:[o.jsx(e,{className:"h-3 w-3"}),t]})}const K0={before:"#eab308",after:"#3b82f6"},Z0={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},Q0={shell:ye,event:hs,webhook:ls};function J0({hook:e,onClick:t}){const n=K0[e.timing]??"#3b82f6",s=Z0[e.type]??"#22c55e",r=Q0[e.type]??ye,i=ds(e),a=q0[i],c=Fi[e.category],l=c.icon;return o.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),o.jsx("span",{className:"text-zinc-300",children:e.label}),o.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),o.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[o.jsx(r,{className:"h-2.5 w-2.5"}),e.type]})]}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[o.jsx(r,{className:"h-3 w-3 shrink-0 text-zinc-600"}),o.jsx("span",{className:"truncate",children:e.target})]}),e.description&&o.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}const ex={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function Rr({edge:e,showField:t}){const n=ex[e.direction]??"#22c55e";return o.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5",children:[o.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.direction}),o.jsx("span",{className:"text-zinc-400",children:t==="from"?e.from:e.to}),o.jsx("span",{className:"ml-auto text-zinc-600",children:e.label})]})}const tx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},Bi={guard:{icon:pn,color:"#ef4444",label:"Guards"},gate:{icon:be,color:"#f59e0b",label:"Gates"},lifecycle:{icon:hn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},nx=["guard","gate","lifecycle","observer"],sx={blocker:"#ef4444",advisor:"#f59e0b",operator:"#3b82f6",silent:"#6b7280"};function rx({edge:e,hooks:t,onClose:n,onHookClick:s}){if(!e)return null;const r=tx[e.direction]??"#22c55e",i=N.useMemo(()=>{const a=new Map;for(const c of t){const l=a.get(c.category);l?l.push(c):a.set(c.category,[c])}return a},[t]);return o.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[o.jsx("span",{className:"text-zinc-300",children:e.from}),o.jsx(Le,{className:"h-3.5 w-3.5 text-zinc-600"}),o.jsx("span",{className:"text-zinc-300",children:e.to})]}),o.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[o.jsxs(ht,{title:"Transition",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-semibold uppercase",style:{backgroundColor:`${r}20`,color:r},children:e.direction}),o.jsx("span",{className:"text-zinc-300",children:e.label})]}),o.jsx("p",{className:"mt-1.5 text-zinc-500",children:e.description})]}),e.command&&o.jsx(ht,{title:"Command",children:o.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800 bg-zinc-950 px-3 py-2 font-mono text-emerald-400",children:[o.jsx(ye,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),e.command]})}),o.jsx(ht,{title:"Behavior",children:o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(Ht,{label:"Confirm",value:e.confirmLevel}),e.dispatchOnly&&o.jsx(Ht,{label:"Dispatch Only",active:!0}),e.humanOnly&&o.jsx(Ht,{label:"Human Only",active:!0}),e.skipServerTransition&&o.jsx(Ht,{label:"Skip Server",active:!0})]})}),e.checklist&&e.checklist.length>0&&o.jsx(ht,{title:`Checklist (${e.checklist.length})`,children:o.jsx("div",{className:"space-y-1.5",children:e.checklist.map((a,c)=>o.jsxs("div",{className:"flex items-start gap-2 text-zinc-400",children:[o.jsx(Jt,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),o.jsx("span",{children:a})]},c))})}),t.length>0&&o.jsx(ht,{title:`Hooks (${t.length})`,children:o.jsx("div",{className:"space-y-3",children:nx.map(a=>{const c=i.get(a);if(!(c!=null&&c.length))return null;const l=Bi[a],f=l.icon;return o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[o.jsx(f,{className:"h-2.5 w-2.5",style:{color:l.color}}),o.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:l.color},children:l.label})]}),c.map(h=>o.jsx(cx,{hook:h,onClick:s},h.id))]},a)})})})]})]})}function ht({title:e,children:t}){return o.jsxs("div",{children:[o.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const ox={before:"#eab308",after:"#3b82f6"},ix={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},ax={shell:ye,event:hs,webhook:ls};function cx({hook:e,onClick:t}){const n=ox[e.timing]??"#3b82f6",s=ix[e.type]??"#22c55e",r=ax[e.type]??ye,i=ds(e),a=sx[i],c=Bi[e.category],l=c.icon;return o.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),o.jsx("span",{className:"text-zinc-300",children:e.label}),o.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),o.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[o.jsx(r,{className:"h-2.5 w-2.5"}),e.type]})]}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[o.jsx(r,{className:"h-3 w-3 shrink-0 text-zinc-600"}),o.jsx("span",{className:"truncate",children:e.target})]}),e.description&&o.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}function Ht({label:e,value:t,active:n}){return o.jsxs("span",{className:"rounded border px-1.5 py-0.5 text-[10px]",style:{borderColor:n?"#22c55e33":"#27272a",color:n?"#22c55e":"#a1a1aa",backgroundColor:n?"#22c55e10":"transparent"},children:[e,t?`: ${t}`:""]})}function lx({activeConfigName:e}){const[t,n]=N.useState([]),[s,r]=N.useState(!1),[i,a]=N.useState(!1),[c,l]=N.useState(""),[f,h]=N.useState(!1),[d,u]=N.useState(null),[p,x]=N.useState(!1),y=N.useCallback(async()=>{try{const m=await fetch("/api/orbital/workflow/presets");if(!m.ok)return;const z=await m.json();z.success&&n(z.data)}catch{}},[]);N.useEffect(()=>{y()},[y]);const v=async m=>{try{const z=await fetch(`/api/orbital/workflow/presets/${encodeURIComponent(m)}`);if(!z.ok)return;const C=await z.json();if(!C.success)return;const S=await fetch("/api/orbital/workflow/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C.data)});if(!S.ok)return;const P=await S.json();if(!P.success)return;const D=P.data;if(D.removedLists.length===0&&D.addedLists.length===0&&D.orphanedScopes.length===0){await w(C.data,{});return}const M=(C.data.lists??[]).map($=>$.id);u({presetName:m,config:C.data,plan:D,mappings:{...D.suggestedMappings},newListIds:M}),r(!1)}catch{}},w=async(m,z)=>{x(!0);try{await fetch("/api/orbital/workflow/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:m,orphanMappings:z})}),u(null),r(!1)}catch{}finally{x(!1)}},b=async()=>{if(c.trim()){a(!0);try{await fetch("/api/orbital/workflow/presets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.trim()})}),l(""),h(!1),y()}catch{}finally{a(!1)}}},g=async m=>{try{await fetch(`/api/orbital/workflow/presets/${encodeURIComponent(m)}`,{method:"DELETE"}),y()}catch{}};return o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>r(!s),className:"flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-xs text-zinc-300 transition-colors hover:border-zinc-700 hover:text-zinc-100",children:[e,o.jsx(ic,{className:"h-3.5 w-3.5 text-zinc-500"})]}),s&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),o.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1.5 w-64 rounded-lg border border-zinc-800 bg-zinc-900/95 p-2 shadow-xl backdrop-blur",children:[o.jsx("div",{className:"mb-1 px-2 text-[9px] font-semibold uppercase tracking-wider text-zinc-600",children:"Presets"}),t.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-zinc-600",children:"No presets saved"}):o.jsx("div",{className:"max-h-48 space-y-0.5 overflow-y-auto",children:t.map(m=>o.jsxs("div",{className:"group flex items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-zinc-800",children:[o.jsxs("button",{onClick:()=>v(m.name),className:"flex flex-1 items-center gap-2 text-left text-zinc-300",children:[o.jsx(ac,{className:"h-3 w-3 text-zinc-600"}),m.name,m.isDefault&&o.jsx("span",{className:"text-[9px] text-zinc-600",children:"(default)"})]}),!m.isDefault&&o.jsx("button",{onClick:()=>g(m.name),className:"rounded p-0.5 text-zinc-600 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:o.jsx(us,{className:"h-3 w-3"})})]},m.name))}),o.jsx("div",{className:"mt-2 border-t border-zinc-800 pt-2",children:f?o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("input",{value:c,onChange:m=>l(m.target.value),onKeyDown:m=>m.key==="Enter"&&b(),placeholder:"Preset name...",className:"flex-1 rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-700 focus:border-zinc-600",autoFocus:!0}),o.jsx("button",{onClick:b,disabled:i||!c.trim(),className:"rounded bg-zinc-800 px-2 py-1 text-xs text-zinc-300 hover:bg-zinc-700 disabled:opacity-50",children:"Save"})]}):o.jsxs("button",{onClick:()=>h(!0),className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:[o.jsx(Kr,{className:"h-3 w-3"}),"Save current as preset"]})})]})]}),d&&o.jsx(dx,{presetName:d.presetName,plan:d.plan,mappings:d.mappings,newListIds:d.newListIds,applying:p,onUpdateMapping:(m,z)=>{u(C=>C&&{...C,mappings:{...C.mappings,[m]:z}})},onConfirm:()=>w(d.config,d.mappings),onCancel:()=>u(null)})]})}function dx({presetName:e,plan:t,mappings:n,newListIds:s,applying:r,onUpdateMapping:i,onConfirm:a,onCancel:c}){const l=t.orphanedScopes.length>0,f=t.orphanedScopes.every(h=>n[h.listId]&&n[h.listId].trim().length>0);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-[60] bg-black/60 backdrop-blur-sm",onClick:c}),o.jsx("div",{className:"fixed inset-0 z-[61] flex items-center justify-center p-4",children:o.jsxs("div",{className:"w-full max-w-lg rounded-lg border border-zinc-800 bg-zinc-950 shadow-2xl",onClick:h=>h.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-3 border-b border-zinc-800 px-5 py-4",children:[o.jsx(be,{className:"h-5 w-5 text-amber-400"}),o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium text-zinc-100",children:['Switch to "',e,'"?']}),o.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"This will change your workflow and may move scopes between lists."})]})]}),o.jsxs("div",{className:"max-h-[60vh] overflow-y-auto px-5 py-4 space-y-4",children:[t.removedLists.length>0&&o.jsxs("div",{children:[o.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[o.jsx(Zr,{className:"h-3 w-3 text-red-400"}),"Lists being removed"]}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.removedLists.map(h=>o.jsx("span",{className:"rounded bg-red-500/10 px-2 py-0.5 text-xs text-red-300 border border-red-500/20",children:h},h))})]}),t.addedLists.length>0&&o.jsxs("div",{children:[o.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[o.jsx(Te,{className:"h-3 w-3 text-green-400"}),"Lists being added"]}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.addedLists.map(h=>o.jsx("span",{className:"rounded bg-green-500/10 px-2 py-0.5 text-xs text-green-300 border border-green-500/20",children:h},h))})]}),l&&o.jsxs("div",{children:[o.jsxs("h4",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[o.jsx(Yc,{className:"h-3 w-3 text-amber-400"}),"Scopes that need to move"]}),o.jsx("p",{className:"mb-3 text-xs text-zinc-500",children:"These scopes are in lists being removed. Choose where each group should be moved."}),o.jsx("div",{className:"space-y-3",children:t.orphanedScopes.map(h=>o.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/50 p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:"rounded bg-red-500/10 px-1.5 py-0.5 text-red-300 border border-red-500/20",children:h.listId}),o.jsx(Le,{className:"h-3 w-3 text-zinc-600"}),o.jsxs("select",{value:n[h.listId]??"",onChange:d=>i(h.listId,d.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"Select destination..."}),s.map(d=>o.jsx("option",{value:d,children:d},d))]})]}),o.jsxs("div",{className:"mt-2 text-xxs text-zinc-500",children:[h.scopeFiles.length," scope",h.scopeFiles.length!==1?"s":"",":"," ",o.jsxs("span",{className:"text-zinc-400",children:[h.scopeFiles.slice(0,5).join(", "),h.scopeFiles.length>5&&` +${h.scopeFiles.length-5} more`]})]})]},h.listId))})]}),t.lostEdges.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"mb-1.5 text-xs font-medium text-zinc-300",children:"Transitions being removed"}),o.jsx("div",{className:"space-y-1",children:t.lostEdges.map((h,d)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-zinc-500",children:[o.jsx("span",{children:h.from}),o.jsx(Le,{className:"h-3 w-3"}),o.jsx("span",{children:h.to})]},d))})]}),t.impactSummary&&o.jsx("div",{className:"rounded bg-zinc-900 px-3 py-2 text-xs text-zinc-400 border border-zinc-800",children:t.impactSummary})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-3",children:[o.jsx("button",{onClick:c,className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition-colors",children:"Cancel"}),o.jsx("button",{onClick:a,disabled:r||l&&!f,className:"rounded bg-amber-500/20 border border-amber-500/30 px-3 py-1.5 text-xs text-amber-300 hover:bg-amber-500/30 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:r?"Applying...":"Confirm Switch"})]})]})})]})}function ux({hook:e,open:t,onClose:n}){const[s,r]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(null);return N.useEffect(()=>{if(!e||!t){r(null),l(null);return}let f=!1;return a(!0),l(null),fetch(`/api/orbital/workflow/hooks/source?path=${encodeURIComponent(e.scriptPath)}`).then(async h=>{if(!f)if(h.ok){const d=await h.json();r(d.data)}else{const d=await h.json().catch(()=>({error:`HTTP ${h.status}`}));l(d.error??`Failed to load source (HTTP ${h.status})`),r(null)}}).catch(h=>{f||l(h instanceof Error?h.message:"Network error")}).finally(()=>{f||a(!1)}),()=>{f=!0}},[e==null?void 0:e.id,e==null?void 0:e.scriptPath,t]),e?o.jsx(cc,{open:t,onOpenChange:f=>{f||n()},children:o.jsxs(lc,{className:"max-w-[min(56rem,calc(100vw_-_2rem))] h-[80vh] flex flex-col p-0 gap-0 overflow-hidden",children:[o.jsxs(dc,{className:"px-4 pt-3 pb-2",children:[o.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[o.jsx(tn,{className:"h-4 w-4 shrink-0 text-zinc-500"}),o.jsx(uc,{className:"text-sm font-medium text-foreground leading-tight truncate",children:e.label})]}),o.jsx(fc,{className:"mt-1 font-mono text-[11px] text-zinc-500 truncate",children:e.scriptPath})]}),o.jsx("div",{className:"flex-1 min-h-0 border-t border-zinc-800 bg-[#0a0a12]",children:o.jsx(hc,{className:"h-full",children:o.jsxs("div",{className:"px-2 py-3",children:[i&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-8 text-xs text-zinc-500",children:[o.jsx(Qr,{className:"h-4 w-4 animate-spin"}),"Loading source..."]}),c&&o.jsxs("div",{className:"px-4 py-8 text-xs text-red-400",children:[o.jsx(tn,{className:"mb-2 h-5 w-5 text-zinc-600"}),c]}),s&&o.jsx(fx,{content:s.content,filePath:s.filePath}),!i&&!c&&!s&&o.jsx("div",{className:"px-4 py-8 text-xs text-zinc-600 italic",children:"No source available"})]})})}),s&&o.jsxs("div",{className:"border-t border-zinc-800 px-4 py-2 text-[10px] text-zinc-600",children:[s.lineCount," lines"]})]})}):null}function fx({content:e,filePath:t}){const n=e.split(`
|
|
84
|
-
`),s=String(n.length).length;return o.jsxs("div",{children:[o.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-900/50 px-3 py-1.5 font-mono text-[10px] text-zinc-500",children:[o.jsx(tn,{className:"h-3 w-3 shrink-0"}),t]}),o.jsx("pre",{className:"font-mono text-[12px] leading-[1.6]",children:n.map((r,i)=>o.jsxs("div",{className:"flex hover:bg-white/[0.02]",children:[o.jsx("span",{className:"select-none text-right text-zinc-700 pr-3 shrink-0",style:{width:`${s+2}ch`},children:i+1}),o.jsx("span",{className:"text-zinc-300 whitespace-pre overflow-x-auto",children:r||" "})]},i))})]})}function hx(){return o.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-zinc-800 bg-zinc-950/50 p-8 text-center",children:[o.jsxs("div",{className:"flex items-center gap-2 text-zinc-600",children:[o.jsx(rt,{className:"h-4 w-4"}),o.jsx(Jr,{className:"h-4 w-4"})]}),o.jsx("span",{className:"text-xs font-medium text-zinc-500",children:"No hook execution data available"}),o.jsx("p",{className:"max-w-xs text-[10px] text-zinc-600",children:"Hook execution tracking will be added when the Hook & Event Foundation (scope 079) is implemented. This panel will show real-time hook firing events with timestamps, results, and durations."})]})}const px={guard:{icon:pn,color:"#ef4444",label:"Guards"},gate:{icon:be,color:"#f59e0b",label:"Gates"},lifecycle:{icon:hn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observers"}},xx=["guard","gate","lifecycle","observer"],mx=["SessionStart","PreToolUse","PostToolUse","SessionEnd"],gx={SessionStart:"#22c55e",PreToolUse:"#eab308",PostToolUse:"#3b82f6",SessionEnd:"#ef4444"};function bx({hooks:e,edges:t,onHookClick:n}){const{workflowHooks:s,ccOnlyHooks:r,stats:i}=N.useMemo(()=>{const l=[],f=[];let h=0;for(const u of e)u.source==="workflow"||u.source==="both"?(l.push(u),u.source==="both"&&h++):f.push(u);const d=t.filter(u=>(u.hooks??[]).length>0).length;return{workflowHooks:l,ccOnlyHooks:f,stats:{total:e.length,workflow:l.length,ccOnly:f.length,shared:h,edgesWithHooks:d}}},[e,t]),a=N.useMemo(()=>{const l=new Map;for(const f of s){if(!f.workflow)continue;const h=f.workflow.category,d=l.get(h);d?d.push(f):l.set(h,[f])}return l},[s]),c=N.useMemo(()=>{var f;const l=new Map;for(const h of r){if(!((f=h.ccTriggers)!=null&&f.length))continue;const d=h.ccTriggers[0],u=d.event,p=d.matcher??"(all)";l.has(u)||l.set(u,[]);const x=l.get(u),y=x.find(v=>v.matcher===p);y?y.hooks.push(h):x.push({matcher:p,hooks:[h]})}return l},[r]);return o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[o.jsx(yx,{stats:i}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(xn,{className:"h-4 w-4 text-orange-400"}),o.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Transition Enforcement"}),o.jsxs("span",{className:"text-[10px] text-zinc-500",children:[s.length," hooks on ",i.edgesWithHooks," edges"]})]}),o.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire during scope transitions"}),o.jsxs("div",{className:"flex gap-1 items-stretch",children:[o.jsx("div",{className:"flex items-center",children:o.jsx("span",{className:"rounded-l bg-yellow-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-yellow-500 [writing-mode:vertical-lr] rotate-180",children:"Before"})}),o.jsx("div",{className:"grid flex-1 grid-cols-3 gap-3",children:xx.slice(0,3).map((l,f)=>o.jsx(Or,{category:l,hooks:a.get(l)??[],onHookClick:n,showArrow:f<2},l))}),o.jsx("div",{className:"flex flex-col items-center justify-center px-2",children:o.jsx("div",{className:"h-full w-px bg-zinc-800"})}),o.jsx("div",{className:"flex items-center",children:o.jsx("span",{className:"rounded-l bg-cyan-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-cyan-500 [writing-mode:vertical-lr] rotate-180",children:"After"})}),o.jsx("div",{className:"w-56",children:o.jsx(Or,{category:"observer",hooks:a.get("observer")??[],onHookClick:n,showArrow:!1})})]})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(en,{className:"h-4 w-4 text-emerald-400"}),o.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Session Enforcement"}),o.jsxs("span",{className:"text-[10px] text-zinc-500",children:[r.length," CC hooks"]})]}),o.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire on Claude Code tool events"}),o.jsx("div",{className:"grid grid-cols-4 gap-3",children:mx.map((l,f)=>o.jsx(wx,{event:l,matcherGroups:c.get(l)??[],onHookClick:n,showArrow:f<3},l))})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(Jr,{className:"h-4 w-4 text-zinc-500"}),o.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Execution Log"}),o.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] text-zinc-500",children:"scope 079"})]}),o.jsx(hx,{})]})]})}function yx({stats:e}){return o.jsxs("div",{className:"flex items-center gap-4 rounded-lg border border-zinc-800 bg-zinc-900/50 px-4 py-2.5",children:[o.jsx(Bn,{icon:rt,color:"#f97316",label:"hooks",value:e.total}),o.jsx(Vn,{}),o.jsx(Bn,{icon:xn,color:"#f97316",label:"workflow",value:e.workflow}),o.jsx(Vn,{}),o.jsx(Bn,{icon:en,color:"#10b981",label:"CC-only",value:e.ccOnly}),o.jsx(Vn,{}),o.jsxs("span",{className:"text-[10px] text-zinc-500",children:[e.shared," shared scripts"]})]})}function Bn({icon:e,color:t,label:n,value:s}){return o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(e,{className:"h-3.5 w-3.5",style:{color:t}}),o.jsx("span",{className:"text-sm font-semibold text-zinc-200",children:s}),o.jsx("span",{className:"text-[10px] text-zinc-500",children:n})]})}function Vn(){return o.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function Or({category:e,hooks:t,onHookClick:n,showArrow:s}){const r=px[e],i=r.icon;return o.jsxs("div",{className:"relative",children:[o.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[o.jsx(i,{className:"h-3 w-3",style:{color:r.color}}),o.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:r.color},children:r.label}),o.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",t.length,")"]})]}),o.jsx("div",{className:"space-y-1.5",children:t.length===0?o.jsxs("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:["No ",r.label.toLowerCase()]}):t.map(a=>o.jsx(Vi,{hook:a,onHookClick:n},a.id))}),s&&o.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:o.jsx(eo,{className:"h-4 w-4"})})]})}function wx({event:e,matcherGroups:t,onHookClick:n,showArrow:s}){const r=gx[e],i=t.reduce((a,c)=>a+c.hooks.length,0);return o.jsxs("div",{className:"relative",children:[o.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[o.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r}}),o.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:r},children:e}),i>0&&o.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",i,")"]})]}),o.jsx("div",{className:"space-y-2",children:t.length===0?o.jsx("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:"No hooks"}):t.map(a=>o.jsxs("div",{children:[a.matcher!=="(all)"&&o.jsx("div",{className:"mb-1 rounded bg-zinc-800/50 px-1.5 py-0.5 font-mono text-[9px] text-zinc-500 w-fit",children:a.matcher}),o.jsx("div",{className:"space-y-1.5",children:a.hooks.map(c=>o.jsx(Vi,{hook:c,onHookClick:n},c.id))})]},a.matcher))}),s&&o.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:o.jsx(eo,{className:"h-4 w-4"})})]})}function Vi({hook:e,onHookClick:t}){var r;const n=(r=e.workflow)==null?void 0:r.blocking,s=e.source==="both";return o.jsx("button",{onClick:()=>t(e),className:"w-full rounded border bg-zinc-950/50 px-2.5 py-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:n?"#ef444440":"#27272a"},children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[11px] font-medium text-zinc-300 truncate",children:e.label}),n&&o.jsx(xn,{className:"h-2.5 w-2.5 shrink-0 text-red-400"}),s&&o.jsx("span",{className:"ml-auto shrink-0 rounded bg-emerald-500/15 px-1 py-0.5 text-[8px] font-bold text-emerald-400",children:"+CC"})]})})}const vx={guard:{icon:pn,color:"#ef4444",label:"Guard"},gate:{icon:be,color:"#f59e0b",label:"Gate"},lifecycle:{icon:hn,color:"#3b82f6",label:"Lifecycle"},observer:{icon:Ct,color:"#6b7280",label:"Observer"}},Nx={blocker:{color:"#ef4444",description:"Blocks transition on failure"},advisor:{color:"#f59e0b",description:"Warns but allows transition"},operator:{color:"#3b82f6",description:"Side-effects during lifecycle"},silent:{color:"#6b7280",description:"Observes without affecting outcome"}},jx={before:"#eab308",after:"#3b82f6"},Cx={shell:ye,event:hs,webhook:ls},zx={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},kx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},Sx={workflow:{label:"Workflow",color:"#f97316"},"claude-code":{label:"Claude Code",color:"#10b981"},both:{label:"Both",color:"#8b5cf6"}},_x={SessionStart:"#22c55e",SessionEnd:"#ef4444",PreToolUse:"#eab308",PostToolUse:"#3b82f6"};function Ex({hook:e,edges:t,onClose:n,onViewSource:s,onNavigateToEdge:r}){var y;const i=N.useMemo(()=>e!=null&&e.workflow?t.filter(v=>(v.hooks??[]).includes(e.id)):[],[e,t]);if(!e)return null;const a=!!e.workflow,c=!!((y=e.ccTriggers)!=null&&y.length),l=Sx[e.source],f=a?vx[e.workflow.category]:null,h=(f==null?void 0:f.icon)??en,d=(f==null?void 0:f.color)??"#10b981",u=a?ds({category:e.workflow.category}):null,p=u?Nx[u]:null,x=a?Cx[e.workflow.type]??ye:en;return o.jsxs("div",{className:"flex h-full w-96 shrink-0 flex-col rounded-lg border border-zinc-800 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(h,{className:"h-4 w-4 shrink-0",style:{color:d}}),o.jsx("span",{className:"text-sm font-medium text-zinc-200 truncate",children:e.label})]}),o.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${l.color}20`,color:l.color},children:l.label}),a&&u&&p&&o.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${p.color}20`,color:p.color},children:u}),a&&e.workflow.blocking&&o.jsxs("span",{className:"flex items-center gap-1 rounded bg-red-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase text-red-400",children:[o.jsx(xn,{className:"h-2.5 w-2.5"}),"Blocking"]})]}),a&&o.jsxs(Ve,{title:"Workflow Properties",children:[o.jsx(Ft,{label:"Timing",value:e.workflow.timing,color:jx[e.workflow.timing]}),o.jsx(Ft,{label:"Type",value:e.workflow.type,color:zx[e.workflow.type]}),o.jsx(Ft,{label:"Category",value:e.workflow.category,color:d}),o.jsx(Ft,{label:"Blocking",value:e.workflow.blocking?"Yes":"No",color:e.workflow.blocking?"#ef4444":"#6b7280"})]}),a&&u&&p&&o.jsxs(Ve,{title:"Enforcement",children:[o.jsx("p",{className:"text-zinc-500",children:p.description}),o.jsxs("p",{className:"mt-1 text-[10px] text-zinc-600",children:[e.workflow.category," ",o.jsx("span",{className:"text-zinc-700",children:"→"})," ",o.jsx("span",{style:{color:p.color},children:u})]})]}),a&&e.workflow.description&&o.jsx(Ve,{title:"Description",children:o.jsx("p",{className:"text-zinc-400 leading-relaxed",children:e.workflow.description})}),o.jsx(Ve,{title:"Script Path",children:o.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800 bg-zinc-950 px-3 py-2 font-mono text-[11px] text-emerald-400",children:[o.jsx(x,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),o.jsx("span",{className:"truncate",children:e.scriptPath})]})}),c&&o.jsx(Ve,{title:`Claude Code Triggers (${e.ccTriggers.length})`,children:o.jsx(Mx,{triggers:e.ccTriggers})}),a&&o.jsx(Ve,{title:`Attached Edges (${i.length})`,children:i.length===0?o.jsx("span",{className:"text-zinc-600",children:"No edges reference this hook"}):o.jsx("div",{className:"space-y-1.5",children:i.map(v=>{const w=kx[v.direction]??"#22c55e";return o.jsxs("button",{onClick:()=>r==null?void 0:r(v.from,v.to),className:"flex w-full items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5 text-left transition-colors hover:border-zinc-700 hover:bg-zinc-900/50",children:[o.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${w}20`,color:w},children:v.direction}),o.jsx("span",{className:"text-zinc-300",children:v.from}),o.jsx(Le,{className:"h-2.5 w-2.5 text-zinc-600"}),o.jsx("span",{className:"text-zinc-300",children:v.to}),o.jsx(pc,{className:"ml-auto h-3 w-3 text-zinc-600"})]},`${v.from}:${v.to}`)})})})]}),o.jsx("div",{className:"border-t border-zinc-800 p-3",children:o.jsxs("button",{onClick:()=>s(e),className:"flex w-full items-center justify-center gap-2 rounded border border-zinc-700 bg-zinc-800/50 px-3 py-2 text-xs text-zinc-300 transition-colors hover:border-zinc-600 hover:bg-zinc-800",children:[o.jsx(tn,{className:"h-3.5 w-3.5"}),"View Source Code"]})})]})}function Mx({triggers:e}){return o.jsx("div",{className:"space-y-1.5",children:e.map((t,n)=>{const s=_x[t.event]??"#10b981";return o.jsxs("div",{className:"flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-950/30 px-2 py-1.5",children:[o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:t.event}),t.matcher&&o.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:t.matcher}),t.statusMessage&&o.jsx("span",{className:"ml-auto truncate text-[10px] text-zinc-600",children:t.statusMessage})]},n)})})}function Ve({title:e,children:t}){return o.jsxs("div",{children:[o.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Ft({label:e,value:t,color:n}){return o.jsxs("div",{className:"flex items-center justify-between py-0.5",children:[o.jsx("span",{className:"text-zinc-500",children:e}),o.jsx("span",{className:"text-zinc-300",style:n?{color:n}:void 0,children:t})]})}function Ix(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,r=Math.max(t,n,s),i=Math.min(t,n,s),a=(r+i)/2;if(r===i)return`0 0% ${Math.round(a*100)}%`;const c=r-i,l=a>.5?c/(2-r-i):c/(r+i);let f=0;return r===t?f=((n-s)/c+(n<s?6:0))/6:r===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function $x({list:e,config:t,isNew:n,onSave:s,onDelete:r,onClose:i}){const[a,c]=N.useState(()=>structuredClone(e)),[l,f]=N.useState(!1),h=N.useMemo(()=>[...new Set(t.lists.map(v=>v.group).filter(Boolean))],[t.lists]),d=N.useMemo(()=>{const y=[];return a.label.trim()||y.push("Label is required"),/^[a-z0-9-]+$/.test(a.id)||y.push("ID must be lowercase alphanumeric + hyphens"),a.id||y.push("ID is required"),t.lists.some(v=>v.id===a.id&&v.id!==e.id)&&y.push("ID already exists"),a.isEntryPoint&&t.lists.some(v=>v.isEntryPoint&&v.id!==e.id)&&y.push("Another list is already the entry point"),y},[a,t.lists,e.id]),u=N.useCallback((y,v)=>{c(w=>({...w,[y]:v}))},[]),p=N.useCallback(y=>{c(v=>({...v,hex:y,color:Ix(y)}))},[]),x=N.useCallback(()=>{d.length>0||s(a)},[a,d,s]);return o.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:a.hex}}),o.jsx("span",{className:"text-sm font-medium",children:n?"New List":"Edit List"})]}),o.jsx("button",{onClick:i,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[o.jsx(Me,{label:"ID",children:o.jsx("input",{value:a.id,onChange:y=>u("id",y.target.value),disabled:!n,className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500 disabled:opacity-50",placeholder:"e.g. review"})}),o.jsx(Me,{label:"Label",children:o.jsx("input",{value:a.label,onChange:y=>u("label",y.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),o.jsx(Me,{label:"Color",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",value:a.hex,onChange:y=>p(y.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),o.jsx("input",{value:a.hex,onChange:y=>p(y.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),o.jsx(Me,{label:"Order",children:o.jsx("input",{type:"number",value:a.order,onChange:y=>u("order",parseInt(y.target.value,10)||0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),o.jsx(Me,{label:"Group",children:o.jsxs("select",{value:a.group??"",onChange:y=>u("group",y.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"None"}),h.map(y=>o.jsx("option",{value:y,children:y},y))]})}),o.jsx(Me,{label:"Git Branch (optional)",children:o.jsx("input",{value:a.gitBranch??"",onChange:y=>u("gitBranch",y.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. dev"})}),o.jsx(Me,{label:"Session Key (optional)",children:o.jsx("input",{value:a.sessionKey??"",onChange:y=>u("sessionKey",y.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. COMMIT_SESSION"})}),o.jsx(Me,{label:"Flags",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(Bt,{label:"Entry Point",checked:a.isEntryPoint??!1,onChange:y=>u("isEntryPoint",y||void 0)}),o.jsx(Bt,{label:"Has Directory",checked:a.hasDirectory,onChange:y=>u("hasDirectory",y)}),o.jsx(Bt,{label:"Supports Batch",checked:a.supportsBatch??!1,onChange:y=>u("supportsBatch",y||void 0)}),o.jsx(Bt,{label:"Supports Sprint",checked:a.supportsSprint??!1,onChange:y=>u("supportsSprint",y||void 0)})]})}),d.length>0&&o.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:d.map(y=>o.jsx("p",{className:"text-[10px] text-red-400",children:y},y))})]}),o.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[!n&&(l?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),o.jsx("button",{onClick:r,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),o.jsx("button",{onClick:()=>f(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):o.jsx("button",{onClick:()=>f(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:o.jsx(us,{className:"h-3.5 w-3.5"})})),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:x,disabled:d.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[o.jsx(to,{className:"h-3 w-3"}),"Apply"]})]})]})}function Me({label:e,children:t}){return o.jsxs("div",{children:[o.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Bt({label:e,checked:t,onChange:n}){return o.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:s=>n(s.target.checked),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),o.jsx("span",{className:"text-zinc-300",children:e})]})}const Yn=[{value:"forward",label:"Forward",description:"Normal progression through the workflow",icon:Le,arrowColor:"#22c55e",bgActive:"rgba(34,197,94,0.12)",borderActive:"rgba(34,197,94,0.4)",hint:""},{value:"backward",label:"Backward",description:"Return to a previous stage for rework",icon:no,arrowColor:"#f59e0b",bgActive:"rgba(245,158,11,0.12)",borderActive:"rgba(245,158,11,0.4)",hint:"Backward edges are shown as amber dashed lines"},{value:"shortcut",label:"Shortcut",description:"Skip intermediate stages",icon:oo,arrowColor:"#6366f1",bgActive:"rgba(99,102,241,0.12)",borderActive:"rgba(99,102,241,0.4)",hint:"Shortcut edges are shown as dashed lines and may require a checklist confirmation"}];function Tx({value:e,onChange:t,fromLabel:n,toLabel:s}){const r=Yn.find(i=>i.value===e)??Yn[0];return o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"space-y-1.5",children:Yn.map(i=>{const a=e===i.value,c=i.icon;return o.jsxs("button",{onClick:()=>t(i.value),className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:a?i.bgActive:"transparent",border:`1px solid ${a?i.borderActive:"#27272a"}`},children:[o.jsx(c,{className:"h-4 w-4 shrink-0",style:{color:a?i.arrowColor:"#52525b"}}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-[11px] font-semibold",style:{color:a?i.arrowColor:"#a1a1aa"},children:i.label}),o.jsx("div",{className:"text-[9px] text-zinc-500 truncate",children:i.description})]})]},i.value)})}),o.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/50 px-3 py-2",children:[o.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:n}),o.jsx("svg",{width:"48",height:"16",viewBox:"0 0 48 16",className:"shrink-0",children:e==="backward"?o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"40",y1:"8",x2:"8",y2:"8",stroke:r.arrowColor,strokeWidth:"1.5",strokeDasharray:"3 2"}),o.jsx("polygon",{points:"8,8 14,4 14,12",fill:r.arrowColor})]}):o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:"8",y1:"8",x2:"40",y2:"8",stroke:r.arrowColor,strokeWidth:"1.5",strokeDasharray:e==="shortcut"?"3 2":"none"}),o.jsx("polygon",{points:"40,8 34,4 34,12",fill:r.arrowColor})]})}),o.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:s})]}),r.hint&&o.jsx("p",{className:"text-[9px] text-zinc-600 leading-relaxed",children:r.hint})]})}const Ax="093",Px=["/scope-","/git-","/test-","/session-"];function Dx({value:e,onChange:t,allowedPrefixes:n}){const[s,r]=N.useState(!1),i=N.useRef(null),a=n.length>0?n:Px,c=N.useMemo(()=>e?a.some(p=>e.startsWith(p))?{valid:!0,message:""}:{valid:!1,message:`Command must start with: ${a.join(", ")}`}:null,[e,a]),l=N.useMemo(()=>e?e.replace("{id}",Ax):null,[e]),f=N.useCallback(u=>{var p;t(u+"{id}"),r(!1),(p=i.current)==null||p.focus()},[t]),h=N.useCallback(()=>{t(null),r(!1)},[t]),d=N.useMemo(()=>{if(!e)return[];const u=[],p=a.find(x=>e.startsWith(x));if(p){u.push({text:p,type:"prefix"});const x=e.slice(p.length);Hr(x,u)}else Hr(e,u);return u},[e,a]);return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"relative",children:[o.jsxs("div",{className:"flex items-center rounded border border-zinc-700 bg-zinc-800 focus-within:border-zinc-500",children:[o.jsx(ye,{className:"ml-2 h-3 w-3 shrink-0 text-zinc-600"}),o.jsx("input",{ref:i,value:e??"",onChange:u=>t(u.target.value||null),onFocus:()=>!e&&r(!0),onBlur:()=>setTimeout(()=>r(!1),150),className:"flex-1 bg-transparent px-2 py-1.5 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600",placeholder:"/scope-implement {id}"}),e&&o.jsx("button",{onClick:h,className:"mr-1 rounded p-0.5 text-zinc-600 hover:text-zinc-300",children:o.jsx(pe,{className:"h-3 w-3"})})]}),s&&!e&&o.jsx("div",{className:"absolute left-0 top-full z-10 mt-1 w-full rounded border border-zinc-700 bg-zinc-800 py-1 shadow-xl",children:a.map(u=>o.jsxs("button",{onMouseDown:()=>f(u),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-zinc-700",children:[o.jsx("span",{className:"font-mono text-cyan-400",children:u.trim()}),o.jsx("span",{className:"text-[9px] text-zinc-600",children:"{id}"})]},u))})]}),e&&d.length>0&&o.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-mono text-xs",children:d.map((u,p)=>o.jsx("span",{style:{color:u.type==="prefix"?"#60a5fa":u.type==="placeholder"?"#facc15":"#e4e4e7"},children:u.text},p))}),l&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-[9px] text-zinc-600",children:"Preview:"}),o.jsx("code",{className:"text-[9px] font-mono text-zinc-400",children:l})]}),c&&!c.valid&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[o.jsx(be,{className:"h-3 w-3 shrink-0"}),c.message]}),o.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Use ",o.jsx("code",{className:"rounded bg-zinc-800 px-1 text-yellow-400",children:"{id}"})," as the scope ID placeholder"]})]})}function Hr(e,t){const n=/\{id\}/g;let s=0,r;for(;(r=n.exec(e))!==null;)r.index>s&&t.push({text:e.slice(s,r.index),type:"arg"}),t.push({text:"{id}",type:"placeholder"}),s=r.index+r[0].length;s<e.length&&t.push({text:e.slice(s),type:"arg"})}function Yi(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function Lx(e,t){return e.reduce((n,s,r)=>{const i=t.get(s);return i&&(n[r]=i),n},Array(e.length))}function Vt(e){return e!==null&&e>=0}function Rx(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ox(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Gi=e=>{let{rects:t,activeIndex:n,overIndex:s,index:r}=e;const i=Yi(t,s,n),a=t[r],c=i[r];return!c||!a?null:{x:c.left-a.left,y:c.top-a.top,scaleX:c.width/a.width,scaleY:c.height/a.height}},Yt={scaleX:1,scaleY:1},Hx=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:r,rects:i,overIndex:a}=e;const c=(t=i[n])!=null?t:s;if(!c)return null;if(r===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(c.top+c.height):f.top-c.top,...Yt}:null}const l=Fx(i,r,n);return r>n&&r<=a?{x:0,y:-c.height-l,...Yt}:r<n&&r>=a?{x:0,y:c.height+l,...Yt}:{x:0,y:0,...Yt}};function Fx(e,t,n){const s=e[t],r=e[t-1],i=e[t+1];return s?n<t?r?s.top-(r.top+r.height):i?i.top-(s.top+s.height):0:i?i.top-(s.top+s.height):r?s.top-(r.top+r.height):0:0}const Wi="Sortable",Xi=cs.createContext({activeIndex:-1,containerId:Wi,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Gi,disabled:{draggable:!1,droppable:!1}});function Bx(e){let{children:t,id:n,items:s,strategy:r=Gi,disabled:i=!1}=e;const{active:a,dragOverlay:c,droppableRects:l,over:f,measureDroppableContainers:h}=xc(),d=mc(Wi,n),u=c.rect!==null,p=N.useMemo(()=>s.map(C=>typeof C=="object"&&"id"in C?C.id:C),[s]),x=a!=null,y=a?p.indexOf(a.id):-1,v=f?p.indexOf(f.id):-1,w=N.useRef(p),b=!Rx(p,w.current),g=v!==-1&&y===-1||b,m=Ox(i);so(()=>{b&&x&&h(p)},[b,p,x,h]),N.useEffect(()=>{w.current=p},[p]);const z=N.useMemo(()=>({activeIndex:y,containerId:d,disabled:m,disableTransforms:g,items:p,overIndex:v,useDragOverlay:u,sortedRects:Lx(p,l),strategy:r}),[y,d,m.draggable,m.droppable,g,p,v,l,u,r]);return cs.createElement(Xi.Provider,{value:z},t)}const Vx=e=>{let{id:t,items:n,activeIndex:s,overIndex:r}=e;return Yi(n,s,r).indexOf(t)},Yx=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:r,items:i,newIndex:a,previousItems:c,previousContainerId:l,transition:f}=e;return!f||!s||c!==i&&r===a?!1:n?!0:a!==r&&t===l},Gx={duration:200,easing:"ease"},qi="transform",Wx=fs.Transition.toString({property:qi,duration:0,easing:"linear"}),Xx={roleDescription:"sortable"};function qx(e){let{disabled:t,index:n,node:s,rect:r}=e;const[i,a]=N.useState(null),c=N.useRef(n);return so(()=>{if(!t&&n!==c.current&&s.current){const l=r.current;if(l){const f=zc(s.current,{ignoreTransform:!0}),h={x:l.left-f.left,y:l.top-f.top,scaleX:l.width/f.width,scaleY:l.height/f.height};(h.x||h.y)&&a(h)}}n!==c.current&&(c.current=n)},[t,n,s,r]),N.useEffect(()=>{i&&a(null)},[i]),i}function Ux(e){let{animateLayoutChanges:t=Yx,attributes:n,disabled:s,data:r,getNewIndex:i=Vx,id:a,strategy:c,resizeObserverConfig:l,transition:f=Gx}=e;const{items:h,containerId:d,activeIndex:u,disabled:p,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:w,strategy:b}=N.useContext(Xi),g=Kx(s,p),m=h.indexOf(a),z=N.useMemo(()=>({sortable:{containerId:d,index:m,items:h},...r}),[d,r,m,h]),C=N.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:S,node:P,isOver:D,setNodeRef:H}=vc({id:a,data:z,disabled:g.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...l}}),{active:M,activatorEvent:$,activeNodeRect:L,attributes:j,setNodeRef:A,listeners:k,isDragging:I,over:E,setActivatorNodeRef:_,transform:R}=Nc({id:a,data:z,attributes:{...Xx,...n},disabled:g.draggable}),O=jc(H,A),T=!!M,F=T&&!x&&Vt(u)&&Vt(v),V=!w&&I,W=V&&F?R:null,U=F?W??(c??b)({rects:y,activeNodeRect:L,activeIndex:u,overIndex:v,index:m}):null,B=Vt(u)&&Vt(v)?i({id:a,items:h,activeIndex:u,overIndex:v}):m,G=M==null?void 0:M.id,X=N.useRef({activeId:G,items:h,newIndex:B,containerId:d}),Q=h!==X.current.items,K=t({active:M,containerId:d,isDragging:I,isSorting:T,id:a,index:m,items:h,newIndex:X.current.newIndex,previousItems:X.current.items,previousContainerId:X.current.containerId,transition:f,wasDragging:X.current.activeId!=null}),q=qx({disabled:!K,index:m,node:P,rect:S});return N.useEffect(()=>{T&&X.current.newIndex!==B&&(X.current.newIndex=B),d!==X.current.containerId&&(X.current.containerId=d),h!==X.current.items&&(X.current.items=h)},[T,B,d,h]),N.useEffect(()=>{if(G===X.current.activeId)return;if(G!=null&&X.current.activeId==null){X.current.activeId=G;return}const ne=setTimeout(()=>{X.current.activeId=G},50);return()=>clearTimeout(ne)},[G]),{active:M,activeIndex:u,attributes:j,data:z,rect:S,index:m,newIndex:B,items:h,isOver:D,isSorting:T,isDragging:I,listeners:k,node:P,overIndex:v,over:E,setNodeRef:O,setActivatorNodeRef:_,setDroppableNodeRef:H,setDraggableNodeRef:A,transform:q??U,transition:ee()};function ee(){if(q||Q&&X.current.newIndex===m)return Wx;if(!(V&&!Cc($)||!f)&&(T||K))return fs.Transition.toString({...f,property:qi})}}function Kx(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function fn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Zx=[$e.Down,$e.Right,$e.Up,$e.Left],Qx=(e,t)=>{let{context:{active:n,collisionRect:s,droppableRects:r,droppableContainers:i,over:a,scrollableAncestors:c}}=t;if(Zx.includes(e.code)){if(e.preventDefault(),!n||!s)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const u=r.get(d.id);if(u)switch(e.code){case $e.Down:s.top<u.top&&l.push(d);break;case $e.Up:s.top>u.top&&l.push(d);break;case $e.Left:s.left>u.left&&l.push(d);break;case $e.Right:s.left<u.left&&l.push(d);break}});const f=gc({collisionRect:s,droppableRects:r,droppableContainers:l});let h=bc(f,"id");if(h===(a==null?void 0:a.id)&&f.length>1&&(h=f[1].id),h!=null){const d=i.get(n.id),u=i.get(h),p=u?r.get(u.id):null,x=u==null?void 0:u.node.current;if(x&&p&&d&&u){const v=yc(x).some((C,S)=>c[S]!==C),w=Ui(d,u),b=Jx(d,u),g=v||!w?{x:0,y:0}:{x:b?s.width-p.width:0,y:b?s.height-p.height:0},m={x:p.left,y:p.top};return g.x&&g.y?m:wc(m,g)}}}};function Ui(e,t){return!fn(e)||!fn(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Jx(e,t){return!fn(e)||!fn(t)||!Ui(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const em=["Implementation is complete and tested","No merge conflicts with target branch","Tests pass on source branch","Code reviewed","Documentation updated"];function tm({items:e,onChange:t,confirmLevel:n}){const[s,r]=N.useState(""),[i,a]=N.useState(null),[c,l]=N.useState(""),f=N.useId(),h=kc(Fs(Mc,{activationConstraint:{distance:4}}),Fs(Ec,{coordinateGetter:Qx})),d=e.map((b,g)=>`checklist-${g}`),u=N.useCallback(b=>{const{active:g,over:m}=b;if(!m||g.id===m.id)return;const z=d.indexOf(String(g.id)),C=d.indexOf(String(m.id));if(z===-1||C===-1)return;const S=[...e],[P]=S.splice(z,1);S.splice(C,0,P),t(S)},[e,d,t]),p=N.useCallback(()=>{const b=s.trim();b&&(t([...e,b]),r(""))},[s,e,t]),x=N.useCallback(b=>{t(e.filter((g,m)=>m!==b)),i===b&&a(null)},[e,t,i]),y=N.useCallback(b=>{a(b),l(e[b])},[e]),v=N.useCallback(()=>{if(i===null)return;const b=c.trim();if(b&&b!==e[i]){const g=[...e];g[i]=b,t(g)}a(null)},[i,c,e,t]),w=N.useCallback(b=>{e.includes(b)||t([...e,b])},[e,t]);return o.jsxs("div",{className:"space-y-2",children:[e.length>0?o.jsx(Sc,{id:f,sensors:h,collisionDetection:_c,onDragEnd:u,children:o.jsx(Bx,{items:d,strategy:Hx,children:o.jsx("div",{className:"space-y-1",children:e.map((b,g)=>o.jsx(nm,{id:d[g],item:b,index:g,isEditing:i===g,editValue:c,onEditValueChange:l,onStartEdit:y,onFinishEdit:v,onRemove:x},d[g]))})})}):o.jsxs("div",{className:"rounded border border-dashed border-zinc-800 bg-zinc-950/30 px-3 py-4 text-center",children:[o.jsx(sl,{className:"mx-auto mb-1.5 h-4 w-4 text-zinc-700"}),o.jsx("p",{className:"text-[10px] text-zinc-600",children:"No checklist items. Add items that must be acknowledged before this transition."})]}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("input",{value:s,onChange:b=>r(b.target.value),onKeyDown:b=>b.key==="Enter"&&p(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"New item..."}),o.jsx("button",{onClick:p,disabled:!s.trim(),className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:o.jsx(Te,{className:"h-3 w-3"})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"mb-1 block text-[9px] font-medium text-zinc-600",children:"Quick add:"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:em.filter(b=>!e.includes(b)).map(b=>o.jsxs("button",{onClick:()=>w(b),className:"rounded border border-zinc-800 bg-zinc-950/50 px-1.5 py-0.5 text-[9px] text-zinc-500 transition-colors hover:border-zinc-700 hover:text-zinc-300",children:["+ ",b.length>30?`${b.slice(0,30)}…`:b]},b))})]}),n==="full"&&e.length>0&&o.jsxs("div",{className:"rounded border border-violet-500/20 bg-violet-500/5 p-2",children:[o.jsx("span",{className:"text-[9px] font-medium text-violet-400",children:"Dispatch preview:"}),o.jsx("ul",{className:"mt-1 space-y-0.5",children:e.map((b,g)=>o.jsxs("li",{className:"flex items-center gap-1.5 text-[9px] text-zinc-400",children:[o.jsx("span",{className:"h-3 w-3 shrink-0 rounded border border-zinc-600"}),b]},g))})]})]})}function nm({id:e,item:t,index:n,isEditing:s,editValue:r,onEditValueChange:i,onStartEdit:a,onFinishEdit:c,onRemove:l}){const{attributes:f,listeners:h,setNodeRef:d,transform:u,transition:p,isDragging:x}=Ux({id:e}),y={transform:fs.Transform.toString(u),transition:p,opacity:x?.5:1};return o.jsxs("div",{ref:d,style:y,className:"group flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-950/30 px-1.5 py-1",children:[o.jsx("button",{...f,...h,className:"cursor-grab touch-none rounded p-0.5 text-zinc-700 hover:text-zinc-500 active:cursor-grabbing",children:o.jsx(Wc,{className:"h-3 w-3"})}),s?o.jsx("input",{value:r,onChange:v=>i(v.target.value),onBlur:c,onKeyDown:v=>v.key==="Enter"&&c(),className:"flex-1 bg-transparent text-xs text-zinc-200 outline-none",autoFocus:!0}):o.jsx("span",{onClick:()=>a(n),className:"flex-1 cursor-text truncate text-xs text-zinc-300",children:t}),o.jsx("button",{onClick:()=>l(n),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:o.jsx(Zr,{className:"h-3 w-3"})})]})}function sm({dispatchOnly:e,humanOnly:t,skipServerTransition:n,confirmLevel:s,hasCommand:r,onDispatchOnlyChange:i,onHumanOnlyChange:a,onSkipServerTransitionChange:c,onConfirmLevelChange:l}){return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Gn,{icon:ye,label:"Dispatch Only",description:"This transition can only be triggered by a skill command, not by manual drag-and-drop",checked:e,onChange:i}),e&&!r&&o.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"No command configured — add one below for this toggle to be effective"}),o.jsx(Gn,{icon:ol,label:"Human Only",description:"This transition requires human confirmation and cannot be triggered by automated processes",checked:t,onChange:a,badge:t?"HUMAN":void 0,badgeColor:"#6366f1"}),o.jsx(Gn,{icon:tl,label:"Skip Server Transition",description:"The skill command handles the status change itself — the server won't move the scope",checked:n,onChange:c}),n&&o.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"The bound skill must handle the scope move itself"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Confirmation Mode"}),o.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[o.jsx(Fr,{icon:rt,label:"Quick",description:"Immediate — one click to confirm",active:s==="quick",onClick:()=>l("quick"),color:"#f59e0b"}),o.jsx(Fr,{icon:Hc,label:"Full",description:"Review — must acknowledge checklist",active:s==="full",onClick:()=>l("full"),color:"#8b5cf6"})]}),s==="full"&&o.jsx("p",{className:"mt-1.5 text-[9px] text-violet-400",children:"Users must review the checklist before confirming this transition"})]})]})}function Gn({icon:e,label:t,description:n,checked:s,onChange:r,badge:i,badgeColor:a}){return o.jsxs("label",{className:"flex cursor-pointer gap-2 rounded-md border border-zinc-800 bg-zinc-950/30 px-2.5 py-2 transition-colors hover:border-zinc-700",children:[o.jsxs("div",{className:"relative mt-0.5 h-4 w-7 shrink-0 rounded-full transition-colors",style:{backgroundColor:s?"#22c55e":"#3f3f46"},children:[o.jsx("div",{className:"absolute top-0.5 h-3 w-3 rounded-full bg-white transition-transform",style:{transform:s?"translateX(12px)":"translateX(2px)"}}),o.jsx("input",{type:"checkbox",checked:s,onChange:c=>r(c.target.checked),className:"sr-only"})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(e,{className:"h-3 w-3 text-zinc-400"}),o.jsx("span",{className:"text-[11px] font-medium text-zinc-300",children:t}),i&&o.jsx("span",{className:"rounded px-1 py-0.5 text-[8px] font-bold",style:{backgroundColor:`${a}20`,color:a},children:i})]}),o.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-600 leading-relaxed",children:n})]})]})}function Fr({icon:e,label:t,description:n,active:s,onClick:r,color:i}){return o.jsxs("button",{onClick:r,className:"rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:s?`${i}12`:"transparent",border:`1px solid ${s?`${i}60`:"#27272a"}`},children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(e,{className:"h-3.5 w-3.5",style:{color:s?i:"#52525b"}}),o.jsx("span",{className:"text-[10px] font-semibold",style:{color:s?i:"#a1a1aa"},children:t})]}),o.jsx("p",{className:"mt-0.5 text-[8px]",style:{color:s?"#a1a1aa":"#52525b"},children:n})]})}function rm({edge:e,lists:t}){const n=N.useMemo(()=>[...t].sort((c,l)=>c.order-l.order),[t]),s=t.find(c=>c.id===e.from),r=t.find(c=>c.id===e.to),i=(s==null?void 0:s.order)??-1,a=(r==null?void 0:r.order)??-1;return e.direction==="shortcut"?o.jsx(om,{sortedLists:n,fromOrder:i,toOrder:a,edge:e}):e.direction==="backward"?o.jsx(im,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(r==null?void 0:r.label)??e.to}):o.jsx(am,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(r==null?void 0:r.label)??e.to})}function om({sortedLists:e,fromOrder:t,toOrder:n,edge:s}){const r=e.filter(i=>i.order>Math.min(t,n)&&i.order<Math.max(t,n));return o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ms,{icon:oo,color:"#6366f1",label:"Shortcut — Skip Rules"}),o.jsx("div",{className:"flex items-center gap-1 rounded border border-zinc-800 bg-zinc-950/50 px-2.5 py-2 overflow-x-auto",children:e.map((i,a)=>{const c=i.id===s.from,l=i.id===s.to,f=r.some(h=>h.id===i.id);return o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[8px] font-medium whitespace-nowrap",style:{backgroundColor:c||l?"#6366f120":f?"#27272a":"#18181b",color:c||l?"#818cf8":f?"#52525b":"#71717a",border:c||l?"1px solid #6366f140":"1px solid transparent",textDecoration:f?"line-through":"none"},children:i.label}),a<e.length-1&&o.jsx("span",{className:"text-[8px] text-zinc-700",children:"›"})]},i.id)})}),r.length>0?o.jsxs("p",{className:"text-[9px] text-zinc-500",children:[o.jsx("span",{className:"text-indigo-400",children:s.from})," → ",o.jsx("span",{className:"text-indigo-400",children:s.to})," skips ",o.jsx("span",{className:"text-zinc-400",children:r.map(i=>i.label).join(", ")})]}):o.jsx("p",{className:"text-[9px] text-zinc-500",children:"No intermediate lists are skipped."})]})}function im({edge:e,fromLabel:t,toLabel:n}){const s=["Issue documented","Fix scope created","Root cause identified"];return o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ms,{icon:no,color:"#f59e0b",label:"Backward — Revert Rules"}),o.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/20 bg-amber-500/5 px-2.5 py-2",children:[o.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:t}),o.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[o.jsx("line",{x1:"20",y1:"6",x2:"4",y2:"6",stroke:"#f59e0b",strokeWidth:"1.5",strokeDasharray:"2 2"}),o.jsx("polygon",{points:"4,6 8,3 8,9",fill:"#f59e0b"})]}),o.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:n}),o.jsx("span",{className:"ml-auto rounded bg-amber-500/15 px-1.5 py-0.5 text-[8px] font-semibold text-amber-400",children:"REPAIR"})]}),o.jsxs("p",{className:"text-[9px] text-zinc-500",children:[t," → ",n," is a ",o.jsx("span",{className:"text-amber-400",children:"repair"})," operation. Scopes move backward for rework."]}),(!e.checklist||e.checklist.length===0)&&o.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-2",children:[o.jsxs("div",{className:"flex items-center gap-1 mb-1.5",children:[o.jsx(Ic,{className:"h-3 w-3 text-zinc-600"}),o.jsx("span",{className:"text-[9px] font-medium text-zinc-500",children:"Suggested checklist items"})]}),o.jsx("ul",{className:"space-y-0.5",children:s.map(r=>o.jsxs("li",{className:"text-[9px] text-zinc-600 flex items-center gap-1.5",children:[o.jsx("span",{className:"h-1 w-1 rounded-full bg-zinc-700 shrink-0"}),r]},r))})]})]})}function am({edge:e,fromLabel:t,toLabel:n}){return o.jsxs("div",{className:"space-y-2",children:[o.jsx(Ms,{icon:Le,color:"#22c55e",label:"Forward — Progression"}),o.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2",children:[o.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:t}),o.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[o.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6",stroke:"#22c55e",strokeWidth:"1.5"}),o.jsx("polygon",{points:"20,6 16,3 16,9",fill:"#22c55e"})]}),o.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:n})]}),e.dispatchOnly&&o.jsxs("p",{className:"text-[9px] text-zinc-500",children:["This transition requires a ",o.jsx("span",{className:"text-cyan-400",children:"skill command"})," to trigger."]})]})}function Ms({icon:e,color:t,label:n}){return o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(e,{className:"h-3 w-3",style:{color:t}}),o.jsx("span",{className:"text-[10px] font-semibold",style:{color:t},children:n})]})}function cm({edge:e,config:t,onSave:n,onDelete:s,onClose:r}){const[i,a]=N.useState(()=>structuredClone(e)),[c,l]=N.useState(!1),f=N.useMemo(()=>t.lists.map(b=>b.id),[t.lists]),h=N.useMemo(()=>t.hooks??[],[t.hooks]),d=N.useMemo(()=>t.allowedCommandPrefixes??[],[t.allowedCommandPrefixes]),u=N.useMemo(()=>{var b;return((b=t.lists.find(g=>g.id===i.from))==null?void 0:b.label)??i.from},[t.lists,i.from]),p=N.useMemo(()=>{var b;return((b=t.lists.find(g=>g.id===i.to))==null?void 0:b.label)??i.to},[t.lists,i.to]),x=N.useMemo(()=>{const b=[];i.from||b.push("From is required"),i.to||b.push("To is required"),i.from===i.to&&b.push("From and To must be different"),i.label.trim()||b.push("Label is required"),i.description.trim()||b.push("Description is required");const g=`${i.from}:${i.to}`,m=`${e.from}:${e.to}`;return g!==m&&t.edges.some(z=>`${z.from}:${z.to}`===g)&&b.push("An edge with this from:to already exists"),b},[i,e,t.edges]),y=N.useCallback((b,g)=>{a(m=>({...m,[b]:g}))},[]),v=N.useCallback(b=>{a(g=>{const m=g.hooks??[],z=m.includes(b);return{...g,hooks:z?m.filter(C=>C!==b):[...m,b]}})},[]),w=N.useCallback(()=>{x.length>0||n(i)},[i,x,n]);return o.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsx("span",{className:"text-sm font-medium",children:"Edit Edge"}),o.jsx("button",{onClick:r,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(me,{label:"From",children:o.jsx("select",{value:i.from,onChange:b=>y("from",b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(b=>o.jsx("option",{value:b,children:b},b))})}),o.jsx(me,{label:"To",children:o.jsx("select",{value:i.to,onChange:b=>y("to",b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(b=>o.jsx("option",{value:b,children:b},b))})})]}),o.jsx(me,{label:"Direction",children:o.jsx(Tx,{value:i.direction,onChange:b=>y("direction",b),fromLabel:u,toLabel:p})}),o.jsx(me,{label:"Movement Rules",children:o.jsx(rm,{edge:i,lists:t.lists})}),o.jsx(me,{label:"Label",children:o.jsx("input",{value:i.label,onChange:b=>y("label",b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),o.jsx(me,{label:"Description",children:o.jsx("textarea",{value:i.description,onChange:b=>y("description",b.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),o.jsx(me,{label:"Skill Command",children:o.jsx(Dx,{value:i.command,onChange:b=>y("command",b),allowedPrefixes:d})}),o.jsx(me,{label:"Dispatch & Confirmation",children:o.jsx(sm,{dispatchOnly:i.dispatchOnly??!1,humanOnly:i.humanOnly??!1,skipServerTransition:i.skipServerTransition??!1,confirmLevel:i.confirmLevel,hasCommand:i.command!==null,onDispatchOnlyChange:b=>y("dispatchOnly",b||void 0),onHumanOnlyChange:b=>y("humanOnly",b||void 0),onSkipServerTransitionChange:b=>y("skipServerTransition",b||void 0),onConfirmLevelChange:b=>y("confirmLevel",b)})}),o.jsx(me,{label:`Checklist (${(i.checklist??[]).length})`,children:o.jsx(tm,{items:i.checklist??[],onChange:b=>y("checklist",b.length>0?b:void 0),confirmLevel:i.confirmLevel})}),h.length>0&&o.jsx(me,{label:`Hooks (${(i.hooks??[]).length} selected)`,children:o.jsx("div",{className:"space-y-1.5",children:h.map(b=>o.jsx(lm,{hook:b,checked:(i.hooks??[]).includes(b.id),onToggle:()=>v(b.id)},b.id))})}),x.length>0&&o.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(b=>o.jsx("p",{className:"text-[10px] text-red-400",children:b},b))})]}),o.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[c?o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),o.jsx("button",{onClick:s,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),o.jsx("button",{onClick:()=>l(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):o.jsx("button",{onClick:()=>l(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:o.jsx(us,{className:"h-3.5 w-3.5"})}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:w,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[o.jsx(to,{className:"h-3 w-3"}),"Apply"]})]})]})}function me({label:e,children:t}){return o.jsxs("div",{children:[o.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function lm({hook:e,checked:t,onToggle:n}){return o.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:n,className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("span",{className:"text-zinc-300",children:e.label}),o.jsxs("span",{className:"ml-1.5 text-[9px] text-zinc-600",children:[e.timing," · ",e.type]})]})]})}function dm({canUndo:e,canRedo:t,changeCount:n,validation:s,saving:r,onAddList:i,onAddEdge:a,onConfigSettings:c,onUndo:l,onRedo:f,onSave:h,onDiscard:d,onPreview:u}){return o.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-cyan-500/30 bg-zinc-900/95 px-3 py-2 shadow-lg backdrop-blur",children:[o.jsx(Ye,{icon:Te,label:"List",onClick:i,color:"blue"}),o.jsx(Ye,{icon:Ur,label:"Edge",onClick:a,color:"blue"}),o.jsx(Ye,{icon:ro,label:"Config",onClick:c}),o.jsx(Wn,{}),o.jsx(Ye,{icon:$c,onClick:l,disabled:!e}),o.jsx(Ye,{icon:Jc,onClick:f,disabled:!t}),n>0&&o.jsxs("span",{className:"rounded-full bg-amber-500/20 px-2 py-0.5 text-[9px] font-semibold text-amber-400",children:[n," change",n!==1?"s":""]}),o.jsx(Wn,{}),s.valid?o.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[o.jsx(Jt,{className:"h-3.5 w-3.5"}),"Valid"]}):o.jsxs("span",{className:"group relative flex items-center gap-1 text-[10px] text-red-400",children:[o.jsx(be,{className:"h-3.5 w-3.5"}),s.errors.length," error",s.errors.length!==1?"s":"",o.jsx("div",{className:"absolute bottom-full left-0 z-50 mb-2 hidden w-64 rounded border border-red-500/30 bg-zinc-900 p-2 shadow-xl group-hover:block",children:s.errors.map(p=>o.jsx("p",{className:"text-[10px] text-red-400",children:p},p))})]}),o.jsx(Wn,{}),o.jsx(Ye,{icon:Ct,label:"Preview",onClick:u}),o.jsxs("button",{onClick:h,disabled:!s.valid||n===0||r,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-emerald-500 disabled:opacity-40",children:[o.jsx(Kr,{className:"h-3 w-3"}),r?"Saving...":"Save"]}),o.jsxs("button",{onClick:d,className:"flex items-center gap-1.5 rounded bg-red-600/80 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-red-500",children:[o.jsx(Tc,{className:"h-3 w-3"}),"Discard"]})]})}function Ye({icon:e,label:t,onClick:n,disabled:s,color:r}){const i=r==="blue";return o.jsxs("button",{onClick:n,disabled:s,className:"flex items-center gap-1 rounded px-2 py-1.5 text-[10px] font-medium transition-colors disabled:opacity-30",style:{color:i?"#3b82f6":"#a1a1aa",backgroundColor:"transparent"},onMouseEnter:a=>{a.currentTarget.style.backgroundColor=i?"#3b82f615":"#27272a"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:[o.jsx(e,{className:"h-3.5 w-3.5"}),t]})}function Wn(){return o.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function um(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,r=Math.max(t,n,s),i=Math.min(t,n,s),a=(r+i)/2;if(r===i)return`0 0% ${Math.round(a*100)}%`;const c=r-i,l=a>.5?c/(2-r-i):c/(r+i);let f=0;return r===t?f=((n-s)/c+(n<s?6:0))/6:r===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function fm({open:e,onOpenChange:t,config:n,onAdd:s}){const[r,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("#3b82f6"),[h,d]=N.useState(""),u=N.useMemo(()=>[...new Set(n.lists.map(b=>b.group).filter(Boolean))],[n.lists]),p=N.useMemo(()=>Math.max(0,...n.lists.map(w=>w.order)),[n.lists]),x=N.useMemo(()=>{const w=[];return r?/^[a-z0-9-]+$/.test(r)?n.lists.some(b=>b.id===r)&&w.push("ID already exists"):w.push("ID must be lowercase alphanumeric + hyphens"):w.push("ID is required"),a.trim()||w.push("Label is required"),w},[r,a,n.lists]),y=N.useCallback(()=>{i(""),c(""),f("#3b82f6"),d("")},[]),v=N.useCallback(()=>{if(x.length>0)return;const w={id:r,label:a.trim(),order:p+1,color:um(l),hex:l,hasDirectory:!0,...h?{group:h}:{}};s(w),y(),t(!1)},[x,r,a,l,h,p,s,y,t]);return o.jsx(ss,{open:e,onOpenChange:t,children:o.jsxs(rs,{children:[o.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),o.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[o.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[o.jsx(Te,{className:"h-4 w-4 text-cyan-400"}),"Add List"]}),o.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-3 rounded border border-zinc-800 bg-zinc-950/50 p-3",children:[o.jsx("div",{className:"h-5 w-5 rounded",style:{backgroundColor:l}}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-zinc-200",children:a||"New List"}),o.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:r||"list-id"})]})]}),o.jsx(Gt,{label:"ID",children:o.jsx("input",{value:r,onChange:w=>i(w.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. review",autoFocus:!0})}),o.jsx(Gt,{label:"Label",children:o.jsx("input",{value:a,onChange:w=>c(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),o.jsx(Gt,{label:"Color",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",value:l,onChange:w=>f(w.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),o.jsx("input",{value:l,onChange:w=>f(w.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),o.jsx(Gt,{label:"Group",children:o.jsxs("select",{value:h,onChange:w=>d(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"None"}),u.map(w=>o.jsx("option",{value:w,children:w},w))]})}),x.length>0&&r.length>0&&o.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(w=>o.jsx("p",{className:"text-[10px] text-red-400",children:w},w))})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[o.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),o.jsxs("button",{onClick:v,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[o.jsx(Te,{className:"h-3.5 w-3.5"}),"Add List"]})]})]})]})})}function Gt({label:e,children:t}){return o.jsxs("div",{children:[o.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const hm=["forward","backward","shortcut"],pm=["quick","full"],xm={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function mm({open:e,onOpenChange:t,config:n,onAdd:s}){const[r,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("forward"),[h,d]=N.useState(""),[u,p]=N.useState(""),[x,y]=N.useState("quick"),v=N.useMemo(()=>n.lists.map(m=>m.id),[n.lists]),w=N.useMemo(()=>{const m=[];return r||m.push("From is required"),a||m.push("To is required"),r&&a&&r===a&&m.push("From and To must be different"),r&&a&&n.edges.some(z=>z.from===r&&z.to===a)&&m.push("An edge with this from:to already exists"),h.trim()||m.push("Label is required"),m},[r,a,h,n.edges]),b=N.useCallback(()=>{i(""),c(""),f("forward"),d(""),p(""),y("quick")},[]),g=N.useCallback(()=>{if(w.length>0)return;const m={from:r,to:a,direction:l,label:h.trim(),description:`Transition from ${r} to ${a}`,command:u.trim()||null,confirmLevel:x};s(m),b(),t(!1)},[w,r,a,l,h,u,x,s,b,t]);return o.jsx(ss,{open:e,onOpenChange:t,children:o.jsxs(rs,{children:[o.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),o.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[o.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[o.jsx(Te,{className:"h-4 w-4 text-cyan-400"}),"Add Edge"]}),o.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(Ge,{label:"From",children:o.jsxs("select",{value:r,onChange:m=>i(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"Select..."}),v.map(m=>o.jsx("option",{value:m,children:m},m))]})}),o.jsx(Ge,{label:"To",children:o.jsxs("select",{value:a,onChange:m=>c(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"Select..."}),v.map(m=>o.jsx("option",{value:m,children:m},m))]})})]}),o.jsx(Ge,{label:"Direction",children:o.jsx("div",{className:"flex gap-1",children:hm.map(m=>{const z=xm[m];return o.jsx("button",{onClick:()=>f(m),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:l===m?`${z}20`:"transparent",color:l===m?z:"#71717a",border:`1px solid ${l===m?`${z}40`:"#27272a"}`},children:m},m)})})}),o.jsx(Ge,{label:"Label",children:o.jsx("input",{value:h,onChange:m=>d(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Implement"})}),o.jsx(Ge,{label:"Command (optional)",children:o.jsx("input",{value:u,onChange:m=>p(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/scope-implement {id}"})}),o.jsx(Ge,{label:"Confirm Level",children:o.jsx("div",{className:"flex gap-1",children:pm.map(m=>o.jsx("button",{onClick:()=>y(m),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:x===m?"#22c55e20":"transparent",color:x===m?"#22c55e":"#71717a",border:`1px solid ${x===m?"#22c55e40":"#27272a"}`},children:m},m))})}),w.length>0&&r.length>0&&a.length>0&&o.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:w.map(m=>o.jsx("p",{className:"text-[10px] text-red-400",children:m},m))})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[o.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),o.jsxs("button",{onClick:g,disabled:w.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[o.jsx(Te,{className:"h-3.5 w-3.5"}),"Add Edge"]})]})]})]})})}function Ge({label:e,children:t}){return o.jsxs("div",{children:[o.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function gm({open:e,onOpenChange:t,config:n,plan:s,loading:r,error:i,onApply:a}){const[c,l]=N.useState({});N.useMemo(()=>{s!=null&&s.suggestedMappings&&l({...s.suggestedMappings})},[s==null?void 0:s.suggestedMappings]);const f=N.useMemo(()=>n.lists.map(u=>u.id),[n.lists]),h=N.useMemo(()=>s?s.orphanedScopes.every(u=>c[u.listId]):!0,[s,c]),d=N.useCallback(()=>{h&&a(c)},[h,c,a]);return o.jsx(ss,{open:e,onOpenChange:t,children:o.jsxs(rs,{children:[o.jsx(os,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),o.jsxs(is,{className:"fixed left-1/2 top-1/2 z-50 max-h-[80vh] w-[520px] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[o.jsxs(as,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[o.jsx(be,{className:"h-4 w-4 text-amber-400"}),"Migration Preview"]}),o.jsx(Ke,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-5 text-xs",children:[r&&o.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-zinc-500",children:[o.jsx(Qr,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{children:"Computing migration impact..."})]}),i&&o.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3 text-red-400",children:i}),s&&!r&&o.jsxs("div",{className:"space-y-4",children:[!s.valid&&o.jsxs("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3",children:[o.jsx("p",{className:"mb-2 font-semibold text-red-400",children:"Validation Errors"}),s.validationErrors.map(u=>o.jsx("p",{className:"text-red-400",children:u},u))]}),s.valid&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-3",children:o.jsx("p",{className:"text-zinc-300",children:s.impactSummary})}),s.addedLists.length>0&&o.jsx(Wt,{title:`Added Lists (${s.addedLists.length})`,children:o.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.addedLists.map(u=>o.jsxs("span",{className:"rounded bg-emerald-500/15 px-2 py-1 font-mono text-emerald-400",children:["+ ",u]},u))})}),s.removedLists.length>0&&o.jsx(Wt,{title:`Removed Lists (${s.removedLists.length})`,children:o.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.removedLists.map(u=>o.jsxs("span",{className:"rounded bg-red-500/15 px-2 py-1 font-mono text-red-400",children:["- ",u]},u))})}),s.lostEdges.length>0&&o.jsx(Wt,{title:`Lost Edges (${s.lostEdges.length})`,children:o.jsx("div",{className:"space-y-1",children:s.lostEdges.map(u=>o.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[o.jsx("span",{className:"font-mono",children:u.from}),o.jsx(Le,{className:"h-3 w-3 text-zinc-600"}),o.jsx("span",{className:"font-mono",children:u.to})]},`${u.from}:${u.to}`))})}),s.orphanedScopes.length>0&&o.jsx(Wt,{title:"Orphaned Scopes — Reassignment Required",children:o.jsx("div",{className:"space-y-3",children:s.orphanedScopes.map(u=>o.jsxs("div",{className:"rounded border border-amber-500/30 bg-amber-500/5 p-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-mono text-amber-400",children:u.listId}),o.jsxs("span",{className:"text-zinc-500",children:[u.scopeFiles.length," scope(s)"]})]}),o.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[o.jsx("span",{className:"text-zinc-500",children:"Move to:"}),o.jsxs("select",{value:c[u.listId]??"",onChange:p=>l(x=>({...x,[u.listId]:p.target.value})),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[o.jsx("option",{value:"",children:"Select destination..."}),f.map(p=>o.jsx("option",{value:p,children:p},p))]})]}),u.scopeFiles.length<=5&&o.jsx("div",{className:"mt-2 space-y-0.5",children:u.scopeFiles.map(p=>o.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:p},p))})]},u.listId))})}),s.removedLists.length===0&&s.addedLists.length===0&&s.lostEdges.length===0&&s.orphanedScopes.length===0&&o.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/30 bg-emerald-500/10 p-3 text-emerald-400",children:[o.jsx(Jt,{className:"h-4 w-4"}),o.jsx("span",{children:"No migration needed — configs are compatible"})]})]})]})]}),o.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[o.jsx(Ke,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),(s==null?void 0:s.valid)&&o.jsxs("button",{onClick:d,disabled:!h,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-40",children:[o.jsx(Jt,{className:"h-3.5 w-3.5"}),"Apply Migration"]})]})]})]})})}function Wt({title:e,children:t}){return o.jsxs("div",{children:[o.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function bm({prefixes:e,edges:t,onChange:n}){const[s,r]=N.useState(""),[i,a]=N.useState(null),c=N.useMemo(()=>{const d=new Map;for(const u of e){const p=t.filter(x=>{var y;return(y=x.command)==null?void 0:y.startsWith(u)}).map(x=>`${x.from} → ${x.to}`);d.set(u,p)}return d},[e,t]),l=N.useCallback(d=>d.startsWith("/")?d.endsWith(" ")?e.includes(d)?"Already exists":null:"Must end with a space":"Must start with /",[e]),f=N.useCallback(()=>{const d=s,u=l(d);if(u){a(u);return}n([...e,d]),r(""),a(null)},[s,e,n,l]),h=N.useCallback(d=>{n(e.filter(u=>u!==d))},[e,n]);return o.jsxs("div",{className:"space-y-2",children:[e.length>0?o.jsx("div",{className:"space-y-1",children:e.map(d=>{const u=c.get(d)??[];return o.jsxs("div",{className:"group flex items-start gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2.5 py-1.5",children:[o.jsx(ye,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("code",{className:"text-xs font-mono text-cyan-400",children:d.trim()}),u.length>0?o.jsxs("p",{className:"mt-0.5 text-[9px] text-zinc-600",children:["Used by: ",u.join(", ")]}):o.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-700",children:"No edges use this prefix"})]}),o.jsx("button",{onClick:()=>h(d),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:o.jsx(pe,{className:"h-3 w-3"})})]},d)})}):o.jsx("p",{className:"text-[10px] text-zinc-600",children:"No command prefixes configured."}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx("input",{value:s,onChange:d=>{r(d.target.value),a(null)},onKeyDown:d=>d.key==="Enter"&&f(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/prefix "}),o.jsx("button",{onClick:f,disabled:!s,className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:o.jsx(Te,{className:"h-3 w-3"})})]}),i&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[o.jsx(be,{className:"h-3 w-3 shrink-0"}),i]}),o.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Prefixes must start with ",o.jsx("code",{className:"text-zinc-400",children:"/"})," and end with a space"]})]})}function ym({config:e,onUpdate:t,onClose:n}){const[s,r]=N.useState(e.name),[i,a]=N.useState(e.description??""),[c,l]=N.useState(e.commitBranchPatterns??""),[f,h]=N.useState(e.branchingMode??"trunk"),d=N.useMemo(()=>e.lists.map(b=>b.id),[e.lists]),[u,p]=N.useState(new Set(e.terminalStatuses??[])),x=N.useMemo(()=>{if(!c)return null;try{return new RegExp(c),null}catch{return"Invalid regex pattern"}},[c]),y=N.useCallback(b=>{p(g=>{const m=new Set(g);return m.has(b)?m.delete(b):m.add(b),m})},[]),v=N.useCallback(b=>{t({...e,allowedCommandPrefixes:b})},[e,t]),w=N.useCallback(()=>{t({...e,name:s.trim()||e.name,description:i.trim()||void 0,branchingMode:f,terminalStatuses:[...u],commitBranchPatterns:c||void 0})},[e,s,i,f,u,c,t]);return o.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-700 bg-zinc-900/95 backdrop-blur",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ro,{className:"h-3.5 w-3.5 text-zinc-400"}),o.jsx("span",{className:"text-sm font-medium",children:"Config Settings"})]}),o.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:o.jsx(pe,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[o.jsx(We,{label:"Config Name",children:o.jsx("input",{value:s,onChange:b=>r(b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),o.jsx(We,{label:"Description",children:o.jsx("textarea",{value:i,onChange:b=>a(b.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",placeholder:"Optional config description..."})}),o.jsxs(We,{label:"Branching Mode",children:[o.jsx("div",{className:"flex gap-2",children:["trunk","worktree"].map(b=>o.jsxs("label",{className:"flex flex-1 cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[o.jsx("input",{type:"radio",name:"branchingMode",value:b,checked:f===b,onChange:()=>h(b),className:"h-3.5 w-3.5 border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),o.jsx("span",{className:"text-zinc-300 capitalize",children:b})]},b))}),o.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Trunk: all work on current branch. Worktree: git worktree per scope for isolation."})]}),o.jsx(We,{label:"Allowed Command Prefixes",children:o.jsx(bm,{prefixes:e.allowedCommandPrefixes??[],edges:e.edges,onChange:v})}),o.jsxs(We,{label:"Terminal Statuses",children:[o.jsx("div",{className:"space-y-1",children:d.map(b=>o.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[o.jsx("input",{type:"checkbox",checked:u.has(b),onChange:()=>y(b),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),o.jsx("span",{className:"text-zinc-300",children:b})]},b))}),o.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:'Terminal statuses mark a scope as "done" — no further progression expected.'})]}),o.jsxs(We,{label:"Commit Branch Patterns",children:[o.jsx("input",{value:c,onChange:b=>l(b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"^(dev|feat/|fix/|scope/)"}),x&&o.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[9px] text-amber-400",children:[o.jsx(be,{className:"h-3 w-3 shrink-0"}),x]}),o.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Regex pattern for branches that should trigger commit-session hooks."})]})]}),o.jsx("div",{className:"flex items-center justify-end border-t border-zinc-800 px-4 py-3",children:o.jsx("button",{onClick:w,className:"rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500",children:"Apply"})})]})}function We({label:e,children:t}){return o.jsxs("div",{children:[o.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const Br=260,wm=230,vm=160,Vr=140,Xt=16;function Nm(e,t,n,s){const r=[...t].sort((d,u)=>d.order-u.order),i=new Map(r.map((d,u)=>[d.id,u])),a=new Map;for(const d of r)a.set(d.id,[]);const c=[];for(const d of e)d.group&&a.has(d.group)?a.get(d.group).push(d):c.push(d);const l=new Map;let f=0;for(const d of r){l.set(d.id,f);const u=a.get(d.id).length;f+=u===1?vm:u*wm}const h=[];for(const d of r){const u=i.get(d.id),p=l.get(d.id),x=a.get(d.id);for(let y=0;y<x.length;y++){const v=x[y];h.push({id:v.id,type:"workflow",position:{x:Xt+p+y*Br,y:Xt+u*Vr},data:{list:v,scopeCount:n.get(v.id)??0}})}}if(c.length>0){const d=r.length;for(let u=0;u<c.length;u++){const p=c[u];h.push({id:p.id,type:"workflow",position:{x:Xt+u*Br,y:Xt+d*Vr},data:{list:p,scopeCount:n.get(p.id)??0}})}}return h}function jm(e,t,n,s){const r=new Map(n.map(c=>[c.id,c])),i=new Map(t.map(c=>[c.id,c])),a=["guard","gate","lifecycle","observer"];return e.map(c=>{const l=c.hooks??[],f=l.map(v=>r.get(v)).filter(v=>v!==void 0),h=a.find(v=>f.some(w=>w.category===v)),d=i.get(c.from),u=i.get(c.to),p=(d==null?void 0:d.group)!=null&&d.group===(u==null?void 0:u.group),{sourceHandle:x,targetHandle:y}=Ki(c.direction,p);return{id:`${c.from}:${c.to}`,source:c.from,target:c.to,sourceHandle:x,targetHandle:y,type:"workflow",data:{edge:c,hookCount:l.length,hasBlockingHook:f.some(v=>v.blocking===!0),highestCategory:h,showHookOverlay:s}}})}const Cm={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function zm(e,t){const n=new Map(t.map(r=>[r.id,r])),s=new Map;for(const r of e){const i=n.get(r.from),a=n.get(r.to),c=(i==null?void 0:i.group)!=null&&i.group===(a==null?void 0:a.group),{sourceHandle:l,targetHandle:f}=Ki(r.direction,c),h=Cm[r.direction]??"#22c55e";s.has(r.from)||s.set(r.from,new Map),s.has(r.to)||s.set(r.to,new Map),s.get(r.from).set(l,h),s.get(r.to).set(f,h)}return s}function Ki(e,t){return e==="backward"?{sourceHandle:"bottom",targetHandle:"bottom-in"}:e==="shortcut"?{sourceHandle:"top-out",targetHandle:"top"}:t?{sourceHandle:"right",targetHandle:"left"}:{sourceHandle:"bottom-fwd",targetHandle:"left"}}function Yr(e){return e.replace(/^"?\$CLAUDE_PROJECT_DIR"?\/?/,"").replace(/^\.\//,"")}function km(e){return e.replace(/\.[^.]+$/,"").split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Sm(e,t){const n=new Map;for(const s of e){const r=Yr(s.target);n.set(r,{id:s.id,label:s.label,scriptPath:r,source:"workflow",workflow:{timing:s.timing,type:s.type,category:s.category,blocking:s.blocking??!1,description:s.description}})}for(const s of t){const r=Yr(s.scriptPath),i={event:s.event,matcher:s.matcher,statusMessage:s.statusMessage},a=n.get(r);if(a)a.source="both",a.ccTriggers||(a.ccTriggers=[]),a.ccTriggers.push(i);else{const c=r,l=n.get(c);l?l.ccTriggers.push(i):n.set(c,{id:s.id,label:km(s.scriptName),scriptPath:r,source:"claude-code",ccTriggers:[i]})}}return Array.from(n.values())}const _m={workflow:B0},Em={workflow:W0};function Am(){const{engine:e}=Ac(),{scopes:t}=Pc(),{ccHooks:n}=H0(),s=e.getConfig(),r=Dc(s),i=r.editMode?r.editConfig:s,a=N.useMemo(()=>[...i.lists].sort((T,F)=>T.order-F.order),[i.lists]),c=i.edges,l=i.hooks??[],f=N.useMemo(()=>Sm(l,n),[l,n]),[h,d]=N.useState("graph"),[u,p]=N.useState(null),[x,y]=N.useState(null),v=N.useCallback(T=>{const F=f.find(V=>V.id===T.id);F&&p(F)},[f]),w=N.useCallback((T,F)=>{y(null),d("graph"),L({type:"edge",from:T,to:F})},[]),b=N.useMemo(()=>{const T=new Map;for(const F of t)T.set(F.status,(T.get(F.status)??0)+1);return T},[t]),g=N.useMemo(()=>zm(c,a),[c,a]),m=N.useMemo(()=>Nm(a,i.groups??[],b).map(T=>({...T,data:{...T.data,activeHandles:g.get(T.id)}})),[a,i.groups,b,c,g]),z=N.useMemo(()=>jm(c,a,l,!1),[c,a,l]),[C,S,P]=u0(m),[D,H,M]=f0(z);N.useEffect(()=>{S(m)},[m,S]),N.useEffect(()=>{H(z)},[z,H]);const[$,L]=N.useState({type:"none"}),j=N.useCallback((T,F)=>{L({type:"node",listId:F.id})},[]),A=N.useCallback((T,F)=>{const[V,W]=F.id.split(":");L({type:"edge",from:V,to:W})},[]),k=N.useCallback(()=>L({type:"none"}),[]),I=$.type==="node"?i.lists.find(T=>T.id===$.listId)??null:null,E=$.type==="edge"?c.find(T=>T.from===$.from&&T.to===$.to)??null:null,_=N.useMemo(()=>{if(!I)return[];const T=c.filter(V=>V.from===I.id||V.to===I.id),F=new Set(T.flatMap(V=>V.hooks??[]));return l.filter(V=>F.has(V.id))},[I,c,l]),R=N.useMemo(()=>I?c.filter(T=>T.from===I.id||T.to===I.id):[],[I,c]),O=N.useMemo(()=>E?(E.hooks??[]).map(T=>l.find(F=>F.id===T)).filter(T=>T!==void 0):[],[E,l]);return o.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[o.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Lc,{className:"h-4 w-4 text-primary"}),o.jsx("h1",{className:"text-xl font-light",children:"Workflow"}),r.editMode&&o.jsx("span",{className:"rounded bg-cyan-500/20 px-2 py-0.5 text-[10px] font-semibold text-cyan-400",children:"EDIT MODE"}),!r.editMode&&o.jsxs("div",{className:"ml-4 flex rounded-lg border border-zinc-800 bg-zinc-900/50 p-0.5",children:[o.jsx(Gr,{active:h==="graph",onClick:()=>d("graph"),icon:o.jsx(Kc,{className:"h-3 w-3"}),label:"Graph"}),o.jsx(Gr,{active:h==="hooks",onClick:()=>d("hooks"),icon:o.jsx(rt,{className:"h-3 w-3"}),label:"Hooks",count:f.length})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[!r.editMode&&o.jsxs("button",{onClick:r.enterEditMode,className:"flex items-center gap-1.5 rounded border border-zinc-800 px-3 py-1.5 text-xs text-zinc-400 transition-colors hover:border-cyan-500/40 hover:text-cyan-400",children:[o.jsx(Rc,{className:"h-3.5 w-3.5"}),"Edit"]}),!r.editMode&&o.jsx(lx,{activeConfigName:s.name})]})]}),r.editMode&&o.jsx("div",{className:"mb-3",children:o.jsx(dm,{canUndo:r.canUndo,canRedo:r.canRedo,changeCount:r.changeCount,validation:r.validation,saving:r.saving,onAddList:()=>r.setShowAddList(!0),onAddEdge:()=>r.setShowAddEdge(!0),onConfigSettings:()=>{r.setShowConfigSettings(!0),L({type:"none"})},onUndo:r.undo,onRedo:r.redo,onSave:r.save,onDiscard:r.discard,onPreview:r.preview})}),(h==="graph"||r.editMode)&&o.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[o.jsx("div",{className:"min-h-0 flex-1 rounded-lg border bg-transparent",style:{borderColor:r.editMode?"#3b82f640":"#27272a"},children:o.jsxs(c0,{nodes:C,edges:D,onNodesChange:P,onEdgesChange:M,nodeTypes:_m,edgeTypes:Em,onNodeClick:j,onEdgeClick:A,onPaneClick:k,fitView:!0,fitViewOptions:{padding:.08},minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},children:[o.jsx(g0,{variant:Ce.Dots,gap:20,size:1,color:"#27272a"}),o.jsx(C0,{className:"!border-zinc-800 !bg-zinc-900 [&>button]:!border-zinc-800 [&>button]:!bg-zinc-900 [&>button]:!fill-zinc-400 [&>button:hover]:!bg-zinc-800"})]})}),r.editMode&&$.type==="node"&&I&&o.jsx($x,{list:I,config:r.editConfig,onSave:T=>{r.updateList(I,T),L({type:"none"})},onDelete:()=>{r.deleteList(I.id),L({type:"none"})},onClose:()=>L({type:"none"})},I.id),r.editMode&&$.type==="edge"&&E&&o.jsx(cm,{edge:E,config:r.editConfig,onSave:T=>{r.updateEdge(E,T),L({type:"none"})},onDelete:()=>{r.deleteEdge(E.from,E.to),L({type:"none"})},onClose:()=>L({type:"none"})},`${E.from}:${E.to}`),r.editMode&&r.showConfigSettings&&$.type==="none"&&o.jsx(ym,{config:r.editConfig,onUpdate:r.updateConfig,onClose:()=>r.setShowConfigSettings(!1)}),!r.editMode&&$.type==="node"&&o.jsx(U0,{list:I,hooks:_,connectedEdges:R,onClose:()=>L({type:"none"}),onHookClick:v}),!r.editMode&&$.type==="edge"&&o.jsx(rx,{edge:E,hooks:O,onClose:()=>L({type:"none"}),onHookClick:v})]}),h==="hooks"&&!r.editMode&&o.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[o.jsx(bx,{hooks:f,edges:c,onHookClick:y}),x&&o.jsx(Ex,{hook:x,edges:c,onClose:()=>y(null),onViewSource:p,onNavigateToEdge:w})]}),o.jsx(fm,{open:r.showAddList,onOpenChange:r.setShowAddList,config:r.editConfig,onAdd:r.addList}),o.jsx(mm,{open:r.showAddEdge,onOpenChange:r.setShowAddEdge,config:r.editConfig,onAdd:r.addEdge}),o.jsx(gm,{open:r.showPreview,onOpenChange:r.setShowPreview,config:r.editConfig,plan:r.previewPlan,loading:r.previewLoading,error:r.previewError,onApply:r.applyMigration}),o.jsx(ux,{hook:u,open:u!==null,onClose:()=>p(null)})]})}function Gr({active:e,onClick:t,icon:n,label:s,count:r}){return o.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",style:{backgroundColor:e?"#27272a":"transparent",color:e?"#e4e4e7":"#71717a"},children:[n,s,r!==void 0&&r>0&&o.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-semibold leading-none",style:{backgroundColor:e?"#f9731630":"#27272a",color:e?"#f97316":"#71717a"},children:r})]})}export{Am as default};
|