toolroll 0.9.134 → 0.9.136
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/CHANGELOG.md +45 -0
- package/dist/acp-check-repo-schema.js +52 -0
- package/dist/acp-check.js +1 -1
- package/dist/acp-client.js +3 -3
- package/dist/acp-inspect.js +2 -1
- package/dist/agent-detect.js +1 -1
- package/dist/agent-fence.js +4 -4
- package/dist/agent-thread/chat-turn.js +2 -2
- package/dist/agent-thread/direct-host.js +2 -2
- package/dist/agent-thread/fence.js +2 -2
- package/dist/agent-thread/git-workspace.js +2 -2
- package/dist/agent-thread/guards.js +1 -1
- package/dist/agent-thread/providers.js +1 -1
- package/dist/agent-thread/ship.js +2 -2
- package/dist/approval-decision.js +1 -0
- package/dist/approval-password.js +1 -1
- package/dist/approval-summary.js +1 -1
- package/dist/attest.js +1 -1
- package/dist/batch-checks.js +2 -2
- package/dist/boot-identity.js +1 -1
- package/dist/bounded-spawn.js +2 -2
- package/dist/browser/{chunk-agents-live-view.e97fbf607cb8075aad7a48664556d11ea41469785f82384b5171b76c524f71e2.js → chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js} +4 -4
- package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.br +0 -0
- package/dist/browser/chunk-agents-live-view.9f4367c89c6366769a567e729ac9181ccaa898bf3a168d3dc618f3cface887c7.js.gz +0 -0
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js +2 -0
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.br +0 -0
- package/dist/browser/chunk-bundle.ac5952c82c76e2efcdcf5a097c4fa235d6f1045dcc36d02ee921ff4be976a46a.js.gz +0 -0
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js +4 -0
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.br +0 -0
- package/dist/browser/chunk-chat-parts.2a0b0b723508c5c48379f6a3d441f07a18c8b91ed64fd018962931c5ae43331e.js.gz +0 -0
- package/dist/browser/{chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js → chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js} +12 -12
- package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.br +0 -0
- package/dist/browser/chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js.gz +0 -0
- package/dist/browser/{chunk-flow-view.264e801af330461985aadcab42bc4ac4e036ba124394a7b5a100f2cd1edf89f0.js → chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js} +7 -7
- package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.br +0 -0
- package/dist/browser/chunk-flow-view.f5d74c7f072b739a7a0ed86ff35cafa7b8a041233372d1eeaab9eb941ddfc11e.js.gz +0 -0
- package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js +4 -0
- package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.br +0 -0
- package/dist/browser/chunk-flows-extra-view.01ebf93780b729363eda11ba21c764fe593bcd3e684aa833c9b86147f780fd41.js.gz +0 -0
- package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js +6 -0
- package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.br +0 -0
- package/dist/browser/chunk-pages-bundle.e18059f0cb4fbb63e3698971d4c1830ad0945c3645235babc93010cd0b725c1d.js.gz +0 -0
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js +2 -0
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.br +0 -0
- package/dist/browser/chunk-result-view.fc6a6494b316aa786807b7d17035c59defae1bfb0c03bf9c3795679b3a35dd77.js.gz +0 -0
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js +20 -0
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.br +0 -0
- package/dist/browser/chunk-settings-view.6dd3a64ded7bd8c047650270918dfb455c9a514a5a40b84c7eb5f443f76fe66f.js.gz +0 -0
- package/dist/browser/{chunk-shared.85e1b9e0838ccc819e7b8368f80dd5240dda90f53ea2974a256a8fa4122ba2fb.js → chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js} +2 -2
- package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.br +0 -0
- package/dist/browser/chunk-shared.02c0b692de21a9bb80d1761aa887d8532431171945c02e663884c9f45b796753.js.gz +0 -0
- package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js +2 -0
- package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.br +0 -0
- package/dist/browser/chunk-shared.0874336833f8101a63b169d8c2e55ca0f281e43e65d4bd6604555c791ea9dd87.js.gz +0 -0
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js +2 -0
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.br +0 -0
- package/dist/browser/chunk-shared.2413dd78f32995fbca67f51ac8c21baf4727cd64f185ea739aa2a058e569b0ed.js.gz +0 -0
- package/dist/browser/{chunk-shared.26f6cbfdeb9bcd63231f23dbf96cacb39b78324aeed2503e86109efa89fa27db.js → chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js} +3 -3
- package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.br +0 -0
- package/dist/browser/chunk-shared.26bb0114998968cccb7bae5f6ffa8979ddecfafd8bc18bb6985760f6bcc030e6.js.gz +0 -0
- package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js +2 -0
- package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.br +0 -0
- package/dist/browser/chunk-shared.6d0b8728b3e309886cfb6eaf596d3f20592939e521bb60bb090824f34da6b086.js.gz +0 -0
- package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js +2 -0
- package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.br +0 -0
- package/dist/browser/chunk-shared.c3e5be1c5f441e94905a4bc2005d816d2a0b0e4108bae43e37ec274a911c6847.js.gz +0 -0
- package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js +2 -0
- package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.br +0 -0
- package/dist/browser/chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js.gz +0 -0
- package/dist/browser/{chunk-shared.5b47ca221b8b77b26ce8006f0569c981df2b905005cebe9fc54444d4906d436e.js → chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js} +3 -3
- package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.br +0 -0
- package/dist/browser/chunk-shared.fd5f2699d3b0017797e5b5e1e1d92eb98818740ebf20a95364bbb7deea0c8242.js.gz +0 -0
- package/dist/browser/{chunk-sonner.160372eb4f9455847ca83e8ff5d983c6b3010ef0dc2eaf541e2eaceaac3b994c.js → chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js} +1 -1
- package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.br +0 -0
- package/dist/browser/chunk-sonner.2472e1da55de10b11dc002c80a840966061e817c47793f5e216f1af6c6dbedff.js.gz +0 -0
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js +2 -0
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.br +0 -0
- package/dist/browser/chunk-task-view.bbeddc793a5e8a6d1f66b6cc5f0ce1da18414137e85c49ccd07be0e20f61ac12.js.gz +0 -0
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js +2 -0
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.br +0 -0
- package/dist/browser/chunk-team-chat.c3255a5a1d94e39d559c07438c4690543602b1552b2c2bf57b8791d7f989141d.js.gz +0 -0
- package/dist/browser/manifest.json +194 -194
- package/dist/browser/workspace.3043c4a6df23ed1c0c8be3fb816fa9410a2ab99053eb54476f22a1735c03ca97.css +4 -0
- package/dist/browser/workspace.3043c4a6df23ed1c0c8be3fb816fa9410a2ab99053eb54476f22a1735c03ca97.css.br +0 -0
- package/dist/browser/workspace.3043c4a6df23ed1c0c8be3fb816fa9410a2ab99053eb54476f22a1735c03ca97.css.gz +0 -0
- package/dist/browser/{workspace.efd01c3aaf8e07c4a64194e2bfbd7aee4f7fa515f2acebdfdd90af1badba8ce7.js → workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js} +4 -4
- package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.br +0 -0
- package/dist/browser/workspace.aebb60d4e5ef4509a80cfaccf0af5f7246867ec7531a1734dd8e28c59594950e.js.gz +0 -0
- package/dist/browser-open.js +1 -1
- package/dist/build-review.js +2 -2
- package/dist/builder.js +21 -14
- package/dist/canvas-capture.js +2 -2
- package/dist/canvas-freshness.js +1 -1
- package/dist/central-recovery-stage.js +1 -1
- package/dist/chat-actions.js +3 -3
- package/dist/chat-decide.js +8 -4
- package/dist/cli-help.js +8 -7
- package/dist/cli.js +2 -2
- package/dist/companion/bonjour.js +1 -1
- package/dist/companion/daemon.js +1 -1
- package/dist/companion/passkey-gate.js +1 -1
- package/dist/companion/reads.js +1 -1
- package/dist/companion/store.js +1 -1
- package/dist/companion/webauthn.js +1 -1
- package/dist/companion/work.js +1 -1
- package/dist/container-state.js +2 -2
- package/dist/containment.js +2 -2
- package/dist/contracts/chat-actions.js +1 -1
- package/dist/contracts/console-api.js +1 -1
- package/dist/contracts/engine-api.js +1 -1
- package/dist/controller-supervisor.js +2 -2
- package/dist/credential-broker.js +1 -1
- package/dist/demo.js +2 -2
- package/dist/easy-start.js +1 -1
- package/dist/egress.js +1 -1
- package/dist/engine-handoff.js +1 -1
- package/dist/engine-reads.js +1 -1
- package/dist/evals.js +2 -2
- package/dist/exec.js +4 -4
- package/dist/fast-owner-schema.js +33 -0
- package/dist/fast-start.js +1 -1
- package/dist/flow-unattended.js +2 -2
- package/dist/github-import.js +1 -1
- package/dist/github-read.js +1 -1
- package/dist/install-mode.js +2 -3
- package/dist/invoke.js +9 -7
- package/dist/laptop-background.js +1 -1
- package/dist/lead-capabilities.js +1 -1
- package/dist/live-backup-change.js +2 -2
- package/dist/live-backup.js +2 -2
- package/dist/live-terminal.js +3 -3
- package/dist/local-checks.js +1 -1
- package/dist/local-landing.js +22 -3
- package/dist/local-owner.js +1 -1
- package/dist/machine-identity.js +1 -1
- package/dist/model-catalog.js +8 -5
- package/dist/model-choices.js +3 -3
- package/dist/model-routing.js +1 -1
- package/dist/models-cli.js +2 -2
- package/dist/names.js +1 -1
- package/dist/onboard.js +1 -1
- package/dist/operate-remote-arguments.js +1 -1
- package/dist/operate.js +33 -16
- package/dist/orphan-sweep.js +1 -1
- package/dist/owner-mode.js +4 -0
- package/dist/peek-cli.js +2 -2
- package/dist/phase-routing.js +1 -1
- package/dist/pi-build.js +1 -1
- package/dist/plane-review.js +1 -1
- package/dist/planner-source.js +2 -2
- package/dist/planner.js +1 -1
- package/dist/pre-run-phase.js +1 -1
- package/dist/presence-hold.js +1 -1
- package/dist/process-liveness.js +1 -1
- package/dist/process-tree.js +1 -1
- package/dist/project-tools.js +2 -2
- package/dist/prompt.js +1 -1
- package/dist/proposal.js +1 -1
- package/dist/protected-storage.js +2 -2
- package/dist/provider-home.js +1 -1
- package/dist/provider-limits.js +1 -1
- package/dist/provider.js +2 -2
- package/dist/public-access.js +1 -1
- package/dist/pull-request-flow.js +2 -2
- package/dist/read-executor.js +1 -1
- package/dist/release-adapters.js +2 -2
- package/dist/release-carry.js +3 -3
- package/dist/release-resume.js +2 -2
- package/dist/release-start.js +1 -0
- package/dist/result-follow-ups.js +2 -2
- package/dist/review-switch.js +1 -1
- package/dist/route-change.js +25 -3
- package/dist/run-closeout.js +2 -2
- package/dist/runner.js +1 -1
- package/dist/sandbox-launch.js +2 -2
- package/dist/sandbox-runtime.js +1 -1
- package/dist/scope.js +1 -1
- package/dist/scout-browser.js +1 -1
- package/dist/serve.js +3 -3
- package/dist/server/chat.js +1 -1
- package/dist/server/direct-chat.js +1 -1
- package/dist/server/engine-api.js +1 -1
- package/dist/server/http.js +1 -1
- package/dist/server/one-time-secret.js +1 -1
- package/dist/server/route-table.js +1 -1
- package/dist/server/runtime.js +1 -1
- package/dist/server/settings-phone.js +1 -1
- package/dist/server/settings-section-table.js +1 -1
- package/dist/server/settings-sections.js +1 -1
- package/dist/server/settings.js +2 -1
- package/dist/server/task-view-data.js +3 -3
- package/dist/server/task-views.js +1 -1
- package/dist/server/tasks.js +5 -5
- package/dist/server/terminals.js +1 -1
- package/dist/settings-data.js +1 -1
- package/dist/settings-proofs.js +1 -1
- package/dist/shared-deps.js +4 -4
- package/dist/sign-in-page.js +2 -2
- package/dist/ssr-workspace.js +88 -88
- package/dist/staged-runtimes.js +1 -1
- package/dist/status-probe.js +2 -2
- package/dist/stop-proof.js +2 -2
- package/dist/storage-sweep-child.js +2 -2
- package/dist/storage-sweep-process.js +1 -1
- package/dist/storage.js +2 -2
- package/dist/store-baseline.js +5 -33
- package/dist/store.js +19 -14
- package/dist/subscription-usage.js +3 -3
- package/dist/surface.js +1 -1
- package/dist/test-temp.js +1 -1
- package/dist/tool-broker.js +1 -1
- package/dist/toolroll-update.js +3 -3
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/tui-launch.js +1 -1
- package/dist/welcome-facts.js +1 -1
- package/package.json +1 -1
- package/dist/browser/chunk-agents-live-view.e97fbf607cb8075aad7a48664556d11ea41469785f82384b5171b76c524f71e2.js.br +0 -0
- package/dist/browser/chunk-agents-live-view.e97fbf607cb8075aad7a48664556d11ea41469785f82384b5171b76c524f71e2.js.gz +0 -0
- package/dist/browser/chunk-bundle.48f442a2868e9b77e9f54c5b77f1bba629ccd1615de8a2f62619b811783314f6.js +0 -2
- package/dist/browser/chunk-bundle.48f442a2868e9b77e9f54c5b77f1bba629ccd1615de8a2f62619b811783314f6.js.br +0 -0
- package/dist/browser/chunk-bundle.48f442a2868e9b77e9f54c5b77f1bba629ccd1615de8a2f62619b811783314f6.js.gz +0 -0
- package/dist/browser/chunk-chat-parts.1669e6985c5c0c11eea6792ea177ea4c9f7e7ebf27bd3b31742feb6a26d5b2a5.js +0 -4
- package/dist/browser/chunk-chat-parts.1669e6985c5c0c11eea6792ea177ea4c9f7e7ebf27bd3b31742feb6a26d5b2a5.js.br +0 -0
- package/dist/browser/chunk-chat-parts.1669e6985c5c0c11eea6792ea177ea4c9f7e7ebf27bd3b31742feb6a26d5b2a5.js.gz +0 -0
- package/dist/browser/chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js.br +0 -0
- package/dist/browser/chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js.gz +0 -0
- package/dist/browser/chunk-flow-view.264e801af330461985aadcab42bc4ac4e036ba124394a7b5a100f2cd1edf89f0.js.br +0 -0
- package/dist/browser/chunk-flow-view.264e801af330461985aadcab42bc4ac4e036ba124394a7b5a100f2cd1edf89f0.js.gz +0 -0
- package/dist/browser/chunk-flows-extra-view.6761503a97e1f17b474703ff5687a8682c54f9db1715e0a9762a979030a1b036.js +0 -4
- package/dist/browser/chunk-flows-extra-view.6761503a97e1f17b474703ff5687a8682c54f9db1715e0a9762a979030a1b036.js.br +0 -0
- package/dist/browser/chunk-flows-extra-view.6761503a97e1f17b474703ff5687a8682c54f9db1715e0a9762a979030a1b036.js.gz +0 -0
- package/dist/browser/chunk-pages-bundle.365da73d009e3ced30b55bca7107f548dc832f7a9f52926d3dcd68aa5596da11.js +0 -6
- package/dist/browser/chunk-pages-bundle.365da73d009e3ced30b55bca7107f548dc832f7a9f52926d3dcd68aa5596da11.js.br +0 -0
- package/dist/browser/chunk-pages-bundle.365da73d009e3ced30b55bca7107f548dc832f7a9f52926d3dcd68aa5596da11.js.gz +0 -0
- package/dist/browser/chunk-result-view.d4dc562a1a6a52a1497e25300d5f80c220952ceb5bb719ca32ef8dc1e74a4124.js +0 -2
- package/dist/browser/chunk-result-view.d4dc562a1a6a52a1497e25300d5f80c220952ceb5bb719ca32ef8dc1e74a4124.js.br +0 -0
- package/dist/browser/chunk-result-view.d4dc562a1a6a52a1497e25300d5f80c220952ceb5bb719ca32ef8dc1e74a4124.js.gz +0 -0
- package/dist/browser/chunk-settings-view.ff302e1c5faf5486c96e5fc96fa32492da4153e6e19997ce7b718adab21bf3b7.js +0 -20
- package/dist/browser/chunk-settings-view.ff302e1c5faf5486c96e5fc96fa32492da4153e6e19997ce7b718adab21bf3b7.js.br +0 -0
- package/dist/browser/chunk-settings-view.ff302e1c5faf5486c96e5fc96fa32492da4153e6e19997ce7b718adab21bf3b7.js.gz +0 -0
- package/dist/browser/chunk-shared.152678a803cfb6dee935162fbbbdb38d031d80f1d32ce48610f37bc1c8621e49.js +0 -2
- package/dist/browser/chunk-shared.152678a803cfb6dee935162fbbbdb38d031d80f1d32ce48610f37bc1c8621e49.js.br +0 -0
- package/dist/browser/chunk-shared.152678a803cfb6dee935162fbbbdb38d031d80f1d32ce48610f37bc1c8621e49.js.gz +0 -0
- package/dist/browser/chunk-shared.26f6cbfdeb9bcd63231f23dbf96cacb39b78324aeed2503e86109efa89fa27db.js.br +0 -0
- package/dist/browser/chunk-shared.26f6cbfdeb9bcd63231f23dbf96cacb39b78324aeed2503e86109efa89fa27db.js.gz +0 -0
- package/dist/browser/chunk-shared.4e21c6b33b9a525e63c360d20a1830f1a26c5021f5d218f2300f21ff840af27e.js +0 -2
- package/dist/browser/chunk-shared.4e21c6b33b9a525e63c360d20a1830f1a26c5021f5d218f2300f21ff840af27e.js.br +0 -0
- package/dist/browser/chunk-shared.4e21c6b33b9a525e63c360d20a1830f1a26c5021f5d218f2300f21ff840af27e.js.gz +0 -0
- package/dist/browser/chunk-shared.5b47ca221b8b77b26ce8006f0569c981df2b905005cebe9fc54444d4906d436e.js.br +0 -0
- package/dist/browser/chunk-shared.5b47ca221b8b77b26ce8006f0569c981df2b905005cebe9fc54444d4906d436e.js.gz +0 -0
- package/dist/browser/chunk-shared.85e1b9e0838ccc819e7b8368f80dd5240dda90f53ea2974a256a8fa4122ba2fb.js.br +0 -0
- package/dist/browser/chunk-shared.85e1b9e0838ccc819e7b8368f80dd5240dda90f53ea2974a256a8fa4122ba2fb.js.gz +0 -0
- package/dist/browser/chunk-shared.a326d625dea5cda744678a73b38c0cb2688721c9228e26d262279ecd5c2d7d11.js +0 -2
- package/dist/browser/chunk-shared.a326d625dea5cda744678a73b38c0cb2688721c9228e26d262279ecd5c2d7d11.js.br +0 -0
- package/dist/browser/chunk-shared.a326d625dea5cda744678a73b38c0cb2688721c9228e26d262279ecd5c2d7d11.js.gz +0 -0
- package/dist/browser/chunk-shared.e906e9c8c0859e000616dbc382f88597447f30205c92b7cb9a8e2351f3ef2722.js +0 -2
- package/dist/browser/chunk-shared.e906e9c8c0859e000616dbc382f88597447f30205c92b7cb9a8e2351f3ef2722.js.br +0 -0
- package/dist/browser/chunk-shared.e906e9c8c0859e000616dbc382f88597447f30205c92b7cb9a8e2351f3ef2722.js.gz +0 -0
- package/dist/browser/chunk-shared.f6354151d62439f2d78f5d17cf9bc44f35b4da37685beb77467d98dd9cc6f1e4.js +0 -2
- package/dist/browser/chunk-shared.f6354151d62439f2d78f5d17cf9bc44f35b4da37685beb77467d98dd9cc6f1e4.js.br +0 -0
- package/dist/browser/chunk-shared.f6354151d62439f2d78f5d17cf9bc44f35b4da37685beb77467d98dd9cc6f1e4.js.gz +0 -0
- package/dist/browser/chunk-sonner.160372eb4f9455847ca83e8ff5d983c6b3010ef0dc2eaf541e2eaceaac3b994c.js.br +0 -0
- package/dist/browser/chunk-sonner.160372eb4f9455847ca83e8ff5d983c6b3010ef0dc2eaf541e2eaceaac3b994c.js.gz +0 -0
- package/dist/browser/chunk-task-view.325b506afc26b25147b2e90cec5ad1392d50e6150a7fb33c81a996daa99bb05a.js +0 -2
- package/dist/browser/chunk-task-view.325b506afc26b25147b2e90cec5ad1392d50e6150a7fb33c81a996daa99bb05a.js.br +0 -0
- package/dist/browser/chunk-task-view.325b506afc26b25147b2e90cec5ad1392d50e6150a7fb33c81a996daa99bb05a.js.gz +0 -0
- package/dist/browser/chunk-team-chat.d560bcc5d819e63133d377b8a6f10f901356e680771f19d4fe1af044adfffb22.js +0 -2
- package/dist/browser/chunk-team-chat.d560bcc5d819e63133d377b8a6f10f901356e680771f19d4fe1af044adfffb22.js.br +0 -0
- package/dist/browser/chunk-team-chat.d560bcc5d819e63133d377b8a6f10f901356e680771f19d4fe1af044adfffb22.js.gz +0 -0
- package/dist/browser/workspace.ac1270b58f672fa920535348cc582f5fc68247b341d6fc8ec733b25336f2b9cc.css +0 -4
- package/dist/browser/workspace.ac1270b58f672fa920535348cc582f5fc68247b341d6fc8ec733b25336f2b9cc.css.br +0 -0
- package/dist/browser/workspace.ac1270b58f672fa920535348cc582f5fc68247b341d6fc8ec733b25336f2b9cc.css.gz +0 -0
- package/dist/browser/workspace.efd01c3aaf8e07c4a64194e2bfbd7aee4f7fa515f2acebdfdd90af1badba8ce7.js.br +0 -0
- package/dist/browser/workspace.efd01c3aaf8e07c4a64194e2bfbd7aee4f7fa515f2acebdfdd90af1badba8ce7.js.gz +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/*! Third-party notices: /assets/THIRD_PARTY_NOTICES.txt */
|
|
2
|
-
import{d as jd,e as Nd}from"./chunk-shared.f6354151d62439f2d78f5d17cf9bc44f35b4da37685beb77467d98dd9cc6f1e4.js";import{p10$A as Pa,p10$B as yo,p10$C as Aa,p10$D as Q0,p10$E as Ia,p10$F as Da,p10$G as Ra,p10$H as Oa,p10$I as rt,p10$J as bo,p10$a as La,p10$b as Ta,p10$c as Ba,p10$d as Va,p10$e as ex,p10$f as tx,p10$g as nx,p10$h as ox,p10$i as ax,p10$j as Ha,p10$k as Fa,p10$l as wo,p10$m as Wa,p10$n as Za,p10$o as Ya,p10$p as Xa,p10$q as jo,p10$r as No,p10$s as qa,p10$t as Ka,p10$u as ko,p10$v as Ua,p10$w as Ga,p10$x as Qe,p10$y as Ja,p10$z as Qa}from"./chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js";import{p11$a as So,p11$b as ix}from"./chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js";import{p1$$ as er,p1$$a as tr,p1$$b as cx,p1$A as ux,p1$Aa as hx,p1$Ab as px,p1$B as mx,p1$Ba as fx,p1$Bb as nr,p1$C as gx,p1$Ca as xx,p1$Cb as vx,p1$D as yx,p1$Da as bx,p1$Db as wx,p1$E as jx,p1$Ea as Nx,p1$Eb as kx,p1$F as Sx,p1$Fa as Cx,p1$Fb as or,p1$G as $x,p1$Ga as Ex,p1$Gb as ar,p1$H as Co,p1$Ha as Mx,p1$Hb as rr,p1$I as zx,p1$Ia as _x,p1$Ib as sr,p1$J as Px,p1$Ja as Ax,p1$Jb as Ix,p1$K as Dx,p1$Ka as Rx,p1$Kb as Ox,p1$L as Lx,p1$La as ir,p1$Lb as Tx,p1$M as Bx,p1$Ma as Vx,p1$Mb as Hx,p1$N as Fx,p1$Na as lr,p1$Nb as Wx,p1$O as Zx,p1$Oa as Yx,p1$Ob as Xx,p1$P as qx,p1$Pa as Kx,p1$Pb as Ux,p1$Q as Gx,p1$Qa as Jx,p1$Qb as Qx,p1$R as ev,p1$Ra as tv,p1$Rb as nv,p1$S as ov,p1$Sa as av,p1$Sb as rv,p1$T as sv,p1$Ta as iv,p1$Tb as $o,p1$U as lv,p1$Ua as dv,p1$Ub as cv,p1$V as xn,p1$Va as uv,p1$Vb as dr,p1$W as hv,p1$Wa as pv,p1$Wb as mv,p1$X as fv,p1$Xa as gv,p1$Xb as xv,p1$Y as vv,p1$Ya as yv,p1$Yb as bv,p1$Z as wv,p1$Za as jv,p1$Zb as Nv,p1$_ as kv,p1$_a as Sv,p1$_b as Cv,p1$a as xe,p1$aa as vn,p1$ab as he,p1$ac as $v,p1$b as Ev,p1$ba as Mv,p1$bb as cr,p1$bc as zv,p1$c as _v,p1$ca as Pv,p1$cb as Tt,p1$cc as Av,p1$d as Iv,p1$da as Dv,p1$db as Eo,p1$dc as Rv,p1$e as te,p1$ea as Ov,p1$eb as Lv,p1$ec as Tv,p1$f as Mo,p1$fa as Bv,p1$fb as bt,p1$fc as Vv,p1$g as Hv,p1$ga as Fv,p1$gb as Wv,p1$gc as Zv,p1$h as Yv,p1$ha as Xv,p1$hb as yn,p1$hc as qv,p1$i as Kv,p1$ia as Uv,p1$ib as Gv,p1$ic as Jv,p1$j as bn,p1$ja as Qv,p1$jb as wn,p1$jc as ey,p1$k as jn,p1$ka as Bt,p1$kb as ty,p1$kc as ny,p1$l as oy,p1$la as ur,p1$lb as ay,p1$lc as ry,p1$m as Nn,p1$ma as wt,p1$mb as sy,p1$n as ne,p1$na as iy,p1$nb as kn,p1$o as ye,p1$oa as ly,p1$ob as dy,p1$p as cy,p1$pa as uy,p1$pb as Sn,p1$q as hy,p1$qa as hr,p1$qb as py,p1$r as my,p1$ra as fy,p1$rb as gy,p1$s as xy,p1$sa as vy,p1$sb as pr,p1$t as yy,p1$ta as by,p1$tb as mr,p1$u as wy,p1$ua as jy,p1$ub as zo,p1$v as Ny,p1$va as ky,p1$vb as fr,p1$w as Sy,p1$wa as Cy,p1$wb as $y,p1$x as Ey,p1$xa as My,p1$xb as gr,p1$y as zy,p1$ya as xr,p1$yb as _y,p1$z as jt,p1$za as Py,p1$zb as Ay}from"./chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js";import{p2$a as Vt,p2$b as et,p2$c as Nt,p2$d as vr,p2$e as _o}from"./chunk-core.64343d638685133eb96578bfb35bf560f329d0743ac5deda720ae27f5699c9d9.js";var kd=Vt(e=>{"use strict";var t=Nt();function n(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var o=typeof Object.is=="function"?Object.is:n,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,l=t.useDebugValue;function h(d,m){var f=m(),w=r({inst:{value:f,getSnapshot:m}}),y=w[0].inst,x=w[1];return i(function(){y.value=f,y.getSnapshot=m,u(y)&&x({inst:y})},[d,f,m]),s(function(){return u(y)&&x({inst:y}),d(function(){u(y)&&x({inst:y})})},[d]),l(f),f}function u(d){var m=d.getSnapshot;d=d.value;try{var f=m();return!o(d,f)}catch{return!0}}function c(d,m){return m()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:h;e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p}),Sd=Vt((e,t)=>{"use strict";t.exports=kd()}),Cd=Vt(e=>{"use strict";var t=Nt(),n=Sd();function o(c,p){return c===p&&(c!==0||1/c===1/p)||c!==c&&p!==p}var r=typeof Object.is=="function"?Object.is:o,s=n.useSyncExternalStore,i=t.useRef,l=t.useEffect,h=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(c,p,d,m,f){var w=i(null);if(w.current===null){var y={hasValue:!1,value:null};w.current=y}else y=w.current;w=h(function(){function E(M){if(!v){if(v=!0,b=M,M=m(M),f!==void 0&&y.hasValue){var C=y.value;if(f(C,M))return j=C}return j=M}if(C=j,r(b,M))return C;var _=m(M);return f!==void 0&&f(C,_)?(b=M,C):(b=M,j=_)}var v=!1,b,j,S=d===void 0?null:d;return[function(){return E(p())},S===null?void 0:function(){return E(S())}]},[p,d,m,f]);var x=s(c,w[0],w[1]);return l(function(){y.hasValue=!0,y.value=x},[x]),u(x),x}}),$d=Vt((e,t)=>{"use strict";t.exports=Cd()}),I=et(_o()),L=et(Nt());function ve(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ve(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Ed={value:()=>{}};function As(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Dn(n)}function Dn(e){this._=e}function Md(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Dn.prototype=As.prototype={constructor:Dn,on:function(e,t){var n=this._,o=Md(e+"",n),r,s=-1,i=o.length;if(arguments.length<2){for(;++s<i;)if((r=(e=o[s]).type)&&(r=zd(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(r=(e=o[s]).type)n[r]=yr(n[r],e.name,t);else if(t==null)for(r in n)n[r]=yr(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 Dn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,s;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,r=s.length;o<r;++o)s[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)}};function zd(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function yr(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Ed,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var na=As,Ho="http://www.w3.org/1999/xhtml",br={svg:"http://www.w3.org/2000/svg",xhtml:Ho,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),br.hasOwnProperty(t)?{space:br[t],local:e}:e}function _d(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ho&&t.documentElement.namespaceURI===Ho?t.createElement(e):t.createElementNS(n,e)}}function Pd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Is(e){var t=Jn(e);return(t.local?Pd:_d)(t)}function Ad(){}function oa(e){return e==null?Ad:function(){return this.querySelector(e)}}function Id(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=new Array(i),h,u,c=0;c<i;++c)(h=s[c])&&(u=e.call(h,h.__data__,c,s))&&("__data__"in h&&(u.__data__=h.__data__),l[c]=u);return new $e(o,this._parents)}function Dd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Rd(){return[]}function Ds(e){return e==null?Rd:function(){return this.querySelectorAll(e)}}function Od(e){return function(){return Dd(e.apply(this,arguments))}}function Ld(e){typeof e=="function"?e=Od(e):e=Ds(e);for(var t=this._groups,n=t.length,o=[],r=[],s=0;s<n;++s)for(var i=t[s],l=i.length,h,u=0;u<l;++u)(h=i[u])&&(o.push(e.call(h,h.__data__,u,i)),r.push(h));return new $e(o,r)}function Rs(e){return function(){return this.matches(e)}}function Os(e){return function(t){return t.matches(e)}}var Td=Array.prototype.find;function Bd(e){return function(){return Td.call(this.children,e)}}function Vd(){return this.firstElementChild}function Hd(e){return this.select(e==null?Vd:Bd(typeof e=="function"?e:Os(e)))}var Fd=Array.prototype.filter;function Wd(){return Array.from(this.children)}function Zd(e){return function(){return Fd.call(this.children,e)}}function Yd(e){return this.selectAll(e==null?Wd:Zd(typeof e=="function"?e:Os(e)))}function Xd(e){typeof e!="function"&&(e=Rs(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=[],h,u=0;u<i;++u)(h=s[u])&&e.call(h,h.__data__,u,s)&&l.push(h);return new $e(o,this._parents)}function Ls(e){return new Array(e.length)}function qd(){return new $e(this._enter||this._groups.map(Ls),this._parents)}function Bn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bn.prototype={constructor:Bn,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 Kd(e){return function(){return e}}function Ud(e,t,n,o,r,s){for(var i=0,l,h=t.length,u=s.length;i<u;++i)(l=t[i])?(l.__data__=s[i],o[i]=l):n[i]=new Bn(e,s[i]);for(;i<h;++i)(l=t[i])&&(r[i]=l)}function Gd(e,t,n,o,r,s,i){var l,h,u=new Map,c=t.length,p=s.length,d=new Array(c),m;for(l=0;l<c;++l)(h=t[l])&&(d[l]=m=i.call(h,h.__data__,l,t)+"",u.has(m)?r[l]=h:u.set(m,h));for(l=0;l<p;++l)m=i.call(e,s[l],l,s)+"",(h=u.get(m))?(o[l]=h,h.__data__=s[l],u.delete(m)):n[l]=new Bn(e,s[l]);for(l=0;l<c;++l)(h=t[l])&&u.get(d[l])===h&&(r[l]=h)}function Jd(e){return e.__data__}function Qd(e,t){if(!arguments.length)return Array.from(this,Jd);var n=t?Gd:Ud,o=this._parents,r=this._groups;typeof e!="function"&&(e=Kd(e));for(var s=r.length,i=new Array(s),l=new Array(s),h=new Array(s),u=0;u<s;++u){var c=o[u],p=r[u],d=p.length,m=ec(e.call(c,c&&c.__data__,u,o)),f=m.length,w=l[u]=new Array(f),y=i[u]=new Array(f),x=h[u]=new Array(d);n(c,p,w,y,x,m,t);for(var E=0,v=0,b,j;E<f;++E)if(b=w[E]){for(E>=v&&(v=E+1);!(j=y[v])&&++v<f;);b._next=j||null}}return i=new $e(i,o),i._enter=l,i._exit=h,i}function ec(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function tc(){return new $e(this._exit||this._groups.map(Ls),this._parents)}function nc(e,t,n){var o=this.enter(),r=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),o&&r?o.merge(r).order():r}function oc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,s=o.length,i=Math.min(r,s),l=new Array(r),h=0;h<i;++h)for(var u=n[h],c=o[h],p=u.length,d=l[h]=new Array(p),m,f=0;f<p;++f)(m=u[f]||c[f])&&(d[f]=m);for(;h<r;++h)l[h]=n[h];return new $e(l,this._parents)}function ac(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,s=o[r],i;--r>=0;)(i=o[r])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function rc(e){e||(e=sc);function t(p,d){return p&&d?e(p.__data__,d.__data__):!p-!d}for(var n=this._groups,o=n.length,r=new Array(o),s=0;s<o;++s){for(var i=n[s],l=i.length,h=r[s]=new Array(l),u,c=0;c<l;++c)(u=i[c])&&(h[c]=u);h.sort(t)}return new $e(r,this._parents).order()}function sc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ic(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function lc(){return Array.from(this)}function dc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length;r<s;++r){var i=o[r];if(i)return i}return null}function cc(){let e=0;for(let t of this)++e;return e}function uc(){return!this.node()}function hc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],s=0,i=r.length,l;s<i;++s)(l=r[s])&&e.call(l,l.__data__,s,r);return this}function pc(e){return function(){this.removeAttribute(e)}}function mc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fc(e,t){return function(){this.setAttribute(e,t)}}function gc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function xc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function vc(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 yc(e,t){var n=Jn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?mc:pc:typeof t=="function"?n.local?vc:xc:n.local?gc:fc)(n,t))}function Ts(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function bc(e){return function(){this.style.removeProperty(e)}}function wc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function jc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Nc(e,t,n){return arguments.length>1?this.each((t==null?bc:typeof t=="function"?jc:wc)(e,t,n??"")):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||Ts(e).getComputedStyle(e,null).getPropertyValue(t)}function kc(e){return function(){delete this[e]}}function Sc(e,t){return function(){this[e]=t}}function Cc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function $c(e,t){return arguments.length>1?this.each((t==null?kc:typeof t=="function"?Cc:Sc)(e,t)):this.node()[e]}function Bs(e){return e.trim().split(/^|\s+/)}function aa(e){return e.classList||new Vs(e)}function Vs(e){this._node=e,this._names=Bs(e.getAttribute("class")||"")}Vs.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 Hs(e,t){for(var n=aa(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Fs(e,t){for(var n=aa(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Ec(e){return function(){Hs(this,e)}}function Mc(e){return function(){Fs(this,e)}}function zc(e,t){return function(){(t.apply(this,arguments)?Hs:Fs)(this,e)}}function _c(e,t){var n=Bs(e+"");if(arguments.length<2){for(var o=aa(this.node()),r=-1,s=n.length;++r<s;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?zc:t?Ec:Mc)(n,t))}function Pc(){this.textContent=""}function Ac(e){return function(){this.textContent=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Dc(e){return arguments.length?this.each(e==null?Pc:(typeof e=="function"?Ic:Ac)(e)):this.node().textContent}function Rc(){this.innerHTML=""}function Oc(e){return function(){this.innerHTML=e}}function Lc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tc(e){return arguments.length?this.each(e==null?Rc:(typeof e=="function"?Lc:Oc)(e)):this.node().innerHTML}function Bc(){this.nextSibling&&this.parentNode.appendChild(this)}function Vc(){return this.each(Bc)}function Hc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Fc(){return this.each(Hc)}function Wc(e){var t=typeof e=="function"?e:Is(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Zc(){return null}function Yc(e,t){var n=typeof e=="function"?e:Is(e),o=t==null?Zc:typeof t=="function"?t:oa(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Xc(){var e=this.parentNode;e&&e.removeChild(this)}function qc(){return this.each(Xc)}function Kc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Uc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gc(e){return this.select(e?Uc:Kc)}function Jc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Qc(e){return function(t){e.call(this,t,this.__data__)}}function eu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function tu(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++o]=s;++o?t.length=o:delete this.__on}}}function nu(e,t,n){return function(){var o=this.__on,r,s=Qc(t);if(o){for(var i=0,l=o.length;i<l;++i)if((r=o[i]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},o?o.push(r):this.__on=[r]}}function ou(e,t,n){var o=eu(e+""),r,s=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var h=0,u=l.length,c;h<u;++h)for(r=0,c=l[h];r<s;++r)if((i=o[r]).type===c.type&&i.name===c.name)return c.value}return}for(l=t?nu:tu,r=0;r<s;++r)this.each(l(o[r],t,n));return this}function Ws(e,t,n){var o=Ts(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function au(e,t){return function(){return Ws(this,e,t)}}function ru(e,t){return function(){return Ws(this,e,t.apply(this,arguments))}}function su(e,t){return this.each((typeof t=="function"?ru:au)(e,t))}function*iu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length,i;r<s;++r)(i=o[r])&&(yield i)}var Zs=[null];function $e(e,t){this._groups=e,this._parents=t}function Ys(){return new $e([[document.documentElement]],Zs)}function lu(){return this}$e.prototype=Ys.prototype={constructor:$e,select:Id,selectAll:Ld,selectChild:Hd,selectChildren:Yd,filter:Xd,data:Qd,enter:qd,exit:tc,join:nc,merge:oc,selection:lu,order:ac,sort:rc,call:ic,nodes:lc,node:dc,size:cc,empty:uc,each:hc,attr:yc,style:Nc,property:$c,classed:_c,text:Dc,html:Tc,raise:Vc,lower:Fc,append:Wc,insert:Yc,remove:qc,clone:Gc,datum:Jc,on:ou,dispatch:su,[Symbol.iterator]:iu};var rn=Ys;function Ce(e){return typeof e=="string"?new $e([[document.querySelector(e)]],[document.documentElement]):new $e([[e]],Zs)}function du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ie(e,t){if(e=du(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.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]}var cu={passive:!1},qt={capture:!0,passive:!1};function Po(e){e.stopImmediatePropagation()}function Ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Xs(e){var t=e.document.documentElement,n=Ce(e).on("dragstart.drag",Ct,qt);"onselectstart"in t?n.on("selectstart.drag",Ct,qt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function qs(e,t){var n=e.document.documentElement,o=Ce(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ct,qt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Cn=e=>()=>e;function Fo(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:s,x:i,y:l,dx:h,dy:u,dispatch:c}){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:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Fo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uu(e){return!e.ctrlKey&&!e.button}function hu(){return this.parentNode}function pu(e,t){return t??{x:e.x,y:e.y}}function mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ks(){var e=uu,t=hu,n=pu,o=mu,r={},s=na("start","drag","end"),i=0,l,h,u,c,p=0;function d(b){b.on("mousedown.drag",m).filter(o).on("touchstart.drag",y).on("touchmove.drag",x,cu).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(b,j){if(!(c||!e.call(this,b,j))){var S=v(this,t.call(this,b,j),b,j,"mouse");S&&(Ce(b.view).on("mousemove.drag",f,qt).on("mouseup.drag",w,qt),Xs(b.view),Po(b),u=!1,l=b.clientX,h=b.clientY,S("start",b))}}function f(b){if(Ct(b),!u){var j=b.clientX-l,S=b.clientY-h;u=j*j+S*S>p}r.mouse("drag",b)}function w(b){Ce(b.view).on("mousemove.drag mouseup.drag",null),qs(b.view,u),Ct(b),r.mouse("end",b)}function y(b,j){if(e.call(this,b,j)){var S=b.changedTouches,M=t.call(this,b,j),C=S.length,_,F;for(_=0;_<C;++_)(F=v(this,M,b,j,S[_].identifier,S[_]))&&(Po(b),F("start",b,S[_]))}}function x(b){var j=b.changedTouches,S=j.length,M,C;for(M=0;M<S;++M)(C=r[j[M].identifier])&&(Ct(b),C("drag",b,j[M]))}function E(b){var j=b.changedTouches,S=j.length,M,C;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),M=0;M<S;++M)(C=r[j[M].identifier])&&(Po(b),C("end",b,j[M]))}function v(b,j,S,M,C,_){var F=s.copy(),O=Ie(_||S,j),R,H,g;if((g=n.call(b,new Fo("beforestart",{sourceEvent:S,target:d,identifier:C,active:i,x:O[0],y:O[1],dx:0,dy:0,dispatch:F}),M))!=null)return R=g.x-O[0]||0,H=g.y-O[1]||0,function N(k,z,A){var $=O,B;switch(k){case"start":r[C]=N,B=i++;break;case"end":delete r[C],--i;case"drag":O=Ie(A||z,j),B=i;break}F.call(k,b,new Fo(k,{sourceEvent:z,subject:g,target:d,identifier:C,active:B,x:O[0]+R,y:O[1]+H,dx:O[0]-$[0],dy:O[1]-$[1],dispatch:F}),M)}}return d.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Cn(!!b),d):e},d.container=function(b){return arguments.length?(t=typeof b=="function"?b:Cn(b),d):t},d.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Cn(b),d):n},d.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Cn(!!b),d):o},d.on=function(){var b=s.on.apply(s,arguments);return b===s?d:b},d.clickDistance=function(b){return arguments.length?(p=(b=+b)*b,d):Math.sqrt(p)},d}function ra(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Us(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function sn(){}var Kt=.7,Vn=1/Kt,$t="\\s*([+-]?\\d+)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",fu=/^#([0-9a-f]{3,8})$/,gu=new RegExp(`^rgb\\(${$t},${$t},${$t}\\)$`),xu=new RegExp(`^rgb\\(${Fe},${Fe},${Fe}\\)$`),vu=new RegExp(`^rgba\\(${$t},${$t},${$t},${Ut}\\)$`),yu=new RegExp(`^rgba\\(${Fe},${Fe},${Fe},${Ut}\\)$`),bu=new RegExp(`^hsl\\(${Ut},${Fe},${Fe}\\)$`),wu=new RegExp(`^hsla\\(${Ut},${Fe},${Fe},${Ut}\\)$`),wr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ra(sn,ct,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jr,formatHex:jr,formatHex8:ju,formatHsl:Nu,formatRgb:Nr,toString:Nr});function jr(){return this.rgb().formatHex()}function ju(){return this.rgb().formatHex8()}function Nu(){return Gs(this).formatHsl()}function Nr(){return this.rgb().formatRgb()}function ct(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=fu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?kr(t):n===3?new ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$n(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$n(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=gu.exec(e))?new ke(t[1],t[2],t[3],1):(t=xu.exec(e))?new ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vu.exec(e))?$n(t[1],t[2],t[3],t[4]):(t=yu.exec(e))?$n(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bu.exec(e))?$r(t[1],t[2]/100,t[3]/100,1):(t=wu.exec(e))?$r(t[1],t[2]/100,t[3]/100,t[4]):wr.hasOwnProperty(e)?kr(wr[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function kr(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function $n(e,t,n,o){return o<=0&&(e=t=n=NaN),new ke(e,t,n,o)}function ku(e){return e instanceof sn||(e=ct(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Hn(e,t,n,o){return arguments.length===1?ku(e):new ke(e,t,n,o??1)}function ke(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}ra(ke,Hn,Us(sn,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(lt(this.r),lt(this.g),lt(this.b),Fn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Sr,formatHex:Sr,formatHex8:Su,formatRgb:Cr,toString:Cr}));function Sr(){return`#${it(this.r)}${it(this.g)}${it(this.b)}`}function Su(){return`#${it(this.r)}${it(this.g)}${it(this.b)}${it((isNaN(this.opacity)?1:this.opacity)*255)}`}function Cr(){let e=Fn(this.opacity);return`${e===1?"rgb(":"rgba("}${lt(this.r)}, ${lt(this.g)}, ${lt(this.b)}${e===1?")":`, ${e})`}`}function Fn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function lt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function it(e){return e=lt(e),(e<16?"0":"")+e.toString(16)}function $r(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new De(e,t,n,o)}function Gs(e){if(e instanceof De)return new De(e.h,e.s,e.l,e.opacity);if(e instanceof sn||(e=ct(e)),!e)return new De;if(e instanceof De)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),s=Math.max(t,n,o),i=NaN,l=s-r,h=(s+r)/2;return l?(t===s?i=(n-o)/l+(n<o)*6:n===s?i=(o-t)/l+2:i=(t-n)/l+4,l/=h<.5?s+r:2-s-r,i*=60):l=h>0&&h<1?0:i,new De(i,l,h,e.opacity)}function Cu(e,t,n,o){return arguments.length===1?Gs(e):new De(e,t,n,o??1)}function De(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}ra(De,Cu,Us(sn,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new De(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new De(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ke(Ao(e>=240?e-240:e+120,r,o),Ao(e,r,o),Ao(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new De(Er(this.h),En(this.s),En(this.l),Fn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Fn(this.opacity);return`${e===1?"hsl(":"hsla("}${Er(this.h)}, ${En(this.s)*100}%, ${En(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Er(e){return e=(e||0)%360,e<0?e+360:e}function En(e){return Math.max(0,Math.min(1,e||0))}function Ao(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function Js(e,t,n,o,r){var s=e*e,i=s*e;return((1-3*e+3*s-i)*t+(4-6*s+3*i)*n+(1+3*e+3*s-3*i)*o+i*r)/6}function $u(e){var t=e.length-1;return function(n){var o=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),r=e[o],s=e[o+1],i=o>0?e[o-1]:2*r-s,l=o<t-1?e[o+2]:2*s-r;return Js((n-o/t)*t,i,r,s,l)}}function Eu(e){var t=e.length;return function(n){var o=Math.floor(((n%=1)<0?++n:n)*t),r=e[(o+t-1)%t],s=e[o%t],i=e[(o+1)%t],l=e[(o+2)%t];return Js((n-o/t)*t,r,s,i,l)}}var sa=e=>()=>e;function Mu(e,t){return function(n){return e+n*t}}function zu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function _u(e){return(e=+e)==1?Qs:function(t,n){return n-t?zu(t,n,e):sa(isNaN(t)?n:t)}}function Qs(e,t){var n=t-e;return n?Mu(e,n):sa(isNaN(e)?t:e)}var Wn=(function e(t){var n=_u(t);function o(r,s){var i=n((r=Hn(r)).r,(s=Hn(s)).r),l=n(r.g,s.g),h=n(r.b,s.b),u=Qs(r.opacity,s.opacity);return function(c){return r.r=i(c),r.g=l(c),r.b=h(c),r.opacity=u(c),r+""}}return o.gamma=e,o})(1);function ei(e){return function(t){var n=t.length,o=new Array(n),r=new Array(n),s=new Array(n),i,l;for(i=0;i<n;++i)l=Hn(t[i]),o[i]=l.r||0,r[i]=l.g||0,s[i]=l.b||0;return o=e(o),r=e(r),s=e(s),l.opacity=1,function(h){return l.r=o(h),l.g=r(h),l.b=s(h),l+""}}}var Vy=ei($u),Hy=ei(Eu);function Pu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(s){for(r=0;r<n;++r)o[r]=e[r]*(1-s)+t[r]*s;return o}}function Au(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Iu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),s=new Array(n),i;for(i=0;i<o;++i)r[i]=Yt(e[i],t[i]);for(;i<n;++i)s[i]=t[i];return function(l){for(i=0;i<o;++i)s[i]=r[i](l);return s}}function Du(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ru(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Yt(e[r],t[r]):o[r]=t[r];return function(s){for(r in n)o[r]=n[r](s);return o}}var Wo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Io=new RegExp(Wo.source,"g");function Ou(e){return function(){return e}}function Lu(e){return function(t){return e(t)+""}}function ti(e,t){var n=Wo.lastIndex=Io.lastIndex=0,o,r,s,i=-1,l=[],h=[];for(e=e+"",t=t+"";(o=Wo.exec(e))&&(r=Io.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),l[i]?l[i]+=s:l[++i]=s),(o=o[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,h.push({i,x:He(o,r)})),n=Io.lastIndex;return n<t.length&&(s=t.slice(n),l[i]?l[i]+=s:l[++i]=s),l.length<2?h[0]?Lu(h[0].x):Ou(t):(t=h.length,function(u){for(var c=0,p;c<t;++c)l[(p=h[c]).i]=p.x(u);return l.join("")})}function Yt(e,t){var n=typeof t,o;return t==null||n==="boolean"?sa(t):(n==="number"?He:n==="string"?(o=ct(t))?(t=o,Wn):ti:t instanceof ct?Wn:t instanceof Date?Du:Au(t)?Pu:Array.isArray(t)?Iu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ru:He)(e,t)}var Mr=180/Math.PI,Zo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ni(e,t,n,o,r,s){var i,l,h;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(h=e*n+t*o)&&(n-=e*h,o-=t*h),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,h/=l),e*o<t*n&&(e=-e,t=-t,h=-h,i=-i),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*Mr,skewX:Math.atan(h)*Mr,scaleX:i,scaleY:l}}var Mn;function Tu(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zo:ni(t.a,t.b,t.c,t.d,t.e,t.f)}function Bu(e){return e==null?Zo:(Mn||(Mn=document.createElementNS("http://www.w3.org/2000/svg","g")),Mn.setAttribute("transform",e),(e=Mn.transform.baseVal.consolidate())?(e=e.matrix,ni(e.a,e.b,e.c,e.d,e.e,e.f)):Zo)}function oi(e,t,n,o){function r(u){return u.length?u.pop()+" ":""}function s(u,c,p,d,m,f){if(u!==p||c!==d){var w=m.push("translate(",null,t,null,n);f.push({i:w-4,x:He(u,p)},{i:w-2,x:He(c,d)})}else(p||d)&&m.push("translate("+p+t+d+n)}function i(u,c,p,d){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),d.push({i:p.push(r(p)+"rotate(",null,o)-2,x:He(u,c)})):c&&p.push(r(p)+"rotate("+c+o)}function l(u,c,p,d){u!==c?d.push({i:p.push(r(p)+"skewX(",null,o)-2,x:He(u,c)}):c&&p.push(r(p)+"skewX("+c+o)}function h(u,c,p,d,m,f){if(u!==p||c!==d){var w=m.push(r(m)+"scale(",null,",",null,")");f.push({i:w-4,x:He(u,p)},{i:w-2,x:He(c,d)})}else(p!==1||d!==1)&&m.push(r(m)+"scale("+p+","+d+")")}return function(u,c){var p=[],d=[];return u=e(u),c=e(c),s(u.translateX,u.translateY,c.translateX,c.translateY,p,d),i(u.rotate,c.rotate,p,d),l(u.skewX,c.skewX,p,d),h(u.scaleX,u.scaleY,c.scaleX,c.scaleY,p,d),u=c=null,function(m){for(var f=-1,w=d.length,y;++f<w;)p[(y=d[f]).i]=y.x(m);return p.join("")}}}var Vu=oi(Tu,"px, ","px)","deg)"),Hu=oi(Bu,", ",")",")"),Fu=1e-12;function zr(e){return((e=Math.exp(e))+1/e)/2}function Wu(e){return((e=Math.exp(e))-1/e)/2}function Zu(e){return((e=Math.exp(2*e))-1)/(e+1)}var Rn=(function e(t,n,o){function r(s,i){var l=s[0],h=s[1],u=s[2],c=i[0],p=i[1],d=i[2],m=c-l,f=p-h,w=m*m+f*f,y,x;if(w<Fu)x=Math.log(d/u)/t,y=function(M){return[l+M*m,h+M*f,u*Math.exp(t*M*x)]};else{var E=Math.sqrt(w),v=(d*d-u*u+o*w)/(2*u*n*E),b=(d*d-u*u-o*w)/(2*d*n*E),j=Math.log(Math.sqrt(v*v+1)-v),S=Math.log(Math.sqrt(b*b+1)-b);x=(S-j)/t,y=function(M){var C=M*x,_=zr(j),F=u/(n*E)*(_*Zu(t*C+j)-Wu(j));return[l+F*m,h+F*f,u*_/zr(t*C+j)]}}return y.duration=x*1e3*t/Math.SQRT2,y}return r.rho=function(s){var i=Math.max(.001,+s),l=i*i,h=l*l;return e(i,l,h)},r})(Math.SQRT2,2,4),Mt=0,Wt=0,Ht=0,ai=1e3,Zn,Zt,Yn=0,ut=0,Qn=0,Gt=typeof performance=="object"&&performance.now?performance:Date,ri=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ia(){return ut||(ri(Yu),ut=Gt.now()+Qn)}function Yu(){ut=0}function Xn(){this._call=this._time=this._next=null}Xn.prototype=si.prototype={constructor:Xn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ia():+n)+(t==null?0:+t),!this._next&&Zt!==this&&(Zt?Zt._next=this:Zn=this,Zt=this),this._call=e,this._time=n,Yo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yo())}};function si(e,t,n){var o=new Xn;return o.restart(e,t,n),o}function Xu(){ia(),++Mt;for(var e=Zn,t;e;)(t=ut-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mt}function _r(){ut=(Yn=Gt.now())+Qn,Mt=Wt=0;try{Xu()}finally{Mt=0,Ku(),ut=0}}function qu(){var e=Gt.now(),t=e-Yn;t>ai&&(Qn-=t,Yn=e)}function Ku(){for(var e,t=Zn,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Zn=n);Zt=e,Yo(o)}function Yo(e){if(!Mt){Wt&&(Wt=clearTimeout(Wt));var t=e-ut;t>24?(e<1/0&&(Wt=setTimeout(_r,e-Gt.now()-Qn)),Ht&&(Ht=clearInterval(Ht))):(Ht||(Yn=Gt.now(),Ht=setInterval(qu,ai)),Mt=1,ri(_r))}}function Pr(e,t,n){var o=new Xn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Uu=na("start","end","cancel","interrupt"),Gu=[],ii=0,Ar=1,Xo=2,On=3,Ir=4,qo=5,Ln=6;function eo(e,t,n,o,r,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Ju(e,n,{name:t,index:o,group:r,on:Uu,tween:Gu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ii})}function la(e,t){var n=Le(e,t);if(n.state>ii)throw new Error("too late; already scheduled");return n}function We(e,t){var n=Le(e,t);if(n.state>On)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ju(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=si(s,0,n.time);function s(u){n.state=Ar,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var c,p,d,m;if(n.state!==Ar)return h();for(c in o)if(m=o[c],m.name===n.name){if(m.state===On)return Pr(i);m.state===Ir?(m.state=Ln,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete o[c]):+c<t&&(m.state=Ln,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete o[c])}if(Pr(function(){n.state===On&&(n.state=Ir,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Xo,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xo){for(n.state=On,r=new Array(d=n.tween.length),c=0,p=-1;c<d;++c)(m=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=m);r.length=p+1}}function l(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(h),n.state=qo,1),p=-1,d=r.length;++p<d;)r[p].call(e,c);n.state===qo&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=Ln,n.timer.stop(),delete o[t];for(var u in o)return;delete e.__transition}}function Tn(e,t){var n=e.__transition,o,r,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){s=!1;continue}r=o.state>Xo&&o.state<qo,o.state=Ln,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}s&&delete e.__transition}}function Qu(e){return this.each(function(){Tn(this,e)})}function eh(e,t){var n,o;return function(){var r=We(this,e),s=r.tween;if(s!==n){o=n=s;for(var i=0,l=o.length;i<l;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}r.tween=o}}function th(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var s=We(this,e),i=s.tween;if(i!==o){r=(o=i).slice();for(var l={name:t,value:n},h=0,u=r.length;h<u;++h)if(r[h].name===t){r[h]=l;break}h===u&&r.push(l)}s.tween=r}}function nh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Le(this.node(),n).tween,r=0,s=o.length,i;r<s;++r)if((i=o[r]).name===e)return i.value;return null}return this.each((t==null?eh:th)(n,e,t))}function da(e,t,n){var o=e._id;return e.each(function(){var r=We(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Le(r,o).value[t]}}function li(e,t){var n;return(typeof t=="number"?He:t instanceof ct?Wn:(n=ct(t))?(t=n,Wn):ti)(e,t)}function oh(e){return function(){this.removeAttribute(e)}}function ah(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttribute(e);return i===r?null:i===o?s:s=t(o=i,n)}}function sh(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===r?null:i===o?s:s=t(o=i,n)}}function ih(e,t,n){var o,r,s;return function(){var i,l=n(this),h;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),h=l+"",i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l)))}}function lh(e,t,n){var o,r,s;return function(){var i,l=n(this),h;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),h=l+"",i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l)))}}function dh(e,t){var n=Jn(e),o=n==="transform"?Hu:li;return this.attrTween(e,typeof t=="function"?(n.local?lh:ih)(n,o,da(this,"attr."+e,t)):t==null?(n.local?ah:oh)(n):(n.local?sh:rh)(n,o,t))}function ch(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function uh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hh(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&uh(e,s)),n}return r._value=t,r}function ph(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&ch(e,s)),n}return r._value=t,r}function mh(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 o=Jn(e);return this.tween(n,(o.local?hh:ph)(o,t))}function fh(e,t){return function(){la(this,e).delay=+t.apply(this,arguments)}}function gh(e,t){return t=+t,function(){la(this,e).delay=t}}function xh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fh:gh)(t,e)):Le(this.node(),t).delay}function vh(e,t){return function(){We(this,e).duration=+t.apply(this,arguments)}}function yh(e,t){return t=+t,function(){We(this,e).duration=t}}function bh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vh:yh)(t,e)):Le(this.node(),t).duration}function wh(e,t){if(typeof t!="function")throw new Error;return function(){We(this,e).ease=t}}function jh(e){var t=this._id;return arguments.length?this.each(wh(t,e)):Le(this.node(),t).ease}function Nh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;We(this,e).ease=n}}function kh(e){if(typeof e!="function")throw new Error;return this.each(Nh(this._id,e))}function Sh(e){typeof e!="function"&&(e=Rs(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=[],h,u=0;u<i;++u)(h=s[u])&&e.call(h,h.__data__,u,s)&&l.push(h);return new Ge(o,this._parents,this._name,this._id)}function Ch(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,s=Math.min(o,r),i=new Array(o),l=0;l<s;++l)for(var h=t[l],u=n[l],c=h.length,p=i[l]=new Array(c),d,m=0;m<c;++m)(d=h[m]||u[m])&&(p[m]=d);for(;l<o;++l)i[l]=t[l];return new Ge(i,this._parents,this._name,this._id)}function $h(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 Eh(e,t,n){var o,r,s=$h(t)?la:We;return function(){var i=s(this,e),l=i.on;l!==o&&(r=(o=l).copy()).on(t,n),i.on=r}}function Mh(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(Eh(n,e,t))}function zh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function _h(){return this.on("end.remove",zh(this._id))}function Ph(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oa(e));for(var o=this._groups,r=o.length,s=new Array(r),i=0;i<r;++i)for(var l=o[i],h=l.length,u=s[i]=new Array(h),c,p,d=0;d<h;++d)(c=l[d])&&(p=e.call(c,c.__data__,d,l))&&("__data__"in c&&(p.__data__=c.__data__),u[d]=p,eo(u[d],t,n,d,u,Le(c,n)));return new Ge(s,this._parents,t,n)}function Ah(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ds(e));for(var o=this._groups,r=o.length,s=[],i=[],l=0;l<r;++l)for(var h=o[l],u=h.length,c,p=0;p<u;++p)if(c=h[p]){for(var d=e.call(c,c.__data__,p,h),m,f=Le(c,n),w=0,y=d.length;w<y;++w)(m=d[w])&&eo(m,t,n,w,d,f);s.push(d),i.push(c)}return new Ge(s,i,t,n)}var Ih=rn.prototype.constructor;function Dh(){return new Ih(this._groups,this._parents)}function Rh(e,t){var n,o,r;return function(){var s=Et(this,e),i=(this.style.removeProperty(e),Et(this,e));return s===i?null:s===n&&i===o?r:r=t(n=s,o=i)}}function di(e){return function(){this.style.removeProperty(e)}}function Oh(e,t,n){var o,r=n+"",s;return function(){var i=Et(this,e);return i===r?null:i===o?s:s=t(o=i,n)}}function Lh(e,t,n){var o,r,s;return function(){var i=Et(this,e),l=n(this),h=l+"";return l==null&&(h=l=(this.style.removeProperty(e),Et(this,e))),i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l))}}function Th(e,t){var n,o,r,s="style."+t,i="end."+s,l;return function(){var h=We(this,e),u=h.on,c=h.value[s]==null?l||(l=di(t)):void 0;(u!==n||r!==c)&&(o=(n=u).copy()).on(i,r=c),h.on=o}}function Bh(e,t,n){var o=(e+="")=="transform"?Vu:li;return t==null?this.styleTween(e,Rh(e,o)).on("end.style."+e,di(e)):typeof t=="function"?this.styleTween(e,Lh(e,o,da(this,"style."+e,t))).each(Th(this._id,e)):this.styleTween(e,Oh(e,o,t),n).on("end.style."+e,null)}function Vh(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Hh(e,t,n){var o,r;function s(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&Vh(e,i,n)),o}return s._value=t,s}function Fh(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Hh(e,t,n??""))}function Wh(e){return function(){this.textContent=e}}function Zh(e){return function(){var t=e(this);this.textContent=t??""}}function Yh(e){return this.tween("text",typeof e=="function"?Zh(da(this,"text",e)):Wh(e==null?"":e+""))}function Xh(e){return function(t){this.textContent=e.call(this,t)}}function qh(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Xh(r)),t}return o._value=e,o}function Kh(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,qh(e))}function Uh(){for(var e=this._name,t=this._id,n=ci(),o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],l=i.length,h,u=0;u<l;++u)if(h=i[u]){var c=Le(h,t);eo(h,e,n,u,i,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Ge(o,this._parents,e,n)}function Gh(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(s,i){var l={value:i},h={value:function(){--r===0&&s()}};n.each(function(){var u=We(this,o),c=u.on;c!==e&&(t=(e=c).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(h)),u.on=t}),r===0&&s()})}var Jh=0;function Ge(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Qh(e){return rn().transition(e)}function ci(){return++Jh}var Ze=rn.prototype;Ge.prototype=Qh.prototype={constructor:Ge,select:Ph,selectAll:Ah,selectChild:Ze.selectChild,selectChildren:Ze.selectChildren,filter:Sh,merge:Ch,selection:Dh,transition:Uh,call:Ze.call,nodes:Ze.nodes,node:Ze.node,size:Ze.size,empty:Ze.empty,each:Ze.each,on:Mh,attr:dh,attrTween:mh,style:Bh,styleTween:Fh,text:Yh,textTween:Kh,remove:_h,tween:nh,delay:xh,duration:bh,ease:jh,easeVarying:kh,end:Gh,[Symbol.iterator]:Ze[Symbol.iterator]};function ep(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tp={time:null,delay:0,duration:250,ease:ep};function np(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 op(e){var t,n;e instanceof Ge?(t=e._id,e=e._name):(t=ci(),(n=tp).time=ia(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],l=i.length,h,u=0;u<l;++u)(h=i[u])&&eo(h,e,t,u,i,n||np(h,t));return new Ge(o,this._parents,e,t)}rn.prototype.interrupt=Qu;rn.prototype.transition=op;var zn=e=>()=>e;function ap(e,{sourceEvent:t,target:n,transform:o,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:o,enumerable:!0,configurable:!0},_:{value:r}})}function qe(e,t,n){this.k=e,this.x=t,this.y=n}qe.prototype={constructor:qe,scale:function(e){return e===1?this:new qe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new qe(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 to=new qe(1,0,0);ui.prototype=qe.prototype;function ui(e){for(;!e.__zoom;)if(!(e=e.parentNode))return to;return e.__zoom}function Do(e){e.stopImmediatePropagation()}function Ft(e){e.preventDefault(),e.stopImmediatePropagation()}function rp(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sp(){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 Dr(){return this.__zoom||to}function ip(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lp(){return navigator.maxTouchPoints||"ontouchstart"in this}function dp(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function hi(){var e=rp,t=sp,n=dp,o=ip,r=lp,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,h=Rn,u=na("start","zoom","end"),c,p,d,m=500,f=150,w=0,y=10;function x(g){g.property("__zoom",Dr).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",F).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(g,N,k,z){var A=g.selection?g.selection():g;A.property("__zoom",Dr),g!==A?j(g,N,k,z):A.interrupt().each(function(){S(this,arguments).event(z).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},x.scaleBy=function(g,N,k,z){x.scaleTo(g,function(){var A=this.__zoom.k,$=typeof N=="function"?N.apply(this,arguments):N;return A*$},k,z)},x.scaleTo=function(g,N,k,z){x.transform(g,function(){var A=t.apply(this,arguments),$=this.__zoom,B=k==null?b(A):typeof k=="function"?k.apply(this,arguments):k,V=$.invert(B),W=typeof N=="function"?N.apply(this,arguments):N;return n(v(E($,W),B,V),A,i)},k,z)},x.translateBy=function(g,N,k,z){x.transform(g,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),i)},null,z)},x.translateTo=function(g,N,k,z,A){x.transform(g,function(){var $=t.apply(this,arguments),B=this.__zoom,V=z==null?b($):typeof z=="function"?z.apply(this,arguments):z;return n(to.translate(V[0],V[1]).scale(B.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof k=="function"?-k.apply(this,arguments):-k),$,i)},z,A)};function E(g,N){return N=Math.max(s[0],Math.min(s[1],N)),N===g.k?g:new qe(N,g.x,g.y)}function v(g,N,k){var z=N[0]-k[0]*g.k,A=N[1]-k[1]*g.k;return z===g.x&&A===g.y?g:new qe(g.k,z,A)}function b(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function j(g,N,k,z){g.on("start.zoom",function(){S(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,$=arguments,B=S(A,$).event(z),V=t.apply(A,$),W=k==null?b(V):typeof k=="function"?k.apply(A,$):k,J=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),X=A.__zoom,Z=typeof N=="function"?N.apply(A,$):N,ee=h(X.invert(W).concat(J/X.k),Z.invert(W).concat(J/Z.k));return function(Q){if(Q===1)Q=Z;else{var T=ee(Q),K=J/T[2];Q=new qe(K,W[0]-T[0]*K,W[1]-T[1]*K)}B.zoom(null,Q)}})}function S(g,N,k){return!k&&g.__zooming||new M(g,N)}function M(g,N){this.that=g,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,N),this.taps=0}M.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,N){return this.mouse&&g!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var N=Ce(this.that).datum();u.call(g,this.that,new ap(g,{sourceEvent:this.sourceEvent,target:x,type:g,transform:this.that.__zoom,dispatch:u}),N)}};function C(g,...N){if(!e.apply(this,arguments))return;var k=S(this,N).event(g),z=this.__zoom,A=Math.max(s[0],Math.min(s[1],z.k*Math.pow(2,o.apply(this,arguments)))),$=Ie(g);if(k.wheel)(k.mouse[0][0]!==$[0]||k.mouse[0][1]!==$[1])&&(k.mouse[1]=z.invert(k.mouse[0]=$)),clearTimeout(k.wheel);else{if(z.k===A)return;k.mouse=[$,z.invert($)],Tn(this),k.start()}Ft(g),k.wheel=setTimeout(B,f),k.zoom("mouse",n(v(E(z,A),k.mouse[0],k.mouse[1]),k.extent,i));function B(){k.wheel=null,k.end()}}function _(g,...N){if(d||!e.apply(this,arguments))return;var k=g.currentTarget,z=S(this,N,!0).event(g),A=Ce(g.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",J,!0),$=Ie(g,k),B=g.clientX,V=g.clientY;Xs(g.view),Do(g),z.mouse=[$,this.__zoom.invert($)],Tn(this),z.start();function W(X){if(Ft(X),!z.moved){var Z=X.clientX-B,ee=X.clientY-V;z.moved=Z*Z+ee*ee>w}z.event(X).zoom("mouse",n(v(z.that.__zoom,z.mouse[0]=Ie(X,k),z.mouse[1]),z.extent,i))}function J(X){A.on("mousemove.zoom mouseup.zoom",null),qs(X.view,z.moved),Ft(X),z.event(X).end()}}function F(g,...N){if(e.apply(this,arguments)){var k=this.__zoom,z=Ie(g.changedTouches?g.changedTouches[0]:g,this),A=k.invert(z),$=k.k*(g.shiftKey?.5:2),B=n(v(E(k,$),z,A),t.apply(this,N),i);Ft(g),l>0?Ce(this).transition().duration(l).call(j,B,z,g):Ce(this).call(x.transform,B,z,g)}}function O(g,...N){if(e.apply(this,arguments)){var k=g.touches,z=k.length,A=S(this,N,g.changedTouches.length===z).event(g),$,B,V,W;for(Do(g),B=0;B<z;++B)V=k[B],W=Ie(V,this),W=[W,this.__zoom.invert(W),V.identifier],A.touch0?!A.touch1&&A.touch0[2]!==W[2]&&(A.touch1=W,A.taps=0):(A.touch0=W,$=!0,A.taps=1+!!c);c&&(c=clearTimeout(c)),$&&(A.taps<2&&(p=W[0],c=setTimeout(function(){c=null},m)),Tn(this),A.start())}}function R(g,...N){if(this.__zooming){var k=S(this,N).event(g),z=g.changedTouches,A=z.length,$,B,V,W;for(Ft(g),$=0;$<A;++$)B=z[$],V=Ie(B,this),k.touch0&&k.touch0[2]===B.identifier?k.touch0[0]=V:k.touch1&&k.touch1[2]===B.identifier&&(k.touch1[0]=V);if(B=k.that.__zoom,k.touch1){var J=k.touch0[0],X=k.touch0[1],Z=k.touch1[0],ee=k.touch1[1],Q=(Q=Z[0]-J[0])*Q+(Q=Z[1]-J[1])*Q,T=(T=ee[0]-X[0])*T+(T=ee[1]-X[1])*T;B=E(B,Math.sqrt(Q/T)),V=[(J[0]+Z[0])/2,(J[1]+Z[1])/2],W=[(X[0]+ee[0])/2,(X[1]+ee[1])/2]}else if(k.touch0)V=k.touch0[0],W=k.touch0[1];else return;k.zoom("touch",n(v(B,V,W),k.extent,i))}}function H(g,...N){if(this.__zooming){var k=S(this,N).event(g),z=g.changedTouches,A=z.length,$,B;for(Do(g),d&&clearTimeout(d),d=setTimeout(function(){d=null},m),$=0;$<A;++$)B=z[$],k.touch0&&k.touch0[2]===B.identifier?delete k.touch0:k.touch1&&k.touch1[2]===B.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&&(B=Ie(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<y)){var V=Ce(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(g){return arguments.length?(o=typeof g=="function"?g:zn(+g),x):o},x.filter=function(g){return arguments.length?(e=typeof g=="function"?g:zn(!!g),x):e},x.touchable=function(g){return arguments.length?(r=typeof g=="function"?g:zn(!!g),x):r},x.extent=function(g){return arguments.length?(t=typeof g=="function"?g:zn([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),x):t},x.scaleExtent=function(g){return arguments.length?(s[0]=+g[0],s[1]=+g[1],x):[s[0],s[1]]},x.translateExtent=function(g){return arguments.length?(i[0][0]=+g[0][0],i[1][0]=+g[1][0],i[0][1]=+g[0][1],i[1][1]=+g[1][1],x):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},x.constrain=function(g){return arguments.length?(n=g,x):n},x.duration=function(g){return arguments.length?(l=+g,x):l},x.interpolate=function(g){return arguments.length?(h=g,x):h},x.on=function(){var g=u.on.apply(u,arguments);return g===u?x:g},x.clickDistance=function(g){return arguments.length?(w=(g=+g)*g,x):Math.sqrt(w)},x.tapDistance=function(g){return arguments.length?(y=+g,x):y},x}var _e={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", 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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],pi=["Enter"," ","Escape"],mi={"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"},zt;(function(e){e.Strict="strict",e.Loose="loose"})(zt||(zt={}));var dt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(dt||(dt={}));var Qt;(function(e){e.Partial="partial",e.Full="full"})(Qt||(Qt={}));var fi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},at;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(at||(at={}));var Xe;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xe||(Xe={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));var Rr={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top},gi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,cp=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ca=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ln=(e,t=[0,0])=>{let{width:n,height:o}=Te(e),r=e.origin??t,s=n*r[0],i=o*r[1];return{x:e.position.x-s,y:e.position.y-i}},up=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,o=e.reduce((r,s)=>{let i=typeof s=="string",l=!t.nodeLookup&&!i?s:void 0;return t.nodeLookup&&(l=i?t.nodeLookup.get(s):ca(s)?s:t.nodeLookup.get(s.id)),l?(n=!0,no(r,qn(l,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?oo(o):{x:0,y:0,width:0,height:0}},dn=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=no(n,qn(r)),o=!0)}),o?oo(n):{x:0,y:0,width:0,height:0}},ua=(e,t,[n,o,r]=[0,0,1],s=!1,i=!1)=>{let l=(t.x-n)/r,h=(t.y-o)/r,u=t.width/r,c=t.height/r,p=[];for(let d of e.values()){let{measured:m,selectable:f=!0,hidden:w=!1}=d;if(i&&!f||w)continue;let y=m.width??d.width??d.initialWidth??0,x=m.height??d.height??d.initialHeight??0,{x:E,y:v}=d.internals.positionAbsolute,b=bi(l,h,u,c,E,v,y,x),j=y*x,S=s&&b>0;(!d.internals.handleBounds||S||b>=j||d.dragging)&&p.push(d)}return p},hp=(e,t)=>{let n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function pp(e,t){let n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let s;if(t?.includeHiddenNodes){let{width:i,height:l}=Te(r);s=i>0&&l>0}else s=!!(r.measured.width&&r.measured.height&&!r.hidden);s&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function mp({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:s},i){if(e.size===0)return!0;let l=pp(e,i),h=dn(l),u=pa(h,t,n,i?.minZoom??r,i?.maxZoom??s,i?.padding??.1);return await o.setViewport(u,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),!0}function xi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:s}){let i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:h,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},c=i.origin??o,p=i.extent||r;if(i.extent==="parent"&&!i.expandParent)if(!l)s?.("005",_e.error005());else{let{width:m,height:f}=Te(l);m&&f&&(p=[[h,u],[h+m,u+f]])}else l&&pt(i.extent)&&(p=[[i.extent[0][0]+h,i.extent[0][1]+u],[i.extent[1][0]+h,i.extent[1][1]+u]]);let d=pt(p)?ht(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&s?.("015",_e.error015()),{position:{x:d.x-h+(i.measured.width??0)*c[0],y:d.y-u+(i.measured.height??0)*c[1]},positionAbsolute:d}}async function fp({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){let s=new Set(e.map(p=>p.id)),i=[];for(let p of n){if(p.deletable===!1)continue;let d=s.has(p.id),m=!d&&p.parentId&&i.find(f=>f.id===p.parentId);(d||m)&&i.push(p)}let l=new Set(t.map(p=>p.id)),h=o.filter(p=>p.deletable!==!1),u=hp(i,h);for(let p of h)l.has(p.id)&&!u.find(d=>d.id===p.id)&&u.push(p);if(!r)return{edges:u,nodes:i};let c=await r({nodes:i,edges:u});return typeof c=="boolean"?c?{edges:u,nodes:i}:{edges:[],nodes:[]}:c}var _t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ht=(e={x:0,y:0},t,n)=>({x:_t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:_t(e.y,t[0][1],t[1][1]-(n?.height??0))});function vi(e,t,n){let{width:o,height:r}=Te(n),{x:s,y:i}=n.internals.positionAbsolute;return ht(e,[[s,i],[s+o,i+r]],t)}var Or=(e,t,n)=>e<t?_t(Math.abs(e-t),1,t)/t:e>n?-_t(Math.abs(e-n),1,t)/t:0,ha=(e,t,n=15,o=40)=>{let r=Or(e.x,o,t.width-o)*n,s=Or(e.y,o,t.height-o)*n;return[r,s]},no=(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)}),Ko=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),oo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),en=(e,t=[0,0])=>{let{x:n,y:o}=ca(e)?e.internals.positionAbsolute:ln(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},qn=(e,t=[0,0])=>{let{x:n,y:o}=ca(e)?e.internals.positionAbsolute:ln(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},yi=(e,t)=>oo(no(Ko(e),Ko(t))),bi=(e,t,n,o,r,s,i,l)=>{let h=Math.max(0,Math.min(e+n,r+i)-Math.max(e,r)),u=Math.max(0,Math.min(t+o,s+l)-Math.max(t,s));return Math.ceil(h*u)},Kn=(e,t)=>bi(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Lr=e=>Re(e.width)&&Re(e.height)&&Re(e.x)&&Re(e.y),Re=e=>!isNaN(e)&&isFinite(e),wi=(e,t)=>(n,o)=>{},cn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),un=({x:e,y:t},[n,o,r],s=!1,i=[1,1])=>{let l={x:(e-n)/r,y:(t-o)/r};return s?cn(l,i):l},Pt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function kt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gp(e,t,n){if(typeof e=="string"||typeof e=="number"){let o=kt(e,n),r=kt(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){let o=kt(e.top??e.y??0,n),r=kt(e.bottom??e.y??0,n),s=kt(e.left??e.x??0,t),i=kt(e.right??e.x??0,t);return{top:o,right:i,bottom:r,left:s,x:s+i,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xp(e,t,n,o,r,s){let{x:i,y:l}=Pt(e,[t,n,o]),{x:h,y:u}=Pt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),c=r-h,p=s-u;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(c),bottom:Math.floor(p)}}var pa=(e,t,n,o,r,s)=>{let i=gp(s,t,n),l=(t-i.x)/e.width,h=(n-i.y)/e.height,u=Math.min(l,h),c=_t(u,o,r),p=e.x+e.width/2,d=e.y+e.height/2,m=t/2-p*c,f=n/2-d*c,w=xp(e,m,f,c,t,n),y={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:m-y.left+y.right,y:f-y.top+y.bottom,zoom:c}},tn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function pt(e){return e!=null&&e!=="parent"}function Te(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ji(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Ni(e,t={width:0,height:0},n,o,r){let s={...e},i=o.get(n);if(i){let l=i.origin||r;s.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return s}function Tr(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function vp(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}function yp(e){return{...mi,...e||{}}}function ki(e){return e===null?null:e?"valid":"invalid"}function Xt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){let{x:s,y:i}=Oe(e),l=un({x:s-(r?.left??0),y:i-(r?.top??0)},o),{x:h,y:u}=n?cn(l,t):l;return{xSnapped:h,ySnapped:u,...l}}var ma=e=>({width:e.offsetWidth,height:e.offsetHeight}),Si=e=>e?.getRootNode?.()||window?.document,bp=["INPUT","SELECT","TEXTAREA"];function Ci(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:bp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}var $i=e=>"clientX"in e,Oe=(e,t)=>{let n=$i(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Br=(e,t,n,o,r)=>{let s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{let l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:r,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...ma(i)}})};function Ei({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:i,targetControlY:l}){let h=e*.125+r*.375+i*.375+n*.125,u=t*.125+s*.375+l*.375+o*.125,c=Math.abs(h-e),p=Math.abs(u-t);return[h,u,c,p]}function _n(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Vr({pos:e,x1:t,y1:n,x2:o,y2:r,c:s}){switch(e){case U.Left:return[t-_n(t-o,s),n];case U.Right:return[t+_n(o-t,s),n];case U.Top:return[t,n-_n(n-r,s)];case U.Bottom:return[t,n+_n(r-n,s)]}}function Mi({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top,curvature:i=.25}){let[l,h]=Vr({pos:n,x1:e,y1:t,x2:o,y2:r,c:i}),[u,c]=Vr({pos:s,x1:o,y1:r,x2:e,y2:t,c:i}),[p,d,m,f]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:l,sourceControlY:h,targetControlX:u,targetControlY:c});return[`M${e},${t} C${l},${h} ${u},${c} ${o},${r}`,p,d,m,f]}function zi({sourceX:e,sourceY:t,targetX:n,targetY:o}){let r=Math.abs(n-e)/2,s=n<e?n+r:n-r,i=Math.abs(o-t)/2,l=o<t?o+i:o-i;return[s,l,r,i]}function wp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return o;let i=r&&n?o+1e3:o,l=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return i+l}function jp({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){let s=no(qn(e),qn(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);let i={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return Kn(i,oo(s))>0}var Np=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,kp=(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)),Sp=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",_e.error006()),t;let o=n.getEdgeId||Np,r;return gi(e)?r={...e}:r={...e,id:o(e)},kp(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function _i({sourceX:e,sourceY:t,targetX:n,targetY:o}){let[r,s,i,l]=zi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,s,i,l]}var Hr={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},Cp=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Fr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function $p({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:o=U.Top,center:r,offset:s,stepPosition:i}){let l=Hr[t],h=Hr[o],u={x:e.x+l.x*s,y:e.y+l.y*s},c={x:n.x+h.x*s,y:n.y+h.y*s},p=Cp({source:u,sourcePosition:t,target:c}),d=p.x!==0?"x":"y",m=p[d],f=[],w,y,x={x:0,y:0},E={x:0,y:0},[,,v,b]=zi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*h[d]===-1){d==="x"?(w=r.x??u.x+(c.x-u.x)*i,y=r.y??(u.y+c.y)/2):(w=r.x??(u.x+c.x)/2,y=r.y??u.y+(c.y-u.y)*i);let M=[{x:w,y:u.y},{x:w,y:c.y}],C=[{x:u.x,y},{x:c.x,y}];l[d]===m?f=d==="x"?M:C:f=d==="x"?C:M}else{let M=[{x:u.x,y:c.y}],C=[{x:c.x,y:u.y}];if(d==="x"?f=l.x===m?C:M:f=l.y===m?M:C,t===o){let H=Math.abs(e[d]-n[d]);if(H<=s){let g=Math.min(s-1,s-H);l[d]===m?x[d]=(u[d]>e[d]?-1:1)*g:E[d]=(c[d]>n[d]?-1:1)*g}}if(t!==o){let H=d==="x"?"y":"x",g=l[d]===h[H],N=u[H]>c[H],k=u[H]<c[H];(l[d]===1&&(!g&&N||g&&k)||l[d]!==1&&(!g&&k||g&&N))&&(f=d==="x"?M:C)}let _={x:u.x+x.x,y:u.y+x.y},F={x:c.x+E.x,y:c.y+E.y},O=Math.max(Math.abs(_.x-f[0].x),Math.abs(F.x-f[0].x)),R=Math.max(Math.abs(_.y-f[0].y),Math.abs(F.y-f[0].y));O>=R?(w=(_.x+F.x)/2,y=f[0].y):(w=f[0].x,y=(_.y+F.y)/2)}let j={x:u.x+x.x,y:u.y+x.y},S={x:c.x+E.x,y:c.y+E.y};return[[e,...j.x!==f[0].x||j.y!==f[0].y?[j]:[],...f,...S.x!==f[f.length-1].x||S.y!==f[f.length-1].y?[S]:[],n],w,y,v,b]}function Ep(e,t,n,o){let r=Math.min(Fr(e,t)/2,Fr(t,n)/2,o),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){let u=e.x<n.x?-1:1,c=e.y<n.y?1:-1;return`L ${s+r*u},${i}Q ${s},${i} ${s},${i+r*c}`}let l=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${s},${i+r*h}Q ${s},${i} ${s+r*l},${i}`}function nn({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top,borderRadius:i=5,centerX:l,centerY:h,offset:u=20,stepPosition:c=.5}){let[p,d,m,f,w]=$p({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:l,y:h},offset:u,stepPosition:c}),y=`M${p[0].x} ${p[0].y}`;for(let x=1;x<p.length-1;x++)y+=Ep(p[x-1],p[x],p[x+1],i);return y+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[y,d,m,f,w]}function Wr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Mp(e){let{sourceNode:t,targetNode:n}=e;if(!Wr(t)||!Wr(n))return null;let o=t.internals.handleBounds||Zr(t.handles),r=n.internals.handleBounds||Zr(n.handles),s=Yr(o?.source??[],e.sourceHandle),i=Yr(e.connectionMode===zt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!s||!i)return e.onError?.("008",_e.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let l=s?.position||U.Bottom,h=i?.position||U.Top,u=mt(t,s,l),c=mt(n,i,h);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y,sourcePosition:l,targetPosition:h}}function Zr(e){if(!e)return null;let t=[],n=[];for(let o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function mt(e,t,n=U.Left,o=!1){let r=(t?.x??0)+e.internals.positionAbsolute.x,s=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Te(e);if(o)return{x:r+i/2,y:s+l/2};switch(t?.position??n){case U.Top:return{x:r+i/2,y:s};case U.Right:return{x:r+i,y:s+l/2};case U.Bottom:return{x:r+i/2,y:s+l};case U.Left:return{x:r,y:s+l/2}}}function Yr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Uo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(n=>`${n}=${e[n]}`).join("&")}`:""}function zp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){let s=new Set;return e.reduce((i,l)=>([l.markerStart||o,l.markerEnd||r].forEach(h=>{if(h&&typeof h=="object"){let u=Uo(h,t);s.has(u)||(i.push({id:u,color:h.color||n,...h}),s.add(u))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}var Pi=1e3,_p=10,fa={nodeOrigin:[0,0],nodeExtent:Jt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Pp={...fa,checkEquality:!0};function ga(e,t){let n={...e};for(let o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Ap(e,t,n){let o=ga(fa,n);for(let r of e.values())if(r.parentId)va(r,e,t,o);else{let s=ln(r,o.nodeOrigin),i=pt(r.extent)?r.extent:o.nodeExtent,l=ht(s,i,Te(r));r.internals.positionAbsolute=l}}function Ip(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],o=[];for(let r of e.handles){let s={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(s):r.type==="target"&&o.push(s)}return{source:n,target:o}}function xa(e){return e==="manual"}function Go(e,t,n,o={}){let r=ga(Pp,o),s={i:0},i=new Map(t),l=r?.elevateNodesOnSelect&&!xa(r.zIndexMode)?Pi:0,h=e.length>0,u=!1;t.clear(),n.clear();for(let c of e){let p=i.get(c.id);if(r.checkEquality&&c===p?.internals.userNode)t.set(c.id,p);else{let d=ln(c,r.nodeOrigin),m=pt(c.extent)?c.extent:r.nodeExtent,f=ht(d,m,Te(c));p={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:f,handleBounds:Ip(c,p),z:Ai(c,l,r.zIndexMode),userNode:c}},t.set(c.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(h=!1),c.parentId&&va(p,t,n,o,s),u||=c.selected??!1}return{nodesInitialized:h,hasSelectedNodes:u}}function Dp(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function va(e,t,n,o,r){let{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:l,zIndexMode:h}=ga(fa,o),u=e.parentId,c=t.get(u);if(!c){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Dp(e,n),r&&!c.parentId&&c.internals.rootParentIndex===void 0&&h==="auto"&&(c.internals.rootParentIndex=++r.i,c.internals.z=c.internals.z+r.i*_p),r&&c.internals.rootParentIndex!==void 0&&(r.i=c.internals.rootParentIndex);let p=s&&!xa(h)?Pi:0,{x:d,y:m,z:f}=Rp(e,c,i,l,p,h),{positionAbsolute:w}=e.internals,y=d!==w.x||m!==w.y;(y||f!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:d,y:m}:w,z:f}})}function Ai(e,t,n){let o=Re(e.zIndex)?e.zIndex:0;return xa(n)?o:o+(e.selected?t:0)}function Rp(e,t,n,o,r,s){let{x:i,y:l}=t.internals.positionAbsolute,h=Te(e),u=ln(e,n),c=pt(e.extent)?ht(u,e.extent,h):u,p=ht({x:i+c.x,y:l+c.y},o,h);e.extent==="parent"&&(p=vi(p,h,t));let d=Ai(e,r,s),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=d?m+1:d}}function ya(e,t,n,o=[0,0]){let r=[],s=new Map;for(let i of e){let l=t.get(i.parentId);if(!l)continue;let h=s.get(i.parentId)?.expandedRect??en(l),u=yi(h,i.rect);s.set(i.parentId,{expandedRect:u,parent:l})}return s.size>0&&s.forEach(({expandedRect:i,parent:l},h)=>{let u=l.internals.positionAbsolute,c=Te(l),p=l.origin??o,d=i.x<u.x?Math.round(Math.abs(u.x-i.x)):0,m=i.y<u.y?Math.round(Math.abs(u.y-i.y)):0,f=Math.max(c.width,Math.round(i.width)),w=Math.max(c.height,Math.round(i.height)),y=(f-c.width)*p[0],x=(w-c.height)*p[1];(d>0||m>0||y||x)&&(r.push({id:h,type:"position",position:{x:l.position.x-d+y,y:l.position.y-m+x}}),n.get(h)?.forEach(E=>{e.some(v=>v.id===E.id)||r.push({id:E.id,type:"position",position:{x:E.position.x+d,y:E.position.y+m}})})),(c.width<i.width||c.height<i.height||d||m)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:f+(d?p[0]*d-y:0),height:w+(m?p[1]*m-x:0)}})}),r}function Op(e,t,n,o,r,s,i){let l=o?.querySelector(".xyflow__viewport"),h=!1;if(!l)return{changes:[],updatedInternals:h};let u=[],c=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(c.transform),d=[];for(let m of e.values()){let f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),h=!0;continue}let w=ma(m.nodeElement),y=f.measured.width!==w.width||f.measured.height!==w.height;if(w.width&&w.height&&(y||!f.internals.handleBounds||m.force)){let x=m.nodeElement.getBoundingClientRect(),E=pt(f.extent)?f.extent:s,{positionAbsolute:v}=f.internals;if(f.parentId&&f.extent==="parent"){let j=t.get(f.parentId);j&&(v=vi(v,w,j))}else E&&(v=ht(v,E,w));let b={...f,measured:w,internals:{...f.internals,positionAbsolute:v,handleBounds:{source:Br("source",m.nodeElement,x,p,f.id),target:Br("target",m.nodeElement,x,p,f.id)}}};t.set(f.id,b),f.parentId&&va(b,t,n,{nodeOrigin:r,zIndexMode:i}),h=!0,y&&(u.push({id:f.id,type:"dimensions",dimensions:w}),f.expandParent&&f.parentId&&d.push({id:f.id,parentId:f.parentId,rect:en(b,r)}))}}if(d.length>0){let m=ya(d,t,n,r);u.push(...m)}return{changes:u,updatedInternals:h}}async function Lp({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:s}){if(!t||!e.x&&!e.y)return!1;let i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],o);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Xr(e,t,n,o,r,s){let i=r,l=o.get(i)||new Map;o.set(i,l.set(n,t)),i=`${r}-${e}`;let h=o.get(i)||new Map;if(o.set(i,h.set(n,t)),s){i=`${r}-${e}-${s}`;let u=o.get(i)||new Map;o.set(i,u.set(n,t))}}function Ii(e,t,n){e.clear(),t.clear();for(let o of n){let{source:r,target:s,sourceHandle:i=null,targetHandle:l=null}=o,h={edgeId:o.id,source:r,target:s,sourceHandle:i,targetHandle:l},u=`${r}-${i}--${s}-${l}`,c=`${s}-${l}--${r}-${i}`;Xr("source",h,c,e,r,i),Xr("target",h,u,e,s,l),t.set(o.id,o)}}function Di(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Di(n,t):!1}function qr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Tp(e,t,n,o){let r=new Map;for(let[s,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!Di(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){let l=e.get(s);l&&r.set(s,{id:s,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return r}function Ro({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){let r=[];for(let[i,l]of t){let h=n.get(i)?.internals.userNode;h&&r.push({...h,position:l.position,dragging:o})}if(!e)return[r[0],r];let s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:o}:r[0],r]}function Bp({dragItems:e,snapGrid:t,x:n,y:o}){let r=e.values().next().value;if(!r)return null;let s={x:n-r.distance.x,y:o-r.distance.y},i=cn(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Vp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let s={x:null,y:null},i=0,l=new Map,h=!1,u={x:0,y:0},c=null,p=!1,d=null,m=!1,f=!1,w=null;function y({noDragClassName:E,handleSelector:v,domNode:b,isSelectable:j,nodeId:S,nodeClickDistance:M=0}){d=Ce(b);function C({x:R,y:H}){let{nodeLookup:g,nodeExtent:N,snapGrid:k,snapToGrid:z,nodeOrigin:A,onNodeDrag:$,onSelectionDrag:B,onError:V,updateNodePositions:W}=t();s={x:R,y:H};let J=!1,X=l.size>1,Z=X&&N?Ko(dn(l)):null,ee=X&&z?Bp({dragItems:l,snapGrid:k,x:R,y:H}):null;for(let[Q,T]of l){if(!g.has(Q))continue;let K={x:R-T.distance.x,y:H-T.distance.y};z&&(K=ee?{x:Math.round(K.x+ee.x),y:Math.round(K.y+ee.y)}:cn(K,k));let oe=null;if(X&&N&&!T.extent&&Z){let{positionAbsolute:se}=T.internals,re=se.x-Z.x+N[0][0],le=se.x+T.measured.width-Z.x2+N[1][0],ce=se.y-Z.y+N[0][1],ge=se.y+T.measured.height-Z.y2+N[1][1];oe=[[re,ce],[le,ge]]}let{position:ie,positionAbsolute:q}=xi({nodeId:Q,nextPosition:K,nodeLookup:g,nodeExtent:oe||N,nodeOrigin:A,onError:V});J=J||T.position.x!==ie.x||T.position.y!==ie.y,T.position=ie,T.internals.positionAbsolute=q}if(f=f||J,!!J&&(W(l,!0),w&&(o||$||!S&&B))){let[Q,T]=Ro({nodeId:S,dragItems:l,nodeLookup:g});o?.(w,l,Q,T),$?.(w,Q,T),S||B?.(w,T)}}async function _(){if(!c)return;let{transform:R,panBy:H,autoPanSpeed:g,autoPanOnNodeDrag:N}=t();if(!N){h=!1,cancelAnimationFrame(i);return}let[k,z]=ha(u,c,g);(k!==0||z!==0)&&(s.x=(s.x??0)-k/R[2],s.y=(s.y??0)-z/R[2],await H({x:k,y:z})&&C(s)),i=requestAnimationFrame(_)}function F(R){let{nodeLookup:H,multiSelectionActive:g,nodesDraggable:N,transform:k,snapGrid:z,snapToGrid:A,selectNodesOnDrag:$,onNodeDragStart:B,onSelectionDragStart:V,unselectNodesAndEdges:W}=t();p=!0,(!$||!j)&&!g&&S&&(H.get(S)?.selected||W()),j&&$&&S&&e?.(S);let J=Xt(R.sourceEvent,{transform:k,snapGrid:z,snapToGrid:A,containerBounds:c});if(s=J,l=Tp(H,N,J,S),l.size>0&&(n||B||!S&&V)){let[X,Z]=Ro({nodeId:S,dragItems:l,nodeLookup:H});n?.(R.sourceEvent,l,X,Z),B?.(R.sourceEvent,X,Z),S||V?.(R.sourceEvent,Z)}}let O=Ks().clickDistance(M).on("start",R=>{let{domNode:H,nodeDragThreshold:g,transform:N,snapGrid:k,snapToGrid:z}=t();c=H?.getBoundingClientRect()||null,m=!1,f=!1,w=R.sourceEvent,g===0&&F(R),s=Xt(R.sourceEvent,{transform:N,snapGrid:k,snapToGrid:z,containerBounds:c}),u=Oe(R.sourceEvent,c)}).on("drag",R=>{let{autoPanOnNodeDrag:H,transform:g,snapGrid:N,snapToGrid:k,nodeDragThreshold:z,nodeLookup:A}=t(),$=Xt(R.sourceEvent,{transform:g,snapGrid:N,snapToGrid:k,containerBounds:c});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||S&&!A.has(S))&&(m=!0),!m){if(!h&&H&&p&&(h=!0,_()),!p){let B=Oe(R.sourceEvent,c),V=B.x-u.x,W=B.y-u.y;Math.sqrt(V*V+W*W)>z&&F(R)}(s.x!==$.xSnapped||s.y!==$.ySnapped)&&l&&p&&(u=Oe(R.sourceEvent,c),C($))}}).on("end",R=>{if(!p||m){m&&l.size>0&&t().updateNodePositions(l,!1);return}if(h=!1,p=!1,cancelAnimationFrame(i),l.size>0){let{nodeLookup:H,updateNodePositions:g,onNodeDragStop:N,onSelectionDragStop:k}=t();if(f&&(g(l,!1),f=!1),r||N||!S&&k){let[z,A]=Ro({nodeId:S,dragItems:l,nodeLookup:H,dragging:!1});r?.(R.sourceEvent,l,z,A),N?.(R.sourceEvent,z,A),S||k?.(R.sourceEvent,A)}}}).filter(R=>{let H=R.target;return!R.button&&(!E||!qr(H,`.${E}`,b))&&(!v||qr(H,v,b))});d.call(O)}function x(){d?.on(".drag",null)}return{update:y,destroy:x}}function Hp(e,t,n){let o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let s of t.values())Kn(r,en(s))>0&&o.push(s);return o}var Fp=250;function Wp(e,t,n,o){let r=[],s=1/0,i=Hp(e,n,t+Fp);for(let l of i){let h=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(let u of h){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;let{x:c,y:p}=mt(l,u,u.position,!0),d=Math.sqrt(Math.pow(c-e.x,2)+Math.pow(p-e.y,2));d>t||(d<s?(r=[{...u,x:c,y:p}],s=d):d===s&&r.push({...u,x:c,y:p}))}}if(!r.length)return null;if(r.length>1){let l=o.type==="source"?"target":"source";return r.find(h=>h.type===l)??r[0]}return r[0]}function Ri(e,t,n,o,r,s=!1){let i=o.get(e);if(!i)return null;let l=r==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],h=(n?l?.find(u=>u.id===n):l?.[0])??null;return h&&s?{...h,...mt(i,h,h.position,!0)}:h}function Oi(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Zp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Li=()=>!0;function Yp(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:s,isTarget:i,domNode:l,nodeLookup:h,lib:u,autoPanOnConnect:c,flowId:p,panBy:d,cancelConnection:m,onConnectStart:f,onConnect:w,onConnectEnd:y,isValidConnection:x=Li,onReconnectEnd:E,updateConnection:v,getTransform:b,getFromHandle:j,autoPanSpeed:S,dragThreshold:M=1,handleDomNode:C}){let _=Si(e.target),F=0,O,{x:R,y:H}=Oe(e),g=Oi(s,C),N=l?.getBoundingClientRect(),k=!1;if(!N||!g)return;let z=Ri(r,g,o,h,t);if(!z)return;let A=Oe(e,N),$=!1,B=null,V=!1,W=null;function J(){if(!c||!N)return;let[oe,ie]=ha(A,N,S);d({x:oe,y:ie}),F=requestAnimationFrame(J)}let X={...z,nodeId:r,type:g,position:z.position},Z=h.get(r),ee={inProgress:!0,isValid:null,from:mt(Z,X,U.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:Z,to:A,toHandle:null,toPosition:Rr[X.position],toNode:null,pointer:A};function Q(){k=!0,v(ee),f?.(e,{nodeId:r,handleId:o,handleType:g})}M===0&&Q();function T(oe){if(!k){let{x:ce,y:ge}=Oe(oe),je=ce-R,Ee=ge-H;if(!(je*je+Ee*Ee>M*M))return;Q()}if(!j()||!X){K(oe);return}let ie=b();A=Oe(oe,N),O=Wp(un(A,ie,!1,[1,1]),n,h,X),$||(J(),$=!0);let q=Ti(oe,{handle:O,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:i?"target":"source",isValidConnection:x,doc:_,lib:u,flowId:p,nodeLookup:h});W=q.handleDomNode,B=q.connection,V=Zp(!!O,q.isValid);let se=h.get(r),re=se?mt(se,X,U.Left,!0):ee.from,le={...ee,from:re,isValid:V,to:q.toHandle&&V?Pt({x:q.toHandle.x,y:q.toHandle.y},ie):A,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:Rr[X.position],toNode:q.toHandle?h.get(q.toHandle.nodeId):null,pointer:A};v(le),ee=le}function K(oe){if(!("touches"in oe&&oe.touches.length>0)){if(k){(O||W)&&B&&V&&w?.(B);let{inProgress:ie,...q}=ee,se={...q,toPosition:ee.toHandle?ee.toPosition:null};y?.(oe,se),s&&E?.(oe,se)}m(),cancelAnimationFrame(F),$=!1,V=!1,B=null,W=null,_.removeEventListener("mousemove",T),_.removeEventListener("mouseup",K),_.removeEventListener("touchmove",T),_.removeEventListener("touchend",K)}}_.addEventListener("mousemove",T),_.addEventListener("mouseup",K),_.addEventListener("touchmove",T),_.addEventListener("touchend",K)}function Ti(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:s,doc:i,lib:l,flowId:h,isValidConnection:u=Li,nodeLookup:c}){let p=s==="target",d=t?i.querySelector(`.${l}-flow__handle[data-id="${h}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:m,y:f}=Oe(e),w=i.elementFromPoint(m,f),y=w?.classList.contains(`${l}-flow__handle`)?w:d,x={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let E=Oi(void 0,y),v=y.getAttribute("data-nodeid"),b=y.getAttribute("data-handleid"),j=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!v||!E)return x;let M={source:p?v:o,sourceHandle:p?b:r,target:p?o:v,targetHandle:p?r:b};x.connection=M;let C=j&&S&&(n===zt.Strict?p&&E==="source"||!p&&E==="target":v!==o||b!==r);x.isValid=C&&u(M),x.toHandle=Ri(v,E,b,c,n,!0)}return x}var Jo={onPointerDown:Yp,isValid:Ti};function Xp({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){let r=Ce(e);function s({translateExtent:l,width:h,height:u,zoomStep:c=1,pannable:p=!0,zoomable:d=!0,inversePan:m=!1}){let f=v=>{if(v.sourceEvent.type!=="wheel"||!t)return;let b=n(),j=v.sourceEvent.ctrlKey&&tn()?10:1,S=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*c,M=b[2]*Math.pow(2,S*j);t.scaleTo(M)},w=[0,0],y=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(w=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},x=v=>{let b=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;let j=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],S=[j[0]-w[0],j[1]-w[1]];w=j;let M=o()*Math.max(b[2],Math.log(b[2]))*(m?-1:1),C={x:b[0]-S[0]*M,y:b[1]-S[1]*M},_=[[0,0],[h,u]];t.setViewportConstrained({x:C.x,y:C.y,zoom:b[2]},_,l)},E=hi().on("start",y).on("zoom",p?x:null).on("zoom.wheel",d?f:null);r.call(E,{})}function i(){r.on("zoom",null)}return{update:s,destroy:i,pointer:Ie}}var ao=e=>({x:e.x,y:e.y,zoom:e.k}),Oo=({x:e,y:t,zoom:n})=>to.translate(e,t).scale(n),ot=(e,t)=>e.target.closest(`.${t}`),Bi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Lo=(e,t=0,n=qp,o=()=>{})=>{let r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Vi=e=>{let t=e.ctrlKey&&tn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Kp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:h,onPanZoomEnd:u}){return c=>{if(ot(c,t))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();let p=n.property("__zoom").k||1;if(c.ctrlKey&&i){let y=Ie(c),x=Vi(c),E=p*Math.pow(2,x);o.scaleTo(n,E,y,c);return}let d=c.deltaMode===1?20:1,m=r===dt.Vertical?0:c.deltaX*d,f=r===dt.Horizontal?0:c.deltaY*d;!tn()&&c.shiftKey&&r!==dt.Vertical&&(m=c.deltaY*d,f=0),o.translateBy(n,-(m/p)*s,-(f/p)*s,{internal:!0});let w=ao(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?h?.(c,w):(e.isPanScrolling=!0,l?.(c,w)),e.panScrollTimeout=setTimeout(()=>{u?.(c,w),e.isPanScrolling=!1},150)}}function Up({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){let s=o.type==="wheel",i=!t&&s&&!o.ctrlKey,l=ot(o,e);if(o.ctrlKey&&s&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,r)}}function Gp({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;let r=ao(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Jp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return s=>{e.usedRightMouseButton=!!(n&&Bi(t,e.mouseButton??0)),s.sourceEvent?.sync||o([s.transform.x,s.transform.y,s.transform.k]),r&&!s.sourceEvent?.internal&&r?.(s.sourceEvent,ao(s.transform))}}function Qp({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:s}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&Bi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){let l=ao(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(i.sourceEvent,l)},n?150:0)}}}function em({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:h,noPanClassName:u,lib:c,connectionInProgress:p}){return d=>{let m=t||n,f=o&&d.ctrlKey,w=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(ot(d,`${c}-flow__node`)||ot(d,`${c}-flow__edge`)||ot(d,`${c}-flow__selection`)||ot(d,`${c}-flow__nodesselection`)))return!0;if(!r&&!m&&!s&&!i&&!o||l||p&&!w||ot(d,h)&&w||ot(d,u)&&(!w||s&&w&&!t)||!o&&d.ctrlKey&&w)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!m&&!s&&!f&&w||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;let y=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||w||e)&&y}}function tm({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:h}){let u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=e.getBoundingClientRect(),p=[[0,0],[c.width,c.height]];(typeof ResizeObserver<"u"?new ResizeObserver(R=>{let H=R[0];H&&(p=[[0,0],[H.contentRect.width,H.contentRect.height]])}):null)?.observe(e);let d=hi().extent(()=>p).scaleExtent([t,n]).translateExtent(o),m=Ce(e).call(d);v({x:r.x,y:r.y,zoom:_t(r.zoom,t,n)},[[0,0],[c.width,c.height]],o);let f=m.on("wheel.zoom"),w=m.on("dblclick.zoom");d.wheelDelta(Vi);async function y(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).transform(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}function x({noWheelClassName:R,noPanClassName:H,onPaneContextMenu:g,userSelectionActive:N,panOnScroll:k,panOnDrag:z,panOnScrollMode:A,panOnScrollSpeed:$,preventScrolling:B,zoomOnPinch:V,zoomOnScroll:W,zoomOnDoubleClick:J,panActivationKeyPressed:X=!1,zoomActivationKeyPressed:Z,lib:ee,onTransformChange:Q,connectionInProgress:T,paneClickDistance:K,selectionOnDrag:oe}){N&&!u.isZoomingOrPanning&&E();let ie=k&&!Z&&!N;d.clickDistance(oe?1/0:!Re(K)||K<0?0:K);let q=ie?Kp({zoomPanValues:u,noWheelClassName:R,d3Selection:m,d3Zoom:d,panOnScrollMode:A,panOnScrollSpeed:$,zoomOnPinch:V,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:l}):Up({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:f});m.on("wheel.zoom",q,{passive:!1});let se=Gp({zoomPanValues:u,onDraggingChange:h,onPanZoomStart:i});d.on("start",se);let re=Jp({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!g,onPanZoom:s,onTransformChange:Q});d.on("zoom",re);let le=Qp({zoomPanValues:u,panOnDrag:z,panOnScroll:k,onPaneContextMenu:g,onPanZoomEnd:l,onDraggingChange:h});d.on("end",le);let ce=em({panActivationKeyPressed:X,zoomActivationKeyPressed:Z,panOnDrag:z,zoomOnScroll:W,panOnScroll:k,zoomOnDoubleClick:J,zoomOnPinch:V,userSelectionActive:N,noPanClassName:H,noWheelClassName:R,lib:ee,connectionInProgress:T});d.filter(ce),J?m.on("dblclick.zoom",w):m.on("dblclick.zoom",null)}function E(){d.on("zoom",null)}async function v(R,H,g){let N=Oo(R),k=d?.constrain()(N,H,g);return k&&await y(k),k}async function b(R,H){let g=Oo(R);return await y(g,H),g}function j(R){if(m){let H=Oo(R),g=m.property("__zoom");(g.k!==R.zoom||g.x!==R.x||g.y!==R.y)&&d?.transform(m,H,null,{sync:!0})}}function S(){let R=m?ui(m.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}async function M(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).scaleTo(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}async function C(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).scaleBy(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}function _(R){d?.scaleExtent(R)}function F(R){d?.translateExtent(R)}function O(R){let H=!Re(R)||R<0?0:R;d?.clickDistance(H)}return{update:x,destroy:E,setViewport:b,setViewportConstrained:v,getViewport:S,scaleTo:M,scaleBy:C,setScaleExtent:_,setTranslateExtent:F,syncViewport:j,setClickDistance:O}}var ft;(function(e){e.Line="line",e.Handle="handle"})(ft||(ft={}));var nm=["top-left","top-right","bottom-left","bottom-right"],om=["top","right","bottom","left"];function am({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:s}){let i=e-t,l=n-o,h=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&r&&(h[0]=h[0]*-1),l&&s&&(h[1]=h[1]*-1),h}function Kr(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function tt(e,t){return Math.max(0,t-e)}function nt(e,t){return Math.max(0,e-t)}function Pn(e,t,n){return Math.max(0,t-e,e-n)}function Ur(e,t){return e?!t:t}function rm(e,t,n,o,r,s,i,l){let{affectsX:h,affectsY:u}=t,{isHorizontal:c,isVertical:p}=t,d=c&&p,{xSnapped:m,ySnapped:f}=n,{minWidth:w,maxWidth:y,minHeight:x,maxHeight:E}=o,{x:v,y:b,width:j,height:S,aspectRatio:M}=e,C=Math.floor(c?m-e.pointerX:0),_=Math.floor(p?f-e.pointerY:0),F=j+(h?-C:C),O=S+(u?-_:_),R=-s[0]*j,H=-s[1]*S,g=Pn(F,w,y),N=Pn(O,x,E);if(i){let A=0,$=0;h&&C<0?A=tt(v+C+R,i[0][0]):!h&&C>0&&(A=nt(v+F+R,i[1][0])),u&&_<0?$=tt(b+_+H,i[0][1]):!u&&_>0&&($=nt(b+O+H,i[1][1])),g=Math.max(g,A),N=Math.max(N,$)}if(l){let A=0,$=0;h&&C>0?A=nt(v+C,l[0][0]):!h&&C<0&&(A=tt(v+F,l[1][0])),u&&_>0?$=nt(b+_,l[0][1]):!u&&_<0&&($=tt(b+O,l[1][1])),g=Math.max(g,A),N=Math.max(N,$)}if(r){if(c){let A=Pn(F/M,x,E)*M;if(g=Math.max(g,A),i){let $=0;!h&&!u||h&&!u&&d?$=nt(b+H+F/M,i[1][1])*M:$=tt(b+H+(h?C:-C)/M,i[0][1])*M,g=Math.max(g,$)}if(l){let $=0;!h&&!u||h&&!u&&d?$=tt(b+F/M,l[1][1])*M:$=nt(b+(h?C:-C)/M,l[0][1])*M,g=Math.max(g,$)}}if(p){let A=Pn(O*M,w,y)/M;if(N=Math.max(N,A),i){let $=0;!h&&!u||u&&!h&&d?$=nt(v+O*M+R,i[1][0])/M:$=tt(v+(u?_:-_)*M+R,i[0][0])/M,N=Math.max(N,$)}if(l){let $=0;!h&&!u||u&&!h&&d?$=tt(v+O*M,l[1][0])/M:$=nt(v+(u?_:-_)*M,l[0][0])/M,N=Math.max(N,$)}}}_=_+(_<0?N:-N),C=C+(C<0?g:-g),r&&(d?F>O*M?_=(Ur(h,u)?-C:C)/M:C=(Ur(h,u)?-_:_)*M:c?(_=C/M,u=h):(C=_*M,h=u));let k=h?v+C:v,z=u?b+_:b;return{width:j+(h?-C:C),height:S+(u?-_:_),x:s[0]*C*(h?-1:1)+k,y:s[1]*_*(u?-1:1)+z}}var Hi={width:0,height:0,x:0,y:0},sm={...Hi,pointerX:0,pointerY:0,aspectRatio:1};function im(e,t,n){let o=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,l=n[0]*s,h=n[1]*i;return[[o-l,r-h],[o+s-l,r+i-h]]}function lm({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){let s=Ce(e),i={controlDirection:Kr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:c,keepAspectRatio:p,resizeDirection:d,onResizeStart:m,onResize:f,onResizeEnd:w,shouldResize:y}){let x={...Hi},E={...sm};i={boundaries:c,resizeDirection:d,keepAspectRatio:p,controlDirection:Kr(u)};let v,b=null,j=[],S,M,C,_=Ks().on("start",F=>{let{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,paneDomNode:k}=n();if(v=O.get(t),!v)return;b=k?.getBoundingClientRect()??null;let{xSnapped:z,ySnapped:A}=Xt(F.sourceEvent,{transform:R,snapGrid:H,snapToGrid:g,containerBounds:b});x={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},E={...x,pointerX:z,pointerY:A,aspectRatio:x.width/x.height},S=void 0,M=pt(v.extent)?v.extent:void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(S=O.get(v.parentId)),S&&v.extent==="parent"&&(M=[[0,0],[S.measured.width,S.measured.height]]),j=[],C=void 0;for(let[$,B]of O)if(B.parentId===t&&(j.push({id:$,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){let V=im(B,v,B.origin??N);C?C=[[Math.min(V[0][0],C[0][0]),Math.min(V[0][1],C[0][1])],[Math.max(V[1][0],C[1][0]),Math.max(V[1][1],C[1][1])]]:C=V}m?.(F,{...x})}).on("drag",F=>{let{transform:O,snapGrid:R,snapToGrid:H,nodeOrigin:g}=n(),N=Xt(F.sourceEvent,{transform:O,snapGrid:R,snapToGrid:H,containerBounds:b}),k=[];if(!v)return;let{x:z,y:A,width:$,height:B}=x,V={},W=v.origin??g,{width:J,height:X,x:Z,y:ee}=rm(E,i.controlDirection,N,i.boundaries,i.keepAspectRatio,W,M,C),Q=J!==$,T=X!==B,K=Z!==z&&Q,oe=ee!==A&&T;if(!K&&!oe&&!Q&&!T)return;let ie={prevValues:{...x},startX:E.x,startY:E.y,childNodes:j.map(re=>({...re,position:{...re.position}}))};if((K||oe||W[0]===1||W[1]===1)&&(V.x=K?Z:x.x,V.y=oe?ee:x.y,x.x=V.x,x.y=V.y,j.length>0)){let re=Z-z,le=ee-A;for(let ce of j)ce.position={x:ce.position.x-re+W[0]*(J-$),y:ce.position.y-le+W[1]*(X-B)},k.push(ce)}if((Q||T)&&(V.width=Q&&(!i.resizeDirection||i.resizeDirection==="horizontal")?J:x.width,V.height=T&&(!i.resizeDirection||i.resizeDirection==="vertical")?X:x.height,x.width=V.width,x.height=V.height),S&&v.expandParent){let re=W[0]*(V.width??0);V.x&&V.x<re&&(x.x=re,E.x=E.x-(V.x-re));let le=W[1]*(V.height??0);V.y&&V.y<le&&(x.y=le,E.y=E.y-(V.y-le))}let q=am({width:x.width,prevWidth:$,height:x.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),se={...x,direction:q};if(y?.(F,se)===!1){x=ie.prevValues,E.x=ie.startX,E.y=ie.startY,j.forEach((re,le)=>{re.position=ie.childNodes[le].position});return}f?.(F,se),o(V,k)}).on("end",F=>{w?.(F,{...x}),r?.({...x})});s.call(_)}function h(){s.on(".drag",null)}return{update:l,destroy:h}}var dm=et(Nt(),1),cm=et($d(),1),Gr=e=>{let t,n=new Set,o=(l,h)=>{let u=typeof l=="function"?l(t):l;if(!Object.is(u,t)){let c=t;t=h??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(p=>p(t,c))}},r=()=>t,s={setState:o,getState:r,getInitialState:()=>i,subscribe:l=>(n.add(l),()=>n.delete(l)),destroy:()=>{(import.meta.env?import.meta.env.MODE: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()}},i=t=e(o,r,s);return s},um=e=>e?Gr(e):Gr,{useDebugValue:hm}=dm.default,{useSyncExternalStoreWithSelector:pm}=cm.default,mm=e=>e;function Fi(e,t=mm,n){let o=pm(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return hm(o),o}var Jr=(e,t)=>{let n=um(e),o=(r,s=t)=>Fi(n,r,s);return Object.assign(o,n),o},fm=(e,t)=>e?Jr(e,t):Jr;function fe(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(let[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let o of e)if(!t.has(o))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var gm=et(vr()),ro=(0,L.createContext)(null),xm=ro.Provider,Wi=_e.error001("react");function de(e,t){let n=(0,L.useContext)(ro);if(n===null)throw new Error(Wi);return Fi(n,e,t)}function pe(){let e=(0,L.useContext)(ro);if(e===null)throw new Error(Wi);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Qr={display:"none"},vm={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Zi="react-flow__node-desc",Yi="react-flow__edge-desc",ym="react-flow__aria-live",bm=e=>e.ariaLiveMessage,wm=e=>e.ariaLabelConfig;function jm({rfId:e}){let t=de(bm);return(0,I.jsx)("div",{id:`${ym}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vm,children:t})}function Nm({rfId:e,disableKeyboardA11y:t}){let n=de(wm);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("div",{id:`${Zi}-${e}`,style:Qr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,I.jsx)("div",{id:`${Yi}-${e}`,style:Qr,children:n["edge.a11yDescription.default"]}),!t&&(0,I.jsx)(jm,{rfId:e})]})}var so=(0,L.forwardRef)(({position:e="top-left",children:t,className:n,style:o,...r},s)=>{let i=`${e}`.split("-");return(0,I.jsx)("div",{className:ve(["react-flow__panel",n,...i]),style:o,ref:s,...r,children:t})});so.displayName="Panel";var es="https://reactflow.dev?utm_source=attribution";function km({proOptions:e,position:t="bottom-right"}){return(0,L.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,I.jsx)(so,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${es}`,children:(0,I.jsx)("a",{href:es,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}var Sm=e=>{let t=[],n=[];for(let[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(let[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},An=e=>e.id;function Cm(e,t){return fe(e.selectedNodes.map(An),t.selectedNodes.map(An))&&fe(e.selectedEdges.map(An),t.selectedEdges.map(An))}function $m({onSelectionChange:e}){let t=pe(),{selectedNodes:n,selectedEdges:o}=de(Sm,Cm);return(0,L.useEffect)(()=>{let r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,o,e]),null}var Em=e=>!!e.onSelectionChangeHandlers;function Mm({onSelectionChange:e}){let t=de(Em);return e||t?(0,I.jsx)($m,{onSelectionChange:e}):null}var Xi=[0,0],zm={x:0,y:0,zoom:1},_m=["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"],ts=[..._m,"rfId"],Pm=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}),ns={translateExtent:Jt,nodeOrigin:Xi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Am(e){let{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:h}=de(Pm,fe),u=pe();(0,L.useEffect)(()=>(h(e.defaultNodes,e.defaultEdges),()=>{c.current=ns,l()}),[]);let c=(0,L.useRef)(ns);return(0,L.useEffect)(()=>{for(let p of ts){let d=e[p],m=c.current[p];d!==m&&(typeof e[p]>"u"||(p==="nodes"?t(d):p==="edges"?n(d):p==="minZoom"?o(d):p==="maxZoom"?r(d):p==="translateExtent"?s(d):p==="nodeExtent"?i(d):p==="ariaLabelConfig"?u.setState({ariaLabelConfig:yp(d)}):p==="fitView"?u.setState({fitViewQueued:d}):p==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[p]:d})))}c.current=e},ts.map(p=>e[p])),null}function os(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Im(e){let[t,n]=(0,L.useState)(e==="system"?null:e);return(0,L.useEffect)(()=>{if(e!=="system"){n(e);return}let o=os(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:os()?.matches?"dark":"light"}var as=typeof document<"u"?document:null;function on(e=null,t={target:as,actInsideInputWithModifier:!0}){let[n,o]=(0,L.useState)(!1),r=(0,L.useRef)(!1),s=(0,L.useRef)(new Set([])),[i,l]=(0,L.useMemo)(()=>{if(e!==null){let h=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace(/\+/g,`
|
|
2
|
+
import{d as jd,e as Nd}from"./chunk-shared.d1f25785c8c168cc75aa99c4be8ca56abfc5eafa3490f8817ff15e61cb901915.js";import{p10$A as Pa,p10$B as yo,p10$C as Aa,p10$D as Q0,p10$E as Ia,p10$F as Da,p10$G as Ra,p10$H as Oa,p10$I as rt,p10$J as bo,p10$a as La,p10$b as Ta,p10$c as Ba,p10$d as Va,p10$e as ex,p10$f as tx,p10$g as nx,p10$h as ox,p10$i as ax,p10$j as Ha,p10$k as Fa,p10$l as wo,p10$m as Wa,p10$n as Za,p10$o as Ya,p10$p as Xa,p10$q as jo,p10$r as No,p10$s as qa,p10$t as Ka,p10$u as ko,p10$v as Ua,p10$w as Ga,p10$x as Qe,p10$y as Ja,p10$z as Qa}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p11$a as So,p11$b as ix}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p1$$ as cx,p1$$a as ux,p1$$b as hx,p1$A as px,p1$Aa as er,p1$Ab as mx,p1$B as fx,p1$Ba as gx,p1$Bb as xx,p1$C as vx,p1$Ca as yx,p1$Cb as bx,p1$D as wx,p1$Da as jx,p1$Db as tr,p1$E as Nx,p1$Ea as kx,p1$Eb as Sx,p1$F as Cx,p1$Fa as $x,p1$Fb as Ex,p1$G as Mx,p1$Ga as zx,p1$Gb as _x,p1$H as Px,p1$Ha as Ax,p1$Hb as nr,p1$I as Ix,p1$Ia as Dx,p1$Ib as or,p1$J as Co,p1$Ja as Rx,p1$Jb as ar,p1$K as Ox,p1$Ka as Lx,p1$Kb as rr,p1$L as Tx,p1$La as Bx,p1$Lb as Vx,p1$M as Hx,p1$Ma as Fx,p1$Mb as Wx,p1$N as Zx,p1$Na as sr,p1$Nb as Yx,p1$O as Xx,p1$Oa as qx,p1$Ob as Kx,p1$P as Ux,p1$Pa as ir,p1$Pb as Gx,p1$Q as Jx,p1$Qa as Qx,p1$Qb as ev,p1$R as tv,p1$Ra as nv,p1$Rb as ov,p1$S as av,p1$Sa as rv,p1$Sb as sv,p1$T as iv,p1$Ta as lv,p1$Tb as dv,p1$U as cv,p1$Ua as uv,p1$Ub as hv,p1$V as pv,p1$Va as mv,p1$Vb as $o,p1$W as fv,p1$Wa as gv,p1$Wb as xv,p1$X as xn,p1$Xa as vv,p1$Xb as lr,p1$Y as yv,p1$Ya as bv,p1$Yb as wv,p1$Z as jv,p1$Za as Nv,p1$Zb as kv,p1$_ as Sv,p1$_a as Cv,p1$_b as $v,p1$a as xe,p1$aa as Ev,p1$ab as Mv,p1$ac as zv,p1$b as _v,p1$ba as dr,p1$bb as cr,p1$bc as Pv,p1$c as Av,p1$ca as vn,p1$cb as he,p1$cc as Iv,p1$d as Dv,p1$da as Rv,p1$db as ur,p1$dc as Ov,p1$e as te,p1$ea as Lv,p1$eb as Tt,p1$ec as Tv,p1$f as Eo,p1$fa as Bv,p1$fb as Mo,p1$fc as Vv,p1$g as Hv,p1$ga as Fv,p1$gb as Wv,p1$gc as Zv,p1$h as Yv,p1$ha as Xv,p1$hb as bt,p1$hc as qv,p1$i as Kv,p1$ia as Uv,p1$ib as Gv,p1$ic as Jv,p1$j as yn,p1$ja as Qv,p1$jb as bn,p1$jc as ey,p1$k as wn,p1$ka as ty,p1$kb as ny,p1$kc as oy,p1$l as ay,p1$la as ry,p1$lb as jn,p1$lc as sy,p1$m as Nn,p1$ma as Bt,p1$mb as iy,p1$mc as ly,p1$n as ne,p1$na as hr,p1$nb as dy,p1$nc as cy,p1$o as ye,p1$oa as wt,p1$ob as uy,p1$p as hy,p1$pa as py,p1$pb as kn,p1$q as my,p1$qa as fy,p1$qb as gy,p1$r as xy,p1$ra as vy,p1$rb as Sn,p1$s as yy,p1$sa as pr,p1$sb as by,p1$t as wy,p1$ta as jy,p1$tb as Ny,p1$u as ky,p1$ua as Sy,p1$ub as mr,p1$v as Cy,p1$va as $y,p1$vb as fr,p1$w as Ey,p1$wa as My,p1$wb as zo,p1$x as zy,p1$xa as _y,p1$xb as gr,p1$y as Py,p1$ya as Ay,p1$yb as Iy,p1$z as jt,p1$za as Dy,p1$zb as xr}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";import{p2$a as Vt,p2$b as et,p2$c as Nt,p2$d as vr,p2$e as _o}from"./chunk-core.5490609e81c3a5f78da3e06b9795d71c287016ebc7fd02794b1122b474ebb07f.js";var kd=Vt(e=>{"use strict";var t=Nt();function n(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var o=typeof Object.is=="function"?Object.is:n,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,l=t.useDebugValue;function h(d,m){var f=m(),w=r({inst:{value:f,getSnapshot:m}}),y=w[0].inst,x=w[1];return i(function(){y.value=f,y.getSnapshot=m,u(y)&&x({inst:y})},[d,f,m]),s(function(){return u(y)&&x({inst:y}),d(function(){u(y)&&x({inst:y})})},[d]),l(f),f}function u(d){var m=d.getSnapshot;d=d.value;try{var f=m();return!o(d,f)}catch{return!0}}function c(d,m){return m()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:h;e.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p}),Sd=Vt((e,t)=>{"use strict";t.exports=kd()}),Cd=Vt(e=>{"use strict";var t=Nt(),n=Sd();function o(c,p){return c===p&&(c!==0||1/c===1/p)||c!==c&&p!==p}var r=typeof Object.is=="function"?Object.is:o,s=n.useSyncExternalStore,i=t.useRef,l=t.useEffect,h=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(c,p,d,m,f){var w=i(null);if(w.current===null){var y={hasValue:!1,value:null};w.current=y}else y=w.current;w=h(function(){function E(M){if(!v){if(v=!0,b=M,M=m(M),f!==void 0&&y.hasValue){var C=y.value;if(f(C,M))return j=C}return j=M}if(C=j,r(b,M))return C;var _=m(M);return f!==void 0&&f(C,_)?(b=M,C):(b=M,j=_)}var v=!1,b,j,S=d===void 0?null:d;return[function(){return E(p())},S===null?void 0:function(){return E(S())}]},[p,d,m,f]);var x=s(c,w[0],w[1]);return l(function(){y.hasValue=!0,y.value=x},[x]),u(x),x}}),$d=Vt((e,t)=>{"use strict";t.exports=Cd()}),I=et(_o()),L=et(Nt());function ve(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ve(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Ed={value:()=>{}};function As(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Dn(n)}function Dn(e){this._=e}function Md(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Dn.prototype=As.prototype={constructor:Dn,on:function(e,t){var n=this._,o=Md(e+"",n),r,s=-1,i=o.length;if(arguments.length<2){for(;++s<i;)if((r=(e=o[s]).type)&&(r=zd(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(r=(e=o[s]).type)n[r]=yr(n[r],e.name,t);else if(t==null)for(r in n)n[r]=yr(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 Dn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,s;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,r=s.length;o<r;++o)s[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)}};function zd(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function yr(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Ed,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var na=As,Ho="http://www.w3.org/1999/xhtml",br={svg:"http://www.w3.org/2000/svg",xhtml:Ho,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),br.hasOwnProperty(t)?{space:br[t],local:e}:e}function _d(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ho&&t.documentElement.namespaceURI===Ho?t.createElement(e):t.createElementNS(n,e)}}function Pd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Is(e){var t=Jn(e);return(t.local?Pd:_d)(t)}function Ad(){}function oa(e){return e==null?Ad:function(){return this.querySelector(e)}}function Id(e){typeof e!="function"&&(e=oa(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=new Array(i),h,u,c=0;c<i;++c)(h=s[c])&&(u=e.call(h,h.__data__,c,s))&&("__data__"in h&&(u.__data__=h.__data__),l[c]=u);return new $e(o,this._parents)}function Dd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Rd(){return[]}function Ds(e){return e==null?Rd:function(){return this.querySelectorAll(e)}}function Od(e){return function(){return Dd(e.apply(this,arguments))}}function Ld(e){typeof e=="function"?e=Od(e):e=Ds(e);for(var t=this._groups,n=t.length,o=[],r=[],s=0;s<n;++s)for(var i=t[s],l=i.length,h,u=0;u<l;++u)(h=i[u])&&(o.push(e.call(h,h.__data__,u,i)),r.push(h));return new $e(o,r)}function Rs(e){return function(){return this.matches(e)}}function Os(e){return function(t){return t.matches(e)}}var Td=Array.prototype.find;function Bd(e){return function(){return Td.call(this.children,e)}}function Vd(){return this.firstElementChild}function Hd(e){return this.select(e==null?Vd:Bd(typeof e=="function"?e:Os(e)))}var Fd=Array.prototype.filter;function Wd(){return Array.from(this.children)}function Zd(e){return function(){return Fd.call(this.children,e)}}function Yd(e){return this.selectAll(e==null?Wd:Zd(typeof e=="function"?e:Os(e)))}function Xd(e){typeof e!="function"&&(e=Rs(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=[],h,u=0;u<i;++u)(h=s[u])&&e.call(h,h.__data__,u,s)&&l.push(h);return new $e(o,this._parents)}function Ls(e){return new Array(e.length)}function qd(){return new $e(this._enter||this._groups.map(Ls),this._parents)}function Bn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Bn.prototype={constructor:Bn,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 Kd(e){return function(){return e}}function Ud(e,t,n,o,r,s){for(var i=0,l,h=t.length,u=s.length;i<u;++i)(l=t[i])?(l.__data__=s[i],o[i]=l):n[i]=new Bn(e,s[i]);for(;i<h;++i)(l=t[i])&&(r[i]=l)}function Gd(e,t,n,o,r,s,i){var l,h,u=new Map,c=t.length,p=s.length,d=new Array(c),m;for(l=0;l<c;++l)(h=t[l])&&(d[l]=m=i.call(h,h.__data__,l,t)+"",u.has(m)?r[l]=h:u.set(m,h));for(l=0;l<p;++l)m=i.call(e,s[l],l,s)+"",(h=u.get(m))?(o[l]=h,h.__data__=s[l],u.delete(m)):n[l]=new Bn(e,s[l]);for(l=0;l<c;++l)(h=t[l])&&u.get(d[l])===h&&(r[l]=h)}function Jd(e){return e.__data__}function Qd(e,t){if(!arguments.length)return Array.from(this,Jd);var n=t?Gd:Ud,o=this._parents,r=this._groups;typeof e!="function"&&(e=Kd(e));for(var s=r.length,i=new Array(s),l=new Array(s),h=new Array(s),u=0;u<s;++u){var c=o[u],p=r[u],d=p.length,m=ec(e.call(c,c&&c.__data__,u,o)),f=m.length,w=l[u]=new Array(f),y=i[u]=new Array(f),x=h[u]=new Array(d);n(c,p,w,y,x,m,t);for(var E=0,v=0,b,j;E<f;++E)if(b=w[E]){for(E>=v&&(v=E+1);!(j=y[v])&&++v<f;);b._next=j||null}}return i=new $e(i,o),i._enter=l,i._exit=h,i}function ec(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function tc(){return new $e(this._exit||this._groups.map(Ls),this._parents)}function nc(e,t,n){var o=this.enter(),r=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?s.remove():n(s),o&&r?o.merge(r).order():r}function oc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,s=o.length,i=Math.min(r,s),l=new Array(r),h=0;h<i;++h)for(var u=n[h],c=o[h],p=u.length,d=l[h]=new Array(p),m,f=0;f<p;++f)(m=u[f]||c[f])&&(d[f]=m);for(;h<r;++h)l[h]=n[h];return new $e(l,this._parents)}function ac(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,s=o[r],i;--r>=0;)(i=o[r])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function rc(e){e||(e=sc);function t(p,d){return p&&d?e(p.__data__,d.__data__):!p-!d}for(var n=this._groups,o=n.length,r=new Array(o),s=0;s<o;++s){for(var i=n[s],l=i.length,h=r[s]=new Array(l),u,c=0;c<l;++c)(u=i[c])&&(h[c]=u);h.sort(t)}return new $e(r,this._parents).order()}function sc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ic(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function lc(){return Array.from(this)}function dc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length;r<s;++r){var i=o[r];if(i)return i}return null}function cc(){let e=0;for(let t of this)++e;return e}function uc(){return!this.node()}function hc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],s=0,i=r.length,l;s<i;++s)(l=r[s])&&e.call(l,l.__data__,s,r);return this}function pc(e){return function(){this.removeAttribute(e)}}function mc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fc(e,t){return function(){this.setAttribute(e,t)}}function gc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function xc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function vc(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 yc(e,t){var n=Jn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?mc:pc:typeof t=="function"?n.local?vc:xc:n.local?gc:fc)(n,t))}function Ts(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function bc(e){return function(){this.style.removeProperty(e)}}function wc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function jc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Nc(e,t,n){return arguments.length>1?this.each((t==null?bc:typeof t=="function"?jc:wc)(e,t,n??"")):Et(this.node(),e)}function Et(e,t){return e.style.getPropertyValue(t)||Ts(e).getComputedStyle(e,null).getPropertyValue(t)}function kc(e){return function(){delete this[e]}}function Sc(e,t){return function(){this[e]=t}}function Cc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function $c(e,t){return arguments.length>1?this.each((t==null?kc:typeof t=="function"?Cc:Sc)(e,t)):this.node()[e]}function Bs(e){return e.trim().split(/^|\s+/)}function aa(e){return e.classList||new Vs(e)}function Vs(e){this._node=e,this._names=Bs(e.getAttribute("class")||"")}Vs.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 Hs(e,t){for(var n=aa(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Fs(e,t){for(var n=aa(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Ec(e){return function(){Hs(this,e)}}function Mc(e){return function(){Fs(this,e)}}function zc(e,t){return function(){(t.apply(this,arguments)?Hs:Fs)(this,e)}}function _c(e,t){var n=Bs(e+"");if(arguments.length<2){for(var o=aa(this.node()),r=-1,s=n.length;++r<s;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?zc:t?Ec:Mc)(n,t))}function Pc(){this.textContent=""}function Ac(e){return function(){this.textContent=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Dc(e){return arguments.length?this.each(e==null?Pc:(typeof e=="function"?Ic:Ac)(e)):this.node().textContent}function Rc(){this.innerHTML=""}function Oc(e){return function(){this.innerHTML=e}}function Lc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Tc(e){return arguments.length?this.each(e==null?Rc:(typeof e=="function"?Lc:Oc)(e)):this.node().innerHTML}function Bc(){this.nextSibling&&this.parentNode.appendChild(this)}function Vc(){return this.each(Bc)}function Hc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Fc(){return this.each(Hc)}function Wc(e){var t=typeof e=="function"?e:Is(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Zc(){return null}function Yc(e,t){var n=typeof e=="function"?e:Is(e),o=t==null?Zc:typeof t=="function"?t:oa(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Xc(){var e=this.parentNode;e&&e.removeChild(this)}function qc(){return this.each(Xc)}function Kc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Uc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gc(e){return this.select(e?Uc:Kc)}function Jc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Qc(e){return function(t){e.call(this,t,this.__data__)}}function eu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function tu(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++o]=s;++o?t.length=o:delete this.__on}}}function nu(e,t,n){return function(){var o=this.__on,r,s=Qc(t);if(o){for(var i=0,l=o.length;i<l;++i)if((r=o[i]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},o?o.push(r):this.__on=[r]}}function ou(e,t,n){var o=eu(e+""),r,s=o.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var h=0,u=l.length,c;h<u;++h)for(r=0,c=l[h];r<s;++r)if((i=o[r]).type===c.type&&i.name===c.name)return c.value}return}for(l=t?nu:tu,r=0;r<s;++r)this.each(l(o[r],t,n));return this}function Ws(e,t,n){var o=Ts(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function au(e,t){return function(){return Ws(this,e,t)}}function ru(e,t){return function(){return Ws(this,e,t.apply(this,arguments))}}function su(e,t){return this.each((typeof t=="function"?ru:au)(e,t))}function*iu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length,i;r<s;++r)(i=o[r])&&(yield i)}var Zs=[null];function $e(e,t){this._groups=e,this._parents=t}function Ys(){return new $e([[document.documentElement]],Zs)}function lu(){return this}$e.prototype=Ys.prototype={constructor:$e,select:Id,selectAll:Ld,selectChild:Hd,selectChildren:Yd,filter:Xd,data:Qd,enter:qd,exit:tc,join:nc,merge:oc,selection:lu,order:ac,sort:rc,call:ic,nodes:lc,node:dc,size:cc,empty:uc,each:hc,attr:yc,style:Nc,property:$c,classed:_c,text:Dc,html:Tc,raise:Vc,lower:Fc,append:Wc,insert:Yc,remove:qc,clone:Gc,datum:Jc,on:ou,dispatch:su,[Symbol.iterator]:iu};var rn=Ys;function Ce(e){return typeof e=="string"?new $e([[document.querySelector(e)]],[document.documentElement]):new $e([[e]],Zs)}function du(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ie(e,t){if(e=du(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.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]}var cu={passive:!1},qt={capture:!0,passive:!1};function Po(e){e.stopImmediatePropagation()}function Ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Xs(e){var t=e.document.documentElement,n=Ce(e).on("dragstart.drag",Ct,qt);"onselectstart"in t?n.on("selectstart.drag",Ct,qt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function qs(e,t){var n=e.document.documentElement,o=Ce(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ct,qt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Cn=e=>()=>e;function Fo(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:s,x:i,y:l,dx:h,dy:u,dispatch:c}){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:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Fo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uu(e){return!e.ctrlKey&&!e.button}function hu(){return this.parentNode}function pu(e,t){return t??{x:e.x,y:e.y}}function mu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ks(){var e=uu,t=hu,n=pu,o=mu,r={},s=na("start","drag","end"),i=0,l,h,u,c,p=0;function d(b){b.on("mousedown.drag",m).filter(o).on("touchstart.drag",y).on("touchmove.drag",x,cu).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(b,j){if(!(c||!e.call(this,b,j))){var S=v(this,t.call(this,b,j),b,j,"mouse");S&&(Ce(b.view).on("mousemove.drag",f,qt).on("mouseup.drag",w,qt),Xs(b.view),Po(b),u=!1,l=b.clientX,h=b.clientY,S("start",b))}}function f(b){if(Ct(b),!u){var j=b.clientX-l,S=b.clientY-h;u=j*j+S*S>p}r.mouse("drag",b)}function w(b){Ce(b.view).on("mousemove.drag mouseup.drag",null),qs(b.view,u),Ct(b),r.mouse("end",b)}function y(b,j){if(e.call(this,b,j)){var S=b.changedTouches,M=t.call(this,b,j),C=S.length,_,F;for(_=0;_<C;++_)(F=v(this,M,b,j,S[_].identifier,S[_]))&&(Po(b),F("start",b,S[_]))}}function x(b){var j=b.changedTouches,S=j.length,M,C;for(M=0;M<S;++M)(C=r[j[M].identifier])&&(Ct(b),C("drag",b,j[M]))}function E(b){var j=b.changedTouches,S=j.length,M,C;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),M=0;M<S;++M)(C=r[j[M].identifier])&&(Po(b),C("end",b,j[M]))}function v(b,j,S,M,C,_){var F=s.copy(),O=Ie(_||S,j),R,H,g;if((g=n.call(b,new Fo("beforestart",{sourceEvent:S,target:d,identifier:C,active:i,x:O[0],y:O[1],dx:0,dy:0,dispatch:F}),M))!=null)return R=g.x-O[0]||0,H=g.y-O[1]||0,function N(k,z,A){var $=O,B;switch(k){case"start":r[C]=N,B=i++;break;case"end":delete r[C],--i;case"drag":O=Ie(A||z,j),B=i;break}F.call(k,b,new Fo(k,{sourceEvent:z,subject:g,target:d,identifier:C,active:B,x:O[0]+R,y:O[1]+H,dx:O[0]-$[0],dy:O[1]-$[1],dispatch:F}),M)}}return d.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Cn(!!b),d):e},d.container=function(b){return arguments.length?(t=typeof b=="function"?b:Cn(b),d):t},d.subject=function(b){return arguments.length?(n=typeof b=="function"?b:Cn(b),d):n},d.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:Cn(!!b),d):o},d.on=function(){var b=s.on.apply(s,arguments);return b===s?d:b},d.clickDistance=function(b){return arguments.length?(p=(b=+b)*b,d):Math.sqrt(p)},d}function ra(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Us(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function sn(){}var Kt=.7,Vn=1/Kt,$t="\\s*([+-]?\\d+)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",fu=/^#([0-9a-f]{3,8})$/,gu=new RegExp(`^rgb\\(${$t},${$t},${$t}\\)$`),xu=new RegExp(`^rgb\\(${Fe},${Fe},${Fe}\\)$`),vu=new RegExp(`^rgba\\(${$t},${$t},${$t},${Ut}\\)$`),yu=new RegExp(`^rgba\\(${Fe},${Fe},${Fe},${Ut}\\)$`),bu=new RegExp(`^hsl\\(${Ut},${Fe},${Fe}\\)$`),wu=new RegExp(`^hsla\\(${Ut},${Fe},${Fe},${Ut}\\)$`),wr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ra(sn,ct,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jr,formatHex:jr,formatHex8:ju,formatHsl:Nu,formatRgb:Nr,toString:Nr});function jr(){return this.rgb().formatHex()}function ju(){return this.rgb().formatHex8()}function Nu(){return Gs(this).formatHsl()}function Nr(){return this.rgb().formatRgb()}function ct(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=fu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?kr(t):n===3?new ke(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$n(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$n(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=gu.exec(e))?new ke(t[1],t[2],t[3],1):(t=xu.exec(e))?new ke(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vu.exec(e))?$n(t[1],t[2],t[3],t[4]):(t=yu.exec(e))?$n(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bu.exec(e))?$r(t[1],t[2]/100,t[3]/100,1):(t=wu.exec(e))?$r(t[1],t[2]/100,t[3]/100,t[4]):wr.hasOwnProperty(e)?kr(wr[e]):e==="transparent"?new ke(NaN,NaN,NaN,0):null}function kr(e){return new ke(e>>16&255,e>>8&255,e&255,1)}function $n(e,t,n,o){return o<=0&&(e=t=n=NaN),new ke(e,t,n,o)}function ku(e){return e instanceof sn||(e=ct(e)),e?(e=e.rgb(),new ke(e.r,e.g,e.b,e.opacity)):new ke}function Hn(e,t,n,o){return arguments.length===1?ku(e):new ke(e,t,n,o??1)}function ke(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}ra(ke,Hn,Us(sn,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new ke(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ke(lt(this.r),lt(this.g),lt(this.b),Fn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Sr,formatHex:Sr,formatHex8:Su,formatRgb:Cr,toString:Cr}));function Sr(){return`#${it(this.r)}${it(this.g)}${it(this.b)}`}function Su(){return`#${it(this.r)}${it(this.g)}${it(this.b)}${it((isNaN(this.opacity)?1:this.opacity)*255)}`}function Cr(){let e=Fn(this.opacity);return`${e===1?"rgb(":"rgba("}${lt(this.r)}, ${lt(this.g)}, ${lt(this.b)}${e===1?")":`, ${e})`}`}function Fn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function lt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function it(e){return e=lt(e),(e<16?"0":"")+e.toString(16)}function $r(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new De(e,t,n,o)}function Gs(e){if(e instanceof De)return new De(e.h,e.s,e.l,e.opacity);if(e instanceof sn||(e=ct(e)),!e)return new De;if(e instanceof De)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),s=Math.max(t,n,o),i=NaN,l=s-r,h=(s+r)/2;return l?(t===s?i=(n-o)/l+(n<o)*6:n===s?i=(o-t)/l+2:i=(t-n)/l+4,l/=h<.5?s+r:2-s-r,i*=60):l=h>0&&h<1?0:i,new De(i,l,h,e.opacity)}function Cu(e,t,n,o){return arguments.length===1?Gs(e):new De(e,t,n,o??1)}function De(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}ra(De,Cu,Us(sn,{brighter(e){return e=e==null?Vn:Math.pow(Vn,e),new De(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Kt:Math.pow(Kt,e),new De(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new ke(Ao(e>=240?e-240:e+120,r,o),Ao(e,r,o),Ao(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new De(Er(this.h),En(this.s),En(this.l),Fn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Fn(this.opacity);return`${e===1?"hsl(":"hsla("}${Er(this.h)}, ${En(this.s)*100}%, ${En(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Er(e){return e=(e||0)%360,e<0?e+360:e}function En(e){return Math.max(0,Math.min(1,e||0))}function Ao(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function Js(e,t,n,o,r){var s=e*e,i=s*e;return((1-3*e+3*s-i)*t+(4-6*s+3*i)*n+(1+3*e+3*s-3*i)*o+i*r)/6}function $u(e){var t=e.length-1;return function(n){var o=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),r=e[o],s=e[o+1],i=o>0?e[o-1]:2*r-s,l=o<t-1?e[o+2]:2*s-r;return Js((n-o/t)*t,i,r,s,l)}}function Eu(e){var t=e.length;return function(n){var o=Math.floor(((n%=1)<0?++n:n)*t),r=e[(o+t-1)%t],s=e[o%t],i=e[(o+1)%t],l=e[(o+2)%t];return Js((n-o/t)*t,r,s,i,l)}}var sa=e=>()=>e;function Mu(e,t){return function(n){return e+n*t}}function zu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function _u(e){return(e=+e)==1?Qs:function(t,n){return n-t?zu(t,n,e):sa(isNaN(t)?n:t)}}function Qs(e,t){var n=t-e;return n?Mu(e,n):sa(isNaN(e)?t:e)}var Wn=(function e(t){var n=_u(t);function o(r,s){var i=n((r=Hn(r)).r,(s=Hn(s)).r),l=n(r.g,s.g),h=n(r.b,s.b),u=Qs(r.opacity,s.opacity);return function(c){return r.r=i(c),r.g=l(c),r.b=h(c),r.opacity=u(c),r+""}}return o.gamma=e,o})(1);function ei(e){return function(t){var n=t.length,o=new Array(n),r=new Array(n),s=new Array(n),i,l;for(i=0;i<n;++i)l=Hn(t[i]),o[i]=l.r||0,r[i]=l.g||0,s[i]=l.b||0;return o=e(o),r=e(r),s=e(s),l.opacity=1,function(h){return l.r=o(h),l.g=r(h),l.b=s(h),l+""}}}var Fy=ei($u),Wy=ei(Eu);function Pu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(s){for(r=0;r<n;++r)o[r]=e[r]*(1-s)+t[r]*s;return o}}function Au(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Iu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),s=new Array(n),i;for(i=0;i<o;++i)r[i]=Yt(e[i],t[i]);for(;i<n;++i)s[i]=t[i];return function(l){for(i=0;i<o;++i)s[i]=r[i](l);return s}}function Du(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ru(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Yt(e[r],t[r]):o[r]=t[r];return function(s){for(r in n)o[r]=n[r](s);return o}}var Wo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Io=new RegExp(Wo.source,"g");function Ou(e){return function(){return e}}function Lu(e){return function(t){return e(t)+""}}function ti(e,t){var n=Wo.lastIndex=Io.lastIndex=0,o,r,s,i=-1,l=[],h=[];for(e=e+"",t=t+"";(o=Wo.exec(e))&&(r=Io.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),l[i]?l[i]+=s:l[++i]=s),(o=o[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,h.push({i,x:He(o,r)})),n=Io.lastIndex;return n<t.length&&(s=t.slice(n),l[i]?l[i]+=s:l[++i]=s),l.length<2?h[0]?Lu(h[0].x):Ou(t):(t=h.length,function(u){for(var c=0,p;c<t;++c)l[(p=h[c]).i]=p.x(u);return l.join("")})}function Yt(e,t){var n=typeof t,o;return t==null||n==="boolean"?sa(t):(n==="number"?He:n==="string"?(o=ct(t))?(t=o,Wn):ti:t instanceof ct?Wn:t instanceof Date?Du:Au(t)?Pu:Array.isArray(t)?Iu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ru:He)(e,t)}var Mr=180/Math.PI,Zo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ni(e,t,n,o,r,s){var i,l,h;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(h=e*n+t*o)&&(n-=e*h,o-=t*h),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,h/=l),e*o<t*n&&(e=-e,t=-t,h=-h,i=-i),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*Mr,skewX:Math.atan(h)*Mr,scaleX:i,scaleY:l}}var Mn;function Tu(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zo:ni(t.a,t.b,t.c,t.d,t.e,t.f)}function Bu(e){return e==null?Zo:(Mn||(Mn=document.createElementNS("http://www.w3.org/2000/svg","g")),Mn.setAttribute("transform",e),(e=Mn.transform.baseVal.consolidate())?(e=e.matrix,ni(e.a,e.b,e.c,e.d,e.e,e.f)):Zo)}function oi(e,t,n,o){function r(u){return u.length?u.pop()+" ":""}function s(u,c,p,d,m,f){if(u!==p||c!==d){var w=m.push("translate(",null,t,null,n);f.push({i:w-4,x:He(u,p)},{i:w-2,x:He(c,d)})}else(p||d)&&m.push("translate("+p+t+d+n)}function i(u,c,p,d){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),d.push({i:p.push(r(p)+"rotate(",null,o)-2,x:He(u,c)})):c&&p.push(r(p)+"rotate("+c+o)}function l(u,c,p,d){u!==c?d.push({i:p.push(r(p)+"skewX(",null,o)-2,x:He(u,c)}):c&&p.push(r(p)+"skewX("+c+o)}function h(u,c,p,d,m,f){if(u!==p||c!==d){var w=m.push(r(m)+"scale(",null,",",null,")");f.push({i:w-4,x:He(u,p)},{i:w-2,x:He(c,d)})}else(p!==1||d!==1)&&m.push(r(m)+"scale("+p+","+d+")")}return function(u,c){var p=[],d=[];return u=e(u),c=e(c),s(u.translateX,u.translateY,c.translateX,c.translateY,p,d),i(u.rotate,c.rotate,p,d),l(u.skewX,c.skewX,p,d),h(u.scaleX,u.scaleY,c.scaleX,c.scaleY,p,d),u=c=null,function(m){for(var f=-1,w=d.length,y;++f<w;)p[(y=d[f]).i]=y.x(m);return p.join("")}}}var Vu=oi(Tu,"px, ","px)","deg)"),Hu=oi(Bu,", ",")",")"),Fu=1e-12;function zr(e){return((e=Math.exp(e))+1/e)/2}function Wu(e){return((e=Math.exp(e))-1/e)/2}function Zu(e){return((e=Math.exp(2*e))-1)/(e+1)}var Rn=(function e(t,n,o){function r(s,i){var l=s[0],h=s[1],u=s[2],c=i[0],p=i[1],d=i[2],m=c-l,f=p-h,w=m*m+f*f,y,x;if(w<Fu)x=Math.log(d/u)/t,y=function(M){return[l+M*m,h+M*f,u*Math.exp(t*M*x)]};else{var E=Math.sqrt(w),v=(d*d-u*u+o*w)/(2*u*n*E),b=(d*d-u*u-o*w)/(2*d*n*E),j=Math.log(Math.sqrt(v*v+1)-v),S=Math.log(Math.sqrt(b*b+1)-b);x=(S-j)/t,y=function(M){var C=M*x,_=zr(j),F=u/(n*E)*(_*Zu(t*C+j)-Wu(j));return[l+F*m,h+F*f,u*_/zr(t*C+j)]}}return y.duration=x*1e3*t/Math.SQRT2,y}return r.rho=function(s){var i=Math.max(.001,+s),l=i*i,h=l*l;return e(i,l,h)},r})(Math.SQRT2,2,4),Mt=0,Wt=0,Ht=0,ai=1e3,Zn,Zt,Yn=0,ut=0,Qn=0,Gt=typeof performance=="object"&&performance.now?performance:Date,ri=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ia(){return ut||(ri(Yu),ut=Gt.now()+Qn)}function Yu(){ut=0}function Xn(){this._call=this._time=this._next=null}Xn.prototype=si.prototype={constructor:Xn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ia():+n)+(t==null?0:+t),!this._next&&Zt!==this&&(Zt?Zt._next=this:Zn=this,Zt=this),this._call=e,this._time=n,Yo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yo())}};function si(e,t,n){var o=new Xn;return o.restart(e,t,n),o}function Xu(){ia(),++Mt;for(var e=Zn,t;e;)(t=ut-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mt}function _r(){ut=(Yn=Gt.now())+Qn,Mt=Wt=0;try{Xu()}finally{Mt=0,Ku(),ut=0}}function qu(){var e=Gt.now(),t=e-Yn;t>ai&&(Qn-=t,Yn=e)}function Ku(){for(var e,t=Zn,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Zn=n);Zt=e,Yo(o)}function Yo(e){if(!Mt){Wt&&(Wt=clearTimeout(Wt));var t=e-ut;t>24?(e<1/0&&(Wt=setTimeout(_r,e-Gt.now()-Qn)),Ht&&(Ht=clearInterval(Ht))):(Ht||(Yn=Gt.now(),Ht=setInterval(qu,ai)),Mt=1,ri(_r))}}function Pr(e,t,n){var o=new Xn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Uu=na("start","end","cancel","interrupt"),Gu=[],ii=0,Ar=1,Xo=2,On=3,Ir=4,qo=5,Ln=6;function eo(e,t,n,o,r,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Ju(e,n,{name:t,index:o,group:r,on:Uu,tween:Gu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ii})}function la(e,t){var n=Le(e,t);if(n.state>ii)throw new Error("too late; already scheduled");return n}function We(e,t){var n=Le(e,t);if(n.state>On)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Ju(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=si(s,0,n.time);function s(u){n.state=Ar,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var c,p,d,m;if(n.state!==Ar)return h();for(c in o)if(m=o[c],m.name===n.name){if(m.state===On)return Pr(i);m.state===Ir?(m.state=Ln,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete o[c]):+c<t&&(m.state=Ln,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete o[c])}if(Pr(function(){n.state===On&&(n.state=Ir,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Xo,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xo){for(n.state=On,r=new Array(d=n.tween.length),c=0,p=-1;c<d;++c)(m=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(r[++p]=m);r.length=p+1}}function l(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(h),n.state=qo,1),p=-1,d=r.length;++p<d;)r[p].call(e,c);n.state===qo&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=Ln,n.timer.stop(),delete o[t];for(var u in o)return;delete e.__transition}}function Tn(e,t){var n=e.__transition,o,r,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((o=n[i]).name!==t){s=!1;continue}r=o.state>Xo&&o.state<qo,o.state=Ln,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[i]}s&&delete e.__transition}}function Qu(e){return this.each(function(){Tn(this,e)})}function eh(e,t){var n,o;return function(){var r=We(this,e),s=r.tween;if(s!==n){o=n=s;for(var i=0,l=o.length;i<l;++i)if(o[i].name===t){o=o.slice(),o.splice(i,1);break}}r.tween=o}}function th(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var s=We(this,e),i=s.tween;if(i!==o){r=(o=i).slice();for(var l={name:t,value:n},h=0,u=r.length;h<u;++h)if(r[h].name===t){r[h]=l;break}h===u&&r.push(l)}s.tween=r}}function nh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Le(this.node(),n).tween,r=0,s=o.length,i;r<s;++r)if((i=o[r]).name===e)return i.value;return null}return this.each((t==null?eh:th)(n,e,t))}function da(e,t,n){var o=e._id;return e.each(function(){var r=We(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Le(r,o).value[t]}}function li(e,t){var n;return(typeof t=="number"?He:t instanceof ct?Wn:(n=ct(t))?(t=n,Wn):ti)(e,t)}function oh(e){return function(){this.removeAttribute(e)}}function ah(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttribute(e);return i===r?null:i===o?s:s=t(o=i,n)}}function sh(e,t,n){var o,r=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===r?null:i===o?s:s=t(o=i,n)}}function ih(e,t,n){var o,r,s;return function(){var i,l=n(this),h;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),h=l+"",i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l)))}}function lh(e,t,n){var o,r,s;return function(){var i,l=n(this),h;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),h=l+"",i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l)))}}function dh(e,t){var n=Jn(e),o=n==="transform"?Hu:li;return this.attrTween(e,typeof t=="function"?(n.local?lh:ih)(n,o,da(this,"attr."+e,t)):t==null?(n.local?ah:oh)(n):(n.local?sh:rh)(n,o,t))}function ch(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function uh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hh(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&uh(e,s)),n}return r._value=t,r}function ph(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&ch(e,s)),n}return r._value=t,r}function mh(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 o=Jn(e);return this.tween(n,(o.local?hh:ph)(o,t))}function fh(e,t){return function(){la(this,e).delay=+t.apply(this,arguments)}}function gh(e,t){return t=+t,function(){la(this,e).delay=t}}function xh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fh:gh)(t,e)):Le(this.node(),t).delay}function vh(e,t){return function(){We(this,e).duration=+t.apply(this,arguments)}}function yh(e,t){return t=+t,function(){We(this,e).duration=t}}function bh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vh:yh)(t,e)):Le(this.node(),t).duration}function wh(e,t){if(typeof t!="function")throw new Error;return function(){We(this,e).ease=t}}function jh(e){var t=this._id;return arguments.length?this.each(wh(t,e)):Le(this.node(),t).ease}function Nh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;We(this,e).ease=n}}function kh(e){if(typeof e!="function")throw new Error;return this.each(Nh(this._id,e))}function Sh(e){typeof e!="function"&&(e=Rs(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],i=s.length,l=o[r]=[],h,u=0;u<i;++u)(h=s[u])&&e.call(h,h.__data__,u,s)&&l.push(h);return new Ge(o,this._parents,this._name,this._id)}function Ch(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,s=Math.min(o,r),i=new Array(o),l=0;l<s;++l)for(var h=t[l],u=n[l],c=h.length,p=i[l]=new Array(c),d,m=0;m<c;++m)(d=h[m]||u[m])&&(p[m]=d);for(;l<o;++l)i[l]=t[l];return new Ge(i,this._parents,this._name,this._id)}function $h(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 Eh(e,t,n){var o,r,s=$h(t)?la:We;return function(){var i=s(this,e),l=i.on;l!==o&&(r=(o=l).copy()).on(t,n),i.on=r}}function Mh(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(Eh(n,e,t))}function zh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function _h(){return this.on("end.remove",zh(this._id))}function Ph(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oa(e));for(var o=this._groups,r=o.length,s=new Array(r),i=0;i<r;++i)for(var l=o[i],h=l.length,u=s[i]=new Array(h),c,p,d=0;d<h;++d)(c=l[d])&&(p=e.call(c,c.__data__,d,l))&&("__data__"in c&&(p.__data__=c.__data__),u[d]=p,eo(u[d],t,n,d,u,Le(c,n)));return new Ge(s,this._parents,t,n)}function Ah(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ds(e));for(var o=this._groups,r=o.length,s=[],i=[],l=0;l<r;++l)for(var h=o[l],u=h.length,c,p=0;p<u;++p)if(c=h[p]){for(var d=e.call(c,c.__data__,p,h),m,f=Le(c,n),w=0,y=d.length;w<y;++w)(m=d[w])&&eo(m,t,n,w,d,f);s.push(d),i.push(c)}return new Ge(s,i,t,n)}var Ih=rn.prototype.constructor;function Dh(){return new Ih(this._groups,this._parents)}function Rh(e,t){var n,o,r;return function(){var s=Et(this,e),i=(this.style.removeProperty(e),Et(this,e));return s===i?null:s===n&&i===o?r:r=t(n=s,o=i)}}function di(e){return function(){this.style.removeProperty(e)}}function Oh(e,t,n){var o,r=n+"",s;return function(){var i=Et(this,e);return i===r?null:i===o?s:s=t(o=i,n)}}function Lh(e,t,n){var o,r,s;return function(){var i=Et(this,e),l=n(this),h=l+"";return l==null&&(h=l=(this.style.removeProperty(e),Et(this,e))),i===h?null:i===o&&h===r?s:(r=h,s=t(o=i,l))}}function Th(e,t){var n,o,r,s="style."+t,i="end."+s,l;return function(){var h=We(this,e),u=h.on,c=h.value[s]==null?l||(l=di(t)):void 0;(u!==n||r!==c)&&(o=(n=u).copy()).on(i,r=c),h.on=o}}function Bh(e,t,n){var o=(e+="")=="transform"?Vu:li;return t==null?this.styleTween(e,Rh(e,o)).on("end.style."+e,di(e)):typeof t=="function"?this.styleTween(e,Lh(e,o,da(this,"style."+e,t))).each(Th(this._id,e)):this.styleTween(e,Oh(e,o,t),n).on("end.style."+e,null)}function Vh(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Hh(e,t,n){var o,r;function s(){var i=t.apply(this,arguments);return i!==r&&(o=(r=i)&&Vh(e,i,n)),o}return s._value=t,s}function Fh(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Hh(e,t,n??""))}function Wh(e){return function(){this.textContent=e}}function Zh(e){return function(){var t=e(this);this.textContent=t??""}}function Yh(e){return this.tween("text",typeof e=="function"?Zh(da(this,"text",e)):Wh(e==null?"":e+""))}function Xh(e){return function(t){this.textContent=e.call(this,t)}}function qh(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Xh(r)),t}return o._value=e,o}function Kh(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,qh(e))}function Uh(){for(var e=this._name,t=this._id,n=ci(),o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],l=i.length,h,u=0;u<l;++u)if(h=i[u]){var c=Le(h,t);eo(h,e,n,u,i,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Ge(o,this._parents,e,n)}function Gh(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(s,i){var l={value:i},h={value:function(){--r===0&&s()}};n.each(function(){var u=We(this,o),c=u.on;c!==e&&(t=(e=c).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(h)),u.on=t}),r===0&&s()})}var Jh=0;function Ge(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Qh(e){return rn().transition(e)}function ci(){return++Jh}var Ze=rn.prototype;Ge.prototype=Qh.prototype={constructor:Ge,select:Ph,selectAll:Ah,selectChild:Ze.selectChild,selectChildren:Ze.selectChildren,filter:Sh,merge:Ch,selection:Dh,transition:Uh,call:Ze.call,nodes:Ze.nodes,node:Ze.node,size:Ze.size,empty:Ze.empty,each:Ze.each,on:Mh,attr:dh,attrTween:mh,style:Bh,styleTween:Fh,text:Yh,textTween:Kh,remove:_h,tween:nh,delay:xh,duration:bh,ease:jh,easeVarying:kh,end:Gh,[Symbol.iterator]:Ze[Symbol.iterator]};function ep(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var tp={time:null,delay:0,duration:250,ease:ep};function np(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 op(e){var t,n;e instanceof Ge?(t=e._id,e=e._name):(t=ci(),(n=tp).time=ia(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,s=0;s<r;++s)for(var i=o[s],l=i.length,h,u=0;u<l;++u)(h=i[u])&&eo(h,e,t,u,i,n||np(h,t));return new Ge(o,this._parents,e,t)}rn.prototype.interrupt=Qu;rn.prototype.transition=op;var zn=e=>()=>e;function ap(e,{sourceEvent:t,target:n,transform:o,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:o,enumerable:!0,configurable:!0},_:{value:r}})}function qe(e,t,n){this.k=e,this.x=t,this.y=n}qe.prototype={constructor:qe,scale:function(e){return e===1?this:new qe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new qe(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 to=new qe(1,0,0);ui.prototype=qe.prototype;function ui(e){for(;!e.__zoom;)if(!(e=e.parentNode))return to;return e.__zoom}function Do(e){e.stopImmediatePropagation()}function Ft(e){e.preventDefault(),e.stopImmediatePropagation()}function rp(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function sp(){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 Dr(){return this.__zoom||to}function ip(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function lp(){return navigator.maxTouchPoints||"ontouchstart"in this}function dp(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function hi(){var e=rp,t=sp,n=dp,o=ip,r=lp,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,h=Rn,u=na("start","zoom","end"),c,p,d,m=500,f=150,w=0,y=10;function x(g){g.property("__zoom",Dr).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",F).filter(r).on("touchstart.zoom",O).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(g,N,k,z){var A=g.selection?g.selection():g;A.property("__zoom",Dr),g!==A?j(g,N,k,z):A.interrupt().each(function(){S(this,arguments).event(z).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},x.scaleBy=function(g,N,k,z){x.scaleTo(g,function(){var A=this.__zoom.k,$=typeof N=="function"?N.apply(this,arguments):N;return A*$},k,z)},x.scaleTo=function(g,N,k,z){x.transform(g,function(){var A=t.apply(this,arguments),$=this.__zoom,B=k==null?b(A):typeof k=="function"?k.apply(this,arguments):k,V=$.invert(B),W=typeof N=="function"?N.apply(this,arguments):N;return n(v(E($,W),B,V),A,i)},k,z)},x.translateBy=function(g,N,k,z){x.transform(g,function(){return n(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),i)},null,z)},x.translateTo=function(g,N,k,z,A){x.transform(g,function(){var $=t.apply(this,arguments),B=this.__zoom,V=z==null?b($):typeof z=="function"?z.apply(this,arguments):z;return n(to.translate(V[0],V[1]).scale(B.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof k=="function"?-k.apply(this,arguments):-k),$,i)},z,A)};function E(g,N){return N=Math.max(s[0],Math.min(s[1],N)),N===g.k?g:new qe(N,g.x,g.y)}function v(g,N,k){var z=N[0]-k[0]*g.k,A=N[1]-k[1]*g.k;return z===g.x&&A===g.y?g:new qe(g.k,z,A)}function b(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function j(g,N,k,z){g.on("start.zoom",function(){S(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(z).end()}).tween("zoom",function(){var A=this,$=arguments,B=S(A,$).event(z),V=t.apply(A,$),W=k==null?b(V):typeof k=="function"?k.apply(A,$):k,J=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),X=A.__zoom,Z=typeof N=="function"?N.apply(A,$):N,ee=h(X.invert(W).concat(J/X.k),Z.invert(W).concat(J/Z.k));return function(Q){if(Q===1)Q=Z;else{var T=ee(Q),K=J/T[2];Q=new qe(K,W[0]-T[0]*K,W[1]-T[1]*K)}B.zoom(null,Q)}})}function S(g,N,k){return!k&&g.__zooming||new M(g,N)}function M(g,N){this.that=g,this.args=N,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,N),this.taps=0}M.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,N){return this.mouse&&g!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var N=Ce(this.that).datum();u.call(g,this.that,new ap(g,{sourceEvent:this.sourceEvent,target:x,type:g,transform:this.that.__zoom,dispatch:u}),N)}};function C(g,...N){if(!e.apply(this,arguments))return;var k=S(this,N).event(g),z=this.__zoom,A=Math.max(s[0],Math.min(s[1],z.k*Math.pow(2,o.apply(this,arguments)))),$=Ie(g);if(k.wheel)(k.mouse[0][0]!==$[0]||k.mouse[0][1]!==$[1])&&(k.mouse[1]=z.invert(k.mouse[0]=$)),clearTimeout(k.wheel);else{if(z.k===A)return;k.mouse=[$,z.invert($)],Tn(this),k.start()}Ft(g),k.wheel=setTimeout(B,f),k.zoom("mouse",n(v(E(z,A),k.mouse[0],k.mouse[1]),k.extent,i));function B(){k.wheel=null,k.end()}}function _(g,...N){if(d||!e.apply(this,arguments))return;var k=g.currentTarget,z=S(this,N,!0).event(g),A=Ce(g.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",J,!0),$=Ie(g,k),B=g.clientX,V=g.clientY;Xs(g.view),Do(g),z.mouse=[$,this.__zoom.invert($)],Tn(this),z.start();function W(X){if(Ft(X),!z.moved){var Z=X.clientX-B,ee=X.clientY-V;z.moved=Z*Z+ee*ee>w}z.event(X).zoom("mouse",n(v(z.that.__zoom,z.mouse[0]=Ie(X,k),z.mouse[1]),z.extent,i))}function J(X){A.on("mousemove.zoom mouseup.zoom",null),qs(X.view,z.moved),Ft(X),z.event(X).end()}}function F(g,...N){if(e.apply(this,arguments)){var k=this.__zoom,z=Ie(g.changedTouches?g.changedTouches[0]:g,this),A=k.invert(z),$=k.k*(g.shiftKey?.5:2),B=n(v(E(k,$),z,A),t.apply(this,N),i);Ft(g),l>0?Ce(this).transition().duration(l).call(j,B,z,g):Ce(this).call(x.transform,B,z,g)}}function O(g,...N){if(e.apply(this,arguments)){var k=g.touches,z=k.length,A=S(this,N,g.changedTouches.length===z).event(g),$,B,V,W;for(Do(g),B=0;B<z;++B)V=k[B],W=Ie(V,this),W=[W,this.__zoom.invert(W),V.identifier],A.touch0?!A.touch1&&A.touch0[2]!==W[2]&&(A.touch1=W,A.taps=0):(A.touch0=W,$=!0,A.taps=1+!!c);c&&(c=clearTimeout(c)),$&&(A.taps<2&&(p=W[0],c=setTimeout(function(){c=null},m)),Tn(this),A.start())}}function R(g,...N){if(this.__zooming){var k=S(this,N).event(g),z=g.changedTouches,A=z.length,$,B,V,W;for(Ft(g),$=0;$<A;++$)B=z[$],V=Ie(B,this),k.touch0&&k.touch0[2]===B.identifier?k.touch0[0]=V:k.touch1&&k.touch1[2]===B.identifier&&(k.touch1[0]=V);if(B=k.that.__zoom,k.touch1){var J=k.touch0[0],X=k.touch0[1],Z=k.touch1[0],ee=k.touch1[1],Q=(Q=Z[0]-J[0])*Q+(Q=Z[1]-J[1])*Q,T=(T=ee[0]-X[0])*T+(T=ee[1]-X[1])*T;B=E(B,Math.sqrt(Q/T)),V=[(J[0]+Z[0])/2,(J[1]+Z[1])/2],W=[(X[0]+ee[0])/2,(X[1]+ee[1])/2]}else if(k.touch0)V=k.touch0[0],W=k.touch0[1];else return;k.zoom("touch",n(v(B,V,W),k.extent,i))}}function H(g,...N){if(this.__zooming){var k=S(this,N).event(g),z=g.changedTouches,A=z.length,$,B;for(Do(g),d&&clearTimeout(d),d=setTimeout(function(){d=null},m),$=0;$<A;++$)B=z[$],k.touch0&&k.touch0[2]===B.identifier?delete k.touch0:k.touch1&&k.touch1[2]===B.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&&(B=Ie(B,this),Math.hypot(p[0]-B[0],p[1]-B[1])<y)){var V=Ce(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(g){return arguments.length?(o=typeof g=="function"?g:zn(+g),x):o},x.filter=function(g){return arguments.length?(e=typeof g=="function"?g:zn(!!g),x):e},x.touchable=function(g){return arguments.length?(r=typeof g=="function"?g:zn(!!g),x):r},x.extent=function(g){return arguments.length?(t=typeof g=="function"?g:zn([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),x):t},x.scaleExtent=function(g){return arguments.length?(s[0]=+g[0],s[1]=+g[1],x):[s[0],s[1]]},x.translateExtent=function(g){return arguments.length?(i[0][0]=+g[0][0],i[1][0]=+g[1][0],i[0][1]=+g[0][1],i[1][1]=+g[1][1],x):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},x.constrain=function(g){return arguments.length?(n=g,x):n},x.duration=function(g){return arguments.length?(l=+g,x):l},x.interpolate=function(g){return arguments.length?(h=g,x):h},x.on=function(){var g=u.on.apply(u,arguments);return g===u?x:g},x.clickDistance=function(g){return arguments.length?(w=(g=+g)*g,x):Math.sqrt(w)},x.tapDistance=function(g){return arguments.length?(y=+g,x):y},x}var _e={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", 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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],pi=["Enter"," ","Escape"],mi={"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"},zt;(function(e){e.Strict="strict",e.Loose="loose"})(zt||(zt={}));var dt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(dt||(dt={}));var Qt;(function(e){e.Partial="partial",e.Full="full"})(Qt||(Qt={}));var fi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},at;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(at||(at={}));var Xe;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Xe||(Xe={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));var Rr={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top},gi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,cp=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ca=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ln=(e,t=[0,0])=>{let{width:n,height:o}=Te(e),r=e.origin??t,s=n*r[0],i=o*r[1];return{x:e.position.x-s,y:e.position.y-i}},up=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,o=e.reduce((r,s)=>{let i=typeof s=="string",l=!t.nodeLookup&&!i?s:void 0;return t.nodeLookup&&(l=i?t.nodeLookup.get(s):ca(s)?s:t.nodeLookup.get(s.id)),l?(n=!0,no(r,qn(l,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?oo(o):{x:0,y:0,width:0,height:0}},dn=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=no(n,qn(r)),o=!0)}),o?oo(n):{x:0,y:0,width:0,height:0}},ua=(e,t,[n,o,r]=[0,0,1],s=!1,i=!1)=>{let l=(t.x-n)/r,h=(t.y-o)/r,u=t.width/r,c=t.height/r,p=[];for(let d of e.values()){let{measured:m,selectable:f=!0,hidden:w=!1}=d;if(i&&!f||w)continue;let y=m.width??d.width??d.initialWidth??0,x=m.height??d.height??d.initialHeight??0,{x:E,y:v}=d.internals.positionAbsolute,b=bi(l,h,u,c,E,v,y,x),j=y*x,S=s&&b>0;(!d.internals.handleBounds||S||b>=j||d.dragging)&&p.push(d)}return p},hp=(e,t)=>{let n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function pp(e,t){let n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let s;if(t?.includeHiddenNodes){let{width:i,height:l}=Te(r);s=i>0&&l>0}else s=!!(r.measured.width&&r.measured.height&&!r.hidden);s&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function mp({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:s},i){if(e.size===0)return!0;let l=pp(e,i),h=dn(l),u=pa(h,t,n,i?.minZoom??r,i?.maxZoom??s,i?.padding??.1);return await o.setViewport(u,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),!0}function xi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:s}){let i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:h,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},c=i.origin??o,p=i.extent||r;if(i.extent==="parent"&&!i.expandParent)if(!l)s?.("005",_e.error005());else{let{width:m,height:f}=Te(l);m&&f&&(p=[[h,u],[h+m,u+f]])}else l&&pt(i.extent)&&(p=[[i.extent[0][0]+h,i.extent[0][1]+u],[i.extent[1][0]+h,i.extent[1][1]+u]]);let d=pt(p)?ht(t,p,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&s?.("015",_e.error015()),{position:{x:d.x-h+(i.measured.width??0)*c[0],y:d.y-u+(i.measured.height??0)*c[1]},positionAbsolute:d}}async function fp({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){let s=new Set(e.map(p=>p.id)),i=[];for(let p of n){if(p.deletable===!1)continue;let d=s.has(p.id),m=!d&&p.parentId&&i.find(f=>f.id===p.parentId);(d||m)&&i.push(p)}let l=new Set(t.map(p=>p.id)),h=o.filter(p=>p.deletable!==!1),u=hp(i,h);for(let p of h)l.has(p.id)&&!u.find(d=>d.id===p.id)&&u.push(p);if(!r)return{edges:u,nodes:i};let c=await r({nodes:i,edges:u});return typeof c=="boolean"?c?{edges:u,nodes:i}:{edges:[],nodes:[]}:c}var _t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ht=(e={x:0,y:0},t,n)=>({x:_t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:_t(e.y,t[0][1],t[1][1]-(n?.height??0))});function vi(e,t,n){let{width:o,height:r}=Te(n),{x:s,y:i}=n.internals.positionAbsolute;return ht(e,[[s,i],[s+o,i+r]],t)}var Or=(e,t,n)=>e<t?_t(Math.abs(e-t),1,t)/t:e>n?-_t(Math.abs(e-n),1,t)/t:0,ha=(e,t,n=15,o=40)=>{let r=Or(e.x,o,t.width-o)*n,s=Or(e.y,o,t.height-o)*n;return[r,s]},no=(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)}),Ko=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),oo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),en=(e,t=[0,0])=>{let{x:n,y:o}=ca(e)?e.internals.positionAbsolute:ln(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},qn=(e,t=[0,0])=>{let{x:n,y:o}=ca(e)?e.internals.positionAbsolute:ln(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},yi=(e,t)=>oo(no(Ko(e),Ko(t))),bi=(e,t,n,o,r,s,i,l)=>{let h=Math.max(0,Math.min(e+n,r+i)-Math.max(e,r)),u=Math.max(0,Math.min(t+o,s+l)-Math.max(t,s));return Math.ceil(h*u)},Kn=(e,t)=>bi(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Lr=e=>Re(e.width)&&Re(e.height)&&Re(e.x)&&Re(e.y),Re=e=>!isNaN(e)&&isFinite(e),wi=(e,t)=>(n,o)=>{},cn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),un=({x:e,y:t},[n,o,r],s=!1,i=[1,1])=>{let l={x:(e-n)/r,y:(t-o)/r};return s?cn(l,i):l},Pt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function kt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gp(e,t,n){if(typeof e=="string"||typeof e=="number"){let o=kt(e,n),r=kt(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){let o=kt(e.top??e.y??0,n),r=kt(e.bottom??e.y??0,n),s=kt(e.left??e.x??0,t),i=kt(e.right??e.x??0,t);return{top:o,right:i,bottom:r,left:s,x:s+i,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xp(e,t,n,o,r,s){let{x:i,y:l}=Pt(e,[t,n,o]),{x:h,y:u}=Pt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),c=r-h,p=s-u;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(c),bottom:Math.floor(p)}}var pa=(e,t,n,o,r,s)=>{let i=gp(s,t,n),l=(t-i.x)/e.width,h=(n-i.y)/e.height,u=Math.min(l,h),c=_t(u,o,r),p=e.x+e.width/2,d=e.y+e.height/2,m=t/2-p*c,f=n/2-d*c,w=xp(e,m,f,c,t,n),y={left:Math.min(w.left-i.left,0),top:Math.min(w.top-i.top,0),right:Math.min(w.right-i.right,0),bottom:Math.min(w.bottom-i.bottom,0)};return{x:m-y.left+y.right,y:f-y.top+y.bottom,zoom:c}},tn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function pt(e){return e!=null&&e!=="parent"}function Te(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ji(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Ni(e,t={width:0,height:0},n,o,r){let s={...e},i=o.get(n);if(i){let l=i.origin||r;s.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return s}function Tr(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function vp(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve:e,reject:t}}function yp(e){return{...mi,...e||{}}}function ki(e){return e===null?null:e?"valid":"invalid"}function Xt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){let{x:s,y:i}=Oe(e),l=un({x:s-(r?.left??0),y:i-(r?.top??0)},o),{x:h,y:u}=n?cn(l,t):l;return{xSnapped:h,ySnapped:u,...l}}var ma=e=>({width:e.offsetWidth,height:e.offsetHeight}),Si=e=>e?.getRootNode?.()||window?.document,bp=["INPUT","SELECT","TEXTAREA"];function Ci(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:bp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}var $i=e=>"clientX"in e,Oe=(e,t)=>{let n=$i(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Br=(e,t,n,o,r)=>{let s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{let l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:r,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...ma(i)}})};function Ei({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:i,targetControlY:l}){let h=e*.125+r*.375+i*.375+n*.125,u=t*.125+s*.375+l*.375+o*.125,c=Math.abs(h-e),p=Math.abs(u-t);return[h,u,c,p]}function _n(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Vr({pos:e,x1:t,y1:n,x2:o,y2:r,c:s}){switch(e){case U.Left:return[t-_n(t-o,s),n];case U.Right:return[t+_n(o-t,s),n];case U.Top:return[t,n-_n(n-r,s)];case U.Bottom:return[t,n+_n(r-n,s)]}}function Mi({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top,curvature:i=.25}){let[l,h]=Vr({pos:n,x1:e,y1:t,x2:o,y2:r,c:i}),[u,c]=Vr({pos:s,x1:o,y1:r,x2:e,y2:t,c:i}),[p,d,m,f]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:l,sourceControlY:h,targetControlX:u,targetControlY:c});return[`M${e},${t} C${l},${h} ${u},${c} ${o},${r}`,p,d,m,f]}function zi({sourceX:e,sourceY:t,targetX:n,targetY:o}){let r=Math.abs(n-e)/2,s=n<e?n+r:n-r,i=Math.abs(o-t)/2,l=o<t?o+i:o-i;return[s,l,r,i]}function wp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return o;let i=r&&n?o+1e3:o,l=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return i+l}function jp({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){let s=no(qn(e),qn(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);let i={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return Kn(i,oo(s))>0}var Np=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,kp=(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)),Sp=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",_e.error006()),t;let o=n.getEdgeId||Np,r;return gi(e)?r={...e}:r={...e,id:o(e)},kp(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function _i({sourceX:e,sourceY:t,targetX:n,targetY:o}){let[r,s,i,l]=zi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,s,i,l]}var Hr={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},Cp=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},Fr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function $p({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:o=U.Top,center:r,offset:s,stepPosition:i}){let l=Hr[t],h=Hr[o],u={x:e.x+l.x*s,y:e.y+l.y*s},c={x:n.x+h.x*s,y:n.y+h.y*s},p=Cp({source:u,sourcePosition:t,target:c}),d=p.x!==0?"x":"y",m=p[d],f=[],w,y,x={x:0,y:0},E={x:0,y:0},[,,v,b]=zi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*h[d]===-1){d==="x"?(w=r.x??u.x+(c.x-u.x)*i,y=r.y??(u.y+c.y)/2):(w=r.x??(u.x+c.x)/2,y=r.y??u.y+(c.y-u.y)*i);let M=[{x:w,y:u.y},{x:w,y:c.y}],C=[{x:u.x,y},{x:c.x,y}];l[d]===m?f=d==="x"?M:C:f=d==="x"?C:M}else{let M=[{x:u.x,y:c.y}],C=[{x:c.x,y:u.y}];if(d==="x"?f=l.x===m?C:M:f=l.y===m?M:C,t===o){let H=Math.abs(e[d]-n[d]);if(H<=s){let g=Math.min(s-1,s-H);l[d]===m?x[d]=(u[d]>e[d]?-1:1)*g:E[d]=(c[d]>n[d]?-1:1)*g}}if(t!==o){let H=d==="x"?"y":"x",g=l[d]===h[H],N=u[H]>c[H],k=u[H]<c[H];(l[d]===1&&(!g&&N||g&&k)||l[d]!==1&&(!g&&k||g&&N))&&(f=d==="x"?M:C)}let _={x:u.x+x.x,y:u.y+x.y},F={x:c.x+E.x,y:c.y+E.y},O=Math.max(Math.abs(_.x-f[0].x),Math.abs(F.x-f[0].x)),R=Math.max(Math.abs(_.y-f[0].y),Math.abs(F.y-f[0].y));O>=R?(w=(_.x+F.x)/2,y=f[0].y):(w=f[0].x,y=(_.y+F.y)/2)}let j={x:u.x+x.x,y:u.y+x.y},S={x:c.x+E.x,y:c.y+E.y};return[[e,...j.x!==f[0].x||j.y!==f[0].y?[j]:[],...f,...S.x!==f[f.length-1].x||S.y!==f[f.length-1].y?[S]:[],n],w,y,v,b]}function Ep(e,t,n,o){let r=Math.min(Fr(e,t)/2,Fr(t,n)/2,o),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){let u=e.x<n.x?-1:1,c=e.y<n.y?1:-1;return`L ${s+r*u},${i}Q ${s},${i} ${s},${i+r*c}`}let l=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${s},${i+r*h}Q ${s},${i} ${s+r*l},${i}`}function nn({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top,borderRadius:i=5,centerX:l,centerY:h,offset:u=20,stepPosition:c=.5}){let[p,d,m,f,w]=$p({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:l,y:h},offset:u,stepPosition:c}),y=`M${p[0].x} ${p[0].y}`;for(let x=1;x<p.length-1;x++)y+=Ep(p[x-1],p[x],p[x+1],i);return y+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[y,d,m,f,w]}function Wr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Mp(e){let{sourceNode:t,targetNode:n}=e;if(!Wr(t)||!Wr(n))return null;let o=t.internals.handleBounds||Zr(t.handles),r=n.internals.handleBounds||Zr(n.handles),s=Yr(o?.source??[],e.sourceHandle),i=Yr(e.connectionMode===zt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!s||!i)return e.onError?.("008",_e.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let l=s?.position||U.Bottom,h=i?.position||U.Top,u=mt(t,s,l),c=mt(n,i,h);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y,sourcePosition:l,targetPosition:h}}function Zr(e){if(!e)return null;let t=[],n=[];for(let o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function mt(e,t,n=U.Left,o=!1){let r=(t?.x??0)+e.internals.positionAbsolute.x,s=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Te(e);if(o)return{x:r+i/2,y:s+l/2};switch(t?.position??n){case U.Top:return{x:r+i/2,y:s};case U.Right:return{x:r+i,y:s+l/2};case U.Bottom:return{x:r+i/2,y:s+l};case U.Left:return{x:r,y:s+l/2}}}function Yr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Uo(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(n=>`${n}=${e[n]}`).join("&")}`:""}function zp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){let s=new Set;return e.reduce((i,l)=>([l.markerStart||o,l.markerEnd||r].forEach(h=>{if(h&&typeof h=="object"){let u=Uo(h,t);s.has(u)||(i.push({id:u,color:h.color||n,...h}),s.add(u))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}var Pi=1e3,_p=10,fa={nodeOrigin:[0,0],nodeExtent:Jt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Pp={...fa,checkEquality:!0};function ga(e,t){let n={...e};for(let o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Ap(e,t,n){let o=ga(fa,n);for(let r of e.values())if(r.parentId)va(r,e,t,o);else{let s=ln(r,o.nodeOrigin),i=pt(r.extent)?r.extent:o.nodeExtent,l=ht(s,i,Te(r));r.internals.positionAbsolute=l}}function Ip(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],o=[];for(let r of e.handles){let s={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(s):r.type==="target"&&o.push(s)}return{source:n,target:o}}function xa(e){return e==="manual"}function Go(e,t,n,o={}){let r=ga(Pp,o),s={i:0},i=new Map(t),l=r?.elevateNodesOnSelect&&!xa(r.zIndexMode)?Pi:0,h=e.length>0,u=!1;t.clear(),n.clear();for(let c of e){let p=i.get(c.id);if(r.checkEquality&&c===p?.internals.userNode)t.set(c.id,p);else{let d=ln(c,r.nodeOrigin),m=pt(c.extent)?c.extent:r.nodeExtent,f=ht(d,m,Te(c));p={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:f,handleBounds:Ip(c,p),z:Ai(c,l,r.zIndexMode),userNode:c}},t.set(c.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(h=!1),c.parentId&&va(p,t,n,o,s),u||=c.selected??!1}return{nodesInitialized:h,hasSelectedNodes:u}}function Dp(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function va(e,t,n,o,r){let{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:l,zIndexMode:h}=ga(fa,o),u=e.parentId,c=t.get(u);if(!c){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Dp(e,n),r&&!c.parentId&&c.internals.rootParentIndex===void 0&&h==="auto"&&(c.internals.rootParentIndex=++r.i,c.internals.z=c.internals.z+r.i*_p),r&&c.internals.rootParentIndex!==void 0&&(r.i=c.internals.rootParentIndex);let p=s&&!xa(h)?Pi:0,{x:d,y:m,z:f}=Rp(e,c,i,l,p,h),{positionAbsolute:w}=e.internals,y=d!==w.x||m!==w.y;(y||f!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:d,y:m}:w,z:f}})}function Ai(e,t,n){let o=Re(e.zIndex)?e.zIndex:0;return xa(n)?o:o+(e.selected?t:0)}function Rp(e,t,n,o,r,s){let{x:i,y:l}=t.internals.positionAbsolute,h=Te(e),u=ln(e,n),c=pt(e.extent)?ht(u,e.extent,h):u,p=ht({x:i+c.x,y:l+c.y},o,h);e.extent==="parent"&&(p=vi(p,h,t));let d=Ai(e,r,s),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=d?m+1:d}}function ya(e,t,n,o=[0,0]){let r=[],s=new Map;for(let i of e){let l=t.get(i.parentId);if(!l)continue;let h=s.get(i.parentId)?.expandedRect??en(l),u=yi(h,i.rect);s.set(i.parentId,{expandedRect:u,parent:l})}return s.size>0&&s.forEach(({expandedRect:i,parent:l},h)=>{let u=l.internals.positionAbsolute,c=Te(l),p=l.origin??o,d=i.x<u.x?Math.round(Math.abs(u.x-i.x)):0,m=i.y<u.y?Math.round(Math.abs(u.y-i.y)):0,f=Math.max(c.width,Math.round(i.width)),w=Math.max(c.height,Math.round(i.height)),y=(f-c.width)*p[0],x=(w-c.height)*p[1];(d>0||m>0||y||x)&&(r.push({id:h,type:"position",position:{x:l.position.x-d+y,y:l.position.y-m+x}}),n.get(h)?.forEach(E=>{e.some(v=>v.id===E.id)||r.push({id:E.id,type:"position",position:{x:E.position.x+d,y:E.position.y+m}})})),(c.width<i.width||c.height<i.height||d||m)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:f+(d?p[0]*d-y:0),height:w+(m?p[1]*m-x:0)}})}),r}function Op(e,t,n,o,r,s,i){let l=o?.querySelector(".xyflow__viewport"),h=!1;if(!l)return{changes:[],updatedInternals:h};let u=[],c=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(c.transform),d=[];for(let m of e.values()){let f=t.get(m.id);if(!f)continue;if(f.hidden){t.set(f.id,{...f,internals:{...f.internals,handleBounds:void 0}}),h=!0;continue}let w=ma(m.nodeElement),y=f.measured.width!==w.width||f.measured.height!==w.height;if(w.width&&w.height&&(y||!f.internals.handleBounds||m.force)){let x=m.nodeElement.getBoundingClientRect(),E=pt(f.extent)?f.extent:s,{positionAbsolute:v}=f.internals;if(f.parentId&&f.extent==="parent"){let j=t.get(f.parentId);j&&(v=vi(v,w,j))}else E&&(v=ht(v,E,w));let b={...f,measured:w,internals:{...f.internals,positionAbsolute:v,handleBounds:{source:Br("source",m.nodeElement,x,p,f.id),target:Br("target",m.nodeElement,x,p,f.id)}}};t.set(f.id,b),f.parentId&&va(b,t,n,{nodeOrigin:r,zIndexMode:i}),h=!0,y&&(u.push({id:f.id,type:"dimensions",dimensions:w}),f.expandParent&&f.parentId&&d.push({id:f.id,parentId:f.parentId,rect:en(b,r)}))}}if(d.length>0){let m=ya(d,t,n,r);u.push(...m)}return{changes:u,updatedInternals:h}}async function Lp({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:s}){if(!t||!e.x&&!e.y)return!1;let i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],o);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function Xr(e,t,n,o,r,s){let i=r,l=o.get(i)||new Map;o.set(i,l.set(n,t)),i=`${r}-${e}`;let h=o.get(i)||new Map;if(o.set(i,h.set(n,t)),s){i=`${r}-${e}-${s}`;let u=o.get(i)||new Map;o.set(i,u.set(n,t))}}function Ii(e,t,n){e.clear(),t.clear();for(let o of n){let{source:r,target:s,sourceHandle:i=null,targetHandle:l=null}=o,h={edgeId:o.id,source:r,target:s,sourceHandle:i,targetHandle:l},u=`${r}-${i}--${s}-${l}`,c=`${s}-${l}--${r}-${i}`;Xr("source",h,c,e,r,i),Xr("target",h,u,e,s,l),t.set(o.id,o)}}function Di(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Di(n,t):!1}function qr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Tp(e,t,n,o){let r=new Map;for(let[s,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!Di(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){let l=e.get(s);l&&r.set(s,{id:s,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return r}function Ro({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){let r=[];for(let[i,l]of t){let h=n.get(i)?.internals.userNode;h&&r.push({...h,position:l.position,dragging:o})}if(!e)return[r[0],r];let s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:o}:r[0],r]}function Bp({dragItems:e,snapGrid:t,x:n,y:o}){let r=e.values().next().value;if(!r)return null;let s={x:n-r.distance.x,y:o-r.distance.y},i=cn(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Vp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let s={x:null,y:null},i=0,l=new Map,h=!1,u={x:0,y:0},c=null,p=!1,d=null,m=!1,f=!1,w=null;function y({noDragClassName:E,handleSelector:v,domNode:b,isSelectable:j,nodeId:S,nodeClickDistance:M=0}){d=Ce(b);function C({x:R,y:H}){let{nodeLookup:g,nodeExtent:N,snapGrid:k,snapToGrid:z,nodeOrigin:A,onNodeDrag:$,onSelectionDrag:B,onError:V,updateNodePositions:W}=t();s={x:R,y:H};let J=!1,X=l.size>1,Z=X&&N?Ko(dn(l)):null,ee=X&&z?Bp({dragItems:l,snapGrid:k,x:R,y:H}):null;for(let[Q,T]of l){if(!g.has(Q))continue;let K={x:R-T.distance.x,y:H-T.distance.y};z&&(K=ee?{x:Math.round(K.x+ee.x),y:Math.round(K.y+ee.y)}:cn(K,k));let oe=null;if(X&&N&&!T.extent&&Z){let{positionAbsolute:se}=T.internals,re=se.x-Z.x+N[0][0],le=se.x+T.measured.width-Z.x2+N[1][0],ce=se.y-Z.y+N[0][1],ge=se.y+T.measured.height-Z.y2+N[1][1];oe=[[re,ce],[le,ge]]}let{position:ie,positionAbsolute:q}=xi({nodeId:Q,nextPosition:K,nodeLookup:g,nodeExtent:oe||N,nodeOrigin:A,onError:V});J=J||T.position.x!==ie.x||T.position.y!==ie.y,T.position=ie,T.internals.positionAbsolute=q}if(f=f||J,!!J&&(W(l,!0),w&&(o||$||!S&&B))){let[Q,T]=Ro({nodeId:S,dragItems:l,nodeLookup:g});o?.(w,l,Q,T),$?.(w,Q,T),S||B?.(w,T)}}async function _(){if(!c)return;let{transform:R,panBy:H,autoPanSpeed:g,autoPanOnNodeDrag:N}=t();if(!N){h=!1,cancelAnimationFrame(i);return}let[k,z]=ha(u,c,g);(k!==0||z!==0)&&(s.x=(s.x??0)-k/R[2],s.y=(s.y??0)-z/R[2],await H({x:k,y:z})&&C(s)),i=requestAnimationFrame(_)}function F(R){let{nodeLookup:H,multiSelectionActive:g,nodesDraggable:N,transform:k,snapGrid:z,snapToGrid:A,selectNodesOnDrag:$,onNodeDragStart:B,onSelectionDragStart:V,unselectNodesAndEdges:W}=t();p=!0,(!$||!j)&&!g&&S&&(H.get(S)?.selected||W()),j&&$&&S&&e?.(S);let J=Xt(R.sourceEvent,{transform:k,snapGrid:z,snapToGrid:A,containerBounds:c});if(s=J,l=Tp(H,N,J,S),l.size>0&&(n||B||!S&&V)){let[X,Z]=Ro({nodeId:S,dragItems:l,nodeLookup:H});n?.(R.sourceEvent,l,X,Z),B?.(R.sourceEvent,X,Z),S||V?.(R.sourceEvent,Z)}}let O=Ks().clickDistance(M).on("start",R=>{let{domNode:H,nodeDragThreshold:g,transform:N,snapGrid:k,snapToGrid:z}=t();c=H?.getBoundingClientRect()||null,m=!1,f=!1,w=R.sourceEvent,g===0&&F(R),s=Xt(R.sourceEvent,{transform:N,snapGrid:k,snapToGrid:z,containerBounds:c}),u=Oe(R.sourceEvent,c)}).on("drag",R=>{let{autoPanOnNodeDrag:H,transform:g,snapGrid:N,snapToGrid:k,nodeDragThreshold:z,nodeLookup:A}=t(),$=Xt(R.sourceEvent,{transform:g,snapGrid:N,snapToGrid:k,containerBounds:c});if(w=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||S&&!A.has(S))&&(m=!0),!m){if(!h&&H&&p&&(h=!0,_()),!p){let B=Oe(R.sourceEvent,c),V=B.x-u.x,W=B.y-u.y;Math.sqrt(V*V+W*W)>z&&F(R)}(s.x!==$.xSnapped||s.y!==$.ySnapped)&&l&&p&&(u=Oe(R.sourceEvent,c),C($))}}).on("end",R=>{if(!p||m){m&&l.size>0&&t().updateNodePositions(l,!1);return}if(h=!1,p=!1,cancelAnimationFrame(i),l.size>0){let{nodeLookup:H,updateNodePositions:g,onNodeDragStop:N,onSelectionDragStop:k}=t();if(f&&(g(l,!1),f=!1),r||N||!S&&k){let[z,A]=Ro({nodeId:S,dragItems:l,nodeLookup:H,dragging:!1});r?.(R.sourceEvent,l,z,A),N?.(R.sourceEvent,z,A),S||k?.(R.sourceEvent,A)}}}).filter(R=>{let H=R.target;return!R.button&&(!E||!qr(H,`.${E}`,b))&&(!v||qr(H,v,b))});d.call(O)}function x(){d?.on(".drag",null)}return{update:y,destroy:x}}function Hp(e,t,n){let o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let s of t.values())Kn(r,en(s))>0&&o.push(s);return o}var Fp=250;function Wp(e,t,n,o){let r=[],s=1/0,i=Hp(e,n,t+Fp);for(let l of i){let h=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(let u of h){if(o.nodeId===u.nodeId&&o.type===u.type&&o.id===u.id)continue;let{x:c,y:p}=mt(l,u,u.position,!0),d=Math.sqrt(Math.pow(c-e.x,2)+Math.pow(p-e.y,2));d>t||(d<s?(r=[{...u,x:c,y:p}],s=d):d===s&&r.push({...u,x:c,y:p}))}}if(!r.length)return null;if(r.length>1){let l=o.type==="source"?"target":"source";return r.find(h=>h.type===l)??r[0]}return r[0]}function Ri(e,t,n,o,r,s=!1){let i=o.get(e);if(!i)return null;let l=r==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],h=(n?l?.find(u=>u.id===n):l?.[0])??null;return h&&s?{...h,...mt(i,h,h.position,!0)}:h}function Oi(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Zp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Li=()=>!0;function Yp(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:s,isTarget:i,domNode:l,nodeLookup:h,lib:u,autoPanOnConnect:c,flowId:p,panBy:d,cancelConnection:m,onConnectStart:f,onConnect:w,onConnectEnd:y,isValidConnection:x=Li,onReconnectEnd:E,updateConnection:v,getTransform:b,getFromHandle:j,autoPanSpeed:S,dragThreshold:M=1,handleDomNode:C}){let _=Si(e.target),F=0,O,{x:R,y:H}=Oe(e),g=Oi(s,C),N=l?.getBoundingClientRect(),k=!1;if(!N||!g)return;let z=Ri(r,g,o,h,t);if(!z)return;let A=Oe(e,N),$=!1,B=null,V=!1,W=null;function J(){if(!c||!N)return;let[oe,ie]=ha(A,N,S);d({x:oe,y:ie}),F=requestAnimationFrame(J)}let X={...z,nodeId:r,type:g,position:z.position},Z=h.get(r),ee={inProgress:!0,isValid:null,from:mt(Z,X,U.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:Z,to:A,toHandle:null,toPosition:Rr[X.position],toNode:null,pointer:A};function Q(){k=!0,v(ee),f?.(e,{nodeId:r,handleId:o,handleType:g})}M===0&&Q();function T(oe){if(!k){let{x:ce,y:ge}=Oe(oe),je=ce-R,Ee=ge-H;if(!(je*je+Ee*Ee>M*M))return;Q()}if(!j()||!X){K(oe);return}let ie=b();A=Oe(oe,N),O=Wp(un(A,ie,!1,[1,1]),n,h,X),$||(J(),$=!0);let q=Ti(oe,{handle:O,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:i?"target":"source",isValidConnection:x,doc:_,lib:u,flowId:p,nodeLookup:h});W=q.handleDomNode,B=q.connection,V=Zp(!!O,q.isValid);let se=h.get(r),re=se?mt(se,X,U.Left,!0):ee.from,le={...ee,from:re,isValid:V,to:q.toHandle&&V?Pt({x:q.toHandle.x,y:q.toHandle.y},ie):A,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:Rr[X.position],toNode:q.toHandle?h.get(q.toHandle.nodeId):null,pointer:A};v(le),ee=le}function K(oe){if(!("touches"in oe&&oe.touches.length>0)){if(k){(O||W)&&B&&V&&w?.(B);let{inProgress:ie,...q}=ee,se={...q,toPosition:ee.toHandle?ee.toPosition:null};y?.(oe,se),s&&E?.(oe,se)}m(),cancelAnimationFrame(F),$=!1,V=!1,B=null,W=null,_.removeEventListener("mousemove",T),_.removeEventListener("mouseup",K),_.removeEventListener("touchmove",T),_.removeEventListener("touchend",K)}}_.addEventListener("mousemove",T),_.addEventListener("mouseup",K),_.addEventListener("touchmove",T),_.addEventListener("touchend",K)}function Ti(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:s,doc:i,lib:l,flowId:h,isValidConnection:u=Li,nodeLookup:c}){let p=s==="target",d=t?i.querySelector(`.${l}-flow__handle[data-id="${h}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:m,y:f}=Oe(e),w=i.elementFromPoint(m,f),y=w?.classList.contains(`${l}-flow__handle`)?w:d,x={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let E=Oi(void 0,y),v=y.getAttribute("data-nodeid"),b=y.getAttribute("data-handleid"),j=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!v||!E)return x;let M={source:p?v:o,sourceHandle:p?b:r,target:p?o:v,targetHandle:p?r:b};x.connection=M;let C=j&&S&&(n===zt.Strict?p&&E==="source"||!p&&E==="target":v!==o||b!==r);x.isValid=C&&u(M),x.toHandle=Ri(v,E,b,c,n,!0)}return x}var Jo={onPointerDown:Yp,isValid:Ti};function Xp({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){let r=Ce(e);function s({translateExtent:l,width:h,height:u,zoomStep:c=1,pannable:p=!0,zoomable:d=!0,inversePan:m=!1}){let f=v=>{if(v.sourceEvent.type!=="wheel"||!t)return;let b=n(),j=v.sourceEvent.ctrlKey&&tn()?10:1,S=-v.sourceEvent.deltaY*(v.sourceEvent.deltaMode===1?.05:v.sourceEvent.deltaMode?1:.002)*c,M=b[2]*Math.pow(2,S*j);t.scaleTo(M)},w=[0,0],y=v=>{(v.sourceEvent.type==="mousedown"||v.sourceEvent.type==="touchstart")&&(w=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY])},x=v=>{let b=n();if(v.sourceEvent.type!=="mousemove"&&v.sourceEvent.type!=="touchmove"||!t)return;let j=[v.sourceEvent.clientX??v.sourceEvent.touches[0].clientX,v.sourceEvent.clientY??v.sourceEvent.touches[0].clientY],S=[j[0]-w[0],j[1]-w[1]];w=j;let M=o()*Math.max(b[2],Math.log(b[2]))*(m?-1:1),C={x:b[0]-S[0]*M,y:b[1]-S[1]*M},_=[[0,0],[h,u]];t.setViewportConstrained({x:C.x,y:C.y,zoom:b[2]},_,l)},E=hi().on("start",y).on("zoom",p?x:null).on("zoom.wheel",d?f:null);r.call(E,{})}function i(){r.on("zoom",null)}return{update:s,destroy:i,pointer:Ie}}var ao=e=>({x:e.x,y:e.y,zoom:e.k}),Oo=({x:e,y:t,zoom:n})=>to.translate(e,t).scale(n),ot=(e,t)=>e.target.closest(`.${t}`),Bi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Lo=(e,t=0,n=qp,o=()=>{})=>{let r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Vi=e=>{let t=e.ctrlKey&&tn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Kp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:h,onPanZoomEnd:u}){return c=>{if(ot(c,t))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();let p=n.property("__zoom").k||1;if(c.ctrlKey&&i){let y=Ie(c),x=Vi(c),E=p*Math.pow(2,x);o.scaleTo(n,E,y,c);return}let d=c.deltaMode===1?20:1,m=r===dt.Vertical?0:c.deltaX*d,f=r===dt.Horizontal?0:c.deltaY*d;!tn()&&c.shiftKey&&r!==dt.Vertical&&(m=c.deltaY*d,f=0),o.translateBy(n,-(m/p)*s,-(f/p)*s,{internal:!0});let w=ao(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?h?.(c,w):(e.isPanScrolling=!0,l?.(c,w)),e.panScrollTimeout=setTimeout(()=>{u?.(c,w),e.isPanScrolling=!1},150)}}function Up({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){let s=o.type==="wheel",i=!t&&s&&!o.ctrlKey,l=ot(o,e);if(o.ctrlKey&&s&&l&&o.preventDefault(),i||l)return null;o.preventDefault(),n.call(this,o,r)}}function Gp({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;let r=ao(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Jp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return s=>{e.usedRightMouseButton=!!(n&&Bi(t,e.mouseButton??0)),s.sourceEvent?.sync||o([s.transform.x,s.transform.y,s.transform.k]),r&&!s.sourceEvent?.internal&&r?.(s.sourceEvent,ao(s.transform))}}function Qp({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:s}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&Bi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){let l=ao(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(i.sourceEvent,l)},n?150:0)}}}function em({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:l,noWheelClassName:h,noPanClassName:u,lib:c,connectionInProgress:p}){return d=>{let m=t||n,f=o&&d.ctrlKey,w=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(ot(d,`${c}-flow__node`)||ot(d,`${c}-flow__edge`)||ot(d,`${c}-flow__selection`)||ot(d,`${c}-flow__nodesselection`)))return!0;if(!r&&!m&&!s&&!i&&!o||l||p&&!w||ot(d,h)&&w||ot(d,u)&&(!w||s&&w&&!t)||!o&&d.ctrlKey&&w)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!m&&!s&&!f&&w||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;let y=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||w||e)&&y}}function tm({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:h}){let u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=e.getBoundingClientRect(),p=[[0,0],[c.width,c.height]];(typeof ResizeObserver<"u"?new ResizeObserver(R=>{let H=R[0];H&&(p=[[0,0],[H.contentRect.width,H.contentRect.height]])}):null)?.observe(e);let d=hi().extent(()=>p).scaleExtent([t,n]).translateExtent(o),m=Ce(e).call(d);v({x:r.x,y:r.y,zoom:_t(r.zoom,t,n)},[[0,0],[c.width,c.height]],o);let f=m.on("wheel.zoom"),w=m.on("dblclick.zoom");d.wheelDelta(Vi);async function y(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).transform(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}function x({noWheelClassName:R,noPanClassName:H,onPaneContextMenu:g,userSelectionActive:N,panOnScroll:k,panOnDrag:z,panOnScrollMode:A,panOnScrollSpeed:$,preventScrolling:B,zoomOnPinch:V,zoomOnScroll:W,zoomOnDoubleClick:J,panActivationKeyPressed:X=!1,zoomActivationKeyPressed:Z,lib:ee,onTransformChange:Q,connectionInProgress:T,paneClickDistance:K,selectionOnDrag:oe}){N&&!u.isZoomingOrPanning&&E();let ie=k&&!Z&&!N;d.clickDistance(oe?1/0:!Re(K)||K<0?0:K);let q=ie?Kp({zoomPanValues:u,noWheelClassName:R,d3Selection:m,d3Zoom:d,panOnScrollMode:A,panOnScrollSpeed:$,zoomOnPinch:V,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:l}):Up({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:f});m.on("wheel.zoom",q,{passive:!1});let se=Gp({zoomPanValues:u,onDraggingChange:h,onPanZoomStart:i});d.on("start",se);let re=Jp({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!g,onPanZoom:s,onTransformChange:Q});d.on("zoom",re);let le=Qp({zoomPanValues:u,panOnDrag:z,panOnScroll:k,onPaneContextMenu:g,onPanZoomEnd:l,onDraggingChange:h});d.on("end",le);let ce=em({panActivationKeyPressed:X,zoomActivationKeyPressed:Z,panOnDrag:z,zoomOnScroll:W,panOnScroll:k,zoomOnDoubleClick:J,zoomOnPinch:V,userSelectionActive:N,noPanClassName:H,noWheelClassName:R,lib:ee,connectionInProgress:T});d.filter(ce),J?m.on("dblclick.zoom",w):m.on("dblclick.zoom",null)}function E(){d.on("zoom",null)}async function v(R,H,g){let N=Oo(R),k=d?.constrain()(N,H,g);return k&&await y(k),k}async function b(R,H){let g=Oo(R);return await y(g,H),g}function j(R){if(m){let H=Oo(R),g=m.property("__zoom");(g.k!==R.zoom||g.x!==R.x||g.y!==R.y)&&d?.transform(m,H,null,{sync:!0})}}function S(){let R=m?ui(m.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}async function M(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).scaleTo(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}async function C(R,H){return m?new Promise(g=>{d?.interpolate(H?.interpolate==="linear"?Yt:Rn).scaleBy(Lo(m,H?.duration,H?.ease,()=>g(!0)),R)}):!1}function _(R){d?.scaleExtent(R)}function F(R){d?.translateExtent(R)}function O(R){let H=!Re(R)||R<0?0:R;d?.clickDistance(H)}return{update:x,destroy:E,setViewport:b,setViewportConstrained:v,getViewport:S,scaleTo:M,scaleBy:C,setScaleExtent:_,setTranslateExtent:F,syncViewport:j,setClickDistance:O}}var ft;(function(e){e.Line="line",e.Handle="handle"})(ft||(ft={}));var nm=["top-left","top-right","bottom-left","bottom-right"],om=["top","right","bottom","left"];function am({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:s}){let i=e-t,l=n-o,h=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&r&&(h[0]=h[0]*-1),l&&s&&(h[1]=h[1]*-1),h}function Kr(e){let t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function tt(e,t){return Math.max(0,t-e)}function nt(e,t){return Math.max(0,e-t)}function Pn(e,t,n){return Math.max(0,t-e,e-n)}function Ur(e,t){return e?!t:t}function rm(e,t,n,o,r,s,i,l){let{affectsX:h,affectsY:u}=t,{isHorizontal:c,isVertical:p}=t,d=c&&p,{xSnapped:m,ySnapped:f}=n,{minWidth:w,maxWidth:y,minHeight:x,maxHeight:E}=o,{x:v,y:b,width:j,height:S,aspectRatio:M}=e,C=Math.floor(c?m-e.pointerX:0),_=Math.floor(p?f-e.pointerY:0),F=j+(h?-C:C),O=S+(u?-_:_),R=-s[0]*j,H=-s[1]*S,g=Pn(F,w,y),N=Pn(O,x,E);if(i){let A=0,$=0;h&&C<0?A=tt(v+C+R,i[0][0]):!h&&C>0&&(A=nt(v+F+R,i[1][0])),u&&_<0?$=tt(b+_+H,i[0][1]):!u&&_>0&&($=nt(b+O+H,i[1][1])),g=Math.max(g,A),N=Math.max(N,$)}if(l){let A=0,$=0;h&&C>0?A=nt(v+C,l[0][0]):!h&&C<0&&(A=tt(v+F,l[1][0])),u&&_>0?$=nt(b+_,l[0][1]):!u&&_<0&&($=tt(b+O,l[1][1])),g=Math.max(g,A),N=Math.max(N,$)}if(r){if(c){let A=Pn(F/M,x,E)*M;if(g=Math.max(g,A),i){let $=0;!h&&!u||h&&!u&&d?$=nt(b+H+F/M,i[1][1])*M:$=tt(b+H+(h?C:-C)/M,i[0][1])*M,g=Math.max(g,$)}if(l){let $=0;!h&&!u||h&&!u&&d?$=tt(b+F/M,l[1][1])*M:$=nt(b+(h?C:-C)/M,l[0][1])*M,g=Math.max(g,$)}}if(p){let A=Pn(O*M,w,y)/M;if(N=Math.max(N,A),i){let $=0;!h&&!u||u&&!h&&d?$=nt(v+O*M+R,i[1][0])/M:$=tt(v+(u?_:-_)*M+R,i[0][0])/M,N=Math.max(N,$)}if(l){let $=0;!h&&!u||u&&!h&&d?$=tt(v+O*M,l[1][0])/M:$=nt(v+(u?_:-_)*M,l[0][0])/M,N=Math.max(N,$)}}}_=_+(_<0?N:-N),C=C+(C<0?g:-g),r&&(d?F>O*M?_=(Ur(h,u)?-C:C)/M:C=(Ur(h,u)?-_:_)*M:c?(_=C/M,u=h):(C=_*M,h=u));let k=h?v+C:v,z=u?b+_:b;return{width:j+(h?-C:C),height:S+(u?-_:_),x:s[0]*C*(h?-1:1)+k,y:s[1]*_*(u?-1:1)+z}}var Hi={width:0,height:0,x:0,y:0},sm={...Hi,pointerX:0,pointerY:0,aspectRatio:1};function im(e,t,n){let o=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,l=n[0]*s,h=n[1]*i;return[[o-l,r-h],[o+s-l,r+i-h]]}function lm({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){let s=Ce(e),i={controlDirection:Kr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:c,keepAspectRatio:p,resizeDirection:d,onResizeStart:m,onResize:f,onResizeEnd:w,shouldResize:y}){let x={...Hi},E={...sm};i={boundaries:c,resizeDirection:d,keepAspectRatio:p,controlDirection:Kr(u)};let v,b=null,j=[],S,M,C,_=Ks().on("start",F=>{let{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,paneDomNode:k}=n();if(v=O.get(t),!v)return;b=k?.getBoundingClientRect()??null;let{xSnapped:z,ySnapped:A}=Xt(F.sourceEvent,{transform:R,snapGrid:H,snapToGrid:g,containerBounds:b});x={width:v.measured.width??0,height:v.measured.height??0,x:v.position.x??0,y:v.position.y??0},E={...x,pointerX:z,pointerY:A,aspectRatio:x.width/x.height},S=void 0,M=pt(v.extent)?v.extent:void 0,v.parentId&&(v.extent==="parent"||v.expandParent)&&(S=O.get(v.parentId)),S&&v.extent==="parent"&&(M=[[0,0],[S.measured.width,S.measured.height]]),j=[],C=void 0;for(let[$,B]of O)if(B.parentId===t&&(j.push({id:$,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){let V=im(B,v,B.origin??N);C?C=[[Math.min(V[0][0],C[0][0]),Math.min(V[0][1],C[0][1])],[Math.max(V[1][0],C[1][0]),Math.max(V[1][1],C[1][1])]]:C=V}m?.(F,{...x})}).on("drag",F=>{let{transform:O,snapGrid:R,snapToGrid:H,nodeOrigin:g}=n(),N=Xt(F.sourceEvent,{transform:O,snapGrid:R,snapToGrid:H,containerBounds:b}),k=[];if(!v)return;let{x:z,y:A,width:$,height:B}=x,V={},W=v.origin??g,{width:J,height:X,x:Z,y:ee}=rm(E,i.controlDirection,N,i.boundaries,i.keepAspectRatio,W,M,C),Q=J!==$,T=X!==B,K=Z!==z&&Q,oe=ee!==A&&T;if(!K&&!oe&&!Q&&!T)return;let ie={prevValues:{...x},startX:E.x,startY:E.y,childNodes:j.map(re=>({...re,position:{...re.position}}))};if((K||oe||W[0]===1||W[1]===1)&&(V.x=K?Z:x.x,V.y=oe?ee:x.y,x.x=V.x,x.y=V.y,j.length>0)){let re=Z-z,le=ee-A;for(let ce of j)ce.position={x:ce.position.x-re+W[0]*(J-$),y:ce.position.y-le+W[1]*(X-B)},k.push(ce)}if((Q||T)&&(V.width=Q&&(!i.resizeDirection||i.resizeDirection==="horizontal")?J:x.width,V.height=T&&(!i.resizeDirection||i.resizeDirection==="vertical")?X:x.height,x.width=V.width,x.height=V.height),S&&v.expandParent){let re=W[0]*(V.width??0);V.x&&V.x<re&&(x.x=re,E.x=E.x-(V.x-re));let le=W[1]*(V.height??0);V.y&&V.y<le&&(x.y=le,E.y=E.y-(V.y-le))}let q=am({width:x.width,prevWidth:$,height:x.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),se={...x,direction:q};if(y?.(F,se)===!1){x=ie.prevValues,E.x=ie.startX,E.y=ie.startY,j.forEach((re,le)=>{re.position=ie.childNodes[le].position});return}f?.(F,se),o(V,k)}).on("end",F=>{w?.(F,{...x}),r?.({...x})});s.call(_)}function h(){s.on(".drag",null)}return{update:l,destroy:h}}var dm=et(Nt(),1),cm=et($d(),1),Gr=e=>{let t,n=new Set,o=(l,h)=>{let u=typeof l=="function"?l(t):l;if(!Object.is(u,t)){let c=t;t=h??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(p=>p(t,c))}},r=()=>t,s={setState:o,getState:r,getInitialState:()=>i,subscribe:l=>(n.add(l),()=>n.delete(l)),destroy:()=>{(import.meta.env?import.meta.env.MODE: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()}},i=t=e(o,r,s);return s},um=e=>e?Gr(e):Gr,{useDebugValue:hm}=dm.default,{useSyncExternalStoreWithSelector:pm}=cm.default,mm=e=>e;function Fi(e,t=mm,n){let o=pm(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return hm(o),o}var Jr=(e,t)=>{let n=um(e),o=(r,s=t)=>Fi(n,r,s);return Object.assign(o,n),o},fm=(e,t)=>e?Jr(e,t):Jr;function fe(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(let[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let o of e)if(!t.has(o))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var gm=et(vr()),ro=(0,L.createContext)(null),xm=ro.Provider,Wi=_e.error001("react");function de(e,t){let n=(0,L.useContext)(ro);if(n===null)throw new Error(Wi);return Fi(n,e,t)}function pe(){let e=(0,L.useContext)(ro);if(e===null)throw new Error(Wi);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Qr={display:"none"},vm={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Zi="react-flow__node-desc",Yi="react-flow__edge-desc",ym="react-flow__aria-live",bm=e=>e.ariaLiveMessage,wm=e=>e.ariaLabelConfig;function jm({rfId:e}){let t=de(bm);return(0,I.jsx)("div",{id:`${ym}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vm,children:t})}function Nm({rfId:e,disableKeyboardA11y:t}){let n=de(wm);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("div",{id:`${Zi}-${e}`,style:Qr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,I.jsx)("div",{id:`${Yi}-${e}`,style:Qr,children:n["edge.a11yDescription.default"]}),!t&&(0,I.jsx)(jm,{rfId:e})]})}var so=(0,L.forwardRef)(({position:e="top-left",children:t,className:n,style:o,...r},s)=>{let i=`${e}`.split("-");return(0,I.jsx)("div",{className:ve(["react-flow__panel",n,...i]),style:o,ref:s,...r,children:t})});so.displayName="Panel";var es="https://reactflow.dev?utm_source=attribution";function km({proOptions:e,position:t="bottom-right"}){return(0,L.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,I.jsx)(so,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${es}`,children:(0,I.jsx)("a",{href:es,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}var Sm=e=>{let t=[],n=[];for(let[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(let[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},An=e=>e.id;function Cm(e,t){return fe(e.selectedNodes.map(An),t.selectedNodes.map(An))&&fe(e.selectedEdges.map(An),t.selectedEdges.map(An))}function $m({onSelectionChange:e}){let t=pe(),{selectedNodes:n,selectedEdges:o}=de(Sm,Cm);return(0,L.useEffect)(()=>{let r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,o,e]),null}var Em=e=>!!e.onSelectionChangeHandlers;function Mm({onSelectionChange:e}){let t=de(Em);return e||t?(0,I.jsx)($m,{onSelectionChange:e}):null}var Xi=[0,0],zm={x:0,y:0,zoom:1},_m=["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"],ts=[..._m,"rfId"],Pm=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}),ns={translateExtent:Jt,nodeOrigin:Xi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Am(e){let{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:h}=de(Pm,fe),u=pe();(0,L.useEffect)(()=>(h(e.defaultNodes,e.defaultEdges),()=>{c.current=ns,l()}),[]);let c=(0,L.useRef)(ns);return(0,L.useEffect)(()=>{for(let p of ts){let d=e[p],m=c.current[p];d!==m&&(typeof e[p]>"u"||(p==="nodes"?t(d):p==="edges"?n(d):p==="minZoom"?o(d):p==="maxZoom"?r(d):p==="translateExtent"?s(d):p==="nodeExtent"?i(d):p==="ariaLabelConfig"?u.setState({ariaLabelConfig:yp(d)}):p==="fitView"?u.setState({fitViewQueued:d}):p==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[p]:d})))}c.current=e},ts.map(p=>e[p])),null}function os(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Im(e){let[t,n]=(0,L.useState)(e==="system"?null:e);return(0,L.useEffect)(()=>{if(e!=="system"){n(e);return}let o=os(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:os()?.matches?"dark":"light"}var as=typeof document<"u"?document:null;function on(e=null,t={target:as,actInsideInputWithModifier:!0}){let[n,o]=(0,L.useState)(!1),r=(0,L.useRef)(!1),s=(0,L.useRef)(new Set([])),[i,l]=(0,L.useMemo)(()=>{if(e!==null){let h=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace(/\+/g,`
|
|
3
3
|
`).replace(`
|
|
4
4
|
|
|
5
5
|
`,`
|
|
6
6
|
+`).split(`
|
|
7
|
-
`)),u=h.reduce((c,p)=>c.concat(...p),[]);return[h,u]}return[[],[]]},[e]);return(0,L.useEffect)(()=>{let h=t?.target??as,u=t?.actInsideInputWithModifier??!0;if(e!==null){let c=m=>{if(r.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!r.current||r.current&&!u)&&Ci(m))return!1;let f=ss(m.code,l);if(s.current.add(m[f]),rs(i,s.current,!1)){let w=m.composedPath?.()?.[0]||m.target,y=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&m.preventDefault(),o(!0)}},p=m=>{let f=ss(m.code,l);rs(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(m[f]),m.key==="Meta"&&s.current.clear(),r.current=!1},d=()=>{s.current.clear(),o(!1)};return h?.addEventListener("keydown",c),h?.addEventListener("keyup",p),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{h?.removeEventListener("keydown",c),h?.removeEventListener("keyup",p),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function rs(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ss(e,t){return t.includes(e)?"code":"key"}var Dm=()=>{let e=pe();return(0,L.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[o,r,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{let[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{let{width:o,height:r,minZoom:s,maxZoom:i,panZoom:l}=e.getState(),h=pa(t,o,r,s,i,n?.padding??.1);return l?(await l.setViewport(h,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:o,snapGrid:r,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;let{x:l,y:h}=i.getBoundingClientRect(),u={x:t.x-l,y:t.y-h},c=n.snapGrid??r,p=n.snapToGrid??s;return un(u,o,p,c)},flowToScreenPosition:t=>{let{transform:n,domNode:o}=e.getState();if(!o)return t;let{x:r,y:s}=o.getBoundingClientRect(),i=Pt(t,n);return{x:i.x+r,y:i.y+s}}}),[])};function qi(e,t){let n=[],o=new Map,r=[];for(let s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")o.set(s.id,[s]);else{let i=o.get(s.id);i?i.push(s):o.set(s.id,[s])}for(let s of t){let i=o.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}let l={...s};for(let h of i)Rm(h,l);n.push(l)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function Rm(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 Ki(e,t){return qi(e,t)}function Om(e,t){return qi(e,t)}function st(e,t){return{id:e,type:"select",selected:t}}function St(e,t=new Set,n=!1){let o=[];for(let[r,s]of e){let i=t.has(r);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),o.push(st(s.id,i)))}return o}function is({items:e=[],lookup:t}){let n=[],o=new Map(e.map(r=>[r.id,r]));for(let[r,s]of e.entries()){let i=t.get(s.id),l=i?.internals?.userNode??i;l!==void 0&&l!==s&&n.push({id:s.id,item:s,type:"replace"}),l===void 0&&n.push({item:s,type:"add",index:r})}for(let[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function ls(e){return{id:e.id,type:"remove"}}var Lm=wi("React Flow","https://reactflow.dev/");function Tm(e,t,n={}){return Sp(e,t,{...n,onError:n.onError??Lm})}var ds=e=>cp(e),Bm=e=>gi(e);function Ui(e){return(0,L.forwardRef)(e)}var Gi=typeof window<"u"?L.useLayoutEffect:L.useEffect;function cs(e){let[t,n]=(0,L.useState)(BigInt(0)),[o]=(0,L.useState)(()=>Vm(()=>n(r=>r+BigInt(1))));return Gi(()=>{let r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Vm(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Ji=(0,L.createContext)(null);function Hm({children:e}){let t=pe(),n=(0,L.useCallback)(l=>{let{nodes:h=[],setNodes:u,hasDefaultNodes:c,onNodesChange:p,nodeLookup:d,fitViewQueued:m,onNodesChangeMiddlewareMap:f}=t.getState(),w=h;for(let x of l)w=typeof x=="function"?x(w):x;let y=is({items:w,lookup:d});for(let x of f.values())y=x(y);c&&u(w),y.length>0?p?.(y):m&&window.requestAnimationFrame(()=>{let{fitViewQueued:x,nodes:E,setNodes:v}=t.getState();x&&v(E)})},[]),o=cs(n),r=(0,L.useCallback)(l=>{let{edges:h=[],setEdges:u,hasDefaultEdges:c,onEdgesChange:p,edgeLookup:d}=t.getState(),m=h;for(let f of l)m=typeof f=="function"?f(m):f;c?u(m):p&&p(is({items:m,lookup:d}))},[]),s=cs(r),i=(0,L.useMemo)(()=>({nodeQueue:o,edgeQueue:s}),[]);return(0,I.jsx)(Ji.Provider,{value:i,children:e})}function Fm(){let e=(0,L.useContext)(Ji);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}var Wm=e=>!!e.panZoom;function Dt(){let e=Dm(),t=pe(),n=Fm(),o=de(Wm),r=(0,L.useMemo)(()=>{let s=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},h=p=>{let{nodeLookup:d,nodeOrigin:m}=t.getState(),f=ds(p)?p:d.get(p.id),w=f.parentId?Ni(f.position,f.measured,f.parentId,d,m):f.position,y={...f,position:w,width:f.measured?.width??f.width,height:f.measured?.height??f.height};return en(y)},u=(p,d,m={replace:!1})=>{i(f=>f.map(w=>{if(w.id===p){let y=typeof d=="function"?d(w):d;return m.replace&&ds(y)?y:{...w,...y}}return w}))},c=(p,d,m={replace:!1})=>{l(f=>f.map(w=>{if(w.id===p){let y=typeof d=="function"?d(w):d;return m.replace&&Bm(y)?y:{...w,...y}}return w}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>s(p)?.internals.userNode,getInternalNode:s,getEdges:()=>{let{edges:p=[]}=t.getState();return p.map(d=>({...d}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{let d=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...d])},addEdges:p=>{let d=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...d])},toObject:()=>{let{nodes:p=[],edges:d=[],transform:m}=t.getState(),[f,w,y]=m;return{nodes:p.map(x=>({...x})),edges:d.map(x=>({...x})),viewport:{x:f,y:w,zoom:y}}},deleteElements:async({nodes:p=[],edges:d=[]})=>{let{nodes:m,edges:f,onNodesDelete:w,onEdgesDelete:y,triggerNodeChanges:x,triggerEdgeChanges:E,onDelete:v,onBeforeDelete:b}=t.getState(),{nodes:j,edges:S}=await fp({nodesToRemove:p,edgesToRemove:d,nodes:m,edges:f,onBeforeDelete:b}),M=S.length>0,C=j.length>0;if(M){let _=S.map(ls);y?.(S),E(_)}if(C){let _=j.map(ls);w?.(j),x(_)}return(C||M)&&v?.({nodes:j,edges:S}),{deletedNodes:j,deletedEdges:S}},getIntersectingNodes:(p,d=!0,m)=>{let f=Lr(p),w=f?p:h(p),y=m!==void 0;return w?(m||t.getState().nodes).filter(x=>{let E=t.getState().nodeLookup.get(x.id);if(E&&!f&&(x.id===p.id||!E.internals.positionAbsolute))return!1;let v=en(y?x:E),b=Kn(v,w);return d&&b>0||b>=v.width*v.height||b>=w.width*w.height}):[]},isNodeIntersecting:(p,d,m=!0)=>{let f=Lr(p)?p:h(p);if(!f)return!1;let w=Kn(f,d);return m&&w>0||w>=d.width*d.height||w>=f.width*f.height},updateNode:u,updateNodeData:(p,d,m={replace:!1})=>{u(p,f=>{let w=typeof d=="function"?d(f):d;return m.replace?{...f,data:w}:{...f,data:{...f.data,...w}}},m)},updateEdge:c,updateEdgeData:(p,d,m={replace:!1})=>{c(p,f=>{let w=typeof d=="function"?d(f):d;return m.replace?{...f,data:w}:{...f,data:{...f.data,...w}}},m)},getNodesBounds:p=>{let{nodeLookup:d,nodeOrigin:m}=t.getState();return up(p,{nodeLookup:d,nodeOrigin:m})},getHandleConnections:({type:p,id:d,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}-${p}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:d,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}${p?d?`-${p}-${d}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{let d=t.getState().fitViewResolver??vp();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:d}),n.nodeQueue.push(m=>[...m]),d.promise}}},[]);return(0,L.useMemo)(()=>({...r,...e,viewportInitialized:o}),[o])}var us=e=>e.selected,Zm=typeof window<"u"?window:void 0;function Ym({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=pe(),{deleteElements:o}=Dt(),r=on(e,{actInsideInputWithModifier:!1}),s=on(t,{target:Zm});(0,L.useEffect)(()=>{if(r){let{edges:i,nodes:l}=n.getState();o({nodes:l.filter(us),edges:i.filter(us)}),n.setState({nodesSelectionActive:!1})}},[r]),(0,L.useEffect)(()=>{n.setState({multiSelectionActive:s})},[s])}function Xm(e){let t=pe();(0,L.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let o=ma(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",_e.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);let o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}var io={position:"absolute",width:"100%",height:"100%",top:0,left:0},qm=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Km({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:s=.5,panOnScrollMode:i=dt.Free,zoomOnDoubleClick:l=!0,panOnDrag:h=!0,defaultViewport:u,translateExtent:c,minZoom:p,maxZoom:d,zoomActivationKeyCode:m,preventScrolling:f=!0,children:w,noWheelClassName:y,noPanClassName:x,onViewportChange:E,isControlledViewport:v,paneClickDistance:b,selectionOnDrag:j}){let S=pe(),M=(0,L.useRef)(null),{userSelectionActive:C,lib:_,connectionInProgress:F}=de(qm,fe),O=on(m),R=(0,L.useRef)();Xm(M);let H=(0,L.useCallback)(g=>{E?.({x:g[0],y:g[1],zoom:g[2]}),v||S.setState({transform:g})},[E,v]);return(0,L.useEffect)(()=>{if(M.current){R.current=tm({domNode:M.current,minZoom:p,maxZoom:d,translateExtent:c,viewport:u,onDraggingChange:z=>S.setState(A=>A.paneDragging===z?A:{paneDragging:z}),onPanZoomStart:(z,A)=>{let{onViewportChangeStart:$,onMoveStart:B}=S.getState();B?.(z,A),$?.(A)},onPanZoom:(z,A)=>{let{onViewportChange:$,onMove:B}=S.getState();B?.(z,A),$?.(A)},onPanZoomEnd:(z,A)=>{let{onViewportChangeEnd:$,onMoveEnd:B}=S.getState();B?.(z,A),$?.(A)}});let{x:g,y:N,zoom:k}=R.current.getViewport();return S.setState({panZoom:R.current,transform:[g,N,k],domNode:M.current.closest(".react-flow")}),()=>{R.current?.destroy()}}},[]),(0,L.useEffect)(()=>{R.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:l,panOnDrag:h,zoomActivationKeyPressed:O,preventScrolling:f,noPanClassName:x,userSelectionActive:C,noWheelClassName:y,lib:_,onTransformChange:H,connectionInProgress:F,selectionOnDrag:j,paneClickDistance:b})},[e,t,n,o,r,s,i,l,h,O,f,x,C,y,_,H,F,j,b]),(0,I.jsx)("div",{className:"react-flow__renderer",ref:M,style:io,children:w})}var Um=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Gm(){let{userSelectionActive:e,userSelectionRect:t}=de(Um,fe);return e&&t?(0,I.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}var To=(e,t)=>n=>{n.target===t.current&&e?.(n)},Jm=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Qm({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Qt.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:l,onSelectionEnd:h,onPaneClick:u,onPaneContextMenu:c,onPaneScroll:p,onPaneMouseEnter:d,onPaneMouseMove:m,onPaneMouseLeave:f,children:w}){let y=(0,L.useRef)(0),x=pe(),{userSelectionActive:E,elementsSelectable:v,dragging:b,panBy:j,autoPanSpeed:S}=de(Jm,fe),M=v&&(e||E),C=(0,L.useRef)(null),_=(0,L.useRef)(),F=(0,L.useRef)(new Set),O=(0,L.useRef)(new Set),R=(0,L.useRef)(!1),H=(0,L.useRef)(!1),g=(0,L.useRef)({x:0,y:0}),N=(0,L.useRef)(!1),k=T=>{if(H.current||R.current||x.getState().connection.inProgress){H.current=!1,R.current=!1;return}u?.(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},z=T=>{if(Array.isArray(o)&&o?.includes(2)){T.preventDefault();return}c?.(T)},A=p?T=>p(T):void 0,$=T=>{H.current&&(T.stopPropagation(),H.current=!1)},B=T=>{if(T.pointerType==="touch"&&o!==!1&&!t)return;let{domNode:K,transform:oe}=x.getState();if(_.current=K?.getBoundingClientRect(),!_.current)return;let ie=T.target===C.current;if(!ie&&T.target.closest(".nokey")||!e||!(i&&ie||t)||T.button!==0||!T.isPrimary)return;T.target?.setPointerCapture?.(T.pointerId),H.current=!1;let{x:q,y:se}=Oe(T.nativeEvent,_.current),re=un({x:q,y:se},oe);x.setState({userSelectionRect:{width:0,height:0,startX:re.x,startY:re.y,x:q,y:se}}),ie||(T.stopPropagation(),T.preventDefault())};function V(T,K){let{userSelectionRect:oe}=x.getState();if(!oe)return;let{transform:ie,nodeLookup:q,edgeLookup:se,connectionLookup:re,triggerNodeChanges:le,triggerEdgeChanges:ce,defaultEdgeOptions:ge}=x.getState(),je={x:oe.startX,y:oe.startY},{x:Ee,y:Me}=Pt(je,ie),be={startX:je.x,startY:je.y,x:T<Ee?T:Ee,y:K<Me?K:Me,width:Math.abs(T-Ee),height:Math.abs(K-Me)},Pe=F.current,Be=O.current;F.current=new Set(ua(q,be,ie,n===Qt.Partial,!0).map(Se=>Se.id)),O.current=new Set;let Ve=ge?.selectable??!0;for(let Se of F.current){let Ae=re.get(Se);if(Ae)for(let{edgeId:Ne}of Ae.values()){let we=se.get(Ne);we&&(we.selectable??Ve)&&O.current.add(Ne)}}if(!Tr(Pe,F.current)){let Se=St(q,F.current,!0);le(Se)}if(!Tr(Be,O.current)){let Se=St(se,O.current);ce(Se)}x.setState({userSelectionRect:be,userSelectionActive:!0,nodesSelectionActive:!1})}function W(){if(!r||!_.current)return;let[T,K]=ha(g.current,_.current,S);j({x:T,y:K}).then(oe=>{if(!H.current||!oe){y.current=requestAnimationFrame(W);return}let{x:ie,y:q}=g.current;V(ie,q),y.current=requestAnimationFrame(W)})}let J=()=>{cancelAnimationFrame(y.current),y.current=0,N.current=!1};(0,L.useEffect)(()=>()=>J(),[]);let X=T=>{let{userSelectionRect:K,transform:oe,resetSelectedElements:ie}=x.getState();if(!_.current||!K)return;let{x:q,y:se}=Oe(T.nativeEvent,_.current);g.current={x:q,y:se};let re=Pt({x:K.startX,y:K.startY},oe);if(!H.current){let le=t?0:s;if(Math.hypot(q-re.x,se-re.y)<=le)return;ie(),l?.(T)}H.current=!0,N.current||(W(),N.current=!0),V(q,se)},Z=T=>{if(!M){T.target===C.current&&x.getState().connection.inProgress&&(R.current=!0);return}T.button===0&&(T.target?.releasePointerCapture?.(T.pointerId),!E&&T.target===C.current&&x.getState().userSelectionRect&&k?.(T),x.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(h?.(T),x.setState({nodesSelectionActive:F.current.size>0})),J())},ee=T=>{T.target?.releasePointerCapture?.(T.pointerId),J()},Q=o===!0||Array.isArray(o)&&o.includes(0);return(0,I.jsxs)("div",{className:ve(["react-flow__pane",{draggable:Q,dragging:b,selection:e}]),onClick:M?void 0:To(k,C),onContextMenu:To(z,C),onWheel:To(A,C),onPointerEnter:M?void 0:d,onPointerMove:M?X:m,onPointerUp:Z,onPointerCancel:M?ee:void 0,onPointerDownCapture:M?B:void 0,onClickCapture:M?$:void 0,onPointerLeave:f,ref:C,style:io,children:[w,(0,I.jsx)(Gm,{})]})}function Qo({id:e,store:t,unselect:n=!1,nodeRef:o}){let{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:l,onError:h}=t.getState(),u=l.get(e);if(!u){h?.("012",_e.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Qi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,nodeClickDistance:i}){let l=pe(),[h,u]=(0,L.useState)(!1),c=(0,L.useRef)();return(0,L.useEffect)(()=>{if(!t)return c.current=Vp({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Qo({id:p,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{c.current?.destroy(),c.current=void 0}},[t,l,e]),(0,L.useEffect)(()=>{t||!e.current||!c.current||c.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:i})},[n,o,t,s,e,r,i]),h}var ef=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function el(){let e=pe();return(0,L.useCallback)(t=>{let{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:s,onError:i,updateNodePositions:l,nodeLookup:h,nodeOrigin:u}=e.getState(),c=new Map,p=ef(s),d=o?r[0]:5,m=o?r[1]:5,f=t.direction.x*d*t.factor,w=t.direction.y*m*t.factor;for(let[,y]of h){if(!p(y))continue;let x={x:y.internals.positionAbsolute.x+f,y:y.internals.positionAbsolute.y+w};o&&(x=cn(x,r));let{position:E,positionAbsolute:v}=xi({nodeId:y.id,nextPosition:x,nodeLookup:h,nodeExtent:n,nodeOrigin:u,onError:i});y.position=E,y.internals.positionAbsolute=v,c.set(y.id,y)}l(c)},[])}var ba=(0,L.createContext)(null),tf=ba.Provider;ba.Consumer;var tl=()=>(0,L.useContext)(ba),nf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),nl=(0,L.createContext)(null);function of({children:e}){let t=de(nf,fe);return(0,I.jsx)(nl.Provider,{value:t,children:e})}function af(){let e=(0,L.useContext)(nl);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}var rf={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},sf=(e,t,n)=>o=>{let{connectionClickStartHandle:r,connectionMode:s,connection:i}=o,{fromHandle:l,toHandle:h,isValid:u}=i;if(!l&&!r)return rf;let c=h?.nodeId===e&&h?.id===t&&h?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:c,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:s===zt.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!r,valid:c&&u}};function lf({type:e="source",position:t=U.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:h,className:u,onMouseDown:c,onTouchStart:p,...d},m){let f=i||null,w=e==="target",y=pe(),x=tl(),{connectOnClick:E,noPanClassName:v,rfId:b}=af(),{connectingFrom:j,connectingTo:S,clickConnecting:M,isPossibleEndHandle:C,connectionInProcess:_,clickConnectionInProcess:F,valid:O}=de(sf(x,f,e),fe);x||y.getState().onError?.("010",_e.error010());let R=N=>{let{defaultEdgeOptions:k,onConnect:z,hasDefaultEdges:A}=y.getState(),$={...k,...N};if(A){let{edges:B,setEdges:V,onError:W}=y.getState();V(Tm($,B,{onError:W}))}z?.($),l?.($)},H=N=>{if(!x)return;let k=$i(N.nativeEvent);if(r&&(k&&N.button===0||!k)){let z=y.getState();Jo.onPointerDown(N.nativeEvent,{handleDomNode:N.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:w,handleId:f,nodeId:x,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...A)=>y.getState().onConnectEnd?.(...A),updateConnection:z.updateConnection,onConnect:R,isValidConnection:n||((...A)=>y.getState().isValidConnection?.(...A)??!0),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}k?c?.(N):p?.(N)},g=N=>{let{onClickConnectStart:k,onClickConnectEnd:z,connectionClickStartHandle:A,connectionMode:$,isValidConnection:B,lib:V,rfId:W,nodeLookup:J,connection:X}=y.getState();if(!x||!A&&!r)return;if(!A){k?.(N.nativeEvent,{nodeId:x,handleId:f,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:x,type:e,id:f}});return}let Z=Si(N.target),ee=n||B,{connection:Q,isValid:T}=Jo.isValid(N.nativeEvent,{handle:{nodeId:x,id:f,type:e},connectionMode:$,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:ee,flowId:W,doc:Z,lib:V,nodeLookup:J});T&&Q&&R(Q);let K=structuredClone(X);delete K.inProgress,K.toPosition=K.toHandle?K.toHandle.position:null,z?.(N,K),y.setState({connectionClickStartHandle:null})};return(0,I.jsx)("div",{"data-handleid":f,"data-nodeid":x,"data-handlepos":t,"data-id":`${b}-${x}-${f}-${e}`,className:ve(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,u,{source:!w,target:w,connectable:o,connectablestart:r,connectableend:s,clickconnecting:M,connectingfrom:j,connectingto:S,valid:O,connectionindicator:o&&(!_||C)&&(_||F?s:r)}]),onMouseDown:H,onTouchStart:H,onClick:E?g:void 0,ref:m,...d,children:h})}var Ke=(0,L.memo)(Ui(lf));function df({data:e,isConnectable:t,sourcePosition:n=U.Bottom}){return(0,I.jsxs)(I.Fragment,{children:[e?.label,(0,I.jsx)(Ke,{type:"source",position:n,isConnectable:t})]})}function cf({data:e,isConnectable:t,targetPosition:n=U.Top,sourcePosition:o=U.Bottom}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ke,{type:"target",position:n,isConnectable:t}),e?.label,(0,I.jsx)(Ke,{type:"source",position:o,isConnectable:t})]})}function uf(){return null}function hf({data:e,isConnectable:t,targetPosition:n=U.Top}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ke,{type:"target",position:n,isConnectable:t}),e?.label]})}var Un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hs={input:df,default:cf,output:hf,group:uf};function pf(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var mf=e=>{let{width:t,height:n,x:o,y:r}=dn(e.nodeLookup,{filter:s=>!!s.selected});return{width:Re(t)?t:null,height:Re(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function ff({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let o=pe(),{width:r,height:s,transformString:i,userSelectionActive:l}=de(mf,fe),h=el(),u=(0,L.useRef)(null);(0,L.useEffect)(()=>{n||u.current?.focus({preventScroll:!0})},[n]);let c=!l&&r!==null&&s!==null;if(Qi({nodeRef:u,disabled:!c}),!c)return null;let p=e?m=>{let f=o.getState().nodes.filter(w=>w.selected);e(m,f)}:void 0,d=m=>{Object.prototype.hasOwnProperty.call(Un,m.key)&&(m.preventDefault(),h({direction:Un[m.key],factor:m.shiftKey?4:1}))};return(0,I.jsx)("div",{className:ve(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:(0,I.jsx)("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:s}})})}var ps=typeof window<"u"?window:void 0,gf=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ol({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:h,selectionKeyCode:u,selectionOnDrag:c,selectionMode:p,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:f,panActivationKeyCode:w,zoomActivationKeyCode:y,elementsSelectable:x,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:b,panOnScrollSpeed:j,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:C,autoPanOnSelection:_,defaultViewport:F,translateExtent:O,minZoom:R,maxZoom:H,preventScrolling:g,onSelectionContextMenu:N,noWheelClassName:k,noPanClassName:z,disableKeyboardA11y:A,onViewportChange:$,isControlledViewport:B}){let{nodesSelectionActive:V,userSelectionActive:W}=de(gf,fe),J=on(u,{target:ps}),X=on(w,{target:ps}),Z=X||C,ee=X||b,Q=c&&Z!==!0,T=J||W||Q;return Ym({deleteKeyCode:h,multiSelectionKeyCode:f}),(0,I.jsx)(Km,{onPaneContextMenu:s,elementsSelectable:x,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:ee,panActivationKeyPressed:X,panOnScrollSpeed:j,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:!J&&Z,defaultViewport:F,translateExtent:O,minZoom:R,maxZoom:H,zoomActivationKeyCode:y,preventScrolling:g,noWheelClassName:k,noPanClassName:z,onViewportChange:$,isControlledViewport:B,paneClickDistance:l,selectionOnDrag:Q,children:(0,I.jsxs)(Qm,{onSelectionStart:d,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:Z,autoPanOnSelection:_,isSelecting:!!T,selectionMode:p,selectionKeyPressed:J,paneClickDistance:l,selectionOnDrag:Q,children:[e,V&&(0,I.jsx)(ff,{onSelectionContextMenu:N,noPanClassName:z,disableKeyboardA11y:A})]})})}ol.displayName="FlowRenderer";var xf=(0,L.memo)(ol),vf=e=>t=>e?ua(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 yf(e){return de((0,L.useCallback)(vf(e),[e]),fe)}var bf=e=>e.updateNodeInternals;function wf(){let e=de(bf),[t]=(0,L.useState)(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{let o=new Map;n.forEach(r=>{let s=r.target.getAttribute("data-id");o.set(s,{id:s,nodeElement:r.target,force:!0})}),e(o)}));return(0,L.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function jf({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){let r=pe(),s=(0,L.useRef)(null),i=(0,L.useRef)(null),l=(0,L.useRef)(e.sourcePosition),h=(0,L.useRef)(e.targetPosition),u=(0,L.useRef)(t),c=n&&!!e.internals.handleBounds;return(0,L.useEffect)(()=>{s.current&&!e.hidden&&(!c||i.current!==s.current)&&(i.current&&o?.unobserve(i.current),o?.observe(s.current),i.current=s.current)},[c,e.hidden]),(0,L.useEffect)(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),(0,L.useEffect)(()=>{if(s.current){let p=u.current!==t,d=l.current!==e.sourcePosition,m=h.current!==e.targetPosition;(p||d||m)&&(u.current=t,l.current=e.sourcePosition,h.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function Nf({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:s,onDoubleClick:i,nodesDraggable:l,elementsSelectable:h,nodesConnectable:u,nodesFocusable:c,resizeObserver:p,noDragClassName:d,noPanClassName:m,disableKeyboardA11y:f,rfId:w,nodeTypes:y,nodeClickDistance:x,onError:E}){let{node:v,internals:b,isParent:j}=de(T=>{let K=T.nodeLookup.get(e),oe=T.parentLookup.has(e);return{node:K,internals:K.internals,isParent:oe}},fe),S=v.type||"default",M=y?.[S]||hs[S];M===void 0&&(E?.("003",_e.error003(S)),S="default",M=y?.default||hs.default);let C=!!(v.draggable||l&&typeof v.draggable>"u"),_=!!(v.selectable||h&&typeof v.selectable>"u"),F=!!(v.connectable||u&&typeof v.connectable>"u"),O=!!(v.focusable||c&&typeof v.focusable>"u"),R=pe(),H=ji(v),g=jf({node:v,nodeType:S,hasDimensions:H,resizeObserver:p}),N=Qi({nodeRef:g,disabled:v.hidden||!C,noDragClassName:d,handleSelector:v.dragHandle,nodeId:e,isSelectable:_,nodeClickDistance:x}),k=el();if(v.hidden)return null;let z=Te(v),A=pf(v),$=_||C||t||n||o||r,B=n?T=>n(T,{...b.userNode}):void 0,V=o?T=>o(T,{...b.userNode}):void 0,W=r?T=>r(T,{...b.userNode}):void 0,J=s?T=>s(T,{...b.userNode}):void 0,X=i?T=>i(T,{...b.userNode}):void 0,Z=T=>{let{selectNodesOnDrag:K,nodeDragThreshold:oe}=R.getState();_&&(!K||!C||oe>0)&&Qo({id:e,store:R,nodeRef:g}),t&&t(T,{...b.userNode})},ee=T=>{if(!(Ci(T.nativeEvent)||f)){if(pi.includes(T.key)&&_){let K=T.key==="Escape";Qo({id:e,store:R,unselect:K,nodeRef:g})}else if(C&&v.selected&&Object.prototype.hasOwnProperty.call(Un,T.key)){T.preventDefault();let{ariaLabelConfig:K}=R.getState();R.setState({ariaLiveMessage:K["node.a11yDescription.ariaLiveMessage"]({direction:T.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),k({direction:Un[T.key],factor:T.shiftKey?4:1})}}},Q=()=>{if(f||!g.current?.matches(":focus-visible"))return;let{transform:T,width:K,height:oe,autoPanOnNodeFocus:ie,setCenter:q}=R.getState();ie&&(ua(new Map([[e,v]]),{x:0,y:0,width:K,height:oe},T,!0).length>0||q(v.position.x+z.width/2,v.position.y+z.height/2,{zoom:T[2]}))};return(0,I.jsx)("div",{className:ve(["react-flow__node",`react-flow__node-${S}`,{[m]:C},v.className,{selected:v.selected,selectable:_,parent:j,draggable:C,dragging:N}]),ref:g,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:H?"visible":"hidden",...v.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:V,onMouseLeave:W,onContextMenu:J,onClick:Z,onDoubleClick:X,onKeyDown:O?ee:void 0,tabIndex:O?0:void 0,onFocus:O?Q:void 0,role:v.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":f?void 0:`${Zi}-${w}`,"aria-label":v.ariaLabel,...v.domAttributes,children:(0,I.jsx)(tf,{value:e,children:(0,I.jsx)(M,{id:e,data:v.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:v.selected??!1,selectable:_,draggable:C,deletable:v.deletable??!0,isConnectable:F,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:N,dragHandle:v.dragHandle,zIndex:b.z,parentId:v.parentId,...z})})})}var kf=(0,L.memo)(Nf),Sf=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function al(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=de(Sf,fe),s=yf(e.onlyRenderVisibleElements),i=wf();return(0,I.jsx)("div",{className:"react-flow__nodes",style:io,children:s.map(l=>(0,I.jsx)(kf,{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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},l))})}al.displayName="NodeRenderer";var Cf=(0,L.memo)(al);function $f(e){return de((0,L.useCallback)(t=>{if(!e)return t.edges.map(o=>o.id);let n=[];if(t.width&&t.height)for(let o of t.edges){let r=t.nodeLookup.get(o.source),s=t.nodeLookup.get(o.target);r&&s&&jp({sourceNode:r,targetNode:s,width:t.width,height:t.height,transform:t.transform})&&n.push(o.id)}return n},[e]),fe)}var Ef=({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,I.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Mf=({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,I.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ms={[Xe.Arrow]:Ef,[Xe.ArrowClosed]:Mf};function zf(e){let t=pe();return(0,L.useMemo)(()=>Object.prototype.hasOwnProperty.call(ms,e)?ms[e]:(t.getState().onError?.("009",_e.error009(e)),null),[e])}var _f=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{let h=zf(t);return h?(0,I.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0",children:(0,I.jsx)(h,{color:n,strokeWidth:i})}):null},rl=({defaultColor:e,rfId:t})=>{let n=de(s=>s.edges),o=de(s=>s.defaultEdgeOptions),r=(0,L.useMemo)(()=>zp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?(0,I.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,I.jsx)("defs",{children:r.map(s=>(0,I.jsx)(_f,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};rl.displayName="MarkerDefinitions";var Pf=(0,L.memo)(rl);function sl({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:h,className:u,...c}){let[p,d]=(0,L.useState)({x:1,y:0,width:0,height:0}),m=ve(["react-flow__edge-textwrapper",u]),f=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(f.current){let w=f.current.getBBox();d({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?(0,I.jsxs)("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...c,children:[r&&(0,I.jsx)("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),(0,I.jsx)("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:o,children:n}),h]}):null}sl.displayName="EdgeText";var Af=(0,L.memo)(sl);function hn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:h,interactionWidth:u=20,...c}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("path",{...c,d:e,fill:"none",className:ve(["react-flow__edge-path",c.className])}),u?(0,I.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,o&&Re(t)&&Re(n)?(0,I.jsx)(Af,{x:t,y:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:h}):null]})}function fs({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===U.Left||e===U.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function il({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top}){let[i,l]=fs({pos:n,x1:e,y1:t,x2:o,y2:r}),[h,u]=fs({pos:s,x1:o,y1:r,x2:e,y2:t}),[c,p,d,m]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:l,targetControlX:h,targetControlY:u});return[`M${e},${t} C${i},${l} ${h},${u} ${o},${r}`,c,p,d,m]}function ll(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:x})=>{let[E,v,b]=il({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),j=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:j,path:E,labelX:v,labelY:b,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:x})})}var If=ll({isInternal:!1}),dl=ll({isInternal:!0});If.displayName="SimpleBezierEdge";dl.displayName="SimpleBezierEdgeInternal";function cl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,sourcePosition:m=U.Bottom,targetPosition:f=U.Top,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:E})=>{let[v,b,j]=nn({sourceX:n,sourceY:o,sourcePosition:m,targetX:r,targetY:s,targetPosition:f,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),S=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:S,path:v,labelX:b,labelY:j,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:w,markerStart:y,interactionWidth:E})})}var ul=cl({isInternal:!1}),hl=cl({isInternal:!0});ul.displayName="SmoothStepEdge";hl.displayName="SmoothStepEdgeInternal";function pl(e){return(0,L.memo)(({id:t,...n})=>{let o=e.isInternal?void 0:t;return(0,I.jsx)(ul,{...n,id:o,pathOptions:(0,L.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Df=pl({isInternal:!1}),ml=pl({isInternal:!0});Df.displayName="StepEdge";ml.displayName="StepEdgeInternal";function fl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:f,interactionWidth:w})=>{let[y,x,E]=_i({sourceX:n,sourceY:o,targetX:r,targetY:s}),v=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:v,path:y,labelX:x,labelY:E,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:f,interactionWidth:w})})}var Rf=fl({isInternal:!1}),gl=fl({isInternal:!0});Rf.displayName="StraightEdge";gl.displayName="StraightEdgeInternal";function xl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i=U.Bottom,targetPosition:l=U.Top,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:E})=>{let[v,b,j]=Mi({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:l,curvature:x?.curvature}),S=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:S,path:v,labelX:b,labelY:j,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:E})})}var Of=xl({isInternal:!1}),vl=xl({isInternal:!0});Of.displayName="BezierEdge";vl.displayName="BezierEdgeInternal";var gs={default:vl,straight:gl,step:ml,smoothstep:hl,simplebezier:dl},xs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Lf=(e,t,n)=>n===U.Left?e-t:n===U.Right?e+t:e,Tf=(e,t,n)=>n===U.Top?e-t:n===U.Bottom?e+t:e,vs="react-flow__edgeupdater";function ys({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:i,type:l}){return(0,I.jsx)("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:i,className:ve([vs,`${vs}-${l}`]),cx:Lf(t,o,e),cy:Tf(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Bf({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:s,targetY:i,sourcePosition:l,targetPosition:h,onReconnect:u,onReconnectStart:c,onReconnectEnd:p,setReconnecting:d,setUpdateHover:m}){let f=pe(),w=(b,j)=>{if(b.button!==0)return;let{autoPanOnConnect:S,domNode:M,connectionMode:C,connectionRadius:_,lib:F,onConnectStart:O,cancelConnection:R,nodeLookup:H,rfId:g,panBy:N,updateConnection:k}=f.getState(),z=j.type==="target",A=(V,W)=>{d(!1),p?.(V,n,j.type,W)},$=V=>u?.(n,V),B=(V,W)=>{d(!0),c?.(b,n,j.type),O?.(V,W)};Jo.onPointerDown(b.nativeEvent,{autoPanOnConnect:S,connectionMode:C,connectionRadius:_,domNode:M,handleId:j.id,nodeId:j.nodeId,nodeLookup:H,isTarget:z,edgeUpdaterType:j.type,lib:F,flowId:g,cancelConnection:R,panBy:N,isValidConnection:(...V)=>f.getState().isValidConnection?.(...V)??!0,onConnect:$,onConnectStart:B,onConnectEnd:(...V)=>f.getState().onConnectEnd?.(...V),onReconnectEnd:A,updateConnection:k,getTransform:()=>f.getState().transform,getFromHandle:()=>f.getState().connection.fromHandle,dragThreshold:f.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},y=b=>w(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=b=>w(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>m(!0),v=()=>m(!1);return(0,I.jsxs)(I.Fragment,{children:[(e===!0||e==="source")&&(0,I.jsx)(ys,{position:l,centerX:o,centerY:r,radius:t,onMouseDown:y,onMouseEnter:E,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&(0,I.jsx)(ys,{position:h,centerX:s,centerY:i,radius:t,onMouseDown:x,onMouseEnter:E,onMouseOut:v,type:"target"})]})}function Vf({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:s,onContextMenu:i,onMouseEnter:l,onMouseMove:h,onMouseLeave:u,reconnectRadius:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,rfId:f,edgeTypes:w,noPanClassName:y,onError:x,disableKeyboardA11y:E}){let v=de(q=>q.edgeLookup.get(e)),b=de(q=>q.defaultEdgeOptions);v=b?{...b,...v}:v;let j=v.type||"default",S=w?.[j]||gs[j];S===void 0&&(x?.("011",_e.error011(j)),j="default",S=w?.default||gs.default);let M=!!(v.focusable||t&&typeof v.focusable>"u"),C=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),_=!!(v.selectable||o&&typeof v.selectable>"u"),F=(0,L.useRef)(null),[O,R]=(0,L.useState)(!1),[H,g]=(0,L.useState)(!1),N=pe(),{zIndex:k=v.zIndex,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W}=de((0,L.useCallback)(q=>{let se=q.nodeLookup.get(v.source),re=q.nodeLookup.get(v.target);if(!se||!re)return xs;let le=Mp({id:e,sourceNode:se,targetNode:re,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:q.connectionMode,onError:x}),ce=wp({selected:v.selected,zIndex:v.zIndex,sourceNode:se,targetNode:re,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode});return{...le||xs,zIndex:ce}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex,x]),fe),J=(0,L.useMemo)(()=>v.markerStart?`url('#${Uo(v.markerStart,f)}')`:void 0,[v.markerStart,f]),X=(0,L.useMemo)(()=>v.markerEnd?`url('#${Uo(v.markerEnd,f)}')`:void 0,[v.markerEnd,f]);if(v.hidden||z===null||A===null||$===null||B===null)return null;let Z=q=>{let{addSelectedEdges:se,unselectNodesAndEdges:re,multiSelectionActive:le}=N.getState();_&&(N.setState({nodesSelectionActive:!1}),v.selected&&le?(re({nodes:[],edges:[v]}),F.current?.blur()):se([e])),r&&r(q,v)},ee=s?q=>{s(q,{...v})}:void 0,Q=i?q=>{i(q,{...v})}:void 0,T=l?q=>{l(q,{...v})}:void 0,K=h?q=>{h(q,{...v})}:void 0,oe=u?q=>{u(q,{...v})}:void 0,ie=q=>{if(!E&&pi.includes(q.key)&&_){let{unselectNodesAndEdges:se,addSelectedEdges:re}=N.getState();q.key==="Escape"?(F.current?.blur(),se({edges:[v]})):re([e])}};return(0,I.jsx)("svg",{style:{zIndex:k},children:(0,I.jsxs)("g",{className:ve(["react-flow__edge",`react-flow__edge-${j}`,v.className,y,{selected:v.selected,animated:v.animated,inactive:!_&&!r,updating:O,selectable:_}]),onClick:Z,onDoubleClick:ee,onContextMenu:Q,onMouseEnter:T,onMouseMove:K,onMouseLeave:oe,onKeyDown:M?ie:void 0,tabIndex:M?0:void 0,role:v.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":M?`${Yi}-${f}`:void 0,ref:F,...v.domAttributes,children:[!H&&(0,I.jsx)(S,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:_,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:J,markerEnd:X,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),C&&(0,I.jsx)(Bf,{edge:v,isReconnectable:C,reconnectRadius:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W,setUpdateHover:R,setReconnecting:g})]})})}var Hf=(0,L.memo)(Vf),Ff=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function yl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:h,onEdgeMouseLeave:u,onEdgeClick:c,reconnectRadius:p,onEdgeDoubleClick:d,onReconnectStart:m,onReconnectEnd:f,disableKeyboardA11y:w}){let{edgesFocusable:y,edgesReconnectable:x,elementsSelectable:E,onError:v}=de(Ff,fe),b=$f(t);return(0,I.jsxs)("div",{className:"react-flow__edges",children:[(0,I.jsx)(Pf,{defaultColor:e,rfId:n}),b.map(j=>(0,I.jsx)(Hf,{id:j,edgesFocusable:y,edgesReconnectable:x,elementsSelectable:E,noPanClassName:r,onReconnect:s,onContextMenu:i,onMouseEnter:l,onMouseMove:h,onMouseLeave:u,onClick:c,reconnectRadius:p,onDoubleClick:d,onReconnectStart:m,onReconnectEnd:f,rfId:n,onError:v,edgeTypes:o,disableKeyboardA11y:w},j))]})}yl.displayName="EdgeRenderer";var Wf=(0,L.memo)(yl),bs=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Zf({children:e}){let t=pe(),n=(0,L.useRef)(null),[o]=(0,L.useState)(()=>t.getState().transform);return Gi(()=>{let r=null,s=()=>{let i=t.getState().transform;r&&i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]||(r=i,n.current&&(n.current.style.transform=bs(i)))};return s(),t.subscribe(s)},[t]),(0,I.jsx)("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:bs(o)},children:e})}function Yf(e){let t=Dt(),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Xf=e=>e.panZoom?.syncViewport;function qf(e){let t=de(Xf),n=pe();return(0,L.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function ws(e){return e.connection.inProgress?{...e.connection,to:un(e.connection.to,e.transform)}:{...e.connection}}function Kf(e){return e?t=>{let n=ws(t);return e(n)}:ws}function Uf(e){let t=Kf(e);return de(t,fe)}var Gf=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Jf({containerStyle:e,style:t,type:n,component:o}){let{nodesConnectable:r,width:s,height:i,isValid:l,inProgress:h}=de(Gf,fe);return s&&r&&h?(0,I.jsx)("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:(0,I.jsx)("g",{className:ve(["react-flow__connection",ki(l)]),children:(0,I.jsx)(bl,{style:t,type:n,CustomComponent:o,isValid:l})})}):null}var bl=({style:e,type:t=at.Bezier,CustomComponent:n,isValid:o})=>{let{inProgress:r,from:s,fromNode:i,fromHandle:l,fromPosition:h,to:u,toNode:c,toHandle:p,toPosition:d,pointer:m}=Uf();if(!r)return;if(n)return(0,I.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:h,toPosition:d,connectionStatus:ki(o),toNode:c,toHandle:p,pointer:m});let f="",w={sourceX:s.x,sourceY:s.y,sourcePosition:h,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case at.Bezier:[f]=Mi(w);break;case at.SimpleBezier:[f]=il(w);break;case at.Step:[f]=nn({...w,borderRadius:0});break;case at.SmoothStep:[f]=nn(w);break;default:[f]=_i(w)}return(0,I.jsx)("path",{d:f,fill:"none",className:"react-flow__connection-path",style:e})};bl.displayName="ConnectionLine";var Qf={};function js(e=Qf){let t=(0,L.useRef)(e),n=pe();(0,L.useEffect)(()=>{},[e])}function eg(){let e=pe(),t=(0,L.useRef)(!1);(0,L.useEffect)(()=>{},[])}function wl({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:h,onNodeMouseLeave:u,onNodeContextMenu:c,onSelectionContextMenu:p,onSelectionStart:d,onSelectionEnd:m,connectionLineType:f,connectionLineStyle:w,connectionLineComponent:y,connectionLineContainerStyle:x,selectionKeyCode:E,selectionOnDrag:v,selectionMode:b,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:M,deleteKeyCode:C,onlyRenderVisibleElements:_,elementsSelectable:F,defaultViewport:O,translateExtent:R,minZoom:H,maxZoom:g,preventScrolling:N,defaultMarkerColor:k,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:$,panOnScrollSpeed:B,panOnScrollMode:V,zoomOnDoubleClick:W,panOnDrag:J,autoPanOnSelection:X,onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:Q,onPaneMouseLeave:T,onPaneScroll:K,onPaneContextMenu:oe,paneClickDistance:ie,nodeClickDistance:q,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:le,onEdgeMouseLeave:ce,reconnectRadius:ge,onReconnect:je,onReconnectStart:Ee,onReconnectEnd:Me,noDragClassName:be,noWheelClassName:Pe,noPanClassName:Be,disableKeyboardA11y:Ve,nodeExtent:Se,rfId:Ae,viewport:Ne,onViewportChange:we,nodesDraggable:vt}){return js(e),js(t),eg(),Yf(n),qf(Ne),(0,I.jsx)(xf,{onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:Q,onPaneMouseLeave:T,onPaneContextMenu:oe,onPaneScroll:K,paneClickDistance:ie,deleteKeyCode:C,selectionKeyCode:E,selectionOnDrag:v,selectionMode:b,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:M,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:W,panOnScroll:$,panOnScrollSpeed:B,panOnScrollMode:V,panOnDrag:J,autoPanOnSelection:X,defaultViewport:O,translateExtent:R,minZoom:H,maxZoom:g,onSelectionContextMenu:p,preventScrolling:N,noDragClassName:be,noWheelClassName:Pe,noPanClassName:Be,disableKeyboardA11y:Ve,onViewportChange:we,isControlledViewport:!!Ne,children:(0,I.jsxs)(Zf,{children:[(0,I.jsx)(Wf,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:je,onReconnectStart:Ee,onReconnectEnd:Me,onlyRenderVisibleElements:_,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:le,onEdgeMouseLeave:ce,reconnectRadius:ge,defaultMarkerColor:k,noPanClassName:Be,disableKeyboardA11y:Ve,rfId:Ae}),(0,I.jsx)(Jf,{style:w,type:f,component:y,containerStyle:x}),(0,I.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,I.jsx)(Cf,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:h,onNodeMouseLeave:u,onNodeContextMenu:c,nodeClickDistance:q,onlyRenderVisibleElements:_,noPanClassName:Be,noDragClassName:be,disableKeyboardA11y:Ve,nodeExtent:Se,rfId:Ae,nodesDraggable:vt}),(0,I.jsx)("div",{className:"react-flow__viewport-portal"})]})})}wl.displayName="GraphView";var tg=(0,L.memo)(wl),ng=wi("React Flow","https://reactflow.dev/"),Ns=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:p,zIndexMode:d="basic"}={})=>{let m=new Map,f=new Map,w=new Map,y=new Map,x=o??t??[],E=n??e??[],v=c??[0,0],b=p??Jt;Ii(w,y,x);let{nodesInitialized:j}=Go(E,m,f,{nodeOrigin:v,nodeExtent:b,zIndexMode:d}),S=[0,0,1];if(i&&r&&s){let M=dn(m,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:C,y:_,zoom:F}=pa(M,r,s,h,u,l?.padding??.1);S=[C,_,F]}return{rfId:"1",width:r??0,height:s??0,transform:S,nodes:E,nodesInitialized:j,nodeLookup:m,parentLookup:f,edges:x,edgeLookup:y,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:h,maxZoom:u,translateExtent:Jt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:zt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,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:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...fi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ng,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:mi,zIndexMode:d,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},og=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h,maxZoom:u,nodeOrigin:c,nodeExtent:p,zIndexMode:d})=>fm((m,f)=>{async function w(){let{nodeLookup:y,panZoom:x,fitViewOptions:E,fitViewResolver:v,width:b,height:j,minZoom:S,maxZoom:M}=f();x&&(await mp({nodes:y,width:b,height:j,panZoom:x,minZoom:S,maxZoom:M},E),v?.resolve(!0),m({fitViewResolver:null}))}return{...Ns({nodes:e,edges:t,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h,maxZoom:u,nodeOrigin:c,nodeExtent:p,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:y=>{let{nodeLookup:x,parentLookup:E,nodeOrigin:v,nodeExtent:b,elevateNodesOnSelect:j,fitViewQueued:S,zIndexMode:M,nodesSelectionActive:C}=f(),{nodesInitialized:_,hasSelectedNodes:F}=Go(y,x,E,{nodeOrigin:v,nodeExtent:b,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:M}),O=C&&F;S&&_?(w(),m({nodes:y,nodesInitialized:_,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):m({nodes:y,nodesInitialized:_,nodesSelectionActive:O})},setEdges:y=>{let{connectionLookup:x,edgeLookup:E}=f();Ii(x,E,y),m({edges:y})},setDefaultNodesAndEdges:(y,x)=>{if(y){let{setNodes:E}=f();E(y),m({hasDefaultNodes:!0})}if(x){let{setEdges:E}=f();E(x),m({hasDefaultEdges:!0})}},updateNodeInternals:y=>{let{triggerNodeChanges:x,nodeLookup:E,parentLookup:v,domNode:b,nodeOrigin:j,nodeExtent:S,debug:M,fitViewQueued:C,zIndexMode:_}=f(),{changes:F,updatedInternals:O}=Op(y,E,v,b,j,S,_);O&&(Ap(E,v,{nodeOrigin:j,nodeExtent:S,zIndexMode:_}),C?(w(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),F?.length>0&&(M&&console.log("React Flow: trigger node changes",F),x?.(F)))},updateNodePositions:(y,x=!1)=>{let E=[],v=[],{nodeLookup:b,triggerNodeChanges:j,connection:S,updateConnection:M,onNodesChangeMiddlewareMap:C}=f();for(let[_,F]of y){let O=b.get(_),R=!!(O?.expandParent&&O?.parentId&&F?.position),H={id:_,type:"position",position:R?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:x};if(O&&S.inProgress&&S.fromNode.id===O.id){let g=mt(O,S.fromHandle,U.Left,!0);M({...S,from:g})}R&&O.parentId&&E.push({id:_,parentId:O.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),v.push(H)}if(E.length>0){let{parentLookup:_,nodeOrigin:F}=f(),O=ya(E,b,_,F);v.push(...O)}for(let _ of C.values())v=_(v);j(v)},triggerNodeChanges:y=>{let{onNodesChange:x,setNodes:E,nodes:v,hasDefaultNodes:b,debug:j}=f();if(y?.length){if(b){let S=Ki(y,v);E(S)}j&&console.log("React Flow: trigger node changes",y),x?.(y)}},triggerEdgeChanges:y=>{let{onEdgesChange:x,setEdges:E,edges:v,hasDefaultEdges:b,debug:j}=f();if(y?.length){if(b){let S=Om(y,v);E(S)}j&&console.log("React Flow: trigger edge changes",y),x?.(y)}},addSelectedNodes:y=>{let{multiSelectionActive:x,edgeLookup:E,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:j}=f();if(x){let S=y.map(M=>st(M,!0));b(S);return}b(St(v,new Set([...y]),!0)),j(St(E))},addSelectedEdges:y=>{let{multiSelectionActive:x,edgeLookup:E,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:j}=f();if(x){let S=y.map(M=>st(M,!0));j(S);return}j(St(E,new Set([...y]))),b(St(v,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:x}={})=>{let{edges:E,nodes:v,nodeLookup:b,triggerNodeChanges:j,triggerEdgeChanges:S}=f(),M=y||v,C=x||E,_=[];for(let O of M){if(!O.selected)continue;let R=b.get(O.id);R&&(R.selected=!1),_.push(st(O.id,!1))}let F=[];for(let O of C)O.selected&&F.push(st(O.id,!1));j(_),S(F)},setMinZoom:y=>{let{panZoom:x,maxZoom:E}=f();x?.setScaleExtent([y,E]),m({minZoom:y})},setMaxZoom:y=>{let{panZoom:x,minZoom:E}=f();x?.setScaleExtent([E,y]),m({maxZoom:y})},setTranslateExtent:y=>{f().panZoom?.setTranslateExtent(y),m({translateExtent:y})},resetSelectedElements:()=>{let{edges:y,nodes:x,triggerNodeChanges:E,triggerEdgeChanges:v,elementsSelectable:b}=f();if(!b)return;let j=x.reduce((M,C)=>C.selected?[...M,st(C.id,!1)]:M,[]),S=y.reduce((M,C)=>C.selected?[...M,st(C.id,!1)]:M,[]);E(j),v(S)},setNodeExtent:y=>{let{nodes:x,nodeLookup:E,parentLookup:v,nodeOrigin:b,elevateNodesOnSelect:j,nodeExtent:S,zIndexMode:M}=f();y[0][0]===S[0][0]&&y[0][1]===S[0][1]&&y[1][0]===S[1][0]&&y[1][1]===S[1][1]||(Go(x,E,v,{nodeOrigin:b,nodeExtent:y,elevateNodesOnSelect:j,checkEquality:!1,zIndexMode:M}),m({nodeExtent:y}))},panBy:y=>{let{transform:x,width:E,height:v,panZoom:b,translateExtent:j}=f();return Lp({delta:y,panZoom:b,transform:x,translateExtent:j,width:E,height:v})},setCenter:async(y,x,E)=>{let{width:v,height:b,maxZoom:j,panZoom:S}=f();if(!S)return!1;let M=typeof E?.zoom<"u"?E.zoom:j;return await S.setViewport({x:v/2-y*M,y:b/2-x*M,zoom:M},{duration:E?.duration,ease:E?.ease,interpolate:E?.interpolate}),!0},cancelConnection:()=>{m({connection:{...fi}})},updateConnection:y=>{m({connection:y})},reset:()=>m({...Ns()})}},Object.is);function jl({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:s,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:h,fitView:u,nodeOrigin:c,nodeExtent:p,zIndexMode:d,children:m}){let[f]=(0,L.useState)(()=>og({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:u,minZoom:i,maxZoom:l,fitViewOptions:h,nodeOrigin:c,nodeExtent:p,zIndexMode:d}));return(0,I.jsx)(xm,{value:f,children:(0,I.jsx)(Hm,{children:(0,I.jsx)(of,{children:m})})})}function ag({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:s,height:i,fitView:l,fitViewOptions:h,minZoom:u,maxZoom:c,nodeOrigin:p,nodeExtent:d,zIndexMode:m}){return(0,L.useContext)(ro)?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsx)(jl,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:l,initialFitViewOptions:h,initialMinZoom:u,initialMaxZoom:c,nodeOrigin:p,nodeExtent:d,zIndexMode:m,children:e})}var rg={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function sg({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s,edgeTypes:i,onNodeClick:l,onEdgeClick:h,onInit:u,onMove:c,onMoveStart:p,onMoveEnd:d,onConnect:m,onConnectStart:f,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:S,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:_,onNodesDelete:F,onEdgesDelete:O,onDelete:R,onSelectionChange:H,onSelectionDragStart:g,onSelectionDrag:N,onSelectionDragStop:k,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:$,onBeforeDelete:B,connectionMode:V,connectionLineType:W=at.Bezier,connectionLineStyle:J,connectionLineComponent:X,connectionLineContainerStyle:Z,deleteKeyCode:ee="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:T=!1,selectionMode:K=Qt.Full,panActivationKeyCode:oe="Space",multiSelectionKeyCode:ie=tn()?"Meta":"Control",zoomActivationKeyCode:q=tn()?"Meta":"Control",snapToGrid:se,snapGrid:re,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ce,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ee,nodesFocusable:Me,nodeOrigin:be=Xi,edgesFocusable:Pe,edgesReconnectable:Be,elementsSelectable:Ve=!0,defaultViewport:Se=zm,minZoom:Ae=.5,maxZoom:Ne=2,translateExtent:we=Jt,preventScrolling:vt=!0,nodeExtent:Rt,defaultMarkerColor:pn="#b1b1b7",zoomOnScroll:mn=!0,zoomOnPinch:lo=!0,panOnScroll:co=!1,panOnScrollSpeed:fn=.5,panOnScrollMode:uo=dt.Free,zoomOnDoubleClick:Je=!0,panOnDrag:gn=!0,onPaneClick:ho,onPaneMouseEnter:po,onPaneMouseMove:mo,onPaneMouseLeave:fo,onPaneScroll:go,onPaneContextMenu:xo,paneClickDistance:Ot=1,nodeClickDistance:yt=0,children:Lt,onReconnect:P,onReconnectStart:G,onReconnectEnd:ae,onEdgeContextMenu:ze,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Vl,onEdgeMouseMove:Hl,onEdgeMouseLeave:Fl,reconnectRadius:Wl=10,onNodesChange:Zl,onEdgesChange:Yl,noDragClassName:Xl="nodrag",noWheelClassName:ql="nowheel",noPanClassName:ka="nopan",fitView:Sa,fitViewOptions:Ca,connectOnClick:Kl,attributionPosition:Ul,proOptions:Gl,defaultEdgeOptions:Jl,elevateNodesOnSelect:Ql=!0,elevateEdgesOnSelect:ed=!1,disableKeyboardA11y:$a=!1,autoPanOnConnect:td,autoPanOnNodeDrag:nd,autoPanOnSelection:od=!0,autoPanSpeed:ad,connectionRadius:rd,isValidConnection:sd,onError:id,style:ld,id:Ea,nodeDragThreshold:dd,connectionDragThreshold:cd,viewport:ud,onViewportChange:hd,width:pd,height:md,colorMode:fd="light",debug:gd,onScroll:Ma,ariaLabelConfig:xd,zIndexMode:za="basic",...vd},yd){let vo=Ea||"1",bd=Im(fd),wd=(0,L.useCallback)(_a=>{_a.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ma?.(_a)},[Ma]);return(0,I.jsx)("div",{"data-testid":"rf__wrapper",...vd,onScroll:wd,style:{...ld,...rg},ref:yd,className:ve(["react-flow",r,bd]),id:Ea,role:"application",children:(0,I.jsxs)(ag,{nodes:e,edges:t,width:pd,height:md,fitView:Sa,fitViewOptions:Ca,minZoom:Ae,maxZoom:Ne,nodeOrigin:be,nodeExtent:Rt,zIndexMode:za,children:[(0,I.jsx)(Am,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:f,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ee,nodesFocusable:Me,edgesFocusable:Pe,edgesReconnectable:Be,elementsSelectable:Ve,elevateNodesOnSelect:Ql,elevateEdgesOnSelect:ed,minZoom:Ae,maxZoom:Ne,nodeExtent:Rt,onNodesChange:Zl,onEdgesChange:Yl,snapToGrid:se,snapGrid:re,connectionMode:V,translateExtent:we,connectOnClick:Kl,defaultEdgeOptions:Jl,fitView:Sa,fitViewOptions:Ca,onNodesDelete:F,onEdgesDelete:O,onDelete:R,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:_,onSelectionDrag:N,onSelectionDragStart:g,onSelectionDragStop:k,onMove:c,onMoveStart:p,onMoveEnd:d,noPanClassName:ka,nodeOrigin:be,rfId:vo,autoPanOnConnect:td,autoPanOnNodeDrag:nd,autoPanSpeed:ad,onError:id,connectionRadius:rd,isValidConnection:sd,selectNodesOnDrag:ce,nodeDragThreshold:dd,connectionDragThreshold:cd,onBeforeDelete:B,debug:gd,ariaLabelConfig:xd,zIndexMode:za}),(0,I.jsx)(tg,{onInit:u,onNodeClick:l,onEdgeClick:h,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:i,connectionLineType:W,connectionLineStyle:J,connectionLineComponent:X,connectionLineContainerStyle:Z,selectionKeyCode:Q,selectionOnDrag:T,selectionMode:K,deleteKeyCode:ee,multiSelectionKeyCode:ie,panActivationKeyCode:oe,zoomActivationKeyCode:q,onlyRenderVisibleElements:le,defaultViewport:Se,translateExtent:we,minZoom:Ae,maxZoom:Ne,preventScrolling:vt,zoomOnScroll:mn,zoomOnPinch:lo,zoomOnDoubleClick:Je,panOnScroll:co,panOnScrollSpeed:fn,panOnScrollMode:uo,panOnDrag:gn,autoPanOnSelection:od,onPaneClick:ho,onPaneMouseEnter:po,onPaneMouseMove:mo,onPaneMouseLeave:fo,onPaneScroll:go,onPaneContextMenu:xo,paneClickDistance:Ot,nodeClickDistance:yt,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:$,onReconnect:P,onReconnectStart:G,onReconnectEnd:ae,onEdgeContextMenu:ze,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Vl,onEdgeMouseMove:Hl,onEdgeMouseLeave:Fl,reconnectRadius:Wl,defaultMarkerColor:pn,noDragClassName:Xl,noWheelClassName:ql,noPanClassName:ka,rfId:vo,disableKeyboardA11y:$a,nodeExtent:Rt,viewport:ud,onViewportChange:hd,nodesDraggable:ge}),(0,I.jsx)(Mm,{onSelectionChange:H}),Lt,(0,I.jsx)(km,{proOptions:Gl,position:Ul}),(0,I.jsx)(Nm,{rfId:vo,disableKeyboardA11y:$a})]})})}var ig=Ui(sg),lg=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function dg({children:e}){let t=de(lg);return t?(0,gm.createPortal)(e,t):null}var cg=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function ug(){return de(cg,fe)}var Fy=_e.error014();function hg({dimensions:e,lineWidth:t,variant:n,className:o}){return(0,I.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ve(["react-flow__background-pattern",n,o])})}function pg({radius:e,className:t}){return(0,I.jsx)("circle",{cx:e,cy:e,r:e,className:ve(["react-flow__background-pattern","dots",t])})}var Ue;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ue||(Ue={}));var mg={[Ue.Dots]:1,[Ue.Lines]:1,[Ue.Cross]:6},fg=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Nl({id:e,variant:t=Ue.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=0,color:i,bgColor:l,style:h,className:u,patternClassName:c}){let p=(0,L.useRef)(null),{transform:d,patternId:m}=de(fg,fe),f=o||mg[t],w=t===Ue.Dots,y=t===Ue.Cross,x=Array.isArray(n)?n:[n,n],E=[x[0]*d[2]||1,x[1]*d[2]||1],v=f*d[2],b=Array.isArray(s)?s:[s,s],j=y?[v,v]:E,S=[b[0]*d[2]+j[0]/2,b[1]*d[2]+j[1]/2],M=`${m}${e||""}`;return(0,I.jsxs)("svg",{className:ve(["react-flow__background",u]),style:{...h,...io,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[(0,I.jsx)("pattern",{id:M,x:d[0]%E[0],y:d[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:w?(0,I.jsx)(pg,{radius:v/2,className:c}):(0,I.jsx)(hg,{dimensions:j,lineWidth:r,variant:t,className:c})}),(0,I.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Nl.displayName="Background";var gg=(0,L.memo)(Nl);function xg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,I.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function vg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,I.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function yg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,I.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 bg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,I.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 wg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,I.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 In({children:e,className:t,...n}){return(0,I.jsx)("button",{type:"button",className:ve(["react-flow__controls-button",t]),...n,children:e})}var jg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function kl({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:h,className:u,children:c,position:p="bottom-left",orientation:d="vertical","aria-label":m}){let f=pe(),{isInteractive:w,minZoomReached:y,maxZoomReached:x,ariaLabelConfig:E}=de(jg,fe),{zoomIn:v,zoomOut:b,fitView:j}=Dt(),S=()=>{v(),s?.()},M=()=>{b(),i?.()},C=()=>{j(r),l?.()},_=()=>{f.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),h?.(!w)};return(0,I.jsxs)(so,{className:ve(["react-flow__controls",d==="horizontal"?"horizontal":"vertical",u]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??E["controls.ariaLabel"],children:[t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(In,{onClick:S,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:x,children:(0,I.jsx)(xg,{})}),(0,I.jsx)(In,{onClick:M,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:y,children:(0,I.jsx)(vg,{})})]}),n&&(0,I.jsx)(In,{className:"react-flow__controls-fitview",onClick:C,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:(0,I.jsx)(yg,{})}),o&&(0,I.jsx)(In,{className:"react-flow__controls-interactive",onClick:_,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:w?(0,I.jsx)(wg,{}):(0,I.jsx)(bg,{})}),c]})}kl.displayName="Controls";var Wy=(0,L.memo)(kl);function Ng({id:e,x:t,y:n,width:o,height:r,style:s,color:i,strokeColor:l,strokeWidth:h,className:u,borderRadius:c,shapeRendering:p,selected:d,onClick:m}){let{background:f,backgroundColor:w}=s||{},y=i||f||w;return(0,I.jsx)("rect",{className:ve(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:c,ry:c,width:o,height:r,style:{fill:y,stroke:l,strokeWidth:h},shapeRendering:p,onClick:m?x=>m(x,e):void 0})}var kg=(0,L.memo)(Ng),Sg=e=>e.nodes.map(t=>t.id),Bo=e=>e instanceof Function?e:()=>e;function Cg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:s=kg,onClick:i}){let l=de(Sg,fe),h=Bo(t),u=Bo(e),c=Bo(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return(0,I.jsx)(I.Fragment,{children:l.map(d=>(0,I.jsx)(Eg,{id:d,nodeColorFunc:h,nodeStrokeColorFunc:u,nodeClassNameFunc:c,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:s,onClick:i,shapeRendering:p},d))})}function $g({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:l,onClick:h}){let{node:u,x:c,y:p,width:d,height:m}=de(f=>{let w=f.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};let y=w.internals.userNode,{x,y:E}=w.internals.positionAbsolute,{width:v,height:b}=Te(y);return{node:y,x,y:E,width:v,height:b}},fe);return!u||u.hidden||!ji(u)?null:(0,I.jsx)(l,{x:c,y:p,width:d,height:m,style:u.style,selected:!!u.selected,className:o(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:s,shapeRendering:i,onClick:h,id:u.id})}var Eg=(0,L.memo)($g),Mg=(0,L.memo)(Cg),zg=200,_g=150,Pg=e=>!e.hidden,Ag=e=>{let 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]},n=!1;for(let o of e.nodeLookup.values())if(!o.hidden){n=!0;break}return{viewBB:t,boundingRect:n?yi(dn(e.nodeLookup,{filter:Pg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ks=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Ig=(e,t)=>ks(e.viewBB,t.viewBB)&&ks(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Dg="react-flow__minimap-desc";function Sl({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:h,maskColor:u,maskStrokeColor:c,maskStrokeWidth:p,position:d="bottom-right",onClick:m,onNodeClick:f,pannable:w=!1,zoomable:y=!1,ariaLabel:x,inversePan:E,zoomStep:v=1,offsetScale:b=5}){let j=pe(),S=(0,L.useRef)(null),{boundingRect:M,panZoom:C,viewBB:_,rfId:F,translateExtent:O,flowWidth:R,flowHeight:H,ariaLabelConfig:g}=de(Ag,Ig),N=e?.width??zg,k=e?.height??_g,z=M.width/N,A=M.height/k,$=Math.max(z,A),B=$*N,V=$*k,W=b*$,J=M.x-(B-M.width)/2-W,X=M.y-(V-M.height)/2-W,Z=B+W*2,ee=V+W*2,Q=`${Dg}-${F}`,T=(0,L.useRef)(0),K=(0,L.useRef)();T.current=$,(0,L.useEffect)(()=>{let re=j.getState().panZoom;if(S.current&&re)return K.current=Xp({domNode:S.current,panZoom:re,getTransform:()=>j.getState().transform,getViewScale:()=>T.current}),()=>{K.current?.destroy()}},[C]),(0,L.useEffect)(()=>{K.current?.update({translateExtent:O,width:R,height:H,inversePan:E,pannable:w,zoomStep:v,zoomable:y})},[w,y,E,v,O,R,H]);let oe=m?re=>{let[le,ce]=K.current?.pointer(re)||[0,0];m(re,{x:le,y:ce})}:void 0,ie=(0,L.useCallback)((re,le)=>{let ce=j.getState().nodeLookup.get(le).internals.userNode;f?.(re,ce)},[f]),q=f?ie:void 0,se=x??g["minimap.ariaLabel"];return(0,I.jsx)(so,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*$:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:ve(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,I.jsxs)("svg",{width:N,height:k,viewBox:`${J} ${X} ${Z} ${ee}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Q,ref:S,onClick:oe,children:[se&&(0,I.jsx)("title",{id:Q,children:se}),(0,I.jsx)(Mg,{onClick:q,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:l}),(0,I.jsx)("path",{className:"react-flow__minimap-mask",d:`M${J-W},${X-W}h${Z+W*2}v${ee+W*2}h${-Z-W*2}z
|
|
8
|
-
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Sl.displayName="MiniMap";var Zy=(0,L.memo)(Sl),Rg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Og={[ft.Line]:"right",[ft.Handle]:"bottom-right"};function Lg({nodeId:e,position:t,variant:n=ft.Handle,className:o,style:r=void 0,children:s,color:i,minWidth:l=10,minHeight:h=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:d,autoScale:m=!0,shouldResize:f,onResizeStart:w,onResize:y,onResizeEnd:x}){let E=tl(),v=typeof e=="string"?e:E,b=pe(),j=(0,L.useRef)(null),S=n===ft.Handle,M=de((0,L.useCallback)(Rg(S&&m),[S,m]),fe),C=(0,L.useRef)(null),_=t??Og[n];(0,L.useEffect)(()=>{if(!(!j.current||!v))return C.current||(C.current=lm({domNode:j.current,nodeId:v,getStoreItems:()=>{let{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,domNode:k}=b.getState();return{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,paneDomNode:k}},onChange:(O,R)=>{let{triggerNodeChanges:H,nodeLookup:g,parentLookup:N,nodeOrigin:k}=b.getState(),z=[],A={x:O.x,y:O.y},$=g.get(v);if($&&$.expandParent&&$.parentId){let B=$.origin??k,V=O.width??$.measured.width??0,W=O.height??$.measured.height??0,J={id:$.id,parentId:$.parentId,rect:{width:V,height:W,...Ni({x:O.x??$.position.x,y:O.y??$.position.y},{width:V,height:W},$.parentId,g,B)}},X=ya([J],g,N,k);z.push(...X),A.x=O.x?Math.max(B[0]*V,O.x):void 0,A.y=O.y?Math.max(B[1]*W,O.y):void 0}if(A.x!==void 0&&A.y!==void 0){let B={id:v,type:"position",position:{...A}};z.push(B)}if(O.width!==void 0&&O.height!==void 0){let B={id:v,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};z.push(B)}for(let B of R){let V={...B,type:"position"};z.push(V)}H(z)},onEnd:({width:O,height:R})=>{let H={id:v,type:"dimensions",resizing:!1,dimensions:{width:O,height:R}};b.getState().triggerNodeChanges([H])}})),C.current.update({controlPosition:_,boundaries:{minWidth:l,minHeight:h,maxWidth:u,maxHeight:c},keepAspectRatio:p,resizeDirection:d,onResizeStart:w,onResize:y,onResizeEnd:x,shouldResize:f}),()=>{C.current?.destroy()}},[_,l,h,u,c,p,w,y,x,f]);let F=_.split("-");return(0,I.jsx)("div",{className:ve(["react-flow__resize-control","nodrag",...F,n,o]),ref:j,style:{...r,scale:M,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:s})}var Ss=(0,L.memo)(Lg);function Tg({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:o,lineClassName:r,lineStyle:s,color:i,minWidth:l=10,minHeight:h=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:p=!1,autoScale:d=!0,shouldResize:m,onResizeStart:f,onResize:w,onResizeEnd:y}){return t?(0,I.jsxs)(I.Fragment,{children:[om.map(x=>(0,I.jsx)(Ss,{className:r,style:s,nodeId:e,position:x,variant:ft.Line,color:i,minWidth:l,minHeight:h,maxWidth:u,maxHeight:c,onResizeStart:f,keepAspectRatio:p,autoScale:d,shouldResize:m,onResize:w,onResizeEnd:y},x)),nm.map(x=>(0,I.jsx)(Ss,{className:n,style:o,nodeId:e,position:x,color:i,minWidth:l,minHeight:h,maxWidth:u,maxHeight:c,onResizeStart:f,keepAspectRatio:p,autoScale:d,shouldResize:m,onResize:w,onResizeEnd:y},x))]}):null}var D=et(Nt(),1),Cl=e=>`$${(e/1e6).toFixed(2)}`;function Bg(e){let t=e.trim().replace(/^\$/,"");if(t==="")return{ok:!0,value:null};let n=Number(t);return!/^\d+(\.\d{1,2})?$/.test(t)||n<=0||Math.round(n*1e6)>1e8?{ok:!1,message:`Give the budget in dollars, up to ${Cl(1e8)}, or leave it empty.`}:{ok:!0,value:Math.round(n*1e6)}}function Vg(e){let t=e.trim();if(t==="")return{ok:!0,value:null};let n=Number(t);return!/^\d+$/.test(t)||!Number.isInteger(n)||n<1||n>50?{ok:!1,message:"Give runs a day as 1 to 50, or leave it empty."}:{ok:!0,value:n}}var Cs=e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(e)),Hg=e=>`It covers ${e.length===1?"this schedule":"these schedules"} when ${e.length===1?"it fires":"they fire"} on time: ${e.map(t=>t.words).join("; ")}. Run now, and schedules added or changed later, wait for you.`;function $l(e,t){return[e===null?"No dollar cap per attempt.":`Each attempt may spend up to ${Cl(e)}.`,t===null?"No daily limit on runs.":`At most ${t} run${t===1?"":"s"} a day (UTC); after that, cards wait for you.`]}var Fg=e=>`Ends ${e} day${e===1?"":"s"} after you sign. Revoking it earlier is one click.`,a=et(_o(),1);function gt({name:e,size:t="sm"}){let n=[...e].reduce((r,s)=>(r*31+s.charCodeAt(0))%360,7),o=e.split(/[\s._-]+/).filter(Boolean).map(r=>r[0].toUpperCase()).slice(0,2).join("")||e.slice(0,2).toUpperCase();return(0,a.jsx)("span",{title:e,"aria-label":e,className:xe("inline-flex shrink-0 items-center justify-center rounded-full font-semibold text-white",t==="sm"?"size-5 text-[9px]":"size-7 text-[11px]"),style:{background:`hsl(${n} 45% 45%)`},children:o})}var At={slate:"var(--so-muted)",blue:"var(--so-info)",violet:"var(--so-ink)",amber:"var(--so-neutral-ink)",green:"var(--so-success)",rose:"var(--so-danger)"},Wg={slate:"Muted",blue:"Blue",violet:"Ink",amber:"Neutral",green:"Green",rose:"Red"},El={inbox:(0,a.jsx)(Xa,{className:"size-3.5","aria-hidden":"true"}),task:(0,a.jsx)(Za,{className:"size-3.5","aria-hidden":"true"}),report:(0,a.jsx)(Ja,{className:"size-3.5","aria-hidden":"true"}),approval:(0,a.jsx)(Ia,{className:"size-3.5","aria-hidden":"true"}),notify:(0,a.jsx)(qa,{className:"size-3.5","aria-hidden":"true"}),done:(0,a.jsx)(Fa,{className:"size-3.5","aria-hidden":"true"}),check:(0,a.jsx)(jo,{className:"size-3.5","aria-hidden":"true"}),"pull-request":(0,a.jsx)(wo,{className:"size-3.5","aria-hidden":"true"}),update:(0,a.jsx)(Ka,{className:"size-3.5","aria-hidden":"true"}),sort:(0,a.jsx)(yo,{className:"size-3.5","aria-hidden":"true"}),draft:(0,a.jsx)(Ga,{className:"size-3.5","aria-hidden":"true"}),request:(0,a.jsx)(Wa,{className:"size-3.5","aria-hidden":"true"}),email:(0,a.jsx)(No,{className:"size-3.5","aria-hidden":"true"}),tool:(0,a.jsx)(Oa,{className:"size-3.5","aria-hidden":"true"}),wait:(0,a.jsx)(Ya,{className:"size-3.5","aria-hidden":"true"}),subagent:(0,a.jsx)(Ba,{className:"size-3.5","aria-hidden":"true"}),send:(0,a.jsx)(Qa,{className:"size-3.5","aria-hidden":"true"}),choose:(0,a.jsx)(Pa,{className:"size-3.5","aria-hidden":"true"})};function wa({sorted:e}){return(0,a.jsxs)("span",{className:xe("inline-flex max-w-full items-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-mono-count leading-4 font-medium",!e.confident&&"text-foreground"),title:e.confident?"Sorted by Jev":"Jev wasn't sure","data-sort-chip":!0,children:[(0,a.jsx)(yo,{className:"size-3 shrink-0",style:{color:e.confident?At.violet:void 0},"aria-hidden":"true"}),(0,a.jsx)("span",{className:"truncate",children:e.confident?e.chip:`Not sure · ${e.chip}`})]})}var Ml={button:(0,a.jsx)(Ua,{className:"size-3.5","aria-hidden":"true"}),schedule:(0,a.jsx)(Va,{className:"size-3.5","aria-hidden":"true"}),github:(0,a.jsx)(wo,{className:"size-3.5","aria-hidden":"true"}),linear:(0,a.jsx)(Aa,{className:"size-3.5","aria-hidden":"true"}),flow:(0,a.jsx)(Ra,{className:"size-3.5","aria-hidden":"true"}),webhook:(0,a.jsx)(Da,{className:"size-3.5","aria-hidden":"true"}),email:(0,a.jsx)(No,{className:"size-3.5","aria-hidden":"true"}),chat:(0,a.jsx)(ko,{className:"size-3.5","aria-hidden":"true"})},Zg=()=>{try{return new URLSearchParams(window.location.search).get("browser")==="1"}catch{return!1}};async function me(e,t,n){let o=new URLSearchParams({csrf:n,...t});try{let r=await fetch(e,{method:"POST",body:o,credentials:"same-origin",headers:dr({accept:"application/json"}),signal:AbortSignal.timeout(2e4)}),s=await r.json();return{ok:s.ok===!0,said:typeof s.said=="string"?s.said:r.ok?"Done.":"That didn't go through.",...s.view===void 0?{}:{view:s.view},...s.reveal===void 0?{}:{reveal:s.reveal}}}catch{return{ok:!1,said:"That didn't go through. Check your connection and try again."}}}function Yg(e,t,n){let[o,r]=(0,D.useState)([]),s=(0,D.useRef)(e.live);s.current=e.live;let i=(0,D.useRef)(n.editing);i.current=n.editing;let l=(0,D.useRef)(!1),h=(0,D.useRef)(!1),u=(0,D.useRef)(void 0),c=e.flow.href,p=(0,D.useCallback)(async()=>{if(l.current||i.current){h.current=!0;return}l.current=!0,h.current=!1,window.clearTimeout(u.current);let d=!1;try{let m=await fetch(`${c}?format=json`,{credentials:"same-origin",headers:{accept:"application/json"}});if(m.ok){let f=await m.json();s.current=f.live,t(f),d=!0}}catch{}finally{l.current=!1}h.current?p():d||(u.current=window.setTimeout(()=>{document.visibilityState==="visible"&&p()},5e3))},[c,t]);return(0,D.useEffect)(()=>{!n.editing&&h.current&&p()},[n.editing,p]),(0,D.useEffect)(()=>()=>window.clearTimeout(u.current),[]),lr(ir("flow",e.flow.id,{card:n.card,editing:n.editing}),(d,m)=>{if(d==="change"){let f=m.at;(typeof f!="string"||f!==s.current)&&p()}else if(d==="reload")p();else if(d==="here"){let f=m.people;Array.isArray(f)&&r(f)}else(d==="gone"||d==="lost")&&r([])}),o}function Xg({others:e,cards:t}){if(e.length===0)return null;let n=s=>{if(s.editing)return"changing this flow";let i=s.cards.map(l=>t.find(h=>h.id===l)?.title).filter(l=>l!==void 0);return i.length===0?"looking at the flow":`looking at ${i.map(l=>`“${l}”`).join(", ")}`},o=e.map(s=>`${s.name} is ${n(s)}`).join(". "),r=e.find(s=>s.editing);return(0,a.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1.5","data-also-here":!0,role:"status","aria-label":`Also here: ${o}`,title:o,children:[(0,a.jsx)("span",{className:"flex -space-x-1.5",children:e.slice(0,4).map(s=>(0,a.jsx)("span",{className:"rounded-full ring-2 ring-card",children:(0,a.jsx)(gt,{name:s.name})},s.name))}),(0,a.jsx)("span",{className:"truncate text-caption text-muted-foreground font-normal",children:r!==void 0?`${r.name} is changing this flow`:e.length===1?`${e[0].name} is here`:`${e.length} others here`})]})}function qg({data:e,selected:t}){let{stage:n,cards:o,editing:r,canMove:s}=e,[i,l]=(0,D.useState)(!1),h=xe("fl-handle",!r&&"off");return(0,a.jsxs)("div",{className:xe("fl-zone-n",t&&r&&"selected",i&&"over"),onDragOver:u=>{!s||r||(u.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:u=>{l(!1);let c=Number(u.dataTransfer.getData("text/so-card"));c>0&&e.onDrop(c,n.id)},"data-zone":n.id,children:[r&&(0,a.jsx)(Tg,{isVisible:t,minWidth:220,minHeight:160,lineClassName:"fl-resize-line",handleClassName:"fl-resize-handle",onResizeEnd:(u,c)=>e.onResize(n.id,c)}),(0,a.jsx)(Ke,{type:"source",position:U.Right,id:"next",className:xe(h,"next"),isConnectable:r}),(0,a.jsx)(Ke,{type:"source",position:U.Bottom,id:"fail",className:xe(h,"fail"),style:{left:"75%"},isConnectable:r}),["Left","Right","Top","Bottom"].map(u=>(0,a.jsx)(Ke,{type:"target",position:U[u],id:`t-${u}`,className:h,isConnectable:r},`t-${u}`)),["Left","Right","Top","Bottom"].map(u=>(0,a.jsx)(Ke,{type:"source",position:U[u],id:`s-${u}`,className:"fl-handle route",isConnectable:!1},`s-${u}`)),(0,a.jsxs)("header",{className:"fl-zone-h",children:[(0,a.jsx)("span",{className:"fl-ico",style:{color:At[n.zone.color]??At.slate},children:El[n.kind]}),(0,a.jsxs)("span",{className:"fl-zone-t",children:[(0,a.jsx)("b",{children:n.title}),(0,a.jsxs)("span",{children:[e.kindLabel,e.start?" · new cards start here":"",e.subagent!==null?` · ${e.subagent}`:n.toOwner===!0?` · ${e.owner}`:n.approver?` · ${n.approver}`:""]})]}),o.length>0&&(0,a.jsx)(bt,{n:o.length,ink:o.some(u=>u.canDecide)})]}),e.browserLine!==null&&n.kind==="check"&&n.browser===!0&&!r&&(0,a.jsx)("p",{className:"fl-zone-br","data-zone-browser":!0,children:e.browserLine}),(0,a.jsxs)("ul",{className:"nowheel fl-zone-cards",children:[o.map(u=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",draggable:s&&!r,onDragStart:c=>{c.dataTransfer.setData("text/so-card",String(u.id)),c.dataTransfer.effectAllowed="move"},onClick:c=>e.onCard(u.id,c.currentTarget),className:xe("nodrag nopan fl-card",e.selectedCard===u.id&&"selected",u.canDecide&&"wait"),"data-card":u.id,children:[(0,a.jsxs)("span",{className:"fl-card-top",children:[(0,a.jsx)("span",{className:"fl-card-t",children:u.title}),(e.lookers[u.id]?.length??0)>0&&(0,a.jsx)("span",{className:"fl-faces","data-card-lookers":!0,title:`${e.lookers[u.id].join(" and ")} ${e.lookers[u.id].length===1?"is":"are"} looking at this`,children:e.lookers[u.id].slice(0,2).map(c=>(0,a.jsx)(gt,{name:c},c))})]}),u.sorted!==null&&(0,a.jsx)("span",{className:"fl-card-l",children:(0,a.jsx)(wa,{sorted:u.sorted})}),u.waiting!==null&&(0,a.jsx)("span",{className:xe("fl-card-l",u.canDecide||u.question?.mine?"mine":""),children:(0,a.jsx)("span",{children:u.canDecide?xn.card.sentence({}):u.question?.mine?`${u.question.from.split(" · ")[0]} asks you`:u.waiting})}),u.deadline!=null&&(0,a.jsx)("span",{className:"fl-card-l","data-card-deadline":!0,children:vn(u.deadline,Bt(),wt())}),(u.owner!==null||u.comments.length>0)&&(0,a.jsxs)("span",{className:"fl-card-foot",children:[u.owner!==null&&(0,a.jsx)(gt,{name:u.owner}),(0,a.jsx)("span",{className:"k-grow"}),u.comments.length>0&&(0,a.jsxs)("span",{className:"fl-card-c",children:[(0,a.jsx)(ko,{className:"size-3","aria-hidden":"true"}),u.comments.length]})]})]})},u.id)),o.length===0&&(0,a.jsx)("li",{className:"fl-zone-empty",children:r?n.kind==="done"?"":"Drag the dots to connect zones.":e.hidden>0?"":"No cards here."}),e.hidden>0&&(0,a.jsxs)("li",{className:"fl-zone-empty",children:[e.hidden," other card",e.hidden===1?"":"s"]})]})]})}var zl=48,_l=30;function Kg({data:e}){return(0,a.jsxs)("div",{className:"fl-trig-n","data-trigger-group":!0,children:[(0,a.jsx)(Ke,{type:"source",position:U.Right,id:"out",className:"fl-handle route",isConnectable:!1}),(0,a.jsxs)("div",{className:"fl-trig-h",style:{height:_l},children:[(0,a.jsx)(tr,{name:"bolt",small:!0}),"Starts cards"]}),e.triggers.map(t=>{let n=t.failing||t.hook!==null&&!t.hook.ready,o=t.state==="paused"?"Paused":t.failing?"Needs attention":t.hook!==null&&!t.hook.ready?"Needs its secret":t.detail;return(0,a.jsxs)("div",{className:xe("fl-trig",t.state==="paused"&&"paused"),style:{height:zl},"data-trigger":t.id,children:[(0,a.jsx)("span",{className:"fl-ico",children:Ml[t.kind]??(0,a.jsx)(bo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("span",{className:"fl-trig-b",children:[(0,a.jsx)(he,{variant:"ghost",sm:!0,label:t.name,className:"nodrag nopan","aria-label":`Trigger: ${t.words}`,onClick:r=>e.onOpen(t.id,r.currentTarget)}),(0,a.jsx)("span",{className:n?"bad":"",children:o})]}),t.button!==null&&t.state==="active"&&(0,a.jsx)(he,{sm:!0,label:"Start",className:"nodrag nopan",onClick:r=>e.onPress(t.id,r.currentTarget)})]},t.id)})]})}var Ug={zone:qg,trigger:Kg};function Gg({sourceX:e,sourceY:t,sourcePosition:n,targetX:o,targetY:r,targetPosition:s,label:i,labelStyle:l,labelBgStyle:h,markerEnd:u,style:c,data:p}){let{path:d,shift:m}=p??{},[f,w,y]=nn({sourceX:e,sourceY:t,sourcePosition:n,targetX:o,targetY:r,targetPosition:s,...d}),x=l;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(hn,{path:f,...u===void 0?{}:{markerEnd:u},...c===void 0?{}:{style:c}}),(0,a.jsx)(dg,{children:(0,a.jsx)("div",{className:"nodrag nopan pointer-events-none absolute rounded-sm px-1 leading-4 whitespace-nowrap",style:{transform:`translate(-50%, -50%) translate(${w+(m?.x??0)}px, ${y+(m?.y??0)}px)`,color:x?.fill,fontSize:x?.fontSize,fontWeight:x?.fontWeight,background:h?.fill},children:i})})]})}var Jg={named:Gg};function Qg(e,t){let n=(s,i)=>{let l=t.find(p=>p.id===s)?.zone;if(l===void 0||i==null)return null;let h=i.slice(2),u=h==="Left"?l.x:h==="Right"?l.x+l.w:l.x+l.w/2,c=h==="Top"?l.y:h==="Bottom"?l.y+l.h:l.y+l.h/2;return{x:u,y:c,position:U[h]}},o=[],r=s=>o.some(i=>Math.abs(i.x-s.x)<(i.w+s.w)/2+4&&Math.abs(i.y-s.y)<(i.h+s.h)/2+2);return e.map(s=>{if(typeof s.label!="string"||s.type!=="smoothstep")return s;let i=n(s.source,s.sourceHandle),l=n(s.target,s.targetHandle);if(i===null||l===null)return s;let h=s.pathOptions,[,u,c]=nn({sourceX:i.x,sourceY:i.y,sourcePosition:i.position,targetX:l.x,targetY:l.y,targetPosition:l.position,...h}),p=s.label.length*6.4+10,d=18,m=(i.position===U.Left||i.position===U.Right)&&(l.position===U.Left||l.position===U.Right)?{x:0,y:d+6}:{x:p/2+34,y:0},f={x:0,y:0};for(let x of[0,1,-1,2,-2,3,-3])if(f={x:m.x*x,y:m.y*x},!r({x:u+f.x,y:c+f.y,w:p,h:d}))break;o.push({x:u+f.x,y:c+f.y,w:p,h:d});let{pathOptions:w,...y}=s;return{...y,type:"named",data:{...s.data,path:h,shift:f}}})}function Pl(e,t){let n=[],o=new Set,r=s=>{for(;s!==null&&!o.has(s);){let i=e.find(l=>l.id===s);if(i===void 0)return;o.add(s),n.push(i);for(let l of i.sort?.answers??[])r(l.to);i.sort!==null&&i.onFail!==null&&r(i.onFail),s=i.next}};r(t);for(let s of e)o.has(s.id)||r(s.id);return[...n.filter(s=>s.kind!=="done"),...n.filter(s=>s.kind==="done")]}function e0(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,24)||"zone",o=n,r=2;for(;t.has(o);)o=`${n}-${r++}`;return o}var an=e=>So(e),t0=(e,t=Bt())=>Number.isNaN(new Date(e).getTime())?"":er(e,t,wt(),!0),n0=e=>e%1440===0?`${e/1440} day${e===1440?"":"s"}`:e%60===0?`${e/60} h`:`${e} min`;function o0({link:e}){return e===null?null:(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.href,"data-status-link":!0,children:e.label})]})}function a0({body:e,mentions:t}){if(t.length===0)return(0,a.jsx)(a.Fragment,{children:e});let n=new RegExp(`(@(?:${t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}))(?![A-Za-z0-9_])`,"gi");return(0,a.jsx)(a.Fragment,{children:e.split(n).map((o,r)=>r%2===1?(0,a.jsx)("span",{className:"font-semibold text-primary",children:o},r):o)})}function r0({card:e,view:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(""),[i,l]=(0,D.useState)(!1),h=/(?:^|\s)@([A-Za-z0-9_.-]*)$/.exec(r)?.[1],u=h===void 0?[]:t.approvers.filter(c=>c!==t.me&&c.toLowerCase().startsWith(h.toLowerCase())).slice(0,6);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-flow-discussion":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Discussion"}),e.comments.length===0?(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"No comments yet."}):(0,a.jsx)("ol",{className:"flex flex-col gap-3",children:e.comments.map(c=>(0,a.jsxs)("li",{className:"flex gap-2","data-comment":c.id,children:[(0,a.jsx)(gt,{name:c.author,size:"md"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[(0,a.jsx)("span",{className:"font-semibold text-foreground",children:c.author})," · ",an(c.at)]}),(0,a.jsx)("p",{className:"whitespace-pre-wrap break-words text-body",children:(0,a.jsx)(a0,{body:c.body,mentions:c.mentions})})]})]},c.id))}),t.canEdit&&(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async c=>{c.preventDefault(),l(!0);let p=await me(`${t.flow.href}/cards/${e.id}/comment`,{body:r},n);l(!1),o(p),p.ok&&s("")},children:[(0,a.jsx)(ye,{value:r,onChange:c=>s(c.target.value),rows:3,maxLength:4e3,placeholder:"Add a comment. Type @ and a name to ping someone.","aria-label":"Comment"}),u.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5","aria-label":"People to mention",children:u.map(c=>(0,a.jsxs)("button",{type:"button",className:"inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2 text-caption hover:border-primary/60 font-normal",onClick:()=>s(p=>p.replace(/@([A-Za-z0-9_.-]*)$/,`@${c} `)),children:[(0,a.jsx)(gt,{name:c}),c]},c))}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:i||r.trim()==="",children:"Comment"})]})]})}function s0({card:e,view:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(!1),i=async(h,u)=>{s(!0),o(await me(`${t.flow.href}/cards/${e.id}/${h}`,u,n)),s(!1)},l=e.watchers.filter(h=>h!==e.owner);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-flow-card-people":!0,children:[t.canEdit&&e.state==="active"?(0,a.jsxs)("label",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Owner"}),(0,a.jsxs)("select",{className:ue,value:e.owner??"",disabled:r,onChange:h=>{i("assign",{owner:h.target.value})},"aria-label":"Owner",children:[(0,a.jsx)("option",{value:"",children:"No owner"}),t.approvers.map(h=>(0,a.jsx)("option",{value:h,children:h===t.me?`${h} (you)`:h},h))]})]}):e.owner!==null&&(0,a.jsxs)("p",{className:"flex items-center gap-2 text-body",children:[(0,a.jsx)(gt,{name:e.owner})," Owned by ",e.owner]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[t.canEdit&&e.state==="active"&&e.owner===null&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:r,onClick:()=>{i("assign",{owner:t.me})},children:"Take it"}),l.length>0&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-caption text-muted-foreground font-normal",children:[l.slice(0,5).map(h=>(0,a.jsx)(gt,{name:h},h)),l.length===1?" follows it":" follow it"]}),t.canEdit&&e.owner!==t.me&&(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:r,onClick:()=>{i("watch",{watching:e.watching?"no":"yes"})},"aria-pressed":e.watching,children:e.watching?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(La,{className:"size-4"}),"Stop following"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Ta,{className:"size-4"}),"Follow"]})})]})]})}function Al({links:e}){return(0,a.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:e.map(t=>(0,a.jsx)("a",{className:"text-body text-primary underline-offset-4 hover:underline font-medium",href:t.href,...t.href.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:t.label},t.label))})}function Il({items:e}){return(0,a.jsx)("ol",{className:"flex flex-col gap-3","data-flow-items":!0,children:e.map(t=>(0,a.jsxs)("li",{className:"flex items-start gap-3","data-flow-item":t.number,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 text-[12.5px]",children:[(0,a.jsxs)("p",{className:"font-semibold",children:[t.number,". ",t.title]}),t.lines.map((n,o)=>(0,a.jsx)("p",{className:"break-words text-muted-foreground",children:n},o)),(0,a.jsx)("a",{className:"self-start font-medium text-primary underline-offset-4 hover:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.source})]}),t.image!==null&&(0,a.jsx)("a",{className:"w-28 shrink-0",href:t.image.src,target:"_blank",rel:"noreferrer",children:(0,a.jsx)("img",{className:"w-full rounded-md border object-cover object-top",style:{aspectRatio:"4 / 3"},src:t.image.src,alt:t.image.caption,loading:"lazy"})})]},t.number))})}function i0({sent:e}){return(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-flow-sent":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Sent to ",e.person," · ",an(e.at)]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e.title}),(0,a.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,a.jsx)(Il,{items:e.items}),e.card!==void 0&&(0,a.jsx)(Co,{card:e.card}),e.links.length>0&&(0,a.jsx)(Al,{links:e.links})]})]})}function l0({choose:e,base:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(""),[i,l]=(0,D.useState)(!1),h=async u=>{l(!0);let c=await me(`${t}/choose`,u,n);l(!1),o(c),c.ok&&s("")};return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-flow-choose":!0,children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e.title}),(0,a.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,a.jsx)(Il,{items:e.items}),e.links.length>0&&(0,a.jsx)(Al,{links:e.links}),e.mine?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map(u=>(0,a.jsx)(te,{size:"sm",variant:u.choice===0?"default":"outline",disabled:i,onClick:()=>{h({choice:String(u.choice),label:u.label,entry:String(e.entry)})},"data-flow-choice":u.choice,children:u.label},u.choice))}),e.reply&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ye,{value:r,onChange:u=>s(u.target.value),rows:2,maxLength:4e3,placeholder:"Or say what you'd change","aria-label":"What you'd change"}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:i||r.trim()==="",onClick:()=>{h({note:r,entry:String(e.entry)})},children:"Send reply"})]})]}):(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["Waiting for ",e.person," to choose."]})]})}function d0({card:e,view:t,csrf:n,apply:o,onAllowBrowser:r}){let[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(e.draft?.text??"");(0,D.useEffect)(()=>{h(e.draft?.text??"")},[e.id,e.draft?.text]);let[u,c]=(0,D.useState)(!1),p=t.stages.find(f=>f.id===e.stage),d=async(f,w)=>{c(!0);let y=await me(f,w,n);c(!1),o(y),y.ok&&i("")},m=`${t.flow.href}/cards/${e.id}`;return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-card-panel":e.id,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[e.state==="active"?`In ${p?.title??e.stage}`:e.state==="done"?"Done":e.waiting==="Ignored"?"Ignored":"Cancelled"," · added by ",e.createdBy]}),e.sorted!==null&&(0,a.jsx)("div",{className:"mt-1.5 flex",children:(0,a.jsx)(wa,{sorted:e.sorted})})]}),e.source!==null&&(e.source.shown!=null&&e.source.url!==null?(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal break-all",children:["From ",e.source.label,e.source.proved===void 0?null:` (${e.source.proved})`," · ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,target:"_blank",rel:"noopener noreferrer",children:e.source.shown})]}):(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["From ",e.source.url===null?e.source.label:(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,...e.source.url.startsWith("/")?{}:{target:"_blank",rel:"noopener noreferrer"},children:e.source.label}),e.source.proved===void 0?null:` (${e.source.proved})`]})),e.description!==null&&(0,a.jsx)("p",{className:"whitespace-pre-wrap text-body",children:e.description}),e.waiting!==null&&e.question==null&&e.choose==null&&e.state==="active"&&(0,a.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-body",children:[e.waiting,e.deadline!=null&&(0,a.jsx)("span",{className:"block text-muted-foreground",children:vn(e.deadline,Bt(),wt())})]}),e.browserWait===!0&&e.state==="active"&&t.canEdit&&t.browser?.canApprove!==!1&&(r!==void 0?(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start phone:min-h-11",onClick:r,"data-card-allow-browser":!0,children:"Allow browser"}):(0,a.jsx)("a",{className:"text-body font-medium text-primary underline-offset-4 hover:underline",href:`${t.flow.href}?browser=1`,"data-card-allow-browser":!0,children:"Allow browser"})),e.question!=null&&(0,a.jsx)(p0,{question:e.question,csrf:n,apply:o}),e.choose!=null&&(0,a.jsx)(l0,{choose:e.choose,base:`${t.flow.href}/cards/${e.id}`,csrf:n,apply:o}),e.sent!=null&&(0,a.jsx)(i0,{sent:e.sent}),e.result!==void 0&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:"What happened"}),(0,a.jsx)(Co,{card:e.result})]}),e.question!=null&&e.deadline!=null&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:vn(e.deadline,Bt(),wt())}),(0,a.jsx)(s0,{card:e,view:t,csrf:n,apply:o}),e.task!==null&&(0,a.jsx)("a",{className:"text-body text-primary underline-offset-4 hover:underline font-medium",href:e.task.href,children:"Open its task"}),e.task?.composer!=null&&(0,a.jsxs)("div",{className:"flex flex-col gap-1","data-flow-task-composer":!0,children:[(0,a.jsx)(jd,{controls:e.task.composer.controls,back:`flow:${t.flow.id}:${e.id}`}),e.task.composer.steer!==null&&(0,a.jsx)(Nd,{steer:e.task.composer.steer,controls:e.task.composer.controls,back:`flow:${t.flow.id}:${e.id}`},`${e.id}:${e.task.composer.steer.run}`)]}),e.draft!==null&&!e.canDecide&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",open:!0,"data-flow-draft":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Draft from ",e.draft.title]}),(0,a.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px]",children:e.draft.text})]}),e.canDecide&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3",children:[e.handoff!=null&&(0,a.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-body","data-subagent-handoff":!0,children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.handoff.from,":"]})," ",e.handoff.note]}),e.draft!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(Nn,{htmlFor:"flow-draft",className:"text-body",children:["Draft from ",e.draft.title]}),(0,a.jsx)(ye,{id:"flow-draft",value:l,onChange:f=>h(f.target.value),rows:8,maxLength:12e3,"data-flow-draft-edit":!0}),l.trim()!==e.draft.text.trim()&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"Approving sends your edited version on."})]}),(0,a.jsxs)(Nn,{htmlFor:"flow-note",className:"text-body",children:[p?.title??"Decision",": approve, or send it back"]}),(0,a.jsx)(ye,{id:"flow-note",value:s,onChange:f=>i(f.target.value),placeholder:"What should change? (needed to send it back)",rows:3}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(te,{size:"sm",disabled:u||e.draft!==null&&l.trim()==="",onClick:()=>{d(`${m}/decide`,{decision:"approve",note:s,...e.draft===null?{}:{draft:l}})},children:xn.card.action.label}),p?.onFail!==null&&p?.onFail!==void 0&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:u||s.trim()==="",onClick:()=>{d(`${m}/decide`,{decision:"send-back",note:s})},children:"Send back"})]})]}),t.canEdit&&e.state==="active"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(Nn,{htmlFor:"flow-move",className:"text-body",children:"Move to"}),(0,a.jsx)("select",{id:"flow-move",className:Dl,value:e.stage,disabled:u,onChange:f=>{d(`${m}/move`,{stage:f.target.value})},children:t.stages.map(f=>(0,a.jsx)("option",{value:f.id,children:f.title},f.id))})]}),(e.calls??[]).length>0&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-subagent-calls":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Tool calls (",e.calls.length,")"]}),(0,a.jsx)("ol",{className:"mt-2 flex flex-col gap-2.5",children:e.calls.map(f=>(0,a.jsxs)("li",{className:"flex flex-col gap-0.5 text-[12.5px]","data-subagent-call":f.state,children:[(0,a.jsxs)("span",{className:"break-words",children:[(0,a.jsx)("span",{className:"font-medium",children:f.who})," · ",f.words]}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[f.outcome,f.why!==""&&f.state!=="refused"?` · ${f.why}`:""]}),f.result!==null&&f.result!==""&&(f.state==="done"||f.state==="failed")&&(0,a.jsx)("span",{className:"mt-0.5 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted px-2 py-1 text-caption font-normal",children:f.result}),f.undo!=null&&f.subagent!==void 0&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"mt-1 self-start",disabled:u,"data-subagent-undo":f.id,onClick:()=>{d(`/settings/lead/subagents/${f.subagent}/week`,{op:"undo",id:String(f.id)})},children:["Undo with ",f.undo]})]},f.id))})]}),e.outputs.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"What zones reported"}),e.outputs.map(f=>(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:f.title}),(0,a.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px] text-muted-foreground",children:f.text})]},f.stage))]}),(0,a.jsx)(r0,{card:e,view:t,csrf:n,apply:o}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"History"}),(0,a.jsx)("ol",{className:"flex flex-col gap-1.5",children:e.history.map((f,w)=>(0,a.jsxs)("li",{className:"text-caption font-normal",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:t0(f.at)})," · ",f.text]},w))})]}),t.canEdit&&e.state==="active"&&(0,a.jsx)(te,{variant:"ghost",size:"sm",className:"self-start text-destructive",disabled:u,onClick:()=>{d(`${m}/cancel`,{})},children:"Cancel card"})]})}function Y({label:e,hint:t,children:n}){return(0,a.jsxs)("label",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:e}),n,t!==void 0&&(0,a.jsx)("span",{className:"text-caption text-muted-foreground font-normal",children:t})]})}var ue="h-9 w-full rounded-xl border border-transparent bg-field px-3 text-body",Dl="h-9 rounded-xl border border-transparent bg-field px-3 text-body",c0=[.95,.9,.85,.8,.7,.6];function u0({sort:e,others:t,ready:n,set:o}){let r=(i,l)=>o({...e,answers:e.answers.map((h,u)=>u===i?{...h,...l}:h)}),s=(i,l)=>o({...e,notes:e.notes.map((h,u)=>u===i?{...h,...l}:h)});return(0,a.jsxs)(a.Fragment,{children:[!n&&(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-sort-needs-key":!0,children:["Sorting needs an OpenRouter key. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/agents#providers",children:"Add it in Settings"})]}),(0,a.jsx)(Y,{label:"Question",children:(0,a.jsx)(ne,{value:e.question,maxLength:300,onChange:i=>o({...e,question:i.target.value}),"aria-label":"Question"})}),(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Answers"}),e.answers.map((i,l)=>(0,a.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-answer":l,children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(ne,{value:i.answer,maxLength:40,placeholder:"Answer",onChange:h=>r(l,{answer:h.target.value}),"aria-label":`Answer ${l+1}`}),(0,a.jsx)(te,{variant:"ghost",size:"icon",disabled:e.answers.length<=2,onClick:()=>o({...e,answers:e.answers.filter((h,u)=>u!==l)}),"aria-label":`Remove ${i.answer||`answer ${l+1}`}`,children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(ne,{value:i.means,maxLength:200,placeholder:"What it means, in a few words",onChange:h=>r(l,{means:h.target.value}),"aria-label":`What ${i.answer||`answer ${l+1}`} means`}),(0,a.jsxs)("select",{className:ue,value:i.to,onChange:h=>r(l,{to:h.target.value}),"aria-label":`Where ${i.answer||`answer ${l+1}`} goes`,children:[i.to===""&&(0,a.jsx)("option",{value:"",children:"Choose where it goes"}),t.map(h=>(0,a.jsxs)("option",{value:h.id,children:["Goes to ",h.title]},h.id))]})]},l)),e.answers.length<12&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,answers:[...e.answers,{answer:"",means:"",to:""}]}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add an answer"]})]}),(0,a.jsx)(Y,{label:"Acts on its own when",hint:"Below this, the card takes the not-sure path.",children:(0,a.jsx)("select",{className:ue,value:String(e.sureAt),onChange:i=>o({...e,sureAt:Number(i.target.value)}),"aria-label":"Acts on its own when",children:[...new Set([...c0,e.sureAt])].sort((i,l)=>l-i).map(i=>(0,a.jsxs)("option",{value:String(i),children:[Math.round(i*100),"% sure or more"]},i))})}),(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",open:e.notes.length>0||void 0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Also note on the card",e.notes.length>0?` (${e.notes.length})`:""]}),(0,a.jsxs)("div",{className:"mt-2 grid gap-2",children:[e.notes.map((i,l)=>(0,a.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-note":l,children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsxs)("select",{className:ue,value:i.kind,onChange:h=>s(l,h.target.value==="score"?{kind:"score",levels:i.levels??["Low","Medium","High"]}:{kind:"yes-no",levels:null}),"aria-label":`Note ${l+1}: kind`,children:[(0,a.jsx)("option",{value:"score",children:"A score"}),(0,a.jsx)("option",{value:"yes-no",children:"Yes or no"})]}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>o({...e,notes:e.notes.filter((h,u)=>u!==l)}),"aria-label":`Remove note ${l+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(ne,{value:i.question,maxLength:300,placeholder:i.kind==="score"?"How urgent is this?":"Is the customer asking for money back?",onChange:h=>s(l,{question:h.target.value}),"aria-label":`Note ${l+1}: question`}),i.kind==="score"&&(0,a.jsx)(ye,{rows:3,value:(i.levels??[]).join(`
|
|
7
|
+
`)),u=h.reduce((c,p)=>c.concat(...p),[]);return[h,u]}return[[],[]]},[e]);return(0,L.useEffect)(()=>{let h=t?.target??as,u=t?.actInsideInputWithModifier??!0;if(e!==null){let c=m=>{if(r.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!r.current||r.current&&!u)&&Ci(m))return!1;let f=ss(m.code,l);if(s.current.add(m[f]),rs(i,s.current,!1)){let w=m.composedPath?.()?.[0]||m.target,y=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&m.preventDefault(),o(!0)}},p=m=>{let f=ss(m.code,l);rs(i,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(m[f]),m.key==="Meta"&&s.current.clear(),r.current=!1},d=()=>{s.current.clear(),o(!1)};return h?.addEventListener("keydown",c),h?.addEventListener("keyup",p),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{h?.removeEventListener("keydown",c),h?.removeEventListener("keyup",p),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function rs(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function ss(e,t){return t.includes(e)?"code":"key"}var Dm=()=>{let e=pe();return(0,L.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[o,r,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{let[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{let{width:o,height:r,minZoom:s,maxZoom:i,panZoom:l}=e.getState(),h=pa(t,o,r,s,i,n?.padding??.1);return l?(await l.setViewport(h,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:o,snapGrid:r,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;let{x:l,y:h}=i.getBoundingClientRect(),u={x:t.x-l,y:t.y-h},c=n.snapGrid??r,p=n.snapToGrid??s;return un(u,o,p,c)},flowToScreenPosition:t=>{let{transform:n,domNode:o}=e.getState();if(!o)return t;let{x:r,y:s}=o.getBoundingClientRect(),i=Pt(t,n);return{x:i.x+r,y:i.y+s}}}),[])};function qi(e,t){let n=[],o=new Map,r=[];for(let s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")o.set(s.id,[s]);else{let i=o.get(s.id);i?i.push(s):o.set(s.id,[s])}for(let s of t){let i=o.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}let l={...s};for(let h of i)Rm(h,l);n.push(l)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function Rm(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 Ki(e,t){return qi(e,t)}function Om(e,t){return qi(e,t)}function st(e,t){return{id:e,type:"select",selected:t}}function St(e,t=new Set,n=!1){let o=[];for(let[r,s]of e){let i=t.has(r);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),o.push(st(s.id,i)))}return o}function is({items:e=[],lookup:t}){let n=[],o=new Map(e.map(r=>[r.id,r]));for(let[r,s]of e.entries()){let i=t.get(s.id),l=i?.internals?.userNode??i;l!==void 0&&l!==s&&n.push({id:s.id,item:s,type:"replace"}),l===void 0&&n.push({item:s,type:"add",index:r})}for(let[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function ls(e){return{id:e.id,type:"remove"}}var Lm=wi("React Flow","https://reactflow.dev/");function Tm(e,t,n={}){return Sp(e,t,{...n,onError:n.onError??Lm})}var ds=e=>cp(e),Bm=e=>gi(e);function Ui(e){return(0,L.forwardRef)(e)}var Gi=typeof window<"u"?L.useLayoutEffect:L.useEffect;function cs(e){let[t,n]=(0,L.useState)(BigInt(0)),[o]=(0,L.useState)(()=>Vm(()=>n(r=>r+BigInt(1))));return Gi(()=>{let r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Vm(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Ji=(0,L.createContext)(null);function Hm({children:e}){let t=pe(),n=(0,L.useCallback)(l=>{let{nodes:h=[],setNodes:u,hasDefaultNodes:c,onNodesChange:p,nodeLookup:d,fitViewQueued:m,onNodesChangeMiddlewareMap:f}=t.getState(),w=h;for(let x of l)w=typeof x=="function"?x(w):x;let y=is({items:w,lookup:d});for(let x of f.values())y=x(y);c&&u(w),y.length>0?p?.(y):m&&window.requestAnimationFrame(()=>{let{fitViewQueued:x,nodes:E,setNodes:v}=t.getState();x&&v(E)})},[]),o=cs(n),r=(0,L.useCallback)(l=>{let{edges:h=[],setEdges:u,hasDefaultEdges:c,onEdgesChange:p,edgeLookup:d}=t.getState(),m=h;for(let f of l)m=typeof f=="function"?f(m):f;c?u(m):p&&p(is({items:m,lookup:d}))},[]),s=cs(r),i=(0,L.useMemo)(()=>({nodeQueue:o,edgeQueue:s}),[]);return(0,I.jsx)(Ji.Provider,{value:i,children:e})}function Fm(){let e=(0,L.useContext)(Ji);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}var Wm=e=>!!e.panZoom;function Dt(){let e=Dm(),t=pe(),n=Fm(),o=de(Wm),r=(0,L.useMemo)(()=>{let s=p=>t.getState().nodeLookup.get(p),i=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},h=p=>{let{nodeLookup:d,nodeOrigin:m}=t.getState(),f=ds(p)?p:d.get(p.id),w=f.parentId?Ni(f.position,f.measured,f.parentId,d,m):f.position,y={...f,position:w,width:f.measured?.width??f.width,height:f.measured?.height??f.height};return en(y)},u=(p,d,m={replace:!1})=>{i(f=>f.map(w=>{if(w.id===p){let y=typeof d=="function"?d(w):d;return m.replace&&ds(y)?y:{...w,...y}}return w}))},c=(p,d,m={replace:!1})=>{l(f=>f.map(w=>{if(w.id===p){let y=typeof d=="function"?d(w):d;return m.replace&&Bm(y)?y:{...w,...y}}return w}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>s(p)?.internals.userNode,getInternalNode:s,getEdges:()=>{let{edges:p=[]}=t.getState();return p.map(d=>({...d}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:i,setEdges:l,addNodes:p=>{let d=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...d])},addEdges:p=>{let d=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...d])},toObject:()=>{let{nodes:p=[],edges:d=[],transform:m}=t.getState(),[f,w,y]=m;return{nodes:p.map(x=>({...x})),edges:d.map(x=>({...x})),viewport:{x:f,y:w,zoom:y}}},deleteElements:async({nodes:p=[],edges:d=[]})=>{let{nodes:m,edges:f,onNodesDelete:w,onEdgesDelete:y,triggerNodeChanges:x,triggerEdgeChanges:E,onDelete:v,onBeforeDelete:b}=t.getState(),{nodes:j,edges:S}=await fp({nodesToRemove:p,edgesToRemove:d,nodes:m,edges:f,onBeforeDelete:b}),M=S.length>0,C=j.length>0;if(M){let _=S.map(ls);y?.(S),E(_)}if(C){let _=j.map(ls);w?.(j),x(_)}return(C||M)&&v?.({nodes:j,edges:S}),{deletedNodes:j,deletedEdges:S}},getIntersectingNodes:(p,d=!0,m)=>{let f=Lr(p),w=f?p:h(p),y=m!==void 0;return w?(m||t.getState().nodes).filter(x=>{let E=t.getState().nodeLookup.get(x.id);if(E&&!f&&(x.id===p.id||!E.internals.positionAbsolute))return!1;let v=en(y?x:E),b=Kn(v,w);return d&&b>0||b>=v.width*v.height||b>=w.width*w.height}):[]},isNodeIntersecting:(p,d,m=!0)=>{let f=Lr(p)?p:h(p);if(!f)return!1;let w=Kn(f,d);return m&&w>0||w>=d.width*d.height||w>=f.width*f.height},updateNode:u,updateNodeData:(p,d,m={replace:!1})=>{u(p,f=>{let w=typeof d=="function"?d(f):d;return m.replace?{...f,data:w}:{...f,data:{...f.data,...w}}},m)},updateEdge:c,updateEdgeData:(p,d,m={replace:!1})=>{c(p,f=>{let w=typeof d=="function"?d(f):d;return m.replace?{...f,data:w}:{...f,data:{...f.data,...w}}},m)},getNodesBounds:p=>{let{nodeLookup:d,nodeOrigin:m}=t.getState();return up(p,{nodeLookup:d,nodeOrigin:m})},getHandleConnections:({type:p,id:d,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}-${p}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:p,handleId:d,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}${p?d?`-${p}-${d}`:`-${p}`:""}`)?.values()??[]),fitView:async p=>{let d=t.getState().fitViewResolver??vp();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:d}),n.nodeQueue.push(m=>[...m]),d.promise}}},[]);return(0,L.useMemo)(()=>({...r,...e,viewportInitialized:o}),[o])}var us=e=>e.selected,Zm=typeof window<"u"?window:void 0;function Ym({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=pe(),{deleteElements:o}=Dt(),r=on(e,{actInsideInputWithModifier:!1}),s=on(t,{target:Zm});(0,L.useEffect)(()=>{if(r){let{edges:i,nodes:l}=n.getState();o({nodes:l.filter(us),edges:i.filter(us)}),n.setState({nodesSelectionActive:!1})}},[r]),(0,L.useEffect)(()=>{n.setState({multiSelectionActive:s})},[s])}function Xm(e){let t=pe();(0,L.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let o=ma(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",_e.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);let o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}var io={position:"absolute",width:"100%",height:"100%",top:0,left:0},qm=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Km({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:s=.5,panOnScrollMode:i=dt.Free,zoomOnDoubleClick:l=!0,panOnDrag:h=!0,defaultViewport:u,translateExtent:c,minZoom:p,maxZoom:d,zoomActivationKeyCode:m,preventScrolling:f=!0,children:w,noWheelClassName:y,noPanClassName:x,onViewportChange:E,isControlledViewport:v,paneClickDistance:b,selectionOnDrag:j}){let S=pe(),M=(0,L.useRef)(null),{userSelectionActive:C,lib:_,connectionInProgress:F}=de(qm,fe),O=on(m),R=(0,L.useRef)();Xm(M);let H=(0,L.useCallback)(g=>{E?.({x:g[0],y:g[1],zoom:g[2]}),v||S.setState({transform:g})},[E,v]);return(0,L.useEffect)(()=>{if(M.current){R.current=tm({domNode:M.current,minZoom:p,maxZoom:d,translateExtent:c,viewport:u,onDraggingChange:z=>S.setState(A=>A.paneDragging===z?A:{paneDragging:z}),onPanZoomStart:(z,A)=>{let{onViewportChangeStart:$,onMoveStart:B}=S.getState();B?.(z,A),$?.(A)},onPanZoom:(z,A)=>{let{onViewportChange:$,onMove:B}=S.getState();B?.(z,A),$?.(A)},onPanZoomEnd:(z,A)=>{let{onViewportChangeEnd:$,onMoveEnd:B}=S.getState();B?.(z,A),$?.(A)}});let{x:g,y:N,zoom:k}=R.current.getViewport();return S.setState({panZoom:R.current,transform:[g,N,k],domNode:M.current.closest(".react-flow")}),()=>{R.current?.destroy()}}},[]),(0,L.useEffect)(()=>{R.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:l,panOnDrag:h,zoomActivationKeyPressed:O,preventScrolling:f,noPanClassName:x,userSelectionActive:C,noWheelClassName:y,lib:_,onTransformChange:H,connectionInProgress:F,selectionOnDrag:j,paneClickDistance:b})},[e,t,n,o,r,s,i,l,h,O,f,x,C,y,_,H,F,j,b]),(0,I.jsx)("div",{className:"react-flow__renderer",ref:M,style:io,children:w})}var Um=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Gm(){let{userSelectionActive:e,userSelectionRect:t}=de(Um,fe);return e&&t?(0,I.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}var To=(e,t)=>n=>{n.target===t.current&&e?.(n)},Jm=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Qm({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Qt.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:l,onSelectionEnd:h,onPaneClick:u,onPaneContextMenu:c,onPaneScroll:p,onPaneMouseEnter:d,onPaneMouseMove:m,onPaneMouseLeave:f,children:w}){let y=(0,L.useRef)(0),x=pe(),{userSelectionActive:E,elementsSelectable:v,dragging:b,panBy:j,autoPanSpeed:S}=de(Jm,fe),M=v&&(e||E),C=(0,L.useRef)(null),_=(0,L.useRef)(),F=(0,L.useRef)(new Set),O=(0,L.useRef)(new Set),R=(0,L.useRef)(!1),H=(0,L.useRef)(!1),g=(0,L.useRef)({x:0,y:0}),N=(0,L.useRef)(!1),k=T=>{if(H.current||R.current||x.getState().connection.inProgress){H.current=!1,R.current=!1;return}u?.(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},z=T=>{if(Array.isArray(o)&&o?.includes(2)){T.preventDefault();return}c?.(T)},A=p?T=>p(T):void 0,$=T=>{H.current&&(T.stopPropagation(),H.current=!1)},B=T=>{if(T.pointerType==="touch"&&o!==!1&&!t)return;let{domNode:K,transform:oe}=x.getState();if(_.current=K?.getBoundingClientRect(),!_.current)return;let ie=T.target===C.current;if(!ie&&T.target.closest(".nokey")||!e||!(i&&ie||t)||T.button!==0||!T.isPrimary)return;T.target?.setPointerCapture?.(T.pointerId),H.current=!1;let{x:q,y:se}=Oe(T.nativeEvent,_.current),re=un({x:q,y:se},oe);x.setState({userSelectionRect:{width:0,height:0,startX:re.x,startY:re.y,x:q,y:se}}),ie||(T.stopPropagation(),T.preventDefault())};function V(T,K){let{userSelectionRect:oe}=x.getState();if(!oe)return;let{transform:ie,nodeLookup:q,edgeLookup:se,connectionLookup:re,triggerNodeChanges:le,triggerEdgeChanges:ce,defaultEdgeOptions:ge}=x.getState(),je={x:oe.startX,y:oe.startY},{x:Ee,y:Me}=Pt(je,ie),be={startX:je.x,startY:je.y,x:T<Ee?T:Ee,y:K<Me?K:Me,width:Math.abs(T-Ee),height:Math.abs(K-Me)},Pe=F.current,Be=O.current;F.current=new Set(ua(q,be,ie,n===Qt.Partial,!0).map(Se=>Se.id)),O.current=new Set;let Ve=ge?.selectable??!0;for(let Se of F.current){let Ae=re.get(Se);if(Ae)for(let{edgeId:Ne}of Ae.values()){let we=se.get(Ne);we&&(we.selectable??Ve)&&O.current.add(Ne)}}if(!Tr(Pe,F.current)){let Se=St(q,F.current,!0);le(Se)}if(!Tr(Be,O.current)){let Se=St(se,O.current);ce(Se)}x.setState({userSelectionRect:be,userSelectionActive:!0,nodesSelectionActive:!1})}function W(){if(!r||!_.current)return;let[T,K]=ha(g.current,_.current,S);j({x:T,y:K}).then(oe=>{if(!H.current||!oe){y.current=requestAnimationFrame(W);return}let{x:ie,y:q}=g.current;V(ie,q),y.current=requestAnimationFrame(W)})}let J=()=>{cancelAnimationFrame(y.current),y.current=0,N.current=!1};(0,L.useEffect)(()=>()=>J(),[]);let X=T=>{let{userSelectionRect:K,transform:oe,resetSelectedElements:ie}=x.getState();if(!_.current||!K)return;let{x:q,y:se}=Oe(T.nativeEvent,_.current);g.current={x:q,y:se};let re=Pt({x:K.startX,y:K.startY},oe);if(!H.current){let le=t?0:s;if(Math.hypot(q-re.x,se-re.y)<=le)return;ie(),l?.(T)}H.current=!0,N.current||(W(),N.current=!0),V(q,se)},Z=T=>{if(!M){T.target===C.current&&x.getState().connection.inProgress&&(R.current=!0);return}T.button===0&&(T.target?.releasePointerCapture?.(T.pointerId),!E&&T.target===C.current&&x.getState().userSelectionRect&&k?.(T),x.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(h?.(T),x.setState({nodesSelectionActive:F.current.size>0})),J())},ee=T=>{T.target?.releasePointerCapture?.(T.pointerId),J()},Q=o===!0||Array.isArray(o)&&o.includes(0);return(0,I.jsxs)("div",{className:ve(["react-flow__pane",{draggable:Q,dragging:b,selection:e}]),onClick:M?void 0:To(k,C),onContextMenu:To(z,C),onWheel:To(A,C),onPointerEnter:M?void 0:d,onPointerMove:M?X:m,onPointerUp:Z,onPointerCancel:M?ee:void 0,onPointerDownCapture:M?B:void 0,onClickCapture:M?$:void 0,onPointerLeave:f,ref:C,style:io,children:[w,(0,I.jsx)(Gm,{})]})}function Qo({id:e,store:t,unselect:n=!1,nodeRef:o}){let{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:l,onError:h}=t.getState(),u=l.get(e);if(!u){h?.("012",_e.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Qi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,nodeClickDistance:i}){let l=pe(),[h,u]=(0,L.useState)(!1),c=(0,L.useRef)();return(0,L.useEffect)(()=>{if(!t)return c.current=Vp({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{Qo({id:p,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{c.current?.destroy(),c.current=void 0}},[t,l,e]),(0,L.useEffect)(()=>{t||!e.current||!c.current||c.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:i})},[n,o,t,s,e,r,i]),h}var ef=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function el(){let e=pe();return(0,L.useCallback)(t=>{let{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:s,onError:i,updateNodePositions:l,nodeLookup:h,nodeOrigin:u}=e.getState(),c=new Map,p=ef(s),d=o?r[0]:5,m=o?r[1]:5,f=t.direction.x*d*t.factor,w=t.direction.y*m*t.factor;for(let[,y]of h){if(!p(y))continue;let x={x:y.internals.positionAbsolute.x+f,y:y.internals.positionAbsolute.y+w};o&&(x=cn(x,r));let{position:E,positionAbsolute:v}=xi({nodeId:y.id,nextPosition:x,nodeLookup:h,nodeExtent:n,nodeOrigin:u,onError:i});y.position=E,y.internals.positionAbsolute=v,c.set(y.id,y)}l(c)},[])}var ba=(0,L.createContext)(null),tf=ba.Provider;ba.Consumer;var tl=()=>(0,L.useContext)(ba),nf=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),nl=(0,L.createContext)(null);function of({children:e}){let t=de(nf,fe);return(0,I.jsx)(nl.Provider,{value:t,children:e})}function af(){let e=(0,L.useContext)(nl);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}var rf={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},sf=(e,t,n)=>o=>{let{connectionClickStartHandle:r,connectionMode:s,connection:i}=o,{fromHandle:l,toHandle:h,isValid:u}=i;if(!l&&!r)return rf;let c=h?.nodeId===e&&h?.id===t&&h?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:c,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:s===zt.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!r,valid:c&&u}};function lf({type:e="source",position:t=U.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:i,onConnect:l,children:h,className:u,onMouseDown:c,onTouchStart:p,...d},m){let f=i||null,w=e==="target",y=pe(),x=tl(),{connectOnClick:E,noPanClassName:v,rfId:b}=af(),{connectingFrom:j,connectingTo:S,clickConnecting:M,isPossibleEndHandle:C,connectionInProcess:_,clickConnectionInProcess:F,valid:O}=de(sf(x,f,e),fe);x||y.getState().onError?.("010",_e.error010());let R=N=>{let{defaultEdgeOptions:k,onConnect:z,hasDefaultEdges:A}=y.getState(),$={...k,...N};if(A){let{edges:B,setEdges:V,onError:W}=y.getState();V(Tm($,B,{onError:W}))}z?.($),l?.($)},H=N=>{if(!x)return;let k=$i(N.nativeEvent);if(r&&(k&&N.button===0||!k)){let z=y.getState();Jo.onPointerDown(N.nativeEvent,{handleDomNode:N.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:w,handleId:f,nodeId:x,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...A)=>y.getState().onConnectEnd?.(...A),updateConnection:z.updateConnection,onConnect:R,isValidConnection:n||((...A)=>y.getState().isValidConnection?.(...A)??!0),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}k?c?.(N):p?.(N)},g=N=>{let{onClickConnectStart:k,onClickConnectEnd:z,connectionClickStartHandle:A,connectionMode:$,isValidConnection:B,lib:V,rfId:W,nodeLookup:J,connection:X}=y.getState();if(!x||!A&&!r)return;if(!A){k?.(N.nativeEvent,{nodeId:x,handleId:f,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:x,type:e,id:f}});return}let Z=Si(N.target),ee=n||B,{connection:Q,isValid:T}=Jo.isValid(N.nativeEvent,{handle:{nodeId:x,id:f,type:e},connectionMode:$,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:ee,flowId:W,doc:Z,lib:V,nodeLookup:J});T&&Q&&R(Q);let K=structuredClone(X);delete K.inProgress,K.toPosition=K.toHandle?K.toHandle.position:null,z?.(N,K),y.setState({connectionClickStartHandle:null})};return(0,I.jsx)("div",{"data-handleid":f,"data-nodeid":x,"data-handlepos":t,"data-id":`${b}-${x}-${f}-${e}`,className:ve(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",v,u,{source:!w,target:w,connectable:o,connectablestart:r,connectableend:s,clickconnecting:M,connectingfrom:j,connectingto:S,valid:O,connectionindicator:o&&(!_||C)&&(_||F?s:r)}]),onMouseDown:H,onTouchStart:H,onClick:E?g:void 0,ref:m,...d,children:h})}var Ke=(0,L.memo)(Ui(lf));function df({data:e,isConnectable:t,sourcePosition:n=U.Bottom}){return(0,I.jsxs)(I.Fragment,{children:[e?.label,(0,I.jsx)(Ke,{type:"source",position:n,isConnectable:t})]})}function cf({data:e,isConnectable:t,targetPosition:n=U.Top,sourcePosition:o=U.Bottom}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ke,{type:"target",position:n,isConnectable:t}),e?.label,(0,I.jsx)(Ke,{type:"source",position:o,isConnectable:t})]})}function uf(){return null}function hf({data:e,isConnectable:t,targetPosition:n=U.Top}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ke,{type:"target",position:n,isConnectable:t}),e?.label]})}var Un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hs={input:df,default:cf,output:hf,group:uf};function pf(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var mf=e=>{let{width:t,height:n,x:o,y:r}=dn(e.nodeLookup,{filter:s=>!!s.selected});return{width:Re(t)?t:null,height:Re(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function ff({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let o=pe(),{width:r,height:s,transformString:i,userSelectionActive:l}=de(mf,fe),h=el(),u=(0,L.useRef)(null);(0,L.useEffect)(()=>{n||u.current?.focus({preventScroll:!0})},[n]);let c=!l&&r!==null&&s!==null;if(Qi({nodeRef:u,disabled:!c}),!c)return null;let p=e?m=>{let f=o.getState().nodes.filter(w=>w.selected);e(m,f)}:void 0,d=m=>{Object.prototype.hasOwnProperty.call(Un,m.key)&&(m.preventDefault(),h({direction:Un[m.key],factor:m.shiftKey?4:1}))};return(0,I.jsx)("div",{className:ve(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:(0,I.jsx)("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:s}})})}var ps=typeof window<"u"?window:void 0,gf=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ol({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:l,deleteKeyCode:h,selectionKeyCode:u,selectionOnDrag:c,selectionMode:p,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:f,panActivationKeyCode:w,zoomActivationKeyCode:y,elementsSelectable:x,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:b,panOnScrollSpeed:j,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:C,autoPanOnSelection:_,defaultViewport:F,translateExtent:O,minZoom:R,maxZoom:H,preventScrolling:g,onSelectionContextMenu:N,noWheelClassName:k,noPanClassName:z,disableKeyboardA11y:A,onViewportChange:$,isControlledViewport:B}){let{nodesSelectionActive:V,userSelectionActive:W}=de(gf,fe),J=on(u,{target:ps}),X=on(w,{target:ps}),Z=X||C,ee=X||b,Q=c&&Z!==!0,T=J||W||Q;return Ym({deleteKeyCode:h,multiSelectionKeyCode:f}),(0,I.jsx)(Km,{onPaneContextMenu:s,elementsSelectable:x,zoomOnScroll:E,zoomOnPinch:v,panOnScroll:ee,panActivationKeyPressed:X,panOnScrollSpeed:j,panOnScrollMode:S,zoomOnDoubleClick:M,panOnDrag:!J&&Z,defaultViewport:F,translateExtent:O,minZoom:R,maxZoom:H,zoomActivationKeyCode:y,preventScrolling:g,noWheelClassName:k,noPanClassName:z,onViewportChange:$,isControlledViewport:B,paneClickDistance:l,selectionOnDrag:Q,children:(0,I.jsxs)(Qm,{onSelectionStart:d,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:Z,autoPanOnSelection:_,isSelecting:!!T,selectionMode:p,selectionKeyPressed:J,paneClickDistance:l,selectionOnDrag:Q,children:[e,V&&(0,I.jsx)(ff,{onSelectionContextMenu:N,noPanClassName:z,disableKeyboardA11y:A})]})})}ol.displayName="FlowRenderer";var xf=(0,L.memo)(ol),vf=e=>t=>e?ua(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 yf(e){return de((0,L.useCallback)(vf(e),[e]),fe)}var bf=e=>e.updateNodeInternals;function wf(){let e=de(bf),[t]=(0,L.useState)(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{let o=new Map;n.forEach(r=>{let s=r.target.getAttribute("data-id");o.set(s,{id:s,nodeElement:r.target,force:!0})}),e(o)}));return(0,L.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function jf({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){let r=pe(),s=(0,L.useRef)(null),i=(0,L.useRef)(null),l=(0,L.useRef)(e.sourcePosition),h=(0,L.useRef)(e.targetPosition),u=(0,L.useRef)(t),c=n&&!!e.internals.handleBounds;return(0,L.useEffect)(()=>{s.current&&!e.hidden&&(!c||i.current!==s.current)&&(i.current&&o?.unobserve(i.current),o?.observe(s.current),i.current=s.current)},[c,e.hidden]),(0,L.useEffect)(()=>()=>{i.current&&(o?.unobserve(i.current),i.current=null)},[]),(0,L.useEffect)(()=>{if(s.current){let p=u.current!==t,d=l.current!==e.sourcePosition,m=h.current!==e.targetPosition;(p||d||m)&&(u.current=t,l.current=e.sourcePosition,h.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function Nf({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:s,onDoubleClick:i,nodesDraggable:l,elementsSelectable:h,nodesConnectable:u,nodesFocusable:c,resizeObserver:p,noDragClassName:d,noPanClassName:m,disableKeyboardA11y:f,rfId:w,nodeTypes:y,nodeClickDistance:x,onError:E}){let{node:v,internals:b,isParent:j}=de(T=>{let K=T.nodeLookup.get(e),oe=T.parentLookup.has(e);return{node:K,internals:K.internals,isParent:oe}},fe),S=v.type||"default",M=y?.[S]||hs[S];M===void 0&&(E?.("003",_e.error003(S)),S="default",M=y?.default||hs.default);let C=!!(v.draggable||l&&typeof v.draggable>"u"),_=!!(v.selectable||h&&typeof v.selectable>"u"),F=!!(v.connectable||u&&typeof v.connectable>"u"),O=!!(v.focusable||c&&typeof v.focusable>"u"),R=pe(),H=ji(v),g=jf({node:v,nodeType:S,hasDimensions:H,resizeObserver:p}),N=Qi({nodeRef:g,disabled:v.hidden||!C,noDragClassName:d,handleSelector:v.dragHandle,nodeId:e,isSelectable:_,nodeClickDistance:x}),k=el();if(v.hidden)return null;let z=Te(v),A=pf(v),$=_||C||t||n||o||r,B=n?T=>n(T,{...b.userNode}):void 0,V=o?T=>o(T,{...b.userNode}):void 0,W=r?T=>r(T,{...b.userNode}):void 0,J=s?T=>s(T,{...b.userNode}):void 0,X=i?T=>i(T,{...b.userNode}):void 0,Z=T=>{let{selectNodesOnDrag:K,nodeDragThreshold:oe}=R.getState();_&&(!K||!C||oe>0)&&Qo({id:e,store:R,nodeRef:g}),t&&t(T,{...b.userNode})},ee=T=>{if(!(Ci(T.nativeEvent)||f)){if(pi.includes(T.key)&&_){let K=T.key==="Escape";Qo({id:e,store:R,unselect:K,nodeRef:g})}else if(C&&v.selected&&Object.prototype.hasOwnProperty.call(Un,T.key)){T.preventDefault();let{ariaLabelConfig:K}=R.getState();R.setState({ariaLiveMessage:K["node.a11yDescription.ariaLiveMessage"]({direction:T.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),k({direction:Un[T.key],factor:T.shiftKey?4:1})}}},Q=()=>{if(f||!g.current?.matches(":focus-visible"))return;let{transform:T,width:K,height:oe,autoPanOnNodeFocus:ie,setCenter:q}=R.getState();ie&&(ua(new Map([[e,v]]),{x:0,y:0,width:K,height:oe},T,!0).length>0||q(v.position.x+z.width/2,v.position.y+z.height/2,{zoom:T[2]}))};return(0,I.jsx)("div",{className:ve(["react-flow__node",`react-flow__node-${S}`,{[m]:C},v.className,{selected:v.selected,selectable:_,parent:j,draggable:C,dragging:N}]),ref:g,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:$?"all":"none",visibility:H?"visible":"hidden",...v.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:V,onMouseLeave:W,onContextMenu:J,onClick:Z,onDoubleClick:X,onKeyDown:O?ee:void 0,tabIndex:O?0:void 0,onFocus:O?Q:void 0,role:v.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":f?void 0:`${Zi}-${w}`,"aria-label":v.ariaLabel,...v.domAttributes,children:(0,I.jsx)(tf,{value:e,children:(0,I.jsx)(M,{id:e,data:v.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:v.selected??!1,selectable:_,draggable:C,deletable:v.deletable??!0,isConnectable:F,sourcePosition:v.sourcePosition,targetPosition:v.targetPosition,dragging:N,dragHandle:v.dragHandle,zIndex:b.z,parentId:v.parentId,...z})})})}var kf=(0,L.memo)(Nf),Sf=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function al(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=de(Sf,fe),s=yf(e.onlyRenderVisibleElements),i=wf();return(0,I.jsx)("div",{className:"react-flow__nodes",style:io,children:s.map(l=>(0,I.jsx)(kf,{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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},l))})}al.displayName="NodeRenderer";var Cf=(0,L.memo)(al);function $f(e){return de((0,L.useCallback)(t=>{if(!e)return t.edges.map(o=>o.id);let n=[];if(t.width&&t.height)for(let o of t.edges){let r=t.nodeLookup.get(o.source),s=t.nodeLookup.get(o.target);r&&s&&jp({sourceNode:r,targetNode:s,width:t.width,height:t.height,transform:t.transform})&&n.push(o.id)}return n},[e]),fe)}var Ef=({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,I.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Mf=({color:e="none",strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,I.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ms={[Xe.Arrow]:Ef,[Xe.ArrowClosed]:Mf};function zf(e){let t=pe();return(0,L.useMemo)(()=>Object.prototype.hasOwnProperty.call(ms,e)?ms[e]:(t.getState().onError?.("009",_e.error009(e)),null),[e])}var _f=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{let h=zf(t);return h?(0,I.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:l,refX:"0",refY:"0",children:(0,I.jsx)(h,{color:n,strokeWidth:i})}):null},rl=({defaultColor:e,rfId:t})=>{let n=de(s=>s.edges),o=de(s=>s.defaultEdgeOptions),r=(0,L.useMemo)(()=>zp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?(0,I.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,I.jsx)("defs",{children:r.map(s=>(0,I.jsx)(_f,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};rl.displayName="MarkerDefinitions";var Pf=(0,L.memo)(rl);function sl({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:h,className:u,...c}){let[p,d]=(0,L.useState)({x:1,y:0,width:0,height:0}),m=ve(["react-flow__edge-textwrapper",u]),f=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(f.current){let w=f.current.getBBox();d({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?(0,I.jsxs)("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...c,children:[r&&(0,I.jsx)("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:l,ry:l}),(0,I.jsx)("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:o,children:n}),h]}):null}sl.displayName="EdgeText";var Af=(0,L.memo)(sl);function hn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:h,interactionWidth:u=20,...c}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)("path",{...c,d:e,fill:"none",className:ve(["react-flow__edge-path",c.className])}),u?(0,I.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,o&&Re(t)&&Re(n)?(0,I.jsx)(Af,{x:t,y:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:h}):null]})}function fs({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===U.Left||e===U.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function il({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:o,targetY:r,targetPosition:s=U.Top}){let[i,l]=fs({pos:n,x1:e,y1:t,x2:o,y2:r}),[h,u]=fs({pos:s,x1:o,y1:r,x2:e,y2:t}),[c,p,d,m]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:l,targetControlX:h,targetControlY:u});return[`M${e},${t} C${i},${l} ${h},${u} ${o},${r}`,c,p,d,m]}function ll(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:x})=>{let[E,v,b]=il({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),j=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:j,path:E,labelX:v,labelY:b,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:x})})}var If=ll({isInternal:!1}),dl=ll({isInternal:!0});If.displayName="SimpleBezierEdge";dl.displayName="SimpleBezierEdgeInternal";function cl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,sourcePosition:m=U.Bottom,targetPosition:f=U.Top,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:E})=>{let[v,b,j]=nn({sourceX:n,sourceY:o,sourcePosition:m,targetX:r,targetY:s,targetPosition:f,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),S=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:S,path:v,labelX:b,labelY:j,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:w,markerStart:y,interactionWidth:E})})}var ul=cl({isInternal:!1}),hl=cl({isInternal:!0});ul.displayName="SmoothStepEdge";hl.displayName="SmoothStepEdgeInternal";function pl(e){return(0,L.memo)(({id:t,...n})=>{let o=e.isInternal?void 0:t;return(0,I.jsx)(ul,{...n,id:o,pathOptions:(0,L.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Df=pl({isInternal:!1}),ml=pl({isInternal:!0});Df.displayName="StepEdge";ml.displayName="StepEdgeInternal";function fl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:f,interactionWidth:w})=>{let[y,x,E]=_i({sourceX:n,sourceY:o,targetX:r,targetY:s}),v=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:v,path:y,labelX:x,labelY:E,label:i,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:f,interactionWidth:w})})}var Rf=fl({isInternal:!1}),gl=fl({isInternal:!0});Rf.displayName="StraightEdge";gl.displayName="StraightEdgeInternal";function xl(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i=U.Bottom,targetPosition:l=U.Top,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:E})=>{let[v,b,j]=Mi({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:s,targetPosition:l,curvature:x?.curvature}),S=e.isInternal?void 0:t;return(0,I.jsx)(hn,{id:S,path:v,labelX:b,labelY:j,label:h,labelStyle:u,labelShowBg:c,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:f,markerEnd:w,markerStart:y,interactionWidth:E})})}var Of=xl({isInternal:!1}),vl=xl({isInternal:!0});Of.displayName="BezierEdge";vl.displayName="BezierEdgeInternal";var gs={default:vl,straight:gl,step:ml,smoothstep:hl,simplebezier:dl},xs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Lf=(e,t,n)=>n===U.Left?e-t:n===U.Right?e+t:e,Tf=(e,t,n)=>n===U.Top?e-t:n===U.Bottom?e+t:e,vs="react-flow__edgeupdater";function ys({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:i,type:l}){return(0,I.jsx)("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:i,className:ve([vs,`${vs}-${l}`]),cx:Lf(t,o,e),cy:Tf(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Bf({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:s,targetY:i,sourcePosition:l,targetPosition:h,onReconnect:u,onReconnectStart:c,onReconnectEnd:p,setReconnecting:d,setUpdateHover:m}){let f=pe(),w=(b,j)=>{if(b.button!==0)return;let{autoPanOnConnect:S,domNode:M,connectionMode:C,connectionRadius:_,lib:F,onConnectStart:O,cancelConnection:R,nodeLookup:H,rfId:g,panBy:N,updateConnection:k}=f.getState(),z=j.type==="target",A=(V,W)=>{d(!1),p?.(V,n,j.type,W)},$=V=>u?.(n,V),B=(V,W)=>{d(!0),c?.(b,n,j.type),O?.(V,W)};Jo.onPointerDown(b.nativeEvent,{autoPanOnConnect:S,connectionMode:C,connectionRadius:_,domNode:M,handleId:j.id,nodeId:j.nodeId,nodeLookup:H,isTarget:z,edgeUpdaterType:j.type,lib:F,flowId:g,cancelConnection:R,panBy:N,isValidConnection:(...V)=>f.getState().isValidConnection?.(...V)??!0,onConnect:$,onConnectStart:B,onConnectEnd:(...V)=>f.getState().onConnectEnd?.(...V),onReconnectEnd:A,updateConnection:k,getTransform:()=>f.getState().transform,getFromHandle:()=>f.getState().connection.fromHandle,dragThreshold:f.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},y=b=>w(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=b=>w(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>m(!0),v=()=>m(!1);return(0,I.jsxs)(I.Fragment,{children:[(e===!0||e==="source")&&(0,I.jsx)(ys,{position:l,centerX:o,centerY:r,radius:t,onMouseDown:y,onMouseEnter:E,onMouseOut:v,type:"source"}),(e===!0||e==="target")&&(0,I.jsx)(ys,{position:h,centerX:s,centerY:i,radius:t,onMouseDown:x,onMouseEnter:E,onMouseOut:v,type:"target"})]})}function Vf({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:s,onContextMenu:i,onMouseEnter:l,onMouseMove:h,onMouseLeave:u,reconnectRadius:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,rfId:f,edgeTypes:w,noPanClassName:y,onError:x,disableKeyboardA11y:E}){let v=de(q=>q.edgeLookup.get(e)),b=de(q=>q.defaultEdgeOptions);v=b?{...b,...v}:v;let j=v.type||"default",S=w?.[j]||gs[j];S===void 0&&(x?.("011",_e.error011(j)),j="default",S=w?.default||gs.default);let M=!!(v.focusable||t&&typeof v.focusable>"u"),C=typeof p<"u"&&(v.reconnectable||n&&typeof v.reconnectable>"u"),_=!!(v.selectable||o&&typeof v.selectable>"u"),F=(0,L.useRef)(null),[O,R]=(0,L.useState)(!1),[H,g]=(0,L.useState)(!1),N=pe(),{zIndex:k=v.zIndex,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W}=de((0,L.useCallback)(q=>{let se=q.nodeLookup.get(v.source),re=q.nodeLookup.get(v.target);if(!se||!re)return xs;let le=Mp({id:e,sourceNode:se,targetNode:re,sourceHandle:v.sourceHandle||null,targetHandle:v.targetHandle||null,connectionMode:q.connectionMode,onError:x}),ce=wp({selected:v.selected,zIndex:v.zIndex,sourceNode:se,targetNode:re,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode});return{...le||xs,zIndex:ce}},[v.source,v.target,v.sourceHandle,v.targetHandle,v.selected,v.zIndex,x]),fe),J=(0,L.useMemo)(()=>v.markerStart?`url('#${Uo(v.markerStart,f)}')`:void 0,[v.markerStart,f]),X=(0,L.useMemo)(()=>v.markerEnd?`url('#${Uo(v.markerEnd,f)}')`:void 0,[v.markerEnd,f]);if(v.hidden||z===null||A===null||$===null||B===null)return null;let Z=q=>{let{addSelectedEdges:se,unselectNodesAndEdges:re,multiSelectionActive:le}=N.getState();_&&(N.setState({nodesSelectionActive:!1}),v.selected&&le?(re({nodes:[],edges:[v]}),F.current?.blur()):se([e])),r&&r(q,v)},ee=s?q=>{s(q,{...v})}:void 0,Q=i?q=>{i(q,{...v})}:void 0,T=l?q=>{l(q,{...v})}:void 0,K=h?q=>{h(q,{...v})}:void 0,oe=u?q=>{u(q,{...v})}:void 0,ie=q=>{if(!E&&pi.includes(q.key)&&_){let{unselectNodesAndEdges:se,addSelectedEdges:re}=N.getState();q.key==="Escape"?(F.current?.blur(),se({edges:[v]})):re([e])}};return(0,I.jsx)("svg",{style:{zIndex:k},children:(0,I.jsxs)("g",{className:ve(["react-flow__edge",`react-flow__edge-${j}`,v.className,y,{selected:v.selected,animated:v.animated,inactive:!_&&!r,updating:O,selectable:_}]),onClick:Z,onDoubleClick:ee,onContextMenu:Q,onMouseEnter:T,onMouseMove:K,onMouseLeave:oe,onKeyDown:M?ie:void 0,tabIndex:M?0:void 0,role:v.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":v.ariaLabel===null?void 0:v.ariaLabel||`Edge from ${v.source} to ${v.target}`,"aria-describedby":M?`${Yi}-${f}`:void 0,ref:F,...v.domAttributes,children:[!H&&(0,I.jsx)(S,{id:e,source:v.source,target:v.target,type:v.type,selected:v.selected,animated:v.animated,selectable:_,deletable:v.deletable??!0,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W,data:v.data,style:v.style,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerStart:J,markerEnd:X,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth}),C&&(0,I.jsx)(Bf,{edge:v,isReconnectable:C,reconnectRadius:c,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,sourceX:z,sourceY:A,targetX:$,targetY:B,sourcePosition:V,targetPosition:W,setUpdateHover:R,setReconnecting:g})]})})}var Hf=(0,L.memo)(Vf),Ff=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function yl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:h,onEdgeMouseLeave:u,onEdgeClick:c,reconnectRadius:p,onEdgeDoubleClick:d,onReconnectStart:m,onReconnectEnd:f,disableKeyboardA11y:w}){let{edgesFocusable:y,edgesReconnectable:x,elementsSelectable:E,onError:v}=de(Ff,fe),b=$f(t);return(0,I.jsxs)("div",{className:"react-flow__edges",children:[(0,I.jsx)(Pf,{defaultColor:e,rfId:n}),b.map(j=>(0,I.jsx)(Hf,{id:j,edgesFocusable:y,edgesReconnectable:x,elementsSelectable:E,noPanClassName:r,onReconnect:s,onContextMenu:i,onMouseEnter:l,onMouseMove:h,onMouseLeave:u,onClick:c,reconnectRadius:p,onDoubleClick:d,onReconnectStart:m,onReconnectEnd:f,rfId:n,onError:v,edgeTypes:o,disableKeyboardA11y:w},j))]})}yl.displayName="EdgeRenderer";var Wf=(0,L.memo)(yl),bs=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Zf({children:e}){let t=pe(),n=(0,L.useRef)(null),[o]=(0,L.useState)(()=>t.getState().transform);return Gi(()=>{let r=null,s=()=>{let i=t.getState().transform;r&&i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]||(r=i,n.current&&(n.current.style.transform=bs(i)))};return s(),t.subscribe(s)},[t]),(0,I.jsx)("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:bs(o)},children:e})}function Yf(e){let t=Dt(),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Xf=e=>e.panZoom?.syncViewport;function qf(e){let t=de(Xf),n=pe();return(0,L.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function ws(e){return e.connection.inProgress?{...e.connection,to:un(e.connection.to,e.transform)}:{...e.connection}}function Kf(e){return e?t=>{let n=ws(t);return e(n)}:ws}function Uf(e){let t=Kf(e);return de(t,fe)}var Gf=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Jf({containerStyle:e,style:t,type:n,component:o}){let{nodesConnectable:r,width:s,height:i,isValid:l,inProgress:h}=de(Gf,fe);return s&&r&&h?(0,I.jsx)("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:(0,I.jsx)("g",{className:ve(["react-flow__connection",ki(l)]),children:(0,I.jsx)(bl,{style:t,type:n,CustomComponent:o,isValid:l})})}):null}var bl=({style:e,type:t=at.Bezier,CustomComponent:n,isValid:o})=>{let{inProgress:r,from:s,fromNode:i,fromHandle:l,fromPosition:h,to:u,toNode:c,toHandle:p,toPosition:d,pointer:m}=Uf();if(!r)return;if(n)return(0,I.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:l,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:h,toPosition:d,connectionStatus:ki(o),toNode:c,toHandle:p,pointer:m});let f="",w={sourceX:s.x,sourceY:s.y,sourcePosition:h,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case at.Bezier:[f]=Mi(w);break;case at.SimpleBezier:[f]=il(w);break;case at.Step:[f]=nn({...w,borderRadius:0});break;case at.SmoothStep:[f]=nn(w);break;default:[f]=_i(w)}return(0,I.jsx)("path",{d:f,fill:"none",className:"react-flow__connection-path",style:e})};bl.displayName="ConnectionLine";var Qf={};function js(e=Qf){let t=(0,L.useRef)(e),n=pe();(0,L.useEffect)(()=>{},[e])}function eg(){let e=pe(),t=(0,L.useRef)(!1);(0,L.useEffect)(()=>{},[])}function wl({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:h,onNodeMouseLeave:u,onNodeContextMenu:c,onSelectionContextMenu:p,onSelectionStart:d,onSelectionEnd:m,connectionLineType:f,connectionLineStyle:w,connectionLineComponent:y,connectionLineContainerStyle:x,selectionKeyCode:E,selectionOnDrag:v,selectionMode:b,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:M,deleteKeyCode:C,onlyRenderVisibleElements:_,elementsSelectable:F,defaultViewport:O,translateExtent:R,minZoom:H,maxZoom:g,preventScrolling:N,defaultMarkerColor:k,zoomOnScroll:z,zoomOnPinch:A,panOnScroll:$,panOnScrollSpeed:B,panOnScrollMode:V,zoomOnDoubleClick:W,panOnDrag:J,autoPanOnSelection:X,onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:Q,onPaneMouseLeave:T,onPaneScroll:K,onPaneContextMenu:oe,paneClickDistance:ie,nodeClickDistance:q,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:le,onEdgeMouseLeave:ce,reconnectRadius:ge,onReconnect:je,onReconnectStart:Ee,onReconnectEnd:Me,noDragClassName:be,noWheelClassName:Pe,noPanClassName:Be,disableKeyboardA11y:Ve,nodeExtent:Se,rfId:Ae,viewport:Ne,onViewportChange:we,nodesDraggable:vt}){return js(e),js(t),eg(),Yf(n),qf(Ne),(0,I.jsx)(xf,{onPaneClick:Z,onPaneMouseEnter:ee,onPaneMouseMove:Q,onPaneMouseLeave:T,onPaneContextMenu:oe,onPaneScroll:K,paneClickDistance:ie,deleteKeyCode:C,selectionKeyCode:E,selectionOnDrag:v,selectionMode:b,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:j,panActivationKeyCode:S,zoomActivationKeyCode:M,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:A,zoomOnDoubleClick:W,panOnScroll:$,panOnScrollSpeed:B,panOnScrollMode:V,panOnDrag:J,autoPanOnSelection:X,defaultViewport:O,translateExtent:R,minZoom:H,maxZoom:g,onSelectionContextMenu:p,preventScrolling:N,noDragClassName:be,noWheelClassName:Pe,noPanClassName:Be,disableKeyboardA11y:Ve,onViewportChange:we,isControlledViewport:!!Ne,children:(0,I.jsxs)(Zf,{children:[(0,I.jsx)(Wf,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:je,onReconnectStart:Ee,onReconnectEnd:Me,onlyRenderVisibleElements:_,onEdgeContextMenu:se,onEdgeMouseEnter:re,onEdgeMouseMove:le,onEdgeMouseLeave:ce,reconnectRadius:ge,defaultMarkerColor:k,noPanClassName:Be,disableKeyboardA11y:Ve,rfId:Ae}),(0,I.jsx)(Jf,{style:w,type:f,component:y,containerStyle:x}),(0,I.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,I.jsx)(Cf,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:h,onNodeMouseLeave:u,onNodeContextMenu:c,nodeClickDistance:q,onlyRenderVisibleElements:_,noPanClassName:Be,noDragClassName:be,disableKeyboardA11y:Ve,nodeExtent:Se,rfId:Ae,nodesDraggable:vt}),(0,I.jsx)("div",{className:"react-flow__viewport-portal"})]})})}wl.displayName="GraphView";var tg=(0,L.memo)(wl),ng=wi("React Flow","https://reactflow.dev/"),Ns=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:p,zIndexMode:d="basic"}={})=>{let m=new Map,f=new Map,w=new Map,y=new Map,x=o??t??[],E=n??e??[],v=c??[0,0],b=p??Jt;Ii(w,y,x);let{nodesInitialized:j}=Go(E,m,f,{nodeOrigin:v,nodeExtent:b,zIndexMode:d}),S=[0,0,1];if(i&&r&&s){let M=dn(m,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:C,y:_,zoom:F}=pa(M,r,s,h,u,l?.padding??.1);S=[C,_,F]}return{rfId:"1",width:r??0,height:s??0,transform:S,nodes:E,nodesInitialized:j,nodeLookup:m,parentLookup:f,edges:x,edgeLookup:y,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:h,maxZoom:u,translateExtent:Jt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:zt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:v,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:i??!1,fitViewOptions:l,fitViewResolver:null,connection:{...fi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ng,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:mi,zIndexMode:d,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},og=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h,maxZoom:u,nodeOrigin:c,nodeExtent:p,zIndexMode:d})=>fm((m,f)=>{async function w(){let{nodeLookup:y,panZoom:x,fitViewOptions:E,fitViewResolver:v,width:b,height:j,minZoom:S,maxZoom:M}=f();x&&(await mp({nodes:y,width:b,height:j,panZoom:x,minZoom:S,maxZoom:M},E),v?.resolve(!0),m({fitViewResolver:null}))}return{...Ns({nodes:e,edges:t,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:h,maxZoom:u,nodeOrigin:c,nodeExtent:p,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:y=>{let{nodeLookup:x,parentLookup:E,nodeOrigin:v,nodeExtent:b,elevateNodesOnSelect:j,fitViewQueued:S,zIndexMode:M,nodesSelectionActive:C}=f(),{nodesInitialized:_,hasSelectedNodes:F}=Go(y,x,E,{nodeOrigin:v,nodeExtent:b,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:M}),O=C&&F;S&&_?(w(),m({nodes:y,nodesInitialized:_,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):m({nodes:y,nodesInitialized:_,nodesSelectionActive:O})},setEdges:y=>{let{connectionLookup:x,edgeLookup:E}=f();Ii(x,E,y),m({edges:y})},setDefaultNodesAndEdges:(y,x)=>{if(y){let{setNodes:E}=f();E(y),m({hasDefaultNodes:!0})}if(x){let{setEdges:E}=f();E(x),m({hasDefaultEdges:!0})}},updateNodeInternals:y=>{let{triggerNodeChanges:x,nodeLookup:E,parentLookup:v,domNode:b,nodeOrigin:j,nodeExtent:S,debug:M,fitViewQueued:C,zIndexMode:_}=f(),{changes:F,updatedInternals:O}=Op(y,E,v,b,j,S,_);O&&(Ap(E,v,{nodeOrigin:j,nodeExtent:S,zIndexMode:_}),C?(w(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),F?.length>0&&(M&&console.log("React Flow: trigger node changes",F),x?.(F)))},updateNodePositions:(y,x=!1)=>{let E=[],v=[],{nodeLookup:b,triggerNodeChanges:j,connection:S,updateConnection:M,onNodesChangeMiddlewareMap:C}=f();for(let[_,F]of y){let O=b.get(_),R=!!(O?.expandParent&&O?.parentId&&F?.position),H={id:_,type:"position",position:R?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:x};if(O&&S.inProgress&&S.fromNode.id===O.id){let g=mt(O,S.fromHandle,U.Left,!0);M({...S,from:g})}R&&O.parentId&&E.push({id:_,parentId:O.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),v.push(H)}if(E.length>0){let{parentLookup:_,nodeOrigin:F}=f(),O=ya(E,b,_,F);v.push(...O)}for(let _ of C.values())v=_(v);j(v)},triggerNodeChanges:y=>{let{onNodesChange:x,setNodes:E,nodes:v,hasDefaultNodes:b,debug:j}=f();if(y?.length){if(b){let S=Ki(y,v);E(S)}j&&console.log("React Flow: trigger node changes",y),x?.(y)}},triggerEdgeChanges:y=>{let{onEdgesChange:x,setEdges:E,edges:v,hasDefaultEdges:b,debug:j}=f();if(y?.length){if(b){let S=Om(y,v);E(S)}j&&console.log("React Flow: trigger edge changes",y),x?.(y)}},addSelectedNodes:y=>{let{multiSelectionActive:x,edgeLookup:E,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:j}=f();if(x){let S=y.map(M=>st(M,!0));b(S);return}b(St(v,new Set([...y]),!0)),j(St(E))},addSelectedEdges:y=>{let{multiSelectionActive:x,edgeLookup:E,nodeLookup:v,triggerNodeChanges:b,triggerEdgeChanges:j}=f();if(x){let S=y.map(M=>st(M,!0));j(S);return}j(St(E,new Set([...y]))),b(St(v,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:x}={})=>{let{edges:E,nodes:v,nodeLookup:b,triggerNodeChanges:j,triggerEdgeChanges:S}=f(),M=y||v,C=x||E,_=[];for(let O of M){if(!O.selected)continue;let R=b.get(O.id);R&&(R.selected=!1),_.push(st(O.id,!1))}let F=[];for(let O of C)O.selected&&F.push(st(O.id,!1));j(_),S(F)},setMinZoom:y=>{let{panZoom:x,maxZoom:E}=f();x?.setScaleExtent([y,E]),m({minZoom:y})},setMaxZoom:y=>{let{panZoom:x,minZoom:E}=f();x?.setScaleExtent([E,y]),m({maxZoom:y})},setTranslateExtent:y=>{f().panZoom?.setTranslateExtent(y),m({translateExtent:y})},resetSelectedElements:()=>{let{edges:y,nodes:x,triggerNodeChanges:E,triggerEdgeChanges:v,elementsSelectable:b}=f();if(!b)return;let j=x.reduce((M,C)=>C.selected?[...M,st(C.id,!1)]:M,[]),S=y.reduce((M,C)=>C.selected?[...M,st(C.id,!1)]:M,[]);E(j),v(S)},setNodeExtent:y=>{let{nodes:x,nodeLookup:E,parentLookup:v,nodeOrigin:b,elevateNodesOnSelect:j,nodeExtent:S,zIndexMode:M}=f();y[0][0]===S[0][0]&&y[0][1]===S[0][1]&&y[1][0]===S[1][0]&&y[1][1]===S[1][1]||(Go(x,E,v,{nodeOrigin:b,nodeExtent:y,elevateNodesOnSelect:j,checkEquality:!1,zIndexMode:M}),m({nodeExtent:y}))},panBy:y=>{let{transform:x,width:E,height:v,panZoom:b,translateExtent:j}=f();return Lp({delta:y,panZoom:b,transform:x,translateExtent:j,width:E,height:v})},setCenter:async(y,x,E)=>{let{width:v,height:b,maxZoom:j,panZoom:S}=f();if(!S)return!1;let M=typeof E?.zoom<"u"?E.zoom:j;return await S.setViewport({x:v/2-y*M,y:b/2-x*M,zoom:M},{duration:E?.duration,ease:E?.ease,interpolate:E?.interpolate}),!0},cancelConnection:()=>{m({connection:{...fi}})},updateConnection:y=>{m({connection:y})},reset:()=>m({...Ns()})}},Object.is);function jl({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:s,initialMinZoom:i,initialMaxZoom:l,initialFitViewOptions:h,fitView:u,nodeOrigin:c,nodeExtent:p,zIndexMode:d,children:m}){let[f]=(0,L.useState)(()=>og({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:u,minZoom:i,maxZoom:l,fitViewOptions:h,nodeOrigin:c,nodeExtent:p,zIndexMode:d}));return(0,I.jsx)(xm,{value:f,children:(0,I.jsx)(Hm,{children:(0,I.jsx)(of,{children:m})})})}function ag({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:s,height:i,fitView:l,fitViewOptions:h,minZoom:u,maxZoom:c,nodeOrigin:p,nodeExtent:d,zIndexMode:m}){return(0,L.useContext)(ro)?(0,I.jsx)(I.Fragment,{children:e}):(0,I.jsx)(jl,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:s,initialHeight:i,fitView:l,initialFitViewOptions:h,initialMinZoom:u,initialMaxZoom:c,nodeOrigin:p,nodeExtent:d,zIndexMode:m,children:e})}var rg={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function sg({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s,edgeTypes:i,onNodeClick:l,onEdgeClick:h,onInit:u,onMove:c,onMoveStart:p,onMoveEnd:d,onConnect:m,onConnectStart:f,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:S,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:_,onNodesDelete:F,onEdgesDelete:O,onDelete:R,onSelectionChange:H,onSelectionDragStart:g,onSelectionDrag:N,onSelectionDragStop:k,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:$,onBeforeDelete:B,connectionMode:V,connectionLineType:W=at.Bezier,connectionLineStyle:J,connectionLineComponent:X,connectionLineContainerStyle:Z,deleteKeyCode:ee="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:T=!1,selectionMode:K=Qt.Full,panActivationKeyCode:oe="Space",multiSelectionKeyCode:ie=tn()?"Meta":"Control",zoomActivationKeyCode:q=tn()?"Meta":"Control",snapToGrid:se,snapGrid:re,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ce,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ee,nodesFocusable:Me,nodeOrigin:be=Xi,edgesFocusable:Pe,edgesReconnectable:Be,elementsSelectable:Ve=!0,defaultViewport:Se=zm,minZoom:Ae=.5,maxZoom:Ne=2,translateExtent:we=Jt,preventScrolling:vt=!0,nodeExtent:Rt,defaultMarkerColor:pn="#b1b1b7",zoomOnScroll:mn=!0,zoomOnPinch:lo=!0,panOnScroll:co=!1,panOnScrollSpeed:fn=.5,panOnScrollMode:uo=dt.Free,zoomOnDoubleClick:Je=!0,panOnDrag:gn=!0,onPaneClick:ho,onPaneMouseEnter:po,onPaneMouseMove:mo,onPaneMouseLeave:fo,onPaneScroll:go,onPaneContextMenu:xo,paneClickDistance:Ot=1,nodeClickDistance:yt=0,children:Lt,onReconnect:P,onReconnectStart:G,onReconnectEnd:ae,onEdgeContextMenu:ze,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Vl,onEdgeMouseMove:Hl,onEdgeMouseLeave:Fl,reconnectRadius:Wl=10,onNodesChange:Zl,onEdgesChange:Yl,noDragClassName:Xl="nodrag",noWheelClassName:ql="nowheel",noPanClassName:ka="nopan",fitView:Sa,fitViewOptions:Ca,connectOnClick:Kl,attributionPosition:Ul,proOptions:Gl,defaultEdgeOptions:Jl,elevateNodesOnSelect:Ql=!0,elevateEdgesOnSelect:ed=!1,disableKeyboardA11y:$a=!1,autoPanOnConnect:td,autoPanOnNodeDrag:nd,autoPanOnSelection:od=!0,autoPanSpeed:ad,connectionRadius:rd,isValidConnection:sd,onError:id,style:ld,id:Ea,nodeDragThreshold:dd,connectionDragThreshold:cd,viewport:ud,onViewportChange:hd,width:pd,height:md,colorMode:fd="light",debug:gd,onScroll:Ma,ariaLabelConfig:xd,zIndexMode:za="basic",...vd},yd){let vo=Ea||"1",bd=Im(fd),wd=(0,L.useCallback)(_a=>{_a.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ma?.(_a)},[Ma]);return(0,I.jsx)("div",{"data-testid":"rf__wrapper",...vd,onScroll:wd,style:{...ld,...rg},ref:yd,className:ve(["react-flow",r,bd]),id:Ea,role:"application",children:(0,I.jsxs)(ag,{nodes:e,edges:t,width:pd,height:md,fitView:Sa,fitViewOptions:Ca,minZoom:Ae,maxZoom:Ne,nodeOrigin:be,nodeExtent:Rt,zIndexMode:za,children:[(0,I.jsx)(Am,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:f,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,nodesDraggable:ge,autoPanOnNodeFocus:je,nodesConnectable:Ee,nodesFocusable:Me,edgesFocusable:Pe,edgesReconnectable:Be,elementsSelectable:Ve,elevateNodesOnSelect:Ql,elevateEdgesOnSelect:ed,minZoom:Ae,maxZoom:Ne,nodeExtent:Rt,onNodesChange:Zl,onEdgesChange:Yl,snapToGrid:se,snapGrid:re,connectionMode:V,translateExtent:we,connectOnClick:Kl,defaultEdgeOptions:Jl,fitView:Sa,fitViewOptions:Ca,onNodesDelete:F,onEdgesDelete:O,onDelete:R,onNodeDragStart:M,onNodeDrag:C,onNodeDragStop:_,onSelectionDrag:N,onSelectionDragStart:g,onSelectionDragStop:k,onMove:c,onMoveStart:p,onMoveEnd:d,noPanClassName:ka,nodeOrigin:be,rfId:vo,autoPanOnConnect:td,autoPanOnNodeDrag:nd,autoPanSpeed:ad,onError:id,connectionRadius:rd,isValidConnection:sd,selectNodesOnDrag:ce,nodeDragThreshold:dd,connectionDragThreshold:cd,onBeforeDelete:B,debug:gd,ariaLabelConfig:xd,zIndexMode:za}),(0,I.jsx)(tg,{onInit:u,onNodeClick:l,onEdgeClick:h,onNodeMouseEnter:E,onNodeMouseMove:v,onNodeMouseLeave:b,onNodeContextMenu:j,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:i,connectionLineType:W,connectionLineStyle:J,connectionLineComponent:X,connectionLineContainerStyle:Z,selectionKeyCode:Q,selectionOnDrag:T,selectionMode:K,deleteKeyCode:ee,multiSelectionKeyCode:ie,panActivationKeyCode:oe,zoomActivationKeyCode:q,onlyRenderVisibleElements:le,defaultViewport:Se,translateExtent:we,minZoom:Ae,maxZoom:Ne,preventScrolling:vt,zoomOnScroll:mn,zoomOnPinch:lo,zoomOnDoubleClick:Je,panOnScroll:co,panOnScrollSpeed:fn,panOnScrollMode:uo,panOnDrag:gn,autoPanOnSelection:od,onPaneClick:ho,onPaneMouseEnter:po,onPaneMouseMove:mo,onPaneMouseLeave:fo,onPaneScroll:go,onPaneContextMenu:xo,paneClickDistance:Ot,nodeClickDistance:yt,onSelectionContextMenu:z,onSelectionStart:A,onSelectionEnd:$,onReconnect:P,onReconnectStart:G,onReconnectEnd:ae,onEdgeContextMenu:ze,onEdgeDoubleClick:Bl,onEdgeMouseEnter:Vl,onEdgeMouseMove:Hl,onEdgeMouseLeave:Fl,reconnectRadius:Wl,defaultMarkerColor:pn,noDragClassName:Xl,noWheelClassName:ql,noPanClassName:ka,rfId:vo,disableKeyboardA11y:$a,nodeExtent:Rt,viewport:ud,onViewportChange:hd,nodesDraggable:ge}),(0,I.jsx)(Mm,{onSelectionChange:H}),Lt,(0,I.jsx)(km,{proOptions:Gl,position:Ul}),(0,I.jsx)(Nm,{rfId:vo,disableKeyboardA11y:$a})]})})}var ig=Ui(sg),lg=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function dg({children:e}){let t=de(lg);return t?(0,gm.createPortal)(e,t):null}var cg=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function ug(){return de(cg,fe)}var Zy=_e.error014();function hg({dimensions:e,lineWidth:t,variant:n,className:o}){return(0,I.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ve(["react-flow__background-pattern",n,o])})}function pg({radius:e,className:t}){return(0,I.jsx)("circle",{cx:e,cy:e,r:e,className:ve(["react-flow__background-pattern","dots",t])})}var Ue;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ue||(Ue={}));var mg={[Ue.Dots]:1,[Ue.Lines]:1,[Ue.Cross]:6},fg=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Nl({id:e,variant:t=Ue.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=0,color:i,bgColor:l,style:h,className:u,patternClassName:c}){let p=(0,L.useRef)(null),{transform:d,patternId:m}=de(fg,fe),f=o||mg[t],w=t===Ue.Dots,y=t===Ue.Cross,x=Array.isArray(n)?n:[n,n],E=[x[0]*d[2]||1,x[1]*d[2]||1],v=f*d[2],b=Array.isArray(s)?s:[s,s],j=y?[v,v]:E,S=[b[0]*d[2]+j[0]/2,b[1]*d[2]+j[1]/2],M=`${m}${e||""}`;return(0,I.jsxs)("svg",{className:ve(["react-flow__background",u]),style:{...h,...io,"--xy-background-color-props":l,"--xy-background-pattern-color-props":i},ref:p,"data-testid":"rf__background",children:[(0,I.jsx)("pattern",{id:M,x:d[0]%E[0],y:d[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:w?(0,I.jsx)(pg,{radius:v/2,className:c}):(0,I.jsx)(hg,{dimensions:j,lineWidth:r,variant:t,className:c})}),(0,I.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}Nl.displayName="Background";var gg=(0,L.memo)(Nl);function xg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,I.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function vg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,I.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function yg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,I.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 bg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,I.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 wg(){return(0,I.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,I.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 In({children:e,className:t,...n}){return(0,I.jsx)("button",{type:"button",className:ve(["react-flow__controls-button",t]),...n,children:e})}var jg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function kl({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:i,onFitView:l,onInteractiveChange:h,className:u,children:c,position:p="bottom-left",orientation:d="vertical","aria-label":m}){let f=pe(),{isInteractive:w,minZoomReached:y,maxZoomReached:x,ariaLabelConfig:E}=de(jg,fe),{zoomIn:v,zoomOut:b,fitView:j}=Dt(),S=()=>{v(),s?.()},M=()=>{b(),i?.()},C=()=>{j(r),l?.()},_=()=>{f.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),h?.(!w)};return(0,I.jsxs)(so,{className:ve(["react-flow__controls",d==="horizontal"?"horizontal":"vertical",u]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??E["controls.ariaLabel"],children:[t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(In,{onClick:S,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:x,children:(0,I.jsx)(xg,{})}),(0,I.jsx)(In,{onClick:M,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:y,children:(0,I.jsx)(vg,{})})]}),n&&(0,I.jsx)(In,{className:"react-flow__controls-fitview",onClick:C,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:(0,I.jsx)(yg,{})}),o&&(0,I.jsx)(In,{className:"react-flow__controls-interactive",onClick:_,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:w?(0,I.jsx)(wg,{}):(0,I.jsx)(bg,{})}),c]})}kl.displayName="Controls";var Yy=(0,L.memo)(kl);function Ng({id:e,x:t,y:n,width:o,height:r,style:s,color:i,strokeColor:l,strokeWidth:h,className:u,borderRadius:c,shapeRendering:p,selected:d,onClick:m}){let{background:f,backgroundColor:w}=s||{},y=i||f||w;return(0,I.jsx)("rect",{className:ve(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:c,ry:c,width:o,height:r,style:{fill:y,stroke:l,strokeWidth:h},shapeRendering:p,onClick:m?x=>m(x,e):void 0})}var kg=(0,L.memo)(Ng),Sg=e=>e.nodes.map(t=>t.id),Bo=e=>e instanceof Function?e:()=>e;function Cg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:s=kg,onClick:i}){let l=de(Sg,fe),h=Bo(t),u=Bo(e),c=Bo(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return(0,I.jsx)(I.Fragment,{children:l.map(d=>(0,I.jsx)(Eg,{id:d,nodeColorFunc:h,nodeStrokeColorFunc:u,nodeClassNameFunc:c,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:s,onClick:i,shapeRendering:p},d))})}function $g({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:l,onClick:h}){let{node:u,x:c,y:p,width:d,height:m}=de(f=>{let w=f.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};let y=w.internals.userNode,{x,y:E}=w.internals.positionAbsolute,{width:v,height:b}=Te(y);return{node:y,x,y:E,width:v,height:b}},fe);return!u||u.hidden||!ji(u)?null:(0,I.jsx)(l,{x:c,y:p,width:d,height:m,style:u.style,selected:!!u.selected,className:o(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:s,shapeRendering:i,onClick:h,id:u.id})}var Eg=(0,L.memo)($g),Mg=(0,L.memo)(Cg),zg=200,_g=150,Pg=e=>!e.hidden,Ag=e=>{let 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]},n=!1;for(let o of e.nodeLookup.values())if(!o.hidden){n=!0;break}return{viewBB:t,boundingRect:n?yi(dn(e.nodeLookup,{filter:Pg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ks=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Ig=(e,t)=>ks(e.viewBB,t.viewBB)&&ks(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Dg="react-flow__minimap-desc";function Sl({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:l,bgColor:h,maskColor:u,maskStrokeColor:c,maskStrokeWidth:p,position:d="bottom-right",onClick:m,onNodeClick:f,pannable:w=!1,zoomable:y=!1,ariaLabel:x,inversePan:E,zoomStep:v=1,offsetScale:b=5}){let j=pe(),S=(0,L.useRef)(null),{boundingRect:M,panZoom:C,viewBB:_,rfId:F,translateExtent:O,flowWidth:R,flowHeight:H,ariaLabelConfig:g}=de(Ag,Ig),N=e?.width??zg,k=e?.height??_g,z=M.width/N,A=M.height/k,$=Math.max(z,A),B=$*N,V=$*k,W=b*$,J=M.x-(B-M.width)/2-W,X=M.y-(V-M.height)/2-W,Z=B+W*2,ee=V+W*2,Q=`${Dg}-${F}`,T=(0,L.useRef)(0),K=(0,L.useRef)();T.current=$,(0,L.useEffect)(()=>{let re=j.getState().panZoom;if(S.current&&re)return K.current=Xp({domNode:S.current,panZoom:re,getTransform:()=>j.getState().transform,getViewScale:()=>T.current}),()=>{K.current?.destroy()}},[C]),(0,L.useEffect)(()=>{K.current?.update({translateExtent:O,width:R,height:H,inversePan:E,pannable:w,zoomStep:v,zoomable:y})},[w,y,E,v,O,R,H]);let oe=m?re=>{let[le,ce]=K.current?.pointer(re)||[0,0];m(re,{x:le,y:ce})}:void 0,ie=(0,L.useCallback)((re,le)=>{let ce=j.getState().nodeLookup.get(le).internals.userNode;f?.(re,ce)},[f]),q=f?ie:void 0,se=x??g["minimap.ariaLabel"];return(0,I.jsx)(so,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*$:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:ve(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,I.jsxs)("svg",{width:N,height:k,viewBox:`${J} ${X} ${Z} ${ee}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Q,ref:S,onClick:oe,children:[se&&(0,I.jsx)("title",{id:Q,children:se}),(0,I.jsx)(Mg,{onClick:q,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:l}),(0,I.jsx)("path",{className:"react-flow__minimap-mask",d:`M${J-W},${X-W}h${Z+W*2}v${ee+W*2}h${-Z-W*2}z
|
|
8
|
+
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Sl.displayName="MiniMap";var Xy=(0,L.memo)(Sl),Rg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Og={[ft.Line]:"right",[ft.Handle]:"bottom-right"};function Lg({nodeId:e,position:t,variant:n=ft.Handle,className:o,style:r=void 0,children:s,color:i,minWidth:l=10,minHeight:h=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:d,autoScale:m=!0,shouldResize:f,onResizeStart:w,onResize:y,onResizeEnd:x}){let E=tl(),v=typeof e=="string"?e:E,b=pe(),j=(0,L.useRef)(null),S=n===ft.Handle,M=de((0,L.useCallback)(Rg(S&&m),[S,m]),fe),C=(0,L.useRef)(null),_=t??Og[n];(0,L.useEffect)(()=>{if(!(!j.current||!v))return C.current||(C.current=lm({domNode:j.current,nodeId:v,getStoreItems:()=>{let{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,domNode:k}=b.getState();return{nodeLookup:O,transform:R,snapGrid:H,snapToGrid:g,nodeOrigin:N,paneDomNode:k}},onChange:(O,R)=>{let{triggerNodeChanges:H,nodeLookup:g,parentLookup:N,nodeOrigin:k}=b.getState(),z=[],A={x:O.x,y:O.y},$=g.get(v);if($&&$.expandParent&&$.parentId){let B=$.origin??k,V=O.width??$.measured.width??0,W=O.height??$.measured.height??0,J={id:$.id,parentId:$.parentId,rect:{width:V,height:W,...Ni({x:O.x??$.position.x,y:O.y??$.position.y},{width:V,height:W},$.parentId,g,B)}},X=ya([J],g,N,k);z.push(...X),A.x=O.x?Math.max(B[0]*V,O.x):void 0,A.y=O.y?Math.max(B[1]*W,O.y):void 0}if(A.x!==void 0&&A.y!==void 0){let B={id:v,type:"position",position:{...A}};z.push(B)}if(O.width!==void 0&&O.height!==void 0){let B={id:v,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};z.push(B)}for(let B of R){let V={...B,type:"position"};z.push(V)}H(z)},onEnd:({width:O,height:R})=>{let H={id:v,type:"dimensions",resizing:!1,dimensions:{width:O,height:R}};b.getState().triggerNodeChanges([H])}})),C.current.update({controlPosition:_,boundaries:{minWidth:l,minHeight:h,maxWidth:u,maxHeight:c},keepAspectRatio:p,resizeDirection:d,onResizeStart:w,onResize:y,onResizeEnd:x,shouldResize:f}),()=>{C.current?.destroy()}},[_,l,h,u,c,p,w,y,x,f]);let F=_.split("-");return(0,I.jsx)("div",{className:ve(["react-flow__resize-control","nodrag",...F,n,o]),ref:j,style:{...r,scale:M,...i&&{[S?"backgroundColor":"borderColor"]:i}},children:s})}var Ss=(0,L.memo)(Lg);function Tg({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:o,lineClassName:r,lineStyle:s,color:i,minWidth:l=10,minHeight:h=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:p=!1,autoScale:d=!0,shouldResize:m,onResizeStart:f,onResize:w,onResizeEnd:y}){return t?(0,I.jsxs)(I.Fragment,{children:[om.map(x=>(0,I.jsx)(Ss,{className:r,style:s,nodeId:e,position:x,variant:ft.Line,color:i,minWidth:l,minHeight:h,maxWidth:u,maxHeight:c,onResizeStart:f,keepAspectRatio:p,autoScale:d,shouldResize:m,onResize:w,onResizeEnd:y},x)),nm.map(x=>(0,I.jsx)(Ss,{className:n,style:o,nodeId:e,position:x,color:i,minWidth:l,minHeight:h,maxWidth:u,maxHeight:c,onResizeStart:f,keepAspectRatio:p,autoScale:d,shouldResize:m,onResize:w,onResizeEnd:y},x))]}):null}var D=et(Nt(),1),Cl=e=>`$${(e/1e6).toFixed(2)}`;function Bg(e){let t=e.trim().replace(/^\$/,"");if(t==="")return{ok:!0,value:null};let n=Number(t);return!/^\d+(\.\d{1,2})?$/.test(t)||n<=0||Math.round(n*1e6)>1e8?{ok:!1,message:`Give the budget in dollars, up to ${Cl(1e8)}, or leave it empty.`}:{ok:!0,value:Math.round(n*1e6)}}function Vg(e){let t=e.trim();if(t==="")return{ok:!0,value:null};let n=Number(t);return!/^\d+$/.test(t)||!Number.isInteger(n)||n<1||n>50?{ok:!1,message:"Give runs a day as 1 to 50, or leave it empty."}:{ok:!0,value:n}}var Cs=e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(e)),Hg=e=>`It covers ${e.length===1?"this schedule":"these schedules"} when ${e.length===1?"it fires":"they fire"} on time: ${e.map(t=>t.words).join("; ")}. Run now, and schedules added or changed later, wait for you.`;function $l(e,t){return[e===null?"No dollar cap per attempt.":`Each attempt may spend up to ${Cl(e)}.`,t===null?"No daily limit on runs.":`At most ${t} run${t===1?"":"s"} a day (UTC); after that, cards wait for you.`]}var Fg=e=>`Ends ${e} day${e===1?"":"s"} after you sign. Revoking it earlier is one click.`,a=et(_o(),1);function gt({name:e,size:t="sm"}){let n=[...e].reduce((r,s)=>(r*31+s.charCodeAt(0))%360,7),o=e.split(/[\s._-]+/).filter(Boolean).map(r=>r[0].toUpperCase()).slice(0,2).join("")||e.slice(0,2).toUpperCase();return(0,a.jsx)("span",{title:e,"aria-label":e,className:xe("inline-flex shrink-0 items-center justify-center rounded-full font-semibold text-white",t==="sm"?"size-5 text-[9px]":"size-7 text-[11px]"),style:{background:`hsl(${n} 45% 45%)`},children:o})}var At={slate:"var(--so-muted)",blue:"var(--so-info)",violet:"var(--so-ink)",amber:"var(--so-neutral-ink)",green:"var(--so-success)",rose:"var(--so-danger)"},Wg={slate:"Muted",blue:"Blue",violet:"Ink",amber:"Neutral",green:"Green",rose:"Red"},El={inbox:(0,a.jsx)(Xa,{className:"size-3.5","aria-hidden":"true"}),task:(0,a.jsx)(Za,{className:"size-3.5","aria-hidden":"true"}),report:(0,a.jsx)(Ja,{className:"size-3.5","aria-hidden":"true"}),approval:(0,a.jsx)(Ia,{className:"size-3.5","aria-hidden":"true"}),notify:(0,a.jsx)(qa,{className:"size-3.5","aria-hidden":"true"}),done:(0,a.jsx)(Fa,{className:"size-3.5","aria-hidden":"true"}),check:(0,a.jsx)(jo,{className:"size-3.5","aria-hidden":"true"}),"pull-request":(0,a.jsx)(wo,{className:"size-3.5","aria-hidden":"true"}),update:(0,a.jsx)(Ka,{className:"size-3.5","aria-hidden":"true"}),sort:(0,a.jsx)(yo,{className:"size-3.5","aria-hidden":"true"}),draft:(0,a.jsx)(Ga,{className:"size-3.5","aria-hidden":"true"}),request:(0,a.jsx)(Wa,{className:"size-3.5","aria-hidden":"true"}),email:(0,a.jsx)(No,{className:"size-3.5","aria-hidden":"true"}),tool:(0,a.jsx)(Oa,{className:"size-3.5","aria-hidden":"true"}),wait:(0,a.jsx)(Ya,{className:"size-3.5","aria-hidden":"true"}),subagent:(0,a.jsx)(Ba,{className:"size-3.5","aria-hidden":"true"}),send:(0,a.jsx)(Qa,{className:"size-3.5","aria-hidden":"true"}),choose:(0,a.jsx)(Pa,{className:"size-3.5","aria-hidden":"true"})};function wa({sorted:e}){return(0,a.jsxs)("span",{className:xe("inline-flex max-w-full items-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-mono-count leading-4 font-medium",!e.confident&&"text-foreground"),title:e.confident?"Sorted by Jev":"Jev wasn't sure","data-sort-chip":!0,children:[(0,a.jsx)(yo,{className:"size-3 shrink-0",style:{color:e.confident?At.violet:void 0},"aria-hidden":"true"}),(0,a.jsx)("span",{className:"truncate",children:e.confident?e.chip:`Not sure · ${e.chip}`})]})}var Ml={button:(0,a.jsx)(Ua,{className:"size-3.5","aria-hidden":"true"}),schedule:(0,a.jsx)(Va,{className:"size-3.5","aria-hidden":"true"}),github:(0,a.jsx)(wo,{className:"size-3.5","aria-hidden":"true"}),linear:(0,a.jsx)(Aa,{className:"size-3.5","aria-hidden":"true"}),flow:(0,a.jsx)(Ra,{className:"size-3.5","aria-hidden":"true"}),webhook:(0,a.jsx)(Da,{className:"size-3.5","aria-hidden":"true"}),email:(0,a.jsx)(No,{className:"size-3.5","aria-hidden":"true"}),chat:(0,a.jsx)(ko,{className:"size-3.5","aria-hidden":"true"})},Zg=()=>{try{return new URLSearchParams(window.location.search).get("browser")==="1"}catch{return!1}};async function me(e,t,n){let o=new URLSearchParams({csrf:n,...t});try{let r=await fetch(e,{method:"POST",body:o,credentials:"same-origin",headers:lr({accept:"application/json"}),signal:AbortSignal.timeout(2e4)}),s=await r.json();return{ok:s.ok===!0,said:typeof s.said=="string"?s.said:r.ok?"Done.":"That didn't go through.",...s.view===void 0?{}:{view:s.view},...s.reveal===void 0?{}:{reveal:s.reveal}}}catch{return{ok:!1,said:"That didn't go through. Check your connection and try again."}}}function Yg(e,t,n){let[o,r]=(0,D.useState)([]),s=(0,D.useRef)(e.live);s.current=e.live;let i=(0,D.useRef)(n.editing);i.current=n.editing;let l=(0,D.useRef)(!1),h=(0,D.useRef)(!1),u=(0,D.useRef)(void 0),c=e.flow.href,p=(0,D.useCallback)(async()=>{if(l.current||i.current){h.current=!0;return}l.current=!0,h.current=!1,window.clearTimeout(u.current);let d=!1;try{let m=await fetch(`${c}?format=json`,{credentials:"same-origin",headers:{accept:"application/json"}});if(m.ok){let f=await m.json();s.current=f.live,t(f),d=!0}}catch{}finally{l.current=!1}h.current?p():d||(u.current=window.setTimeout(()=>{document.visibilityState==="visible"&&p()},5e3))},[c,t]);return(0,D.useEffect)(()=>{!n.editing&&h.current&&p()},[n.editing,p]),(0,D.useEffect)(()=>()=>window.clearTimeout(u.current),[]),ir(sr("flow",e.flow.id,{card:n.card,editing:n.editing}),(d,m)=>{if(d==="change"){let f=m.at;(typeof f!="string"||f!==s.current)&&p()}else if(d==="reload")p();else if(d==="here"){let f=m.people;Array.isArray(f)&&r(f)}else(d==="gone"||d==="lost")&&r([])}),o}function Xg({others:e,cards:t}){if(e.length===0)return null;let n=s=>{if(s.editing)return"changing this flow";let i=s.cards.map(l=>t.find(h=>h.id===l)?.title).filter(l=>l!==void 0);return i.length===0?"looking at the flow":`looking at ${i.map(l=>`“${l}”`).join(", ")}`},o=e.map(s=>`${s.name} is ${n(s)}`).join(". "),r=e.find(s=>s.editing);return(0,a.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1.5","data-also-here":!0,role:"status","aria-label":`Also here: ${o}`,title:o,children:[(0,a.jsx)("span",{className:"flex -space-x-1.5",children:e.slice(0,4).map(s=>(0,a.jsx)("span",{className:"rounded-full ring-2 ring-card",children:(0,a.jsx)(gt,{name:s.name})},s.name))}),(0,a.jsx)("span",{className:"truncate text-caption text-muted-foreground font-normal",children:r!==void 0?`${r.name} is changing this flow`:e.length===1?`${e[0].name} is here`:`${e.length} others here`})]})}function qg({data:e,selected:t}){let{stage:n,cards:o,editing:r,canMove:s}=e,[i,l]=(0,D.useState)(!1),h=xe("fl-handle",!r&&"off");return(0,a.jsxs)("div",{className:xe("fl-zone-n",t&&r&&"selected",i&&"over"),onDragOver:u=>{!s||r||(u.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:u=>{l(!1);let c=Number(u.dataTransfer.getData("text/so-card"));c>0&&e.onDrop(c,n.id)},"data-zone":n.id,children:[r&&(0,a.jsx)(Tg,{isVisible:t,minWidth:220,minHeight:160,lineClassName:"fl-resize-line",handleClassName:"fl-resize-handle",onResizeEnd:(u,c)=>e.onResize(n.id,c)}),(0,a.jsx)(Ke,{type:"source",position:U.Right,id:"next",className:xe(h,"next"),isConnectable:r}),(0,a.jsx)(Ke,{type:"source",position:U.Bottom,id:"fail",className:xe(h,"fail"),style:{left:"75%"},isConnectable:r}),["Left","Right","Top","Bottom"].map(u=>(0,a.jsx)(Ke,{type:"target",position:U[u],id:`t-${u}`,className:h,isConnectable:r},`t-${u}`)),["Left","Right","Top","Bottom"].map(u=>(0,a.jsx)(Ke,{type:"source",position:U[u],id:`s-${u}`,className:"fl-handle route",isConnectable:!1},`s-${u}`)),(0,a.jsxs)("header",{className:"fl-zone-h",children:[(0,a.jsx)("span",{className:"fl-ico",style:{color:At[n.zone.color]??At.slate},children:El[n.kind]}),(0,a.jsxs)("span",{className:"fl-zone-t",children:[(0,a.jsx)("b",{children:n.title}),(0,a.jsxs)("span",{children:[e.kindLabel,e.start?" · new cards start here":"",e.subagent!==null?` · ${e.subagent}`:n.toOwner===!0?` · ${e.owner}`:n.approver?` · ${n.approver}`:""]})]}),o.length>0&&(0,a.jsx)(bt,{n:o.length,ink:o.some(u=>u.canDecide)})]}),e.browserLine!==null&&n.kind==="check"&&n.browser===!0&&!r&&(0,a.jsx)("p",{className:"fl-zone-br","data-zone-browser":!0,children:e.browserLine}),(0,a.jsxs)("ul",{className:"nowheel fl-zone-cards",children:[o.map(u=>(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",draggable:s&&!r,onDragStart:c=>{c.dataTransfer.setData("text/so-card",String(u.id)),c.dataTransfer.effectAllowed="move"},onClick:c=>e.onCard(u.id,c.currentTarget),className:xe("nodrag nopan fl-card",e.selectedCard===u.id&&"selected",u.canDecide&&"wait"),"data-card":u.id,children:[(0,a.jsxs)("span",{className:"fl-card-top",children:[(0,a.jsx)("span",{className:"fl-card-t",children:u.title}),(e.lookers[u.id]?.length??0)>0&&(0,a.jsx)("span",{className:"fl-faces","data-card-lookers":!0,title:`${e.lookers[u.id].join(" and ")} ${e.lookers[u.id].length===1?"is":"are"} looking at this`,children:e.lookers[u.id].slice(0,2).map(c=>(0,a.jsx)(gt,{name:c},c))})]}),u.sorted!==null&&(0,a.jsx)("span",{className:"fl-card-l",children:(0,a.jsx)(wa,{sorted:u.sorted})}),u.waiting!==null&&(0,a.jsx)("span",{className:xe("fl-card-l",u.canDecide||u.question?.mine?"mine":""),children:(0,a.jsx)("span",{children:u.canDecide?xn.card.sentence({}):u.question?.mine?`${u.question.from.split(" · ")[0]} asks you`:u.waiting})}),u.deadline!=null&&(0,a.jsx)("span",{className:"fl-card-l","data-card-deadline":!0,children:vn(u.deadline,Bt(),wt())}),(u.owner!==null||u.comments.length>0)&&(0,a.jsxs)("span",{className:"fl-card-foot",children:[u.owner!==null&&(0,a.jsx)(gt,{name:u.owner}),(0,a.jsx)("span",{className:"k-grow"}),u.comments.length>0&&(0,a.jsxs)("span",{className:"fl-card-c",children:[(0,a.jsx)(ko,{className:"size-3","aria-hidden":"true"}),u.comments.length]})]})]})},u.id)),o.length===0&&(0,a.jsx)("li",{className:"fl-zone-empty",children:r?n.kind==="done"?"":"Drag the dots to connect zones.":e.hidden>0?"":"No cards here."}),e.hidden>0&&(0,a.jsxs)("li",{className:"fl-zone-empty",children:[e.hidden," other card",e.hidden===1?"":"s"]})]})]})}var zl=48,_l=30;function Kg({data:e}){return(0,a.jsxs)("div",{className:"fl-trig-n","data-trigger-group":!0,children:[(0,a.jsx)(Ke,{type:"source",position:U.Right,id:"out",className:"fl-handle route",isConnectable:!1}),(0,a.jsxs)("div",{className:"fl-trig-h",style:{height:_l},children:[(0,a.jsx)(cr,{name:"bolt",small:!0}),"Starts cards"]}),e.triggers.map(t=>{let n=t.failing||t.hook!==null&&!t.hook.ready,o=t.state==="paused"?"Paused":t.failing?"Needs attention":t.hook!==null&&!t.hook.ready?"Needs its secret":t.detail;return(0,a.jsxs)("div",{className:xe("fl-trig",t.state==="paused"&&"paused"),style:{height:zl},"data-trigger":t.id,children:[(0,a.jsx)("span",{className:"fl-ico",children:Ml[t.kind]??(0,a.jsx)(bo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("span",{className:"fl-trig-b",children:[(0,a.jsx)(he,{variant:"ghost",sm:!0,label:t.name,className:"nodrag nopan","aria-label":`Trigger: ${t.words}`,onClick:r=>e.onOpen(t.id,r.currentTarget)}),(0,a.jsx)("span",{className:n?"bad":"",children:o})]}),t.button!==null&&t.state==="active"&&(0,a.jsx)(he,{sm:!0,label:"Start",className:"nodrag nopan",onClick:r=>e.onPress(t.id,r.currentTarget)})]},t.id)})]})}var Ug={zone:qg,trigger:Kg};function Gg({sourceX:e,sourceY:t,sourcePosition:n,targetX:o,targetY:r,targetPosition:s,label:i,labelStyle:l,labelBgStyle:h,markerEnd:u,style:c,data:p}){let{path:d,shift:m}=p??{},[f,w,y]=nn({sourceX:e,sourceY:t,sourcePosition:n,targetX:o,targetY:r,targetPosition:s,...d}),x=l;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(hn,{path:f,...u===void 0?{}:{markerEnd:u},...c===void 0?{}:{style:c}}),(0,a.jsx)(dg,{children:(0,a.jsx)("div",{className:"nodrag nopan pointer-events-none absolute rounded-sm px-1 leading-4 whitespace-nowrap",style:{transform:`translate(-50%, -50%) translate(${w+(m?.x??0)}px, ${y+(m?.y??0)}px)`,color:x?.fill,fontSize:x?.fontSize,fontWeight:x?.fontWeight,background:h?.fill},children:i})})]})}var Jg={named:Gg};function Qg(e,t){let n=(s,i)=>{let l=t.find(p=>p.id===s)?.zone;if(l===void 0||i==null)return null;let h=i.slice(2),u=h==="Left"?l.x:h==="Right"?l.x+l.w:l.x+l.w/2,c=h==="Top"?l.y:h==="Bottom"?l.y+l.h:l.y+l.h/2;return{x:u,y:c,position:U[h]}},o=[],r=s=>o.some(i=>Math.abs(i.x-s.x)<(i.w+s.w)/2+4&&Math.abs(i.y-s.y)<(i.h+s.h)/2+2);return e.map(s=>{if(typeof s.label!="string"||s.type!=="smoothstep")return s;let i=n(s.source,s.sourceHandle),l=n(s.target,s.targetHandle);if(i===null||l===null)return s;let h=s.pathOptions,[,u,c]=nn({sourceX:i.x,sourceY:i.y,sourcePosition:i.position,targetX:l.x,targetY:l.y,targetPosition:l.position,...h}),p=s.label.length*6.4+10,d=18,m=(i.position===U.Left||i.position===U.Right)&&(l.position===U.Left||l.position===U.Right)?{x:0,y:d+6}:{x:p/2+34,y:0},f={x:0,y:0};for(let x of[0,1,-1,2,-2,3,-3])if(f={x:m.x*x,y:m.y*x},!r({x:u+f.x,y:c+f.y,w:p,h:d}))break;o.push({x:u+f.x,y:c+f.y,w:p,h:d});let{pathOptions:w,...y}=s;return{...y,type:"named",data:{...s.data,path:h,shift:f}}})}function Pl(e,t){let n=[],o=new Set,r=s=>{for(;s!==null&&!o.has(s);){let i=e.find(l=>l.id===s);if(i===void 0)return;o.add(s),n.push(i);for(let l of i.sort?.answers??[])r(l.to);i.sort!==null&&i.onFail!==null&&r(i.onFail),s=i.next}};r(t);for(let s of e)o.has(s.id)||r(s.id);return[...n.filter(s=>s.kind!=="done"),...n.filter(s=>s.kind==="done")]}function e0(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,24)||"zone",o=n,r=2;for(;t.has(o);)o=`${n}-${r++}`;return o}var an=e=>So(e),t0=(e,t=Bt())=>Number.isNaN(new Date(e).getTime())?"":dr(e,t,wt(),!0),n0=e=>e%1440===0?`${e/1440} day${e===1440?"":"s"}`:e%60===0?`${e/60} h`:`${e} min`;function o0({link:e}){return e===null?null:(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.href,"data-status-link":!0,children:e.label})]})}function a0({body:e,mentions:t}){if(t.length===0)return(0,a.jsx)(a.Fragment,{children:e});let n=new RegExp(`(@(?:${t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}))(?![A-Za-z0-9_])`,"gi");return(0,a.jsx)(a.Fragment,{children:e.split(n).map((o,r)=>r%2===1?(0,a.jsx)("span",{className:"font-semibold text-primary",children:o},r):o)})}function r0({card:e,view:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(""),[i,l]=(0,D.useState)(!1),h=/(?:^|\s)@([A-Za-z0-9_.-]*)$/.exec(r)?.[1],u=h===void 0?[]:t.approvers.filter(c=>c!==t.me&&c.toLowerCase().startsWith(h.toLowerCase())).slice(0,6);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-flow-discussion":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Discussion"}),e.comments.length===0?(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"No comments yet."}):(0,a.jsx)("ol",{className:"flex flex-col gap-3",children:e.comments.map(c=>(0,a.jsxs)("li",{className:"flex gap-2","data-comment":c.id,children:[(0,a.jsx)(gt,{name:c.author,size:"md"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[(0,a.jsx)("span",{className:"font-semibold text-foreground",children:c.author})," · ",an(c.at)]}),(0,a.jsx)("p",{className:"whitespace-pre-wrap break-words text-body",children:(0,a.jsx)(a0,{body:c.body,mentions:c.mentions})})]})]},c.id))}),t.canEdit&&(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async c=>{c.preventDefault(),l(!0);let p=await me(`${t.flow.href}/cards/${e.id}/comment`,{body:r},n);l(!1),o(p),p.ok&&s("")},children:[(0,a.jsx)(ye,{value:r,onChange:c=>s(c.target.value),rows:3,maxLength:4e3,placeholder:"Add a comment. Type @ and a name to ping someone.","aria-label":"Comment"}),u.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5","aria-label":"People to mention",children:u.map(c=>(0,a.jsxs)("button",{type:"button",className:"inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2 text-caption hover:border-primary/60 font-normal",onClick:()=>s(p=>p.replace(/@([A-Za-z0-9_.-]*)$/,`@${c} `)),children:[(0,a.jsx)(gt,{name:c}),c]},c))}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:i||r.trim()==="",children:"Comment"})]})]})}function s0({card:e,view:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(!1),i=async(h,u)=>{s(!0),o(await me(`${t.flow.href}/cards/${e.id}/${h}`,u,n)),s(!1)},l=e.watchers.filter(h=>h!==e.owner);return(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-flow-card-people":!0,children:[t.canEdit&&e.state==="active"?(0,a.jsxs)("label",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Owner"}),(0,a.jsxs)("select",{className:ue,value:e.owner??"",disabled:r,onChange:h=>{i("assign",{owner:h.target.value})},"aria-label":"Owner",children:[(0,a.jsx)("option",{value:"",children:"No owner"}),t.approvers.map(h=>(0,a.jsx)("option",{value:h,children:h===t.me?`${h} (you)`:h},h))]})]}):e.owner!==null&&(0,a.jsxs)("p",{className:"flex items-center gap-2 text-body",children:[(0,a.jsx)(gt,{name:e.owner})," Owned by ",e.owner]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[t.canEdit&&e.state==="active"&&e.owner===null&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:r,onClick:()=>{i("assign",{owner:t.me})},children:"Take it"}),l.length>0&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-caption text-muted-foreground font-normal",children:[l.slice(0,5).map(h=>(0,a.jsx)(gt,{name:h},h)),l.length===1?" follows it":" follow it"]}),t.canEdit&&e.owner!==t.me&&(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:r,onClick:()=>{i("watch",{watching:e.watching?"no":"yes"})},"aria-pressed":e.watching,children:e.watching?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(La,{className:"size-4"}),"Stop following"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Ta,{className:"size-4"}),"Follow"]})})]})]})}function Al({links:e}){return(0,a.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:e.map(t=>(0,a.jsx)("a",{className:"text-body text-primary underline-offset-4 hover:underline font-medium",href:t.href,...t.href.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:t.label},t.label))})}function Il({items:e}){return(0,a.jsx)("ol",{className:"flex flex-col gap-3","data-flow-items":!0,children:e.map(t=>(0,a.jsxs)("li",{className:"flex items-start gap-3","data-flow-item":t.number,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 text-[12.5px]",children:[(0,a.jsxs)("p",{className:"font-semibold",children:[t.number,". ",t.title]}),t.lines.map((n,o)=>(0,a.jsx)("p",{className:"break-words text-muted-foreground",children:n},o)),(0,a.jsx)("a",{className:"self-start font-medium text-primary underline-offset-4 hover:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.source})]}),t.image!==null&&(0,a.jsx)("a",{className:"w-28 shrink-0",href:t.image.src,target:"_blank",rel:"noreferrer",children:(0,a.jsx)("img",{className:"w-full rounded-md border object-cover object-top",style:{aspectRatio:"4 / 3"},src:t.image.src,alt:t.image.caption,loading:"lazy"})})]},t.number))})}function i0({sent:e}){return(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-flow-sent":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Sent to ",e.person," · ",an(e.at)]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e.title}),(0,a.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,a.jsx)(Il,{items:e.items}),e.card!==void 0&&(0,a.jsx)(Co,{card:e.card}),e.links.length>0&&(0,a.jsx)(Al,{links:e.links})]})]})}function l0({choose:e,base:t,csrf:n,apply:o}){let[r,s]=(0,D.useState)(""),[i,l]=(0,D.useState)(!1),h=async u=>{l(!0);let c=await me(`${t}/choose`,u,n);l(!1),o(c),c.ok&&s("")};return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-flow-choose":!0,children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e.title}),(0,a.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,a.jsx)(Il,{items:e.items}),e.links.length>0&&(0,a.jsx)(Al,{links:e.links}),e.mine?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map(u=>(0,a.jsx)(te,{size:"sm",variant:u.choice===0?"default":"outline",disabled:i,onClick:()=>{h({choice:String(u.choice),label:u.label,entry:String(e.entry)})},"data-flow-choice":u.choice,children:u.label},u.choice))}),e.reply&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ye,{value:r,onChange:u=>s(u.target.value),rows:2,maxLength:4e3,placeholder:"Or say what you'd change","aria-label":"What you'd change"}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:i||r.trim()==="",onClick:()=>{h({note:r,entry:String(e.entry)})},children:"Send reply"})]})]}):(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["Waiting for ",e.person," to choose."]})]})}function d0({card:e,view:t,csrf:n,apply:o,onAllowBrowser:r}){let[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(e.draft?.text??"");(0,D.useEffect)(()=>{h(e.draft?.text??"")},[e.id,e.draft?.text]);let[u,c]=(0,D.useState)(!1),p=t.stages.find(f=>f.id===e.stage),d=async(f,w)=>{c(!0);let y=await me(f,w,n);c(!1),o(y),y.ok&&i("")},m=`${t.flow.href}/cards/${e.id}`;return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-card-panel":e.id,children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[e.state==="active"?`In ${p?.title??e.stage}`:e.state==="done"?"Done":e.waiting==="Ignored"?"Ignored":"Cancelled"," · added by ",e.createdBy]}),e.sorted!==null&&(0,a.jsx)("div",{className:"mt-1.5 flex",children:(0,a.jsx)(wa,{sorted:e.sorted})})]}),e.source!==null&&(e.source.shown!=null&&e.source.url!==null?(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal break-all",children:["From ",e.source.label,e.source.proved===void 0?null:` (${e.source.proved})`," · ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,target:"_blank",rel:"noopener noreferrer",children:e.source.shown})]}):(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["From ",e.source.url===null?e.source.label:(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,...e.source.url.startsWith("/")?{}:{target:"_blank",rel:"noopener noreferrer"},children:e.source.label}),e.source.proved===void 0?null:` (${e.source.proved})`]})),e.description!==null&&(0,a.jsx)("p",{className:"whitespace-pre-wrap text-body",children:e.description}),e.waiting!==null&&e.question==null&&e.choose==null&&e.state==="active"&&(0,a.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-body",children:[e.waiting,e.deadline!=null&&(0,a.jsx)("span",{className:"block text-muted-foreground",children:vn(e.deadline,Bt(),wt())})]}),e.browserWait===!0&&e.state==="active"&&t.canEdit&&t.browser?.canApprove!==!1&&(r!==void 0?(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start phone:min-h-11",onClick:r,"data-card-allow-browser":!0,children:"Allow browser"}):(0,a.jsx)("a",{className:"text-body font-medium text-primary underline-offset-4 hover:underline",href:`${t.flow.href}?browser=1`,"data-card-allow-browser":!0,children:"Allow browser"})),e.question!=null&&(0,a.jsx)(p0,{question:e.question,csrf:n,apply:o}),e.choose!=null&&(0,a.jsx)(l0,{choose:e.choose,base:`${t.flow.href}/cards/${e.id}`,csrf:n,apply:o}),e.sent!=null&&(0,a.jsx)(i0,{sent:e.sent}),e.result!==void 0&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:"What happened"}),(0,a.jsx)(Co,{card:e.result})]}),e.question!=null&&e.deadline!=null&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:vn(e.deadline,Bt(),wt())}),(0,a.jsx)(s0,{card:e,view:t,csrf:n,apply:o}),e.task!==null&&(0,a.jsx)("a",{className:"text-body text-primary underline-offset-4 hover:underline font-medium",href:e.task.href,children:"Open its task"}),e.task?.composer!=null&&(0,a.jsxs)("div",{className:"flex flex-col gap-1","data-flow-task-composer":!0,children:[(0,a.jsx)(jd,{controls:e.task.composer.controls,back:`flow:${t.flow.id}:${e.id}`}),e.task.composer.steer!==null&&(0,a.jsx)(Nd,{steer:e.task.composer.steer,controls:e.task.composer.controls,back:`flow:${t.flow.id}:${e.id}`},`${e.id}:${e.task.composer.steer.run}`)]}),e.draft!==null&&!e.canDecide&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",open:!0,"data-flow-draft":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Draft from ",e.draft.title]}),(0,a.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px]",children:e.draft.text})]}),e.canDecide&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3",children:[e.handoff!=null&&(0,a.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-body","data-subagent-handoff":!0,children:[(0,a.jsxs)("span",{className:"font-medium",children:[e.handoff.from,":"]})," ",e.handoff.note]}),e.draft!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(Nn,{htmlFor:"flow-draft",className:"text-body",children:["Draft from ",e.draft.title]}),(0,a.jsx)(ye,{id:"flow-draft",value:l,onChange:f=>h(f.target.value),rows:8,maxLength:12e3,"data-flow-draft-edit":!0}),l.trim()!==e.draft.text.trim()&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"Approving sends your edited version on."})]}),(0,a.jsxs)(Nn,{htmlFor:"flow-note",className:"text-body",children:[p?.title??"Decision",": approve, or send it back"]}),(0,a.jsx)(ye,{id:"flow-note",value:s,onChange:f=>i(f.target.value),placeholder:"What should change? (needed to send it back)",rows:3}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(te,{size:"sm",disabled:u||e.draft!==null&&l.trim()==="",onClick:()=>{d(`${m}/decide`,{decision:"approve",note:s,...e.draft===null?{}:{draft:l}})},children:xn.card.action.label}),p?.onFail!==null&&p?.onFail!==void 0&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:u||s.trim()==="",onClick:()=>{d(`${m}/decide`,{decision:"send-back",note:s})},children:"Send back"})]})]}),t.canEdit&&e.state==="active"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(Nn,{htmlFor:"flow-move",className:"text-body",children:"Move to"}),(0,a.jsx)("select",{id:"flow-move",className:Dl,value:e.stage,disabled:u,onChange:f=>{d(`${m}/move`,{stage:f.target.value})},children:t.stages.map(f=>(0,a.jsx)("option",{value:f.id,children:f.title},f.id))})]}),(e.calls??[]).length>0&&(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-subagent-calls":!0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Tool calls (",e.calls.length,")"]}),(0,a.jsx)("ol",{className:"mt-2 flex flex-col gap-2.5",children:e.calls.map(f=>(0,a.jsxs)("li",{className:"flex flex-col gap-0.5 text-[12.5px]","data-subagent-call":f.state,children:[(0,a.jsxs)("span",{className:"break-words",children:[(0,a.jsx)("span",{className:"font-medium",children:f.who})," · ",f.words]}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[f.outcome,f.why!==""&&f.state!=="refused"?` · ${f.why}`:""]}),f.result!==null&&f.result!==""&&(f.state==="done"||f.state==="failed")&&(0,a.jsx)("span",{className:"mt-0.5 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted px-2 py-1 text-caption font-normal",children:f.result}),f.undo!=null&&f.subagent!==void 0&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"mt-1 self-start",disabled:u,"data-subagent-undo":f.id,onClick:()=>{d(`/settings/lead/subagents/${f.subagent}/week`,{op:"undo",id:String(f.id)})},children:["Undo with ",f.undo]})]},f.id))})]}),e.outputs.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"What zones reported"}),e.outputs.map(f=>(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:f.title}),(0,a.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px] text-muted-foreground",children:f.text})]},f.stage))]}),(0,a.jsx)(r0,{card:e,view:t,csrf:n,apply:o}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"History"}),(0,a.jsx)("ol",{className:"flex flex-col gap-1.5",children:e.history.map((f,w)=>(0,a.jsxs)("li",{className:"text-caption font-normal",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:t0(f.at)})," · ",f.text]},w))})]}),t.canEdit&&e.state==="active"&&(0,a.jsx)(te,{variant:"ghost",size:"sm",className:"self-start text-destructive",disabled:u,onClick:()=>{d(`${m}/cancel`,{})},children:"Cancel card"})]})}function Y({label:e,hint:t,children:n}){return(0,a.jsxs)("label",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:e}),n,t!==void 0&&(0,a.jsx)("span",{className:"text-caption text-muted-foreground font-normal",children:t})]})}var ue="h-9 w-full rounded-xl border border-transparent bg-field px-3 text-body",Dl="h-9 rounded-xl border border-transparent bg-field px-3 text-body",c0=[.95,.9,.85,.8,.7,.6];function u0({sort:e,others:t,ready:n,set:o}){let r=(i,l)=>o({...e,answers:e.answers.map((h,u)=>u===i?{...h,...l}:h)}),s=(i,l)=>o({...e,notes:e.notes.map((h,u)=>u===i?{...h,...l}:h)});return(0,a.jsxs)(a.Fragment,{children:[!n&&(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-sort-needs-key":!0,children:["Sorting needs an OpenRouter key. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/agents#providers",children:"Add it in Settings"})]}),(0,a.jsx)(Y,{label:"Question",children:(0,a.jsx)(ne,{value:e.question,maxLength:300,onChange:i=>o({...e,question:i.target.value}),"aria-label":"Question"})}),(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Answers"}),e.answers.map((i,l)=>(0,a.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-answer":l,children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(ne,{value:i.answer,maxLength:40,placeholder:"Answer",onChange:h=>r(l,{answer:h.target.value}),"aria-label":`Answer ${l+1}`}),(0,a.jsx)(te,{variant:"ghost",size:"icon",disabled:e.answers.length<=2,onClick:()=>o({...e,answers:e.answers.filter((h,u)=>u!==l)}),"aria-label":`Remove ${i.answer||`answer ${l+1}`}`,children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(ne,{value:i.means,maxLength:200,placeholder:"What it means, in a few words",onChange:h=>r(l,{means:h.target.value}),"aria-label":`What ${i.answer||`answer ${l+1}`} means`}),(0,a.jsxs)("select",{className:ue,value:i.to,onChange:h=>r(l,{to:h.target.value}),"aria-label":`Where ${i.answer||`answer ${l+1}`} goes`,children:[i.to===""&&(0,a.jsx)("option",{value:"",children:"Choose where it goes"}),t.map(h=>(0,a.jsxs)("option",{value:h.id,children:["Goes to ",h.title]},h.id))]})]},l)),e.answers.length<12&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,answers:[...e.answers,{answer:"",means:"",to:""}]}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add an answer"]})]}),(0,a.jsx)(Y,{label:"Acts on its own when",hint:"Below this, the card takes the not-sure path.",children:(0,a.jsx)("select",{className:ue,value:String(e.sureAt),onChange:i=>o({...e,sureAt:Number(i.target.value)}),"aria-label":"Acts on its own when",children:[...new Set([...c0,e.sureAt])].sort((i,l)=>l-i).map(i=>(0,a.jsxs)("option",{value:String(i),children:[Math.round(i*100),"% sure or more"]},i))})}),(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2",open:e.notes.length>0||void 0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Also note on the card",e.notes.length>0?` (${e.notes.length})`:""]}),(0,a.jsxs)("div",{className:"mt-2 grid gap-2",children:[e.notes.map((i,l)=>(0,a.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-note":l,children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsxs)("select",{className:ue,value:i.kind,onChange:h=>s(l,h.target.value==="score"?{kind:"score",levels:i.levels??["Low","Medium","High"]}:{kind:"yes-no",levels:null}),"aria-label":`Note ${l+1}: kind`,children:[(0,a.jsx)("option",{value:"score",children:"A score"}),(0,a.jsx)("option",{value:"yes-no",children:"Yes or no"})]}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>o({...e,notes:e.notes.filter((h,u)=>u!==l)}),"aria-label":`Remove note ${l+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(ne,{value:i.question,maxLength:300,placeholder:i.kind==="score"?"How urgent is this?":"Is the customer asking for money back?",onChange:h=>s(l,{question:h.target.value}),"aria-label":`Note ${l+1}: question`}),i.kind==="score"&&(0,a.jsx)(ye,{rows:3,value:(i.levels??[]).join(`
|
|
9
9
|
`),onChange:h=>s(l,{levels:h.target.value.split(`
|
|
10
|
-
`)}),placeholder:"One level per line, lowest first","aria-label":`Note ${l+1}: levels, lowest first`})]},l)),e.notes.length<3&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,notes:[...e.notes,{id:"",kind:"yes-no",question:"",levels:null}]}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a note"]})]})]})]})}var ja="Fill-ins: {{card.title}}, {{card.description}}, {{card.email}}, {{stage.<zone id>}}.";function h0({request:e,view:t,csrf:n,apply:o,set:r}){let s=Object.entries(e.headers),i=(l,h,u)=>r({...e,headers:Object.fromEntries(s.map((c,p)=>p===l?[h,u]:c).filter(([c])=>c!==""))});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Address",hint:`The host is written out; fill-ins can go after it. ${ja}`,children:(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)("select",{className:xe(ue,"w-24 shrink-0"),value:e.method,onChange:l=>r({...e,method:l.target.value}),"aria-label":"Method",children:["GET","POST","PUT","PATCH","DELETE"].map(l=>(0,a.jsx)("option",{value:l,children:l},l))}),(0,a.jsx)(ne,{value:e.url,maxLength:2e3,onChange:l=>r({...e,url:l.target.value}),className:"font-mono text-[12.5px]",placeholder:"https://api.example.com/items","aria-label":"Address"})]})}),(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Headers"}),s.map(([l,h],u)=>(0,a.jsxs)("div",{className:"flex gap-1.5","data-request-header":u,children:[(0,a.jsx)(ne,{value:l,maxLength:64,onChange:c=>i(u,c.target.value,h),className:"w-32 shrink-0 font-mono text-mono",placeholder:"Authorization","aria-label":`Header ${u+1} name`}),(0,a.jsx)(ne,{value:h,maxLength:500,onChange:c=>i(u,l,c.target.value),className:"font-mono text-mono",placeholder:"Bearer {{secret.API_TOKEN}}","aria-label":`Header ${u+1} value`}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>r({...e,headers:Object.fromEntries(s.filter((c,p)=>p!==u))}),"aria-label":`Remove header ${l||u+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},u)),s.length<10&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>r({...e,headers:{...e.headers,[`X-Header-${s.length+1}`]:""}}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a header"]})]}),e.method!=="GET"&&e.method!=="DELETE"&&(0,a.jsx)(Y,{label:"What it sends",hint:"JSON is sent as JSON, with fill-ins inside its strings; anything else as plain text.",children:(0,a.jsx)(ye,{rows:5,value:e.body??"",maxLength:8e3,onChange:l=>r({...e,body:l.target.value}),className:"font-mono text-mono","aria-label":"What it sends"})}),(0,a.jsx)(Rl,{view:t,csrf:n,apply:o,words:(0,a.jsxs)(a.Fragment,{children:["Kept on this computer, never shown again. Use one in a header as ","{{secret.NAME}}","."]})})]})}function Rl({view:e,csrf:t,apply:n,words:o,chosen:r,choose:s}){let[i,l]=(0,D.useState)({name:"",value:""}),[h,u]=(0,D.useState)(!1),c=r??[];return(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-request-secrets":!0,open:c.length>0?!0:void 0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Secrets",s!==void 0?c.length>0?` (${c.length} used)`:"":e.requestSecrets.length>0?` (${e.requestSecrets.length})`:""]}),(0,a.jsxs)("div",{className:"mt-2 grid gap-2",children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:o}),e.requestSecrets.length>0&&(s===void 0?(0,a.jsx)("p",{className:"flex flex-wrap gap-1.5",children:e.requestSecrets.map(p=>(0,a.jsx)(Mo,{tone:"neutral",className:"font-mono",children:p},p))}):(0,a.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5",children:e.requestSecrets.map(p=>(0,a.jsxs)("label",{className:"inline-flex items-center gap-1.5 font-mono text-mono",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:c.includes(p),onChange:d=>s(d.target.checked?[...c,p]:c.filter(m=>m!==p))}),p]},p))})),c.filter(p=>!e.requestSecrets.includes(p)).map(p=>(0,a.jsxs)("p",{className:"text-caption text-foreground font-medium",children:[p," isn't saved yet: save it below."]},p)),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)(ne,{value:i.name,onChange:p=>l({...i,name:p.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"_")}),className:"w-32 shrink-0 font-mono text-mono",placeholder:"API_TOKEN","aria-label":"Secret name"}),(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:i.value,onChange:p=>l({...i,value:p.target.value}),placeholder:"Its value (empty removes it)","aria-label":"Secret value"})]}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:h||i.name==="",onClick:async()=>{u(!0);let p=await me(`${e.flow.href}/secrets`,i,t);u(!1),n(p),p.ok&&(s!==void 0&&i.value.trim()!==""&&!c.includes(i.name)&&s([...c,i.name]),l({name:"",value:""}))},children:"Save secret"})]})]})}function Ol({routes:e,others:t,set:n,hint:o}){return(0,a.jsxs)("div",{className:"grid gap-1.5","data-code-routes":!0,children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Answers (optional)"}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:o}),e.map((r,s)=>(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)(ne,{value:r.answer,maxLength:40,onChange:i=>n(e.map((l,h)=>h===s?{...l,answer:i.target.value}:l)),className:"w-32 shrink-0",placeholder:"Urgent","aria-label":`Answer ${s+1}`}),(0,a.jsx)("select",{className:ue,value:r.to,onChange:i=>n(e.map((l,h)=>h===s?{...l,to:i.target.value}:l)),"aria-label":`Where ${r.answer||`answer ${s+1}`} leads`,children:t.map(i=>(0,a.jsx)("option",{value:i.id,children:i.title},i.id))}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>n(e.filter((i,l)=>l!==s)),"aria-label":`Remove ${r.answer||`answer ${s+1}`}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},s)),e.length<12&&t.length>0&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n([...e,{answer:"",to:t[0].id}]),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add an answer"]})]})}function p0({question:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(""),[s,i]=(0,D.useState)(!1),l=async u=>{i(!0);let c=await me(`/settings/lead/subagents/questions/${e.id}/answer`,u,t);i(!1),n(c),c.ok&&r("")},h=e.call??null;return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-subagent-question":e.id,children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:h===null?`${e.from} asks${e.mine?" you":` ${e.askedOf}`}`:`${e.from} needs ${e.mine?"your":`${e.askedOf}'s`} approval`}),(0,a.jsx)("p",{className:"break-words text-body font-medium",children:e.question}),h!==null&&(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground","data-subagent-call-why":!0,children:[h.why!==""&&(0,a.jsxs)(a.Fragment,{children:[h.why," "]}),"(",h.rule,")"]}),e.mine&&(0,a.jsxs)(a.Fragment,{children:[e.options.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map((u,c)=>(0,a.jsx)(te,{size:"sm",variant:h!==null&&c===0?"default":"outline",disabled:s,onClick:()=>{l({choice:u.id})},children:u.label},u.id))}),(0,a.jsx)(ye,{value:o,onChange:u=>r(u.target.value),rows:2,maxLength:2e3,placeholder:h===null?"Or answer in your words":`Or tell ${e.from.split(" · ")[0]} what to do instead`,"aria-label":"Your answer"}),(0,a.jsx)(te,{size:"sm",className:"self-start",disabled:s||o.trim()==="",onClick:()=>{l({text:o})},children:"Answer"})]})]})}function m0({stage:e,others:t,view:n,update:o}){let r=n.subagents??[];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Subagent",hint:r.length===0?void 0:"It follows its soul file's rules, and asks the flow's owner when they say to.",children:r.length===0?(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["No subagents in this project yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/lead/subagents",children:"Add one"}),"."]}):(0,a.jsx)("select",{className:ue,"aria-label":"Subagent",value:e.subagent??"",onChange:s=>o({subagent:s.target.value}),children:r.map(s=>(0,a.jsxs)("option",{value:s.handle,children:[s.label,s.working?"":" (paused)"]},s.handle))})}),(0,a.jsx)(Y,{label:"What to do here",children:(0,a.jsx)(ye,{rows:4,value:e.instructions??"",maxLength:8e3,onChange:s=>o({instructions:s.target.value}),"aria-label":"What to do here",placeholder:"Read the customer's reply and decide what happens next."})}),(0,a.jsx)(Ol,{routes:e.routes??[],others:t,set:s=>o({routes:s}),hint:"It picks one, and writes what the next zones send. With none, it moves the card on to “Then”."}),(0,a.jsxs)("label",{className:"flex items-start gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4",checked:e.reply===!0,onChange:s=>o({reply:s.target.checked?!0:void 0}),"data-subagent-reply":!0}),(0,a.jsxs)("span",{children:["Answer whoever asked",(0,a.jsx)("span",{className:"block text-caption text-muted-foreground font-normal",children:"What it writes goes back to the person who added the card, in their chat app."})]})]})]})}function f0({stage:e,others:t,view:n,csrf:o,apply:r,update:s}){let i=e.routes??[],l=n.scripts.find(u=>u.name===e.script),h=u=>s({routes:u});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Script",hint:n.scripts.length===0?"This project has no scripts yet: make one with Scripts in the toolbar, or ask your lead in chat.":l!==void 0?`${Ll[l.language]}${l.file===null?"":`, runs ${l.file}`}. It gets the card as JSON on stdin; what it prints is this step's result.`:void 0,children:(0,a.jsxs)("select",{className:ue,"aria-label":"Script",value:e.script??"",onChange:u=>s({script:u.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Choose a script"}),n.scripts.map(u=>(0,a.jsxs)("option",{value:u.name,children:[u.name," — ",u.about]},u.name)),e.script!==null&&!n.scripts.some(u=>u.name===e.script)&&(0,a.jsxs)("option",{value:e.script,children:[e.script," (missing)"]})]})}),(0,a.jsx)(Y,{label:"Runs in",hint:(e.runIn??"copy")==="folder"?"Fast. The project's folder is at $FLOW_PROJECT.":"The project's setup runs first. Use this to test or check code.",children:(0,a.jsxs)("select",{className:ue,"aria-label":"Runs in",value:e.runIn??"copy",onChange:u=>s({runIn:u.target.value}),children:[(0,a.jsx)("option",{value:"folder",children:"An empty folder"}),(0,a.jsx)("option",{value:"copy",children:"A copy of the project, at the card's work"})]})}),(0,a.jsxs)("label",{className:"flex items-start gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 accent-primary",checked:e.browser===!0,onChange:u=>s({browser:u.target.checked?!0:void 0}),"data-zone-browser-toggle":!0}),(0,a.jsxs)("span",{children:["Starts a browser",(0,a.jsx)("span",{className:"block text-caption text-muted-foreground font-normal",children:"Playwright's Chromium. It runs only once a person allows browser use for this flow."})]})]}),(0,a.jsx)(Ol,{routes:i,others:t,set:h,hint:(0,a.jsxs)(a.Fragment,{children:["If its last line is “goto: ",(0,a.jsx)("em",{children:"answer"}),"”, the card goes where that answer leads."]})}),(0,a.jsx)(Rl,{view:n,csrf:o,apply:r,chosen:e.secrets??[],choose:u=>s({secrets:u}),words:"Kept on this computer, never shown again. The script gets each one it's given as a variable of the same name."})]})}var Ll={shell:"Shell",python:"Python",node:"Node"},g0={python:`import json, sys
|
|
10
|
+
`)}),placeholder:"One level per line, lowest first","aria-label":`Note ${l+1}: levels, lowest first`})]},l)),e.notes.length<3&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,notes:[...e.notes,{id:"",kind:"yes-no",question:"",levels:null}]}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a note"]})]})]})]})}var ja="Fill-ins: {{card.title}}, {{card.description}}, {{card.email}}, {{stage.<zone id>}}.";function h0({request:e,view:t,csrf:n,apply:o,set:r}){let s=Object.entries(e.headers),i=(l,h,u)=>r({...e,headers:Object.fromEntries(s.map((c,p)=>p===l?[h,u]:c).filter(([c])=>c!==""))});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Address",hint:`The host is written out; fill-ins can go after it. ${ja}`,children:(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)("select",{className:xe(ue,"w-24 shrink-0"),value:e.method,onChange:l=>r({...e,method:l.target.value}),"aria-label":"Method",children:["GET","POST","PUT","PATCH","DELETE"].map(l=>(0,a.jsx)("option",{value:l,children:l},l))}),(0,a.jsx)(ne,{value:e.url,maxLength:2e3,onChange:l=>r({...e,url:l.target.value}),className:"font-mono text-[12.5px]",placeholder:"https://api.example.com/items","aria-label":"Address"})]})}),(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Headers"}),s.map(([l,h],u)=>(0,a.jsxs)("div",{className:"flex gap-1.5","data-request-header":u,children:[(0,a.jsx)(ne,{value:l,maxLength:64,onChange:c=>i(u,c.target.value,h),className:"w-32 shrink-0 font-mono text-mono",placeholder:"Authorization","aria-label":`Header ${u+1} name`}),(0,a.jsx)(ne,{value:h,maxLength:500,onChange:c=>i(u,l,c.target.value),className:"font-mono text-mono",placeholder:"Bearer {{secret.API_TOKEN}}","aria-label":`Header ${u+1} value`}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>r({...e,headers:Object.fromEntries(s.filter((c,p)=>p!==u))}),"aria-label":`Remove header ${l||u+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},u)),s.length<10&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>r({...e,headers:{...e.headers,[`X-Header-${s.length+1}`]:""}}),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a header"]})]}),e.method!=="GET"&&e.method!=="DELETE"&&(0,a.jsx)(Y,{label:"What it sends",hint:"JSON is sent as JSON, with fill-ins inside its strings; anything else as plain text.",children:(0,a.jsx)(ye,{rows:5,value:e.body??"",maxLength:8e3,onChange:l=>r({...e,body:l.target.value}),className:"font-mono text-mono","aria-label":"What it sends"})}),(0,a.jsx)(Rl,{view:t,csrf:n,apply:o,words:(0,a.jsxs)(a.Fragment,{children:["Kept on this computer, never shown again. Use one in a header as ","{{secret.NAME}}","."]})})]})}function Rl({view:e,csrf:t,apply:n,words:o,chosen:r,choose:s}){let[i,l]=(0,D.useState)({name:"",value:""}),[h,u]=(0,D.useState)(!1),c=r??[];return(0,a.jsxs)("details",{className:"rounded-md border px-3 py-2","data-request-secrets":!0,open:c.length>0?!0:void 0,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Secrets",s!==void 0?c.length>0?` (${c.length} used)`:"":e.requestSecrets.length>0?` (${e.requestSecrets.length})`:""]}),(0,a.jsxs)("div",{className:"mt-2 grid gap-2",children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:o}),e.requestSecrets.length>0&&(s===void 0?(0,a.jsx)("p",{className:"flex flex-wrap gap-1.5",children:e.requestSecrets.map(p=>(0,a.jsx)(Eo,{tone:"neutral",className:"font-mono",children:p},p))}):(0,a.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5",children:e.requestSecrets.map(p=>(0,a.jsxs)("label",{className:"inline-flex items-center gap-1.5 font-mono text-mono",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:c.includes(p),onChange:d=>s(d.target.checked?[...c,p]:c.filter(m=>m!==p))}),p]},p))})),c.filter(p=>!e.requestSecrets.includes(p)).map(p=>(0,a.jsxs)("p",{className:"text-caption text-foreground font-medium",children:[p," isn't saved yet: save it below."]},p)),(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)(ne,{value:i.name,onChange:p=>l({...i,name:p.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"_")}),className:"w-32 shrink-0 font-mono text-mono",placeholder:"API_TOKEN","aria-label":"Secret name"}),(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:i.value,onChange:p=>l({...i,value:p.target.value}),placeholder:"Its value (empty removes it)","aria-label":"Secret value"})]}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:h||i.name==="",onClick:async()=>{u(!0);let p=await me(`${e.flow.href}/secrets`,i,t);u(!1),n(p),p.ok&&(s!==void 0&&i.value.trim()!==""&&!c.includes(i.name)&&s([...c,i.name]),l({name:"",value:""}))},children:"Save secret"})]})]})}function Ol({routes:e,others:t,set:n,hint:o}){return(0,a.jsxs)("div",{className:"grid gap-1.5","data-code-routes":!0,children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Answers (optional)"}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:o}),e.map((r,s)=>(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)(ne,{value:r.answer,maxLength:40,onChange:i=>n(e.map((l,h)=>h===s?{...l,answer:i.target.value}:l)),className:"w-32 shrink-0",placeholder:"Urgent","aria-label":`Answer ${s+1}`}),(0,a.jsx)("select",{className:ue,value:r.to,onChange:i=>n(e.map((l,h)=>h===s?{...l,to:i.target.value}:l)),"aria-label":`Where ${r.answer||`answer ${s+1}`} leads`,children:t.map(i=>(0,a.jsx)("option",{value:i.id,children:i.title},i.id))}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>n(e.filter((i,l)=>l!==s)),"aria-label":`Remove ${r.answer||`answer ${s+1}`}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},s)),e.length<12&&t.length>0&&(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n([...e,{answer:"",to:t[0].id}]),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add an answer"]})]})}function p0({question:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(""),[s,i]=(0,D.useState)(!1),l=async u=>{i(!0);let c=await me(`/settings/lead/subagents/questions/${e.id}/answer`,u,t);i(!1),n(c),c.ok&&r("")},h=e.call??null;return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-subagent-question":e.id,children:[(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:h===null?`${e.from} asks${e.mine?" you":` ${e.askedOf}`}`:`${e.from} needs ${e.mine?"your":`${e.askedOf}'s`} approval`}),(0,a.jsx)("p",{className:"break-words text-body font-medium",children:e.question}),h!==null&&(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground","data-subagent-call-why":!0,children:[h.why!==""&&(0,a.jsxs)(a.Fragment,{children:[h.why," "]}),"(",h.rule,")"]}),e.mine&&(0,a.jsxs)(a.Fragment,{children:[e.options.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map((u,c)=>(0,a.jsx)(te,{size:"sm",variant:h!==null&&c===0?"default":"outline",disabled:s,onClick:()=>{l({choice:u.id})},children:u.label},u.id))}),(0,a.jsx)(ye,{value:o,onChange:u=>r(u.target.value),rows:2,maxLength:2e3,placeholder:h===null?"Or answer in your words":`Or tell ${e.from.split(" · ")[0]} what to do instead`,"aria-label":"Your answer"}),(0,a.jsx)(te,{size:"sm",className:"self-start",disabled:s||o.trim()==="",onClick:()=>{l({text:o})},children:"Answer"})]})]})}function m0({stage:e,others:t,view:n,update:o}){let r=n.subagents??[];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Subagent",hint:r.length===0?void 0:"It follows its soul file's rules, and asks the flow's owner when they say to.",children:r.length===0?(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["No subagents in this project yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/lead/subagents",children:"Add one"}),"."]}):(0,a.jsx)("select",{className:ue,"aria-label":"Subagent",value:e.subagent??"",onChange:s=>o({subagent:s.target.value}),children:r.map(s=>(0,a.jsxs)("option",{value:s.handle,children:[s.label,s.working?"":" (paused)"]},s.handle))})}),(0,a.jsx)(Y,{label:"What to do here",children:(0,a.jsx)(ye,{rows:4,value:e.instructions??"",maxLength:8e3,onChange:s=>o({instructions:s.target.value}),"aria-label":"What to do here",placeholder:"Read the customer's reply and decide what happens next."})}),(0,a.jsx)(Ol,{routes:e.routes??[],others:t,set:s=>o({routes:s}),hint:"It picks one, and writes what the next zones send. With none, it moves the card on to “Then”."}),(0,a.jsxs)("label",{className:"flex items-start gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4",checked:e.reply===!0,onChange:s=>o({reply:s.target.checked?!0:void 0}),"data-subagent-reply":!0}),(0,a.jsxs)("span",{children:["Answer whoever asked",(0,a.jsx)("span",{className:"block text-caption text-muted-foreground font-normal",children:"What it writes goes back to the person who added the card, in their chat app."})]})]})]})}function f0({stage:e,others:t,view:n,csrf:o,apply:r,update:s}){let i=e.routes??[],l=n.scripts.find(u=>u.name===e.script),h=u=>s({routes:u});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Script",hint:n.scripts.length===0?"This project has no scripts yet: make one with Scripts in the toolbar, or ask your lead in chat.":l!==void 0?`${Ll[l.language]}${l.file===null?"":`, runs ${l.file}`}. It gets the card as JSON on stdin; what it prints is this step's result.`:void 0,children:(0,a.jsxs)("select",{className:ue,"aria-label":"Script",value:e.script??"",onChange:u=>s({script:u.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Choose a script"}),n.scripts.map(u=>(0,a.jsxs)("option",{value:u.name,children:[u.name," — ",u.about]},u.name)),e.script!==null&&!n.scripts.some(u=>u.name===e.script)&&(0,a.jsxs)("option",{value:e.script,children:[e.script," (missing)"]})]})}),(0,a.jsx)(Y,{label:"Runs in",hint:(e.runIn??"copy")==="folder"?"Fast. The project's folder is at $FLOW_PROJECT.":"The project's setup runs first. Use this to test or check code.",children:(0,a.jsxs)("select",{className:ue,"aria-label":"Runs in",value:e.runIn??"copy",onChange:u=>s({runIn:u.target.value}),children:[(0,a.jsx)("option",{value:"folder",children:"An empty folder"}),(0,a.jsx)("option",{value:"copy",children:"A copy of the project, at the card's work"})]})}),(0,a.jsxs)("label",{className:"flex items-start gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4 accent-primary",checked:e.browser===!0,onChange:u=>s({browser:u.target.checked?!0:void 0}),"data-zone-browser-toggle":!0}),(0,a.jsxs)("span",{children:["Starts a browser",(0,a.jsx)("span",{className:"block text-caption text-muted-foreground font-normal",children:"Playwright's Chromium. It runs only once a person allows browser use for this flow."})]})]}),(0,a.jsx)(Ol,{routes:i,others:t,set:h,hint:(0,a.jsxs)(a.Fragment,{children:["If its last line is “goto: ",(0,a.jsx)("em",{children:"answer"}),"”, the card goes where that answer leads."]})}),(0,a.jsx)(Rl,{view:n,csrf:o,apply:r,chosen:e.secrets??[],choose:u=>s({secrets:u}),words:"Kept on this computer, never shown again. The script gets each one it's given as a variable of the same name."})]})}var Ll={shell:"Shell",python:"Python",node:"Node"},g0={python:`import json, sys
|
|
11
11
|
card = json.load(sys.stdin)["card"]
|
|
12
12
|
print(f"Looked at {card['title']}")`,node:'import { readFileSync } from "node:fs";\nconst { card } = JSON.parse(readFileSync(0, "utf8"));\nconsole.log(`Looked at ${card.title}`);',shell:`npm ci
|
|
13
|
-
npm test`};function x0({email:e,view:t,set:n}){return(0,a.jsxs)(a.Fragment,{children:[!t.emailReady&&(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-email-needs-setup":!0,children:["Email isn't set up yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/alerts#email",children:"Add your mail server in Settings"})]}),(0,a.jsx)(Y,{label:"To",children:(0,a.jsx)(ne,{value:e.to,maxLength:500,onChange:o=>n({...e,to:o.target.value}),"aria-label":"To"})}),(0,a.jsx)(Y,{label:"Subject",children:(0,a.jsx)(ne,{value:e.subject,maxLength:200,onChange:o=>n({...e,subject:o.target.value}),"aria-label":"Subject"})}),(0,a.jsx)(Y,{label:"Email",hint:ja,children:(0,a.jsx)(ye,{rows:6,value:e.body,maxLength:8e3,onChange:o=>n({...e,body:o.target.value}),"aria-label":"Email"})})]})}function v0({tool:e,view:t,set:n}){let o=t.tools.find(r=>r.name===e.server);return(0,a.jsxs)(a.Fragment,{children:[t.tools.length===0?(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-tool-needs-setup":!0,children:["This project has no tools yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/tools",children:"Add one on the Tools page"})]}):(0,a.jsx)(Y,{label:"Tool",...o!==void 0&&!o.ready?{hint:"It needs its secrets set on the Tools page first."}:o!==void 0?{hint:o.about}:{},children:(0,a.jsxs)("select",{className:ue,value:e.server,onChange:r=>n({...e,server:r.target.value,name:t.tools.find(s=>s.name===r.target.value)?.functions[0]??""}),"aria-label":"Tool",children:[o===void 0&&(0,a.jsx)("option",{value:e.server,children:e.server===""?"Choose a tool":`${e.server} (missing)`}),t.tools.map(r=>(0,a.jsx)("option",{value:r.name,children:r.name},r.name))]})}),(0,a.jsx)(Y,{label:"What it does",hint:o!==void 0&&o.functions.length===0?"Test the tool on the Tools page to list what it can do.":void 0,children:o!==void 0&&o.functions.length>0?(0,a.jsxs)("select",{className:ue,value:e.name,onChange:r=>n({...e,name:r.target.value}),"aria-label":"What it does",children:[!o.functions.includes(e.name)&&(0,a.jsx)("option",{value:e.name,children:e.name||"Choose"}),o.functions.map(r=>(0,a.jsx)("option",{value:r,children:r},r))]}):(0,a.jsx)(ne,{value:e.name,maxLength:100,onChange:r=>n({...e,name:r.target.value}),className:"font-mono","aria-label":"What it does"})}),(0,a.jsx)(Y,{label:"Arguments",hint:`JSON, with fill-ins inside its strings. ${ja}`,children:(0,a.jsx)(ye,{rows:5,value:e.args,maxLength:4e3,onChange:r=>n({...e,args:r.target.value}),className:"font-mono text-mono","aria-label":"Arguments"})})]})}function y0({stage:e,stages:t,view:n,csrf:o,apply:r,update:s,remove:i,makeStart:l,onClose:h}){let u=t.filter(d=>d.id!==e.id),c=ue,p=n.kinds.find(d=>d.kind===e.kind);return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-flow-zone-panel":e.id,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"flex-1 text-title",children:"Edit zone"}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:h,"aria-label":"Close",children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(Y,{label:"Name",children:(0,a.jsx)(ne,{value:e.title,maxLength:60,onChange:d=>s({title:d.target.value}),"aria-label":"Zone name"})}),(0,a.jsx)(Y,{label:"What happens here",...p===void 0?{}:{hint:p.about},children:(0,a.jsx)("select",{className:c,"aria-label":"What happens here",value:e.kind,onChange:d=>s({kind:d.target.value,...d.target.value==="done"?{next:null,onFail:null}:{},...d.target.value==="update"?{close:e.close??!0,message:e.message??"Done: {{card.title}}"}:{},...d.target.value==="check"?{script:e.script??n.scripts[0]?.name??null,runIn:e.runIn??"folder"}:{},...d.target.value==="request"?{request:e.request??{method:"POST",url:"https://",headers:{},body:'{"title": "{{card.title}}", "details": "{{card.description}}"}'}}:{},...d.target.value==="email"?{email:e.email??{to:"{{card.email}}",subject:"Re: {{card.title}}",body:t.find(m=>m.kind==="draft")?`{{stage.${t.find(m=>m.kind==="draft").id}}}`:""}}:{},...d.target.value==="tool"?{tool:e.tool??{server:n.tools[0]?.name??"",name:n.tools[0]?.functions[0]??"",args:'{"text": "{{card.title}}"}'}}:{},...d.target.value==="draft"?{instructions:e.instructions??"Write a short, friendly reply to the person who sent this card, in plain words."}:{},...d.target.value==="approval"?{toOwner:e.toOwner??!0}:{},...d.target.value==="wait"?{wait:e.wait??{for:"reply",minutes:4320}}:{},...d.target.value==="subagent"?{subagent:e.subagent??n.subagents?.[0]?.handle,instructions:e.instructions??"Read the card and decide what happens next."}:d.target.value!=="approval"?{subagent:void 0}:{},...d.target.value==="wait"||d.target.value==="done"?{limit:void 0}:d.target.value!=="inbox"&&d.target.value!=="approval"&&d.target.value!=="choose"&&e.limit!==void 0?{limit:{...e.limit,to:null}}:{},...d.target.value==="choose"?{next:null,options:e.options??[{label:"Looks good",to:u.find(m=>m.kind==="done")?.id??u[0]?.id??"end"},{label:"Ignore",to:"end"}]}:{options:void 0},...d.target.value==="task"?{}:{repo:void 0},...d.target.value==="sort"?{next:null,sort:e.sort??{question:"What kind of card is this?",answers:u.slice(0,2).map(m=>({answer:m.title.slice(0,40),means:m.title,to:m.id})),sureAt:.8,notes:[]}}:{}}),children:n.kinds.map(d=>(0,a.jsx)("option",{value:d.kind,children:d.label},d.kind))})}),e.kind==="draft"&&(0,a.jsx)(Y,{label:"What Claude should write",hint:"Claude reads the card and what earlier zones said. Put a “Person decides” zone next to read and edit it first.",children:(0,a.jsx)(ye,{rows:5,value:e.instructions??"",maxLength:8e3,onChange:d=>s({instructions:d.target.value}),"aria-label":"What Claude should write"})}),(e.kind==="task"||e.kind==="report")&&(0,a.jsx)(Y,{label:"What the agent should do",hint:"Fill-ins: {{card.title}}, {{card.description}}, {{note}} (the latest send-back note), {{stage.<zone id>}} (an earlier zone's report; a research zone adds .items and .report).",children:(0,a.jsx)(ye,{rows:7,value:e.instructions??"",onChange:d=>s({instructions:d.target.value}),"aria-label":"What the agent should do"})}),e.kind==="task"&&(n.projects??[]).length>1&&(0,a.jsx)(Y,{label:"Builds in",hint:"Another project files its task there, as the flow's owner, under that project's approvals.",children:(0,a.jsxs)("select",{className:c,"aria-label":"Builds in",value:e.repo??n.projects[0].path,onChange:d=>s({repo:d.target.value===n.projects[0].path?void 0:d.target.value}),children:[n.projects.map((d,m)=>(0,a.jsx)("option",{value:d.path,children:m===0?`${d.name} (this flow's project)`:d.name},d.path)),e.repo!==void 0&&!n.projects.some(d=>d.path===e.repo)&&(0,a.jsxs)("option",{value:e.repo,children:[e.repo," (not yours)"]})]})}),e.kind==="choose"&&(0,a.jsx)(b0,{options:e.options??[],others:u,set:d=>s({options:d})}),e.kind==="task"&&(0,a.jsx)(Y,{label:"Plan first?",children:(0,a.jsxs)("select",{className:c,"aria-label":"Plan first?",value:e.planning??"auto",onChange:d=>s({planning:d.target.value}),children:[(0,a.jsx)("option",{value:"auto",children:"Let Toolroll decide"}),(0,a.jsx)("option",{value:"required",children:"Always plan first"}),(0,a.jsx)("option",{value:"skip",children:"Build directly"})]})}),e.kind==="approval"&&(0,a.jsx)(Y,{label:"Who decides",children:(0,a.jsxs)("select",{className:c,"aria-label":"Who decides",value:e.subagent!==void 0?`__mate__:${e.subagent}`:e.toOwner===!0?"__owner__":e.approver??"",onChange:d=>s(d.target.value.startsWith("__mate__:")?{subagent:d.target.value.slice(9),toOwner:!0,approver:null}:d.target.value==="__owner__"?{subagent:void 0,toOwner:!0,approver:null}:{subagent:void 0,toOwner:!1,approver:d.target.value===""?null:d.target.value}),children:[(n.subagents??[]).map(d=>(0,a.jsxs)("option",{value:`__mate__:${d.handle}`,children:[d.name," (subagent), handing hard ones to the flow's owner",d.working?"":" (paused)"]},d.handle)),(0,a.jsxs)("option",{value:"__owner__",children:["The flow's owner (",n.flow.owner,"), in their chat app"]}),(0,a.jsx)("option",{value:"",children:"Anyone who can approve"}),n.approvers.map(d=>(0,a.jsx)("option",{value:d,children:d},d))]})}),e.kind==="notify"&&(0,a.jsx)(Y,{label:"Message",children:(0,a.jsx)(ne,{value:e.message??"",maxLength:1e3,onChange:d=>s({message:d.target.value}),"aria-label":"Message"})}),e.kind==="update"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Comment on the issue",hint:"Fill-ins: {{card.title}}, {{note}}, {{stage.<zone id>}}.",children:(0,a.jsx)(ye,{rows:3,value:e.message??"",maxLength:1e3,onChange:d=>s({message:d.target.value}),"aria-label":"Comment on the issue"})}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:e.close!==!1,onChange:d=>s({close:d.target.checked})}),"Close the issue too (Linear: move it to done)"]})]}),e.kind==="pull-request"&&(0,a.jsx)(Y,{label:"When checks pass",hint:"Merging needs a “Person decides” zone before this one, and a person's approval of the card since it was built.",children:(0,a.jsxs)("select",{className:c,"aria-label":"When checks pass",value:e.merge??"",onChange:d=>s({merge:d.target.value===""?void 0:d.target.value}),children:[(0,a.jsx)("option",{value:"",children:"Move on; a person merges"}),(0,a.jsx)("option",{value:"squash",children:"Merge (squash)"}),(0,a.jsx)("option",{value:"merge",children:"Merge (merge commit)"}),(0,a.jsx)("option",{value:"rebase",children:"Merge (rebase)"})]})}),e.kind==="check"&&(0,a.jsx)(f0,{stage:e,others:u,view:n,csrf:o,apply:r,update:s}),e.kind==="subagent"&&(0,a.jsx)(m0,{stage:e,others:u,view:n,update:s}),e.kind==="request"&&e.request!==void 0&&(0,a.jsx)(h0,{request:e.request,view:n,csrf:o,apply:r,set:d=>s({request:d})}),e.kind==="email"&&e.email!==void 0&&(0,a.jsx)(x0,{email:e.email,view:n,set:d=>s({email:d})}),e.kind==="tool"&&e.tool!==void 0&&(0,a.jsx)(v0,{tool:e.tool,view:n,set:d=>s({tool:d})}),e.kind==="sort"&&e.sort!==null&&(0,a.jsx)(u0,{sort:e.sort,others:u,ready:n.sortReady,set:d=>s({sort:d})}),e.kind==="wait"&&e.wait!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Wait for",hint:e.wait.for==="reply"?"Only a reply from someone it emailed counts. Needs the inbox in Settings → Email.":void 0,children:(0,a.jsxs)("select",{className:c,"aria-label":"Wait for",value:e.wait.for,onChange:d=>s({wait:d.target.value==="hours"?{for:"hours",minutes:0,from:e.wait.from??"22:00",to:e.wait.to??"06:00"}:{for:d.target.value,minutes:e.wait.minutes>0?e.wait.minutes:1440}}),children:[(0,a.jsx)("option",{value:"reply",children:"A reply to the card's email"}),(0,a.jsx)("option",{value:"time",children:"A set time"}),(0,a.jsx)("option",{value:"hours",children:"Set hours, like overnight"})]})}),e.wait.for==="hours"?(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsx)(Y,{label:"From",children:(0,a.jsx)(ne,{type:"time",value:e.wait.from??"22:00",onChange:d=>s({wait:{...e.wait,from:d.target.value}}),"aria-label":"From"})}),(0,a.jsx)(Y,{label:"Until",children:(0,a.jsx)(ne,{type:"time",value:e.wait.to??"06:00",onChange:d=>s({wait:{...e.wait,to:d.target.value}}),"aria-label":"Until"})})]}):(0,a.jsx)(Y,{label:e.wait.for==="reply"?"For up to":"How long",children:(0,a.jsx)(Tl,{minutes:e.wait.minutes,label:e.wait.for==="reply"?"For up to":"How long",set:d=>s({wait:{...e.wait,minutes:d}})})})]}),e.kind!=="done"&&e.kind!=="sort"&&e.kind!=="choose"&&(0,a.jsx)(Y,{label:e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",children:(0,a.jsxs)("select",{className:c,"aria-label":e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",value:e.next??"",onChange:d=>s({next:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Wait here"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind==="wait"&&e.wait?.for==="reply"&&(0,a.jsx)(Y,{label:"If no reply",children:(0,a.jsxs)("select",{className:c,"aria-label":"If no reply",value:e.onFail??"",onChange:d=>s({onFail:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Stay here for a person"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),(e.kind==="approval"||e.kind==="task"||e.kind==="report"||e.kind==="check"||e.kind==="pull-request"||e.kind==="update"||e.kind==="sort"||e.kind==="request"||e.kind==="email"||e.kind==="tool"||e.kind==="subagent"||e.kind==="choose")&&(0,a.jsx)(Y,{label:$s[e.kind]??"If it fails",...e.kind==="choose"?{hint:"Their reply is the note there ({{note}})."}:{},children:(0,a.jsxs)("select",{className:c,"aria-label":$s[e.kind]??"If it fails",value:e.onFail??"",onChange:d=>s({onFail:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:e.kind==="approval"?"Can't be sent back":e.kind==="sort"?"Wait here for a person":e.kind==="choose"?"Where the first option goes":"Wait here"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind!=="wait"&&e.kind!=="done"&&(0,a.jsx)(w0,{stage:e,others:u,update:s}),(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Color"}),(0,a.jsx)("div",{className:"flex gap-2",children:n.colors.map(d=>(0,a.jsx)(he,{type:"button",variant:"ghost",sm:!0,iconOnly:"check",label:Wg[d]??d,"aria-pressed":e.zone.color===d,className:"rounded-full [&_svg]:invisible aria-pressed:[&_svg]:visible",style:{background:At[d],color:"var(--so-paper)"},onClick:()=>s({zone:{...e.zone,color:d}})},d))})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:[n.start!==e.id&&(0,a.jsx)(te,{variant:"outline",size:"sm",onClick:l,children:"New cards start here"}),(0,a.jsx)(te,{variant:"ghost",size:"sm",className:"text-destructive",onClick:i,disabled:t.length<=1,children:"Delete zone"})]})]})}var $s={approval:"If sent back",sort:"If it isn't sure",subagent:"If it can't handle it","pull-request":"If checks fail",choose:"If they reply"};function b0({options:e,others:t,set:n}){let o=(r,s)=>n(e.map((i,l)=>l===r?{...i,...s}:i));return(0,a.jsxs)("div",{className:"grid gap-2","data-choose-options":!0,children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Buttons"}),e.map((r,s)=>(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ne,{className:"min-w-0 flex-1",value:r.label,maxLength:40,onChange:i=>o(s,{label:i.target.value}),"aria-label":`Button ${s+1}`}),(0,a.jsxs)("select",{className:xe(ue,"min-w-0 flex-1"),"aria-label":`Button ${s+1} goes to`,value:r.to,onChange:i=>o(s,{to:i.target.value}),children:[(0,a.jsx)("option",{value:"end",children:"Ignore the card"}),t.map(i=>(0,a.jsx)("option",{value:i.id,children:i.title},i.id))]}),e.length>2&&(0,a.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(e.filter((i,l)=>l!==s)),"aria-label":`Remove button ${s+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},s)),e.length<4&&(0,a.jsxs)(te,{type:"button",variant:"outline",size:"sm",className:"self-start",onClick:()=>n([...e,{label:"",to:t[0]?.id??"end"}]),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a button"]})]})}function Tl({minutes:e,label:t,set:n}){let o=e%1440===0?1440:e%60===0?60:1;return(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(ne,{type:"number",min:1,max:Math.floor(43200/o),value:e/o,className:"w-24","aria-label":`${t} (number)`,onChange:r=>{let s=Math.round(Number(r.target.value));Number.isFinite(s)&&s>=1&&n(Math.min(43200,s*o))}}),(0,a.jsxs)("select",{className:ue,"aria-label":`${t} (unit)`,value:o,onChange:r=>n(Math.min(43200,Math.max(1,e/o*Number(r.target.value)))),children:[(0,a.jsx)("option",{value:1,children:"minutes"}),(0,a.jsx)("option",{value:60,children:"hours"}),(0,a.jsx)("option",{value:1440,children:"days"})]})]})}function w0({stage:e,others:t,update:n}){let o=e.kind==="inbox"||e.kind==="approval"||e.kind==="choose";return(0,a.jsxs)("div",{className:"grid gap-2","data-time-limit":!0,children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-body font-medium",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:e.limit!==void 0,onChange:r=>n({limit:r.target.checked?{minutes:1440,to:null}:void 0})}),"Time limit"]}),e.limit!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Remind after",hint:e.kind==="approval"?"Whoever decides hears about it once.":e.kind==="choose"?"Whoever chooses hears about it once.":"The card's owner (or the flow's) hears about it once.",children:(0,a.jsx)(Tl,{minutes:e.limit.minutes,label:"Remind after",set:r=>n({limit:{...e.limit,minutes:r}})})}),o&&(0,a.jsx)(Y,{label:e.kind==="choose"?"If no reply":"Then",children:(0,a.jsxs)("select",{className:ue,"aria-label":"After the time limit",value:e.limit.to??"",onChange:r=>n({limit:{...e.limit,to:r.target.value||null}}),children:[(0,a.jsx)("option",{value:"",children:"Keep it here"}),t.map(r=>(0,a.jsxs)("option",{value:r.id,children:["Move it to ",r.title]},r.id))]})})]})]})}function j0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(""),[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(!1),u=e.stages.find(c=>c.id===e.start);return(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async c=>{c.preventDefault(),h(!0);let p=await me(`${e.flow.href}/cards`,{title:o,description:s},t);h(!1),n(p),p.ok&&(r(""),i(""))},children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["It starts in ",u?.title??"the first zone","."]}),(0,a.jsx)(ne,{value:o,onChange:c=>r(c.target.value),placeholder:"What needs doing?",maxLength:200,required:!0,"aria-label":"Title"}),(0,a.jsx)(ye,{value:s,onChange:c=>i(c.target.value),placeholder:"Details (optional)",rows:4,"aria-label":"Details"}),(0,a.jsx)(kn,{children:(0,a.jsx)(he,{type:"submit",variant:"primary",label:"Add card",busy:l?"Adding…":!1,disabled:o.trim()===""})})]})}var Es=e=>{if(e===null)return"";let t=Math.round((ur()-Date.parse(e))/6e4);return t<1?"Just now":t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} h ago`:So(e)};function Ms({label:e,value:t}){let[n,o]=(0,D.useState)(null);return(0,a.jsxs)("div",{className:"grid gap-1",children:[(0,a.jsx)("span",{className:"text-caption",children:e}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(ne,{readOnly:!0,value:t,className:"h-8 font-mono text-mono",onFocus:r=>r.target.select(),"aria-label":e}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>o(`${e} copied.`),()=>o("Select it and copy it by hand."))},"aria-label":`Copy ${e.toLowerCase()}`,children:(0,a.jsx)(Ha,{className:"size-3.5"})})]}),n!==null&&(0,a.jsx)("p",{className:"k-note",role:"status",children:n})]})}function N0({kind:e,reveal:t,onDone:n}){return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-primary/40 bg-primary/5 p-3","data-trigger-reveal":!0,children:[(0,a.jsx)("p",{className:"text-body font-semibold",children:"Copy these now. They aren't shown again."}),t.path===""?null:t.address===null?(0,a.jsxs)("p",{className:"text-caption font-normal",children:["Save your public webhook address below first, then choose New address. ",(0,a.jsx)("span",{className:"break-all font-mono",children:t.path})]}):(0,a.jsx)(Ms,{label:"Address",value:t.address}),t.secret!==null&&(0,a.jsx)(Ms,{label:"Secret",value:t.secret}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e==="github"?"In GitHub: Settings → Webhooks → Add webhook. Paste the address and the secret, choose application/json, and pick the events this trigger watches (Issues, Pull requests or Workflow runs).":e==="linear"?"In Linear: Settings → API → Webhooks → New webhook. Paste the address and choose Issues. Then paste Linear's signing secret on this trigger.":e==="form"?"Share this link. Anyone who has it can add a card without signing in; the work it starts still waits for your approval.":e==="sentry"?"In Sentry: Settings → Developer Settings → Internal Integration. Paste the address as its Webhook URL, turn on Alert Rule Action and Issue events, then paste its Client Secret on this trigger.":e==="vercel"?"In Vercel: Settings → Webhooks. Paste the address, choose Deployment Error, then paste the secret Vercel shows on this trigger.":e==="standard"?"Give the sender the address and the secret (whsec_…): it signs each delivery the Standard Webhooks way.":e==="github-style"?"Give the sender the address and the secret: it signs each delivery's body with HMAC-SHA256 in an X-Hub-Signature-256: sha256=… header.":"Post JSON to the address. A title field becomes the card's title; description, its details. Anyone with the address can post: choose who signs it to close that."}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",className:"self-start",onClick:n,children:"Done"})]})}var k0={button:["label","questions"],schedule:["schedule","title","description","script","secrets"],github:["repo","watch","label","branch","from","delivery"],linear:["team","state","label","delivery"],flow:["flow","when"],webhook:["title","titleField","bodyField"],email:["folder","sender","subject"],"plane-review":["at","timeZone"]};function S0({view:e,csrf:t,open:n,onResult:o}){let r=e.triggerSetup,[s,i]=(0,D.useState)("button"),[l,h]=(0,D.useState)({}),[u,c]=(0,D.useState)(!1),[p,d]=(0,D.useState)(!1),[m,f]=(0,D.useState)(""),w=wt(),y={schedule:{schedule:`daily 09:00 ${w}`},github:{repo:r.githubRepo??"",watch:"issues",from:"team",delivery:"poll",branch:"main"},linear:{delivery:"poll"},flow:{flow:String(r.otherFlows[0]?.id??"")},webhook:{title:"Webhook"},email:{folder:"INBOX"},"plane-review":{at:"07:30",timeZone:w}},x=C=>l[C]??y[s]?.[C]??"",E=s==="webhook"||(s==="github"||s==="linear")&&x("delivery")==="webhook",v=!E&&(s==="github"&&x("from")==="anyone"||s==="email"&&x("sender").trim()===""),b=(0,D.useContext)(jt),j=C=>_=>h(F=>({...F,[C]:_.target.value})),S=r.otherFlows.find(C=>String(C.id)===x("flow")),M=async C=>{C.preventDefault();let _={kind:s,zone:x("zone")||null};for(let O of k0[s]??[])_[O]=O==="questions"?x(O).split(`
|
|
13
|
+
npm test`};function x0({email:e,view:t,set:n}){return(0,a.jsxs)(a.Fragment,{children:[!t.emailReady&&(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-email-needs-setup":!0,children:["Email isn't set up yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/alerts#email",children:"Add your mail server in Settings"})]}),(0,a.jsx)(Y,{label:"To",children:(0,a.jsx)(ne,{value:e.to,maxLength:500,onChange:o=>n({...e,to:o.target.value}),"aria-label":"To"})}),(0,a.jsx)(Y,{label:"Subject",children:(0,a.jsx)(ne,{value:e.subject,maxLength:200,onChange:o=>n({...e,subject:o.target.value}),"aria-label":"Subject"})}),(0,a.jsx)(Y,{label:"Email",hint:ja,children:(0,a.jsx)(ye,{rows:6,value:e.body,maxLength:8e3,onChange:o=>n({...e,body:o.target.value}),"aria-label":"Email"})})]})}function v0({tool:e,view:t,set:n}){let o=t.tools.find(r=>r.name===e.server);return(0,a.jsxs)(a.Fragment,{children:[t.tools.length===0?(0,a.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-tool-needs-setup":!0,children:["This project has no tools yet. ",(0,a.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/tools",children:"Add one on the Tools page"})]}):(0,a.jsx)(Y,{label:"Tool",...o!==void 0&&!o.ready?{hint:"It needs its secrets set on the Tools page first."}:o!==void 0?{hint:o.about}:{},children:(0,a.jsxs)("select",{className:ue,value:e.server,onChange:r=>n({...e,server:r.target.value,name:t.tools.find(s=>s.name===r.target.value)?.functions[0]??""}),"aria-label":"Tool",children:[o===void 0&&(0,a.jsx)("option",{value:e.server,children:e.server===""?"Choose a tool":`${e.server} (missing)`}),t.tools.map(r=>(0,a.jsx)("option",{value:r.name,children:r.name},r.name))]})}),(0,a.jsx)(Y,{label:"What it does",hint:o!==void 0&&o.functions.length===0?"Test the tool on the Tools page to list what it can do.":void 0,children:o!==void 0&&o.functions.length>0?(0,a.jsxs)("select",{className:ue,value:e.name,onChange:r=>n({...e,name:r.target.value}),"aria-label":"What it does",children:[!o.functions.includes(e.name)&&(0,a.jsx)("option",{value:e.name,children:e.name||"Choose"}),o.functions.map(r=>(0,a.jsx)("option",{value:r,children:r},r))]}):(0,a.jsx)(ne,{value:e.name,maxLength:100,onChange:r=>n({...e,name:r.target.value}),className:"font-mono","aria-label":"What it does"})}),(0,a.jsx)(Y,{label:"Arguments",hint:`JSON, with fill-ins inside its strings. ${ja}`,children:(0,a.jsx)(ye,{rows:5,value:e.args,maxLength:4e3,onChange:r=>n({...e,args:r.target.value}),className:"font-mono text-mono","aria-label":"Arguments"})})]})}function y0({stage:e,stages:t,view:n,csrf:o,apply:r,update:s,remove:i,makeStart:l,onClose:h}){let u=t.filter(d=>d.id!==e.id),c=ue,p=n.kinds.find(d=>d.kind===e.kind);return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-flow-zone-panel":e.id,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"flex-1 text-title",children:"Edit zone"}),(0,a.jsx)(te,{variant:"ghost",size:"icon",onClick:h,"aria-label":"Close",children:(0,a.jsx)(rt,{className:"size-4"})})]}),(0,a.jsx)(Y,{label:"Name",children:(0,a.jsx)(ne,{value:e.title,maxLength:60,onChange:d=>s({title:d.target.value}),"aria-label":"Zone name"})}),(0,a.jsx)(Y,{label:"What happens here",...p===void 0?{}:{hint:p.about},children:(0,a.jsx)("select",{className:c,"aria-label":"What happens here",value:e.kind,onChange:d=>s({kind:d.target.value,...d.target.value==="done"?{next:null,onFail:null}:{},...d.target.value==="update"?{close:e.close??!0,message:e.message??"Done: {{card.title}}"}:{},...d.target.value==="check"?{script:e.script??n.scripts[0]?.name??null,runIn:e.runIn??"folder"}:{},...d.target.value==="request"?{request:e.request??{method:"POST",url:"https://",headers:{},body:'{"title": "{{card.title}}", "details": "{{card.description}}"}'}}:{},...d.target.value==="email"?{email:e.email??{to:"{{card.email}}",subject:"Re: {{card.title}}",body:t.find(m=>m.kind==="draft")?`{{stage.${t.find(m=>m.kind==="draft").id}}}`:""}}:{},...d.target.value==="tool"?{tool:e.tool??{server:n.tools[0]?.name??"",name:n.tools[0]?.functions[0]??"",args:'{"text": "{{card.title}}"}'}}:{},...d.target.value==="draft"?{instructions:e.instructions??"Write a short, friendly reply to the person who sent this card, in plain words."}:{},...d.target.value==="approval"?{toOwner:e.toOwner??!0}:{},...d.target.value==="wait"?{wait:e.wait??{for:"reply",minutes:4320}}:{},...d.target.value==="subagent"?{subagent:e.subagent??n.subagents?.[0]?.handle,instructions:e.instructions??"Read the card and decide what happens next."}:d.target.value!=="approval"?{subagent:void 0}:{},...d.target.value==="wait"||d.target.value==="done"?{limit:void 0}:d.target.value!=="inbox"&&d.target.value!=="approval"&&d.target.value!=="choose"&&e.limit!==void 0?{limit:{...e.limit,to:null}}:{},...d.target.value==="choose"?{next:null,options:e.options??[{label:"Looks good",to:u.find(m=>m.kind==="done")?.id??u[0]?.id??"end"},{label:"Ignore",to:"end"}]}:{options:void 0},...d.target.value==="task"?{}:{repo:void 0},...d.target.value==="sort"?{next:null,sort:e.sort??{question:"What kind of card is this?",answers:u.slice(0,2).map(m=>({answer:m.title.slice(0,40),means:m.title,to:m.id})),sureAt:.8,notes:[]}}:{}}),children:n.kinds.map(d=>(0,a.jsx)("option",{value:d.kind,children:d.label},d.kind))})}),e.kind==="draft"&&(0,a.jsx)(Y,{label:"What Claude should write",hint:"Claude reads the card and what earlier zones said. Put a “Person decides” zone next to read and edit it first.",children:(0,a.jsx)(ye,{rows:5,value:e.instructions??"",maxLength:8e3,onChange:d=>s({instructions:d.target.value}),"aria-label":"What Claude should write"})}),(e.kind==="task"||e.kind==="report")&&(0,a.jsx)(Y,{label:"What the agent should do",hint:"Fill-ins: {{card.title}}, {{card.description}}, {{note}} (the latest send-back note), {{stage.<zone id>}} (an earlier zone's report; a research zone adds .items and .report).",children:(0,a.jsx)(ye,{rows:7,value:e.instructions??"",onChange:d=>s({instructions:d.target.value}),"aria-label":"What the agent should do"})}),e.kind==="task"&&(n.projects??[]).length>1&&(0,a.jsx)(Y,{label:"Builds in",hint:"Another project files its task there, as the flow's owner, under that project's approvals.",children:(0,a.jsxs)("select",{className:c,"aria-label":"Builds in",value:e.repo??n.projects[0].path,onChange:d=>s({repo:d.target.value===n.projects[0].path?void 0:d.target.value}),children:[n.projects.map((d,m)=>(0,a.jsx)("option",{value:d.path,children:m===0?`${d.name} (this flow's project)`:d.name},d.path)),e.repo!==void 0&&!n.projects.some(d=>d.path===e.repo)&&(0,a.jsxs)("option",{value:e.repo,children:[e.repo," (not yours)"]})]})}),e.kind==="choose"&&(0,a.jsx)(b0,{options:e.options??[],others:u,set:d=>s({options:d})}),e.kind==="task"&&(0,a.jsx)(Y,{label:"Plan first?",children:(0,a.jsxs)("select",{className:c,"aria-label":"Plan first?",value:e.planning??"auto",onChange:d=>s({planning:d.target.value}),children:[(0,a.jsx)("option",{value:"auto",children:"Let Toolroll decide"}),(0,a.jsx)("option",{value:"required",children:"Always plan first"}),(0,a.jsx)("option",{value:"skip",children:"Build directly"})]})}),e.kind==="approval"&&(0,a.jsx)(Y,{label:"Who decides",children:(0,a.jsxs)("select",{className:c,"aria-label":"Who decides",value:e.subagent!==void 0?`__mate__:${e.subagent}`:e.toOwner===!0?"__owner__":e.approver??"",onChange:d=>s(d.target.value.startsWith("__mate__:")?{subagent:d.target.value.slice(9),toOwner:!0,approver:null}:d.target.value==="__owner__"?{subagent:void 0,toOwner:!0,approver:null}:{subagent:void 0,toOwner:!1,approver:d.target.value===""?null:d.target.value}),children:[(n.subagents??[]).map(d=>(0,a.jsxs)("option",{value:`__mate__:${d.handle}`,children:[d.name," (subagent), handing hard ones to the flow's owner",d.working?"":" (paused)"]},d.handle)),(0,a.jsxs)("option",{value:"__owner__",children:["The flow's owner (",n.flow.owner,"), in their chat app"]}),(0,a.jsx)("option",{value:"",children:"Anyone who can approve"}),n.approvers.map(d=>(0,a.jsx)("option",{value:d,children:d},d))]})}),e.kind==="notify"&&(0,a.jsx)(Y,{label:"Message",children:(0,a.jsx)(ne,{value:e.message??"",maxLength:1e3,onChange:d=>s({message:d.target.value}),"aria-label":"Message"})}),e.kind==="update"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Comment on the issue",hint:"Fill-ins: {{card.title}}, {{note}}, {{stage.<zone id>}}.",children:(0,a.jsx)(ye,{rows:3,value:e.message??"",maxLength:1e3,onChange:d=>s({message:d.target.value}),"aria-label":"Comment on the issue"})}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-body",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:e.close!==!1,onChange:d=>s({close:d.target.checked})}),"Close the issue too (Linear: move it to done)"]})]}),e.kind==="pull-request"&&(0,a.jsx)(Y,{label:"When checks pass",hint:"Merging needs a “Person decides” zone before this one, and a person's approval of the card since it was built.",children:(0,a.jsxs)("select",{className:c,"aria-label":"When checks pass",value:e.merge??"",onChange:d=>s({merge:d.target.value===""?void 0:d.target.value}),children:[(0,a.jsx)("option",{value:"",children:"Move on; a person merges"}),(0,a.jsx)("option",{value:"squash",children:"Merge (squash)"}),(0,a.jsx)("option",{value:"merge",children:"Merge (merge commit)"}),(0,a.jsx)("option",{value:"rebase",children:"Merge (rebase)"})]})}),e.kind==="check"&&(0,a.jsx)(f0,{stage:e,others:u,view:n,csrf:o,apply:r,update:s}),e.kind==="subagent"&&(0,a.jsx)(m0,{stage:e,others:u,view:n,update:s}),e.kind==="request"&&e.request!==void 0&&(0,a.jsx)(h0,{request:e.request,view:n,csrf:o,apply:r,set:d=>s({request:d})}),e.kind==="email"&&e.email!==void 0&&(0,a.jsx)(x0,{email:e.email,view:n,set:d=>s({email:d})}),e.kind==="tool"&&e.tool!==void 0&&(0,a.jsx)(v0,{tool:e.tool,view:n,set:d=>s({tool:d})}),e.kind==="sort"&&e.sort!==null&&(0,a.jsx)(u0,{sort:e.sort,others:u,ready:n.sortReady,set:d=>s({sort:d})}),e.kind==="wait"&&e.wait!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Wait for",hint:e.wait.for==="reply"?"Only a reply from someone it emailed counts. Needs the inbox in Settings → Email.":void 0,children:(0,a.jsxs)("select",{className:c,"aria-label":"Wait for",value:e.wait.for,onChange:d=>s({wait:d.target.value==="hours"?{for:"hours",minutes:0,from:e.wait.from??"22:00",to:e.wait.to??"06:00"}:{for:d.target.value,minutes:e.wait.minutes>0?e.wait.minutes:1440}}),children:[(0,a.jsx)("option",{value:"reply",children:"A reply to the card's email"}),(0,a.jsx)("option",{value:"time",children:"A set time"}),(0,a.jsx)("option",{value:"hours",children:"Set hours, like overnight"})]})}),e.wait.for==="hours"?(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsx)(Y,{label:"From",children:(0,a.jsx)(ne,{type:"time",value:e.wait.from??"22:00",onChange:d=>s({wait:{...e.wait,from:d.target.value}}),"aria-label":"From"})}),(0,a.jsx)(Y,{label:"Until",children:(0,a.jsx)(ne,{type:"time",value:e.wait.to??"06:00",onChange:d=>s({wait:{...e.wait,to:d.target.value}}),"aria-label":"Until"})})]}):(0,a.jsx)(Y,{label:e.wait.for==="reply"?"For up to":"How long",children:(0,a.jsx)(Tl,{minutes:e.wait.minutes,label:e.wait.for==="reply"?"For up to":"How long",set:d=>s({wait:{...e.wait,minutes:d}})})})]}),e.kind!=="done"&&e.kind!=="sort"&&e.kind!=="choose"&&(0,a.jsx)(Y,{label:e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",children:(0,a.jsxs)("select",{className:c,"aria-label":e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",value:e.next??"",onChange:d=>s({next:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Wait here"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind==="wait"&&e.wait?.for==="reply"&&(0,a.jsx)(Y,{label:"If no reply",children:(0,a.jsxs)("select",{className:c,"aria-label":"If no reply",value:e.onFail??"",onChange:d=>s({onFail:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:"Stay here for a person"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),(e.kind==="approval"||e.kind==="task"||e.kind==="report"||e.kind==="check"||e.kind==="pull-request"||e.kind==="update"||e.kind==="sort"||e.kind==="request"||e.kind==="email"||e.kind==="tool"||e.kind==="subagent"||e.kind==="choose")&&(0,a.jsx)(Y,{label:$s[e.kind]??"If it fails",...e.kind==="choose"?{hint:"Their reply is the note there ({{note}})."}:{},children:(0,a.jsxs)("select",{className:c,"aria-label":$s[e.kind]??"If it fails",value:e.onFail??"",onChange:d=>s({onFail:d.target.value||null}),children:[(0,a.jsx)("option",{value:"",children:e.kind==="approval"?"Can't be sent back":e.kind==="sort"?"Wait here for a person":e.kind==="choose"?"Where the first option goes":"Wait here"}),u.map(d=>(0,a.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind!=="wait"&&e.kind!=="done"&&(0,a.jsx)(w0,{stage:e,others:u,update:s}),(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Color"}),(0,a.jsx)("div",{className:"flex gap-2",children:n.colors.map(d=>(0,a.jsx)(he,{type:"button",variant:"ghost",sm:!0,iconOnly:"check",label:Wg[d]??d,"aria-pressed":e.zone.color===d,className:"rounded-full [&_svg]:invisible aria-pressed:[&_svg]:visible",style:{background:At[d],color:"var(--so-paper)"},onClick:()=>s({zone:{...e.zone,color:d}})},d))})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:[n.start!==e.id&&(0,a.jsx)(te,{variant:"outline",size:"sm",onClick:l,children:"New cards start here"}),(0,a.jsx)(te,{variant:"ghost",size:"sm",className:"text-destructive",onClick:i,disabled:t.length<=1,children:"Delete zone"})]})]})}var $s={approval:"If sent back",sort:"If it isn't sure",subagent:"If it can't handle it","pull-request":"If checks fail",choose:"If they reply"};function b0({options:e,others:t,set:n}){let o=(r,s)=>n(e.map((i,l)=>l===r?{...i,...s}:i));return(0,a.jsxs)("div",{className:"grid gap-2","data-choose-options":!0,children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Buttons"}),e.map((r,s)=>(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ne,{className:"min-w-0 flex-1",value:r.label,maxLength:40,onChange:i=>o(s,{label:i.target.value}),"aria-label":`Button ${s+1}`}),(0,a.jsxs)("select",{className:xe(ue,"min-w-0 flex-1"),"aria-label":`Button ${s+1} goes to`,value:r.to,onChange:i=>o(s,{to:i.target.value}),children:[(0,a.jsx)("option",{value:"end",children:"Ignore the card"}),t.map(i=>(0,a.jsx)("option",{value:i.id,children:i.title},i.id))]}),e.length>2&&(0,a.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(e.filter((i,l)=>l!==s)),"aria-label":`Remove button ${s+1}`,children:(0,a.jsx)(rt,{className:"size-4"})})]},s)),e.length<4&&(0,a.jsxs)(te,{type:"button",variant:"outline",size:"sm",className:"self-start",onClick:()=>n([...e,{label:"",to:t[0]?.id??"end"}]),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add a button"]})]})}function Tl({minutes:e,label:t,set:n}){let o=e%1440===0?1440:e%60===0?60:1;return(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(ne,{type:"number",min:1,max:Math.floor(43200/o),value:e/o,className:"w-24","aria-label":`${t} (number)`,onChange:r=>{let s=Math.round(Number(r.target.value));Number.isFinite(s)&&s>=1&&n(Math.min(43200,s*o))}}),(0,a.jsxs)("select",{className:ue,"aria-label":`${t} (unit)`,value:o,onChange:r=>n(Math.min(43200,Math.max(1,e/o*Number(r.target.value)))),children:[(0,a.jsx)("option",{value:1,children:"minutes"}),(0,a.jsx)("option",{value:60,children:"hours"}),(0,a.jsx)("option",{value:1440,children:"days"})]})]})}function w0({stage:e,others:t,update:n}){let o=e.kind==="inbox"||e.kind==="approval"||e.kind==="choose";return(0,a.jsxs)("div",{className:"grid gap-2","data-time-limit":!0,children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-body font-medium",children:[(0,a.jsx)("input",{type:"checkbox",className:"size-4 accent-primary",checked:e.limit!==void 0,onChange:r=>n({limit:r.target.checked?{minutes:1440,to:null}:void 0})}),"Time limit"]}),e.limit!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Remind after",hint:e.kind==="approval"?"Whoever decides hears about it once.":e.kind==="choose"?"Whoever chooses hears about it once.":"The card's owner (or the flow's) hears about it once.",children:(0,a.jsx)(Tl,{minutes:e.limit.minutes,label:"Remind after",set:r=>n({limit:{...e.limit,minutes:r}})})}),o&&(0,a.jsx)(Y,{label:e.kind==="choose"?"If no reply":"Then",children:(0,a.jsxs)("select",{className:ue,"aria-label":"After the time limit",value:e.limit.to??"",onChange:r=>n({limit:{...e.limit,to:r.target.value||null}}),children:[(0,a.jsx)("option",{value:"",children:"Keep it here"}),t.map(r=>(0,a.jsxs)("option",{value:r.id,children:["Move it to ",r.title]},r.id))]})})]})]})}function j0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(""),[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(!1),u=e.stages.find(c=>c.id===e.start);return(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async c=>{c.preventDefault(),h(!0);let p=await me(`${e.flow.href}/cards`,{title:o,description:s},t);h(!1),n(p),p.ok&&(r(""),i(""))},children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["It starts in ",u?.title??"the first zone","."]}),(0,a.jsx)(ne,{value:o,onChange:c=>r(c.target.value),placeholder:"What needs doing?",maxLength:200,required:!0,"aria-label":"Title"}),(0,a.jsx)(ye,{value:s,onChange:c=>i(c.target.value),placeholder:"Details (optional)",rows:4,"aria-label":"Details"}),(0,a.jsx)(kn,{children:(0,a.jsx)(he,{type:"submit",variant:"primary",label:"Add card",busy:l?"Adding…":!1,disabled:o.trim()===""})})]})}var Es=e=>{if(e===null)return"";let t=Math.round((hr()-Date.parse(e))/6e4);return t<1?"Just now":t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} h ago`:So(e)};function Ms({label:e,value:t}){let[n,o]=(0,D.useState)(null);return(0,a.jsxs)("div",{className:"grid gap-1",children:[(0,a.jsx)("span",{className:"text-caption",children:e}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(ne,{readOnly:!0,value:t,className:"h-8 font-mono text-mono",onFocus:r=>r.target.select(),"aria-label":e}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>o(`${e} copied.`),()=>o("Select it and copy it by hand."))},"aria-label":`Copy ${e.toLowerCase()}`,children:(0,a.jsx)(Ha,{className:"size-3.5"})})]}),n!==null&&(0,a.jsx)("p",{className:"k-note",role:"status",children:n})]})}function N0({kind:e,reveal:t,onDone:n}){return(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-primary/40 bg-primary/5 p-3","data-trigger-reveal":!0,children:[(0,a.jsx)("p",{className:"text-body font-semibold",children:"Copy these now. They aren't shown again."}),t.path===""?null:t.address===null?(0,a.jsxs)("p",{className:"text-caption font-normal",children:["Save your public webhook address below first, then choose New address. ",(0,a.jsx)("span",{className:"break-all font-mono",children:t.path})]}):(0,a.jsx)(Ms,{label:"Address",value:t.address}),t.secret!==null&&(0,a.jsx)(Ms,{label:"Secret",value:t.secret}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:e==="github"?"In GitHub: Settings → Webhooks → Add webhook. Paste the address and the secret, choose application/json, and pick the events this trigger watches (Issues, Pull requests or Workflow runs).":e==="linear"?"In Linear: Settings → API → Webhooks → New webhook. Paste the address and choose Issues. Then paste Linear's signing secret on this trigger.":e==="form"?"Share this link. Anyone who has it can add a card without signing in; the work it starts still waits for your approval.":e==="sentry"?"In Sentry: Settings → Developer Settings → Internal Integration. Paste the address as its Webhook URL, turn on Alert Rule Action and Issue events, then paste its Client Secret on this trigger.":e==="vercel"?"In Vercel: Settings → Webhooks. Paste the address, choose Deployment Error, then paste the secret Vercel shows on this trigger.":e==="standard"?"Give the sender the address and the secret (whsec_…): it signs each delivery the Standard Webhooks way.":e==="github-style"?"Give the sender the address and the secret: it signs each delivery's body with HMAC-SHA256 in an X-Hub-Signature-256: sha256=… header.":"Post JSON to the address. A title field becomes the card's title; description, its details. Anyone with the address can post: choose who signs it to close that."}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",className:"self-start",onClick:n,children:"Done"})]})}var k0={button:["label","questions"],schedule:["schedule","title","description","script","secrets"],github:["repo","watch","label","branch","from","delivery"],linear:["team","state","label","delivery"],flow:["flow","when"],webhook:["title","titleField","bodyField"],email:["folder","sender","subject"],"plane-review":["at","timeZone"]};function S0({view:e,csrf:t,open:n,onResult:o}){let r=e.triggerSetup,[s,i]=(0,D.useState)("button"),[l,h]=(0,D.useState)({}),[u,c]=(0,D.useState)(!1),[p,d]=(0,D.useState)(!1),[m,f]=(0,D.useState)(""),w=wt(),y={schedule:{schedule:`daily 09:00 ${w}`},github:{repo:r.githubRepo??"",watch:"issues",from:"team",delivery:"poll",branch:"main"},linear:{delivery:"poll"},flow:{flow:String(r.otherFlows[0]?.id??"")},webhook:{title:"Webhook"},email:{folder:"INBOX"},"plane-review":{at:"07:30",timeZone:w}},x=C=>l[C]??y[s]?.[C]??"",E=s==="webhook"||(s==="github"||s==="linear")&&x("delivery")==="webhook",v=!E&&(s==="github"&&x("from")==="anyone"||s==="email"&&x("sender").trim()===""),b=(0,D.useContext)(jt),j=C=>_=>h(F=>({...F,[C]:_.target.value})),S=r.otherFlows.find(C=>String(C.id)===x("flow")),M=async C=>{C.preventDefault();let _={kind:s,zone:x("zone")||null};for(let O of k0[s]??[])_[O]=O==="questions"?x(O).split(`
|
|
14
14
|
`):O==="flow"?Number(x(O)):x(O)||null;d(!0);let F=await me(`${e.flow.href}/triggers`,{trigger:JSON.stringify(_),...E||v?{password:m}:{}},t);F.ok&&f(""),d(!1),o(F,s),F.ok&&h({})};return(0,a.jsxs)("details",{className:"rounded-lg border px-3 py-2",open:n||void 0,children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-semibold",children:"Add a trigger"}),(0,a.jsxs)("form",{className:"flex flex-col gap-3 pt-3",onSubmit:C=>{M(C)},"data-add-trigger":!0,children:[(0,a.jsx)(Y,{label:"What starts cards",children:(0,a.jsx)("select",{className:ue,value:s,onChange:C=>{i(C.target.value),h({})},children:r.kinds.map(C=>(0,a.jsx)("option",{value:C.kind,children:C.label},C.kind))})}),s==="button"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Button name",children:(0,a.jsx)(ne,{value:x("label"),onChange:j("label"),placeholder:"Report a bug",maxLength:40,required:!0})}),(0,a.jsx)(Y,{label:"Questions it asks",hint:"One per line. The first answer becomes the card's title.",children:(0,a.jsx)(ye,{rows:3,value:x("questions"),onChange:j("questions"),placeholder:`What happened?
|
|
15
15
|
Steps to reproduce
|
|
16
|
-
How bad is it?`})})]}),s==="schedule"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"When",hint:"For example: daily 09:00 Europe/London, monday 09:00, every 4 hours.",children:(0,a.jsx)(ne,{value:x("schedule"),onChange:j("schedule"),required:!0})}),(0,a.jsx)(Y,{label:"Makes",children:(0,a.jsxs)("select",{className:ue,value:x("script")===""&&!u?"card":"script","aria-label":"Makes",onChange:C=>{c(C.target.value==="script"),h(_=>({..._,script:C.target.value==="script"?e.scripts[0]?.name??"":""}))},children:[(0,a.jsx)("option",{value:"card",children:"One card each time"}),(0,a.jsx)("option",{value:"script",children:"A card for each item a script prints"})]})}),x("script")!==""||u?e.scripts.length===0?(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"This project has no scripts yet: make one with Scripts in the toolbar."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Script",hint:'It prints one item per line (a title, or JSON like {"title": "…", "key": 42}). The same item never makes two cards.',children:(0,a.jsx)("select",{className:ue,value:x("script"),onChange:j("script"),"aria-label":"Script",children:e.scripts.map(C=>(0,a.jsxs)("option",{value:C.name,children:[C.name," — ",C.about]},C.name))})}),(0,a.jsx)(Y,{label:"Secrets it gets (optional)",hint:"Names of saved secrets, like CRM_KEY. Save them on a script zone's Secrets.",children:(0,a.jsx)(ne,{value:x("secrets"),onChange:j("secrets"),className:"font-mono",placeholder:"CRM_KEY",maxLength:400})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Card title",hint:"Each card's date is added to it.",children:(0,a.jsx)(ne,{value:x("title"),onChange:j("title"),placeholder:"Dependency check",maxLength:200,required:!0})}),(0,a.jsx)(Y,{label:"Details (optional)",children:(0,a.jsx)(ye,{rows:3,value:x("description"),onChange:j("description")})})]})]}),s==="github"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Repository",children:(0,a.jsx)(ne,{value:x("repo"),onChange:j("repo"),placeholder:"owner/name",required:!0})}),(0,a.jsx)(Y,{label:"Watch",children:(0,a.jsxs)("select",{className:ue,value:x("watch"),onChange:j("watch"),children:[(0,a.jsx)("option",{value:"issues",children:"New issues"}),(0,a.jsx)("option",{value:"pulls",children:"New pull requests"}),(0,a.jsx)("option",{value:"checks",children:"Failed checks"})]})}),x("watch")!=="checks"&&(0,a.jsx)(Y,{label:"Label (optional)",hint:x("watch")==="issues"?"With a label, an issue joins the moment it gets the label.":"Only pull requests with this label.",children:(0,a.jsx)(ne,{value:x("label"),onChange:j("label"),placeholder:"bug",maxLength:50})}),x("watch")==="checks"&&(0,a.jsx)(Y,{label:"Branch",children:(0,a.jsx)(ne,{value:x("branch"),onChange:j("branch"),maxLength:100})}),x("watch")!=="checks"&&(0,a.jsx)(Y,{label:"From",hint:x("from")==="anyone"?"Anyone who can open one there can write what the agent reads. The work still waits for your approval.":void 0,children:(0,a.jsxs)("select",{className:ue,value:x("from"),onChange:j("from"),children:[(0,a.jsx)("option",{value:"team",children:"People with write access"}),(0,a.jsx)("option",{value:"anyone",children:"Anyone"})]})})]}),s==="linear"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Team key",hint:"Like ENG. Name a team, a label, or both.",children:(0,a.jsx)(ne,{value:x("team"),onChange:j("team"),placeholder:"ENG",maxLength:12})}),(0,a.jsx)(Y,{label:"When it moves to (optional)",children:(0,a.jsx)(ne,{value:x("state"),onChange:j("state"),placeholder:"Todo",maxLength:40})}),(0,a.jsx)(Y,{label:"Label (optional)",children:(0,a.jsx)(ne,{value:x("label"),onChange:j("label"),placeholder:"bug",maxLength:50})})]}),(s==="github"||s==="linear")&&(0,a.jsx)(Y,{label:"How it arrives",hint:x("delivery")==="webhook"?r.hooksBase===null?"Needs your public webhook address: set it under Settings below.":"You'll get an address to paste into "+(s==="github"?"GitHub.":"Linear."):s==="linear"&&!r.linearKey?"Save your Linear key under Settings below first.":void 0,children:(0,a.jsxs)("select",{className:ue,value:x("delivery"),onChange:j("delivery"),children:[(0,a.jsx)("option",{value:"poll",children:"Checked every 2 minutes"}),(0,a.jsx)("option",{value:"webhook",children:"Sent to a webhook address"})]})}),s==="flow"&&(r.otherFlows.length===0?(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"There are no other flows to follow yet."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Flow",children:(0,a.jsx)("select",{className:ue,value:x("flow"),onChange:C=>h(_=>({..._,flow:C.target.value,when:""})),children:r.otherFlows.map(C=>(0,a.jsx)("option",{value:C.id,children:C.name},C.id))})}),(0,a.jsx)(Y,{label:"When a card reaches",children:(0,a.jsxs)("select",{className:ue,value:x("when"),onChange:j("when"),children:[(0,a.jsx)("option",{value:"",children:"The end"}),S?.zones.map(C=>(0,a.jsx)("option",{value:C.id,children:C.title},C.id))]})})]})),s==="chat"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-chat-connect":!0,children:[(0,a.jsx)("p",{children:"Connect a Slack, Discord or Teams channel, or a Telegram group, from the channel itself. Where Toolroll is, send:"}),(0,a.jsx)("p",{children:(0,a.jsxs)("code",{className:"rounded bg-background px-1.5 py-0.5 font-semibold",children:["flow ",e.flow.id]})}),(0,a.jsxs)("p",{className:"text-muted-foreground",children:["Each new message there becomes a card here, and replies in its thread join the card's discussion. “flow off” stops it. In Teams, mention Toolroll in each message. In Telegram, send /flow ",e.flow.id,", and turn the bot's privacy mode off in BotFather so it sees every message."]})]}),s==="email"&&(0,a.jsxs)(a.Fragment,{children:[r.mailbox===null?(0,a.jsxs)("p",{className:"rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-mailbox-missing":!0,children:["Reading mail isn't set up yet. Add your mail server's IMAP address, or sign in with Google, in ",(0,a.jsx)("a",{className:"underline",href:"/settings/alerts#email",children:"Settings → Email"}),"."]}):(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["New mail in ",r.mailbox," becomes cards, from now on. The mailbox is only read: nothing is marked or moved."]}),(0,a.jsx)(Y,{label:"Folder",children:(0,a.jsx)(ne,{value:x("folder"),onChange:j("folder"),placeholder:"INBOX",maxLength:100})}),(0,a.jsx)(Y,{label:"Only from (optional)",hint:"Addresses or domains, like priya@example.com, example.com.",children:(0,a.jsx)(ne,{value:x("sender"),onChange:j("sender"),maxLength:300})}),(0,a.jsx)(Y,{label:"Subject has (optional)",children:(0,a.jsx)(ne,{value:x("subject"),onChange:j("subject"),placeholder:"Order",maxLength:100})})]}),s==="plane-review"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Every morning, reads the last 24 hours and makes one card per problem worth fixing. A problem that comes back joins its card. A clean day adds nothing."}),(0,a.jsx)(Y,{label:"Time",hint:`Every day, in ${x("timeZone")||"your time zone"}.`,children:(0,a.jsx)(ne,{type:"time",value:x("at"),onChange:j("at"),required:!0})})]}),s==="webhook"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Title field",hint:"Where to find the card's title in the posted JSON, like title or data.issue.title.",children:(0,a.jsx)(ne,{value:x("titleField"),onChange:j("titleField"),placeholder:"title",maxLength:80})}),(0,a.jsx)(Y,{label:"Details field",children:(0,a.jsx)(ne,{value:x("bodyField"),onChange:j("bodyField"),placeholder:"description",maxLength:80})}),(0,a.jsx)(Y,{label:"Title when there is none",children:(0,a.jsx)(ne,{value:x("title"),onChange:j("title"),maxLength:120})})]}),s!=="chat"&&(0,a.jsx)(Y,{label:"Cards start in",children:(0,a.jsxs)("select",{className:ue,value:x("zone"),onChange:j("zone"),children:[(0,a.jsx)("option",{value:"",children:e.stages.find(C=>C.id===e.start)?.title??"The first zone"}),e.stages.filter(C=>C.id!==e.start).map(C=>(0,a.jsx)("option",{value:C.id,children:C.title},C.id))]})}),E&&(0,a.jsx)(It,{view:e,password:m,setPassword:f,credential:!0}),v&&(0,a.jsx)(It,{view:e,password:m,setPassword:f}),s!=="chat"&&(0,a.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:p||s==="flow"&&r.otherFlows.length===0||E&&!xt(e,m)||v&&!xt(e,m,b),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add trigger"]})]})]})}function C0({view:e,csrf:t,apply:n}){let o=e.triggerSetup,r=(0,D.useContext)(jt),[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(""),[u,c]=(0,D.useState)(o.hooksBase??""),[p,d]=(0,D.useState)(!1),m=async(f,w)=>{d(!0);let y=await me(f,w,t);d(!1),n(y),y.ok&&(i(""),h(""))};return(0,a.jsxs)("details",{className:"rounded-lg border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-semibold",children:"Settings"}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-3",children:[o.linearKey?(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Linear key"}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"Saved on this computer."}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"ghost",className:"self-start text-destructive",disabled:p,onClick:()=>{m(`${e.flow.href}/linear-key`,{remove:"yes"})},children:"Remove key"})]}):(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:f=>{f.preventDefault(),m(`${e.flow.href}/linear-key`,{key:s,password:l})},children:[(0,a.jsx)(Y,{label:"Linear key",hint:"From Linear → Settings → Security & access → Personal API keys. Kept on this computer only.",children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:s,onChange:f=>i(f.target.value),placeholder:"lin_api_…"})}),(0,a.jsx)(It,{view:e,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:p||s.trim()===""||!xt(e,l,r),children:"Save key"})]}),(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:f=>{f.preventDefault(),m(`${e.flow.href}/hooks-address`,{address:u})},children:[(0,a.jsx)(Y,{label:"Public webhook address",hint:"The https site your reverse proxy (Caddy, for example) serves. Have it pass only paths starting /hooks/ to this console.",children:(0,a.jsx)(ne,{value:u,onChange:f=>c(f.target.value),placeholder:"https://hooks.example.com"})}),(0,a.jsx)(te,{type:"submit",size:"sm",variant:"outline",className:"self-start",disabled:p,children:"Save address"})]})]})]})}function It({view:e,password:t,setPassword:n,credential:o=!1}){let r=(0,D.useContext)(jt);return!o&&r?null:e.stepUp===void 0?(0,a.jsx)(Y,{label:"Your Toolroll password",children:(0,a.jsx)(ne,{type:"password",autoComplete:"current-password",value:t,onChange:s=>n(s.target.value)})}):e.stepUp.fresh?(0,a.jsxs)("p",{className:"text-body text-success","data-sso-step-up":"confirmed",children:["✓ Confirmed with ",e.stepUp.label]}):(0,a.jsxs)("a",{className:"text-body underline","data-sso-step-up":"confirm",href:e.stepUp.confirmHref,children:["Confirm with ",e.stepUp.label]})}var xt=(e,t,n=!1)=>n||(e.stepUp===void 0?t!=="":e.stepUp.fresh);function zs({view:e,label:t,busy:n,className:o,onConfirm:r}){let[s,i]=(0,D.useState)(!1),[l,h]=(0,D.useState)("");return s?(0,a.jsxs)("span",{className:"flex w-full flex-wrap items-end gap-2","data-credential-action":!0,children:[(0,a.jsx)(It,{view:e,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{size:"sm",disabled:n||!xt(e,l),onClick:()=>{r(l).then(u=>{u&&(i(!1),h(""))})},children:t}),(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:n,onClick:()=>{i(!1),h("")},children:"Cancel"})]}):(0,a.jsx)(te,{size:"sm",variant:"outline",className:o,disabled:n,onClick:()=>i(!0),children:t})}var ea={linear:{label:"Linear's signing secret",hint:"Linear shows it when you create the webhook."},sentry:{label:"Sentry's Client Secret",hint:"In Sentry: Settings → Developer Settings → your Internal Integration → Client Secret."},vercel:{label:"Vercel's webhook secret",hint:"Vercel shows it once when you create the webhook (an integration's webhooks use its Client Secret)."}},$0=[["none","Unsigned (the address alone)"],["standard","Standard Webhooks"],["github-style","GitHub-style signature"],["sentry","Sentry"],["vercel","Vercel"]];function E0({trigger:e,view:t,csrf:n,apply:o,onReveal:r}){let s=e.hook,i=s.sender??"none",[l,h]=(0,D.useState)(i),[u,c]=(0,D.useState)(""),[p,d]=(0,D.useState)(s.scope?.project??""),[m,f]=(0,D.useState)(s.scope?.team??""),[w,y]=(0,D.useState)(""),[x,E]=(0,D.useState)(!1),v=async(M,C)=>{E(!0);let _=await me(`${t.flow.href}/triggers/${e.id}/${M}`,{...C,password:w},n);E(!1),o(_),_.ok&&(y(""),c("")),_.reveal!==void 0&&r(_.reveal)},b=l!==i,j=ea[i],S=xt(t,w);return(0,a.jsxs)("details",{className:"mt-2 rounded-md border px-2 py-1.5",open:!s.ready||s.warning!==null||void 0,"data-trigger-signing":i,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Signing",s.ready&&i!=="none"?"":" · needs you"]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[s.warning!==null&&(0,a.jsx)("p",{className:xe("text-caption font-normal",i==="none"||!s.ready?"text-foreground":"text-muted-foreground"),"data-trigger-signing-warning":!0,children:s.warning}),s.readerNote!==null&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal","data-trigger-reader-note":!0,children:s.readerNote}),(0,a.jsx)(Y,{label:"Signed by",hint:"Who signs this webhook's deliveries. Changing it keeps the address and drops the secret: it then needs one again.",children:(0,a.jsx)("select",{className:Dl,value:l,onChange:M=>h(M.target.value),"data-trigger-sender":!0,children:$0.map(([M,C])=>(0,a.jsx)("option",{value:M,children:C},M))})}),!b&&s.scope!==null&&(0,a.jsx)(Y,{label:i==="vercel"?"Vercel project ID":"Sentry project",hint:i==="vercel"?"Only this project's deployments add cards (prj_…, from the project's Settings). Blank takes any project the secret covers.":"Only this project's issues add cards (its slug or number). Blank takes any project the integration sees.",children:(0,a.jsx)(ne,{value:p,onChange:M=>d(M.target.value),"data-trigger-project":!0})}),!b&&i==="vercel"&&(0,a.jsx)(Y,{label:"Vercel team ID",hint:"Only deliveries from this team (team_…). Blank takes any.",children:(0,a.jsx)(ne,{value:m,onChange:M=>f(M.target.value),"data-trigger-team":!0})}),!b&&j!==void 0&&(0,a.jsx)(Y,{label:s.ready?`Replace ${j.label}`:j.label,hint:j.hint,children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:u,onChange:M=>c(M.target.value),"data-trigger-secret":!0})}),(0,a.jsx)(It,{view:t,password:w,setPassword:y}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[b&&(0,a.jsx)(te,{type:"button",size:"sm",disabled:x||!S,onClick:()=>{v("sender",{sender:l})},children:"Change who signs it"}),!b&&s.makesSecret&&(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",disabled:x||!S,onClick:()=>{v("setup",{})},"data-trigger-setup":!0,children:s.ready?"Replace secret":"Set up"}),!b&&j!==void 0&&(0,a.jsx)(te,{type:"button",size:"sm",disabled:x||!S||u.trim()==="",onClick:()=>{v("secret",{secret:u})},children:s.ready?"Replace secret":"Save secret"}),!b&&s.scope!==null&&(p.trim()!==(s.scope.project??"")||m.trim()!==(s.scope.team??""))&&(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",disabled:x||!S,onClick:()=>{v("scope",{project:p,team:m})},"data-trigger-save-scope":!0,children:"Save project"})]})]})]})}function M0({trigger:e,view:t,csrf:n,apply:o}){let r=ea[e.hook?.sender??e.kind]??ea.linear,[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(""),[u,c]=(0,D.useState)(!1);return(0,a.jsxs)("form",{className:"mt-2 flex flex-col gap-2 rounded-md border border-attention/50 p-2",onSubmit:async p=>{p.preventDefault(),c(!0);let d=await me(`${t.flow.href}/triggers/${e.id}/secret`,{secret:s,password:l},n);c(!1),o(d),d.ok&&(i(""),h(""))},children:[(0,a.jsx)(Y,{label:r.label,hint:r.hint,children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:s,onChange:p=>i(p.target.value)})}),(0,a.jsx)(It,{view:t,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:u||s.trim()===""||!xt(t,l),children:"Save secret"})]})}function Na({view:e,label:t,busyLabel:n,terms:o,text:r,docked:s,check:i,act:l}){let h=(0,D.useContext)(jt),[u,c]=(0,D.useState)(!1),[p,d]=(0,D.useState)(null);return e.stepUp!==void 0?xt(e,"")?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(he,{variant:"primary",label:t,docked:s===!0,busy:u?n:!1,"data-sso-step-up":"confirmed",onClick:async()=>{if(!(u||i!==void 0&&!i())){c(!0),d(null);try{d(await l(""))}finally{c(!1)}}}}),p!==null&&(0,a.jsx)(Sn,{children:p})]}):(0,a.jsx)(cr,{variant:"primary",href:e.stepUp.confirmHref,label:`Confirm with ${e.stepUp.label}`,"data-sso-step-up":"confirm"}):(0,a.jsx)(sr,{kind:"step-up",facts:{passwordless:h,remembered:!1},label:t,terms:o,...r===void 0?{}:{text:r},...s?{docked:!0}:{},...i===void 0?{}:{check:i},onApprove:m=>l(m??"")})}function z0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(!1),s=e.unattended.active,i=e.unattended.ended??null;return s!==null?(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-unattended":"on",children:[(0,a.jsxs)("span",{title:`Ends ${s.untilWords} · covers ${s.covers.join("; ")}`,children:["Runs on its own until ",Cs(s.until)]}),e.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Revoke",busy:o?"Revoking…":!1,"data-flow-unattended-revoke":!0,onClick:async()=>{o||(r(!0),n(await me(`${e.flow.href}/unattended-off`,{},t)),r(!1))}})]}):i!==null?(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-unattended-ended":!0,children:["No longer runs on its own: ",i.why," (",Cs(i.at),"), so steps wait for you again"]}):null}function _0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(!1),s=e.browser;return s==null||s.status!=="allowed"?null:(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-browser":"allowed",children:[(0,a.jsx)("span",{children:s.words}),e.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Turn off",busy:o?"Turning off…":!1,"data-flow-browser-off":!0,onClick:async()=>{o||(r(!0),n(await me(`${e.flow.href}/browser-off`,{},t)),r(!1))}})]})}function P0(e){let t=e!=null&&e.status!=="allowed"?e:null,n=(0,D.useRef)(t),[,o]=(0,D.useState)(0);t===null?n.current=null:n.current===null&&(n.current=t);let r=(0,D.useCallback)(()=>{n.current=t,o(i=>i+1)},[t]),s=n.current;return{frozen:s,moved:s!==null&&t!==null&&s.digest!==t.digest,reread:r}}function A0({view:e,csrf:t,apply:n,phone:o,frozen:r,moved:s,reread:i}){let l=e.browser;if(l==null||l.status==="allowed"||r===null)return null;let h=l.status==="ended",u=r.zones[0]?.title??e.stages.find(m=>m.kind==="check"&&m.browser===!0)?.title??"A step",c=l.words.replace(/^Browser approval ended: /,""),p=e.canEdit&&l.canApprove!==!1,d=p&&l.problem===null&&r.digest!==null&&!s?(0,a.jsx)(Na,{view:e,label:"Allow browser",busyLabel:"Allowing…",docked:o,terms:`${e.flow.name} · ${r.zones.map(m=>`${m.title} runs ${m.script} v${m.version}`).join("; ")} · digest ${r.digest.slice(0,12)}`,act:async m=>{let f=await me(`${e.flow.href}/browser`,{digest:r.digest,password:m},t);return f.ok?(n(f),null):f.said}}):null;return(0,a.jsxs)("div",{className:"fl-browser",id:"fl-browser","data-flow-browser-panel":!0,"data-flow-browser":l.status,children:[(0,a.jsx)(rr,{wait:!0,status:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Tt,{word:"Needs you",tone:"needs"}),(0,a.jsx)("h2",{children:h?"Browser approval expired":`Allow browser for ${u}?`})]}),text:(0,a.jsxs)(a.Fragment,{children:[h?`It ended because ${c}. The next run waits at ${u} until someone allows it again.`:`${u} starts a browser. The next run waits there until someone allows it.`,r.zones.length>0&&(0,a.jsx)("span",{className:"fl-zones","data-flow-browser-zones":!0,children:r.zones.map(m=>(0,a.jsxs)("span",{className:"fl-zone",children:[(0,a.jsx)("b",{children:m.title})," runs ",(0,a.jsx)("span",{className:"k-mono",children:m.script})," v",m.version,(0,a.jsx)("span",{className:"k-mono fl-dig",children:m.digest})]},m.zone))})]}),acts:s?(0,a.jsx)("span",{"data-flow-browser-moved":!0,children:(0,a.jsx)(he,{label:"Read the new terms",onClick:i})}):d,terms:p?l.problem!==null?l.problem:s?"This flow or its scripts changed while you were reading.":e.stepUp!==void 0?`Asks you to confirm with ${e.stepUp.label}.`:"Allowing it is a step-up: it asks for your password unless Passwordless is on.":"Only an approver with access to every project can allow browser use."}),r.terms.length>0&&(0,a.jsx)(mr,{summary:"What else allowing means",children:(0,a.jsxs)("div",{className:"fl-terms","data-flow-browser-terms":!0,children:[(0,a.jsx)("ul",{children:["Each run of these steps starts a headless Chromium.",...r.terms].map((m,f)=>(0,a.jsx)("li",{children:m},f))}),(0,a.jsxs)("p",{className:"k-note",children:["Approval digest ",(0,a.jsx)("span",{className:"k-mono",children:r.digest})]})]})})]})}function _s(e,t){let n=Bg(t.budget),o=Vg(t.runs),r={...n.ok?{}:{budget:n.message},...o.ok?{}:{runs:o.message}};if(!n.ok||!o.ok)return{errors:r,snapshot:null};let s=Math.min(e.unattended.maxDays,Math.max(1,Math.round(Number(t.days))||1)),i=new Set(e.unattended.schedules.filter(u=>u.optional!==null).map(u=>u.id)),l=t.include.filter(u=>i.has(u)),h=e.unattended.schedules.filter(u=>u.optional===null||l.includes(u.id)).map(u=>({id:u.id,words:u.words}));return{errors:r,snapshot:{days:s,budgetMicrousd:n.value,dailyRunCap:o.value,include:l,covered:h,schedulesDigest:e.unattended.schedulesDigest,revision:e.flow.revision}}}var I0=(e,t)=>[...e.unattended.terms.head,...t.covered.length===0?[]:[Hg(t.covered)],...$l(t.budgetMicrousd,t.dailyRunCap),...e.unattended.terms.rules,Fg(t.days)];function D0({view:e,csrf:t,apply:n,onSigned:o}){let r=(0,D.useContext)(jt),[s,i]=(0,D.useState)({days:"1",budget:"",runs:"",include:[]}),[l,h]=(0,D.useState)(null),[u,c]=(0,D.useState)(null),p=_s(e,s),d=(0,D.useRef)(p.snapshot);p.snapshot!==null&&(d.current=p.snapshot);let m=p.snapshot??d.current,f=(0,D.useRef)(null),w=(0,D.useRef)(null),y=(0,D.useRef)(null);if(!e.unattended.canSign)return(0,a.jsx)("div",{"data-flow-unattended-panel":!0,children:(0,a.jsx)("p",{className:"k-note","data-flow-unattended-problem":!0,children:e.unattended.problem})});let x=b=>j=>{h(null),i(S=>({...S,[b]:j.target.value}))},E=()=>{let b=_s(e,s);return b.snapshot===null?((b.errors.budget!==void 0?w:y).current?.focus(),!1):b.snapshot.covered.length===0?(h("Pick a schedule above to sign."),!1):(f.current=b.snapshot,c(b.snapshot),!0)},v=e.unattended.schedules.filter(b=>b.optional!==null);return(0,a.jsxs)("div",{className:"fl-form","data-flow-unattended-panel":!0,children:[(0,a.jsx)("p",{className:"k-note",children:"While it runs on its own, cards its schedule adds move past steps that would wait for you, within the limits you set here. It never merges or ships anything."}),(0,a.jsx)(bn,{label:"Lasts",children:b=>(0,a.jsx)(wn,{id:b.id,value:s.days,onChange:x("days"),"data-flow-unattended-days":!0,wide:!0,items:Array.from({length:e.unattended.maxDays},(j,S)=>[String(S+1),`${S+1} day${S===0?"":"s"}`])})}),(0,a.jsxs)("div",{className:"fl-two",children:[(0,a.jsx)(bn,{label:"Budget per attempt ($)",error:p.errors.budget??null,children:b=>(0,a.jsx)(jn,{ref:w,id:b.id,inputMode:"decimal",placeholder:"No cap",value:s.budget,onChange:x("budget"),"aria-invalid":b.invalid||void 0,"aria-describedby":b.describedBy,"data-flow-unattended-budget":!0})}),(0,a.jsx)(bn,{label:"Runs a day",error:p.errors.runs??null,children:b=>(0,a.jsx)(jn,{ref:y,id:b.id,inputMode:"numeric",placeholder:"No limit",value:s.runs,onChange:x("runs"),"aria-invalid":b.invalid||void 0,"aria-describedby":b.describedBy,"data-flow-unattended-runs":!0})})]}),v.length>0&&(0,a.jsxs)("fieldset",{className:"fl-checks","data-flow-unattended-schedules":!0,children:[(0,a.jsx)("legend",{children:"Also cover"}),v.map(b=>(0,a.jsxs)("label",{className:"fl-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:s.include.includes(b.id),onChange:j=>{h(null),i(S=>({...S,include:j.target.checked?[...S.include,b.id]:S.include.filter(M=>M!==b.id)}))}}),(0,a.jsxs)("span",{children:[b.words,(0,a.jsx)("span",{className:"k-note",children:b.optional})]})]},b.id))]}),m!==null&&(0,a.jsxs)("div",{className:"fl-signs","data-flow-unattended-terms":!0,children:[(0,a.jsx)("b",{children:e.stepUp===void 0&&!r?"Your password signs exactly this":"Signing covers exactly this"}),(0,a.jsx)("ul",{"aria-live":"polite",children:I0(e,m).map((b,j)=>(0,a.jsx)("li",{children:b},j))})]}),l!==null&&(0,a.jsx)(Sn,{children:l}),(0,a.jsx)(kn,{children:(0,a.jsx)(Na,{view:e,label:"Sign",busyLabel:"Signing…",check:E,terms:u===null?"":`${e.flow.name} · ${u.days} day${u.days===1?"":"s"} · ${$l(u.budgetMicrousd,u.dailyRunCap).join(" ")}`,act:async b=>{let j=f.current;if(j===null)return"Read the terms again. Nothing was signed.";let S=await me(`${e.flow.href}/unattended`,{days:String(j.days),budget:j.budgetMicrousd===null?"":(j.budgetMicrousd/1e6).toFixed(2),runs:j.dailyRunCap===null?"":String(j.dailyRunCap),include:j.include.join(","),schedules:j.schedulesDigest,password:b,revision:String(j.revision)},t);return S.ok?(n(S),o(),null):S.said}})})]})}function R0({view:e,csrf:t,apply:n,focus:o,onPress:r}){let[s,i]=(0,D.useState)(null),[l,h]=(0,D.useState)(!1),u=`${e.flow.href}/triggers`,c=async(d,m,f={})=>{h(!0);let w=await me(d,f,t);return h(!1),n(w),w.reveal!==void 0&&i({kind:m,reveal:w.reveal}),w.ok},p=e.triggers.filter(d=>d.state!=="removed");return(0,D.useEffect)(()=>{o!==null&&document.querySelector(`[data-trigger-row="${o}"]`)?.scrollIntoView({block:"nearest"})},[o]),(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-triggers":!0,children:[(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["Triggers add cards to this flow on their own.",p.some(d=>d.order!==void 0)?"":" The work they start still waits for your usual approvals."]}),s!==null&&(0,a.jsx)(N0,{kind:s.kind,reveal:s.reveal,onDone:()=>i(null)}),p.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-3",children:p.map(d=>(0,a.jsxs)("li",{className:xe("rounded-lg border p-3",o===d.id&&"ring-2 ring-primary/50"),"data-trigger-row":d.id,children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:Ml[d.kind]??(0,a.jsx)(bo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"text-body leading-snug font-medium",children:d.words}),(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["Starts in ",d.zone,d.state==="paused"?" · Paused":"",d.shared?" · Shared as a form":""]}),d.status!==null&&(0,a.jsxs)("p",{className:xe("text-caption font-normal",d.failing?"text-foreground":"text-muted-foreground"),children:[Es(d.statusAt),": ",d.status,(0,a.jsx)(o0,{link:d.statusLink})]})]})]}),d.order!==void 0&&(0,a.jsx)("p",{className:"mt-2 text-caption break-words font-normal","data-trigger-approval":!0,children:d.order.at(-1)}),d.order!==void 0&&(0,a.jsxs)("details",{className:"mt-2 rounded-md border px-3 py-2","data-trigger-order":!0,children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:"What each run files"}),(0,a.jsx)("ul",{className:"mt-1 flex flex-col gap-1 text-caption text-muted-foreground font-normal",children:d.order.slice(0,-1).map((m,f)=>(0,a.jsx)("li",{className:"break-words",children:m},f))})]}),d.hook?.dropped!=null&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5 rounded-md border border-attention/50 p-2","data-trigger-dropped":!0,children:[(0,a.jsxs)("p",{className:"text-body font-medium",children:[d.hook.dropped.count===1?"1 delivery was":`${d.hook.dropped.count} deliveries were`," turned away since ",Es(d.hook.dropped.since),": too many were already waiting."]}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:d.hook.dropped.resend}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:l,onClick:()=>{c(`${u}/${d.id}/dropped`,d.kind)},children:"Clear"})]}),d.hook?.sender!=null&&(0,a.jsx)(E0,{trigger:d,view:e,csrf:t,apply:n,onReveal:m=>i({kind:d.hook?.sender??d.kind,reveal:m})}),d.hook?.sender==null&&d.hook?.needsSecret===!0&&!d.hook.ready&&(0,a.jsx)(M0,{trigger:d,view:e,csrf:t,apply:n}),(0,a.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.button!==null&&d.state==="active"&&(0,a.jsx)(te,{size:"sm",onClick:()=>r(d.id),children:"Start"}),d.button!==null&&(0,a.jsx)(zs,{view:e,busy:l,label:d.shared?"New form link":"Share as a form",onConfirm:m=>c(`${u}/${d.id}/share`,"form",{password:m})}),d.shared&&(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{c(`${u}/${d.id}/unshare`,"form")},children:"Stop sharing"}),d.checkable&&d.state==="active"&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:l,onClick:()=>{c(`${u}/${d.id}/check`,d.kind)},children:d.kind==="schedule"?"Run now":"Check now"}),d.hook!==null&&(0,a.jsx)(zs,{view:e,busy:l,label:"New address",onConfirm:m=>c(`${u}/${d.id}/renew`,d.kind,{password:m})}),(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{c(`${u}/${d.id}/${d.state==="paused"?"resume":"pause"}`,d.kind)},children:d.state==="paused"?"Turn on":"Pause"}),(0,a.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:l,onClick:()=>{c(`${u}/${d.id}/remove`,d.kind)},children:"Remove"})]})]},d.id))}),(0,a.jsx)(S0,{view:e,csrf:t,open:p.length===0,onResult:(d,m)=>{n(d),d.reveal!==void 0&&i({kind:m,reveal:d.reveal})}}),(0,a.jsx)(C0,{view:e,csrf:t,apply:n})]})}function O0({trigger:e,view:t,csrf:n,apply:o,onDone:r}){let s=e.button?.questions??[],[i,l]=(0,D.useState)(s.map(()=>"")),[h,u]=(0,D.useState)(!1),c=p=>d=>l(m=>m.map((f,w)=>w===p?d.target.value:f));return(0,a.jsxs)("form",{className:"flex flex-col gap-3","data-flow-press":e.id,onSubmit:async p=>{p.preventDefault(),u(!0);let d=await me(`${t.flow.href}/triggers/${e.id}/press`,{answers:JSON.stringify(i)},n);u(!1),o(d),d.ok&&r()},children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["The card starts in ",e.zone,"."]}),s.map((p,d)=>(0,a.jsx)(Y,{label:p,children:d===0?(0,a.jsx)(ne,{value:i[d]??"",onChange:c(d),maxLength:200,required:!0,autoFocus:!0}):(0,a.jsx)(ye,{rows:3,value:i[d]??"",onChange:c(d)})},d)),(0,a.jsx)(kn,{children:(0,a.jsx)(he,{type:"submit",variant:"primary",label:"Add card",busy:h?"Adding…":!1,disabled:(i[0]??"").trim()===""})})]})}function L0({view:e,csrf:t,apply:n}){let o={name:"",about:"",body:"",timeoutMinutes:"15",language:"python",file:""},[r,s]=(0,D.useState)(e.scripts.length===0?o:null),[i,l]=(0,D.useState)(!1),h=async()=>{if(r===null)return;l(!0);let d=await me(`${e.flow.href}/scripts`,r,t);l(!1),n(d),d.ok&&(s(null),p(!1))},u=d=>m=>s(f=>f===null?f:{...f,[d]:m.target.value}),[c,p]=(0,D.useState)(!1);return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-scripts":!0,children:[(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["Reusable steps with no AI, in shell, Python or Node. A “Run a script” zone runs one with the card, and a schedule can run one to make cards. Any flow in ",e.flow.project," can use them."]}),e.scripts.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:e.scripts.map(d=>(0,a.jsxs)("li",{className:"rounded-lg border p-3","data-script":d.name,children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,a.jsx)(jo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"flex flex-wrap items-center gap-1.5 font-mono text-body font-semibold",children:[d.name,d.held&&(0,a.jsx)(Mo,{tone:"attention",children:"Needs approval"})]}),(0,a.jsx)("p",{className:"text-[12.5px]",children:d.about}),(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[Ll[d.language],d.file===null?"":` · runs ${d.file}`," · version ",d.version," · ",d.savedBy," · up to ",d.timeoutMinutes," min",d.usedHere.length>0?` · runs in ${d.usedHere.join(", ")}`:" · not used in this flow"]})]})]}),d.file===null&&(0,a.jsxs)("details",{className:"mt-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-caption text-muted-foreground font-normal",children:"Show the script"}),(0,a.jsx)("pre",{className:"mt-2 max-h-56 overflow-auto rounded-md bg-muted p-2 font-mono text-mono",children:d.body})]}),d.held&&(0,a.jsx)("p",{className:"mt-2 text-[12.5px]","data-script-held":!0,children:"It came with an imported flow, so it doesn't run until you approve it. Read it first."}),e.canEdit&&(0,a.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[d.held&&(0,a.jsx)(te,{size:"sm",disabled:i,onClick:async()=>{l(!0),n(await me(`${e.flow.href}/scripts`,{approve:"yes",name:d.name,version:String(d.version),digest:d.digest},t)),l(!1)},"data-approve-script":!0,children:"Approve"}),(0,a.jsx)(te,{size:"sm",variant:"outline",onClick:()=>{p(d.file!==null),s({name:d.name,about:d.about,body:d.body,timeoutMinutes:String(d.timeoutMinutes),language:d.language,file:d.file??""})},children:"Edit"}),(0,a.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:i,onClick:async()=>{l(!0),n(await me(`${e.flow.href}/scripts`,{remove:"yes",name:d.name},t)),l(!1)},children:"Remove"})]})]},d.name))}),e.canEdit&&(r===null?(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>{p(!1),s(o)},children:[(0,a.jsx)(Qe,{className:"size-4"}),"New script"]}):(0,a.jsxs)("form",{className:"flex flex-col gap-3 rounded-lg border p-3",onSubmit:d=>{d.preventDefault(),h()},"data-script-form":!0,children:[(0,a.jsx)(Y,{label:"Name",hint:"Lowercase and dashes, like run-tests. Saving under an existing name makes a new version.",children:(0,a.jsx)(ne,{value:r.name,onChange:u("name"),maxLength:40,className:"font-mono",required:!0})}),(0,a.jsx)(Y,{label:"What it checks or does",children:(0,a.jsx)(ne,{value:r.about,onChange:u("about"),maxLength:160,placeholder:"Looks the company up in our CRM",required:!0})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(Y,{label:"Language",children:(0,a.jsxs)("select",{className:ue,value:r.language,onChange:u("language"),"aria-label":"Language",children:[(0,a.jsx)("option",{value:"python",children:"Python"}),(0,a.jsx)("option",{value:"node",children:"Node"}),(0,a.jsx)("option",{value:"shell",children:"Shell"})]})}),(0,a.jsx)(Y,{label:"Runs",children:(0,a.jsxs)("select",{className:ue,value:r.file===""&&!c?"here":"file",onChange:d=>{p(d.target.value==="file"),s(m=>m===null?m:{...m,file:d.target.value==="file"?m.file:""})},"aria-label":"Runs",children:[(0,a.jsx)("option",{value:"here",children:"What's written here"}),(0,a.jsx)("option",{value:"file",children:"A file in the project"})]})})]}),c||r.file!==""?(0,a.jsx)(Y,{label:"File",hint:"A path from the top of the project. It gets the card as JSON on stdin (and in $FLOW_INPUT); what it prints is the step's result.",children:(0,a.jsx)(ne,{value:r.file,onChange:u("file"),maxLength:200,className:"font-mono",placeholder:"scripts/enrich.py",required:!0})}):(0,a.jsx)(Y,{label:"Script",hint:"It gets the card as JSON on stdin (and in $FLOW_INPUT). What it prints is the step's result; a last line “goto: <answer>” picks the next zone. Exit 0 passes.",children:(0,a.jsx)(ye,{value:r.body,onChange:u("body"),rows:8,className:"font-mono text-[12.5px]",placeholder:g0[r.language]??"",required:!0})}),(0,a.jsx)(Y,{label:"Stop it after (minutes)",children:(0,a.jsx)(ne,{type:"number",min:1,max:60,value:r.timeoutMinutes,onChange:u("timeoutMinutes"),className:"w-28"})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(te,{type:"submit",size:"sm",disabled:i,children:"Save script"}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"ghost",onClick:()=>s(null),children:"Cancel"})]})]}))]})}var T0=e=>e===null?"—":e<1?"under a minute":e<90?`${Math.round(e)} min`:e<2880?`${Math.round(e/60)} h`:`${Math.round(e/1440)} days`;function B0({view:e}){let[t,n]=(0,D.useState)(30),[o,r]=(0,D.useState)(null),[s,i]=(0,D.useState)(null),[l,h]=(0,D.useState)(null);(0,D.useEffect)(()=>{let c=!0;return r(null),i(null),fetch(`${e.flow.href}/insights?days=${t}`,{credentials:"same-origin",headers:{accept:"application/json"}}).then(async p=>{if(c){if(!p.ok)throw new Error("load");r(await p.json())}}).catch(()=>{c&&i("The insights couldn't load. Try again.")}),()=>{c=!1}},[t,e.flow.href,e.flow.revision]);let u=async(c,p)=>{let d=`${c}:${p}`;if(l?.key===d){h(null);return}try{let m=await(await fetch(`${e.flow.href}/runs/${c}/${p}`,{credentials:"same-origin",headers:{accept:"application/json"}})).json();h({key:d,text:m.log===void 0||m.log===""?"This run left no output.":m.log})}catch{h({key:d,text:"The log couldn't load."})}};return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-insights":!0,children:[(0,a.jsxs)("div",{className:"fl-secthead",children:[(0,a.jsx)("h3",{children:"How it went"}),(0,a.jsx)(wn,{sm:!0,value:String(t),onChange:c=>n(Number(c.target.value)),"aria-label":"Period",items:[["7","Last 7 days"],["30","Last 30 days"],["90","Last 90 days"]]})]}),s!==null&&(0,a.jsx)("p",{className:"text-body text-destructive",children:s}),o===null&&s===null&&(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"Loading…"}),o!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-body",children:[o.cards.started," card",o.cards.started===1?"":"s"," started, ",o.cards.finished," finished, ",o.cards.active," in progress."]}),(0,a.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Where it breaks"}),o.breaks.length===0?(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Nothing failed or was sent back in this period."}):(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:o.breaks.map(c=>{let p=o.zones.find(d=>d.zone===c.zone);return(0,a.jsxs)("li",{className:"rounded-lg border border-border p-2.5 text-body",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-semibold",children:c.title}),": ",c.problems," of ",c.of," card",c.of===1?"":"s"," failed or were sent back"]}),p?.lastProblem&&(0,a.jsxs)("p",{className:"mt-0.5 text-caption text-muted-foreground font-normal",children:["Latest: ",p.lastProblem.cardTitle,p.lastProblem.note===null?"":` — ${p.lastProblem.note.split(`
|
|
17
|
-
`)[0]}`]})]},c.zone)})})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Zones"}),(0,a.jsxs)("table",{className:"w-full text-left text-caption font-normal",children:[(0,a.jsx)("thead",{className:"text-muted-foreground",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-1 font-medium",children:"Zone"}),(0,a.jsx)("th",{className:"font-medium",children:"In"}),(0,a.jsx)("th",{className:"font-medium",children:"On"}),(0,a.jsx)("th",{className:"font-medium",children:"Failed"}),(0,a.jsx)("th",{className:"font-medium",children:"Back"}),(0,a.jsx)("th",{className:"font-medium",children:"Typical stay"})]})}),(0,a.jsx)("tbody",{children:o.zones.map(c=>(0,a.jsxs)("tr",{className:"border-t",children:[(0,a.jsxs)("td",{className:"py-1.5 pr-2 font-medium",children:[c.title,c.here>0?(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" · ",c.here," here"]}):null]}),(0,a.jsx)("td",{children:c.entered}),(0,a.jsx)("td",{children:c.movedOn}),(0,a.jsx)("td",{className:c.failed>0?"font-semibold text-destructive":"",children:c.failed}),(0,a.jsx)("td",{className:c.sentBack>0?"font-semibold text-foreground":"",children:c.sentBack}),(0,a.jsx)("td",{children:T0(c.typicalMinutes)})]},c.zone))})]})]}),o.scripts.length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Scripts"}),(0,a.jsx)("ul",{className:"flex flex-col gap-1 text-[12.5px]",children:o.scripts.map(c=>(0,a.jsxs)("li",{children:[(0,a.jsx)("span",{className:"font-mono font-semibold",children:c.script}),": ",c.passed," of ",c.runs," passed",c.typicalSeconds===null?"":`, usually ${c.typicalSeconds<90?`${c.typicalSeconds} s`:`${Math.round(c.typicalSeconds/60)} min`}`]},c.script))})]}),o.sorts.length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-2","data-insights-sorts":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Sorting"}),o.sorts.map(c=>(0,a.jsxs)("div",{className:"rounded-lg border p-2.5 text-[12.5px]","data-insights-sort":c.zone,children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-semibold",children:c.title}),": ",c.sorted," sorted · ",c.alone," on its own · ",c.notSure," for a person",c.corrected>0&&(0,a.jsxs)(a.Fragment,{children:[" · ",(0,a.jsxs)("span",{className:"font-semibold text-attention",children:[c.corrected," moved elsewhere by people"]})]})]}),c.bands.some(p=>p.of>0)&&(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Right when ",c.bands.filter(p=>p.of>0).map(p=>`${p.from}–${p.to}% sure: ${p.right} of ${p.of}`).join(" · ")]}),c.costUsd>0&&(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Cost: ",c.costUsd<.01?"under 1¢":`$${c.costUsd.toFixed(2)}`]})]},c.zone))]}),(o.recurring??[]).length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-1.5","data-insights-recurring":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"What keeps coming back"}),(0,a.jsx)("ul",{className:"flex flex-col gap-1 text-[12.5px]",children:o.recurring.map(c=>(0,a.jsxs)("li",{className:"flex items-baseline gap-2",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c.card===null?c.title:(0,a.jsx)("a",{className:"underline-offset-2 hover:underline",href:`${e.flow.href}?card=${c.card}`,children:c.title})}),(0,a.jsxs)("span",{className:xe("shrink-0 tabular-nums",c.days>1?"font-semibold text-foreground":"text-muted-foreground"),children:[c.days," day",c.days===1?"":"s"]})]},c.problem))})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Recent runs"}),o.runs.length===0?(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"No scripts, sorts or updates have run in this period."}):(0,a.jsx)("ul",{className:"flex flex-col gap-1.5",children:o.runs.map(c=>{let p=`${c.card}:${c.entry}`;return(0,a.jsxs)("li",{className:"rounded-md border px-2.5 py-2 text-[12.5px]","data-run":p,children:[(0,a.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 text-left",onClick:()=>{u(c.card,c.entry)},"aria-expanded":l?.key===p,children:[(0,a.jsx)("span",{className:xe("mt-1 size-2 shrink-0 rounded-full",c.state==="passed"?"bg-success":c.state==="failed"?"bg-destructive":"bg-info"),"aria-hidden":"true"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"font-medium",children:c.script??c.zoneTitle})," · ",c.cardTitle,(0,a.jsxs)("span",{className:"block text-caption text-muted-foreground font-normal",children:[c.kind==="sort"&&c.state==="passed"&&c.result!==null?c.result.split(". ")[0].replace(/\.$/,""):c.state==="passed"?"Passed":c.state==="failed"?"Failed":c.state==="waiting"?"Trying again":"Running",c.durationMs===null?"":c.kind==="sort"?` · ${c.durationMs<1e3?`${c.durationMs} ms`:`${(c.durationMs/1e3).toFixed(1)} s`}`:` in ${Math.max(1,Math.round(c.durationMs/1e3))} s`," · ",an(c.at)]})]})]}),l?.key===p&&(0,a.jsx)("pre",{className:"mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-2 font-mono text-[11.5px]","data-run-log":!0,children:l.text})]},p)})})]})]})]})}var Ps="(max-width: 760px)";function V0(){let[e,t]=(0,D.useState)(()=>hr(Ps));return(0,D.useEffect)(()=>{let n=window.matchMedia(Ps),o=()=>t(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Gn={min:.4,max:2.5},ta=300;function H0(e,t,n){let o=0;return Pl(e,t).map(r=>{let s=Math.min(360,64+Math.max(1,n(r.id))*64),i={...r,zone:{...r.zone,x:0,y:o,w:ta,h:s}};return o+=s+64,i})}function F0({onExpand:e}){let t=Dt(),{zoom:n}=ug();return(0,a.jsxs)("div",{className:"fl-zoom nodrag nopan",role:"toolbar","aria-label":"Zoom",children:[(0,a.jsx)(he,{variant:"outline",sm:!0,iconOnly:"minus",label:"Zoom out (−)",onClick:()=>{t.zoomOut({duration:160})},disabled:n<=Gn.min+.001}),(0,a.jsxs)("span",{className:"fl-zoom-n k-num","aria-live":"polite",children:[Math.round(n*100),"%"]}),(0,a.jsx)(he,{variant:"outline",sm:!0,iconOnly:"plus",label:"Zoom in (+)",onClick:()=>{t.zoomIn({duration:160})},disabled:n>=Gn.max-.001}),(0,a.jsx)(he,{variant:"outline",sm:!0,lead:"fit",label:"Fit",title:"Fit (0)",onClick:()=>{t.fitView({padding:.12,maxZoom:1,duration:160})}}),e!==void 0&&(0,a.jsx)(he,{variant:"outline",sm:!0,label:"Expand","aria-label":"Expand the canvas to the full screen","data-flow-expand":!0,onClick:o=>e(o.currentTarget)})]})}function W0(e){let{view:t,editing:n,vertical:o,expanded:r}=e,s=Dt(),i=(0,D.useRef)(null),l=(0,D.useCallback)(g=>t.cards.filter(N=>N.stage===g&&N.state==="active"&&(!e.mineOnly||N.mine)).length,[t.cards,e.mineOnly]),h=(0,D.useMemo)(()=>o?H0(e.stages,e.start,l):e.stages,[o,e.stages,e.start,l]),u=e.start,c=(g,N)=>e.setDraft(k=>k===null?k:{...k,stages:k.stages.map(z=>z.id===g?{...z,...N}:z)}),p=(0,D.useMemo)(()=>h.map(g=>({id:g.id,type:"zone",position:{x:g.zone.x,y:g.zone.y},width:g.zone.w,height:g.zone.h,style:{width:g.zone.w,height:g.zone.h},draggable:n,selectable:n,data:{stage:g,kindLabel:t.kinds.find(N=>N.kind===g.kind)?.label??g.kind,owner:e.owner,subagent:g.subagent===void 0?null:t.subagents?.find(N=>N.handle===g.subagent)?.name??g.subagent,cards:t.cards.filter(N=>N.stage===g.id&&N.state==="active"&&(!e.mineOnly||N.mine)),hidden:e.mineOnly?t.cards.filter(N=>N.stage===g.id&&N.state==="active"&&!N.mine).length:0,lookers:e.lookers,editing:n,canMove:t.canEdit&&!o,start:g.id===u,selectedCard:e.selectedCard,onCard:e.onCard,onDrop:e.onDrop,onResize:(N,k)=>e.setDraft(z=>z===null?z:{...z,stages:z.stages.map(A=>A.id===N?{...A,zone:{...A.zone,x:Math.round(k.x),y:Math.round(k.y),w:Math.round(k.width),h:Math.round(k.height)}}:A)}),browserLine:g.kind==="check"&&g.browser===!0&&t.browser!=null&&t.browser.status!=="allowed"?"Starts a browser · not allowed":null}})),[h,t,n,u,e.mineOnly,e.lookers,e.selectedCard,e.owner,e.onCard,e.onDrop,e.setDraft,o]),d=(0,D.useMemo)(()=>t.triggers.filter(g=>g.state!=="removed"),[t.triggers]),m=(0,D.useMemo)(()=>{if(o)return[];let g=new Map;for(let N of d){let k=h.some(z=>z.id===N.zoneId)?N.zoneId:u;g.set(k,[...g.get(k)??[],N])}return[...g].flatMap(([N,k])=>{let z=h.find($=>$.id===N);if(z===void 0)return[];let A=_l+k.length*zl;return[{id:`trigger-${N}`,type:"trigger",position:{x:z.zone.x-272,y:z.zone.y+Math.max(0,(z.zone.h-A)/2)},width:236,height:A,style:{width:236,height:A},draggable:!1,selectable:!1,data:{triggers:k,onOpen:e.onTriggers,onPress:e.onPress}}]})},[d,h,u,o,e.onTriggers,e.onPress]),f=(0,D.useMemo)(()=>[...p,...m],[p,m]),[w,y]=(0,D.useState)(f);(0,D.useEffect)(()=>{y(g=>f.map(N=>{let k=g.find(z=>z.id===N.id);return k===void 0?N:{...k,...N,...k.measured===void 0?{}:{measured:k.measured},selected:n&&k.selected===!0}}))},[f,n]);let x=(0,D.useMemo)(()=>{let g=$=>({x:$.zone.x+$.zone.w/2,y:$.zone.y+$.zone.h/2}),N=($,B,V)=>{let W=g($),J=g(B),X=J.x-W.x,Z=J.y-W.y,ee=Math.abs(X)>=Math.abs(Z);if(V){let Q=B.zone.x>=$.zone.x+$.zone.w||$.zone.x>=B.zone.x+B.zone.w,T=B.zone.y>=$.zone.y+$.zone.h||$.zone.y>=B.zone.y+B.zone.h;return Q&&T?X>=0?{source:"s-Right",target:"t-Left"}:{source:"s-Left",target:"t-Right"}:ee?{source:"s-Bottom",target:"t-Bottom"}:{source:"s-Left",target:"t-Left"}}return ee?X>=0?{source:"s-Right",target:"t-Left"}:{source:"s-Left",target:"t-Right"}:Z>=0?{source:"s-Bottom",target:"t-Top"}:{source:"s-Top",target:"t-Bottom"}},k={labelStyle:{fontSize:11,fontWeight:600,fill:"var(--so-ink)"},labelBgStyle:{fill:"var(--so-paper)"}},z={labelStyle:{fontSize:11,fill:"var(--so-muted)"},labelBgStyle:{fill:"var(--so-paper)"}},A=m.map($=>({id:`${$.id}->zone`,source:$.id,sourceHandle:"out",target:$.id.slice(8),targetHandle:"t-Left",type:"smoothstep",deletable:!1,markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:1.5}}));return Qg([...A,...h.flatMap($=>{let B=$.next===null?void 0:h.find(Z=>Z.id===$.next),V=$.onFail===null?void 0:h.find(Z=>Z.id===$.onFail),W=$.limit?.to==null?void 0:h.find(Z=>Z.id===$.limit.to),J=$.kind==="sort"&&$.sort!==null?$.sort.answers:$.kind==="check"||$.kind==="subagent"?$.routes??[]:$.kind==="choose"?($.options??[]).filter(Z=>Z.to!=="end").map(Z=>({answer:Z.label,to:Z.to})):[],X=J.length>0?[...new Set(J.map(Z=>Z.to))].flatMap(Z=>{let ee=h.find(T=>T.id===Z);if(ee===void 0)return[];let Q=ee.zone.x>$.zone.x+$.zone.w?{source:"s-Right",target:"t-Left"}:N($,ee,!1);return[{id:`${$.id}->answer-${Z}`,source:$.id,target:Z,sourceHandle:Q.source,targetHandle:Q.target,type:"smoothstep",label:J.filter(T=>T.to===Z).map(T=>T.answer).join(", "),...k,markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:2},deletable:!1}]}):[];return[...X,...B===void 0?[]:[{id:`${$.id}->next`,source:$.id,target:B.id,sourceHandle:N($,B,!1).source,targetHandle:N($,B,!1).target,type:"smoothstep",markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:2},deletable:n,...$.kind==="wait"&&$.wait?.for==="reply"?{label:"replied",...k}:{}}],...V===void 0||!n&&X.some(Z=>Z.target===V.id)?[]:[{id:`${$.id}->fail`,source:$.id,target:V.id,sourceHandle:N($,V,!0).source,targetHandle:N($,V,!0).target,type:"smoothstep",pathOptions:{offset:28,borderRadius:10},label:$.kind==="approval"?"sent back":$.kind==="sort"?"not sure":$.kind==="wait"?"no reply":$.kind==="choose"?"reply":"fails",...z,markerEnd:{type:Xe.ArrowClosed,color:"var(--so-muted)"},style:{strokeWidth:1.5,strokeDasharray:"6 4",stroke:"var(--so-muted)"},deletable:n}],...W===void 0||$.limit===void 0?[]:[{id:`${$.id}->limit`,source:$.id,target:W.id,sourceHandle:N($,W,!0).source,targetHandle:N($,W,!0).target,type:"smoothstep",pathOptions:{offset:36,borderRadius:10},label:`after ${n0($.limit.minutes)}`,...z,markerEnd:{type:Xe.ArrowClosed,color:"var(--so-muted)"},style:{strokeWidth:1.5,strokeDasharray:"2 4",stroke:"var(--so-muted)"},deletable:n}]]})],h)},[h,n,m]),E=g=>{if(y(N=>Ki(g,N)),!!n)for(let N of g)N.type==="select"&&N.selected&&!N.id.startsWith("trigger-")&&e.onZone(N.id)},v=(g,N)=>{!n||N.type!=="zone"||e.setDraft(k=>k===null?k:{...k,stages:k.stages.map(z=>z.id===N.id?{...z,zone:{...z.zone,x:Math.round(N.position.x),y:Math.round(N.position.y)}}:z)})},b=g=>{if(!n||g.source===g.target)return;let N=h.find(k=>k.id===g.source);if(N?.kind==="sort"&&N.sort!==null&&g.sourceHandle!=="fail"){let k=h.find(z=>z.id===g.target);k!==void 0&&N.sort.answers.length<12&&c(N.id,{sort:{...N.sort,answers:[...N.sort.answers,{answer:k.title.slice(0,40),means:k.title,to:k.id}]}}),e.onZone(N.id);return}if(N?.kind==="choose"&&g.sourceHandle!=="fail"){let k=h.find(z=>z.id===g.target);k!==void 0&&(N.options??[]).length<4&&c(N.id,{options:[...N.options??[],{label:k.title.slice(0,40),to:k.id}]}),e.onZone(N.id);return}c(g.source,g.sourceHandle==="fail"?{onFail:g.target}:{next:g.target})},j=(0,D.useRef)(null),S=o?"v":"d";(0,D.useEffect)(()=>{if(j.current===S)return;j.current=S;let g=requestAnimationFrame(()=>{if(!o){s.fitView({padding:.12,maxZoom:1});return}let N=i.current?.querySelector(".fl-vp")?.clientWidth??360;s.setViewport({x:Math.max(8,(N-ta)/2),y:16,zoom:1})});return()=>cancelAnimationFrame(g)},[S,o,s]);let M=(0,D.useRef)(e.onCollapse);M.current=e.onCollapse;let C=e.covered===!0,_=(0,D.useRef)(!1);(0,D.useLayoutEffect)(()=>{let g=i.current;if(!r||C||g===null)return;let N=!1,k=()=>{g.hidden=!1,g.removeAttribute("role"),g.removeAttribute("aria-modal"),g.removeAttribute("tabindex")},z=document.activeElement,A=nr(g,null,{dim:!1,onClose:$=>{N=!0,k(),$!=="close"&&M.current?.()}});return g.setAttribute("aria-label",`${e.name}, full screen`),_.current&&z instanceof HTMLElement&&g.contains(z)?z.focus({preventScroll:!0}):g.querySelector("[data-flow-collapse]")?.focus(),_.current=!0,()=>{N||A(),k(),g.removeAttribute("aria-label")}},[r,C,e.name]),(0,D.useEffect)(()=>{r||(_.current=!1)},[r]);let F=(0,D.useRef)(r);(0,D.useEffect)(()=>{if(!o||F.current===r)return;F.current=r;let g=window.setTimeout(()=>{let{y:N,zoom:k}=s.getViewport(),z=i.current?.querySelector(".fl-vp")?.clientWidth??360;s.setViewport({x:Math.max(8,(z-ta*k)/2),y:N,zoom:k})},60);return()=>window.clearTimeout(g)},[r,o,s]);let O=o?"":d.map(g=>`${g.id}:${g.zoneId}`).join(","),R=(0,D.useRef)(O);(0,D.useEffect)(()=>{if(R.current===O)return;R.current=O;let g=requestAnimationFrame(()=>{s.fitView({padding:.12,maxZoom:1,duration:160})});return()=>cancelAnimationFrame(g)},[O,s]);let H=g=>{if(g.target!==g.currentTarget)return;let N=48,{x:k,y:z,zoom:A}=s.getViewport();if(g.key==="+"||g.key==="=")s.zoomIn({duration:160});else if(g.key==="-"||g.key==="_")s.zoomOut({duration:160});else if(g.key==="0")s.fitView({padding:.12,maxZoom:1,duration:160});else if(g.key.startsWith("Arrow"))s.setViewport({x:k+(g.key==="ArrowLeft"?N:g.key==="ArrowRight"?-N:0),y:z+(g.key==="ArrowUp"?N:g.key==="ArrowDown"?-N:0),zoom:A});else return;g.preventDefault()};return(0,a.jsxs)("div",{ref:i,className:xe("fl-canvas",o&&"column",r&&"expanded",r&&C&&"covered",n&&"editing"),"data-flow-canvas":!0,children:[r&&(0,a.jsxs)("div",{className:"fl-xbar",children:[(0,a.jsx)("b",{children:e.name}),(0,a.jsx)("span",{className:"k-note",children:"Drag to move · pinch to zoom"}),(0,a.jsx)("span",{className:"k-grow"}),(0,a.jsx)(he,{variant:"primary",label:"Done","data-flow-collapse":!0,onClick:()=>e.onCollapse?.()})]}),(0,a.jsxs)("div",{className:"fl-vp",tabIndex:0,role:"group","aria-roledescription":"canvas",onKeyDown:H,"aria-label":`${e.name}: its zones and cards. Drag to move, pinch or press + and − to zoom, 0 to fit.`,children:[(0,a.jsx)(ig,{nodes:w,edges:x,nodeTypes:Ug,edgeTypes:Jg,onNodesChange:E,onNodeDragStop:v,onConnect:b,onEdgesDelete:g=>{for(let N of g)c(N.source,N.id.endsWith("->fail")?{onFail:null}:N.id.endsWith("->limit")?{limit:{...h.find(k=>k.id===N.source)?.limit??{minutes:1440},to:null}}:{next:null})},onPaneClick:()=>{n&&e.onZone(null)},onNodeClick:()=>{},fitView:!0,fitViewOptions:{padding:.14,maxZoom:1},nodesDraggable:n,nodesConnectable:n,elementsSelectable:n,minZoom:Gn.min,maxZoom:Gn.max,zoomOnScroll:!1,zoomActivationKeyCode:["Meta","Control"],zoomOnPinch:!0,zoomOnDoubleClick:!n,panOnDrag:!0,preventScrolling:!1,proOptions:{hideAttribution:!0},deleteKeyCode:n?["Backspace","Delete"]:null,children:(0,a.jsx)(gg,{variant:Ue.Dots,gap:20,size:1,color:"var(--so-line)"})}),(0,a.jsx)(F0,{...o&&!r&&e.onExpand!==void 0?{onExpand:e.onExpand}:{}})]}),n&&(0,a.jsx)("p",{className:"fl-hint k-note",children:"Drag zones to arrange them. Drag from a zone's right dot to say where work goes next, from its bottom dot for where it goes if sent back."})]})}function Z0(e){return e.state==="done"?(0,a.jsx)(Eo,{status:"finished"}):e.state==="cancelled"?(0,a.jsx)(Tt,{word:e.waiting==="Ignored"?"Ignored":"Cancelled",dot:!1}):e.canDecide||e.question?.mine===!0||e.choose?.mine===!0?(0,a.jsx)(Tt,{word:"Needs you",tone:"needs"}):e.waiting!==null?(0,a.jsx)(Tt,{word:"Waiting",dot:!1}):(0,a.jsx)(Eo,{status:"running"})}var Ye=e=>e.state==="active"&&(e.canDecide||e.question?.mine===!0||e.choose?.mine===!0),Y0=600,X0=e=>e===null?"":`${e.label}\0${JSON.stringify(e.data??{})}`;function q0(e,t=Y0){let n=X0(e),[o,r]=(0,D.useState)(n),s=(0,D.useRef)(e),i=n===o||o==="";i&&(s.current=e),(0,D.useEffect)(()=>{if(n===o)return;let d=setTimeout(()=>r(n),o===""?0:t);return()=>clearTimeout(d)},[n,o,t]);let l=i?e:s.current,h=(0,D.useRef)(null),u=()=>{h.current=l},c=d=>{let m=d.detail>0&&h.current!==null?h.current:l;h.current=null,m?.act(d.currentTarget)},p=i||e===null?"":`${e.label} is next.`;return{shown:l,onPointerDown:u,run:c,said:p}}function Vo({outcome:e}){return e===null?null:e.ok?(0,a.jsx)("p",{className:"k-note fl-outcome",role:"status","data-flow-outcome":!0,children:e.said}):(0,a.jsx)(Sn,{children:e.said})}function Yy({view:e,csrf:t}){let n=V0(),[o,r]=(0,D.useState)(e),[s,i]=(0,D.useState)(null),l=(0,D.useCallback)(P=>{i({ok:P.ok,said:P.said}),P.view!==void 0&&r(P.view)},[]),[h,u]=(0,D.useState)(()=>e.selectedCard!==null?{open:{card:e.selectedCard},from:null}:e.startTrigger!==null&&e.triggers.some(P=>P.id===e.startTrigger&&P.button!==null)?{open:{press:e.startTrigger},from:null}:null),c=(0,D.useCallback)((P,G)=>{i(null),u({open:P,from:G})},[]),p=(0,D.useCallback)(()=>u(null),[]),[d,m]=(0,D.useState)("steps"),[f,w]=(0,D.useState)("list"),[y,x]=(0,D.useState)(!1),E=(0,D.useRef)(null),[v,b]=(0,D.useState)(!1),[j,S]=(0,D.useState)(null),[M,C]=(0,D.useState)(null),[_,F]=(0,D.useState)(!1),[O,R]=xr(()=>!1,()=>{try{return window.localStorage.getItem("so-flows-mine")==="1"}catch{return!1}});(0,D.useEffect)(()=>{try{window.localStorage.setItem("so-flows-mine",O?"1":"0")}catch{}},[O]);let H=ar(),g=P0(o.browser),N=h!==null&&"card"in h.open?h.open.card:null,k=Yg(o,r,{card:N,editing:v}),z=(0,D.useMemo)(()=>{let P={};for(let G of k)if(!G.editing)for(let ae of G.cards)(P[ae]??=[]).push(G.name);return P},[k]),A=(0,D.useCallback)(async(P,G)=>{let ae=o.cards.find(ze=>ze.id===P);ae===void 0||ae.stage===G||l(await me(`${o.flow.href}/cards/${P}/move`,{stage:G},t))},[o,t,l]),$=(0,D.useCallback)((P,G)=>c({card:P},G),[c]),B=(0,D.useCallback)((P,G)=>c({triggers:P},G),[c]),V=(0,D.useCallback)((P,G)=>c({press:P},G),[c]),W=(0,D.useCallback)(P=>S(P),[]);(0,D.useEffect)(()=>{e.browser!=null&&Zg()&&document.getElementById("fl-browser")?.scrollIntoView({block:"center"})},[e.browser]),(0,D.useEffect)(()=>(document.documentElement.classList.toggle("fl-locked",y),()=>document.documentElement.classList.remove("fl-locked")),[y]),(0,D.useEffect)(()=>{n||x(!1)},[n]);let J=(0,D.useCallback)(()=>x(!1),[]),X=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(y){X.current=!0;return}X.current&&(X.current=!1,document.querySelector("[data-flow-expand]")?.focus({preventScroll:!0}))},[y]);let Z=o.triggers.filter(P=>P.state!=="removed"),ee=j?.stages??o.stages,Q=j?.start??o.start,T=j!==null&&JSON.stringify({name:j.name,start:j.start,stages:j.stages,owner:j.owner})!==JSON.stringify({name:o.flow.name,start:o.start,stages:o.stages,owner:o.flow.owner}),K=()=>{S({name:o.flow.name,start:o.start,stages:o.stages,owner:o.flow.owner}),b(!0),C(null),p(),m("steps")},oe=()=>{S(null),b(!1),C(null)},ie=async()=>{if(j===null||_)return;F(!0);let P=await me(`${o.flow.href}/save`,{name:j.name,owner:j.owner,revision:String(o.flow.revision),definition:JSON.stringify({version:1,start:j.start,stages:j.stages})},t);F(!1),l(P),P.ok&&oe()},q=(0,D.useRef)(null),se=()=>{if(j===null)return;let P=new Set(j.stages.map(ze=>ze.id)),G=q.current?.center()??{x:0,y:0},ae={id:e0("New zone",P),title:"New zone",kind:"inbox",zone:{x:Math.round(G.x-140),y:Math.round(G.y-120),w:280,h:300,color:"slate"},instructions:null,planning:null,approver:null,message:null,close:null,script:null,sort:null,next:null,onFail:null};S({...j,stages:[...j.stages,ae]}),C(ae.id)},re=(P,G)=>S(ae=>ae===null?ae:{...ae,stages:ae.stages.map(ze=>ze.id===P?{...ze,...G}:ze)}),le=o.cards.filter(P=>P.state==="active"),ce=le.filter(Ye),ge=[...o.cards].sort((P,G)=>Date.parse(G.updatedAt)-Date.parse(P.updatedAt))[0],je=P=>o.stages.find(G=>G.id===P)?.title??P,Ee=ce.length>0?ce.length===1?`A card waits for you in ${je(ce[0].stage)}`:`${ce.length} cards wait for you`:le.length>0?`${le.length} card${le.length===1?"":"s"} in progress`:o.cards.length>0?"Nothing in progress":"No cards yet",Me=o.browser!=null&&o.browser.status!=="allowed",be=Z.find(P=>P.button!==null&&P.state==="active"),Pe=Z.find(P=>P.kind==="schedule"&&P.checkable&&P.state==="active"),[Be,Ve]=(0,D.useState)(!1),Se=async()=>{Pe===void 0||Be||(Ve(!0),l(await me(`${o.flow.href}/triggers/${Pe.id}/check`,{},t)),Ve(!1))},Ae=v?null:ce.length>0?{label:ce.length===1?"Review":`Review ${ce.length}`,act:P=>c({card:ce[0].id},P),data:{"data-flow-review":""}}:Me&&o.canEdit&&o.browser?.canApprove!==!1?null:be!==void 0?{label:be.button.label,act:P=>c({press:be.id},P),data:{"data-flow-press":String(be.id)}}:Pe!==void 0&&o.canEdit?{label:"Run now",busy:Be?"Starting…":!1,act:()=>{Se()},data:{"data-flow-run-now":""}}:o.canEdit?{label:"New card",act:P=>c({newCard:!0},P),data:{"data-flow-new-card":""}}:null,Ne=q0(Ae),we=Ne.shown,vt=P=>we===null?null:(0,a.jsx)(he,{variant:"primary",sm:P,label:we.label,busy:we.busy??!1,...we.data,...we.label==="New card"?{lead:"plus"}:{},onPointerDown:Ne.onPointerDown,onClick:G=>Ne.run(G)}),Rt=P=>H(P,n?o.flow.name:"More",[...n?[{label:"Triggers",act:()=>c({triggers:null},P)},{label:"Scripts",act:()=>c({scripts:!0},P)}]:[],...o.canEdit&&!n?[{label:"Edit flow",act:K}]:[],...o.canEdit&&we?.label!=="New card"?[{label:"New card",act:()=>c({newCard:!0},P)}]:[],...o.canEdit&&o.unattended.scheduled&&o.unattended.active===null?[{label:"Run on its own…",act:()=>c({unattended:!0},P)}]:[],...o.canEdit?[{label:"Change it in chat",act:()=>{window.location.assign(o.chatHref)}}]:[],{label:"Export as a file",act:()=>{window.location.assign(`${o.flow.href}/export`)}}]),pn=(0,a.jsx)(yn,{label:"View",current:d,onChange:P=>m(P),items:[{key:"steps",label:"Steps"},{key:"runs",label:"Runs",count:(0,a.jsx)(bt,{n:o.cards.length})}]}),mn=(P={})=>(0,a.jsx)(he,{variant:"ghost",iconOnly:"more",label:"More",sm:P.sm===!0,"aria-haspopup":"dialog","data-flow-menu":!0,onClick:G=>Rt(G.currentTarget)}),lo=v&&j!==null?(0,a.jsxs)("div",{className:"k-tb fl-edit-tb",children:[(0,a.jsx)(jn,{value:j.name,onChange:P=>S({...j,name:P.target.value}),maxLength:80,"aria-label":"Flow name",className:"fl-name"}),(0,a.jsxs)("label",{className:"fl-owner",children:[(0,a.jsx)("span",{className:"k-note",children:"Owner"}),(0,a.jsx)(wn,{sm:!0,value:j.owner,onChange:P=>S({...j,owner:P.target.value}),"aria-label":"Flow owner",items:[...new Set([j.owner,...o.approvers])].map(P=>[P,P===o.me?`${P} (you)`:P])})]}),(0,a.jsx)("span",{className:"k-grow"}),(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"code",label:"Scripts",onClick:P=>c({scripts:!0},P.currentTarget)}),(0,a.jsx)(he,{sm:!0,lead:"plus",label:"Add zone",onClick:se}),(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Discard",onClick:oe}),(0,a.jsx)(he,{variant:"primary",sm:!0,label:"Save flow",busy:_?"Saving…":!1,disabled:!T,onClick:()=>{ie()}})]}):(0,a.jsx)(gr,{title:o.flow.name,back:"/flows",ctx:o.flow.project,right:(0,a.jsxs)(a.Fragment,{children:[pn,o.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"bolt",label:Z.length>0?`Triggers · ${Z.length}`:"Triggers","data-open-triggers":!0,onClick:P=>c({triggers:null},P.currentTarget)}),(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"code",label:"Scripts","data-open-scripts":!0,onClick:P=>c({scripts:!0},P.currentTarget)}),mn({sm:!0}),vt(!0)]}),trailing:mn()}),co=ge===void 0?null:(0,a.jsxs)("p",{className:"fl-latest",children:[(0,a.jsx)("span",{className:xe("fl-dot",Ye(ge)?"wait":ge.state==="done"?"ok":ge.state==="active"&&ge.waiting===null?"run":"idle"),"aria-hidden":"true"}),(0,a.jsxs)("span",{children:[ge.title," · ",ge.state==="active"?`in ${je(ge.stage)}${ge.waiting!==null?`: ${ge.waiting}`:""}`:ge.state==="done"?"done":"cancelled"]}),(0,a.jsx)("span",{className:"fl-when k-num",children:an(ge.updatedAt)})]}),fn=Z.find(P=>P.state==="active")??Z[0],uo=(0,a.jsxs)("div",{className:"fl-head",children:[(0,a.jsx)("h2",{className:"fl-lead",children:Ee}),(0,a.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite","data-flow-primary-said":!0,children:Ne.said}),co,(0,a.jsxs)("p",{className:"fl-meta",children:[(0,a.jsx)("span",{className:"fl-meta-item",children:fn===void 0?"Cards are added by hand":fn.words}),(0,a.jsxs)("span",{className:"fl-meta-item",children:["owner ",o.flow.owner]}),(0,a.jsx)(z0,{view:o,csrf:t,apply:l}),(0,a.jsx)(_0,{view:o,csrf:t,apply:l}),(0,a.jsx)(Xg,{others:k,cards:o.cards})]}),h===null&&(0,a.jsx)(Vo,{outcome:s})]}),Je=[...o.cards].sort((P,G)=>Number(Ye(G))-Number(Ye(P))||Date.parse(G.updatedAt)-Date.parse(P.updatedAt)),gn=P=>(0,a.jsx)("div",{className:"fl-rowwrap","data-card-row":P.id,onClick:G=>{let ae=G.target.closest("a.k-row-t");ae!==null&&(G.preventDefault(),c({card:P.id},ae))},children:(0,a.jsx)(fr,{href:`${o.flow.href}?card=${P.id}`,chip:Z0(P),title:P.title,wait:Ye(P),desc:P.state==="active"?`In ${je(P.stage)}${P.waiting!==null?` · ${P.waiting}`:""}`:P.history.at(-1)?.text??(P.state==="done"?"Finished":"Cancelled"),meta:(0,a.jsx)("span",{className:"k-num",children:an(P.updatedAt)}),action:Ye(P)?(0,a.jsx)(he,{sm:!0,label:"Review",onClick:G=>c({card:P.id},G.currentTarget)}):void 0})},P.id),ho=Je.length===0?null:(0,a.jsxs)("div",{className:"fl-recent","aria-label":"Recent runs",children:[(0,a.jsx)(zo,{label:"Recent runs",count:(0,a.jsx)(bt,{n:Je.length})}),Je.slice(0,3).map(gn),Je.length>3&&(0,a.jsx)("p",{className:"fl-more-runs",children:(0,a.jsx)(he,{variant:"ghost",sm:!0,label:`See all ${Je.length} runs`,onClick:()=>m("runs")})})]}),po=(0,a.jsx)("div",{className:"fl-list","data-flow-list":!0,children:Pl(o.stages,o.start).map(P=>{let G=o.cards.filter(ae=>ae.stage===P.id&&ae.state==="active");return(0,a.jsxs)("section",{className:"fl-step","data-step":P.id,"aria-label":P.title,children:[(0,a.jsxs)("header",{className:"fl-step-h",children:[(0,a.jsx)("span",{className:"fl-ico",style:{color:At[P.zone.color]??At.slate},children:El[P.kind]}),(0,a.jsxs)("span",{className:"fl-step-t",children:[(0,a.jsx)("b",{children:P.title}),(0,a.jsxs)("span",{className:"k-note",children:[o.kinds.find(ae=>ae.kind===P.kind)?.label??P.kind,P.id===o.start?" · new cards start here":""]})]}),G.length>0&&(0,a.jsx)(bt,{n:G.length,ink:G.some(Ye)})]}),P.kind==="check"&&P.browser===!0&&Me&&(0,a.jsx)("p",{className:"fl-step-br k-note",children:"Starts a browser · not allowed"}),G.length>0&&(0,a.jsx)("ul",{className:"fl-cards",children:G.map(ae=>(0,a.jsx)("li",{children:(0,a.jsxs)("a",{href:`${o.flow.href}?card=${ae.id}`,className:xe("fl-card",Ye(ae)&&"wait"),"data-card":ae.id,onClick:ze=>{ze.preventDefault(),$(ae.id,ze.currentTarget)},children:[(0,a.jsx)("span",{className:"fl-card-t",children:ae.title}),ae.sorted!==null&&(0,a.jsx)("span",{className:"fl-card-l",children:(0,a.jsx)(wa,{sorted:ae.sorted})}),ae.waiting!==null&&(0,a.jsx)("span",{className:xe("fl-card-l",Ye(ae)&&"mine"),children:ae.canDecide?xn.card.sentence({}):ae.question?.mine?`${ae.question.from.split(" · ")[0]} asks you`:ae.waiting})]})},ae.id))})]},P.id)})}),mo=(0,a.jsx)(W0,{view:o,stages:ee,start:Q,owner:j?.owner??o.flow.owner,editing:v,vertical:n,expanded:y,mineOnly:O,selectedCard:N,lookers:z,onCard:$,onDrop:(P,G)=>{A(P,G)},onTriggers:B,onPress:V,onZone:C,setDraft:W,name:o.flow.name,covered:h!==null,onExpand:P=>{E.current=P,x(!0)},onCollapse:J}),fo=o.cards.some(P=>P.state==="active"&&!P.mine),go=(0,a.jsxs)(a.Fragment,{children:[n&&(0,a.jsx)("div",{className:"fl-viewsw",children:(0,a.jsx)(yn,{label:"Layout",current:f,onChange:P=>{w(P),x(!1)},items:[{key:"list",label:"List"},{key:"canvas",label:"Canvas"}]})}),!n&&!v&&fo&&(0,a.jsx)("div",{className:"fl-filter",children:(0,a.jsx)(yn,{label:"Which cards",current:O?"mine":"all",onChange:P=>R(P==="mine"),items:[{key:"all",label:"All cards"},{key:"mine",label:"Mine"}]})}),(0,a.jsxs)("div",{className:xe("fl-stage",v&&M!==null&&"with-aside"),children:[n&&f==="list"?po:(0,a.jsxs)(jl,{children:[(0,a.jsx)(U0,{api:q}),mo]}),v&&M!==null&&j!==null&&(()=>{let P=j.stages.find(G=>G.id===M);return P===void 0?null:(0,a.jsx)("aside",{className:"fl-aside","data-flow-drawer":!0,children:(0,a.jsx)(y0,{stage:P,stages:j.stages,view:o,csrf:t,apply:l,update:G=>re(P.id,G),remove:()=>{S(G=>G===null?G:{...G,start:G.start===P.id?G.stages.find(ae=>ae.id!==P.id).id:G.start,stages:G.stages.filter(ae=>ae.id!==P.id).map(ae=>({...ae,next:ae.next===P.id?null:ae.next,onFail:ae.onFail===P.id?null:ae.onFail}))}),C(null)},makeStart:()=>S(G=>G===null?G:{...G,start:P.id}),onClose:()=>C(null)})})})()]}),!v&&ho]}),xo=(0,a.jsxs)("div",{className:"fl-runs",children:[o.cards.length===0?(0,a.jsx)(pr,{title:"This flow hasn't run yet.",text:be!==void 0?`It runs when someone presses ${be.button.label}.`:Pe!==void 0?`It runs ${Pe.words.replace(/^./,P=>P.toLowerCase())}, or press Run now.`:"It runs when its trigger fires, or add a card by hand."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(zo,{label:"Runs",count:(0,a.jsx)(bt,{n:o.cards.length})}),Je.map(gn)]}),(0,a.jsx)("section",{className:"fl-insights",children:(0,a.jsx)(B0,{view:o})})]}),Ot=h!==null&&"card"in h.open?o.cards.find(P=>P.id===h.open.card)??null:null,yt=h!==null&&"press"in h.open?o.triggers.find(P=>P.id===h.open.press&&P.button!==null)??null:null,Lt=h===null?null:Ot!==null?{title:Ot.title,body:(0,a.jsx)(d0,{card:Ot,view:o,csrf:t,apply:l,onAllowBrowser:()=>{p(),requestAnimationFrame(()=>{let P=document.getElementById("fl-browser");P?.scrollIntoView({block:"center"}),P?.querySelector(".k-btn-primary")?.focus({preventScroll:!0})})}})}:yt!==null?{title:yt.button.label,body:(0,a.jsx)(O0,{trigger:yt,view:o,csrf:t,apply:l,onDone:p},yt.id)}:"triggers"in h.open?{title:"Triggers",body:(0,a.jsx)(R0,{view:o,csrf:t,apply:l,focus:h.open.triggers,onPress:P=>c({press:P},h.from)})}:"scripts"in h.open?{title:"Scripts",body:(0,a.jsx)(L0,{view:o,csrf:t,apply:l})}:"unattended"in h.open?{title:"Run on its own",body:(0,a.jsx)(D0,{view:o,csrf:t,apply:l,onSigned:p})}:"newCard"in h.open?{title:"New card",body:(0,a.jsx)(j0,{view:o,csrf:t,apply:P=>{l(P),P.ok&&p()}})}:null;return(0,a.jsxs)("div",{className:"fl-page","data-kit-page":!0,"data-flow":o.flow.id,children:[lo,n&&!v&&(0,a.jsx)("div",{className:"fl-phonebar",children:pn}),!v&&uo,v&&(0,a.jsx)(Vo,{outcome:s}),!v&&(0,a.jsx)(A0,{view:o,csrf:t,apply:l,phone:n,...g}),(0,a.jsx)("div",{className:"fl-body",children:d==="runs"&&!v?xo:go}),n&&!v&&we!==null&&!(Me&&o.canEdit)&&(0,a.jsx)($o,{children:vt(!1)}),n&&!v&&Me&&o.canEdit&&o.browser?.canApprove!==!1&&!g.moved&&g.frozen!==null&&(0,a.jsx)(K0,{view:o,csrf:t,apply:l,frozen:g.frozen}),Lt!==null&&(0,a.jsx)(or,{kind:"drawer",title:Lt.title,trigger:h.from,onClose:p,children:(0,a.jsxs)("div",{"data-view":"flow-drawer",className:"fl-drawer-body",children:[(0,a.jsx)(Vo,{outcome:s}),Lt.body]})})]})}function K0({view:e,csrf:t,apply:n,frozen:o}){if(o.problem!==null||o.digest===null)return null;let r=o.digest;return(0,a.jsx)($o,{children:(0,a.jsx)(Na,{view:e,label:"Allow browser",busyLabel:"Allowing…",terms:`${e.flow.name} · ${o.zones.map(s=>`${s.title} runs ${s.script} v${s.version}`).join("; ")} · digest ${r.slice(0,12)}`,act:async s=>{let i=await me(`${e.flow.href}/browser`,{digest:r,password:s},t);return i.ok?(n(i),null):i.said}})})}function U0({api:e}){let t=Dt();return(0,D.useEffect)(()=>(e.current={center:()=>t.screenToFlowPosition({x:window.innerWidth/2,y:window.innerHeight/2})},()=>{e.current=null}),[t,e]),null}export{Yy as FlowView,Y0 as PRIMARY_SETTLE_MS};
|
|
16
|
+
How bad is it?`})})]}),s==="schedule"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"When",hint:"For example: daily 09:00 Europe/London, monday 09:00, every 4 hours.",children:(0,a.jsx)(ne,{value:x("schedule"),onChange:j("schedule"),required:!0})}),(0,a.jsx)(Y,{label:"Makes",children:(0,a.jsxs)("select",{className:ue,value:x("script")===""&&!u?"card":"script","aria-label":"Makes",onChange:C=>{c(C.target.value==="script"),h(_=>({..._,script:C.target.value==="script"?e.scripts[0]?.name??"":""}))},children:[(0,a.jsx)("option",{value:"card",children:"One card each time"}),(0,a.jsx)("option",{value:"script",children:"A card for each item a script prints"})]})}),x("script")!==""||u?e.scripts.length===0?(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"This project has no scripts yet: make one with Scripts in the toolbar."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Script",hint:'It prints one item per line (a title, or JSON like {"title": "…", "key": 42}). The same item never makes two cards.',children:(0,a.jsx)("select",{className:ue,value:x("script"),onChange:j("script"),"aria-label":"Script",children:e.scripts.map(C=>(0,a.jsxs)("option",{value:C.name,children:[C.name," — ",C.about]},C.name))})}),(0,a.jsx)(Y,{label:"Secrets it gets (optional)",hint:"Names of saved secrets, like CRM_KEY. Save them on a script zone's Secrets.",children:(0,a.jsx)(ne,{value:x("secrets"),onChange:j("secrets"),className:"font-mono",placeholder:"CRM_KEY",maxLength:400})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Card title",hint:"Each card's date is added to it.",children:(0,a.jsx)(ne,{value:x("title"),onChange:j("title"),placeholder:"Dependency check",maxLength:200,required:!0})}),(0,a.jsx)(Y,{label:"Details (optional)",children:(0,a.jsx)(ye,{rows:3,value:x("description"),onChange:j("description")})})]})]}),s==="github"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Repository",children:(0,a.jsx)(ne,{value:x("repo"),onChange:j("repo"),placeholder:"owner/name",required:!0})}),(0,a.jsx)(Y,{label:"Watch",children:(0,a.jsxs)("select",{className:ue,value:x("watch"),onChange:j("watch"),children:[(0,a.jsx)("option",{value:"issues",children:"New issues"}),(0,a.jsx)("option",{value:"pulls",children:"New pull requests"}),(0,a.jsx)("option",{value:"checks",children:"Failed checks"})]})}),x("watch")!=="checks"&&(0,a.jsx)(Y,{label:"Label (optional)",hint:x("watch")==="issues"?"With a label, an issue joins the moment it gets the label.":"Only pull requests with this label.",children:(0,a.jsx)(ne,{value:x("label"),onChange:j("label"),placeholder:"bug",maxLength:50})}),x("watch")==="checks"&&(0,a.jsx)(Y,{label:"Branch",children:(0,a.jsx)(ne,{value:x("branch"),onChange:j("branch"),maxLength:100})}),x("watch")!=="checks"&&(0,a.jsx)(Y,{label:"From",hint:x("from")==="anyone"?"Anyone who can open one there can write what the agent reads. The work still waits for your approval.":void 0,children:(0,a.jsxs)("select",{className:ue,value:x("from"),onChange:j("from"),children:[(0,a.jsx)("option",{value:"team",children:"People with write access"}),(0,a.jsx)("option",{value:"anyone",children:"Anyone"})]})})]}),s==="linear"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Team key",hint:"Like ENG. Name a team, a label, or both.",children:(0,a.jsx)(ne,{value:x("team"),onChange:j("team"),placeholder:"ENG",maxLength:12})}),(0,a.jsx)(Y,{label:"When it moves to (optional)",children:(0,a.jsx)(ne,{value:x("state"),onChange:j("state"),placeholder:"Todo",maxLength:40})}),(0,a.jsx)(Y,{label:"Label (optional)",children:(0,a.jsx)(ne,{value:x("label"),onChange:j("label"),placeholder:"bug",maxLength:50})})]}),(s==="github"||s==="linear")&&(0,a.jsx)(Y,{label:"How it arrives",hint:x("delivery")==="webhook"?r.hooksBase===null?"Needs your public webhook address: set it under Settings below.":"You'll get an address to paste into "+(s==="github"?"GitHub.":"Linear."):s==="linear"&&!r.linearKey?"Save your Linear key under Settings below first.":void 0,children:(0,a.jsxs)("select",{className:ue,value:x("delivery"),onChange:j("delivery"),children:[(0,a.jsx)("option",{value:"poll",children:"Checked every 2 minutes"}),(0,a.jsx)("option",{value:"webhook",children:"Sent to a webhook address"})]})}),s==="flow"&&(r.otherFlows.length===0?(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"There are no other flows to follow yet."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Flow",children:(0,a.jsx)("select",{className:ue,value:x("flow"),onChange:C=>h(_=>({..._,flow:C.target.value,when:""})),children:r.otherFlows.map(C=>(0,a.jsx)("option",{value:C.id,children:C.name},C.id))})}),(0,a.jsx)(Y,{label:"When a card reaches",children:(0,a.jsxs)("select",{className:ue,value:x("when"),onChange:j("when"),children:[(0,a.jsx)("option",{value:"",children:"The end"}),S?.zones.map(C=>(0,a.jsx)("option",{value:C.id,children:C.title},C.id))]})})]})),s==="chat"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-chat-connect":!0,children:[(0,a.jsx)("p",{children:"Connect a Slack, Discord or Teams channel, or a Telegram group, from the channel itself. Where Toolroll is, send:"}),(0,a.jsx)("p",{children:(0,a.jsxs)("code",{className:"rounded bg-background px-1.5 py-0.5 font-semibold",children:["flow ",e.flow.id]})}),(0,a.jsxs)("p",{className:"text-muted-foreground",children:["Each new message there becomes a card here, and replies in its thread join the card's discussion. “flow off” stops it. In Teams, mention Toolroll in each message. In Telegram, send /flow ",e.flow.id,", and turn the bot's privacy mode off in BotFather so it sees every message."]})]}),s==="email"&&(0,a.jsxs)(a.Fragment,{children:[r.mailbox===null?(0,a.jsxs)("p",{className:"rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-mailbox-missing":!0,children:["Reading mail isn't set up yet. Add your mail server's IMAP address, or sign in with Google, in ",(0,a.jsx)("a",{className:"underline",href:"/settings/alerts#email",children:"Settings → Email"}),"."]}):(0,a.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["New mail in ",r.mailbox," becomes cards, from now on. The mailbox is only read: nothing is marked or moved."]}),(0,a.jsx)(Y,{label:"Folder",children:(0,a.jsx)(ne,{value:x("folder"),onChange:j("folder"),placeholder:"INBOX",maxLength:100})}),(0,a.jsx)(Y,{label:"Only from (optional)",hint:"Addresses or domains, like priya@example.com, example.com.",children:(0,a.jsx)(ne,{value:x("sender"),onChange:j("sender"),maxLength:300})}),(0,a.jsx)(Y,{label:"Subject has (optional)",children:(0,a.jsx)(ne,{value:x("subject"),onChange:j("subject"),placeholder:"Order",maxLength:100})})]}),s==="plane-review"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Every morning, reads the last 24 hours and makes one card per problem worth fixing. A problem that comes back joins its card. A clean day adds nothing."}),(0,a.jsx)(Y,{label:"Time",hint:`Every day, in ${x("timeZone")||"your time zone"}.`,children:(0,a.jsx)(ne,{type:"time",value:x("at"),onChange:j("at"),required:!0})})]}),s==="webhook"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Y,{label:"Title field",hint:"Where to find the card's title in the posted JSON, like title or data.issue.title.",children:(0,a.jsx)(ne,{value:x("titleField"),onChange:j("titleField"),placeholder:"title",maxLength:80})}),(0,a.jsx)(Y,{label:"Details field",children:(0,a.jsx)(ne,{value:x("bodyField"),onChange:j("bodyField"),placeholder:"description",maxLength:80})}),(0,a.jsx)(Y,{label:"Title when there is none",children:(0,a.jsx)(ne,{value:x("title"),onChange:j("title"),maxLength:120})})]}),s!=="chat"&&(0,a.jsx)(Y,{label:"Cards start in",children:(0,a.jsxs)("select",{className:ue,value:x("zone"),onChange:j("zone"),children:[(0,a.jsx)("option",{value:"",children:e.stages.find(C=>C.id===e.start)?.title??"The first zone"}),e.stages.filter(C=>C.id!==e.start).map(C=>(0,a.jsx)("option",{value:C.id,children:C.title},C.id))]})}),E&&(0,a.jsx)(It,{view:e,password:m,setPassword:f,credential:!0}),v&&(0,a.jsx)(It,{view:e,password:m,setPassword:f}),s!=="chat"&&(0,a.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:p||s==="flow"&&r.otherFlows.length===0||E&&!xt(e,m)||v&&!xt(e,m,b),children:[(0,a.jsx)(Qe,{className:"size-4"}),"Add trigger"]})]})]})}function C0({view:e,csrf:t,apply:n}){let o=e.triggerSetup,r=(0,D.useContext)(jt),[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(""),[u,c]=(0,D.useState)(o.hooksBase??""),[p,d]=(0,D.useState)(!1),m=async(f,w)=>{d(!0);let y=await me(f,w,t);d(!1),n(y),y.ok&&(i(""),h(""))};return(0,a.jsxs)("details",{className:"rounded-lg border px-3 py-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-semibold",children:"Settings"}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-3",children:[o.linearKey?(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)("span",{className:"text-body font-medium",children:"Linear key"}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:"Saved on this computer."}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"ghost",className:"self-start text-destructive",disabled:p,onClick:()=>{m(`${e.flow.href}/linear-key`,{remove:"yes"})},children:"Remove key"})]}):(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:f=>{f.preventDefault(),m(`${e.flow.href}/linear-key`,{key:s,password:l})},children:[(0,a.jsx)(Y,{label:"Linear key",hint:"From Linear → Settings → Security & access → Personal API keys. Kept on this computer only.",children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:s,onChange:f=>i(f.target.value),placeholder:"lin_api_…"})}),(0,a.jsx)(It,{view:e,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:p||s.trim()===""||!xt(e,l,r),children:"Save key"})]}),(0,a.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:f=>{f.preventDefault(),m(`${e.flow.href}/hooks-address`,{address:u})},children:[(0,a.jsx)(Y,{label:"Public webhook address",hint:"The https site your reverse proxy (Caddy, for example) serves. Have it pass only paths starting /hooks/ to this console.",children:(0,a.jsx)(ne,{value:u,onChange:f=>c(f.target.value),placeholder:"https://hooks.example.com"})}),(0,a.jsx)(te,{type:"submit",size:"sm",variant:"outline",className:"self-start",disabled:p,children:"Save address"})]})]})]})}function It({view:e,password:t,setPassword:n,credential:o=!1}){let r=(0,D.useContext)(jt);return!o&&r?null:e.stepUp===void 0?(0,a.jsx)(Y,{label:"Your Toolroll password",children:(0,a.jsx)(ne,{type:"password",autoComplete:"current-password",value:t,onChange:s=>n(s.target.value)})}):e.stepUp.fresh?(0,a.jsxs)("p",{className:"text-body text-success","data-sso-step-up":"confirmed",children:["✓ Confirmed with ",e.stepUp.label]}):(0,a.jsxs)("a",{className:"text-body underline","data-sso-step-up":"confirm",href:e.stepUp.confirmHref,children:["Confirm with ",e.stepUp.label]})}var xt=(e,t,n=!1)=>n||(e.stepUp===void 0?t!=="":e.stepUp.fresh);function zs({view:e,label:t,busy:n,className:o,onConfirm:r}){let[s,i]=(0,D.useState)(!1),[l,h]=(0,D.useState)("");return s?(0,a.jsxs)("span",{className:"flex w-full flex-wrap items-end gap-2","data-credential-action":!0,children:[(0,a.jsx)(It,{view:e,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{size:"sm",disabled:n||!xt(e,l),onClick:()=>{r(l).then(u=>{u&&(i(!1),h(""))})},children:t}),(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:n,onClick:()=>{i(!1),h("")},children:"Cancel"})]}):(0,a.jsx)(te,{size:"sm",variant:"outline",className:o,disabled:n,onClick:()=>i(!0),children:t})}var ea={linear:{label:"Linear's signing secret",hint:"Linear shows it when you create the webhook."},sentry:{label:"Sentry's Client Secret",hint:"In Sentry: Settings → Developer Settings → your Internal Integration → Client Secret."},vercel:{label:"Vercel's webhook secret",hint:"Vercel shows it once when you create the webhook (an integration's webhooks use its Client Secret)."}},$0=[["none","Unsigned (the address alone)"],["standard","Standard Webhooks"],["github-style","GitHub-style signature"],["sentry","Sentry"],["vercel","Vercel"]];function E0({trigger:e,view:t,csrf:n,apply:o,onReveal:r}){let s=e.hook,i=s.sender??"none",[l,h]=(0,D.useState)(i),[u,c]=(0,D.useState)(""),[p,d]=(0,D.useState)(s.scope?.project??""),[m,f]=(0,D.useState)(s.scope?.team??""),[w,y]=(0,D.useState)(""),[x,E]=(0,D.useState)(!1),v=async(M,C)=>{E(!0);let _=await me(`${t.flow.href}/triggers/${e.id}/${M}`,{...C,password:w},n);E(!1),o(_),_.ok&&(y(""),c("")),_.reveal!==void 0&&r(_.reveal)},b=l!==i,j=ea[i],S=xt(t,w);return(0,a.jsxs)("details",{className:"mt-2 rounded-md border px-2 py-1.5",open:!s.ready||s.warning!==null||void 0,"data-trigger-signing":i,children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-body font-medium",children:["Signing",s.ready&&i!=="none"?"":" · needs you"]}),(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[s.warning!==null&&(0,a.jsx)("p",{className:xe("text-caption font-normal",i==="none"||!s.ready?"text-foreground":"text-muted-foreground"),"data-trigger-signing-warning":!0,children:s.warning}),s.readerNote!==null&&(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal","data-trigger-reader-note":!0,children:s.readerNote}),(0,a.jsx)(Y,{label:"Signed by",hint:"Who signs this webhook's deliveries. Changing it keeps the address and drops the secret: it then needs one again.",children:(0,a.jsx)("select",{className:Dl,value:l,onChange:M=>h(M.target.value),"data-trigger-sender":!0,children:$0.map(([M,C])=>(0,a.jsx)("option",{value:M,children:C},M))})}),!b&&s.scope!==null&&(0,a.jsx)(Y,{label:i==="vercel"?"Vercel project ID":"Sentry project",hint:i==="vercel"?"Only this project's deployments add cards (prj_…, from the project's Settings). Blank takes any project the secret covers.":"Only this project's issues add cards (its slug or number). Blank takes any project the integration sees.",children:(0,a.jsx)(ne,{value:p,onChange:M=>d(M.target.value),"data-trigger-project":!0})}),!b&&i==="vercel"&&(0,a.jsx)(Y,{label:"Vercel team ID",hint:"Only deliveries from this team (team_…). Blank takes any.",children:(0,a.jsx)(ne,{value:m,onChange:M=>f(M.target.value),"data-trigger-team":!0})}),!b&&j!==void 0&&(0,a.jsx)(Y,{label:s.ready?`Replace ${j.label}`:j.label,hint:j.hint,children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:u,onChange:M=>c(M.target.value),"data-trigger-secret":!0})}),(0,a.jsx)(It,{view:t,password:w,setPassword:y}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[b&&(0,a.jsx)(te,{type:"button",size:"sm",disabled:x||!S,onClick:()=>{v("sender",{sender:l})},children:"Change who signs it"}),!b&&s.makesSecret&&(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",disabled:x||!S,onClick:()=>{v("setup",{})},"data-trigger-setup":!0,children:s.ready?"Replace secret":"Set up"}),!b&&j!==void 0&&(0,a.jsx)(te,{type:"button",size:"sm",disabled:x||!S||u.trim()==="",onClick:()=>{v("secret",{secret:u})},children:s.ready?"Replace secret":"Save secret"}),!b&&s.scope!==null&&(p.trim()!==(s.scope.project??"")||m.trim()!==(s.scope.team??""))&&(0,a.jsx)(te,{type:"button",size:"sm",variant:"outline",disabled:x||!S,onClick:()=>{v("scope",{project:p,team:m})},"data-trigger-save-scope":!0,children:"Save project"})]})]})]})}function M0({trigger:e,view:t,csrf:n,apply:o}){let r=ea[e.hook?.sender??e.kind]??ea.linear,[s,i]=(0,D.useState)(""),[l,h]=(0,D.useState)(""),[u,c]=(0,D.useState)(!1);return(0,a.jsxs)("form",{className:"mt-2 flex flex-col gap-2 rounded-md border border-attention/50 p-2",onSubmit:async p=>{p.preventDefault(),c(!0);let d=await me(`${t.flow.href}/triggers/${e.id}/secret`,{secret:s,password:l},n);c(!1),o(d),d.ok&&(i(""),h(""))},children:[(0,a.jsx)(Y,{label:r.label,hint:r.hint,children:(0,a.jsx)(ne,{type:"password",autoComplete:"off",value:s,onChange:p=>i(p.target.value)})}),(0,a.jsx)(It,{view:t,password:l,setPassword:h,credential:!0}),(0,a.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:u||s.trim()===""||!xt(t,l),children:"Save secret"})]})}function Na({view:e,label:t,busyLabel:n,terms:o,text:r,docked:s,check:i,act:l}){let h=(0,D.useContext)(jt),[u,c]=(0,D.useState)(!1),[p,d]=(0,D.useState)(null);return e.stepUp!==void 0?xt(e,"")?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(he,{variant:"primary",label:t,docked:s===!0,busy:u?n:!1,"data-sso-step-up":"confirmed",onClick:async()=>{if(!(u||i!==void 0&&!i())){c(!0),d(null);try{d(await l(""))}finally{c(!1)}}}}),p!==null&&(0,a.jsx)(Sn,{children:p})]}):(0,a.jsx)(ur,{variant:"primary",href:e.stepUp.confirmHref,label:`Confirm with ${e.stepUp.label}`,"data-sso-step-up":"confirm"}):(0,a.jsx)(rr,{kind:"step-up",facts:{passwordless:h,remembered:!1},label:t,terms:o,...r===void 0?{}:{text:r},...s?{docked:!0}:{},...i===void 0?{}:{check:i},onApprove:m=>l(m??"")})}function z0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(!1),s=e.unattended.active,i=e.unattended.ended??null;return s!==null?(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-unattended":"on",children:[(0,a.jsxs)("span",{title:`Ends ${s.untilWords} · covers ${s.covers.join("; ")}`,children:["Runs on its own until ",Cs(s.until)]}),e.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Revoke",busy:o?"Revoking…":!1,"data-flow-unattended-revoke":!0,onClick:async()=>{o||(r(!0),n(await me(`${e.flow.href}/unattended-off`,{},t)),r(!1))}})]}):i!==null?(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-unattended-ended":!0,children:["No longer runs on its own: ",i.why," (",Cs(i.at),"), so steps wait for you again"]}):null}function _0({view:e,csrf:t,apply:n}){let[o,r]=(0,D.useState)(!1),s=e.browser;return s==null||s.status!=="allowed"?null:(0,a.jsxs)("span",{className:"fl-meta-item","data-flow-browser":"allowed",children:[(0,a.jsx)("span",{children:s.words}),e.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Turn off",busy:o?"Turning off…":!1,"data-flow-browser-off":!0,onClick:async()=>{o||(r(!0),n(await me(`${e.flow.href}/browser-off`,{},t)),r(!1))}})]})}function P0(e){let t=e!=null&&e.status!=="allowed"?e:null,n=(0,D.useRef)(t),[,o]=(0,D.useState)(0);t===null?n.current=null:n.current===null&&(n.current=t);let r=(0,D.useCallback)(()=>{n.current=t,o(i=>i+1)},[t]),s=n.current;return{frozen:s,moved:s!==null&&t!==null&&s.digest!==t.digest,reread:r}}function A0({view:e,csrf:t,apply:n,phone:o,frozen:r,moved:s,reread:i}){let l=e.browser;if(l==null||l.status==="allowed"||r===null)return null;let h=l.status==="ended",u=r.zones[0]?.title??e.stages.find(m=>m.kind==="check"&&m.browser===!0)?.title??"A step",c=l.words.replace(/^Browser approval ended: /,""),p=e.canEdit&&l.canApprove!==!1,d=p&&l.problem===null&&r.digest!==null&&!s?(0,a.jsx)(Na,{view:e,label:"Allow browser",busyLabel:"Allowing…",docked:o,terms:`${e.flow.name} · ${r.zones.map(m=>`${m.title} runs ${m.script} v${m.version}`).join("; ")} · digest ${r.digest.slice(0,12)}`,act:async m=>{let f=await me(`${e.flow.href}/browser`,{digest:r.digest,password:m},t);return f.ok?(n(f),null):f.said}}):null;return(0,a.jsxs)("div",{className:"fl-browser",id:"fl-browser","data-flow-browser-panel":!0,"data-flow-browser":l.status,children:[(0,a.jsx)(ar,{wait:!0,status:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Tt,{word:"Needs you",tone:"needs"}),(0,a.jsx)("h2",{children:h?"Browser approval expired":`Allow browser for ${u}?`})]}),text:(0,a.jsxs)(a.Fragment,{children:[h?`It ended because ${c}. The next run waits at ${u} until someone allows it again.`:`${u} starts a browser. The next run waits there until someone allows it.`,r.zones.length>0&&(0,a.jsx)("span",{className:"fl-zones","data-flow-browser-zones":!0,children:r.zones.map(m=>(0,a.jsxs)("span",{className:"fl-zone",children:[(0,a.jsx)("b",{children:m.title})," runs ",(0,a.jsx)("span",{className:"k-mono",children:m.script})," v",m.version,(0,a.jsx)("span",{className:"k-mono fl-dig",children:m.digest})]},m.zone))})]}),acts:s?(0,a.jsx)("span",{"data-flow-browser-moved":!0,children:(0,a.jsx)(he,{label:"Read the new terms",onClick:i})}):d,terms:p?l.problem!==null?l.problem:s?"This flow or its scripts changed while you were reading.":e.stepUp!==void 0?`Asks you to confirm with ${e.stepUp.label}.`:"Allowing it is a step-up: it asks for your password unless Passwordless is on.":"Only an approver with access to every project can allow browser use."}),r.terms.length>0&&(0,a.jsx)(fr,{summary:"What else allowing means",children:(0,a.jsxs)("div",{className:"fl-terms","data-flow-browser-terms":!0,children:[(0,a.jsx)("ul",{children:["Each run of these steps starts a headless Chromium.",...r.terms].map((m,f)=>(0,a.jsx)("li",{children:m},f))}),(0,a.jsxs)("p",{className:"k-note",children:["Approval digest ",(0,a.jsx)("span",{className:"k-mono",children:r.digest})]})]})})]})}function _s(e,t){let n=Bg(t.budget),o=Vg(t.runs),r={...n.ok?{}:{budget:n.message},...o.ok?{}:{runs:o.message}};if(!n.ok||!o.ok)return{errors:r,snapshot:null};let s=Math.min(e.unattended.maxDays,Math.max(1,Math.round(Number(t.days))||1)),i=new Set(e.unattended.schedules.filter(u=>u.optional!==null).map(u=>u.id)),l=t.include.filter(u=>i.has(u)),h=e.unattended.schedules.filter(u=>u.optional===null||l.includes(u.id)).map(u=>({id:u.id,words:u.words}));return{errors:r,snapshot:{days:s,budgetMicrousd:n.value,dailyRunCap:o.value,include:l,covered:h,schedulesDigest:e.unattended.schedulesDigest,revision:e.flow.revision}}}var I0=(e,t)=>[...e.unattended.terms.head,...t.covered.length===0?[]:[Hg(t.covered)],...$l(t.budgetMicrousd,t.dailyRunCap),...e.unattended.terms.rules,Fg(t.days)];function D0({view:e,csrf:t,apply:n,onSigned:o}){let r=(0,D.useContext)(jt),[s,i]=(0,D.useState)({days:"1",budget:"",runs:"",include:[]}),[l,h]=(0,D.useState)(null),[u,c]=(0,D.useState)(null),p=_s(e,s),d=(0,D.useRef)(p.snapshot);p.snapshot!==null&&(d.current=p.snapshot);let m=p.snapshot??d.current,f=(0,D.useRef)(null),w=(0,D.useRef)(null),y=(0,D.useRef)(null);if(!e.unattended.canSign)return(0,a.jsx)("div",{"data-flow-unattended-panel":!0,children:(0,a.jsx)("p",{className:"k-note","data-flow-unattended-problem":!0,children:e.unattended.problem})});let x=b=>j=>{h(null),i(S=>({...S,[b]:j.target.value}))},E=()=>{let b=_s(e,s);return b.snapshot===null?((b.errors.budget!==void 0?w:y).current?.focus(),!1):b.snapshot.covered.length===0?(h("Pick a schedule above to sign."),!1):(f.current=b.snapshot,c(b.snapshot),!0)},v=e.unattended.schedules.filter(b=>b.optional!==null);return(0,a.jsxs)("div",{className:"fl-form","data-flow-unattended-panel":!0,children:[(0,a.jsx)("p",{className:"k-note",children:"While it runs on its own, cards its schedule adds move past steps that would wait for you, within the limits you set here. It never merges or ships anything."}),(0,a.jsx)(yn,{label:"Lasts",children:b=>(0,a.jsx)(jn,{id:b.id,value:s.days,onChange:x("days"),"data-flow-unattended-days":!0,wide:!0,items:Array.from({length:e.unattended.maxDays},(j,S)=>[String(S+1),`${S+1} day${S===0?"":"s"}`])})}),(0,a.jsxs)("div",{className:"fl-two",children:[(0,a.jsx)(yn,{label:"Budget per attempt ($)",error:p.errors.budget??null,children:b=>(0,a.jsx)(wn,{ref:w,id:b.id,inputMode:"decimal",placeholder:"No cap",value:s.budget,onChange:x("budget"),"aria-invalid":b.invalid||void 0,"aria-describedby":b.describedBy,"data-flow-unattended-budget":!0})}),(0,a.jsx)(yn,{label:"Runs a day",error:p.errors.runs??null,children:b=>(0,a.jsx)(wn,{ref:y,id:b.id,inputMode:"numeric",placeholder:"No limit",value:s.runs,onChange:x("runs"),"aria-invalid":b.invalid||void 0,"aria-describedby":b.describedBy,"data-flow-unattended-runs":!0})})]}),v.length>0&&(0,a.jsxs)("fieldset",{className:"fl-checks","data-flow-unattended-schedules":!0,children:[(0,a.jsx)("legend",{children:"Also cover"}),v.map(b=>(0,a.jsxs)("label",{className:"fl-check",children:[(0,a.jsx)("input",{type:"checkbox",checked:s.include.includes(b.id),onChange:j=>{h(null),i(S=>({...S,include:j.target.checked?[...S.include,b.id]:S.include.filter(M=>M!==b.id)}))}}),(0,a.jsxs)("span",{children:[b.words,(0,a.jsx)("span",{className:"k-note",children:b.optional})]})]},b.id))]}),m!==null&&(0,a.jsxs)("div",{className:"fl-signs","data-flow-unattended-terms":!0,children:[(0,a.jsx)("b",{children:e.stepUp===void 0&&!r?"Your password signs exactly this":"Signing covers exactly this"}),(0,a.jsx)("ul",{"aria-live":"polite",children:I0(e,m).map((b,j)=>(0,a.jsx)("li",{children:b},j))})]}),l!==null&&(0,a.jsx)(Sn,{children:l}),(0,a.jsx)(kn,{children:(0,a.jsx)(Na,{view:e,label:"Sign",busyLabel:"Signing…",check:E,terms:u===null?"":`${e.flow.name} · ${u.days} day${u.days===1?"":"s"} · ${$l(u.budgetMicrousd,u.dailyRunCap).join(" ")}`,act:async b=>{let j=f.current;if(j===null)return"Read the terms again. Nothing was signed.";let S=await me(`${e.flow.href}/unattended`,{days:String(j.days),budget:j.budgetMicrousd===null?"":(j.budgetMicrousd/1e6).toFixed(2),runs:j.dailyRunCap===null?"":String(j.dailyRunCap),include:j.include.join(","),schedules:j.schedulesDigest,password:b,revision:String(j.revision)},t);return S.ok?(n(S),o(),null):S.said}})})]})}function R0({view:e,csrf:t,apply:n,focus:o,onPress:r}){let[s,i]=(0,D.useState)(null),[l,h]=(0,D.useState)(!1),u=`${e.flow.href}/triggers`,c=async(d,m,f={})=>{h(!0);let w=await me(d,f,t);return h(!1),n(w),w.reveal!==void 0&&i({kind:m,reveal:w.reveal}),w.ok},p=e.triggers.filter(d=>d.state!=="removed");return(0,D.useEffect)(()=>{o!==null&&document.querySelector(`[data-trigger-row="${o}"]`)?.scrollIntoView({block:"nearest"})},[o]),(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-triggers":!0,children:[(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["Triggers add cards to this flow on their own.",p.some(d=>d.order!==void 0)?"":" The work they start still waits for your usual approvals."]}),s!==null&&(0,a.jsx)(N0,{kind:s.kind,reveal:s.reveal,onDone:()=>i(null)}),p.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-3",children:p.map(d=>(0,a.jsxs)("li",{className:xe("rounded-lg border p-3",o===d.id&&"ring-2 ring-primary/50"),"data-trigger-row":d.id,children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:Ml[d.kind]??(0,a.jsx)(bo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"text-body leading-snug font-medium",children:d.words}),(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["Starts in ",d.zone,d.state==="paused"?" · Paused":"",d.shared?" · Shared as a form":""]}),d.status!==null&&(0,a.jsxs)("p",{className:xe("text-caption font-normal",d.failing?"text-foreground":"text-muted-foreground"),children:[Es(d.statusAt),": ",d.status,(0,a.jsx)(o0,{link:d.statusLink})]})]})]}),d.order!==void 0&&(0,a.jsx)("p",{className:"mt-2 text-caption break-words font-normal","data-trigger-approval":!0,children:d.order.at(-1)}),d.order!==void 0&&(0,a.jsxs)("details",{className:"mt-2 rounded-md border px-3 py-2","data-trigger-order":!0,children:[(0,a.jsx)("summary",{className:"cursor-pointer text-body font-medium",children:"What each run files"}),(0,a.jsx)("ul",{className:"mt-1 flex flex-col gap-1 text-caption text-muted-foreground font-normal",children:d.order.slice(0,-1).map((m,f)=>(0,a.jsx)("li",{className:"break-words",children:m},f))})]}),d.hook?.dropped!=null&&(0,a.jsxs)("div",{className:"mt-2 flex flex-col gap-1.5 rounded-md border border-attention/50 p-2","data-trigger-dropped":!0,children:[(0,a.jsxs)("p",{className:"text-body font-medium",children:[d.hook.dropped.count===1?"1 delivery was":`${d.hook.dropped.count} deliveries were`," turned away since ",Es(d.hook.dropped.since),": too many were already waiting."]}),(0,a.jsx)("p",{className:"text-caption text-muted-foreground font-normal",children:d.hook.dropped.resend}),(0,a.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:l,onClick:()=>{c(`${u}/${d.id}/dropped`,d.kind)},children:"Clear"})]}),d.hook?.sender!=null&&(0,a.jsx)(E0,{trigger:d,view:e,csrf:t,apply:n,onReveal:m=>i({kind:d.hook?.sender??d.kind,reveal:m})}),d.hook?.sender==null&&d.hook?.needsSecret===!0&&!d.hook.ready&&(0,a.jsx)(M0,{trigger:d,view:e,csrf:t,apply:n}),(0,a.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[d.button!==null&&d.state==="active"&&(0,a.jsx)(te,{size:"sm",onClick:()=>r(d.id),children:"Start"}),d.button!==null&&(0,a.jsx)(zs,{view:e,busy:l,label:d.shared?"New form link":"Share as a form",onConfirm:m=>c(`${u}/${d.id}/share`,"form",{password:m})}),d.shared&&(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{c(`${u}/${d.id}/unshare`,"form")},children:"Stop sharing"}),d.checkable&&d.state==="active"&&(0,a.jsx)(te,{size:"sm",variant:"outline",disabled:l,onClick:()=>{c(`${u}/${d.id}/check`,d.kind)},children:d.kind==="schedule"?"Run now":"Check now"}),d.hook!==null&&(0,a.jsx)(zs,{view:e,busy:l,label:"New address",onConfirm:m=>c(`${u}/${d.id}/renew`,d.kind,{password:m})}),(0,a.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{c(`${u}/${d.id}/${d.state==="paused"?"resume":"pause"}`,d.kind)},children:d.state==="paused"?"Turn on":"Pause"}),(0,a.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:l,onClick:()=>{c(`${u}/${d.id}/remove`,d.kind)},children:"Remove"})]})]},d.id))}),(0,a.jsx)(S0,{view:e,csrf:t,open:p.length===0,onResult:(d,m)=>{n(d),d.reveal!==void 0&&i({kind:m,reveal:d.reveal})}}),(0,a.jsx)(C0,{view:e,csrf:t,apply:n})]})}function O0({trigger:e,view:t,csrf:n,apply:o,onDone:r}){let s=e.button?.questions??[],[i,l]=(0,D.useState)(s.map(()=>"")),[h,u]=(0,D.useState)(!1),c=p=>d=>l(m=>m.map((f,w)=>w===p?d.target.value:f));return(0,a.jsxs)("form",{className:"flex flex-col gap-3","data-flow-press":e.id,onSubmit:async p=>{p.preventDefault(),u(!0);let d=await me(`${t.flow.href}/triggers/${e.id}/press`,{answers:JSON.stringify(i)},n);u(!1),o(d),d.ok&&r()},children:[(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:["The card starts in ",e.zone,"."]}),s.map((p,d)=>(0,a.jsx)(Y,{label:p,children:d===0?(0,a.jsx)(ne,{value:i[d]??"",onChange:c(d),maxLength:200,required:!0,autoFocus:!0}):(0,a.jsx)(ye,{rows:3,value:i[d]??"",onChange:c(d)})},d)),(0,a.jsx)(kn,{children:(0,a.jsx)(he,{type:"submit",variant:"primary",label:"Add card",busy:h?"Adding…":!1,disabled:(i[0]??"").trim()===""})})]})}function L0({view:e,csrf:t,apply:n}){let o={name:"",about:"",body:"",timeoutMinutes:"15",language:"python",file:""},[r,s]=(0,D.useState)(e.scripts.length===0?o:null),[i,l]=(0,D.useState)(!1),h=async()=>{if(r===null)return;l(!0);let d=await me(`${e.flow.href}/scripts`,r,t);l(!1),n(d),d.ok&&(s(null),p(!1))},u=d=>m=>s(f=>f===null?f:{...f,[d]:m.target.value}),[c,p]=(0,D.useState)(!1);return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-scripts":!0,children:[(0,a.jsxs)("p",{className:"text-body text-muted-foreground",children:["Reusable steps with no AI, in shell, Python or Node. A “Run a script” zone runs one with the card, and a schedule can run one to make cards. Any flow in ",e.flow.project," can use them."]}),e.scripts.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:e.scripts.map(d=>(0,a.jsxs)("li",{className:"rounded-lg border p-3","data-script":d.name,children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,a.jsx)(jo,{className:"size-3.5","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"flex flex-wrap items-center gap-1.5 font-mono text-body font-semibold",children:[d.name,d.held&&(0,a.jsx)(Eo,{tone:"attention",children:"Needs approval"})]}),(0,a.jsx)("p",{className:"text-[12.5px]",children:d.about}),(0,a.jsxs)("p",{className:"text-caption text-muted-foreground font-normal",children:[Ll[d.language],d.file===null?"":` · runs ${d.file}`," · version ",d.version," · ",d.savedBy," · up to ",d.timeoutMinutes," min",d.usedHere.length>0?` · runs in ${d.usedHere.join(", ")}`:" · not used in this flow"]})]})]}),d.file===null&&(0,a.jsxs)("details",{className:"mt-2",children:[(0,a.jsx)("summary",{className:"cursor-pointer text-caption text-muted-foreground font-normal",children:"Show the script"}),(0,a.jsx)("pre",{className:"mt-2 max-h-56 overflow-auto rounded-md bg-muted p-2 font-mono text-mono",children:d.body})]}),d.held&&(0,a.jsx)("p",{className:"mt-2 text-[12.5px]","data-script-held":!0,children:"It came with an imported flow, so it doesn't run until you approve it. Read it first."}),e.canEdit&&(0,a.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[d.held&&(0,a.jsx)(te,{size:"sm",disabled:i,onClick:async()=>{l(!0),n(await me(`${e.flow.href}/scripts`,{approve:"yes",name:d.name,version:String(d.version),digest:d.digest},t)),l(!1)},"data-approve-script":!0,children:"Approve"}),(0,a.jsx)(te,{size:"sm",variant:"outline",onClick:()=>{p(d.file!==null),s({name:d.name,about:d.about,body:d.body,timeoutMinutes:String(d.timeoutMinutes),language:d.language,file:d.file??""})},children:"Edit"}),(0,a.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:i,onClick:async()=>{l(!0),n(await me(`${e.flow.href}/scripts`,{remove:"yes",name:d.name},t)),l(!1)},children:"Remove"})]})]},d.name))}),e.canEdit&&(r===null?(0,a.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>{p(!1),s(o)},children:[(0,a.jsx)(Qe,{className:"size-4"}),"New script"]}):(0,a.jsxs)("form",{className:"flex flex-col gap-3 rounded-lg border p-3",onSubmit:d=>{d.preventDefault(),h()},"data-script-form":!0,children:[(0,a.jsx)(Y,{label:"Name",hint:"Lowercase and dashes, like run-tests. Saving under an existing name makes a new version.",children:(0,a.jsx)(ne,{value:r.name,onChange:u("name"),maxLength:40,className:"font-mono",required:!0})}),(0,a.jsx)(Y,{label:"What it checks or does",children:(0,a.jsx)(ne,{value:r.about,onChange:u("about"),maxLength:160,placeholder:"Looks the company up in our CRM",required:!0})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(Y,{label:"Language",children:(0,a.jsxs)("select",{className:ue,value:r.language,onChange:u("language"),"aria-label":"Language",children:[(0,a.jsx)("option",{value:"python",children:"Python"}),(0,a.jsx)("option",{value:"node",children:"Node"}),(0,a.jsx)("option",{value:"shell",children:"Shell"})]})}),(0,a.jsx)(Y,{label:"Runs",children:(0,a.jsxs)("select",{className:ue,value:r.file===""&&!c?"here":"file",onChange:d=>{p(d.target.value==="file"),s(m=>m===null?m:{...m,file:d.target.value==="file"?m.file:""})},"aria-label":"Runs",children:[(0,a.jsx)("option",{value:"here",children:"What's written here"}),(0,a.jsx)("option",{value:"file",children:"A file in the project"})]})})]}),c||r.file!==""?(0,a.jsx)(Y,{label:"File",hint:"A path from the top of the project. It gets the card as JSON on stdin (and in $FLOW_INPUT); what it prints is the step's result.",children:(0,a.jsx)(ne,{value:r.file,onChange:u("file"),maxLength:200,className:"font-mono",placeholder:"scripts/enrich.py",required:!0})}):(0,a.jsx)(Y,{label:"Script",hint:"It gets the card as JSON on stdin (and in $FLOW_INPUT). What it prints is the step's result; a last line “goto: <answer>” picks the next zone. Exit 0 passes.",children:(0,a.jsx)(ye,{value:r.body,onChange:u("body"),rows:8,className:"font-mono text-[12.5px]",placeholder:g0[r.language]??"",required:!0})}),(0,a.jsx)(Y,{label:"Stop it after (minutes)",children:(0,a.jsx)(ne,{type:"number",min:1,max:60,value:r.timeoutMinutes,onChange:u("timeoutMinutes"),className:"w-28"})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(te,{type:"submit",size:"sm",disabled:i,children:"Save script"}),(0,a.jsx)(te,{type:"button",size:"sm",variant:"ghost",onClick:()=>s(null),children:"Cancel"})]})]}))]})}var T0=e=>e===null?"—":e<1?"under a minute":e<90?`${Math.round(e)} min`:e<2880?`${Math.round(e/60)} h`:`${Math.round(e/1440)} days`;function B0({view:e}){let[t,n]=(0,D.useState)(30),[o,r]=(0,D.useState)(null),[s,i]=(0,D.useState)(null),[l,h]=(0,D.useState)(null);(0,D.useEffect)(()=>{let c=!0;return r(null),i(null),fetch(`${e.flow.href}/insights?days=${t}`,{credentials:"same-origin",headers:{accept:"application/json"}}).then(async p=>{if(c){if(!p.ok)throw new Error("load");r(await p.json())}}).catch(()=>{c&&i("The insights couldn't load. Try again.")}),()=>{c=!1}},[t,e.flow.href,e.flow.revision]);let u=async(c,p)=>{let d=`${c}:${p}`;if(l?.key===d){h(null);return}try{let m=await(await fetch(`${e.flow.href}/runs/${c}/${p}`,{credentials:"same-origin",headers:{accept:"application/json"}})).json();h({key:d,text:m.log===void 0||m.log===""?"This run left no output.":m.log})}catch{h({key:d,text:"The log couldn't load."})}};return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-flow-insights":!0,children:[(0,a.jsxs)("div",{className:"fl-secthead",children:[(0,a.jsx)("h3",{children:"How it went"}),(0,a.jsx)(jn,{sm:!0,value:String(t),onChange:c=>n(Number(c.target.value)),"aria-label":"Period",items:[["7","Last 7 days"],["30","Last 30 days"],["90","Last 90 days"]]})]}),s!==null&&(0,a.jsx)("p",{className:"text-body text-destructive",children:s}),o===null&&s===null&&(0,a.jsx)("p",{className:"text-body text-muted-foreground",children:"Loading…"}),o!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-body",children:[o.cards.started," card",o.cards.started===1?"":"s"," started, ",o.cards.finished," finished, ",o.cards.active," in progress."]}),(0,a.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Where it breaks"}),o.breaks.length===0?(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Nothing failed or was sent back in this period."}):(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:o.breaks.map(c=>{let p=o.zones.find(d=>d.zone===c.zone);return(0,a.jsxs)("li",{className:"rounded-lg border border-border p-2.5 text-body",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-semibold",children:c.title}),": ",c.problems," of ",c.of," card",c.of===1?"":"s"," failed or were sent back"]}),p?.lastProblem&&(0,a.jsxs)("p",{className:"mt-0.5 text-caption text-muted-foreground font-normal",children:["Latest: ",p.lastProblem.cardTitle,p.lastProblem.note===null?"":` — ${p.lastProblem.note.split(`
|
|
17
|
+
`)[0]}`]})]},c.zone)})})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Zones"}),(0,a.jsxs)("table",{className:"w-full text-left text-caption font-normal",children:[(0,a.jsx)("thead",{className:"text-muted-foreground",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-1 font-medium",children:"Zone"}),(0,a.jsx)("th",{className:"font-medium",children:"In"}),(0,a.jsx)("th",{className:"font-medium",children:"On"}),(0,a.jsx)("th",{className:"font-medium",children:"Failed"}),(0,a.jsx)("th",{className:"font-medium",children:"Back"}),(0,a.jsx)("th",{className:"font-medium",children:"Typical stay"})]})}),(0,a.jsx)("tbody",{children:o.zones.map(c=>(0,a.jsxs)("tr",{className:"border-t",children:[(0,a.jsxs)("td",{className:"py-1.5 pr-2 font-medium",children:[c.title,c.here>0?(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" · ",c.here," here"]}):null]}),(0,a.jsx)("td",{children:c.entered}),(0,a.jsx)("td",{children:c.movedOn}),(0,a.jsx)("td",{className:c.failed>0?"font-semibold text-destructive":"",children:c.failed}),(0,a.jsx)("td",{className:c.sentBack>0?"font-semibold text-foreground":"",children:c.sentBack}),(0,a.jsx)("td",{children:T0(c.typicalMinutes)})]},c.zone))})]})]}),o.scripts.length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Scripts"}),(0,a.jsx)("ul",{className:"flex flex-col gap-1 text-[12.5px]",children:o.scripts.map(c=>(0,a.jsxs)("li",{children:[(0,a.jsx)("span",{className:"font-mono font-semibold",children:c.script}),": ",c.passed," of ",c.runs," passed",c.typicalSeconds===null?"":`, usually ${c.typicalSeconds<90?`${c.typicalSeconds} s`:`${Math.round(c.typicalSeconds/60)} min`}`]},c.script))})]}),o.sorts.length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-2","data-insights-sorts":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Sorting"}),o.sorts.map(c=>(0,a.jsxs)("div",{className:"rounded-lg border p-2.5 text-[12.5px]","data-insights-sort":c.zone,children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-semibold",children:c.title}),": ",c.sorted," sorted · ",c.alone," on its own · ",c.notSure," for a person",c.corrected>0&&(0,a.jsxs)(a.Fragment,{children:[" · ",(0,a.jsxs)("span",{className:"font-semibold text-attention",children:[c.corrected," moved elsewhere by people"]})]})]}),c.bands.some(p=>p.of>0)&&(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Right when ",c.bands.filter(p=>p.of>0).map(p=>`${p.from}–${p.to}% sure: ${p.right} of ${p.of}`).join(" · ")]}),c.costUsd>0&&(0,a.jsxs)("p",{className:"mt-1 text-muted-foreground",children:["Cost: ",c.costUsd<.01?"under 1¢":`$${c.costUsd.toFixed(2)}`]})]},c.zone))]}),(o.recurring??[]).length>0&&(0,a.jsxs)("section",{className:"flex flex-col gap-1.5","data-insights-recurring":!0,children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"What keeps coming back"}),(0,a.jsx)("ul",{className:"flex flex-col gap-1 text-[12.5px]",children:o.recurring.map(c=>(0,a.jsxs)("li",{className:"flex items-baseline gap-2",children:[(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate",children:c.card===null?c.title:(0,a.jsx)("a",{className:"underline-offset-2 hover:underline",href:`${e.flow.href}?card=${c.card}`,children:c.title})}),(0,a.jsxs)("span",{className:xe("shrink-0 tabular-nums",c.days>1?"font-semibold text-foreground":"text-muted-foreground"),children:[c.days," day",c.days===1?"":"s"]})]},c.problem))})]}),(0,a.jsxs)("section",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)("h3",{className:"text-body font-semibold",children:"Recent runs"}),o.runs.length===0?(0,a.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"No scripts, sorts or updates have run in this period."}):(0,a.jsx)("ul",{className:"flex flex-col gap-1.5",children:o.runs.map(c=>{let p=`${c.card}:${c.entry}`;return(0,a.jsxs)("li",{className:"rounded-md border px-2.5 py-2 text-[12.5px]","data-run":p,children:[(0,a.jsxs)("button",{type:"button",className:"flex w-full items-start gap-2 text-left",onClick:()=>{u(c.card,c.entry)},"aria-expanded":l?.key===p,children:[(0,a.jsx)("span",{className:xe("mt-1 size-2 shrink-0 rounded-full",c.state==="passed"?"bg-success":c.state==="failed"?"bg-destructive":"bg-info"),"aria-hidden":"true"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"font-medium",children:c.script??c.zoneTitle})," · ",c.cardTitle,(0,a.jsxs)("span",{className:"block text-caption text-muted-foreground font-normal",children:[c.kind==="sort"&&c.state==="passed"&&c.result!==null?c.result.split(". ")[0].replace(/\.$/,""):c.state==="passed"?"Passed":c.state==="failed"?"Failed":c.state==="waiting"?"Trying again":"Running",c.durationMs===null?"":c.kind==="sort"?` · ${c.durationMs<1e3?`${c.durationMs} ms`:`${(c.durationMs/1e3).toFixed(1)} s`}`:` in ${Math.max(1,Math.round(c.durationMs/1e3))} s`," · ",an(c.at)]})]})]}),l?.key===p&&(0,a.jsx)("pre",{className:"mt-2 max-h-72 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-2 font-mono text-[11.5px]","data-run-log":!0,children:l.text})]},p)})})]})]})]})}var Ps="(max-width: 760px)";function V0(){let[e,t]=(0,D.useState)(()=>pr(Ps));return(0,D.useEffect)(()=>{let n=window.matchMedia(Ps),o=()=>t(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var Gn={min:.4,max:2.5},ta=300;function H0(e,t,n){let o=0;return Pl(e,t).map(r=>{let s=Math.min(360,64+Math.max(1,n(r.id))*64),i={...r,zone:{...r.zone,x:0,y:o,w:ta,h:s}};return o+=s+64,i})}function F0({onExpand:e}){let t=Dt(),{zoom:n}=ug();return(0,a.jsxs)("div",{className:"fl-zoom nodrag nopan",role:"toolbar","aria-label":"Zoom",children:[(0,a.jsx)(he,{variant:"outline",sm:!0,iconOnly:"minus",label:"Zoom out (−)",onClick:()=>{t.zoomOut({duration:160})},disabled:n<=Gn.min+.001}),(0,a.jsxs)("span",{className:"fl-zoom-n k-num","aria-live":"polite",children:[Math.round(n*100),"%"]}),(0,a.jsx)(he,{variant:"outline",sm:!0,iconOnly:"plus",label:"Zoom in (+)",onClick:()=>{t.zoomIn({duration:160})},disabled:n>=Gn.max-.001}),(0,a.jsx)(he,{variant:"outline",sm:!0,lead:"fit",label:"Fit",title:"Fit (0)",onClick:()=>{t.fitView({padding:.12,maxZoom:1,duration:160})}}),e!==void 0&&(0,a.jsx)(he,{variant:"outline",sm:!0,label:"Expand","aria-label":"Expand the canvas to the full screen","data-flow-expand":!0,onClick:o=>e(o.currentTarget)})]})}function W0(e){let{view:t,editing:n,vertical:o,expanded:r}=e,s=Dt(),i=(0,D.useRef)(null),l=(0,D.useCallback)(g=>t.cards.filter(N=>N.stage===g&&N.state==="active"&&(!e.mineOnly||N.mine)).length,[t.cards,e.mineOnly]),h=(0,D.useMemo)(()=>o?H0(e.stages,e.start,l):e.stages,[o,e.stages,e.start,l]),u=e.start,c=(g,N)=>e.setDraft(k=>k===null?k:{...k,stages:k.stages.map(z=>z.id===g?{...z,...N}:z)}),p=(0,D.useMemo)(()=>h.map(g=>({id:g.id,type:"zone",position:{x:g.zone.x,y:g.zone.y},width:g.zone.w,height:g.zone.h,style:{width:g.zone.w,height:g.zone.h},draggable:n,selectable:n,data:{stage:g,kindLabel:t.kinds.find(N=>N.kind===g.kind)?.label??g.kind,owner:e.owner,subagent:g.subagent===void 0?null:t.subagents?.find(N=>N.handle===g.subagent)?.name??g.subagent,cards:t.cards.filter(N=>N.stage===g.id&&N.state==="active"&&(!e.mineOnly||N.mine)),hidden:e.mineOnly?t.cards.filter(N=>N.stage===g.id&&N.state==="active"&&!N.mine).length:0,lookers:e.lookers,editing:n,canMove:t.canEdit&&!o,start:g.id===u,selectedCard:e.selectedCard,onCard:e.onCard,onDrop:e.onDrop,onResize:(N,k)=>e.setDraft(z=>z===null?z:{...z,stages:z.stages.map(A=>A.id===N?{...A,zone:{...A.zone,x:Math.round(k.x),y:Math.round(k.y),w:Math.round(k.width),h:Math.round(k.height)}}:A)}),browserLine:g.kind==="check"&&g.browser===!0&&t.browser!=null&&t.browser.status!=="allowed"?"Starts a browser · not allowed":null}})),[h,t,n,u,e.mineOnly,e.lookers,e.selectedCard,e.owner,e.onCard,e.onDrop,e.setDraft,o]),d=(0,D.useMemo)(()=>t.triggers.filter(g=>g.state!=="removed"),[t.triggers]),m=(0,D.useMemo)(()=>{if(o)return[];let g=new Map;for(let N of d){let k=h.some(z=>z.id===N.zoneId)?N.zoneId:u;g.set(k,[...g.get(k)??[],N])}return[...g].flatMap(([N,k])=>{let z=h.find($=>$.id===N);if(z===void 0)return[];let A=_l+k.length*zl;return[{id:`trigger-${N}`,type:"trigger",position:{x:z.zone.x-272,y:z.zone.y+Math.max(0,(z.zone.h-A)/2)},width:236,height:A,style:{width:236,height:A},draggable:!1,selectable:!1,data:{triggers:k,onOpen:e.onTriggers,onPress:e.onPress}}]})},[d,h,u,o,e.onTriggers,e.onPress]),f=(0,D.useMemo)(()=>[...p,...m],[p,m]),[w,y]=(0,D.useState)(f);(0,D.useEffect)(()=>{y(g=>f.map(N=>{let k=g.find(z=>z.id===N.id);return k===void 0?N:{...k,...N,...k.measured===void 0?{}:{measured:k.measured},selected:n&&k.selected===!0}}))},[f,n]);let x=(0,D.useMemo)(()=>{let g=$=>({x:$.zone.x+$.zone.w/2,y:$.zone.y+$.zone.h/2}),N=($,B,V)=>{let W=g($),J=g(B),X=J.x-W.x,Z=J.y-W.y,ee=Math.abs(X)>=Math.abs(Z);if(V){let Q=B.zone.x>=$.zone.x+$.zone.w||$.zone.x>=B.zone.x+B.zone.w,T=B.zone.y>=$.zone.y+$.zone.h||$.zone.y>=B.zone.y+B.zone.h;return Q&&T?X>=0?{source:"s-Right",target:"t-Left"}:{source:"s-Left",target:"t-Right"}:ee?{source:"s-Bottom",target:"t-Bottom"}:{source:"s-Left",target:"t-Left"}}return ee?X>=0?{source:"s-Right",target:"t-Left"}:{source:"s-Left",target:"t-Right"}:Z>=0?{source:"s-Bottom",target:"t-Top"}:{source:"s-Top",target:"t-Bottom"}},k={labelStyle:{fontSize:11,fontWeight:600,fill:"var(--so-ink)"},labelBgStyle:{fill:"var(--so-paper)"}},z={labelStyle:{fontSize:11,fill:"var(--so-muted)"},labelBgStyle:{fill:"var(--so-paper)"}},A=m.map($=>({id:`${$.id}->zone`,source:$.id,sourceHandle:"out",target:$.id.slice(8),targetHandle:"t-Left",type:"smoothstep",deletable:!1,markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:1.5}}));return Qg([...A,...h.flatMap($=>{let B=$.next===null?void 0:h.find(Z=>Z.id===$.next),V=$.onFail===null?void 0:h.find(Z=>Z.id===$.onFail),W=$.limit?.to==null?void 0:h.find(Z=>Z.id===$.limit.to),J=$.kind==="sort"&&$.sort!==null?$.sort.answers:$.kind==="check"||$.kind==="subagent"?$.routes??[]:$.kind==="choose"?($.options??[]).filter(Z=>Z.to!=="end").map(Z=>({answer:Z.label,to:Z.to})):[],X=J.length>0?[...new Set(J.map(Z=>Z.to))].flatMap(Z=>{let ee=h.find(T=>T.id===Z);if(ee===void 0)return[];let Q=ee.zone.x>$.zone.x+$.zone.w?{source:"s-Right",target:"t-Left"}:N($,ee,!1);return[{id:`${$.id}->answer-${Z}`,source:$.id,target:Z,sourceHandle:Q.source,targetHandle:Q.target,type:"smoothstep",label:J.filter(T=>T.to===Z).map(T=>T.answer).join(", "),...k,markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:2},deletable:!1}]}):[];return[...X,...B===void 0?[]:[{id:`${$.id}->next`,source:$.id,target:B.id,sourceHandle:N($,B,!1).source,targetHandle:N($,B,!1).target,type:"smoothstep",markerEnd:{type:Xe.ArrowClosed},style:{strokeWidth:2},deletable:n,...$.kind==="wait"&&$.wait?.for==="reply"?{label:"replied",...k}:{}}],...V===void 0||!n&&X.some(Z=>Z.target===V.id)?[]:[{id:`${$.id}->fail`,source:$.id,target:V.id,sourceHandle:N($,V,!0).source,targetHandle:N($,V,!0).target,type:"smoothstep",pathOptions:{offset:28,borderRadius:10},label:$.kind==="approval"?"sent back":$.kind==="sort"?"not sure":$.kind==="wait"?"no reply":$.kind==="choose"?"reply":"fails",...z,markerEnd:{type:Xe.ArrowClosed,color:"var(--so-muted)"},style:{strokeWidth:1.5,strokeDasharray:"6 4",stroke:"var(--so-muted)"},deletable:n}],...W===void 0||$.limit===void 0?[]:[{id:`${$.id}->limit`,source:$.id,target:W.id,sourceHandle:N($,W,!0).source,targetHandle:N($,W,!0).target,type:"smoothstep",pathOptions:{offset:36,borderRadius:10},label:`after ${n0($.limit.minutes)}`,...z,markerEnd:{type:Xe.ArrowClosed,color:"var(--so-muted)"},style:{strokeWidth:1.5,strokeDasharray:"2 4",stroke:"var(--so-muted)"},deletable:n}]]})],h)},[h,n,m]),E=g=>{if(y(N=>Ki(g,N)),!!n)for(let N of g)N.type==="select"&&N.selected&&!N.id.startsWith("trigger-")&&e.onZone(N.id)},v=(g,N)=>{!n||N.type!=="zone"||e.setDraft(k=>k===null?k:{...k,stages:k.stages.map(z=>z.id===N.id?{...z,zone:{...z.zone,x:Math.round(N.position.x),y:Math.round(N.position.y)}}:z)})},b=g=>{if(!n||g.source===g.target)return;let N=h.find(k=>k.id===g.source);if(N?.kind==="sort"&&N.sort!==null&&g.sourceHandle!=="fail"){let k=h.find(z=>z.id===g.target);k!==void 0&&N.sort.answers.length<12&&c(N.id,{sort:{...N.sort,answers:[...N.sort.answers,{answer:k.title.slice(0,40),means:k.title,to:k.id}]}}),e.onZone(N.id);return}if(N?.kind==="choose"&&g.sourceHandle!=="fail"){let k=h.find(z=>z.id===g.target);k!==void 0&&(N.options??[]).length<4&&c(N.id,{options:[...N.options??[],{label:k.title.slice(0,40),to:k.id}]}),e.onZone(N.id);return}c(g.source,g.sourceHandle==="fail"?{onFail:g.target}:{next:g.target})},j=(0,D.useRef)(null),S=o?"v":"d";(0,D.useEffect)(()=>{if(j.current===S)return;j.current=S;let g=requestAnimationFrame(()=>{if(!o){s.fitView({padding:.12,maxZoom:1});return}let N=i.current?.querySelector(".fl-vp")?.clientWidth??360;s.setViewport({x:Math.max(8,(N-ta)/2),y:16,zoom:1})});return()=>cancelAnimationFrame(g)},[S,o,s]);let M=(0,D.useRef)(e.onCollapse);M.current=e.onCollapse;let C=e.covered===!0,_=(0,D.useRef)(!1);(0,D.useLayoutEffect)(()=>{let g=i.current;if(!r||C||g===null)return;let N=!1,k=()=>{g.hidden=!1,g.removeAttribute("role"),g.removeAttribute("aria-modal"),g.removeAttribute("tabindex")},z=document.activeElement,A=tr(g,null,{dim:!1,onClose:$=>{N=!0,k(),$!=="close"&&M.current?.()}});return g.setAttribute("aria-label",`${e.name}, full screen`),_.current&&z instanceof HTMLElement&&g.contains(z)?z.focus({preventScroll:!0}):g.querySelector("[data-flow-collapse]")?.focus(),_.current=!0,()=>{N||A(),k(),g.removeAttribute("aria-label")}},[r,C,e.name]),(0,D.useEffect)(()=>{r||(_.current=!1)},[r]);let F=(0,D.useRef)(r);(0,D.useEffect)(()=>{if(!o||F.current===r)return;F.current=r;let g=window.setTimeout(()=>{let{y:N,zoom:k}=s.getViewport(),z=i.current?.querySelector(".fl-vp")?.clientWidth??360;s.setViewport({x:Math.max(8,(z-ta*k)/2),y:N,zoom:k})},60);return()=>window.clearTimeout(g)},[r,o,s]);let O=o?"":d.map(g=>`${g.id}:${g.zoneId}`).join(","),R=(0,D.useRef)(O);(0,D.useEffect)(()=>{if(R.current===O)return;R.current=O;let g=requestAnimationFrame(()=>{s.fitView({padding:.12,maxZoom:1,duration:160})});return()=>cancelAnimationFrame(g)},[O,s]);let H=g=>{if(g.target!==g.currentTarget)return;let N=48,{x:k,y:z,zoom:A}=s.getViewport();if(g.key==="+"||g.key==="=")s.zoomIn({duration:160});else if(g.key==="-"||g.key==="_")s.zoomOut({duration:160});else if(g.key==="0")s.fitView({padding:.12,maxZoom:1,duration:160});else if(g.key.startsWith("Arrow"))s.setViewport({x:k+(g.key==="ArrowLeft"?N:g.key==="ArrowRight"?-N:0),y:z+(g.key==="ArrowUp"?N:g.key==="ArrowDown"?-N:0),zoom:A});else return;g.preventDefault()};return(0,a.jsxs)("div",{ref:i,className:xe("fl-canvas",o&&"column",r&&"expanded",r&&C&&"covered",n&&"editing"),"data-flow-canvas":!0,children:[r&&(0,a.jsxs)("div",{className:"fl-xbar",children:[(0,a.jsx)("b",{children:e.name}),(0,a.jsx)("span",{className:"k-note",children:"Drag to move · pinch to zoom"}),(0,a.jsx)("span",{className:"k-grow"}),(0,a.jsx)(he,{variant:"primary",label:"Done","data-flow-collapse":!0,onClick:()=>e.onCollapse?.()})]}),(0,a.jsxs)("div",{className:"fl-vp",tabIndex:0,role:"group","aria-roledescription":"canvas",onKeyDown:H,"aria-label":`${e.name}: its zones and cards. Drag to move, pinch or press + and − to zoom, 0 to fit.`,children:[(0,a.jsx)(ig,{nodes:w,edges:x,nodeTypes:Ug,edgeTypes:Jg,onNodesChange:E,onNodeDragStop:v,onConnect:b,onEdgesDelete:g=>{for(let N of g)c(N.source,N.id.endsWith("->fail")?{onFail:null}:N.id.endsWith("->limit")?{limit:{...h.find(k=>k.id===N.source)?.limit??{minutes:1440},to:null}}:{next:null})},onPaneClick:()=>{n&&e.onZone(null)},onNodeClick:()=>{},fitView:!0,fitViewOptions:{padding:.14,maxZoom:1},nodesDraggable:n,nodesConnectable:n,elementsSelectable:n,minZoom:Gn.min,maxZoom:Gn.max,zoomOnScroll:!1,zoomActivationKeyCode:["Meta","Control"],zoomOnPinch:!0,zoomOnDoubleClick:!n,panOnDrag:!0,preventScrolling:!1,proOptions:{hideAttribution:!0},deleteKeyCode:n?["Backspace","Delete"]:null,children:(0,a.jsx)(gg,{variant:Ue.Dots,gap:20,size:1,color:"var(--so-line)"})}),(0,a.jsx)(F0,{...o&&!r&&e.onExpand!==void 0?{onExpand:e.onExpand}:{}})]}),n&&(0,a.jsx)("p",{className:"fl-hint k-note",children:"Drag zones to arrange them. Drag from a zone's right dot to say where work goes next, from its bottom dot for where it goes if sent back."})]})}function Z0(e){return e.state==="done"?(0,a.jsx)(Mo,{status:"finished"}):e.state==="cancelled"?(0,a.jsx)(Tt,{word:e.waiting==="Ignored"?"Ignored":"Cancelled",dot:!1}):e.canDecide||e.question?.mine===!0||e.choose?.mine===!0?(0,a.jsx)(Tt,{word:"Needs you",tone:"needs"}):e.waiting!==null?(0,a.jsx)(Tt,{word:"Waiting",dot:!1}):(0,a.jsx)(Mo,{status:"running"})}var Ye=e=>e.state==="active"&&(e.canDecide||e.question?.mine===!0||e.choose?.mine===!0),Y0=600,X0=e=>e===null?"":`${e.label}\0${JSON.stringify(e.data??{})}`;function q0(e,t=Y0){let n=X0(e),[o,r]=(0,D.useState)(n),s=(0,D.useRef)(e),i=n===o||o==="";i&&(s.current=e),(0,D.useEffect)(()=>{if(n===o)return;let d=setTimeout(()=>r(n),o===""?0:t);return()=>clearTimeout(d)},[n,o,t]);let l=i?e:s.current,h=(0,D.useRef)(null),u=()=>{h.current=l},c=d=>{let m=d.detail>0&&h.current!==null?h.current:l;h.current=null,m?.act(d.currentTarget)},p=i||e===null?"":`${e.label} is next.`;return{shown:l,onPointerDown:u,run:c,said:p}}function Vo({outcome:e}){return e===null?null:e.ok?(0,a.jsx)("p",{className:"k-note fl-outcome",role:"status","data-flow-outcome":!0,children:e.said}):(0,a.jsx)(Sn,{children:e.said})}function qy({view:e,csrf:t}){let n=V0(),[o,r]=(0,D.useState)(e),[s,i]=(0,D.useState)(null),l=(0,D.useCallback)(P=>{i({ok:P.ok,said:P.said}),P.view!==void 0&&r(P.view)},[]),[h,u]=(0,D.useState)(()=>e.selectedCard!==null?{open:{card:e.selectedCard},from:null}:e.startTrigger!==null&&e.triggers.some(P=>P.id===e.startTrigger&&P.button!==null)?{open:{press:e.startTrigger},from:null}:null),c=(0,D.useCallback)((P,G)=>{i(null),u({open:P,from:G})},[]),p=(0,D.useCallback)(()=>u(null),[]),[d,m]=(0,D.useState)("steps"),[f,w]=(0,D.useState)("list"),[y,x]=(0,D.useState)(!1),E=(0,D.useRef)(null),[v,b]=(0,D.useState)(!1),[j,S]=(0,D.useState)(null),[M,C]=(0,D.useState)(null),[_,F]=(0,D.useState)(!1),[O,R]=er(()=>!1,()=>{try{return window.localStorage.getItem("so-flows-mine")==="1"}catch{return!1}});(0,D.useEffect)(()=>{try{window.localStorage.setItem("so-flows-mine",O?"1":"0")}catch{}},[O]);let H=or(),g=P0(o.browser),N=h!==null&&"card"in h.open?h.open.card:null,k=Yg(o,r,{card:N,editing:v}),z=(0,D.useMemo)(()=>{let P={};for(let G of k)if(!G.editing)for(let ae of G.cards)(P[ae]??=[]).push(G.name);return P},[k]),A=(0,D.useCallback)(async(P,G)=>{let ae=o.cards.find(ze=>ze.id===P);ae===void 0||ae.stage===G||l(await me(`${o.flow.href}/cards/${P}/move`,{stage:G},t))},[o,t,l]),$=(0,D.useCallback)((P,G)=>c({card:P},G),[c]),B=(0,D.useCallback)((P,G)=>c({triggers:P},G),[c]),V=(0,D.useCallback)((P,G)=>c({press:P},G),[c]),W=(0,D.useCallback)(P=>S(P),[]);(0,D.useEffect)(()=>{e.browser!=null&&Zg()&&document.getElementById("fl-browser")?.scrollIntoView({block:"center"})},[e.browser]),(0,D.useEffect)(()=>(document.documentElement.classList.toggle("fl-locked",y),()=>document.documentElement.classList.remove("fl-locked")),[y]),(0,D.useEffect)(()=>{n||x(!1)},[n]);let J=(0,D.useCallback)(()=>x(!1),[]),X=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(y){X.current=!0;return}X.current&&(X.current=!1,document.querySelector("[data-flow-expand]")?.focus({preventScroll:!0}))},[y]);let Z=o.triggers.filter(P=>P.state!=="removed"),ee=j?.stages??o.stages,Q=j?.start??o.start,T=j!==null&&JSON.stringify({name:j.name,start:j.start,stages:j.stages,owner:j.owner})!==JSON.stringify({name:o.flow.name,start:o.start,stages:o.stages,owner:o.flow.owner}),K=()=>{S({name:o.flow.name,start:o.start,stages:o.stages,owner:o.flow.owner}),b(!0),C(null),p(),m("steps")},oe=()=>{S(null),b(!1),C(null)},ie=async()=>{if(j===null||_)return;F(!0);let P=await me(`${o.flow.href}/save`,{name:j.name,owner:j.owner,revision:String(o.flow.revision),definition:JSON.stringify({version:1,start:j.start,stages:j.stages})},t);F(!1),l(P),P.ok&&oe()},q=(0,D.useRef)(null),se=()=>{if(j===null)return;let P=new Set(j.stages.map(ze=>ze.id)),G=q.current?.center()??{x:0,y:0},ae={id:e0("New zone",P),title:"New zone",kind:"inbox",zone:{x:Math.round(G.x-140),y:Math.round(G.y-120),w:280,h:300,color:"slate"},instructions:null,planning:null,approver:null,message:null,close:null,script:null,sort:null,next:null,onFail:null};S({...j,stages:[...j.stages,ae]}),C(ae.id)},re=(P,G)=>S(ae=>ae===null?ae:{...ae,stages:ae.stages.map(ze=>ze.id===P?{...ze,...G}:ze)}),le=o.cards.filter(P=>P.state==="active"),ce=le.filter(Ye),ge=[...o.cards].sort((P,G)=>Date.parse(G.updatedAt)-Date.parse(P.updatedAt))[0],je=P=>o.stages.find(G=>G.id===P)?.title??P,Ee=ce.length>0?ce.length===1?`A card waits for you in ${je(ce[0].stage)}`:`${ce.length} cards wait for you`:le.length>0?`${le.length} card${le.length===1?"":"s"} in progress`:o.cards.length>0?"Nothing in progress":"No cards yet",Me=o.browser!=null&&o.browser.status!=="allowed",be=Z.find(P=>P.button!==null&&P.state==="active"),Pe=Z.find(P=>P.kind==="schedule"&&P.checkable&&P.state==="active"),[Be,Ve]=(0,D.useState)(!1),Se=async()=>{Pe===void 0||Be||(Ve(!0),l(await me(`${o.flow.href}/triggers/${Pe.id}/check`,{},t)),Ve(!1))},Ae=v?null:ce.length>0?{label:ce.length===1?"Review":`Review ${ce.length}`,act:P=>c({card:ce[0].id},P),data:{"data-flow-review":""}}:Me&&o.canEdit&&o.browser?.canApprove!==!1?null:be!==void 0?{label:be.button.label,act:P=>c({press:be.id},P),data:{"data-flow-press":String(be.id)}}:Pe!==void 0&&o.canEdit?{label:"Run now",busy:Be?"Starting…":!1,act:()=>{Se()},data:{"data-flow-run-now":""}}:o.canEdit?{label:"New card",act:P=>c({newCard:!0},P),data:{"data-flow-new-card":""}}:null,Ne=q0(Ae),we=Ne.shown,vt=P=>we===null?null:(0,a.jsx)(he,{variant:"primary",sm:P,label:we.label,busy:we.busy??!1,...we.data,...we.label==="New card"?{lead:"plus"}:{},onPointerDown:Ne.onPointerDown,onClick:G=>Ne.run(G)}),Rt=P=>H(P,n?o.flow.name:"More",[...n?[{label:"Triggers",act:()=>c({triggers:null},P)},{label:"Scripts",act:()=>c({scripts:!0},P)}]:[],...o.canEdit&&!n?[{label:"Edit flow",act:K}]:[],...o.canEdit&&we?.label!=="New card"?[{label:"New card",act:()=>c({newCard:!0},P)}]:[],...o.canEdit&&o.unattended.scheduled&&o.unattended.active===null?[{label:"Run on its own…",act:()=>c({unattended:!0},P)}]:[],...o.canEdit?[{label:"Change it in chat",act:()=>{window.location.assign(o.chatHref)}}]:[],{label:"Export as a file",act:()=>{window.location.assign(`${o.flow.href}/export`)}}]),pn=(0,a.jsx)(bn,{label:"View",current:d,onChange:P=>m(P),items:[{key:"steps",label:"Steps"},{key:"runs",label:"Runs",count:(0,a.jsx)(bt,{n:o.cards.length})}]}),mn=(P={})=>(0,a.jsx)(he,{variant:"ghost",iconOnly:"more",label:"More",sm:P.sm===!0,"aria-haspopup":"dialog","data-flow-menu":!0,onClick:G=>Rt(G.currentTarget)}),lo=v&&j!==null?(0,a.jsxs)("div",{className:"k-tb fl-edit-tb",children:[(0,a.jsx)(wn,{value:j.name,onChange:P=>S({...j,name:P.target.value}),maxLength:80,"aria-label":"Flow name",className:"fl-name"}),(0,a.jsxs)("label",{className:"fl-owner",children:[(0,a.jsx)("span",{className:"k-note",children:"Owner"}),(0,a.jsx)(jn,{sm:!0,value:j.owner,onChange:P=>S({...j,owner:P.target.value}),"aria-label":"Flow owner",items:[...new Set([j.owner,...o.approvers])].map(P=>[P,P===o.me?`${P} (you)`:P])})]}),(0,a.jsx)("span",{className:"k-grow"}),(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"code",label:"Scripts",onClick:P=>c({scripts:!0},P.currentTarget)}),(0,a.jsx)(he,{sm:!0,lead:"plus",label:"Add zone",onClick:se}),(0,a.jsx)(he,{variant:"ghost",sm:!0,label:"Discard",onClick:oe}),(0,a.jsx)(he,{variant:"primary",sm:!0,label:"Save flow",busy:_?"Saving…":!1,disabled:!T,onClick:()=>{ie()}})]}):(0,a.jsx)(xr,{title:o.flow.name,back:"/flows",ctx:o.flow.project,right:(0,a.jsxs)(a.Fragment,{children:[pn,o.canEdit&&(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"bolt",label:Z.length>0?`Triggers · ${Z.length}`:"Triggers","data-open-triggers":!0,onClick:P=>c({triggers:null},P.currentTarget)}),(0,a.jsx)(he,{variant:"ghost",sm:!0,lead:"code",label:"Scripts","data-open-scripts":!0,onClick:P=>c({scripts:!0},P.currentTarget)}),mn({sm:!0}),vt(!0)]}),trailing:mn()}),co=ge===void 0?null:(0,a.jsxs)("p",{className:"fl-latest",children:[(0,a.jsx)("span",{className:xe("fl-dot",Ye(ge)?"wait":ge.state==="done"?"ok":ge.state==="active"&&ge.waiting===null?"run":"idle"),"aria-hidden":"true"}),(0,a.jsxs)("span",{children:[ge.title," · ",ge.state==="active"?`in ${je(ge.stage)}${ge.waiting!==null?`: ${ge.waiting}`:""}`:ge.state==="done"?"done":"cancelled"]}),(0,a.jsx)("span",{className:"fl-when k-num",children:an(ge.updatedAt)})]}),fn=Z.find(P=>P.state==="active")??Z[0],uo=(0,a.jsxs)("div",{className:"fl-head",children:[(0,a.jsx)("h2",{className:"fl-lead",children:Ee}),(0,a.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite","data-flow-primary-said":!0,children:Ne.said}),co,(0,a.jsxs)("p",{className:"fl-meta",children:[(0,a.jsx)("span",{className:"fl-meta-item",children:fn===void 0?"Cards are added by hand":fn.words}),(0,a.jsxs)("span",{className:"fl-meta-item",children:["owner ",o.flow.owner]}),(0,a.jsx)(z0,{view:o,csrf:t,apply:l}),(0,a.jsx)(_0,{view:o,csrf:t,apply:l}),(0,a.jsx)(Xg,{others:k,cards:o.cards})]}),h===null&&(0,a.jsx)(Vo,{outcome:s})]}),Je=[...o.cards].sort((P,G)=>Number(Ye(G))-Number(Ye(P))||Date.parse(G.updatedAt)-Date.parse(P.updatedAt)),gn=P=>(0,a.jsx)("div",{className:"fl-rowwrap","data-card-row":P.id,onClick:G=>{let ae=G.target.closest("a.k-row-t");ae!==null&&(G.preventDefault(),c({card:P.id},ae))},children:(0,a.jsx)(gr,{href:`${o.flow.href}?card=${P.id}`,chip:Z0(P),title:P.title,wait:Ye(P),desc:P.state==="active"?`In ${je(P.stage)}${P.waiting!==null?` · ${P.waiting}`:""}`:P.history.at(-1)?.text??(P.state==="done"?"Finished":"Cancelled"),meta:(0,a.jsx)("span",{className:"k-num",children:an(P.updatedAt)}),action:Ye(P)?(0,a.jsx)(he,{sm:!0,label:"Review",onClick:G=>c({card:P.id},G.currentTarget)}):void 0})},P.id),ho=Je.length===0?null:(0,a.jsxs)("div",{className:"fl-recent","aria-label":"Recent runs",children:[(0,a.jsx)(zo,{label:"Recent runs",count:(0,a.jsx)(bt,{n:Je.length})}),Je.slice(0,3).map(gn),Je.length>3&&(0,a.jsx)("p",{className:"fl-more-runs",children:(0,a.jsx)(he,{variant:"ghost",sm:!0,label:`See all ${Je.length} runs`,onClick:()=>m("runs")})})]}),po=(0,a.jsx)("div",{className:"fl-list","data-flow-list":!0,children:Pl(o.stages,o.start).map(P=>{let G=o.cards.filter(ae=>ae.stage===P.id&&ae.state==="active");return(0,a.jsxs)("section",{className:"fl-step","data-step":P.id,"aria-label":P.title,children:[(0,a.jsxs)("header",{className:"fl-step-h",children:[(0,a.jsx)("span",{className:"fl-ico",style:{color:At[P.zone.color]??At.slate},children:El[P.kind]}),(0,a.jsxs)("span",{className:"fl-step-t",children:[(0,a.jsx)("b",{children:P.title}),(0,a.jsxs)("span",{className:"k-note",children:[o.kinds.find(ae=>ae.kind===P.kind)?.label??P.kind,P.id===o.start?" · new cards start here":""]})]}),G.length>0&&(0,a.jsx)(bt,{n:G.length,ink:G.some(Ye)})]}),P.kind==="check"&&P.browser===!0&&Me&&(0,a.jsx)("p",{className:"fl-step-br k-note",children:"Starts a browser · not allowed"}),G.length>0&&(0,a.jsx)("ul",{className:"fl-cards",children:G.map(ae=>(0,a.jsx)("li",{children:(0,a.jsxs)("a",{href:`${o.flow.href}?card=${ae.id}`,className:xe("fl-card",Ye(ae)&&"wait"),"data-card":ae.id,onClick:ze=>{ze.preventDefault(),$(ae.id,ze.currentTarget)},children:[(0,a.jsx)("span",{className:"fl-card-t",children:ae.title}),ae.sorted!==null&&(0,a.jsx)("span",{className:"fl-card-l",children:(0,a.jsx)(wa,{sorted:ae.sorted})}),ae.waiting!==null&&(0,a.jsx)("span",{className:xe("fl-card-l",Ye(ae)&&"mine"),children:ae.canDecide?xn.card.sentence({}):ae.question?.mine?`${ae.question.from.split(" · ")[0]} asks you`:ae.waiting})]})},ae.id))})]},P.id)})}),mo=(0,a.jsx)(W0,{view:o,stages:ee,start:Q,owner:j?.owner??o.flow.owner,editing:v,vertical:n,expanded:y,mineOnly:O,selectedCard:N,lookers:z,onCard:$,onDrop:(P,G)=>{A(P,G)},onTriggers:B,onPress:V,onZone:C,setDraft:W,name:o.flow.name,covered:h!==null,onExpand:P=>{E.current=P,x(!0)},onCollapse:J}),fo=o.cards.some(P=>P.state==="active"&&!P.mine),go=(0,a.jsxs)(a.Fragment,{children:[n&&(0,a.jsx)("div",{className:"fl-viewsw",children:(0,a.jsx)(bn,{label:"Layout",current:f,onChange:P=>{w(P),x(!1)},items:[{key:"list",label:"List"},{key:"canvas",label:"Canvas"}]})}),!n&&!v&&fo&&(0,a.jsx)("div",{className:"fl-filter",children:(0,a.jsx)(bn,{label:"Which cards",current:O?"mine":"all",onChange:P=>R(P==="mine"),items:[{key:"all",label:"All cards"},{key:"mine",label:"Mine"}]})}),(0,a.jsxs)("div",{className:xe("fl-stage",v&&M!==null&&"with-aside"),children:[n&&f==="list"?po:(0,a.jsxs)(jl,{children:[(0,a.jsx)(U0,{api:q}),mo]}),v&&M!==null&&j!==null&&(()=>{let P=j.stages.find(G=>G.id===M);return P===void 0?null:(0,a.jsx)("aside",{className:"fl-aside","data-flow-drawer":!0,children:(0,a.jsx)(y0,{stage:P,stages:j.stages,view:o,csrf:t,apply:l,update:G=>re(P.id,G),remove:()=>{S(G=>G===null?G:{...G,start:G.start===P.id?G.stages.find(ae=>ae.id!==P.id).id:G.start,stages:G.stages.filter(ae=>ae.id!==P.id).map(ae=>({...ae,next:ae.next===P.id?null:ae.next,onFail:ae.onFail===P.id?null:ae.onFail}))}),C(null)},makeStart:()=>S(G=>G===null?G:{...G,start:P.id}),onClose:()=>C(null)})})})()]}),!v&&ho]}),xo=(0,a.jsxs)("div",{className:"fl-runs",children:[o.cards.length===0?(0,a.jsx)(mr,{title:"This flow hasn't run yet.",text:be!==void 0?`It runs when someone presses ${be.button.label}.`:Pe!==void 0?`It runs ${Pe.words.replace(/^./,P=>P.toLowerCase())}, or press Run now.`:"It runs when its trigger fires, or add a card by hand."}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(zo,{label:"Runs",count:(0,a.jsx)(bt,{n:o.cards.length})}),Je.map(gn)]}),(0,a.jsx)("section",{className:"fl-insights",children:(0,a.jsx)(B0,{view:o})})]}),Ot=h!==null&&"card"in h.open?o.cards.find(P=>P.id===h.open.card)??null:null,yt=h!==null&&"press"in h.open?o.triggers.find(P=>P.id===h.open.press&&P.button!==null)??null:null,Lt=h===null?null:Ot!==null?{title:Ot.title,body:(0,a.jsx)(d0,{card:Ot,view:o,csrf:t,apply:l,onAllowBrowser:()=>{p(),requestAnimationFrame(()=>{let P=document.getElementById("fl-browser");P?.scrollIntoView({block:"center"}),P?.querySelector(".k-btn-primary")?.focus({preventScroll:!0})})}})}:yt!==null?{title:yt.button.label,body:(0,a.jsx)(O0,{trigger:yt,view:o,csrf:t,apply:l,onDone:p},yt.id)}:"triggers"in h.open?{title:"Triggers",body:(0,a.jsx)(R0,{view:o,csrf:t,apply:l,focus:h.open.triggers,onPress:P=>c({press:P},h.from)})}:"scripts"in h.open?{title:"Scripts",body:(0,a.jsx)(L0,{view:o,csrf:t,apply:l})}:"unattended"in h.open?{title:"Run on its own",body:(0,a.jsx)(D0,{view:o,csrf:t,apply:l,onSigned:p})}:"newCard"in h.open?{title:"New card",body:(0,a.jsx)(j0,{view:o,csrf:t,apply:P=>{l(P),P.ok&&p()}})}:null;return(0,a.jsxs)("div",{className:"fl-page","data-kit-page":!0,"data-flow":o.flow.id,children:[lo,n&&!v&&(0,a.jsx)("div",{className:"fl-phonebar",children:pn}),!v&&uo,v&&(0,a.jsx)(Vo,{outcome:s}),!v&&(0,a.jsx)(A0,{view:o,csrf:t,apply:l,phone:n,...g}),(0,a.jsx)("div",{className:"fl-body",children:d==="runs"&&!v?xo:go}),n&&!v&&we!==null&&!(Me&&o.canEdit)&&(0,a.jsx)($o,{children:vt(!1)}),n&&!v&&Me&&o.canEdit&&o.browser?.canApprove!==!1&&!g.moved&&g.frozen!==null&&(0,a.jsx)(K0,{view:o,csrf:t,apply:l,frozen:g.frozen}),Lt!==null&&(0,a.jsx)(nr,{kind:"drawer",title:Lt.title,trigger:h.from,onClose:p,children:(0,a.jsxs)("div",{"data-view":"flow-drawer",className:"fl-drawer-body",children:[(0,a.jsx)(Vo,{outcome:s}),Lt.body]})})]})}function K0({view:e,csrf:t,apply:n,frozen:o}){if(o.problem!==null||o.digest===null)return null;let r=o.digest;return(0,a.jsx)($o,{children:(0,a.jsx)(Na,{view:e,label:"Allow browser",busyLabel:"Allowing…",terms:`${e.flow.name} · ${o.zones.map(s=>`${s.title} runs ${s.script} v${s.version}`).join("; ")} · digest ${r.slice(0,12)}`,act:async s=>{let i=await me(`${e.flow.href}/browser`,{digest:r,password:s},t);return i.ok?(n(i),null):i.said}})})}function U0({api:e}){let t=Dt();return(0,D.useEffect)(()=>(e.current={center:()=>t.screenToFlowPosition({x:window.innerWidth/2,y:window.innerHeight/2})},()=>{e.current=null}),[t,e]),null}export{qy as FlowView,Y0 as PRIMARY_SETTLE_MS};
|
|
18
18
|
/*! Bundled license information:
|
|
19
19
|
|
|
20
20
|
use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
|