@withbuddi/buddi 0.1.0-pre.28 → 0.1.0-pre.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/extension/manifest.json +2 -2
- package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/cli/dist/args.d.ts +19 -3
- package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/args.js +19 -5
- package/node_modules/@buddi/cli/dist/args.js.map +1 -1
- package/node_modules/@buddi/cli/dist/commands.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/commands.js +80 -8
- package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
- package/node_modules/@buddi/cli/dist/dashboard-cmd.d.ts +3 -0
- package/node_modules/@buddi/cli/dist/dashboard-cmd.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/dashboard-cmd.js +63 -0
- package/node_modules/@buddi/cli/dist/dashboard-cmd.js.map +1 -1
- package/node_modules/@buddi/cli/dist/doctor-probes.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/doctor-probes.js +11 -4
- package/node_modules/@buddi/cli/dist/doctor-probes.js.map +1 -1
- package/node_modules/@buddi/cli/dist/doctor.d.ts +1 -1
- package/node_modules/@buddi/cli/dist/doctor.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/jobs-cmd.d.ts +4 -0
- package/node_modules/@buddi/cli/dist/jobs-cmd.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/jobs-cmd.js +53 -4
- package/node_modules/@buddi/cli/dist/jobs-cmd.js.map +1 -1
- package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/main.js +27 -2
- package/node_modules/@buddi/cli/dist/main.js.map +1 -1
- package/node_modules/@buddi/cli/dist/mcp/gateway-client.d.ts +19 -17
- package/node_modules/@buddi/cli/dist/mcp/gateway-client.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/mcp/gateway-client.js +128 -29
- package/node_modules/@buddi/cli/dist/mcp/gateway-client.js.map +1 -1
- package/node_modules/@buddi/cli/dist/mcp/tools.d.ts +6 -0
- package/node_modules/@buddi/cli/dist/mcp/tools.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/mcp/tools.js +20 -1
- package/node_modules/@buddi/cli/dist/mcp/tools.js.map +1 -1
- package/node_modules/@buddi/cli/dist/telegram-cmd.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/telegram-cmd.js +5 -4
- package/node_modules/@buddi/cli/dist/telegram-cmd.js.map +1 -1
- package/node_modules/@buddi/core/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/core/dist/agents/catalog.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/agents/catalog.js +7 -6
- package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
- package/node_modules/@buddi/core/dist/agents/frontmatter.d.ts +12 -12
- package/node_modules/@buddi/core/dist/agents/skills.d.ts +2 -2
- package/node_modules/@buddi/core/dist/clock-widget.d.ts +38 -0
- package/node_modules/@buddi/core/dist/clock-widget.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/clock-widget.js +114 -0
- package/node_modules/@buddi/core/dist/clock-widget.js.map +1 -0
- package/node_modules/@buddi/core/dist/failures/owner-message.d.ts +25 -0
- package/node_modules/@buddi/core/dist/failures/owner-message.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/failures/owner-message.js +90 -0
- package/node_modules/@buddi/core/dist/failures/owner-message.js.map +1 -1
- package/node_modules/@buddi/core/dist/feedback/index.d.ts +23 -2
- package/node_modules/@buddi/core/dist/feedback/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/feedback/index.js +23 -3
- package/node_modules/@buddi/core/dist/feedback/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/groups.d.ts +33 -0
- package/node_modules/@buddi/core/dist/groups.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/groups.js +76 -4
- package/node_modules/@buddi/core/dist/groups.js.map +1 -1
- package/node_modules/@buddi/core/dist/home.d.ts +5 -5
- package/node_modules/@buddi/core/dist/host/build.d.ts +19 -1
- package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/host/build.js +122 -2
- package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
- package/node_modules/@buddi/core/dist/host/types.d.ts +33 -0
- package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/index.d.ts +8 -0
- package/node_modules/@buddi/core/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/index.js +8 -0
- package/node_modules/@buddi/core/dist/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/lock.d.ts +82 -0
- package/node_modules/@buddi/core/dist/lock.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/lock.js +182 -0
- package/node_modules/@buddi/core/dist/lock.js.map +1 -0
- package/node_modules/@buddi/core/dist/metrics.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/metrics.js +4 -2
- package/node_modules/@buddi/core/dist/metrics.js.map +1 -1
- package/node_modules/@buddi/core/dist/onboarding/store.d.ts +5 -0
- package/node_modules/@buddi/core/dist/onboarding/store.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/onboarding/store.js +35 -5
- package/node_modules/@buddi/core/dist/onboarding/store.js.map +1 -1
- package/node_modules/@buddi/core/dist/onboarding/types.d.ts +10 -0
- package/node_modules/@buddi/core/dist/onboarding/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/onboarding/types.js +2 -0
- package/node_modules/@buddi/core/dist/onboarding/types.js.map +1 -1
- package/node_modules/@buddi/core/dist/owner-format.d.ts +14 -0
- package/node_modules/@buddi/core/dist/owner-format.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/owner-format.js +47 -0
- package/node_modules/@buddi/core/dist/owner-format.js.map +1 -0
- package/node_modules/@buddi/core/dist/owner-timezone.d.ts +46 -0
- package/node_modules/@buddi/core/dist/owner-timezone.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/owner-timezone.js +43 -0
- package/node_modules/@buddi/core/dist/owner-timezone.js.map +1 -0
- package/node_modules/@buddi/core/dist/pages.d.ts +13 -39
- package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages.js +12 -1
- package/node_modules/@buddi/core/dist/pages.js.map +1 -1
- package/node_modules/@buddi/core/dist/places.d.ts +110 -0
- package/node_modules/@buddi/core/dist/places.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/places.js +239 -0
- package/node_modules/@buddi/core/dist/places.js.map +1 -0
- package/node_modules/@buddi/core/dist/plugin/index.d.ts +9 -2
- package/node_modules/@buddi/core/dist/plugin/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/index.js +3 -0
- package/node_modules/@buddi/core/dist/plugin/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/requires.d.ts +75 -0
- package/node_modules/@buddi/core/dist/plugin/requires.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/plugin/requires.js +77 -0
- package/node_modules/@buddi/core/dist/plugin/requires.js.map +1 -0
- package/node_modules/@buddi/core/dist/plugin/uses.d.ts +1 -1
- package/node_modules/@buddi/core/dist/plugin/uses.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/uses.js +2 -0
- package/node_modules/@buddi/core/dist/plugin/uses.js.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/version.d.ts +1 -1
- package/node_modules/@buddi/core/dist/plugin/version.js +1 -1
- package/node_modules/@buddi/core/dist/queue/failures.d.ts +84 -0
- package/node_modules/@buddi/core/dist/queue/failures.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/queue/failures.js +195 -0
- package/node_modules/@buddi/core/dist/queue/failures.js.map +1 -0
- package/node_modules/@buddi/core/dist/queue/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/queue/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/queue/index.js +1 -0
- package/node_modules/@buddi/core/dist/queue/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/queue/jobs.d.ts +39 -3
- package/node_modules/@buddi/core/dist/queue/jobs.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/queue/jobs.js +54 -4
- package/node_modules/@buddi/core/dist/queue/jobs.js.map +1 -1
- package/node_modules/@buddi/core/dist/queue/retry-policy.d.ts +5 -0
- package/node_modules/@buddi/core/dist/queue/retry-policy.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/queue/retry-policy.js +19 -2
- package/node_modules/@buddi/core/dist/queue/retry-policy.js.map +1 -1
- package/node_modules/@buddi/core/dist/queue/types.d.ts +20 -0
- package/node_modules/@buddi/core/dist/queue/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/queue/types.js +17 -0
- package/node_modules/@buddi/core/dist/queue/types.js.map +1 -1
- package/node_modules/@buddi/core/dist/registry.d.ts +37 -2
- package/node_modules/@buddi/core/dist/registry.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/registry.js +137 -3
- package/node_modules/@buddi/core/dist/registry.js.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/enqueue.d.ts +71 -0
- package/node_modules/@buddi/core/dist/scheduler/enqueue.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/scheduler/enqueue.js +116 -0
- package/node_modules/@buddi/core/dist/scheduler/enqueue.js.map +1 -0
- package/node_modules/@buddi/core/dist/scheduler/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/scheduler/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/index.js +1 -0
- package/node_modules/@buddi/core/dist/scheduler/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/missions.d.ts +15 -0
- package/node_modules/@buddi/core/dist/scheduler/missions.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/missions.js +43 -4
- package/node_modules/@buddi/core/dist/scheduler/missions.js.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/types.d.ts +10 -0
- package/node_modules/@buddi/core/dist/scheduler/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/scheduler/types.js +3 -0
- package/node_modules/@buddi/core/dist/scheduler/types.js.map +1 -1
- package/node_modules/@buddi/core/dist/secrets/settings.d.ts +6 -6
- package/node_modules/@buddi/core/dist/secrets/settings.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/secrets/settings.js +23 -3
- package/node_modules/@buddi/core/dist/secrets/settings.js.map +1 -1
- package/node_modules/@buddi/core/dist/semver.d.ts +17 -0
- package/node_modules/@buddi/core/dist/semver.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/semver.js +130 -0
- package/node_modules/@buddi/core/dist/semver.js.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/digest.d.ts +8 -1
- package/node_modules/@buddi/core/dist/sentinels/digest.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/digest.js +10 -3
- package/node_modules/@buddi/core/dist/sentinels/digest.js.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/index.d.ts +1 -0
- package/node_modules/@buddi/core/dist/sentinels/index.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/index.js +1 -0
- package/node_modules/@buddi/core/dist/sentinels/index.js.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/mutes.d.ts +51 -0
- package/node_modules/@buddi/core/dist/sentinels/mutes.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/sentinels/mutes.js +86 -0
- package/node_modules/@buddi/core/dist/sentinels/mutes.js.map +1 -0
- package/node_modules/@buddi/core/dist/sentinels/run.d.ts +20 -5
- package/node_modules/@buddi/core/dist/sentinels/run.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/run.js +105 -42
- package/node_modules/@buddi/core/dist/sentinels/run.js.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/types.d.ts +165 -2
- package/node_modules/@buddi/core/dist/sentinels/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sentinels/types.js +126 -2
- package/node_modules/@buddi/core/dist/sentinels/types.js.map +1 -1
- package/node_modules/@buddi/core/dist/sources/run.d.ts +8 -0
- package/node_modules/@buddi/core/dist/sources/run.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sources/run.js +1 -1
- package/node_modules/@buddi/core/dist/sources/run.js.map +1 -1
- package/node_modules/@buddi/core/dist/sources/watch.d.ts +3 -0
- package/node_modules/@buddi/core/dist/sources/watch.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/sources/watch.js +1 -1
- package/node_modules/@buddi/core/dist/sources/watch.js.map +1 -1
- package/node_modules/@buddi/core/dist/time.d.ts +17 -3
- package/node_modules/@buddi/core/dist/time.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/time.js +27 -3
- package/node_modules/@buddi/core/dist/time.js.map +1 -1
- package/node_modules/@buddi/core/dist/tools.d.ts +30 -1
- package/node_modules/@buddi/core/dist/tools.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/tools.js.map +1 -1
- package/node_modules/@buddi/core/dist/views.d.ts +164 -164
- package/node_modules/@buddi/core/dist/views.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/views.js +5 -0
- package/node_modules/@buddi/core/dist/views.js.map +1 -1
- package/node_modules/@buddi/core/dist/widget-settings.d.ts +161 -0
- package/node_modules/@buddi/core/dist/widget-settings.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/widget-settings.js +314 -0
- package/node_modules/@buddi/core/dist/widget-settings.js.map +1 -0
- package/node_modules/@buddi/core/dist/widgets.d.ts +206 -0
- package/node_modules/@buddi/core/dist/widgets.d.ts.map +1 -0
- package/node_modules/@buddi/core/dist/widgets.js +247 -0
- package/node_modules/@buddi/core/dist/widgets.js.map +1 -0
- package/node_modules/@buddi/core/migrations/059_dashboard_lock.sql +33 -0
- package/node_modules/@buddi/core/migrations/060_owner_places.sql +30 -0
- package/node_modules/@buddi/core/migrations/061_owner_formats.sql +10 -0
- package/node_modules/@buddi/core/migrations/062_group_deleted.sql +7 -0
- package/node_modules/@buddi/core/migrations/063_provider_account_limits.sql +20 -0
- package/node_modules/@buddi/core/migrations/064_mission_coalesce.sql +12 -0
- package/node_modules/@buddi/core/migrations/065_api_tokens.sql +28 -0
- package/node_modules/@buddi/core/migrations/066_alert_decisions.sql +45 -0
- package/node_modules/@buddi/core/migrations/067_job_acknowledged.sql +21 -0
- package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/gateway/dist/account-limits.d.ts +45 -0
- package/node_modules/@buddi/gateway/dist/account-limits.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/account-limits.js +87 -0
- package/node_modules/@buddi/gateway/dist/account-limits.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/accounts-cli.d.ts +88 -0
- package/node_modules/@buddi/gateway/dist/accounts-cli.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/accounts-cli.js +216 -0
- package/node_modules/@buddi/gateway/dist/accounts-cli.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/agents/canvas.d.ts +20 -20
- package/node_modules/@buddi/gateway/dist/agents/learning-digest.d.ts +4 -0
- package/node_modules/@buddi/gateway/dist/agents/learning-digest.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/learning-digest.js +18 -5
- package/node_modules/@buddi/gateway/dist/agents/learning-digest.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/owner-tools.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/owner-tools.js +3 -2
- package/node_modules/@buddi/gateway/dist/agents/owner-tools.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents/platform.d.ts +24 -24
- package/node_modules/@buddi/gateway/dist/api-token-cli.d.ts +17 -0
- package/node_modules/@buddi/gateway/dist/api-token-cli.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/api-token-cli.js +108 -0
- package/node_modules/@buddi/gateway/dist/api-token-cli.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/bootstrap.d.ts +6 -2
- package/node_modules/@buddi/gateway/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/bootstrap.js +25 -7
- package/node_modules/@buddi/gateway/dist/bootstrap.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/conversations.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/conversations.js +8 -2
- package/node_modules/@buddi/gateway/dist/chat/conversations.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/session.d.ts +5 -0
- package/node_modules/@buddi/gateway/dist/chat/session.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/session.js +11 -1
- package/node_modules/@buddi/gateway/dist/chat/session.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/cli.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/cli.js +14 -3
- package/node_modules/@buddi/gateway/dist/cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/index.d.ts +3 -0
- package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/index.js +3 -0
- package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/dead-letter.d.ts +2 -1
- package/node_modules/@buddi/gateway/dist/missions/dead-letter.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/dead-letter.js +19 -5
- package/node_modules/@buddi/gateway/dist/missions/dead-letter.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/defaults.d.ts +6 -0
- package/node_modules/@buddi/gateway/dist/missions/defaults.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/defaults.js +10 -2
- package/node_modules/@buddi/gateway/dist/missions/defaults.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/execute.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/execute.js +49 -9
- package/node_modules/@buddi/gateway/dist/missions/execute.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/goals.d.ts +12 -1
- package/node_modules/@buddi/gateway/dist/missions/goals.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/goals.js +21 -1
- package/node_modules/@buddi/gateway/dist/missions/goals.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/inline.js +1 -1
- package/node_modules/@buddi/gateway/dist/missions/inline.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.d.ts +14 -0
- package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.js +41 -2
- package/node_modules/@buddi/gateway/dist/missions/sentinel-wake.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions-cli.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/missions-cli.js +5 -5
- package/node_modules/@buddi/gateway/dist/missions-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/nudges-cli.js +2 -2
- package/node_modules/@buddi/gateway/dist/nudges-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/owner-seed.js +2 -2
- package/node_modules/@buddi/gateway/dist/owner-seed.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/live.d.ts +8 -1
- package/node_modules/@buddi/gateway/dist/plugins/live.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/live.js +25 -7
- package/node_modules/@buddi/gateway/dist/plugins/live.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/load.d.ts +55 -0
- package/node_modules/@buddi/gateway/dist/plugins/load.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/load.js +100 -4
- package/node_modules/@buddi/gateway/dist/plugins/load.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/requires.d.ts +79 -0
- package/node_modules/@buddi/gateway/dist/plugins/requires.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/plugins/requires.js +178 -0
- package/node_modules/@buddi/gateway/dist/plugins/requires.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts +6 -0
- package/node_modules/@buddi/gateway/dist/plugins/stage.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/stage.js +6 -1
- package/node_modules/@buddi/gateway/dist/plugins/stage.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/update.d.ts +21 -0
- package/node_modules/@buddi/gateway/dist/plugins/update.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins/update.js +16 -0
- package/node_modules/@buddi/gateway/dist/plugins/update.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts +1 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/plugins-cli.js +6 -2
- package/node_modules/@buddi/gateway/dist/plugins-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts +4 -0
- package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.js +68 -10
- package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.js +9 -0
- package/node_modules/@buddi/gateway/dist/provider-diagnostics.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/reminders-cli.js +2 -2
- package/node_modules/@buddi/gateway/dist/reminders-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/serve.d.ts +2 -0
- package/node_modules/@buddi/gateway/dist/serve.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/serve.js +66 -8
- package/node_modules/@buddi/gateway/dist/serve.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/surfaces/failure.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/surfaces/failure.js +9 -1
- package/node_modules/@buddi/gateway/dist/surfaces/failure.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/surfaces/offered-actions.d.ts +17 -0
- package/node_modules/@buddi/gateway/dist/surfaces/offered-actions.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/surfaces/offered-actions.js +27 -0
- package/node_modules/@buddi/gateway/dist/surfaces/offered-actions.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/system-context.d.ts +18 -0
- package/node_modules/@buddi/gateway/dist/system-context.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/system-context.js +46 -4
- package/node_modules/@buddi/gateway/dist/system-context.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/main.js +3 -3
- package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/outbound.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/outbound.js +7 -2
- package/node_modules/@buddi/gateway/dist/telegram/outbound.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/reactions.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/reactions.js +12 -2
- package/node_modules/@buddi/gateway/dist/telegram/reactions.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +4 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.js +13 -3
- package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/engine.d.ts +2 -0
- package/node_modules/@buddi/gateway/dist/tips/engine.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/engine.js +8 -5
- package/node_modules/@buddi/gateway/dist/tips/engine.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/facts.d.ts +23 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/facts.js +19 -0
- package/node_modules/@buddi/gateway/dist/tips/facts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/route.js +2 -2
- package/node_modules/@buddi/gateway/dist/tips/route.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/rules.d.ts +3 -2
- package/node_modules/@buddi/gateway/dist/tips/rules.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/tips/rules.js +26 -0
- package/node_modules/@buddi/gateway/dist/tips/rules.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/alerts.d.ts +179 -0
- package/node_modules/@buddi/gateway/dist/web/alerts.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/alerts.js +363 -0
- package/node_modules/@buddi/gateway/dist/web/alerts.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-routes.d.ts +103 -0
- package/node_modules/@buddi/gateway/dist/web/api-routes.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-routes.js +1239 -0
- package/node_modules/@buddi/gateway/dist/web/api-routes.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-scan.d.ts +17 -0
- package/node_modules/@buddi/gateway/dist/web/api-scan.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-scan.js +206 -0
- package/node_modules/@buddi/gateway/dist/web/api-scan.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-tokens.d.ts +58 -0
- package/node_modules/@buddi/gateway/dist/web/api-tokens.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/api-tokens.js +136 -0
- package/node_modules/@buddi/gateway/dist/web/api-tokens.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/backups.js +2 -2
- package/node_modules/@buddi/gateway/dist/web/backups.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/chat.d.ts +1 -0
- package/node_modules/@buddi/gateway/dist/web/chat.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/chat.js +4 -3
- package/node_modules/@buddi/gateway/dist/web/chat.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/group-lifecycle.d.ts +18 -0
- package/node_modules/@buddi/gateway/dist/web/group-lifecycle.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/group-lifecycle.js +46 -0
- package/node_modules/@buddi/gateway/dist/web/group-lifecycle.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/lock-image.d.ts +37 -0
- package/node_modules/@buddi/gateway/dist/web/lock-image.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/lock-image.js +253 -0
- package/node_modules/@buddi/gateway/dist/web/lock-image.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/lock.d.ts +165 -0
- package/node_modules/@buddi/gateway/dist/web/lock.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/lock.js +478 -0
- package/node_modules/@buddi/gateway/dist/web/lock.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/pages.d.ts +1 -0
- package/node_modules/@buddi/gateway/dist/web/pages.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/pages.js +12 -1
- package/node_modules/@buddi/gateway/dist/web/pages.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/places.d.ts +27 -0
- package/node_modules/@buddi/gateway/dist/web/places.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/places.js +90 -0
- package/node_modules/@buddi/gateway/dist/web/places.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/plugins.d.ts +28 -0
- package/node_modules/@buddi/gateway/dist/web/plugins.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/plugins.js +83 -9
- package/node_modules/@buddi/gateway/dist/web/plugins.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.d.ts +52 -26
- package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.js +52 -36
- package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/secrets.d.ts +61 -1
- package/node_modules/@buddi/gateway/dist/web/secrets.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/secrets.js +111 -3
- package/node_modules/@buddi/gateway/dist/web/secrets.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.d.ts +9 -0
- package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.js +531 -46
- package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/sessions.d.ts +43 -2
- package/node_modules/@buddi/gateway/dist/web/sessions.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/sessions.js +67 -3
- package/node_modules/@buddi/gateway/dist/web/sessions.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/signed-out.d.ts +17 -18
- package/node_modules/@buddi/gateway/dist/web/signed-out.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/signed-out.js +135 -33
- package/node_modules/@buddi/gateway/dist/web/signed-out.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/stream.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/stream.js +14 -0
- package/node_modules/@buddi/gateway/dist/web/stream.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/tailscale.d.ts +33 -4
- package/node_modules/@buddi/gateway/dist/web/tailscale.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/tailscale.js +76 -16
- package/node_modules/@buddi/gateway/dist/web/tailscale.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/widgets.d.ts +131 -0
- package/node_modules/@buddi/gateway/dist/web/widgets.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/widgets.js +478 -0
- package/node_modules/@buddi/gateway/dist/web/widgets.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/write.d.ts +23 -0
- package/node_modules/@buddi/gateway/dist/web/write.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/write.js +46 -1
- package/node_modules/@buddi/gateway/dist/web/write.js.map +1 -1
- package/node_modules/@buddi/install/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/runtime/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/runtime/dist/anthropic.d.ts +15 -0
- package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/anthropic.js +26 -9
- package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts +2 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.js +13 -6
- package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.d.ts +1 -0
- package/node_modules/@buddi/runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.js +1 -0
- package/node_modules/@buddi/runtime/dist/index.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/loop.d.ts +2 -0
- package/node_modules/@buddi/runtime/dist/loop.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/loop.js +22 -0
- package/node_modules/@buddi/runtime/dist/loop.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/openai.d.ts +34 -1
- package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/openai.js +85 -19
- package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/rate-limit.d.ts +91 -0
- package/node_modules/@buddi/runtime/dist/rate-limit.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/rate-limit.js +291 -0
- package/node_modules/@buddi/runtime/dist/rate-limit.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/retry.d.ts +40 -0
- package/node_modules/@buddi/runtime/dist/retry.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/retry.js +42 -8
- package/node_modules/@buddi/runtime/dist/retry.js.map +1 -1
- package/node_modules/@buddi/tool-artifacts/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-browser/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-email/dist/agent.js +1 -1
- package/node_modules/@buddi/tool-email/dist/folders.d.ts +14 -0
- package/node_modules/@buddi/tool-email/dist/folders.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/folders.js +23 -0
- package/node_modules/@buddi/tool-email/dist/folders.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/imap/fake.d.ts +55 -0
- package/node_modules/@buddi/tool-email/dist/imap/fake.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/imap/fake.js +163 -4
- package/node_modules/@buddi/tool-email/dist/imap/fake.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/imap/imapflow-client.d.ts +8 -0
- package/node_modules/@buddi/tool-email/dist/imap/imapflow-client.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/imap/imapflow-client.js +124 -4
- package/node_modules/@buddi/tool-email/dist/imap/imapflow-client.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/index.js +3 -0
- package/node_modules/@buddi/tool-email/dist/index.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mail.d.ts +48 -0
- package/node_modules/@buddi/tool-email/dist/mail.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mail.js +119 -0
- package/node_modules/@buddi/tool-email/dist/mail.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mailbox/actions.d.ts +90 -5
- package/node_modules/@buddi/tool-email/dist/mailbox/actions.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mailbox/actions.js +643 -200
- package/node_modules/@buddi/tool-email/dist/mailbox/actions.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mailbox/select.d.ts +6 -0
- package/node_modules/@buddi/tool-email/dist/mailbox/select.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/mailbox/select.js +20 -2
- package/node_modules/@buddi/tool-email/dist/mailbox/select.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/metrics.d.ts +8 -9
- package/node_modules/@buddi/tool-email/dist/metrics.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/metrics.js +8 -9
- package/node_modules/@buddi/tool-email/dist/metrics.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/needs-you.d.ts +58 -0
- package/node_modules/@buddi/tool-email/dist/needs-you.d.ts.map +1 -0
- package/node_modules/@buddi/tool-email/dist/needs-you.js +97 -0
- package/node_modules/@buddi/tool-email/dist/needs-you.js.map +1 -0
- package/node_modules/@buddi/tool-email/dist/pages/descriptors.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/pages/descriptors.js +126 -80
- package/node_modules/@buddi/tool-email/dist/pages/descriptors.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/pages/drafts-tools.d.ts +2 -2
- package/node_modules/@buddi/tool-email/dist/pages/queries.d.ts +14 -0
- package/node_modules/@buddi/tool-email/dist/pages/queries.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/pages/queries.js +65 -7
- package/node_modules/@buddi/tool-email/dist/pages/queries.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/policies/auto.d.ts +9 -9
- package/node_modules/@buddi/tool-email/dist/policies/auto.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/policies/auto.js +79 -24
- package/node_modules/@buddi/tool-email/dist/policies/auto.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/ports.d.ts +55 -0
- package/node_modules/@buddi/tool-email/dist/ports.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/ports.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sentinels/suspicious-sender.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sentinels/suspicious-sender.js +4 -1
- package/node_modules/@buddi/tool-email/dist/sentinels/suspicious-sender.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.d.ts +19 -22
- package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.js +44 -63
- package/node_modules/@buddi/tool-email/dist/sentinels/waiting-on-me.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sources/idle.d.ts +10 -2
- package/node_modules/@buddi/tool-email/dist/sources/idle.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sources/idle.js +70 -3
- package/node_modules/@buddi/tool-email/dist/sources/idle.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.d.ts +69 -2
- package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.js +143 -13
- package/node_modules/@buddi/tool-email/dist/sources/inbox-poll.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/sources/presence.d.ts +47 -0
- package/node_modules/@buddi/tool-email/dist/sources/presence.d.ts.map +1 -0
- package/node_modules/@buddi/tool-email/dist/sources/presence.js +128 -0
- package/node_modules/@buddi/tool-email/dist/sources/presence.js.map +1 -0
- package/node_modules/@buddi/tool-email/dist/suspicions-store.d.ts +6 -0
- package/node_modules/@buddi/tool-email/dist/suspicions-store.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/suspicions-store.js +16 -1
- package/node_modules/@buddi/tool-email/dist/suspicions-store.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/threads.d.ts +19 -2
- package/node_modules/@buddi/tool-email/dist/threads.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/threads.js +47 -17
- package/node_modules/@buddi/tool-email/dist/threads.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/mailbox.d.ts +3 -0
- package/node_modules/@buddi/tool-email/dist/tools/mailbox.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/mailbox.js +9 -4
- package/node_modules/@buddi/tool-email/dist/tools/mailbox.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/read.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/read.js +29 -2
- package/node_modules/@buddi/tool-email/dist/tools/read.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/threads.d.ts +7 -3
- package/node_modules/@buddi/tool-email/dist/tools/threads.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/tools/threads.js +18 -5
- package/node_modules/@buddi/tool-email/dist/tools/threads.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/watchers.d.ts +91 -7
- package/node_modules/@buddi/tool-email/dist/watchers.d.ts.map +1 -1
- package/node_modules/@buddi/tool-email/dist/watchers.js +164 -1
- package/node_modules/@buddi/tool-email/dist/watchers.js.map +1 -1
- package/node_modules/@buddi/tool-email/dist/widgets.d.ts +14 -0
- package/node_modules/@buddi/tool-email/dist/widgets.d.ts.map +1 -0
- package/node_modules/@buddi/tool-email/dist/widgets.js +51 -0
- package/node_modules/@buddi/tool-email/dist/widgets.js.map +1 -0
- package/node_modules/@buddi/tool-email/migrations/020_mailbox_presence.sql +44 -0
- package/node_modules/@buddi/tool-email/migrations/021_learned_line.sql +9 -0
- package/node_modules/@buddi/tool-email/migrations/022_bulk_checked.sql +13 -0
- package/node_modules/@buddi/tool-email/migrations/023_attention.sql +100 -0
- package/node_modules/@buddi/tool-email/migrations/024_auth_domain.sql +9 -0
- package/node_modules/@buddi/tool-email/migrations/025_thread_ignore.sql +77 -0
- package/node_modules/@buddi/tool-email/package.json +1 -1
- package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-mcp/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-memory/dist/admin.d.ts +9 -0
- package/node_modules/@buddi/tool-memory/dist/admin.d.ts.map +1 -1
- package/node_modules/@buddi/tool-memory/dist/admin.js +11 -0
- package/node_modules/@buddi/tool-memory/dist/admin.js.map +1 -1
- package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
- package/node_modules/ip-address/README.md +34 -34
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/package.json +1 -1
- package/package.json +2 -2
- package/packages/cli/dist/.tsbuildinfo +1 -1
- package/packages/cli/dist/args.d.ts +19 -3
- package/packages/cli/dist/args.d.ts.map +1 -1
- package/packages/cli/dist/args.js +19 -5
- package/packages/cli/dist/args.js.map +1 -1
- package/packages/cli/dist/commands.d.ts.map +1 -1
- package/packages/cli/dist/commands.js +80 -8
- package/packages/cli/dist/commands.js.map +1 -1
- package/packages/cli/dist/dashboard-cmd.d.ts +3 -0
- package/packages/cli/dist/dashboard-cmd.d.ts.map +1 -1
- package/packages/cli/dist/dashboard-cmd.js +63 -0
- package/packages/cli/dist/dashboard-cmd.js.map +1 -1
- package/packages/cli/dist/doctor-probes.d.ts.map +1 -1
- package/packages/cli/dist/doctor-probes.js +11 -4
- package/packages/cli/dist/doctor-probes.js.map +1 -1
- package/packages/cli/dist/doctor.d.ts +1 -1
- package/packages/cli/dist/doctor.d.ts.map +1 -1
- package/packages/cli/dist/jobs-cmd.d.ts +4 -0
- package/packages/cli/dist/jobs-cmd.d.ts.map +1 -1
- package/packages/cli/dist/jobs-cmd.js +53 -4
- package/packages/cli/dist/jobs-cmd.js.map +1 -1
- package/packages/cli/dist/main.d.ts.map +1 -1
- package/packages/cli/dist/main.js +27 -2
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/mcp/gateway-client.d.ts +19 -17
- package/packages/cli/dist/mcp/gateway-client.d.ts.map +1 -1
- package/packages/cli/dist/mcp/gateway-client.js +128 -29
- package/packages/cli/dist/mcp/gateway-client.js.map +1 -1
- package/packages/cli/dist/mcp/tools.d.ts +6 -0
- package/packages/cli/dist/mcp/tools.d.ts.map +1 -1
- package/packages/cli/dist/mcp/tools.js +20 -1
- package/packages/cli/dist/mcp/tools.js.map +1 -1
- package/packages/cli/dist/telegram-cmd.d.ts.map +1 -1
- package/packages/cli/dist/telegram-cmd.js +5 -4
- package/packages/cli/dist/telegram-cmd.js.map +1 -1
- package/packages/core/dist/.tsbuildinfo +1 -1
- package/packages/core/dist/agents/catalog.d.ts.map +1 -1
- package/packages/core/dist/agents/catalog.js +7 -6
- package/packages/core/dist/agents/catalog.js.map +1 -1
- package/packages/core/dist/agents/frontmatter.d.ts +12 -12
- package/packages/core/dist/agents/skills.d.ts +2 -2
- package/packages/core/dist/clock-widget.d.ts +38 -0
- package/packages/core/dist/clock-widget.d.ts.map +1 -0
- package/packages/core/dist/clock-widget.js +114 -0
- package/packages/core/dist/clock-widget.js.map +1 -0
- package/packages/core/dist/failures/owner-message.d.ts +25 -0
- package/packages/core/dist/failures/owner-message.d.ts.map +1 -1
- package/packages/core/dist/failures/owner-message.js +90 -0
- package/packages/core/dist/failures/owner-message.js.map +1 -1
- package/packages/core/dist/feedback/index.d.ts +23 -2
- package/packages/core/dist/feedback/index.d.ts.map +1 -1
- package/packages/core/dist/feedback/index.js +23 -3
- package/packages/core/dist/feedback/index.js.map +1 -1
- package/packages/core/dist/groups.d.ts +33 -0
- package/packages/core/dist/groups.d.ts.map +1 -1
- package/packages/core/dist/groups.js +76 -4
- package/packages/core/dist/groups.js.map +1 -1
- package/packages/core/dist/home.d.ts +5 -5
- package/packages/core/dist/host/build.d.ts +19 -1
- package/packages/core/dist/host/build.d.ts.map +1 -1
- package/packages/core/dist/host/build.js +122 -2
- package/packages/core/dist/host/build.js.map +1 -1
- package/packages/core/dist/host/types.d.ts +33 -0
- package/packages/core/dist/host/types.d.ts.map +1 -1
- package/packages/core/dist/index.d.ts +8 -0
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +8 -0
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/lock.d.ts +82 -0
- package/packages/core/dist/lock.d.ts.map +1 -0
- package/packages/core/dist/lock.js +182 -0
- package/packages/core/dist/lock.js.map +1 -0
- package/packages/core/dist/metrics.d.ts.map +1 -1
- package/packages/core/dist/metrics.js +4 -2
- package/packages/core/dist/metrics.js.map +1 -1
- package/packages/core/dist/onboarding/store.d.ts +5 -0
- package/packages/core/dist/onboarding/store.d.ts.map +1 -1
- package/packages/core/dist/onboarding/store.js +35 -5
- package/packages/core/dist/onboarding/store.js.map +1 -1
- package/packages/core/dist/onboarding/types.d.ts +10 -0
- package/packages/core/dist/onboarding/types.d.ts.map +1 -1
- package/packages/core/dist/onboarding/types.js +2 -0
- package/packages/core/dist/onboarding/types.js.map +1 -1
- package/packages/core/dist/owner-format.d.ts +14 -0
- package/packages/core/dist/owner-format.d.ts.map +1 -0
- package/packages/core/dist/owner-format.js +47 -0
- package/packages/core/dist/owner-format.js.map +1 -0
- package/packages/core/dist/owner-timezone.d.ts +46 -0
- package/packages/core/dist/owner-timezone.d.ts.map +1 -0
- package/packages/core/dist/owner-timezone.js +43 -0
- package/packages/core/dist/owner-timezone.js.map +1 -0
- package/packages/core/dist/pages.d.ts +13 -39
- package/packages/core/dist/pages.d.ts.map +1 -1
- package/packages/core/dist/pages.js +12 -1
- package/packages/core/dist/pages.js.map +1 -1
- package/packages/core/dist/places.d.ts +110 -0
- package/packages/core/dist/places.d.ts.map +1 -0
- package/packages/core/dist/places.js +239 -0
- package/packages/core/dist/places.js.map +1 -0
- package/packages/core/dist/plugin/index.d.ts +9 -2
- package/packages/core/dist/plugin/index.d.ts.map +1 -1
- package/packages/core/dist/plugin/index.js +3 -0
- package/packages/core/dist/plugin/index.js.map +1 -1
- package/packages/core/dist/plugin/requires.d.ts +75 -0
- package/packages/core/dist/plugin/requires.d.ts.map +1 -0
- package/packages/core/dist/plugin/requires.js +77 -0
- package/packages/core/dist/plugin/requires.js.map +1 -0
- package/packages/core/dist/plugin/uses.d.ts +1 -1
- package/packages/core/dist/plugin/uses.d.ts.map +1 -1
- package/packages/core/dist/plugin/uses.js +2 -0
- package/packages/core/dist/plugin/uses.js.map +1 -1
- package/packages/core/dist/plugin/version.d.ts +1 -1
- package/packages/core/dist/plugin/version.js +1 -1
- package/packages/core/dist/queue/failures.d.ts +84 -0
- package/packages/core/dist/queue/failures.d.ts.map +1 -0
- package/packages/core/dist/queue/failures.js +195 -0
- package/packages/core/dist/queue/failures.js.map +1 -0
- package/packages/core/dist/queue/index.d.ts +1 -0
- package/packages/core/dist/queue/index.d.ts.map +1 -1
- package/packages/core/dist/queue/index.js +1 -0
- package/packages/core/dist/queue/index.js.map +1 -1
- package/packages/core/dist/queue/jobs.d.ts +39 -3
- package/packages/core/dist/queue/jobs.d.ts.map +1 -1
- package/packages/core/dist/queue/jobs.js +54 -4
- package/packages/core/dist/queue/jobs.js.map +1 -1
- package/packages/core/dist/queue/retry-policy.d.ts +5 -0
- package/packages/core/dist/queue/retry-policy.d.ts.map +1 -1
- package/packages/core/dist/queue/retry-policy.js +19 -2
- package/packages/core/dist/queue/retry-policy.js.map +1 -1
- package/packages/core/dist/queue/types.d.ts +20 -0
- package/packages/core/dist/queue/types.d.ts.map +1 -1
- package/packages/core/dist/queue/types.js +17 -0
- package/packages/core/dist/queue/types.js.map +1 -1
- package/packages/core/dist/registry.d.ts +37 -2
- package/packages/core/dist/registry.d.ts.map +1 -1
- package/packages/core/dist/registry.js +137 -3
- package/packages/core/dist/registry.js.map +1 -1
- package/packages/core/dist/scheduler/enqueue.d.ts +71 -0
- package/packages/core/dist/scheduler/enqueue.d.ts.map +1 -0
- package/packages/core/dist/scheduler/enqueue.js +116 -0
- package/packages/core/dist/scheduler/enqueue.js.map +1 -0
- package/packages/core/dist/scheduler/index.d.ts +1 -0
- package/packages/core/dist/scheduler/index.d.ts.map +1 -1
- package/packages/core/dist/scheduler/index.js +1 -0
- package/packages/core/dist/scheduler/index.js.map +1 -1
- package/packages/core/dist/scheduler/missions.d.ts +15 -0
- package/packages/core/dist/scheduler/missions.d.ts.map +1 -1
- package/packages/core/dist/scheduler/missions.js +43 -4
- package/packages/core/dist/scheduler/missions.js.map +1 -1
- package/packages/core/dist/scheduler/types.d.ts +10 -0
- package/packages/core/dist/scheduler/types.d.ts.map +1 -1
- package/packages/core/dist/scheduler/types.js +3 -0
- package/packages/core/dist/scheduler/types.js.map +1 -1
- package/packages/core/dist/secrets/settings.d.ts +6 -6
- package/packages/core/dist/secrets/settings.d.ts.map +1 -1
- package/packages/core/dist/secrets/settings.js +23 -3
- package/packages/core/dist/secrets/settings.js.map +1 -1
- package/packages/core/dist/semver.d.ts +17 -0
- package/packages/core/dist/semver.d.ts.map +1 -1
- package/packages/core/dist/semver.js +130 -0
- package/packages/core/dist/semver.js.map +1 -1
- package/packages/core/dist/sentinels/digest.d.ts +8 -1
- package/packages/core/dist/sentinels/digest.d.ts.map +1 -1
- package/packages/core/dist/sentinels/digest.js +10 -3
- package/packages/core/dist/sentinels/digest.js.map +1 -1
- package/packages/core/dist/sentinels/index.d.ts +1 -0
- package/packages/core/dist/sentinels/index.d.ts.map +1 -1
- package/packages/core/dist/sentinels/index.js +1 -0
- package/packages/core/dist/sentinels/index.js.map +1 -1
- package/packages/core/dist/sentinels/mutes.d.ts +51 -0
- package/packages/core/dist/sentinels/mutes.d.ts.map +1 -0
- package/packages/core/dist/sentinels/mutes.js +86 -0
- package/packages/core/dist/sentinels/mutes.js.map +1 -0
- package/packages/core/dist/sentinels/run.d.ts +20 -5
- package/packages/core/dist/sentinels/run.d.ts.map +1 -1
- package/packages/core/dist/sentinels/run.js +105 -42
- package/packages/core/dist/sentinels/run.js.map +1 -1
- package/packages/core/dist/sentinels/types.d.ts +165 -2
- package/packages/core/dist/sentinels/types.d.ts.map +1 -1
- package/packages/core/dist/sentinels/types.js +126 -2
- package/packages/core/dist/sentinels/types.js.map +1 -1
- package/packages/core/dist/sources/run.d.ts +8 -0
- package/packages/core/dist/sources/run.d.ts.map +1 -1
- package/packages/core/dist/sources/run.js +1 -1
- package/packages/core/dist/sources/run.js.map +1 -1
- package/packages/core/dist/sources/watch.d.ts +3 -0
- package/packages/core/dist/sources/watch.d.ts.map +1 -1
- package/packages/core/dist/sources/watch.js +1 -1
- package/packages/core/dist/sources/watch.js.map +1 -1
- package/packages/core/dist/time.d.ts +17 -3
- package/packages/core/dist/time.d.ts.map +1 -1
- package/packages/core/dist/time.js +27 -3
- package/packages/core/dist/time.js.map +1 -1
- package/packages/core/dist/tools.d.ts +30 -1
- package/packages/core/dist/tools.d.ts.map +1 -1
- package/packages/core/dist/tools.js.map +1 -1
- package/packages/core/dist/views.d.ts +164 -164
- package/packages/core/dist/views.d.ts.map +1 -1
- package/packages/core/dist/views.js +5 -0
- package/packages/core/dist/views.js.map +1 -1
- package/packages/core/dist/widget-settings.d.ts +161 -0
- package/packages/core/dist/widget-settings.d.ts.map +1 -0
- package/packages/core/dist/widget-settings.js +314 -0
- package/packages/core/dist/widget-settings.js.map +1 -0
- package/packages/core/dist/widgets.d.ts +206 -0
- package/packages/core/dist/widgets.d.ts.map +1 -0
- package/packages/core/dist/widgets.js +247 -0
- package/packages/core/dist/widgets.js.map +1 -0
- package/packages/core/migrations/059_dashboard_lock.sql +33 -0
- package/packages/core/migrations/060_owner_places.sql +30 -0
- package/packages/core/migrations/061_owner_formats.sql +10 -0
- package/packages/core/migrations/062_group_deleted.sql +7 -0
- package/packages/core/migrations/063_provider_account_limits.sql +20 -0
- package/packages/core/migrations/064_mission_coalesce.sql +12 -0
- package/packages/core/migrations/065_api_tokens.sql +28 -0
- package/packages/core/migrations/066_alert_decisions.sql +45 -0
- package/packages/core/migrations/067_job_acknowledged.sql +21 -0
- package/packages/gateway/dist/.tsbuildinfo +1 -1
- package/packages/gateway/dist/account-limits.d.ts +45 -0
- package/packages/gateway/dist/account-limits.d.ts.map +1 -0
- package/packages/gateway/dist/account-limits.js +87 -0
- package/packages/gateway/dist/account-limits.js.map +1 -0
- package/packages/gateway/dist/accounts-cli.d.ts +88 -0
- package/packages/gateway/dist/accounts-cli.d.ts.map +1 -0
- package/packages/gateway/dist/accounts-cli.js +216 -0
- package/packages/gateway/dist/accounts-cli.js.map +1 -0
- package/packages/gateway/dist/agents/canvas.d.ts +20 -20
- package/packages/gateway/dist/agents/learning-digest.d.ts +4 -0
- package/packages/gateway/dist/agents/learning-digest.d.ts.map +1 -1
- package/packages/gateway/dist/agents/learning-digest.js +18 -5
- package/packages/gateway/dist/agents/learning-digest.js.map +1 -1
- package/packages/gateway/dist/agents/owner-tools.d.ts.map +1 -1
- package/packages/gateway/dist/agents/owner-tools.js +3 -2
- package/packages/gateway/dist/agents/owner-tools.js.map +1 -1
- package/packages/gateway/dist/agents/platform.d.ts +24 -24
- package/packages/gateway/dist/api-token-cli.d.ts +17 -0
- package/packages/gateway/dist/api-token-cli.d.ts.map +1 -0
- package/packages/gateway/dist/api-token-cli.js +108 -0
- package/packages/gateway/dist/api-token-cli.js.map +1 -0
- package/packages/gateway/dist/bootstrap.d.ts +6 -2
- package/packages/gateway/dist/bootstrap.d.ts.map +1 -1
- package/packages/gateway/dist/bootstrap.js +25 -7
- package/packages/gateway/dist/bootstrap.js.map +1 -1
- package/packages/gateway/dist/chat/conversations.d.ts.map +1 -1
- package/packages/gateway/dist/chat/conversations.js +8 -2
- package/packages/gateway/dist/chat/conversations.js.map +1 -1
- package/packages/gateway/dist/chat/session.d.ts +5 -0
- package/packages/gateway/dist/chat/session.d.ts.map +1 -1
- package/packages/gateway/dist/chat/session.js +11 -1
- package/packages/gateway/dist/chat/session.js.map +1 -1
- package/packages/gateway/dist/cli.d.ts.map +1 -1
- package/packages/gateway/dist/cli.js +14 -3
- package/packages/gateway/dist/cli.js.map +1 -1
- package/packages/gateway/dist/index.d.ts +3 -0
- package/packages/gateway/dist/index.d.ts.map +1 -1
- package/packages/gateway/dist/index.js +3 -0
- package/packages/gateway/dist/index.js.map +1 -1
- package/packages/gateway/dist/missions/dead-letter.d.ts +2 -1
- package/packages/gateway/dist/missions/dead-letter.d.ts.map +1 -1
- package/packages/gateway/dist/missions/dead-letter.js +19 -5
- package/packages/gateway/dist/missions/dead-letter.js.map +1 -1
- package/packages/gateway/dist/missions/defaults.d.ts +6 -0
- package/packages/gateway/dist/missions/defaults.d.ts.map +1 -1
- package/packages/gateway/dist/missions/defaults.js +10 -2
- package/packages/gateway/dist/missions/defaults.js.map +1 -1
- package/packages/gateway/dist/missions/execute.d.ts.map +1 -1
- package/packages/gateway/dist/missions/execute.js +49 -9
- package/packages/gateway/dist/missions/execute.js.map +1 -1
- package/packages/gateway/dist/missions/goals.d.ts +12 -1
- package/packages/gateway/dist/missions/goals.d.ts.map +1 -1
- package/packages/gateway/dist/missions/goals.js +21 -1
- package/packages/gateway/dist/missions/goals.js.map +1 -1
- package/packages/gateway/dist/missions/inline.js +1 -1
- package/packages/gateway/dist/missions/inline.js.map +1 -1
- package/packages/gateway/dist/missions/sentinel-wake.d.ts +14 -0
- package/packages/gateway/dist/missions/sentinel-wake.d.ts.map +1 -1
- package/packages/gateway/dist/missions/sentinel-wake.js +41 -2
- package/packages/gateway/dist/missions/sentinel-wake.js.map +1 -1
- package/packages/gateway/dist/missions-cli.d.ts.map +1 -1
- package/packages/gateway/dist/missions-cli.js +5 -5
- package/packages/gateway/dist/missions-cli.js.map +1 -1
- package/packages/gateway/dist/nudges-cli.js +2 -2
- package/packages/gateway/dist/nudges-cli.js.map +1 -1
- package/packages/gateway/dist/owner-seed.js +2 -2
- package/packages/gateway/dist/owner-seed.js.map +1 -1
- package/packages/gateway/dist/plugins/live.d.ts +8 -1
- package/packages/gateway/dist/plugins/live.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/live.js +25 -7
- package/packages/gateway/dist/plugins/live.js.map +1 -1
- package/packages/gateway/dist/plugins/load.d.ts +55 -0
- package/packages/gateway/dist/plugins/load.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/load.js +100 -4
- package/packages/gateway/dist/plugins/load.js.map +1 -1
- package/packages/gateway/dist/plugins/requires.d.ts +79 -0
- package/packages/gateway/dist/plugins/requires.d.ts.map +1 -0
- package/packages/gateway/dist/plugins/requires.js +178 -0
- package/packages/gateway/dist/plugins/requires.js.map +1 -0
- package/packages/gateway/dist/plugins/stage.d.ts +6 -0
- package/packages/gateway/dist/plugins/stage.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/stage.js +6 -1
- package/packages/gateway/dist/plugins/stage.js.map +1 -1
- package/packages/gateway/dist/plugins/update.d.ts +21 -0
- package/packages/gateway/dist/plugins/update.d.ts.map +1 -1
- package/packages/gateway/dist/plugins/update.js +16 -0
- package/packages/gateway/dist/plugins/update.js.map +1 -1
- package/packages/gateway/dist/plugins-cli.d.ts +1 -1
- package/packages/gateway/dist/plugins-cli.d.ts.map +1 -1
- package/packages/gateway/dist/plugins-cli.js +6 -2
- package/packages/gateway/dist/plugins-cli.js.map +1 -1
- package/packages/gateway/dist/provider-accounts.d.ts +4 -0
- package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/provider-accounts.js +68 -10
- package/packages/gateway/dist/provider-accounts.js.map +1 -1
- package/packages/gateway/dist/provider-diagnostics.d.ts.map +1 -1
- package/packages/gateway/dist/provider-diagnostics.js +9 -0
- package/packages/gateway/dist/provider-diagnostics.js.map +1 -1
- package/packages/gateway/dist/reminders-cli.js +2 -2
- package/packages/gateway/dist/reminders-cli.js.map +1 -1
- package/packages/gateway/dist/serve.d.ts +2 -0
- package/packages/gateway/dist/serve.d.ts.map +1 -1
- package/packages/gateway/dist/serve.js +66 -8
- package/packages/gateway/dist/serve.js.map +1 -1
- package/packages/gateway/dist/surfaces/failure.d.ts.map +1 -1
- package/packages/gateway/dist/surfaces/failure.js +9 -1
- package/packages/gateway/dist/surfaces/failure.js.map +1 -1
- package/packages/gateway/dist/surfaces/offered-actions.d.ts +17 -0
- package/packages/gateway/dist/surfaces/offered-actions.d.ts.map +1 -1
- package/packages/gateway/dist/surfaces/offered-actions.js +27 -0
- package/packages/gateway/dist/surfaces/offered-actions.js.map +1 -1
- package/packages/gateway/dist/system-context.d.ts +18 -0
- package/packages/gateway/dist/system-context.d.ts.map +1 -1
- package/packages/gateway/dist/system-context.js +46 -4
- package/packages/gateway/dist/system-context.js.map +1 -1
- package/packages/gateway/dist/telegram/main.js +3 -3
- package/packages/gateway/dist/telegram/main.js.map +1 -1
- package/packages/gateway/dist/telegram/outbound.d.ts +1 -1
- package/packages/gateway/dist/telegram/outbound.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/outbound.js +7 -2
- package/packages/gateway/dist/telegram/outbound.js.map +1 -1
- package/packages/gateway/dist/telegram/reactions.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/reactions.js +12 -2
- package/packages/gateway/dist/telegram/reactions.js.map +1 -1
- package/packages/gateway/dist/telegram/surface.d.ts +4 -1
- package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/surface.js +13 -3
- package/packages/gateway/dist/telegram/surface.js.map +1 -1
- package/packages/gateway/dist/tips/engine.d.ts +2 -0
- package/packages/gateway/dist/tips/engine.d.ts.map +1 -1
- package/packages/gateway/dist/tips/engine.js +8 -5
- package/packages/gateway/dist/tips/engine.js.map +1 -1
- package/packages/gateway/dist/tips/facts.d.ts +23 -0
- package/packages/gateway/dist/tips/facts.d.ts.map +1 -1
- package/packages/gateway/dist/tips/facts.js +19 -0
- package/packages/gateway/dist/tips/facts.js.map +1 -1
- package/packages/gateway/dist/tips/route.js +2 -2
- package/packages/gateway/dist/tips/route.js.map +1 -1
- package/packages/gateway/dist/tips/rules.d.ts +3 -2
- package/packages/gateway/dist/tips/rules.d.ts.map +1 -1
- package/packages/gateway/dist/tips/rules.js +26 -0
- package/packages/gateway/dist/tips/rules.js.map +1 -1
- package/packages/gateway/dist/web/alerts.d.ts +179 -0
- package/packages/gateway/dist/web/alerts.d.ts.map +1 -0
- package/packages/gateway/dist/web/alerts.js +363 -0
- package/packages/gateway/dist/web/alerts.js.map +1 -0
- package/packages/gateway/dist/web/api-routes.d.ts +103 -0
- package/packages/gateway/dist/web/api-routes.d.ts.map +1 -0
- package/packages/gateway/dist/web/api-routes.js +1239 -0
- package/packages/gateway/dist/web/api-routes.js.map +1 -0
- package/packages/gateway/dist/web/api-scan.d.ts +17 -0
- package/packages/gateway/dist/web/api-scan.d.ts.map +1 -0
- package/packages/gateway/dist/web/api-scan.js +206 -0
- package/packages/gateway/dist/web/api-scan.js.map +1 -0
- package/packages/gateway/dist/web/api-tokens.d.ts +58 -0
- package/packages/gateway/dist/web/api-tokens.d.ts.map +1 -0
- package/packages/gateway/dist/web/api-tokens.js +136 -0
- package/packages/gateway/dist/web/api-tokens.js.map +1 -0
- package/packages/gateway/dist/web/backups.js +2 -2
- package/packages/gateway/dist/web/backups.js.map +1 -1
- package/packages/gateway/dist/web/chat.d.ts +1 -0
- package/packages/gateway/dist/web/chat.d.ts.map +1 -1
- package/packages/gateway/dist/web/chat.js +4 -3
- package/packages/gateway/dist/web/chat.js.map +1 -1
- package/packages/gateway/dist/web/group-lifecycle.d.ts +18 -0
- package/packages/gateway/dist/web/group-lifecycle.d.ts.map +1 -0
- package/packages/gateway/dist/web/group-lifecycle.js +46 -0
- package/packages/gateway/dist/web/group-lifecycle.js.map +1 -0
- package/packages/gateway/dist/web/lock-image.d.ts +37 -0
- package/packages/gateway/dist/web/lock-image.d.ts.map +1 -0
- package/packages/gateway/dist/web/lock-image.js +253 -0
- package/packages/gateway/dist/web/lock-image.js.map +1 -0
- package/packages/gateway/dist/web/lock.d.ts +165 -0
- package/packages/gateway/dist/web/lock.d.ts.map +1 -0
- package/packages/gateway/dist/web/lock.js +478 -0
- package/packages/gateway/dist/web/lock.js.map +1 -0
- package/packages/gateway/dist/web/pages.d.ts +1 -0
- package/packages/gateway/dist/web/pages.d.ts.map +1 -1
- package/packages/gateway/dist/web/pages.js +12 -1
- package/packages/gateway/dist/web/pages.js.map +1 -1
- package/packages/gateway/dist/web/places.d.ts +27 -0
- package/packages/gateway/dist/web/places.d.ts.map +1 -0
- package/packages/gateway/dist/web/places.js +90 -0
- package/packages/gateway/dist/web/places.js.map +1 -0
- package/packages/gateway/dist/web/plugins.d.ts +28 -0
- package/packages/gateway/dist/web/plugins.d.ts.map +1 -1
- package/packages/gateway/dist/web/plugins.js +83 -9
- package/packages/gateway/dist/web/plugins.js.map +1 -1
- package/packages/gateway/dist/web/read.d.ts +52 -26
- package/packages/gateway/dist/web/read.d.ts.map +1 -1
- package/packages/gateway/dist/web/read.js +52 -36
- package/packages/gateway/dist/web/read.js.map +1 -1
- package/packages/gateway/dist/web/secrets.d.ts +61 -1
- package/packages/gateway/dist/web/secrets.d.ts.map +1 -1
- package/packages/gateway/dist/web/secrets.js +111 -3
- package/packages/gateway/dist/web/secrets.js.map +1 -1
- package/packages/gateway/dist/web/server.d.ts +9 -0
- package/packages/gateway/dist/web/server.d.ts.map +1 -1
- package/packages/gateway/dist/web/server.js +531 -46
- package/packages/gateway/dist/web/server.js.map +1 -1
- package/packages/gateway/dist/web/sessions.d.ts +43 -2
- package/packages/gateway/dist/web/sessions.d.ts.map +1 -1
- package/packages/gateway/dist/web/sessions.js +67 -3
- package/packages/gateway/dist/web/sessions.js.map +1 -1
- package/packages/gateway/dist/web/signed-out.d.ts +17 -18
- package/packages/gateway/dist/web/signed-out.d.ts.map +1 -1
- package/packages/gateway/dist/web/signed-out.js +135 -33
- package/packages/gateway/dist/web/signed-out.js.map +1 -1
- package/packages/gateway/dist/web/stream.d.ts.map +1 -1
- package/packages/gateway/dist/web/stream.js +14 -0
- package/packages/gateway/dist/web/stream.js.map +1 -1
- package/packages/gateway/dist/web/tailscale.d.ts +33 -4
- package/packages/gateway/dist/web/tailscale.d.ts.map +1 -1
- package/packages/gateway/dist/web/tailscale.js +76 -16
- package/packages/gateway/dist/web/tailscale.js.map +1 -1
- package/packages/gateway/dist/web/widgets.d.ts +131 -0
- package/packages/gateway/dist/web/widgets.d.ts.map +1 -0
- package/packages/gateway/dist/web/widgets.js +478 -0
- package/packages/gateway/dist/web/widgets.js.map +1 -0
- package/packages/gateway/dist/web/write.d.ts +23 -0
- package/packages/gateway/dist/web/write.d.ts.map +1 -1
- package/packages/gateway/dist/web/write.js +46 -1
- package/packages/gateway/dist/web/write.js.map +1 -1
- package/packages/install/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/anthropic.d.ts +15 -0
- package/packages/runtime/dist/anthropic.d.ts.map +1 -1
- package/packages/runtime/dist/anthropic.js +26 -9
- package/packages/runtime/dist/anthropic.js.map +1 -1
- package/packages/runtime/dist/codex-direct.d.ts +2 -1
- package/packages/runtime/dist/codex-direct.d.ts.map +1 -1
- package/packages/runtime/dist/codex-direct.js +13 -6
- package/packages/runtime/dist/codex-direct.js.map +1 -1
- package/packages/runtime/dist/index.d.ts +1 -0
- package/packages/runtime/dist/index.d.ts.map +1 -1
- package/packages/runtime/dist/index.js +1 -0
- package/packages/runtime/dist/index.js.map +1 -1
- package/packages/runtime/dist/loop.d.ts +2 -0
- package/packages/runtime/dist/loop.d.ts.map +1 -1
- package/packages/runtime/dist/loop.js +22 -0
- package/packages/runtime/dist/loop.js.map +1 -1
- package/packages/runtime/dist/openai.d.ts +34 -1
- package/packages/runtime/dist/openai.d.ts.map +1 -1
- package/packages/runtime/dist/openai.js +85 -19
- package/packages/runtime/dist/openai.js.map +1 -1
- package/packages/runtime/dist/rate-limit.d.ts +91 -0
- package/packages/runtime/dist/rate-limit.d.ts.map +1 -0
- package/packages/runtime/dist/rate-limit.js +291 -0
- package/packages/runtime/dist/rate-limit.js.map +1 -0
- package/packages/runtime/dist/retry.d.ts +40 -0
- package/packages/runtime/dist/retry.d.ts.map +1 -1
- package/packages/runtime/dist/retry.js +42 -8
- package/packages/runtime/dist/retry.js.map +1 -1
- package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
- package/packages/tools/browser/dist/.tsbuildinfo +1 -1
- package/packages/tools/email/dist/.tsbuildinfo +1 -1
- package/packages/tools/email/dist/agent.js +1 -1
- package/packages/tools/email/dist/folders.d.ts +14 -0
- package/packages/tools/email/dist/folders.d.ts.map +1 -1
- package/packages/tools/email/dist/folders.js +23 -0
- package/packages/tools/email/dist/folders.js.map +1 -1
- package/packages/tools/email/dist/imap/fake.d.ts +55 -0
- package/packages/tools/email/dist/imap/fake.d.ts.map +1 -1
- package/packages/tools/email/dist/imap/fake.js +163 -4
- package/packages/tools/email/dist/imap/fake.js.map +1 -1
- package/packages/tools/email/dist/imap/imapflow-client.d.ts +8 -0
- package/packages/tools/email/dist/imap/imapflow-client.d.ts.map +1 -1
- package/packages/tools/email/dist/imap/imapflow-client.js +124 -4
- package/packages/tools/email/dist/imap/imapflow-client.js.map +1 -1
- package/packages/tools/email/dist/index.d.ts.map +1 -1
- package/packages/tools/email/dist/index.js +3 -0
- package/packages/tools/email/dist/index.js.map +1 -1
- package/packages/tools/email/dist/mail.d.ts +48 -0
- package/packages/tools/email/dist/mail.d.ts.map +1 -1
- package/packages/tools/email/dist/mail.js +119 -0
- package/packages/tools/email/dist/mail.js.map +1 -1
- package/packages/tools/email/dist/mailbox/actions.d.ts +90 -5
- package/packages/tools/email/dist/mailbox/actions.d.ts.map +1 -1
- package/packages/tools/email/dist/mailbox/actions.js +643 -200
- package/packages/tools/email/dist/mailbox/actions.js.map +1 -1
- package/packages/tools/email/dist/mailbox/select.d.ts +6 -0
- package/packages/tools/email/dist/mailbox/select.d.ts.map +1 -1
- package/packages/tools/email/dist/mailbox/select.js +20 -2
- package/packages/tools/email/dist/mailbox/select.js.map +1 -1
- package/packages/tools/email/dist/metrics.d.ts +8 -9
- package/packages/tools/email/dist/metrics.d.ts.map +1 -1
- package/packages/tools/email/dist/metrics.js +8 -9
- package/packages/tools/email/dist/metrics.js.map +1 -1
- package/packages/tools/email/dist/needs-you.d.ts +58 -0
- package/packages/tools/email/dist/needs-you.d.ts.map +1 -0
- package/packages/tools/email/dist/needs-you.js +97 -0
- package/packages/tools/email/dist/needs-you.js.map +1 -0
- package/packages/tools/email/dist/pages/descriptors.d.ts.map +1 -1
- package/packages/tools/email/dist/pages/descriptors.js +126 -80
- package/packages/tools/email/dist/pages/descriptors.js.map +1 -1
- package/packages/tools/email/dist/pages/drafts-tools.d.ts +2 -2
- package/packages/tools/email/dist/pages/queries.d.ts +14 -0
- package/packages/tools/email/dist/pages/queries.d.ts.map +1 -1
- package/packages/tools/email/dist/pages/queries.js +65 -7
- package/packages/tools/email/dist/pages/queries.js.map +1 -1
- package/packages/tools/email/dist/policies/auto.d.ts +9 -9
- package/packages/tools/email/dist/policies/auto.d.ts.map +1 -1
- package/packages/tools/email/dist/policies/auto.js +79 -24
- package/packages/tools/email/dist/policies/auto.js.map +1 -1
- package/packages/tools/email/dist/ports.d.ts +55 -0
- package/packages/tools/email/dist/ports.d.ts.map +1 -1
- package/packages/tools/email/dist/ports.js.map +1 -1
- package/packages/tools/email/dist/sentinels/suspicious-sender.d.ts.map +1 -1
- package/packages/tools/email/dist/sentinels/suspicious-sender.js +4 -1
- package/packages/tools/email/dist/sentinels/suspicious-sender.js.map +1 -1
- package/packages/tools/email/dist/sentinels/waiting-on-me.d.ts +19 -22
- package/packages/tools/email/dist/sentinels/waiting-on-me.d.ts.map +1 -1
- package/packages/tools/email/dist/sentinels/waiting-on-me.js +44 -63
- package/packages/tools/email/dist/sentinels/waiting-on-me.js.map +1 -1
- package/packages/tools/email/dist/sources/idle.d.ts +10 -2
- package/packages/tools/email/dist/sources/idle.d.ts.map +1 -1
- package/packages/tools/email/dist/sources/idle.js +70 -3
- package/packages/tools/email/dist/sources/idle.js.map +1 -1
- package/packages/tools/email/dist/sources/inbox-poll.d.ts +69 -2
- package/packages/tools/email/dist/sources/inbox-poll.d.ts.map +1 -1
- package/packages/tools/email/dist/sources/inbox-poll.js +143 -13
- package/packages/tools/email/dist/sources/inbox-poll.js.map +1 -1
- package/packages/tools/email/dist/sources/presence.d.ts +47 -0
- package/packages/tools/email/dist/sources/presence.d.ts.map +1 -0
- package/packages/tools/email/dist/sources/presence.js +128 -0
- package/packages/tools/email/dist/sources/presence.js.map +1 -0
- package/packages/tools/email/dist/suspicions-store.d.ts +6 -0
- package/packages/tools/email/dist/suspicions-store.d.ts.map +1 -1
- package/packages/tools/email/dist/suspicions-store.js +16 -1
- package/packages/tools/email/dist/suspicions-store.js.map +1 -1
- package/packages/tools/email/dist/threads.d.ts +19 -2
- package/packages/tools/email/dist/threads.d.ts.map +1 -1
- package/packages/tools/email/dist/threads.js +47 -17
- package/packages/tools/email/dist/threads.js.map +1 -1
- package/packages/tools/email/dist/tools/mailbox.d.ts +3 -0
- package/packages/tools/email/dist/tools/mailbox.d.ts.map +1 -1
- package/packages/tools/email/dist/tools/mailbox.js +9 -4
- package/packages/tools/email/dist/tools/mailbox.js.map +1 -1
- package/packages/tools/email/dist/tools/read.d.ts.map +1 -1
- package/packages/tools/email/dist/tools/read.js +29 -2
- package/packages/tools/email/dist/tools/read.js.map +1 -1
- package/packages/tools/email/dist/tools/threads.d.ts +7 -3
- package/packages/tools/email/dist/tools/threads.d.ts.map +1 -1
- package/packages/tools/email/dist/tools/threads.js +18 -5
- package/packages/tools/email/dist/tools/threads.js.map +1 -1
- package/packages/tools/email/dist/watchers.d.ts +91 -7
- package/packages/tools/email/dist/watchers.d.ts.map +1 -1
- package/packages/tools/email/dist/watchers.js +164 -1
- package/packages/tools/email/dist/watchers.js.map +1 -1
- package/packages/tools/email/dist/widgets.d.ts +14 -0
- package/packages/tools/email/dist/widgets.d.ts.map +1 -0
- package/packages/tools/email/dist/widgets.js +51 -0
- package/packages/tools/email/dist/widgets.js.map +1 -0
- package/packages/tools/email/migrations/020_mailbox_presence.sql +44 -0
- package/packages/tools/email/migrations/021_learned_line.sql +9 -0
- package/packages/tools/email/migrations/022_bulk_checked.sql +13 -0
- package/packages/tools/email/migrations/023_attention.sql +100 -0
- package/packages/tools/email/migrations/024_auth_domain.sql +9 -0
- package/packages/tools/email/migrations/025_thread_ignore.sql +77 -0
- package/packages/tools/email/package.json +1 -1
- package/packages/tools/host/dist/.tsbuildinfo +1 -1
- package/packages/tools/mcp/dist/.tsbuildinfo +1 -1
- package/packages/tools/memory/dist/.tsbuildinfo +1 -1
- package/packages/tools/memory/dist/admin.d.ts +9 -0
- package/packages/tools/memory/dist/admin.d.ts.map +1 -1
- package/packages/tools/memory/dist/admin.js +11 -0
- package/packages/tools/memory/dist/admin.js.map +1 -1
- package/packages/tools/web/dist/.tsbuildinfo +1 -1
- package/packages/web/dist/assets/earth-2560-Ce3xs8Cb.webp +0 -0
- package/packages/web/dist/assets/earth-phone-BqC7cDhk.webp +0 -0
- package/packages/web/dist/assets/index-WS4UjGsy.js +129 -0
- package/packages/web/dist/assets/index-Zrt_o2UG.css +1 -0
- package/packages/web/dist/assets/{lottie_light-CSeMXM8D.js → lottie_light-Ls7i1ATS.js} +1 -1
- package/packages/web/dist/build.json +1 -1
- package/packages/web/dist/index.html +2 -2
- package/packages/web/dist/precache.json +4 -4
- package/packages/web/dist/sw.js +3 -2
- package/packages/web/dist/assets/index-CKuhKCWw.js +0 -131
- package/packages/web/dist/assets/index-DsK8UWCJ.css +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var Mw=e=>{throw TypeError(e)};var Dw=(e,t,s)=>t.has(e)||Mw("Cannot "+s);var hn=(e,t,s)=>(Dw(e,t,"read from private field"),s?s.call(e):t.get(e)),Ow=(e,t,s)=>t.has(e)?Mw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ff=(e,t,s,r)=>(Dw(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s);function I$(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();var sQ=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function P$(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $0={exports:{}},Zd={},I0={exports:{}},Qe={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var hc=Symbol.for("react.element"),M$=Symbol.for("react.portal"),D$=Symbol.for("react.fragment"),O$=Symbol.for("react.strict_mode"),L$=Symbol.for("react.profiler"),_$=Symbol.for("react.provider"),F$=Symbol.for("react.context"),z$=Symbol.for("react.forward_ref"),U$=Symbol.for("react.suspense"),B$=Symbol.for("react.memo"),W$=Symbol.for("react.lazy"),Lw=Symbol.iterator;function H$(e){return e===null||typeof e!="object"?null:(e=Lw&&e[Lw]||e["@@iterator"],typeof e=="function"?e:null)}var P0={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M0=Object.assign,D0={};function ml(e,t,s){this.props=e,this.context=t,this.refs=D0,this.updater=s||P0}ml.prototype.isReactComponent={};ml.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ml.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function O0(){}O0.prototype=ml.prototype;function mx(e,t,s){this.props=e,this.context=t,this.refs=D0,this.updater=s||P0}var px=mx.prototype=new O0;px.constructor=mx;M0(px,ml.prototype);px.isPureReactComponent=!0;var _w=Array.isArray,L0=Object.prototype.hasOwnProperty,gx={current:null},_0={key:!0,ref:!0,__self:!0,__source:!0};function F0(e,t,s){var r,i={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)L0.call(t,r)&&!_0.hasOwnProperty(r)&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=s;else if(1<o){for(var c=Array(o),u=0;u<o;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return{$$typeof:hc,type:e,key:a,ref:l,props:i,_owner:gx.current}}function K$(e,t){return{$$typeof:hc,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function xx(e){return typeof e=="object"&&e!==null&&e.$$typeof===hc}function V$(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var Fw=/\/+/g;function mf(e,t){return typeof e=="object"&&e!==null&&e.key!=null?V$(""+e.key):t.toString(36)}function Tu(e,t,s,r,i){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(a){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case hc:case M$:l=!0}}if(l)return l=e,i=i(l),e=r===""?"."+mf(l,0):r,_w(i)?(s="",e!=null&&(s=e.replace(Fw,"$&/")+"/"),Tu(i,t,s,"",function(u){return u})):i!=null&&(xx(i)&&(i=K$(i,s+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(Fw,"$&/")+"/")+e)),t.push(i)),1;if(l=0,r=r===""?".":r+":",_w(e))for(var o=0;o<e.length;o++){a=e[o];var c=r+mf(a,o);l+=Tu(a,t,s,c,i)}else if(c=H$(e),typeof c=="function")for(e=c.call(e),o=0;!(a=e.next()).done;)a=a.value,c=r+mf(a,o++),l+=Tu(a,t,s,c,i);else if(a==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function zc(e,t,s){if(e==null)return e;var r=[],i=0;return Tu(e,r,"","",function(a){return t.call(s,a,i++)}),r}function G$(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Cn={current:null},Ru={transition:null},Y$={ReactCurrentDispatcher:Cn,ReactCurrentBatchConfig:Ru,ReactCurrentOwner:gx};function z0(){throw Error("act(...) is not supported in production builds of React.")}Qe.Children={map:zc,forEach:function(e,t,s){zc(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return zc(e,function(){t++}),t},toArray:function(e){return zc(e,function(t){return t})||[]},only:function(e){if(!xx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Qe.Component=ml;Qe.Fragment=D$;Qe.Profiler=L$;Qe.PureComponent=mx;Qe.StrictMode=O$;Qe.Suspense=U$;Qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y$;Qe.act=z0;Qe.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=M0({},e.props),i=e.key,a=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,l=gx.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)L0.call(t,c)&&!_0.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&o!==void 0?o[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){o=Array(c);for(var u=0;u<c;u++)o[u]=arguments[u+2];r.children=o}return{$$typeof:hc,type:e.type,key:i,ref:a,props:r,_owner:l}};Qe.createContext=function(e){return e={$$typeof:F$,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:_$,_context:e},e.Consumer=e};Qe.createElement=F0;Qe.createFactory=function(e){var t=F0.bind(null,e);return t.type=e,t};Qe.createRef=function(){return{current:null}};Qe.forwardRef=function(e){return{$$typeof:z$,render:e}};Qe.isValidElement=xx;Qe.lazy=function(e){return{$$typeof:W$,_payload:{_status:-1,_result:e},_init:G$}};Qe.memo=function(e,t){return{$$typeof:B$,type:e,compare:t===void 0?null:t}};Qe.startTransition=function(e){var t=Ru.transition;Ru.transition={};try{e()}finally{Ru.transition=t}};Qe.unstable_act=z0;Qe.useCallback=function(e,t){return Cn.current.useCallback(e,t)};Qe.useContext=function(e){return Cn.current.useContext(e)};Qe.useDebugValue=function(){};Qe.useDeferredValue=function(e){return Cn.current.useDeferredValue(e)};Qe.useEffect=function(e,t){return Cn.current.useEffect(e,t)};Qe.useId=function(){return Cn.current.useId()};Qe.useImperativeHandle=function(e,t,s){return Cn.current.useImperativeHandle(e,t,s)};Qe.useInsertionEffect=function(e,t){return Cn.current.useInsertionEffect(e,t)};Qe.useLayoutEffect=function(e,t){return Cn.current.useLayoutEffect(e,t)};Qe.useMemo=function(e,t){return Cn.current.useMemo(e,t)};Qe.useReducer=function(e,t,s){return Cn.current.useReducer(e,t,s)};Qe.useRef=function(e){return Cn.current.useRef(e)};Qe.useState=function(e){return Cn.current.useState(e)};Qe.useSyncExternalStore=function(e,t,s){return Cn.current.useSyncExternalStore(e,t,s)};Qe.useTransition=function(){return Cn.current.useTransition()};Qe.version="18.3.1";I0.exports=Qe;var d=I0.exports;const q$=P$(d),pl=I$({__proto__:null,default:q$},[d]);/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Q$=d,X$=Symbol.for("react.element"),J$=Symbol.for("react.fragment"),Z$=Object.prototype.hasOwnProperty,eI=Q$.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tI={key:!0,ref:!0,__self:!0,__source:!0};function U0(e,t,s){var r,i={},a=null,l=null;s!==void 0&&(a=""+s),t.key!==void 0&&(a=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)Z$.call(t,r)&&!tI.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:X$,type:e,key:a,ref:l,props:i,_owner:eI.current}}Zd.Fragment=J$;Zd.jsx=U0;Zd.jsxs=U0;$0.exports=Zd;var n=$0.exports,B0={exports:{}},Zn={},W0={exports:{}},H0={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(M,W){var _=M.length;M.push(W);e:for(;0<_;){var G=_-1>>>1,B=M[G];if(0<i(B,W))M[G]=W,M[_]=B,_=G;else break e}}function s(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var W=M[0],_=M.pop();if(_!==W){M[0]=_;e:for(var G=0,B=M.length,K=B>>>1;G<K;){var F=2*(G+1)-1,Q=M[F],X=F+1,Z=M[X];if(0>i(Q,_))X<B&&0>i(Z,Q)?(M[G]=Z,M[X]=_,G=X):(M[G]=Q,M[F]=_,G=F);else if(X<B&&0>i(Z,_))M[G]=Z,M[X]=_,G=X;else break e}}return W}function i(M,W){var _=M.sortIndex-W.sortIndex;return _!==0?_:M.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],h=1,f=null,m=3,p=!1,g=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var W=s(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=M)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=s(u)}}function y(M){if(x=!1,w(M),!g)if(s(c)!==null)g=!0,D(N);else{var W=s(u);W!==null&&O(y,W.startTime-M)}}function N(M,W){g=!1,x&&(x=!1,j(C),C=-1),p=!0;var _=m;try{for(w(W),f=s(c);f!==null&&(!(f.expirationTime>W)||M&&!I());){var G=f.callback;if(typeof G=="function"){f.callback=null,m=f.priorityLevel;var B=G(f.expirationTime<=W);W=e.unstable_now(),typeof B=="function"?f.callback=B:f===s(c)&&r(c),w(W)}else r(c);f=s(c)}if(f!==null)var K=!0;else{var F=s(u);F!==null&&O(y,F.startTime-W),K=!1}return K}finally{f=null,m=_,p=!1}}var k=!1,S=null,C=-1,$=5,R=-1;function I(){return!(e.unstable_now()-R<$)}function z(){if(S!==null){var M=e.unstable_now();R=M;var W=!0;try{W=S(!0,M)}finally{W?U():(k=!1,S=null)}}else k=!1}var U;if(typeof v=="function")U=function(){v(z)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,P=A.port2;A.port1.onmessage=z,U=function(){P.postMessage(null)}}else U=function(){b(z,0)};function D(M){S=M,k||(k=!0,U())}function O(M,W){C=b(function(){M(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){g||p||(g=!0,D(N))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(M){switch(m){case 1:case 2:case 3:var W=3;break;default:W=m}var _=m;m=W;try{return M()}finally{m=_}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,W){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var _=m;m=M;try{return W()}finally{m=_}},e.unstable_scheduleCallback=function(M,W,_){var G=e.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?G+_:G):_=G,M){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=_+B,M={id:h++,callback:W,priorityLevel:M,startTime:_,expirationTime:B,sortIndex:-1},_>G?(M.sortIndex=_,t(u,M),s(c)===null&&M===s(u)&&(x?(j(C),C=-1):x=!0,O(y,_-G))):(M.sortIndex=B,t(c,M),g||p||(g=!0,D(N))),M},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(M){var W=m;return function(){var _=m;m=W;try{return M.apply(this,arguments)}finally{m=_}}}})(H0);W0.exports=H0;var nI=W0.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var sI=d,Qn=nI;function he(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var K0=new Set,So={};function sa(e,t){Xa(e,t),Xa(e+"Capture",t)}function Xa(e,t){for(So[e]=t,e=0;e<t.length;e++)K0.add(t[e])}var Rr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Um=Object.prototype.hasOwnProperty,rI=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,zw={},Uw={};function iI(e){return Um.call(Uw,e)?!0:Um.call(zw,e)?!1:rI.test(e)?Uw[e]=!0:(zw[e]=!0,!1)}function aI(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function lI(e,t,s,r){if(t===null||typeof t>"u"||aI(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function En(e,t,s,r,i,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var cn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){cn[e]=new En(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];cn[t]=new En(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){cn[e]=new En(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){cn[e]=new En(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){cn[e]=new En(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){cn[e]=new En(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){cn[e]=new En(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){cn[e]=new En(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){cn[e]=new En(e,5,!1,e.toLowerCase(),null,!1,!1)});var vx=/[\-:]([a-z])/g;function jx(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(vx,jx);cn[t]=new En(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(vx,jx);cn[t]=new En(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(vx,jx);cn[t]=new En(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){cn[e]=new En(e,1,!1,e.toLowerCase(),null,!1,!1)});cn.xlinkHref=new En("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){cn[e]=new En(e,1,!1,e.toLowerCase(),null,!0,!0)});function wx(e,t,s,r){var i=cn.hasOwnProperty(t)?cn[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(lI(t,s,i,r)&&(s=null),r||i===null?iI(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):i.mustUseProperty?e[i.propertyName]=s===null?i.type===3?!1:"":s:(t=i.attributeName,r=i.attributeNamespace,s===null?e.removeAttribute(t):(i=i.type,s=i===3||i===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var zr=sI.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Uc=Symbol.for("react.element"),Na=Symbol.for("react.portal"),Sa=Symbol.for("react.fragment"),yx=Symbol.for("react.strict_mode"),Bm=Symbol.for("react.profiler"),V0=Symbol.for("react.provider"),G0=Symbol.for("react.context"),bx=Symbol.for("react.forward_ref"),Wm=Symbol.for("react.suspense"),Hm=Symbol.for("react.suspense_list"),kx=Symbol.for("react.memo"),Vr=Symbol.for("react.lazy"),Y0=Symbol.for("react.offscreen"),Bw=Symbol.iterator;function Ul(e){return e===null||typeof e!="object"?null:(e=Bw&&e[Bw]||e["@@iterator"],typeof e=="function"?e:null)}var Mt=Object.assign,pf;function so(e){if(pf===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);pf=t&&t[1]||""}return`
|
|
34
|
+
`+pf+e}var gf=!1;function xf(e,t){if(!e||gf)return"";gf=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
|
|
35
|
+
`),a=r.stack.split(`
|
|
36
|
+
`),l=i.length-1,o=a.length-1;1<=l&&0<=o&&i[l]!==a[o];)o--;for(;1<=l&&0<=o;l--,o--)if(i[l]!==a[o]){if(l!==1||o!==1)do if(l--,o--,0>o||i[l]!==a[o]){var c=`
|
|
37
|
+
`+i[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{gf=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?so(e):""}function oI(e){switch(e.tag){case 5:return so(e.type);case 16:return so("Lazy");case 13:return so("Suspense");case 19:return so("SuspenseList");case 0:case 2:case 15:return e=xf(e.type,!1),e;case 11:return e=xf(e.type.render,!1),e;case 1:return e=xf(e.type,!0),e;default:return""}}function Km(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Sa:return"Fragment";case Na:return"Portal";case Bm:return"Profiler";case yx:return"StrictMode";case Wm:return"Suspense";case Hm:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case G0:return(e.displayName||"Context")+".Consumer";case V0:return(e._context.displayName||"Context")+".Provider";case bx:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case kx:return t=e.displayName||null,t!==null?t:Km(e.type)||"Memo";case Vr:t=e._payload,e=e._init;try{return Km(e(t))}catch{}}return null}function cI(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Km(t);case 8:return t===yx?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function di(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function q0(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function uI(e){var t=q0(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var i=s.get,a=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Bc(e){e._valueTracker||(e._valueTracker=uI(e))}function Q0(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=q0(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function td(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Vm(e,t){var s=t.checked;return Mt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function Ww(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=di(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function X0(e,t){t=t.checked,t!=null&&wx(e,"checked",t,!1)}function Gm(e,t){X0(e,t);var s=di(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ym(e,t.type,s):t.hasOwnProperty("defaultValue")&&Ym(e,t.type,di(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Hw(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Ym(e,t,s){(t!=="number"||td(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var ro=Array.isArray;function Fa(e,t,s,r){if(e=e.options,t){t={};for(var i=0;i<s.length;i++)t["$"+s[i]]=!0;for(s=0;s<e.length;s++)i=t.hasOwnProperty("$"+e[s].value),e[s].selected!==i&&(e[s].selected=i),i&&r&&(e[s].defaultSelected=!0)}else{for(s=""+di(s),t=null,i=0;i<e.length;i++){if(e[i].value===s){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function qm(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(he(91));return Mt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Kw(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(he(92));if(ro(s)){if(1<s.length)throw Error(he(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:di(s)}}function J0(e,t){var s=di(t.value),r=di(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function Vw(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Z0(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Qm(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Z0(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Wc,eN=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Wc=Wc||document.createElement("div"),Wc.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Wc.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Co(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var uo={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},dI=["Webkit","ms","Moz","O"];Object.keys(uo).forEach(function(e){dI.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),uo[t]=uo[e]})});function tN(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||uo.hasOwnProperty(e)&&uo[e]?(""+t).trim():t+"px"}function nN(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,i=tN(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,i):e[s]=i}}var hI=Mt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Xm(e,t){if(t){if(hI[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(he(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(he(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(he(61))}if(t.style!=null&&typeof t.style!="object")throw Error(he(62))}}function Jm(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Zm=null;function Nx(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ep=null,za=null,Ua=null;function Gw(e){if(e=pc(e)){if(typeof ep!="function")throw Error(he(280));var t=e.stateNode;t&&(t=rh(t),ep(e.stateNode,e.type,t))}}function sN(e){za?Ua?Ua.push(e):Ua=[e]:za=e}function rN(){if(za){var e=za,t=Ua;if(Ua=za=null,Gw(e),t)for(e=0;e<t.length;e++)Gw(t[e])}}function iN(e,t){return e(t)}function aN(){}var vf=!1;function lN(e,t,s){if(vf)return e(t,s);vf=!0;try{return iN(e,t,s)}finally{vf=!1,(za!==null||Ua!==null)&&(aN(),rN())}}function Eo(e,t){var s=e.stateNode;if(s===null)return null;var r=rh(s);if(r===null)return null;s=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(he(231,t,typeof s));return s}var tp=!1;if(Rr)try{var Bl={};Object.defineProperty(Bl,"passive",{get:function(){tp=!0}}),window.addEventListener("test",Bl,Bl),window.removeEventListener("test",Bl,Bl)}catch{tp=!1}function fI(e,t,s,r,i,a,l,o,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(s,u)}catch(h){this.onError(h)}}var ho=!1,nd=null,sd=!1,np=null,mI={onError:function(e){ho=!0,nd=e}};function pI(e,t,s,r,i,a,l,o,c){ho=!1,nd=null,fI.apply(mI,arguments)}function gI(e,t,s,r,i,a,l,o,c){if(pI.apply(this,arguments),ho){if(ho){var u=nd;ho=!1,nd=null}else throw Error(he(198));sd||(sd=!0,np=u)}}function ra(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function oN(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Yw(e){if(ra(e)!==e)throw Error(he(188))}function xI(e){var t=e.alternate;if(!t){if(t=ra(e),t===null)throw Error(he(188));return t!==e?null:e}for(var s=e,r=t;;){var i=s.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){s=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===s)return Yw(i),e;if(a===r)return Yw(i),t;a=a.sibling}throw Error(he(188))}if(s.return!==r.return)s=i,r=a;else{for(var l=!1,o=i.child;o;){if(o===s){l=!0,s=i,r=a;break}if(o===r){l=!0,r=i,s=a;break}o=o.sibling}if(!l){for(o=a.child;o;){if(o===s){l=!0,s=a,r=i;break}if(o===r){l=!0,r=a,s=i;break}o=o.sibling}if(!l)throw Error(he(189))}}if(s.alternate!==r)throw Error(he(190))}if(s.tag!==3)throw Error(he(188));return s.stateNode.current===s?e:t}function cN(e){return e=xI(e),e!==null?uN(e):null}function uN(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=uN(e);if(t!==null)return t;e=e.sibling}return null}var dN=Qn.unstable_scheduleCallback,qw=Qn.unstable_cancelCallback,vI=Qn.unstable_shouldYield,jI=Qn.unstable_requestPaint,Lt=Qn.unstable_now,wI=Qn.unstable_getCurrentPriorityLevel,Sx=Qn.unstable_ImmediatePriority,hN=Qn.unstable_UserBlockingPriority,rd=Qn.unstable_NormalPriority,yI=Qn.unstable_LowPriority,fN=Qn.unstable_IdlePriority,eh=null,nr=null;function bI(e){if(nr&&typeof nr.onCommitFiberRoot=="function")try{nr.onCommitFiberRoot(eh,e,void 0,(e.current.flags&128)===128)}catch{}}var Ts=Math.clz32?Math.clz32:SI,kI=Math.log,NI=Math.LN2;function SI(e){return e>>>=0,e===0?32:31-(kI(e)/NI|0)|0}var Hc=64,Kc=4194304;function io(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function id(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,l=s&268435455;if(l!==0){var o=l&~i;o!==0?r=io(o):(a&=l,a!==0&&(r=io(a)))}else l=s&~i,l!==0?r=io(l):a!==0&&(r=io(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,a=t&-t,i>=a||i===16&&(a&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-Ts(t),i=1<<s,r|=e[s],t&=~i;return r}function CI(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function EI(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes;0<a;){var l=31-Ts(a),o=1<<l,c=i[l];c===-1?(!(o&s)||o&r)&&(i[l]=CI(o,t)):c<=t&&(e.expiredLanes|=o),a&=~o}}function sp(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function mN(){var e=Hc;return Hc<<=1,!(Hc&4194240)&&(Hc=64),e}function jf(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function fc(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ts(t),e[t]=s}function AI(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<s;){var i=31-Ts(s),a=1<<i;t[i]=0,r[i]=-1,e[i]=-1,s&=~a}}function Cx(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-Ts(s),i=1<<r;i&t|e[r]&t&&(e[r]|=t),s&=~i}}var mt=0;function pN(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var gN,Ex,xN,vN,jN,rp=!1,Vc=[],ei=null,ti=null,ni=null,Ao=new Map,To=new Map,Yr=[],TI="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Qw(e,t){switch(e){case"focusin":case"focusout":ei=null;break;case"dragenter":case"dragleave":ti=null;break;case"mouseover":case"mouseout":ni=null;break;case"pointerover":case"pointerout":Ao.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":To.delete(t.pointerId)}}function Wl(e,t,s,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=pc(t),t!==null&&Ex(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function RI(e,t,s,r,i){switch(t){case"focusin":return ei=Wl(ei,e,t,s,r,i),!0;case"dragenter":return ti=Wl(ti,e,t,s,r,i),!0;case"mouseover":return ni=Wl(ni,e,t,s,r,i),!0;case"pointerover":var a=i.pointerId;return Ao.set(a,Wl(Ao.get(a)||null,e,t,s,r,i)),!0;case"gotpointercapture":return a=i.pointerId,To.set(a,Wl(To.get(a)||null,e,t,s,r,i)),!0}return!1}function wN(e){var t=Fi(e.target);if(t!==null){var s=ra(t);if(s!==null){if(t=s.tag,t===13){if(t=oN(s),t!==null){e.blockedOn=t,jN(e.priority,function(){xN(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function $u(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=ip(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);Zm=r,s.target.dispatchEvent(r),Zm=null}else return t=pc(s),t!==null&&Ex(t),e.blockedOn=s,!1;t.shift()}return!0}function Xw(e,t,s){$u(e)&&s.delete(t)}function $I(){rp=!1,ei!==null&&$u(ei)&&(ei=null),ti!==null&&$u(ti)&&(ti=null),ni!==null&&$u(ni)&&(ni=null),Ao.forEach(Xw),To.forEach(Xw)}function Hl(e,t){e.blockedOn===t&&(e.blockedOn=null,rp||(rp=!0,Qn.unstable_scheduleCallback(Qn.unstable_NormalPriority,$I)))}function Ro(e){function t(i){return Hl(i,e)}if(0<Vc.length){Hl(Vc[0],e);for(var s=1;s<Vc.length;s++){var r=Vc[s];r.blockedOn===e&&(r.blockedOn=null)}}for(ei!==null&&Hl(ei,e),ti!==null&&Hl(ti,e),ni!==null&&Hl(ni,e),Ao.forEach(t),To.forEach(t),s=0;s<Yr.length;s++)r=Yr[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<Yr.length&&(s=Yr[0],s.blockedOn===null);)wN(s),s.blockedOn===null&&Yr.shift()}var Ba=zr.ReactCurrentBatchConfig,ad=!0;function II(e,t,s,r){var i=mt,a=Ba.transition;Ba.transition=null;try{mt=1,Ax(e,t,s,r)}finally{mt=i,Ba.transition=a}}function PI(e,t,s,r){var i=mt,a=Ba.transition;Ba.transition=null;try{mt=4,Ax(e,t,s,r)}finally{mt=i,Ba.transition=a}}function Ax(e,t,s,r){if(ad){var i=ip(e,t,s,r);if(i===null)Tf(e,t,r,ld,s),Qw(e,r);else if(RI(i,e,t,s,r))r.stopPropagation();else if(Qw(e,r),t&4&&-1<TI.indexOf(e)){for(;i!==null;){var a=pc(i);if(a!==null&&gN(a),a=ip(e,t,s,r),a===null&&Tf(e,t,r,ld,s),a===i)break;i=a}i!==null&&r.stopPropagation()}else Tf(e,t,r,null,s)}}var ld=null;function ip(e,t,s,r){if(ld=null,e=Nx(r),e=Fi(e),e!==null)if(t=ra(e),t===null)e=null;else if(s=t.tag,s===13){if(e=oN(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ld=e,null}function yN(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(wI()){case Sx:return 1;case hN:return 4;case rd:case yI:return 16;case fN:return 536870912;default:return 16}default:return 16}}var Qr=null,Tx=null,Iu=null;function bN(){if(Iu)return Iu;var e,t=Tx,s=t.length,r,i="value"in Qr?Qr.value:Qr.textContent,a=i.length;for(e=0;e<s&&t[e]===i[e];e++);var l=s-e;for(r=1;r<=l&&t[s-r]===i[a-r];r++);return Iu=i.slice(e,1<r?1-r:void 0)}function Pu(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Gc(){return!0}function Jw(){return!1}function es(e){function t(s,r,i,a,l){this._reactName=s,this._targetInst=i,this.type=r,this.nativeEvent=a,this.target=l,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(s=e[o],this[o]=s?s(a):a[o]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Gc:Jw,this.isPropagationStopped=Jw,this}return Mt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Gc)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Gc)},persist:function(){},isPersistent:Gc}),t}var gl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Rx=es(gl),mc=Mt({},gl,{view:0,detail:0}),MI=es(mc),wf,yf,Kl,th=Mt({},mc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$x,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Kl&&(Kl&&e.type==="mousemove"?(wf=e.screenX-Kl.screenX,yf=e.screenY-Kl.screenY):yf=wf=0,Kl=e),wf)},movementY:function(e){return"movementY"in e?e.movementY:yf}}),Zw=es(th),DI=Mt({},th,{dataTransfer:0}),OI=es(DI),LI=Mt({},mc,{relatedTarget:0}),bf=es(LI),_I=Mt({},gl,{animationName:0,elapsedTime:0,pseudoElement:0}),FI=es(_I),zI=Mt({},gl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),UI=es(zI),BI=Mt({},gl,{data:0}),ey=es(BI),WI={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},HI={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},KI={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function VI(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=KI[e])?!!t[e]:!1}function $x(){return VI}var GI=Mt({},mc,{key:function(e){if(e.key){var t=WI[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Pu(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?HI[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$x,charCode:function(e){return e.type==="keypress"?Pu(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Pu(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),YI=es(GI),qI=Mt({},th,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ty=es(qI),QI=Mt({},mc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$x}),XI=es(QI),JI=Mt({},gl,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZI=es(JI),eP=Mt({},th,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),tP=es(eP),nP=[9,13,27,32],Ix=Rr&&"CompositionEvent"in window,fo=null;Rr&&"documentMode"in document&&(fo=document.documentMode);var sP=Rr&&"TextEvent"in window&&!fo,kN=Rr&&(!Ix||fo&&8<fo&&11>=fo),ny=" ",sy=!1;function NN(e,t){switch(e){case"keyup":return nP.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function SN(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ca=!1;function rP(e,t){switch(e){case"compositionend":return SN(t);case"keypress":return t.which!==32?null:(sy=!0,ny);case"textInput":return e=t.data,e===ny&&sy?null:e;default:return null}}function iP(e,t){if(Ca)return e==="compositionend"||!Ix&&NN(e,t)?(e=bN(),Iu=Tx=Qr=null,Ca=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return kN&&t.locale!=="ko"?null:t.data;default:return null}}var aP={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ry(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!aP[e.type]:t==="textarea"}function CN(e,t,s,r){sN(r),t=od(t,"onChange"),0<t.length&&(s=new Rx("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var mo=null,$o=null;function lP(e){LN(e,0)}function nh(e){var t=Ta(e);if(Q0(t))return e}function oP(e,t){if(e==="change")return t}var EN=!1;if(Rr){var kf;if(Rr){var Nf="oninput"in document;if(!Nf){var iy=document.createElement("div");iy.setAttribute("oninput","return;"),Nf=typeof iy.oninput=="function"}kf=Nf}else kf=!1;EN=kf&&(!document.documentMode||9<document.documentMode)}function ay(){mo&&(mo.detachEvent("onpropertychange",AN),$o=mo=null)}function AN(e){if(e.propertyName==="value"&&nh($o)){var t=[];CN(t,$o,e,Nx(e)),lN(lP,t)}}function cP(e,t,s){e==="focusin"?(ay(),mo=t,$o=s,mo.attachEvent("onpropertychange",AN)):e==="focusout"&&ay()}function uP(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return nh($o)}function dP(e,t){if(e==="click")return nh(t)}function hP(e,t){if(e==="input"||e==="change")return nh(t)}function fP(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ms=typeof Object.is=="function"?Object.is:fP;function Io(e,t){if(Ms(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var i=s[r];if(!Um.call(t,i)||!Ms(e[i],t[i]))return!1}return!0}function ly(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function oy(e,t){var s=ly(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=ly(s)}}function TN(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?TN(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function RN(){for(var e=window,t=td();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=td(e.document)}return t}function Px(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function mP(e){var t=RN(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&TN(s.ownerDocument.documentElement,s)){if(r!==null&&Px(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=s.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=oy(s,a);var l=oy(s,r);i&&l&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var pP=Rr&&"documentMode"in document&&11>=document.documentMode,Ea=null,ap=null,po=null,lp=!1;function cy(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;lp||Ea==null||Ea!==td(r)||(r=Ea,"selectionStart"in r&&Px(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),po&&Io(po,r)||(po=r,r=od(ap,"onSelect"),0<r.length&&(t=new Rx("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=Ea)))}function Yc(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Aa={animationend:Yc("Animation","AnimationEnd"),animationiteration:Yc("Animation","AnimationIteration"),animationstart:Yc("Animation","AnimationStart"),transitionend:Yc("Transition","TransitionEnd")},Sf={},$N={};Rr&&($N=document.createElement("div").style,"AnimationEvent"in window||(delete Aa.animationend.animation,delete Aa.animationiteration.animation,delete Aa.animationstart.animation),"TransitionEvent"in window||delete Aa.transitionend.transition);function sh(e){if(Sf[e])return Sf[e];if(!Aa[e])return e;var t=Aa[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in $N)return Sf[e]=t[s];return e}var IN=sh("animationend"),PN=sh("animationiteration"),MN=sh("animationstart"),DN=sh("transitionend"),ON=new Map,uy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function yi(e,t){ON.set(e,t),sa(t,[e])}for(var Cf=0;Cf<uy.length;Cf++){var Ef=uy[Cf],gP=Ef.toLowerCase(),xP=Ef[0].toUpperCase()+Ef.slice(1);yi(gP,"on"+xP)}yi(IN,"onAnimationEnd");yi(PN,"onAnimationIteration");yi(MN,"onAnimationStart");yi("dblclick","onDoubleClick");yi("focusin","onFocus");yi("focusout","onBlur");yi(DN,"onTransitionEnd");Xa("onMouseEnter",["mouseout","mouseover"]);Xa("onMouseLeave",["mouseout","mouseover"]);Xa("onPointerEnter",["pointerout","pointerover"]);Xa("onPointerLeave",["pointerout","pointerover"]);sa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));sa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));sa("onBeforeInput",["compositionend","keypress","textInput","paste"]);sa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));sa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));sa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ao="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),vP=new Set("cancel close invalid load scroll toggle".split(" ").concat(ao));function dy(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,gI(r,t,void 0,e),e.currentTarget=null}function LN(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],i=r.event;r=r.listeners;e:{var a=void 0;if(t)for(var l=r.length-1;0<=l;l--){var o=r[l],c=o.instance,u=o.currentTarget;if(o=o.listener,c!==a&&i.isPropagationStopped())break e;dy(i,o,u),a=c}else for(l=0;l<r.length;l++){if(o=r[l],c=o.instance,u=o.currentTarget,o=o.listener,c!==a&&i.isPropagationStopped())break e;dy(i,o,u),a=c}}}if(sd)throw e=np,sd=!1,np=null,e}function kt(e,t){var s=t[hp];s===void 0&&(s=t[hp]=new Set);var r=e+"__bubble";s.has(r)||(_N(t,e,2,!1),s.add(r))}function Af(e,t,s){var r=0;t&&(r|=4),_N(s,e,r,t)}var qc="_reactListening"+Math.random().toString(36).slice(2);function Po(e){if(!e[qc]){e[qc]=!0,K0.forEach(function(s){s!=="selectionchange"&&(vP.has(s)||Af(s,!1,e),Af(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[qc]||(t[qc]=!0,Af("selectionchange",!1,t))}}function _N(e,t,s,r){switch(yN(t)){case 1:var i=II;break;case 4:i=PI;break;default:i=Ax}s=i.bind(null,t,s,e),i=void 0,!tp||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,s,{capture:!0,passive:i}):e.addEventListener(t,s,!0):i!==void 0?e.addEventListener(t,s,{passive:i}):e.addEventListener(t,s,!1)}function Tf(e,t,s,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var o=r.stateNode.containerInfo;if(o===i||o.nodeType===8&&o.parentNode===i)break;if(l===4)for(l=r.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;l=l.return}for(;o!==null;){if(l=Fi(o),l===null)return;if(c=l.tag,c===5||c===6){r=a=l;continue e}o=o.parentNode}}r=r.return}lN(function(){var u=a,h=Nx(s),f=[];e:{var m=ON.get(e);if(m!==void 0){var p=Rx,g=e;switch(e){case"keypress":if(Pu(s)===0)break e;case"keydown":case"keyup":p=YI;break;case"focusin":g="focus",p=bf;break;case"focusout":g="blur",p=bf;break;case"beforeblur":case"afterblur":p=bf;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=Zw;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=OI;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=XI;break;case IN:case PN:case MN:p=FI;break;case DN:p=ZI;break;case"scroll":p=MI;break;case"wheel":p=tP;break;case"copy":case"cut":case"paste":p=UI;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=ty}var x=(t&4)!==0,b=!x&&e==="scroll",j=x?m!==null?m+"Capture":null:m;x=[];for(var v=u,w;v!==null;){w=v;var y=w.stateNode;if(w.tag===5&&y!==null&&(w=y,j!==null&&(y=Eo(v,j),y!=null&&x.push(Mo(v,y,w)))),b)break;v=v.return}0<x.length&&(m=new p(m,g,null,s,h),f.push({event:m,listeners:x}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",m&&s!==Zm&&(g=s.relatedTarget||s.fromElement)&&(Fi(g)||g[$r]))break e;if((p||m)&&(m=h.window===h?h:(m=h.ownerDocument)?m.defaultView||m.parentWindow:window,p?(g=s.relatedTarget||s.toElement,p=u,g=g?Fi(g):null,g!==null&&(b=ra(g),g!==b||g.tag!==5&&g.tag!==6)&&(g=null)):(p=null,g=u),p!==g)){if(x=Zw,y="onMouseLeave",j="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(x=ty,y="onPointerLeave",j="onPointerEnter",v="pointer"),b=p==null?m:Ta(p),w=g==null?m:Ta(g),m=new x(y,v+"leave",p,s,h),m.target=b,m.relatedTarget=w,y=null,Fi(h)===u&&(x=new x(j,v+"enter",g,s,h),x.target=w,x.relatedTarget=b,y=x),b=y,p&&g)t:{for(x=p,j=g,v=0,w=x;w;w=ga(w))v++;for(w=0,y=j;y;y=ga(y))w++;for(;0<v-w;)x=ga(x),v--;for(;0<w-v;)j=ga(j),w--;for(;v--;){if(x===j||j!==null&&x===j.alternate)break t;x=ga(x),j=ga(j)}x=null}else x=null;p!==null&&hy(f,m,p,x,!1),g!==null&&b!==null&&hy(f,b,g,x,!0)}}e:{if(m=u?Ta(u):window,p=m.nodeName&&m.nodeName.toLowerCase(),p==="select"||p==="input"&&m.type==="file")var N=oP;else if(ry(m))if(EN)N=hP;else{N=uP;var k=cP}else(p=m.nodeName)&&p.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(N=dP);if(N&&(N=N(e,u))){CN(f,N,s,h);break e}k&&k(e,m,u),e==="focusout"&&(k=m._wrapperState)&&k.controlled&&m.type==="number"&&Ym(m,"number",m.value)}switch(k=u?Ta(u):window,e){case"focusin":(ry(k)||k.contentEditable==="true")&&(Ea=k,ap=u,po=null);break;case"focusout":po=ap=Ea=null;break;case"mousedown":lp=!0;break;case"contextmenu":case"mouseup":case"dragend":lp=!1,cy(f,s,h);break;case"selectionchange":if(pP)break;case"keydown":case"keyup":cy(f,s,h)}var S;if(Ix)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Ca?NN(e,s)&&(C="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(C="onCompositionStart");C&&(kN&&s.locale!=="ko"&&(Ca||C!=="onCompositionStart"?C==="onCompositionEnd"&&Ca&&(S=bN()):(Qr=h,Tx="value"in Qr?Qr.value:Qr.textContent,Ca=!0)),k=od(u,C),0<k.length&&(C=new ey(C,e,null,s,h),f.push({event:C,listeners:k}),S?C.data=S:(S=SN(s),S!==null&&(C.data=S)))),(S=sP?rP(e,s):iP(e,s))&&(u=od(u,"onBeforeInput"),0<u.length&&(h=new ey("onBeforeInput","beforeinput",null,s,h),f.push({event:h,listeners:u}),h.data=S))}LN(f,t)})}function Mo(e,t,s){return{instance:e,listener:t,currentTarget:s}}function od(e,t){for(var s=t+"Capture",r=[];e!==null;){var i=e,a=i.stateNode;i.tag===5&&a!==null&&(i=a,a=Eo(e,s),a!=null&&r.unshift(Mo(e,a,i)),a=Eo(e,t),a!=null&&r.push(Mo(e,a,i))),e=e.return}return r}function ga(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function hy(e,t,s,r,i){for(var a=t._reactName,l=[];s!==null&&s!==r;){var o=s,c=o.alternate,u=o.stateNode;if(c!==null&&c===r)break;o.tag===5&&u!==null&&(o=u,i?(c=Eo(s,a),c!=null&&l.unshift(Mo(s,c,o))):i||(c=Eo(s,a),c!=null&&l.push(Mo(s,c,o)))),s=s.return}l.length!==0&&e.push({event:t,listeners:l})}var jP=/\r\n?/g,wP=/\u0000|\uFFFD/g;function fy(e){return(typeof e=="string"?e:""+e).replace(jP,`
|
|
38
|
+
`).replace(wP,"")}function Qc(e,t,s){if(t=fy(t),fy(e)!==t&&s)throw Error(he(425))}function cd(){}var op=null,cp=null;function up(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var dp=typeof setTimeout=="function"?setTimeout:void 0,yP=typeof clearTimeout=="function"?clearTimeout:void 0,my=typeof Promise=="function"?Promise:void 0,bP=typeof queueMicrotask=="function"?queueMicrotask:typeof my<"u"?function(e){return my.resolve(null).then(e).catch(kP)}:dp;function kP(e){setTimeout(function(){throw e})}function Rf(e,t){var s=t,r=0;do{var i=s.nextSibling;if(e.removeChild(s),i&&i.nodeType===8)if(s=i.data,s==="/$"){if(r===0){e.removeChild(i),Ro(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=i}while(s);Ro(t)}function si(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function py(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var xl=Math.random().toString(36).slice(2),Js="__reactFiber$"+xl,Do="__reactProps$"+xl,$r="__reactContainer$"+xl,hp="__reactEvents$"+xl,NP="__reactListeners$"+xl,SP="__reactHandles$"+xl;function Fi(e){var t=e[Js];if(t)return t;for(var s=e.parentNode;s;){if(t=s[$r]||s[Js]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=py(e);e!==null;){if(s=e[Js])return s;e=py(e)}return t}e=s,s=e.parentNode}return null}function pc(e){return e=e[Js]||e[$r],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ta(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(he(33))}function rh(e){return e[Do]||null}var fp=[],Ra=-1;function bi(e){return{current:e}}function Nt(e){0>Ra||(e.current=fp[Ra],fp[Ra]=null,Ra--)}function wt(e,t){Ra++,fp[Ra]=e.current,e.current=t}var hi={},vn=bi(hi),Mn=bi(!1),Yi=hi;function Ja(e,t){var s=e.type.contextTypes;if(!s)return hi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in s)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Dn(e){return e=e.childContextTypes,e!=null}function ud(){Nt(Mn),Nt(vn)}function gy(e,t,s){if(vn.current!==hi)throw Error(he(168));wt(vn,t),wt(Mn,s)}function FN(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(he(108,cI(e)||"Unknown",i));return Mt({},s,r)}function dd(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||hi,Yi=vn.current,wt(vn,e),wt(Mn,Mn.current),!0}function xy(e,t,s){var r=e.stateNode;if(!r)throw Error(he(169));s?(e=FN(e,t,Yi),r.__reactInternalMemoizedMergedChildContext=e,Nt(Mn),Nt(vn),wt(vn,e)):Nt(Mn),wt(Mn,s)}var vr=null,ih=!1,$f=!1;function zN(e){vr===null?vr=[e]:vr.push(e)}function CP(e){ih=!0,zN(e)}function ki(){if(!$f&&vr!==null){$f=!0;var e=0,t=mt;try{var s=vr;for(mt=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}vr=null,ih=!1}catch(i){throw vr!==null&&(vr=vr.slice(e+1)),dN(Sx,ki),i}finally{mt=t,$f=!1}}return null}var $a=[],Ia=0,hd=null,fd=0,os=[],cs=0,qi=null,br=1,kr="";function Mi(e,t){$a[Ia++]=fd,$a[Ia++]=hd,hd=e,fd=t}function UN(e,t,s){os[cs++]=br,os[cs++]=kr,os[cs++]=qi,qi=e;var r=br;e=kr;var i=32-Ts(r)-1;r&=~(1<<i),s+=1;var a=32-Ts(t)+i;if(30<a){var l=i-i%5;a=(r&(1<<l)-1).toString(32),r>>=l,i-=l,br=1<<32-Ts(t)+i|s<<i|r,kr=a+e}else br=1<<a|s<<i|r,kr=e}function Mx(e){e.return!==null&&(Mi(e,1),UN(e,1,0))}function Dx(e){for(;e===hd;)hd=$a[--Ia],$a[Ia]=null,fd=$a[--Ia],$a[Ia]=null;for(;e===qi;)qi=os[--cs],os[cs]=null,kr=os[--cs],os[cs]=null,br=os[--cs],os[cs]=null}var Yn=null,Vn=null,Ct=!1,Es=null;function BN(e,t){var s=fs(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function vy(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Yn=e,Vn=si(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Yn=e,Vn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=qi!==null?{id:br,overflow:kr}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=fs(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,Yn=e,Vn=null,!0):!1;default:return!1}}function mp(e){return(e.mode&1)!==0&&(e.flags&128)===0}function pp(e){if(Ct){var t=Vn;if(t){var s=t;if(!vy(e,t)){if(mp(e))throw Error(he(418));t=si(s.nextSibling);var r=Yn;t&&vy(e,t)?BN(r,s):(e.flags=e.flags&-4097|2,Ct=!1,Yn=e)}}else{if(mp(e))throw Error(he(418));e.flags=e.flags&-4097|2,Ct=!1,Yn=e}}}function jy(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Yn=e}function Xc(e){if(e!==Yn)return!1;if(!Ct)return jy(e),Ct=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!up(e.type,e.memoizedProps)),t&&(t=Vn)){if(mp(e))throw WN(),Error(he(418));for(;t;)BN(e,t),t=si(t.nextSibling)}if(jy(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(he(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){Vn=si(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}Vn=null}}else Vn=Yn?si(e.stateNode.nextSibling):null;return!0}function WN(){for(var e=Vn;e;)e=si(e.nextSibling)}function Za(){Vn=Yn=null,Ct=!1}function Ox(e){Es===null?Es=[e]:Es.push(e)}var EP=zr.ReactCurrentBatchConfig;function Vl(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(he(309));var r=s.stateNode}if(!r)throw Error(he(147,e));var i=r,a=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===a?t.ref:(t=function(l){var o=i.refs;l===null?delete o[a]:o[a]=l},t._stringRef=a,t)}if(typeof e!="string")throw Error(he(284));if(!s._owner)throw Error(he(290,e))}return e}function Jc(e,t){throw e=Object.prototype.toString.call(t),Error(he(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function wy(e){var t=e._init;return t(e._payload)}function HN(e){function t(j,v){if(e){var w=j.deletions;w===null?(j.deletions=[v],j.flags|=16):w.push(v)}}function s(j,v){if(!e)return null;for(;v!==null;)t(j,v),v=v.sibling;return null}function r(j,v){for(j=new Map;v!==null;)v.key!==null?j.set(v.key,v):j.set(v.index,v),v=v.sibling;return j}function i(j,v){return j=li(j,v),j.index=0,j.sibling=null,j}function a(j,v,w){return j.index=w,e?(w=j.alternate,w!==null?(w=w.index,w<v?(j.flags|=2,v):w):(j.flags|=2,v)):(j.flags|=1048576,v)}function l(j){return e&&j.alternate===null&&(j.flags|=2),j}function o(j,v,w,y){return v===null||v.tag!==6?(v=_f(w,j.mode,y),v.return=j,v):(v=i(v,w),v.return=j,v)}function c(j,v,w,y){var N=w.type;return N===Sa?h(j,v,w.props.children,y,w.key):v!==null&&(v.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Vr&&wy(N)===v.type)?(y=i(v,w.props),y.ref=Vl(j,v,w),y.return=j,y):(y=zu(w.type,w.key,w.props,null,j.mode,y),y.ref=Vl(j,v,w),y.return=j,y)}function u(j,v,w,y){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=Ff(w,j.mode,y),v.return=j,v):(v=i(v,w.children||[]),v.return=j,v)}function h(j,v,w,y,N){return v===null||v.tag!==7?(v=Ki(w,j.mode,y,N),v.return=j,v):(v=i(v,w),v.return=j,v)}function f(j,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=_f(""+v,j.mode,w),v.return=j,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Uc:return w=zu(v.type,v.key,v.props,null,j.mode,w),w.ref=Vl(j,null,v),w.return=j,w;case Na:return v=Ff(v,j.mode,w),v.return=j,v;case Vr:var y=v._init;return f(j,y(v._payload),w)}if(ro(v)||Ul(v))return v=Ki(v,j.mode,w,null),v.return=j,v;Jc(j,v)}return null}function m(j,v,w,y){var N=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return N!==null?null:o(j,v,""+w,y);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Uc:return w.key===N?c(j,v,w,y):null;case Na:return w.key===N?u(j,v,w,y):null;case Vr:return N=w._init,m(j,v,N(w._payload),y)}if(ro(w)||Ul(w))return N!==null?null:h(j,v,w,y,null);Jc(j,w)}return null}function p(j,v,w,y,N){if(typeof y=="string"&&y!==""||typeof y=="number")return j=j.get(w)||null,o(v,j,""+y,N);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Uc:return j=j.get(y.key===null?w:y.key)||null,c(v,j,y,N);case Na:return j=j.get(y.key===null?w:y.key)||null,u(v,j,y,N);case Vr:var k=y._init;return p(j,v,w,k(y._payload),N)}if(ro(y)||Ul(y))return j=j.get(w)||null,h(v,j,y,N,null);Jc(v,y)}return null}function g(j,v,w,y){for(var N=null,k=null,S=v,C=v=0,$=null;S!==null&&C<w.length;C++){S.index>C?($=S,S=null):$=S.sibling;var R=m(j,S,w[C],y);if(R===null){S===null&&(S=$);break}e&&S&&R.alternate===null&&t(j,S),v=a(R,v,C),k===null?N=R:k.sibling=R,k=R,S=$}if(C===w.length)return s(j,S),Ct&&Mi(j,C),N;if(S===null){for(;C<w.length;C++)S=f(j,w[C],y),S!==null&&(v=a(S,v,C),k===null?N=S:k.sibling=S,k=S);return Ct&&Mi(j,C),N}for(S=r(j,S);C<w.length;C++)$=p(S,j,C,w[C],y),$!==null&&(e&&$.alternate!==null&&S.delete($.key===null?C:$.key),v=a($,v,C),k===null?N=$:k.sibling=$,k=$);return e&&S.forEach(function(I){return t(j,I)}),Ct&&Mi(j,C),N}function x(j,v,w,y){var N=Ul(w);if(typeof N!="function")throw Error(he(150));if(w=N.call(w),w==null)throw Error(he(151));for(var k=N=null,S=v,C=v=0,$=null,R=w.next();S!==null&&!R.done;C++,R=w.next()){S.index>C?($=S,S=null):$=S.sibling;var I=m(j,S,R.value,y);if(I===null){S===null&&(S=$);break}e&&S&&I.alternate===null&&t(j,S),v=a(I,v,C),k===null?N=I:k.sibling=I,k=I,S=$}if(R.done)return s(j,S),Ct&&Mi(j,C),N;if(S===null){for(;!R.done;C++,R=w.next())R=f(j,R.value,y),R!==null&&(v=a(R,v,C),k===null?N=R:k.sibling=R,k=R);return Ct&&Mi(j,C),N}for(S=r(j,S);!R.done;C++,R=w.next())R=p(S,j,C,R.value,y),R!==null&&(e&&R.alternate!==null&&S.delete(R.key===null?C:R.key),v=a(R,v,C),k===null?N=R:k.sibling=R,k=R);return e&&S.forEach(function(z){return t(j,z)}),Ct&&Mi(j,C),N}function b(j,v,w,y){if(typeof w=="object"&&w!==null&&w.type===Sa&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Uc:e:{for(var N=w.key,k=v;k!==null;){if(k.key===N){if(N=w.type,N===Sa){if(k.tag===7){s(j,k.sibling),v=i(k,w.props.children),v.return=j,j=v;break e}}else if(k.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Vr&&wy(N)===k.type){s(j,k.sibling),v=i(k,w.props),v.ref=Vl(j,k,w),v.return=j,j=v;break e}s(j,k);break}else t(j,k);k=k.sibling}w.type===Sa?(v=Ki(w.props.children,j.mode,y,w.key),v.return=j,j=v):(y=zu(w.type,w.key,w.props,null,j.mode,y),y.ref=Vl(j,v,w),y.return=j,j=y)}return l(j);case Na:e:{for(k=w.key;v!==null;){if(v.key===k)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){s(j,v.sibling),v=i(v,w.children||[]),v.return=j,j=v;break e}else{s(j,v);break}else t(j,v);v=v.sibling}v=Ff(w,j.mode,y),v.return=j,j=v}return l(j);case Vr:return k=w._init,b(j,v,k(w._payload),y)}if(ro(w))return g(j,v,w,y);if(Ul(w))return x(j,v,w,y);Jc(j,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(s(j,v.sibling),v=i(v,w),v.return=j,j=v):(s(j,v),v=_f(w,j.mode,y),v.return=j,j=v),l(j)):s(j,v)}return b}var el=HN(!0),KN=HN(!1),md=bi(null),pd=null,Pa=null,Lx=null;function _x(){Lx=Pa=pd=null}function Fx(e){var t=md.current;Nt(md),e._currentValue=t}function gp(e,t,s){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===s)break;e=e.return}}function Wa(e,t){pd=e,Lx=Pa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Pn=!0),e.firstContext=null)}function gs(e){var t=e._currentValue;if(Lx!==e)if(e={context:e,memoizedValue:t,next:null},Pa===null){if(pd===null)throw Error(he(308));Pa=e,pd.dependencies={lanes:0,firstContext:e}}else Pa=Pa.next=e;return t}var zi=null;function zx(e){zi===null?zi=[e]:zi.push(e)}function VN(e,t,s,r){var i=t.interleaved;return i===null?(s.next=s,zx(t)):(s.next=i.next,i.next=s),t.interleaved=s,Ir(e,r)}function Ir(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var Gr=!1;function Ux(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function GN(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Sr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ri(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,st&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ir(e,s)}return i=r.interleaved,i===null?(t.next=t,zx(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ir(e,s)}function Mu(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Cx(e,s)}}function yy(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var i=null,a=null;if(s=s.firstBaseUpdate,s!==null){do{var l={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};a===null?i=a=l:a=a.next=l,s=s.next}while(s!==null);a===null?i=a=t:a=a.next=t}else i=a=t;s={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function gd(e,t,s,r){var i=e.updateQueue;Gr=!1;var a=i.firstBaseUpdate,l=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?a=u:l.next=u,l=c;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=u:o.next=u,h.lastBaseUpdate=c))}if(a!==null){var f=i.baseState;l=0,h=u=c=null,o=a;do{var m=o.lane,p=o.eventTime;if((r&m)===m){h!==null&&(h=h.next={eventTime:p,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var g=e,x=o;switch(m=t,p=s,x.tag){case 1:if(g=x.payload,typeof g=="function"){f=g.call(p,f,m);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=x.payload,m=typeof g=="function"?g.call(p,f,m):g,m==null)break e;f=Mt({},f,m);break e;case 2:Gr=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=i.effects,m===null?i.effects=[o]:m.push(o))}else p={eventTime:p,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(u=h=p,c=f):h=h.next=p,l|=m;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;m=o,o=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(!0);if(h===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=h,t=i.shared.interleaved,t!==null){i=t;do l|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Xi|=l,e.lanes=l,e.memoizedState=f}}function by(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=s,typeof i!="function")throw Error(he(191,i));i.call(r)}}}var gc={},sr=bi(gc),Oo=bi(gc),Lo=bi(gc);function Ui(e){if(e===gc)throw Error(he(174));return e}function Bx(e,t){switch(wt(Lo,t),wt(Oo,e),wt(sr,gc),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Qm(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Qm(t,e)}Nt(sr),wt(sr,t)}function tl(){Nt(sr),Nt(Oo),Nt(Lo)}function YN(e){Ui(Lo.current);var t=Ui(sr.current),s=Qm(t,e.type);t!==s&&(wt(Oo,e),wt(sr,s))}function Wx(e){Oo.current===e&&(Nt(sr),Nt(Oo))}var $t=bi(0);function xd(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var If=[];function Hx(){for(var e=0;e<If.length;e++)If[e]._workInProgressVersionPrimary=null;If.length=0}var Du=zr.ReactCurrentDispatcher,Pf=zr.ReactCurrentBatchConfig,Qi=0,It=null,Kt=null,Jt=null,vd=!1,go=!1,_o=0,AP=0;function fn(){throw Error(he(321))}function Kx(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Ms(e[s],t[s]))return!1;return!0}function Vx(e,t,s,r,i,a){if(Qi=a,It=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Du.current=e===null||e.memoizedState===null?IP:PP,e=s(r,i),go){a=0;do{if(go=!1,_o=0,25<=a)throw Error(he(301));a+=1,Jt=Kt=null,t.updateQueue=null,Du.current=MP,e=s(r,i)}while(go)}if(Du.current=jd,t=Kt!==null&&Kt.next!==null,Qi=0,Jt=Kt=It=null,vd=!1,t)throw Error(he(300));return e}function Gx(){var e=_o!==0;return _o=0,e}function Qs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jt===null?It.memoizedState=Jt=e:Jt=Jt.next=e,Jt}function xs(){if(Kt===null){var e=It.alternate;e=e!==null?e.memoizedState:null}else e=Kt.next;var t=Jt===null?It.memoizedState:Jt.next;if(t!==null)Jt=t,Kt=e;else{if(e===null)throw Error(he(310));Kt=e,e={memoizedState:Kt.memoizedState,baseState:Kt.baseState,baseQueue:Kt.baseQueue,queue:Kt.queue,next:null},Jt===null?It.memoizedState=Jt=e:Jt=Jt.next=e}return Jt}function Fo(e,t){return typeof t=="function"?t(e):t}function Mf(e){var t=xs(),s=t.queue;if(s===null)throw Error(he(311));s.lastRenderedReducer=e;var r=Kt,i=r.baseQueue,a=s.pending;if(a!==null){if(i!==null){var l=i.next;i.next=a.next,a.next=l}r.baseQueue=i=a,s.pending=null}if(i!==null){a=i.next,r=r.baseState;var o=l=null,c=null,u=a;do{var h=u.lane;if((Qi&h)===h)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:h,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(o=c=f,l=r):c=c.next=f,It.lanes|=h,Xi|=h}u=u.next}while(u!==null&&u!==a);c===null?l=r:c.next=o,Ms(r,t.memoizedState)||(Pn=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,s.lastRenderedState=r}if(e=s.interleaved,e!==null){i=e;do a=i.lane,It.lanes|=a,Xi|=a,i=i.next;while(i!==e)}else i===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function Df(e){var t=xs(),s=t.queue;if(s===null)throw Error(he(311));s.lastRenderedReducer=e;var r=s.dispatch,i=s.pending,a=t.memoizedState;if(i!==null){s.pending=null;var l=i=i.next;do a=e(a,l.action),l=l.next;while(l!==i);Ms(a,t.memoizedState)||(Pn=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),s.lastRenderedState=a}return[a,r]}function qN(){}function QN(e,t){var s=It,r=xs(),i=t(),a=!Ms(r.memoizedState,i);if(a&&(r.memoizedState=i,Pn=!0),r=r.queue,Yx(ZN.bind(null,s,r,e),[e]),r.getSnapshot!==t||a||Jt!==null&&Jt.memoizedState.tag&1){if(s.flags|=2048,zo(9,JN.bind(null,s,r,i,t),void 0,null),nn===null)throw Error(he(349));Qi&30||XN(s,t,i)}return i}function XN(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=It.updateQueue,t===null?(t={lastEffect:null,stores:null},It.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function JN(e,t,s,r){t.value=s,t.getSnapshot=r,eS(t)&&tS(e)}function ZN(e,t,s){return s(function(){eS(t)&&tS(e)})}function eS(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Ms(e,s)}catch{return!0}}function tS(e){var t=Ir(e,1);t!==null&&Rs(t,e,1,-1)}function ky(e){var t=Qs();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:e},t.queue=e,e=e.dispatch=$P.bind(null,It,e),[t.memoizedState,e]}function zo(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=It.updateQueue,t===null?(t={lastEffect:null,stores:null},It.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function nS(){return xs().memoizedState}function Ou(e,t,s,r){var i=Qs();It.flags|=e,i.memoizedState=zo(1|t,s,void 0,r===void 0?null:r)}function ah(e,t,s,r){var i=xs();r=r===void 0?null:r;var a=void 0;if(Kt!==null){var l=Kt.memoizedState;if(a=l.destroy,r!==null&&Kx(r,l.deps)){i.memoizedState=zo(t,s,a,r);return}}It.flags|=e,i.memoizedState=zo(1|t,s,a,r)}function Ny(e,t){return Ou(8390656,8,e,t)}function Yx(e,t){return ah(2048,8,e,t)}function sS(e,t){return ah(4,2,e,t)}function rS(e,t){return ah(4,4,e,t)}function iS(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function aS(e,t,s){return s=s!=null?s.concat([e]):null,ah(4,4,iS.bind(null,t,e),s)}function qx(){}function lS(e,t){var s=xs();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Kx(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function oS(e,t){var s=xs();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Kx(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function cS(e,t,s){return Qi&21?(Ms(s,t)||(s=mN(),It.lanes|=s,Xi|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Pn=!0),e.memoizedState=s)}function TP(e,t){var s=mt;mt=s!==0&&4>s?s:4,e(!0);var r=Pf.transition;Pf.transition={};try{e(!1),t()}finally{mt=s,Pf.transition=r}}function uS(){return xs().memoizedState}function RP(e,t,s){var r=ai(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},dS(e))hS(t,s);else if(s=VN(e,t,s,r),s!==null){var i=Nn();Rs(s,e,r,i),fS(s,t,r)}}function $P(e,t,s){var r=ai(e),i={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(dS(e))hS(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,s);if(i.hasEagerState=!0,i.eagerState=o,Ms(o,l)){var c=t.interleaved;c===null?(i.next=i,zx(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}s=VN(e,t,i,r),s!==null&&(i=Nn(),Rs(s,e,r,i),fS(s,t,r))}}function dS(e){var t=e.alternate;return e===It||t!==null&&t===It}function hS(e,t){go=vd=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function fS(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,Cx(e,s)}}var jd={readContext:gs,useCallback:fn,useContext:fn,useEffect:fn,useImperativeHandle:fn,useInsertionEffect:fn,useLayoutEffect:fn,useMemo:fn,useReducer:fn,useRef:fn,useState:fn,useDebugValue:fn,useDeferredValue:fn,useTransition:fn,useMutableSource:fn,useSyncExternalStore:fn,useId:fn,unstable_isNewReconciler:!1},IP={readContext:gs,useCallback:function(e,t){return Qs().memoizedState=[e,t===void 0?null:t],e},useContext:gs,useEffect:Ny,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,Ou(4194308,4,iS.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Ou(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ou(4,2,e,t)},useMemo:function(e,t){var s=Qs();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=Qs();return t=s!==void 0?s(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=RP.bind(null,It,e),[r.memoizedState,e]},useRef:function(e){var t=Qs();return e={current:e},t.memoizedState=e},useState:ky,useDebugValue:qx,useDeferredValue:function(e){return Qs().memoizedState=e},useTransition:function(){var e=ky(!1),t=e[0];return e=TP.bind(null,e[1]),Qs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=It,i=Qs();if(Ct){if(s===void 0)throw Error(he(407));s=s()}else{if(s=t(),nn===null)throw Error(he(349));Qi&30||XN(r,t,s)}i.memoizedState=s;var a={value:s,getSnapshot:t};return i.queue=a,Ny(ZN.bind(null,r,a,e),[e]),r.flags|=2048,zo(9,JN.bind(null,r,a,s,t),void 0,null),s},useId:function(){var e=Qs(),t=nn.identifierPrefix;if(Ct){var s=kr,r=br;s=(r&~(1<<32-Ts(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=_o++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=AP++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},PP={readContext:gs,useCallback:lS,useContext:gs,useEffect:Yx,useImperativeHandle:aS,useInsertionEffect:sS,useLayoutEffect:rS,useMemo:oS,useReducer:Mf,useRef:nS,useState:function(){return Mf(Fo)},useDebugValue:qx,useDeferredValue:function(e){var t=xs();return cS(t,Kt.memoizedState,e)},useTransition:function(){var e=Mf(Fo)[0],t=xs().memoizedState;return[e,t]},useMutableSource:qN,useSyncExternalStore:QN,useId:uS,unstable_isNewReconciler:!1},MP={readContext:gs,useCallback:lS,useContext:gs,useEffect:Yx,useImperativeHandle:aS,useInsertionEffect:sS,useLayoutEffect:rS,useMemo:oS,useReducer:Df,useRef:nS,useState:function(){return Df(Fo)},useDebugValue:qx,useDeferredValue:function(e){var t=xs();return Kt===null?t.memoizedState=e:cS(t,Kt.memoizedState,e)},useTransition:function(){var e=Df(Fo)[0],t=xs().memoizedState;return[e,t]},useMutableSource:qN,useSyncExternalStore:QN,useId:uS,unstable_isNewReconciler:!1};function Ss(e,t){if(e&&e.defaultProps){t=Mt({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function xp(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:Mt({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var lh={isMounted:function(e){return(e=e._reactInternals)?ra(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=Nn(),i=ai(e),a=Sr(r,i);a.payload=t,s!=null&&(a.callback=s),t=ri(e,a,i),t!==null&&(Rs(t,e,i,r),Mu(t,e,i))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=Nn(),i=ai(e),a=Sr(r,i);a.tag=1,a.payload=t,s!=null&&(a.callback=s),t=ri(e,a,i),t!==null&&(Rs(t,e,i,r),Mu(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Nn(),r=ai(e),i=Sr(s,r);i.tag=2,t!=null&&(i.callback=t),t=ri(e,i,r),t!==null&&(Rs(t,e,r,s),Mu(t,e,r))}};function Sy(e,t,s,r,i,a,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,a,l):t.prototype&&t.prototype.isPureReactComponent?!Io(s,r)||!Io(i,a):!0}function mS(e,t,s){var r=!1,i=hi,a=t.contextType;return typeof a=="object"&&a!==null?a=gs(a):(i=Dn(t)?Yi:vn.current,r=t.contextTypes,a=(r=r!=null)?Ja(e,i):hi),t=new t(s,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=lh,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=a),t}function Cy(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&lh.enqueueReplaceState(t,t.state,null)}function vp(e,t,s,r){var i=e.stateNode;i.props=s,i.state=e.memoizedState,i.refs={},Ux(e);var a=t.contextType;typeof a=="object"&&a!==null?i.context=gs(a):(a=Dn(t)?Yi:vn.current,i.context=Ja(e,a)),i.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(xp(e,t,a,s),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&lh.enqueueReplaceState(i,i.state,null),gd(e,s,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function nl(e,t){try{var s="",r=t;do s+=oI(r),r=r.return;while(r);var i=s}catch(a){i=`
|
|
39
|
+
Error generating stack: `+a.message+`
|
|
40
|
+
`+a.stack}return{value:e,source:t,stack:i,digest:null}}function Of(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function jp(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var DP=typeof WeakMap=="function"?WeakMap:Map;function pS(e,t,s){s=Sr(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){yd||(yd=!0,Tp=r),jp(e,t)},s}function gS(e,t,s){s=Sr(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;s.payload=function(){return r(i)},s.callback=function(){jp(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(s.callback=function(){jp(e,t),typeof r!="function"&&(ii===null?ii=new Set([this]):ii.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),s}function Ey(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new DP;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(s)||(i.add(s),e=qP.bind(null,e,t,s),t.then(e,e))}function Ay(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Ty(e,t,s,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=Sr(-1,1),t.tag=2,ri(s,t,1))),s.lanes|=1),e)}var OP=zr.ReactCurrentOwner,Pn=!1;function bn(e,t,s,r){t.child=e===null?KN(t,null,s,r):el(t,e.child,s,r)}function Ry(e,t,s,r,i){s=s.render;var a=t.ref;return Wa(t,i),r=Vx(e,t,s,r,a,i),s=Gx(),e!==null&&!Pn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Pr(e,t,i)):(Ct&&s&&Mx(t),t.flags|=1,bn(e,t,r,i),t.child)}function $y(e,t,s,r,i){if(e===null){var a=s.type;return typeof a=="function"&&!sv(a)&&a.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=a,xS(e,t,a,r,i)):(e=zu(s.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&i)){var l=a.memoizedProps;if(s=s.compare,s=s!==null?s:Io,s(l,r)&&e.ref===t.ref)return Pr(e,t,i)}return t.flags|=1,e=li(a,r),e.ref=t.ref,e.return=t,t.child=e}function xS(e,t,s,r,i){if(e!==null){var a=e.memoizedProps;if(Io(a,r)&&e.ref===t.ref)if(Pn=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Pn=!0);else return t.lanes=e.lanes,Pr(e,t,i)}return wp(e,t,s,r,i)}function vS(e,t,s){var r=t.pendingProps,i=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},wt(Da,Hn),Hn|=s;else{if(!(s&1073741824))return e=a!==null?a.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,wt(Da,Hn),Hn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:s,wt(Da,Hn),Hn|=r}else a!==null?(r=a.baseLanes|s,t.memoizedState=null):r=s,wt(Da,Hn),Hn|=r;return bn(e,t,i,s),t.child}function jS(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function wp(e,t,s,r,i){var a=Dn(s)?Yi:vn.current;return a=Ja(t,a),Wa(t,i),s=Vx(e,t,s,r,a,i),r=Gx(),e!==null&&!Pn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Pr(e,t,i)):(Ct&&r&&Mx(t),t.flags|=1,bn(e,t,s,i),t.child)}function Iy(e,t,s,r,i){if(Dn(s)){var a=!0;dd(t)}else a=!1;if(Wa(t,i),t.stateNode===null)Lu(e,t),mS(t,s,r),vp(t,s,r,i),r=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var c=l.context,u=s.contextType;typeof u=="object"&&u!==null?u=gs(u):(u=Dn(s)?Yi:vn.current,u=Ja(t,u));var h=s.getDerivedStateFromProps,f=typeof h=="function"||typeof l.getSnapshotBeforeUpdate=="function";f||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==r||c!==u)&&Cy(t,l,r,u),Gr=!1;var m=t.memoizedState;l.state=m,gd(t,r,l,i),c=t.memoizedState,o!==r||m!==c||Mn.current||Gr?(typeof h=="function"&&(xp(t,s,h,r),c=t.memoizedState),(o=Gr||Sy(t,s,o,r,m,c,u))?(f||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),l.props=r,l.state=c,l.context=u,r=o):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,GN(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:Ss(t.type,o),l.props=u,f=t.pendingProps,m=l.context,c=s.contextType,typeof c=="object"&&c!==null?c=gs(c):(c=Dn(s)?Yi:vn.current,c=Ja(t,c));var p=s.getDerivedStateFromProps;(h=typeof p=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==f||m!==c)&&Cy(t,l,r,c),Gr=!1,m=t.memoizedState,l.state=m,gd(t,r,l,i);var g=t.memoizedState;o!==f||m!==g||Mn.current||Gr?(typeof p=="function"&&(xp(t,s,p,r),g=t.memoizedState),(u=Gr||Sy(t,s,u,r,m,g,c)||!1)?(h||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,g,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,g,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),l.props=r,l.state=g,l.context=c,r=u):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return yp(e,t,s,r,a,i)}function yp(e,t,s,r,i,a){jS(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return i&&xy(t,s,!1),Pr(e,t,a);r=t.stateNode,OP.current=t;var o=l&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=el(t,e.child,null,a),t.child=el(t,null,o,a)):bn(e,t,o,a),t.memoizedState=r.state,i&&xy(t,s,!0),t.child}function wS(e){var t=e.stateNode;t.pendingContext?gy(e,t.pendingContext,t.pendingContext!==t.context):t.context&&gy(e,t.context,!1),Bx(e,t.containerInfo)}function Py(e,t,s,r,i){return Za(),Ox(i),t.flags|=256,bn(e,t,s,r),t.child}var bp={dehydrated:null,treeContext:null,retryLane:0};function kp(e){return{baseLanes:e,cachePool:null,transitions:null}}function yS(e,t,s){var r=t.pendingProps,i=$t.current,a=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(i&2)!==0),o?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),wt($t,i&1),e===null)return pp(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=r.children,e=r.fallback,a?(r=t.mode,a=t.child,l={mode:"hidden",children:l},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=l):a=uh(l,r,0,null),e=Ki(e,r,s,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=kp(s),t.memoizedState=bp,e):Qx(t,l));if(i=e.memoizedState,i!==null&&(o=i.dehydrated,o!==null))return LP(e,t,l,r,o,i,s);if(a){a=r.fallback,l=t.mode,i=e.child,o=i.sibling;var c={mode:"hidden",children:r.children};return!(l&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=li(i,c),r.subtreeFlags=i.subtreeFlags&14680064),o!==null?a=li(o,a):(a=Ki(a,l,s,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,l=e.child.memoizedState,l=l===null?kp(s):{baseLanes:l.baseLanes|s,cachePool:null,transitions:l.transitions},a.memoizedState=l,a.childLanes=e.childLanes&~s,t.memoizedState=bp,r}return a=e.child,e=a.sibling,r=li(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function Qx(e,t){return t=uh({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Zc(e,t,s,r){return r!==null&&Ox(r),el(t,e.child,null,s),e=Qx(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function LP(e,t,s,r,i,a,l){if(s)return t.flags&256?(t.flags&=-257,r=Of(Error(he(422))),Zc(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,i=t.mode,r=uh({mode:"visible",children:r.children},i,0,null),a=Ki(a,i,l,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&el(t,e.child,null,l),t.child.memoizedState=kp(l),t.memoizedState=bp,a);if(!(t.mode&1))return Zc(e,t,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var o=r.dgst;return r=o,a=Error(he(419)),r=Of(a,r,void 0),Zc(e,t,l,r)}if(o=(l&e.childLanes)!==0,Pn||o){if(r=nn,r!==null){switch(l&-l){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|l)?0:i,i!==0&&i!==a.retryLane&&(a.retryLane=i,Ir(e,i),Rs(r,e,i,-1))}return nv(),r=Of(Error(he(421))),Zc(e,t,l,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=QP.bind(null,e),i._reactRetry=t,null):(e=a.treeContext,Vn=si(i.nextSibling),Yn=t,Ct=!0,Es=null,e!==null&&(os[cs++]=br,os[cs++]=kr,os[cs++]=qi,br=e.id,kr=e.overflow,qi=t),t=Qx(t,r.children),t.flags|=4096,t)}function My(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),gp(e.return,t,s)}function Lf(e,t,s,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=s,a.tailMode=i)}function bS(e,t,s){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(bn(e,t,r.children,s),r=$t.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&My(e,s,t);else if(e.tag===19)My(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(wt($t,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(s=t.child,i=null;s!==null;)e=s.alternate,e!==null&&xd(e)===null&&(i=s),s=s.sibling;s=i,s===null?(i=t.child,t.child=null):(i=s.sibling,s.sibling=null),Lf(t,!1,i,s,a);break;case"backwards":for(s=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&xd(e)===null){t.child=i;break}e=i.sibling,i.sibling=s,s=i,i=e}Lf(t,!0,s,null,a);break;case"together":Lf(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Lu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Pr(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),Xi|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(he(153));if(t.child!==null){for(e=t.child,s=li(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=li(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function _P(e,t,s){switch(t.tag){case 3:wS(t),Za();break;case 5:YN(t);break;case 1:Dn(t.type)&&dd(t);break;case 4:Bx(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;wt(md,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(wt($t,$t.current&1),t.flags|=128,null):s&t.child.childLanes?yS(e,t,s):(wt($t,$t.current&1),e=Pr(e,t,s),e!==null?e.sibling:null);wt($t,$t.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return bS(e,t,s);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),wt($t,$t.current),r)break;return null;case 22:case 23:return t.lanes=0,vS(e,t,s)}return Pr(e,t,s)}var kS,Np,NS,SS;kS=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};Np=function(){};NS=function(e,t,s,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ui(sr.current);var a=null;switch(s){case"input":i=Vm(e,i),r=Vm(e,r),a=[];break;case"select":i=Mt({},i,{value:void 0}),r=Mt({},r,{value:void 0}),a=[];break;case"textarea":i=qm(e,i),r=qm(e,r),a=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=cd)}Xm(s,r);var l;s=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var o=i[u];for(l in o)o.hasOwnProperty(l)&&(s||(s={}),s[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(So.hasOwnProperty(u)?a||(a=[]):(a=a||[]).push(u,null));for(u in r){var c=r[u];if(o=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==o&&(c!=null||o!=null))if(u==="style")if(o){for(l in o)!o.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(s||(s={}),s[l]="");for(l in c)c.hasOwnProperty(l)&&o[l]!==c[l]&&(s||(s={}),s[l]=c[l])}else s||(a||(a=[]),a.push(u,s)),s=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(a=a||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(So.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&kt("scroll",e),a||o===c||(a=[])):(a=a||[]).push(u,c))}s&&(a=a||[]).push("style",s);var u=a;(t.updateQueue=u)&&(t.flags|=4)}};SS=function(e,t,s,r){s!==r&&(t.flags|=4)};function Gl(e,t){if(!Ct)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function mn(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var i=e.child;i!==null;)s|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)s|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function FP(e,t,s){var r=t.pendingProps;switch(Dx(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mn(t),null;case 1:return Dn(t.type)&&ud(),mn(t),null;case 3:return r=t.stateNode,tl(),Nt(Mn),Nt(vn),Hx(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Xc(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Es!==null&&(Ip(Es),Es=null))),Np(e,t),mn(t),null;case 5:Wx(t);var i=Ui(Lo.current);if(s=t.type,e!==null&&t.stateNode!=null)NS(e,t,s,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(he(166));return mn(t),null}if(e=Ui(sr.current),Xc(t)){r=t.stateNode,s=t.type;var a=t.memoizedProps;switch(r[Js]=t,r[Do]=a,e=(t.mode&1)!==0,s){case"dialog":kt("cancel",r),kt("close",r);break;case"iframe":case"object":case"embed":kt("load",r);break;case"video":case"audio":for(i=0;i<ao.length;i++)kt(ao[i],r);break;case"source":kt("error",r);break;case"img":case"image":case"link":kt("error",r),kt("load",r);break;case"details":kt("toggle",r);break;case"input":Ww(r,a),kt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},kt("invalid",r);break;case"textarea":Kw(r,a),kt("invalid",r)}Xm(s,a),i=null;for(var l in a)if(a.hasOwnProperty(l)){var o=a[l];l==="children"?typeof o=="string"?r.textContent!==o&&(a.suppressHydrationWarning!==!0&&Qc(r.textContent,o,e),i=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(a.suppressHydrationWarning!==!0&&Qc(r.textContent,o,e),i=["children",""+o]):So.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&kt("scroll",r)}switch(s){case"input":Bc(r),Hw(r,a,!0);break;case"textarea":Bc(r),Vw(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=cd)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{l=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Z0(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(s,{is:r.is}):(e=l.createElement(s),s==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,s),e[Js]=t,e[Do]=r,kS(e,t,!1,!1),t.stateNode=e;e:{switch(l=Jm(s,r),s){case"dialog":kt("cancel",e),kt("close",e),i=r;break;case"iframe":case"object":case"embed":kt("load",e),i=r;break;case"video":case"audio":for(i=0;i<ao.length;i++)kt(ao[i],e);i=r;break;case"source":kt("error",e),i=r;break;case"img":case"image":case"link":kt("error",e),kt("load",e),i=r;break;case"details":kt("toggle",e),i=r;break;case"input":Ww(e,r),i=Vm(e,r),kt("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Mt({},r,{value:void 0}),kt("invalid",e);break;case"textarea":Kw(e,r),i=qm(e,r),kt("invalid",e);break;default:i=r}Xm(s,i),o=i;for(a in o)if(o.hasOwnProperty(a)){var c=o[a];a==="style"?nN(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&eN(e,c)):a==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&Co(e,c):typeof c=="number"&&Co(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(So.hasOwnProperty(a)?c!=null&&a==="onScroll"&&kt("scroll",e):c!=null&&wx(e,a,c,l))}switch(s){case"input":Bc(e),Hw(e,r,!1);break;case"textarea":Bc(e),Vw(e);break;case"option":r.value!=null&&e.setAttribute("value",""+di(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?Fa(e,!!r.multiple,a,!1):r.defaultValue!=null&&Fa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=cd)}switch(s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return mn(t),null;case 6:if(e&&t.stateNode!=null)SS(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(he(166));if(s=Ui(Lo.current),Ui(sr.current),Xc(t)){if(r=t.stateNode,s=t.memoizedProps,r[Js]=t,(a=r.nodeValue!==s)&&(e=Yn,e!==null))switch(e.tag){case 3:Qc(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Qc(r.nodeValue,s,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[Js]=t,t.stateNode=r}return mn(t),null;case 13:if(Nt($t),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ct&&Vn!==null&&t.mode&1&&!(t.flags&128))WN(),Za(),t.flags|=98560,a=!1;else if(a=Xc(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(he(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(he(317));a[Js]=t}else Za(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;mn(t),a=!1}else Es!==null&&(Ip(Es),Es=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||$t.current&1?Yt===0&&(Yt=3):nv())),t.updateQueue!==null&&(t.flags|=4),mn(t),null);case 4:return tl(),Np(e,t),e===null&&Po(t.stateNode.containerInfo),mn(t),null;case 10:return Fx(t.type._context),mn(t),null;case 17:return Dn(t.type)&&ud(),mn(t),null;case 19:if(Nt($t),a=t.memoizedState,a===null)return mn(t),null;if(r=(t.flags&128)!==0,l=a.rendering,l===null)if(r)Gl(a,!1);else{if(Yt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=xd(e),l!==null){for(t.flags|=128,Gl(a,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)a=s,e=r,a.flags&=14680066,l=a.alternate,l===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=l.childLanes,a.lanes=l.lanes,a.child=l.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=l.memoizedProps,a.memoizedState=l.memoizedState,a.updateQueue=l.updateQueue,a.type=l.type,e=l.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return wt($t,$t.current&1|2),t.child}e=e.sibling}a.tail!==null&&Lt()>sl&&(t.flags|=128,r=!0,Gl(a,!1),t.lanes=4194304)}else{if(!r)if(e=xd(l),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),Gl(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!Ct)return mn(t),null}else 2*Lt()-a.renderingStartTime>sl&&s!==1073741824&&(t.flags|=128,r=!0,Gl(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(s=a.last,s!==null?s.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=Lt(),t.sibling=null,s=$t.current,wt($t,r?s&1|2:s&1),t):(mn(t),null);case 22:case 23:return tv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Hn&1073741824&&(mn(t),t.subtreeFlags&6&&(t.flags|=8192)):mn(t),null;case 24:return null;case 25:return null}throw Error(he(156,t.tag))}function zP(e,t){switch(Dx(t),t.tag){case 1:return Dn(t.type)&&ud(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return tl(),Nt(Mn),Nt(vn),Hx(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Wx(t),null;case 13:if(Nt($t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(he(340));Za()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Nt($t),null;case 4:return tl(),null;case 10:return Fx(t.type._context),null;case 22:case 23:return tv(),null;case 24:return null;default:return null}}var eu=!1,pn=!1,UP=typeof WeakSet=="function"?WeakSet:Set,Ae=null;function Ma(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){Dt(e,t,r)}else s.current=null}function Sp(e,t,s){try{s()}catch(r){Dt(e,t,r)}}var Dy=!1;function BP(e,t){if(op=ad,e=RN(),Px(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{s.nodeType,a.nodeType}catch{s=null;break e}var l=0,o=-1,c=-1,u=0,h=0,f=e,m=null;t:for(;;){for(var p;f!==s||i!==0&&f.nodeType!==3||(o=l+i),f!==a||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(p=f.firstChild)!==null;)m=f,f=p;for(;;){if(f===e)break t;if(m===s&&++u===i&&(o=l),m===a&&++h===r&&(c=l),(p=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=p}s=o===-1||c===-1?null:{start:o,end:c}}else s=null}s=s||{start:0,end:0}}else s=null;for(cp={focusedElem:e,selectionRange:s},ad=!1,Ae=t;Ae!==null;)if(t=Ae,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ae=e;else for(;Ae!==null;){t=Ae;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var x=g.memoizedProps,b=g.memoizedState,j=t.stateNode,v=j.getSnapshotBeforeUpdate(t.elementType===t.type?x:Ss(t.type,x),b);j.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(he(163))}}catch(y){Dt(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,Ae=e;break}Ae=t.return}return g=Dy,Dy=!1,g}function xo(e,t,s){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&Sp(t,s,a)}i=i.next}while(i!==r)}}function oh(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Cp(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function CS(e){var t=e.alternate;t!==null&&(e.alternate=null,CS(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Js],delete t[Do],delete t[hp],delete t[NP],delete t[SP])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ES(e){return e.tag===5||e.tag===3||e.tag===4}function Oy(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ES(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ep(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=cd));else if(r!==4&&(e=e.child,e!==null))for(Ep(e,t,s),e=e.sibling;e!==null;)Ep(e,t,s),e=e.sibling}function Ap(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ap(e,t,s),e=e.sibling;e!==null;)Ap(e,t,s),e=e.sibling}var ln=null,Cs=!1;function Hr(e,t,s){for(s=s.child;s!==null;)AS(e,t,s),s=s.sibling}function AS(e,t,s){if(nr&&typeof nr.onCommitFiberUnmount=="function")try{nr.onCommitFiberUnmount(eh,s)}catch{}switch(s.tag){case 5:pn||Ma(s,t);case 6:var r=ln,i=Cs;ln=null,Hr(e,t,s),ln=r,Cs=i,ln!==null&&(Cs?(e=ln,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ln.removeChild(s.stateNode));break;case 18:ln!==null&&(Cs?(e=ln,s=s.stateNode,e.nodeType===8?Rf(e.parentNode,s):e.nodeType===1&&Rf(e,s),Ro(e)):Rf(ln,s.stateNode));break;case 4:r=ln,i=Cs,ln=s.stateNode.containerInfo,Cs=!0,Hr(e,t,s),ln=r,Cs=i;break;case 0:case 11:case 14:case 15:if(!pn&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&Sp(s,t,l),i=i.next}while(i!==r)}Hr(e,t,s);break;case 1:if(!pn&&(Ma(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(o){Dt(s,t,o)}Hr(e,t,s);break;case 21:Hr(e,t,s);break;case 22:s.mode&1?(pn=(r=pn)||s.memoizedState!==null,Hr(e,t,s),pn=r):Hr(e,t,s);break;default:Hr(e,t,s)}}function Ly(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new UP),t.forEach(function(r){var i=XP.bind(null,e,r);s.has(r)||(s.add(r),r.then(i,i))})}}function Ns(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var i=s[r];try{var a=e,l=t,o=l;e:for(;o!==null;){switch(o.tag){case 5:ln=o.stateNode,Cs=!1;break e;case 3:ln=o.stateNode.containerInfo,Cs=!0;break e;case 4:ln=o.stateNode.containerInfo,Cs=!0;break e}o=o.return}if(ln===null)throw Error(he(160));AS(a,l,i),ln=null,Cs=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Dt(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)TS(t,e),t=t.sibling}function TS(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Ns(t,e),Vs(e),r&4){try{xo(3,e,e.return),oh(3,e)}catch(x){Dt(e,e.return,x)}try{xo(5,e,e.return)}catch(x){Dt(e,e.return,x)}}break;case 1:Ns(t,e),Vs(e),r&512&&s!==null&&Ma(s,s.return);break;case 5:if(Ns(t,e),Vs(e),r&512&&s!==null&&Ma(s,s.return),e.flags&32){var i=e.stateNode;try{Co(i,"")}catch(x){Dt(e,e.return,x)}}if(r&4&&(i=e.stateNode,i!=null)){var a=e.memoizedProps,l=s!==null?s.memoizedProps:a,o=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{o==="input"&&a.type==="radio"&&a.name!=null&&X0(i,a),Jm(o,l);var u=Jm(o,a);for(l=0;l<c.length;l+=2){var h=c[l],f=c[l+1];h==="style"?nN(i,f):h==="dangerouslySetInnerHTML"?eN(i,f):h==="children"?Co(i,f):wx(i,h,f,u)}switch(o){case"input":Gm(i,a);break;case"textarea":J0(i,a);break;case"select":var m=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!a.multiple;var p=a.value;p!=null?Fa(i,!!a.multiple,p,!1):m!==!!a.multiple&&(a.defaultValue!=null?Fa(i,!!a.multiple,a.defaultValue,!0):Fa(i,!!a.multiple,a.multiple?[]:"",!1))}i[Do]=a}catch(x){Dt(e,e.return,x)}}break;case 6:if(Ns(t,e),Vs(e),r&4){if(e.stateNode===null)throw Error(he(162));i=e.stateNode,a=e.memoizedProps;try{i.nodeValue=a}catch(x){Dt(e,e.return,x)}}break;case 3:if(Ns(t,e),Vs(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{Ro(t.containerInfo)}catch(x){Dt(e,e.return,x)}break;case 4:Ns(t,e),Vs(e);break;case 13:Ns(t,e),Vs(e),i=e.child,i.flags&8192&&(a=i.memoizedState!==null,i.stateNode.isHidden=a,!a||i.alternate!==null&&i.alternate.memoizedState!==null||(Zx=Lt())),r&4&&Ly(e);break;case 22:if(h=s!==null&&s.memoizedState!==null,e.mode&1?(pn=(u=pn)||h,Ns(t,e),pn=u):Ns(t,e),Vs(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!h&&e.mode&1)for(Ae=e,h=e.child;h!==null;){for(f=Ae=h;Ae!==null;){switch(m=Ae,p=m.child,m.tag){case 0:case 11:case 14:case 15:xo(4,m,m.return);break;case 1:Ma(m,m.return);var g=m.stateNode;if(typeof g.componentWillUnmount=="function"){r=m,s=m.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(x){Dt(r,s,x)}}break;case 5:Ma(m,m.return);break;case 22:if(m.memoizedState!==null){Fy(f);continue}}p!==null?(p.return=m,Ae=p):Fy(f)}h=h.sibling}e:for(h=null,f=e;;){if(f.tag===5){if(h===null){h=f;try{i=f.stateNode,u?(a=i.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(o=f.stateNode,c=f.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=tN("display",l))}catch(x){Dt(e,e.return,x)}}}else if(f.tag===6){if(h===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(x){Dt(e,e.return,x)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;h===f&&(h=null),f=f.return}h===f&&(h=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Ns(t,e),Vs(e),r&4&&Ly(e);break;case 21:break;default:Ns(t,e),Vs(e)}}function Vs(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(ES(s)){var r=s;break e}s=s.return}throw Error(he(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Co(i,""),r.flags&=-33);var a=Oy(e);Ap(e,a,i);break;case 3:case 4:var l=r.stateNode.containerInfo,o=Oy(e);Ep(e,o,l);break;default:throw Error(he(161))}}catch(c){Dt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function WP(e,t,s){Ae=e,RS(e)}function RS(e,t,s){for(var r=(e.mode&1)!==0;Ae!==null;){var i=Ae,a=i.child;if(i.tag===22&&r){var l=i.memoizedState!==null||eu;if(!l){var o=i.alternate,c=o!==null&&o.memoizedState!==null||pn;o=eu;var u=pn;if(eu=l,(pn=c)&&!u)for(Ae=i;Ae!==null;)l=Ae,c=l.child,l.tag===22&&l.memoizedState!==null?zy(i):c!==null?(c.return=l,Ae=c):zy(i);for(;a!==null;)Ae=a,RS(a),a=a.sibling;Ae=i,eu=o,pn=u}_y(e)}else i.subtreeFlags&8772&&a!==null?(a.return=i,Ae=a):_y(e)}}function _y(e){for(;Ae!==null;){var t=Ae;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:pn||oh(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!pn)if(s===null)r.componentDidMount();else{var i=t.elementType===t.type?s.memoizedProps:Ss(t.type,s.memoizedProps);r.componentDidUpdate(i,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&by(t,a,r);break;case 3:var l=t.updateQueue;if(l!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}by(t,l,s)}break;case 5:var o=t.stateNode;if(s===null&&t.flags&4){s=o;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&s.focus();break;case"img":c.src&&(s.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var h=u.memoizedState;if(h!==null){var f=h.dehydrated;f!==null&&Ro(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(he(163))}pn||t.flags&512&&Cp(t)}catch(m){Dt(t,t.return,m)}}if(t===e){Ae=null;break}if(s=t.sibling,s!==null){s.return=t.return,Ae=s;break}Ae=t.return}}function Fy(e){for(;Ae!==null;){var t=Ae;if(t===e){Ae=null;break}var s=t.sibling;if(s!==null){s.return=t.return,Ae=s;break}Ae=t.return}}function zy(e){for(;Ae!==null;){var t=Ae;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{oh(4,t)}catch(c){Dt(t,s,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Dt(t,i,c)}}var a=t.return;try{Cp(t)}catch(c){Dt(t,a,c)}break;case 5:var l=t.return;try{Cp(t)}catch(c){Dt(t,l,c)}}}catch(c){Dt(t,t.return,c)}if(t===e){Ae=null;break}var o=t.sibling;if(o!==null){o.return=t.return,Ae=o;break}Ae=t.return}}var HP=Math.ceil,wd=zr.ReactCurrentDispatcher,Xx=zr.ReactCurrentOwner,ms=zr.ReactCurrentBatchConfig,st=0,nn=null,Ut=null,on=0,Hn=0,Da=bi(0),Yt=0,Uo=null,Xi=0,ch=0,Jx=0,vo=null,In=null,Zx=0,sl=1/0,gr=null,yd=!1,Tp=null,ii=null,tu=!1,Xr=null,bd=0,jo=0,Rp=null,_u=-1,Fu=0;function Nn(){return st&6?Lt():_u!==-1?_u:_u=Lt()}function ai(e){return e.mode&1?st&2&&on!==0?on&-on:EP.transition!==null?(Fu===0&&(Fu=mN()),Fu):(e=mt,e!==0||(e=window.event,e=e===void 0?16:yN(e.type)),e):1}function Rs(e,t,s,r){if(50<jo)throw jo=0,Rp=null,Error(he(185));fc(e,s,r),(!(st&2)||e!==nn)&&(e===nn&&(!(st&2)&&(ch|=s),Yt===4&&qr(e,on)),On(e,r),s===1&&st===0&&!(t.mode&1)&&(sl=Lt()+500,ih&&ki()))}function On(e,t){var s=e.callbackNode;EI(e,t);var r=id(e,e===nn?on:0);if(r===0)s!==null&&qw(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&qw(s),t===1)e.tag===0?CP(Uy.bind(null,e)):zN(Uy.bind(null,e)),bP(function(){!(st&6)&&ki()}),s=null;else{switch(pN(r)){case 1:s=Sx;break;case 4:s=hN;break;case 16:s=rd;break;case 536870912:s=fN;break;default:s=rd}s=_S(s,$S.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function $S(e,t){if(_u=-1,Fu=0,st&6)throw Error(he(327));var s=e.callbackNode;if(Ha()&&e.callbackNode!==s)return null;var r=id(e,e===nn?on:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=kd(e,r);else{t=r;var i=st;st|=2;var a=PS();(nn!==e||on!==t)&&(gr=null,sl=Lt()+500,Hi(e,t));do try{GP();break}catch(o){IS(e,o)}while(!0);_x(),wd.current=a,st=i,Ut!==null?t=0:(nn=null,on=0,t=Yt)}if(t!==0){if(t===2&&(i=sp(e),i!==0&&(r=i,t=$p(e,i))),t===1)throw s=Uo,Hi(e,0),qr(e,r),On(e,Lt()),s;if(t===6)qr(e,r);else{if(i=e.current.alternate,!(r&30)&&!KP(i)&&(t=kd(e,r),t===2&&(a=sp(e),a!==0&&(r=a,t=$p(e,a))),t===1))throw s=Uo,Hi(e,0),qr(e,r),On(e,Lt()),s;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(he(345));case 2:Di(e,In,gr);break;case 3:if(qr(e,r),(r&130023424)===r&&(t=Zx+500-Lt(),10<t)){if(id(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Nn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=dp(Di.bind(null,e,In,gr),t);break}Di(e,In,gr);break;case 4:if(qr(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var l=31-Ts(r);a=1<<l,l=t[l],l>i&&(i=l),r&=~a}if(r=i,r=Lt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*HP(r/1960))-r,10<r){e.timeoutHandle=dp(Di.bind(null,e,In,gr),r);break}Di(e,In,gr);break;case 5:Di(e,In,gr);break;default:throw Error(he(329))}}}return On(e,Lt()),e.callbackNode===s?$S.bind(null,e):null}function $p(e,t){var s=vo;return e.current.memoizedState.isDehydrated&&(Hi(e,t).flags|=256),e=kd(e,t),e!==2&&(t=In,In=s,t!==null&&Ip(t)),e}function Ip(e){In===null?In=e:In.push.apply(In,e)}function KP(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var i=s[r],a=i.getSnapshot;i=i.value;try{if(!Ms(a(),i))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function qr(e,t){for(t&=~Jx,t&=~ch,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-Ts(t),r=1<<s;e[s]=-1,t&=~r}}function Uy(e){if(st&6)throw Error(he(327));Ha();var t=id(e,0);if(!(t&1))return On(e,Lt()),null;var s=kd(e,t);if(e.tag!==0&&s===2){var r=sp(e);r!==0&&(t=r,s=$p(e,r))}if(s===1)throw s=Uo,Hi(e,0),qr(e,t),On(e,Lt()),s;if(s===6)throw Error(he(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Di(e,In,gr),On(e,Lt()),null}function ev(e,t){var s=st;st|=1;try{return e(t)}finally{st=s,st===0&&(sl=Lt()+500,ih&&ki())}}function Ji(e){Xr!==null&&Xr.tag===0&&!(st&6)&&Ha();var t=st;st|=1;var s=ms.transition,r=mt;try{if(ms.transition=null,mt=1,e)return e()}finally{mt=r,ms.transition=s,st=t,!(st&6)&&ki()}}function tv(){Hn=Da.current,Nt(Da)}function Hi(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,yP(s)),Ut!==null)for(s=Ut.return;s!==null;){var r=s;switch(Dx(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&ud();break;case 3:tl(),Nt(Mn),Nt(vn),Hx();break;case 5:Wx(r);break;case 4:tl();break;case 13:Nt($t);break;case 19:Nt($t);break;case 10:Fx(r.type._context);break;case 22:case 23:tv()}s=s.return}if(nn=e,Ut=e=li(e.current,null),on=Hn=t,Yt=0,Uo=null,Jx=ch=Xi=0,In=vo=null,zi!==null){for(t=0;t<zi.length;t++)if(s=zi[t],r=s.interleaved,r!==null){s.interleaved=null;var i=r.next,a=s.pending;if(a!==null){var l=a.next;a.next=i,r.next=l}s.pending=r}zi=null}return e}function IS(e,t){do{var s=Ut;try{if(_x(),Du.current=jd,vd){for(var r=It.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}vd=!1}if(Qi=0,Jt=Kt=It=null,go=!1,_o=0,Xx.current=null,s===null||s.return===null){Yt=1,Uo=t,Ut=null;break}e:{var a=e,l=s.return,o=s,c=t;if(t=on,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,h=o,f=h.tag;if(!(h.mode&1)&&(f===0||f===11||f===15)){var m=h.alternate;m?(h.updateQueue=m.updateQueue,h.memoizedState=m.memoizedState,h.lanes=m.lanes):(h.updateQueue=null,h.memoizedState=null)}var p=Ay(l);if(p!==null){p.flags&=-257,Ty(p,l,o,a,t),p.mode&1&&Ey(a,u,t),t=p,c=u;var g=t.updateQueue;if(g===null){var x=new Set;x.add(c),t.updateQueue=x}else g.add(c);break e}else{if(!(t&1)){Ey(a,u,t),nv();break e}c=Error(he(426))}}else if(Ct&&o.mode&1){var b=Ay(l);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Ty(b,l,o,a,t),Ox(nl(c,o));break e}}a=c=nl(c,o),Yt!==4&&(Yt=2),vo===null?vo=[a]:vo.push(a),a=l;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var j=pS(a,c,t);yy(a,j);break e;case 1:o=c;var v=a.type,w=a.stateNode;if(!(a.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(ii===null||!ii.has(w)))){a.flags|=65536,t&=-t,a.lanes|=t;var y=gS(a,o,t);yy(a,y);break e}}a=a.return}while(a!==null)}DS(s)}catch(N){t=N,Ut===s&&s!==null&&(Ut=s=s.return);continue}break}while(!0)}function PS(){var e=wd.current;return wd.current=jd,e===null?jd:e}function nv(){(Yt===0||Yt===3||Yt===2)&&(Yt=4),nn===null||!(Xi&268435455)&&!(ch&268435455)||qr(nn,on)}function kd(e,t){var s=st;st|=2;var r=PS();(nn!==e||on!==t)&&(gr=null,Hi(e,t));do try{VP();break}catch(i){IS(e,i)}while(!0);if(_x(),st=s,wd.current=r,Ut!==null)throw Error(he(261));return nn=null,on=0,Yt}function VP(){for(;Ut!==null;)MS(Ut)}function GP(){for(;Ut!==null&&!vI();)MS(Ut)}function MS(e){var t=LS(e.alternate,e,Hn);e.memoizedProps=e.pendingProps,t===null?DS(e):Ut=t,Xx.current=null}function DS(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=zP(s,t),s!==null){s.flags&=32767,Ut=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Yt=6,Ut=null;return}}else if(s=FP(s,t,Hn),s!==null){Ut=s;return}if(t=t.sibling,t!==null){Ut=t;return}Ut=t=e}while(t!==null);Yt===0&&(Yt=5)}function Di(e,t,s){var r=mt,i=ms.transition;try{ms.transition=null,mt=1,YP(e,t,s,r)}finally{ms.transition=i,mt=r}return null}function YP(e,t,s,r){do Ha();while(Xr!==null);if(st&6)throw Error(he(327));s=e.finishedWork;var i=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(he(177));e.callbackNode=null,e.callbackPriority=0;var a=s.lanes|s.childLanes;if(AI(e,a),e===nn&&(Ut=nn=null,on=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||tu||(tu=!0,_S(rd,function(){return Ha(),null})),a=(s.flags&15990)!==0,s.subtreeFlags&15990||a){a=ms.transition,ms.transition=null;var l=mt;mt=1;var o=st;st|=4,Xx.current=null,BP(e,s),TS(s,e),mP(cp),ad=!!op,cp=op=null,e.current=s,WP(s),jI(),st=o,mt=l,ms.transition=a}else e.current=s;if(tu&&(tu=!1,Xr=e,bd=i),a=e.pendingLanes,a===0&&(ii=null),bI(s.stateNode),On(e,Lt()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)i=t[s],r(i.value,{componentStack:i.stack,digest:i.digest});if(yd)throw yd=!1,e=Tp,Tp=null,e;return bd&1&&e.tag!==0&&Ha(),a=e.pendingLanes,a&1?e===Rp?jo++:(jo=0,Rp=e):jo=0,ki(),null}function Ha(){if(Xr!==null){var e=pN(bd),t=ms.transition,s=mt;try{if(ms.transition=null,mt=16>e?16:e,Xr===null)var r=!1;else{if(e=Xr,Xr=null,bd=0,st&6)throw Error(he(331));var i=st;for(st|=4,Ae=e.current;Ae!==null;){var a=Ae,l=a.child;if(Ae.flags&16){var o=a.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(Ae=u;Ae!==null;){var h=Ae;switch(h.tag){case 0:case 11:case 15:xo(8,h,a)}var f=h.child;if(f!==null)f.return=h,Ae=f;else for(;Ae!==null;){h=Ae;var m=h.sibling,p=h.return;if(CS(h),h===u){Ae=null;break}if(m!==null){m.return=p,Ae=m;break}Ae=p}}}var g=a.alternate;if(g!==null){var x=g.child;if(x!==null){g.child=null;do{var b=x.sibling;x.sibling=null,x=b}while(x!==null)}}Ae=a}}if(a.subtreeFlags&2064&&l!==null)l.return=a,Ae=l;else e:for(;Ae!==null;){if(a=Ae,a.flags&2048)switch(a.tag){case 0:case 11:case 15:xo(9,a,a.return)}var j=a.sibling;if(j!==null){j.return=a.return,Ae=j;break e}Ae=a.return}}var v=e.current;for(Ae=v;Ae!==null;){l=Ae;var w=l.child;if(l.subtreeFlags&2064&&w!==null)w.return=l,Ae=w;else e:for(l=v;Ae!==null;){if(o=Ae,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:oh(9,o)}}catch(N){Dt(o,o.return,N)}if(o===l){Ae=null;break e}var y=o.sibling;if(y!==null){y.return=o.return,Ae=y;break e}Ae=o.return}}if(st=i,ki(),nr&&typeof nr.onPostCommitFiberRoot=="function")try{nr.onPostCommitFiberRoot(eh,e)}catch{}r=!0}return r}finally{mt=s,ms.transition=t}}return!1}function By(e,t,s){t=nl(s,t),t=pS(e,t,1),e=ri(e,t,1),t=Nn(),e!==null&&(fc(e,1,t),On(e,t))}function Dt(e,t,s){if(e.tag===3)By(e,e,s);else for(;t!==null;){if(t.tag===3){By(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ii===null||!ii.has(r))){e=nl(s,e),e=gS(t,e,1),t=ri(t,e,1),e=Nn(),t!==null&&(fc(t,1,e),On(t,e));break}}t=t.return}}function qP(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=Nn(),e.pingedLanes|=e.suspendedLanes&s,nn===e&&(on&s)===s&&(Yt===4||Yt===3&&(on&130023424)===on&&500>Lt()-Zx?Hi(e,0):Jx|=s),On(e,t)}function OS(e,t){t===0&&(e.mode&1?(t=Kc,Kc<<=1,!(Kc&130023424)&&(Kc=4194304)):t=1);var s=Nn();e=Ir(e,t),e!==null&&(fc(e,t,s),On(e,s))}function QP(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),OS(e,s)}function XP(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(s=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(he(314))}r!==null&&r.delete(t),OS(e,s)}var LS;LS=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||Mn.current)Pn=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return Pn=!1,_P(e,t,s);Pn=!!(e.flags&131072)}else Pn=!1,Ct&&t.flags&1048576&&UN(t,fd,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Lu(e,t),e=t.pendingProps;var i=Ja(t,vn.current);Wa(t,s),i=Vx(null,t,r,e,i,s);var a=Gx();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Dn(r)?(a=!0,dd(t)):a=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Ux(t),i.updater=lh,t.stateNode=i,i._reactInternals=t,vp(t,r,e,s),t=yp(null,t,r,!0,a,s)):(t.tag=0,Ct&&a&&Mx(t),bn(null,t,i,s),t=t.child),t;case 16:r=t.elementType;e:{switch(Lu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=ZP(r),e=Ss(r,e),i){case 0:t=wp(null,t,r,e,s);break e;case 1:t=Iy(null,t,r,e,s);break e;case 11:t=Ry(null,t,r,e,s);break e;case 14:t=$y(null,t,r,Ss(r.type,e),s);break e}throw Error(he(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ss(r,i),wp(e,t,r,i,s);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ss(r,i),Iy(e,t,r,i,s);case 3:e:{if(wS(t),e===null)throw Error(he(387));r=t.pendingProps,a=t.memoizedState,i=a.element,GN(e,t),gd(t,r,null,s);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){i=nl(Error(he(423)),t),t=Py(e,t,r,s,i);break e}else if(r!==i){i=nl(Error(he(424)),t),t=Py(e,t,r,s,i);break e}else for(Vn=si(t.stateNode.containerInfo.firstChild),Yn=t,Ct=!0,Es=null,s=KN(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Za(),r===i){t=Pr(e,t,s);break e}bn(e,t,r,s)}t=t.child}return t;case 5:return YN(t),e===null&&pp(t),r=t.type,i=t.pendingProps,a=e!==null?e.memoizedProps:null,l=i.children,up(r,i)?l=null:a!==null&&up(r,a)&&(t.flags|=32),jS(e,t),bn(e,t,l,s),t.child;case 6:return e===null&&pp(t),null;case 13:return yS(e,t,s);case 4:return Bx(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=el(t,null,r,s):bn(e,t,r,s),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ss(r,i),Ry(e,t,r,i,s);case 7:return bn(e,t,t.pendingProps,s),t.child;case 8:return bn(e,t,t.pendingProps.children,s),t.child;case 12:return bn(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,a=t.memoizedProps,l=i.value,wt(md,r._currentValue),r._currentValue=l,a!==null)if(Ms(a.value,l)){if(a.children===i.children&&!Mn.current){t=Pr(e,t,s);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=Sr(-1,s&-s),c.tag=2;var u=a.updateQueue;if(u!==null){u=u.shared;var h=u.pending;h===null?c.next=c:(c.next=h.next,h.next=c),u.pending=c}}a.lanes|=s,c=a.alternate,c!==null&&(c.lanes|=s),gp(a.return,s,t),o.lanes|=s;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(he(341));l.lanes|=s,o=l.alternate,o!==null&&(o.lanes|=s),gp(l,s,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}bn(e,t,i.children,s),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Wa(t,s),i=gs(i),r=r(i),t.flags|=1,bn(e,t,r,s),t.child;case 14:return r=t.type,i=Ss(r,t.pendingProps),i=Ss(r.type,i),$y(e,t,r,i,s);case 15:return xS(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Ss(r,i),Lu(e,t),t.tag=1,Dn(r)?(e=!0,dd(t)):e=!1,Wa(t,s),mS(t,r,i),vp(t,r,i,s),yp(null,t,r,!0,e,s);case 19:return bS(e,t,s);case 22:return vS(e,t,s)}throw Error(he(156,t.tag))};function _S(e,t){return dN(e,t)}function JP(e,t,s,r){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fs(e,t,s,r){return new JP(e,t,s,r)}function sv(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ZP(e){if(typeof e=="function")return sv(e)?1:0;if(e!=null){if(e=e.$$typeof,e===bx)return 11;if(e===kx)return 14}return 2}function li(e,t){var s=e.alternate;return s===null?(s=fs(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function zu(e,t,s,r,i,a){var l=2;if(r=e,typeof e=="function")sv(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Sa:return Ki(s.children,i,a,t);case yx:l=8,i|=8;break;case Bm:return e=fs(12,s,t,i|2),e.elementType=Bm,e.lanes=a,e;case Wm:return e=fs(13,s,t,i),e.elementType=Wm,e.lanes=a,e;case Hm:return e=fs(19,s,t,i),e.elementType=Hm,e.lanes=a,e;case Y0:return uh(s,i,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case V0:l=10;break e;case G0:l=9;break e;case bx:l=11;break e;case kx:l=14;break e;case Vr:l=16,r=null;break e}throw Error(he(130,e==null?e:typeof e,""))}return t=fs(l,s,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function Ki(e,t,s,r){return e=fs(7,e,r,t),e.lanes=s,e}function uh(e,t,s,r){return e=fs(22,e,r,t),e.elementType=Y0,e.lanes=s,e.stateNode={isHidden:!1},e}function _f(e,t,s){return e=fs(6,e,null,t),e.lanes=s,e}function Ff(e,t,s){return t=fs(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function e2(e,t,s,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=jf(0),this.expirationTimes=jf(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=jf(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function rv(e,t,s,r,i,a,l,o,c){return e=new e2(e,t,s,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=fs(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ux(a),e}function t2(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Na,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function FS(e){if(!e)return hi;e=e._reactInternals;e:{if(ra(e)!==e||e.tag!==1)throw Error(he(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Dn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(he(171))}if(e.tag===1){var s=e.type;if(Dn(s))return FN(e,s,t)}return t}function zS(e,t,s,r,i,a,l,o,c){return e=rv(s,r,!0,e,i,a,l,o,c),e.context=FS(null),s=e.current,r=Nn(),i=ai(s),a=Sr(r,i),a.callback=t??null,ri(s,a,i),e.current.lanes=i,fc(e,i,r),On(e,r),e}function dh(e,t,s,r){var i=t.current,a=Nn(),l=ai(i);return s=FS(s),t.context===null?t.context=s:t.pendingContext=s,t=Sr(a,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ri(i,t,l),e!==null&&(Rs(e,i,l,a),Mu(e,i,l)),l}function Nd(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Wy(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function iv(e,t){Wy(e,t),(e=e.alternate)&&Wy(e,t)}function n2(){return null}var US=typeof reportError=="function"?reportError:function(e){console.error(e)};function av(e){this._internalRoot=e}hh.prototype.render=av.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(he(409));dh(e,t,null,null)};hh.prototype.unmount=av.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ji(function(){dh(null,e,null,null)}),t[$r]=null}};function hh(e){this._internalRoot=e}hh.prototype.unstable_scheduleHydration=function(e){if(e){var t=vN();e={blockedOn:null,target:e,priority:t};for(var s=0;s<Yr.length&&t!==0&&t<Yr[s].priority;s++);Yr.splice(s,0,e),s===0&&wN(e)}};function lv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function fh(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Hy(){}function s2(e,t,s,r,i){if(i){if(typeof r=="function"){var a=r;r=function(){var u=Nd(l);a.call(u)}}var l=zS(t,r,e,0,null,!1,!1,"",Hy);return e._reactRootContainer=l,e[$r]=l.current,Po(e.nodeType===8?e.parentNode:e),Ji(),l}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var o=r;r=function(){var u=Nd(c);o.call(u)}}var c=rv(e,0,!1,null,null,!1,!1,"",Hy);return e._reactRootContainer=c,e[$r]=c.current,Po(e.nodeType===8?e.parentNode:e),Ji(function(){dh(t,c,s,r)}),c}function mh(e,t,s,r,i){var a=s._reactRootContainer;if(a){var l=a;if(typeof i=="function"){var o=i;i=function(){var c=Nd(l);o.call(c)}}dh(t,l,e,i)}else l=s2(s,t,e,i,r);return Nd(l)}gN=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=io(t.pendingLanes);s!==0&&(Cx(t,s|1),On(t,Lt()),!(st&6)&&(sl=Lt()+500,ki()))}break;case 13:Ji(function(){var r=Ir(e,1);if(r!==null){var i=Nn();Rs(r,e,1,i)}}),iv(e,1)}};Ex=function(e){if(e.tag===13){var t=Ir(e,134217728);if(t!==null){var s=Nn();Rs(t,e,134217728,s)}iv(e,134217728)}};xN=function(e){if(e.tag===13){var t=ai(e),s=Ir(e,t);if(s!==null){var r=Nn();Rs(s,e,t,r)}iv(e,t)}};vN=function(){return mt};jN=function(e,t){var s=mt;try{return mt=e,t()}finally{mt=s}};ep=function(e,t,s){switch(t){case"input":if(Gm(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var i=rh(r);if(!i)throw Error(he(90));Q0(r),Gm(r,i)}}}break;case"textarea":J0(e,s);break;case"select":t=s.value,t!=null&&Fa(e,!!s.multiple,t,!1)}};iN=ev;aN=Ji;var r2={usingClientEntryPoint:!1,Events:[pc,Ta,rh,sN,rN,ev]},Yl={findFiberByHostInstance:Fi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},i2={bundleType:Yl.bundleType,version:Yl.version,rendererPackageName:Yl.rendererPackageName,rendererConfig:Yl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:zr.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=cN(e),e===null?null:e.stateNode},findFiberByHostInstance:Yl.findFiberByHostInstance||n2,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var nu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nu.isDisabled&&nu.supportsFiber)try{eh=nu.inject(i2),nr=nu}catch{}}Zn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=r2;Zn.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!lv(t))throw Error(he(200));return t2(e,t,null,s)};Zn.createRoot=function(e,t){if(!lv(e))throw Error(he(299));var s=!1,r="",i=US;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=rv(e,1,!1,null,null,s,!1,r,i),e[$r]=t.current,Po(e.nodeType===8?e.parentNode:e),new av(t)};Zn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(he(188)):(e=Object.keys(e).join(","),Error(he(268,e)));return e=cN(t),e=e===null?null:e.stateNode,e};Zn.flushSync=function(e){return Ji(e)};Zn.hydrate=function(e,t,s){if(!fh(t))throw Error(he(200));return mh(null,e,t,!0,s)};Zn.hydrateRoot=function(e,t,s){if(!lv(e))throw Error(he(405));var r=s!=null&&s.hydratedSources||null,i=!1,a="",l=US;if(s!=null&&(s.unstable_strictMode===!0&&(i=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(l=s.onRecoverableError)),t=zS(t,null,e,1,s??null,i,!1,a,l),e[$r]=t.current,Po(e),r)for(e=0;e<r.length;e++)s=r[e],i=s._getVersion,i=i(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,i]:t.mutableSourceEagerHydrationData.push(s,i);return new hh(t)};Zn.render=function(e,t,s){if(!fh(t))throw Error(he(200));return mh(null,e,t,!1,s)};Zn.unmountComponentAtNode=function(e){if(!fh(e))throw Error(he(40));return e._reactRootContainer?(Ji(function(){mh(null,null,e,!1,function(){e._reactRootContainer=null,e[$r]=null})}),!0):!1};Zn.unstable_batchedUpdates=ev;Zn.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!fh(s))throw Error(he(200));if(e==null||e._reactInternals===void 0)throw Error(he(38));return mh(e,t,s,!1,r)};Zn.version="18.3.1-next-f1338f8080-20240426";function BS(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(BS)}catch(e){console.error(e)}}BS(),B0.exports=Zn;var vl=B0.exports,WS,Ky=vl;WS=Ky.createRoot,Ky.hydrateRoot;var a2=Object.defineProperty,jl=(e,t)=>a2(e,"name",{value:t,configurable:!0}),HS=!!(typeof window<"u"&&window.document&&window.document.createElement);function Pe(e,t,{checkForDefaultPrevented:s=!0}={}){return jl(function(i){if(e==null||e(i),s===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}jl(Pe,"composeEventHandlers");function l2(e){var t;if(!HS)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}jl(l2,"getOwnerWindow");function Pp(e){if(!HS)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}jl(Pp,"getOwnerDocument");function KS(e,t=!1){const{activeElement:s}=Pp(e);if(!(s!=null&&s.nodeName))return null;if(VS(s)&&s.contentDocument)return KS(s.contentDocument.body,t);if(t){const r=s.getAttribute("aria-activedescendant");if(r){const i=Pp(s).getElementById(r);if(i)return i}}return s}jl(KS,"getActiveElement");function VS(e){return e.tagName==="IFRAME"}jl(VS,"isFrame");var o2=Object.defineProperty,ov=(e,t)=>o2(e,"name",{value:t,configurable:!0});function Mp(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ov(Mp,"setRef");function GS(...e){return t=>{let s=!1;const r=e.map(i=>{const a=Mp(i,t);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():Mp(e[i],null)}}}}ov(GS,"composeRefs");function jt(...e){return d.useCallback(GS(...e),e)}ov(jt,"useComposedRefs");var c2=Object.defineProperty,hs=(e,t)=>c2(e,"name",{value:t,configurable:!0});function u2(e,t){const s=d.createContext(t);s.displayName=e+"Context";const r=hs(a=>{const{children:l,...o}=a,c=d.useMemo(()=>o,Object.values(o));return n.jsx(s.Provider,{value:c,children:l})},"Provider");r.displayName=e+"Provider";function i(a,l={}){const{optional:o=!1}=l,c=d.useContext(s);if(c)return c;if(t!==void 0)return t;if(!o)throw new Error(`\`${a}\` must be used within \`${e}\``)}return hs(i,"useContext"),[r,i]}hs(u2,"createContext");function _s(e,t=[]){let s=[];function r(a,l){const o=d.createContext(l);o.displayName=a+"Context";const c=s.length;s=[...s,l];const u=hs(f=>{var j;const{scope:m,children:p,...g}=f,x=((j=m==null?void 0:m[e])==null?void 0:j[c])||o,b=d.useMemo(()=>g,Object.values(g));return n.jsx(x.Provider,{value:b,children:p})},"Provider");u.displayName=a+"Provider";function h(f,m,p={}){var j;const{optional:g=!1}=p,x=((j=m==null?void 0:m[e])==null?void 0:j[c])||o,b=d.useContext(x);if(b)return b;if(l!==void 0)return l;if(!g)throw new Error(`\`${f}\` must be used within \`${a}\``)}return hs(h,"useContext"),[u,h]}hs(r,"createContext");const i=hs(()=>{const a=s.map(l=>d.createContext(l));return hs(function(o){const c=(o==null?void 0:o[e])||a;return d.useMemo(()=>({[`__scope${e}`]:{...o,[e]:c}}),[o,c])},"useScope")},"createScope");return i.scopeName=e,[r,YS(i,...t)]}hs(_s,"createContextScope");function YS(...e){const t=e[0];if(e.length===1)return t;const s=hs(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return hs(function(a){const l=r.reduce((o,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...o,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])},"useComposedScopes")},"createScope");return s.scopeName=t.scopeName,s}hs(YS,"composeContextScopes");var d2=Object.defineProperty,Fs=(e,t)=>d2(e,"name",{value:t,configurable:!0});function fi(e){const t=d.forwardRef((s,r)=>{let{children:i,...a}=s,l=null,o=!1;const c=[];Dp(i)&&typeof su=="function"&&(i=su(i._payload)),d.Children.forEach(i,m=>{var p;if(ZS(m)){o=!0;const g=m;let x="child"in g.props?g.props.child:g.props.children;Dp(x)&&typeof su=="function"&&(x=su(x._payload)),l=h2(g,x),c.push((p=l==null?void 0:l.props)==null?void 0:p.children)}else c.push(m)}),l?l=d.cloneElement(l,void 0,c):!o&&d.Children.count(i)===1&&d.isValidElement(i)&&(l=i);const u=l?JS(l):void 0,h=jt(r,u);if(!l){if(i||i===0)throw new Error(o?p2(e):m2(e));return i}const f=XS(a,l.props??{});return l.type!==d.Fragment&&(f.ref=r?h:u),d.cloneElement(l,f)});return t.displayName=`${e}.Slot`,t}Fs(fi,"createSlot");var qS=Symbol.for("radix.slottable");function QS(e){const t=Fs(s=>"child"in s?s.children(s.child):s.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=qS,t}Fs(QS,"createSlottable");var h2=Fs((e,t)=>{if("child"in e.props){const s=e.props.child;return d.isValidElement(s)?d.cloneElement(s,void 0,e.props.children(s.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function XS(e,t){const s={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?s[r]=(...o)=>{const c=a(...o);return i(...o),c}:i&&(s[r]=i):r==="style"?s[r]={...i,...a}:r==="className"&&(s[r]=[i,a].filter(Boolean).join(" "))}return{...e,...s}}Fs(XS,"mergeProps");function JS(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}Fs(JS,"getElementRef");function ZS(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qS}Fs(ZS,"isSlottable");var f2=Symbol.for("react.lazy");function Dp(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===f2&&"_payload"in e&&eC(e._payload)}Fs(Dp,"isLazyComponent");function eC(e){return typeof e=="object"&&e!==null&&"then"in e}Fs(eC,"isPromiseLike");var m2=Fs(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),p2=Fs(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),su=pl[" use ".trim().toString()],g2=Object.defineProperty,Zt=(e,t)=>g2(e,"name",{value:t,configurable:!0});function ph(e){const t=e+"CollectionProvider",[s,r]=_s(t),[i,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),l=Zt(x=>{const{scope:b,children:j}=x,v=d.useRef(null),w=d.useRef(new Map).current;return n.jsx(i,{scope:b,itemMap:w,collectionRef:v,children:j})},"CollectionProvider");l.displayName=t;const o=e+"CollectionSlot",c=fi(o),u=d.forwardRef((x,b)=>{const{scope:j,children:v}=x,w=a(o,j),y=jt(b,w.collectionRef);return n.jsx(c,{ref:y,children:v})});u.displayName=o;const h=e+"CollectionItemSlot",f="data-radix-collection-item",m=fi(h),p=d.forwardRef((x,b)=>{const{scope:j,children:v,...w}=x,y=d.useRef(null),N=jt(b,y),k=a(h,j);return d.useEffect(()=>(k.itemMap.set(y,{ref:y,...w}),()=>void k.itemMap.delete(y))),n.jsx(m,{[f]:"",ref:N,children:v})});p.displayName=h;function g(x){const b=a(e+"CollectionConsumer",x);return d.useCallback(()=>{const v=b.collectionRef.current;if(!v)return[];const w=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((k,S)=>w.indexOf(k.ref.current)-w.indexOf(S.ref.current))},[b.collectionRef,b.itemMap])}return Zt(g,"useCollection"),[{Provider:l,Slot:u,ItemSlot:p},g,r]}Zt(ph,"createCollection");var Vy=new WeakMap,zt,Kn,zf=(Kn=class extends Map{constructor(s){super(s);Ow(this,zt);ff(this,zt,[...super.keys()]),Vy.set(this,!0)}set(s,r){return Vy.get(this)&&(this.has(s)?hn(this,zt)[hn(this,zt).indexOf(s)]=s:hn(this,zt).push(s)),super.set(s,r),this}insert(s,r,i){const a=this.has(r),l=hn(this,zt).length,o=cv(s);let c=o>=0?o:l+o;const u=c<0||c>=l?-1:c;if(u===this.size||a&&u===this.size-1||u===-1)return this.set(r,i),this;const h=this.size+(a?0:1);o<0&&c++;const f=[...hn(this,zt)];let m,p=!1;for(let g=c;g<h;g++)if(c===g){let x=f[g];f[g]===r&&(x=f[g+1]),a&&this.delete(r),m=this.get(x),this.set(r,i)}else{!p&&f[g-1]===r&&(p=!0);const x=f[p?g:g-1],b=m;m=this.get(x),this.delete(x),this.set(x,b)}return this}with(s,r,i){const a=new Kn(this);return a.insert(s,r,i),a}before(s){const r=hn(this,zt).indexOf(s)-1;if(!(r<0))return this.entryAt(r)}setBefore(s,r,i){const a=hn(this,zt).indexOf(s);return a===-1?this:this.insert(a,r,i)}after(s){let r=hn(this,zt).indexOf(s);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(s,r,i){const a=hn(this,zt).indexOf(s);return a===-1?this:this.insert(a+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ff(this,zt,[]),super.clear()}delete(s){const r=super.delete(s);return r&&hn(this,zt).splice(hn(this,zt).indexOf(s),1),r}deleteAt(s){const r=this.keyAt(s);return r!==void 0?this.delete(r):!1}at(s){const r=Uu(hn(this,zt),s);if(r!==void 0)return this.get(r)}entryAt(s){const r=Uu(hn(this,zt),s);if(r!==void 0)return[r,this.get(r)]}indexOf(s){return hn(this,zt).indexOf(s)}keyAt(s){return Uu(hn(this,zt),s)}from(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(s,r){const i=this.indexOf(s);if(i===-1)return;let a=i+r;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return a;i++}}findIndex(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return i;i++}return-1}filter(s,r){const i=[];let a=0;for(const l of this)Reflect.apply(s,r,[l,a,this])&&i.push(l),a++;return new Kn(i)}map(s,r){const i=[];let a=0;for(const l of this)i.push([l[0],Reflect.apply(s,r,[l,a,this])]),a++;return new Kn(i)}reduce(...s){const[r,i]=s;let a=0,l=i??this.at(0);for(const o of this)a===0&&s.length===1?l=o:l=Reflect.apply(r,this,[l,o,a,this]),a++;return l}reduceRight(...s){const[r,i]=s;let a=i??this.at(-1);for(let l=this.size-1;l>=0;l--){const o=this.at(l);l===this.size-1&&s.length===1?a=o:a=Reflect.apply(r,this,[a,o,l,this])}return a}toSorted(s){const r=[...this.entries()].sort(s);return new Kn(r)}toReversed(){const s=new Kn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),a=this.get(i);s.set(i,a)}return s}toSpliced(...s){const r=[...this.entries()];return r.splice(...s),new Kn(r)}slice(s,r){const i=new Kn;let a=this.size-1;if(s===void 0)return i;s<0&&(s=s+this.size),r!==void 0&&r>0&&(a=r-1);for(let l=s;l<=a;l++){const o=this.keyAt(l),c=this.get(o);i.set(o,c)}return i}every(s,r){let i=0;for(const a of this){if(!Reflect.apply(s,r,[a,i,this]))return!1;i++}return!0}some(s,r){let i=0;for(const a of this){if(Reflect.apply(s,r,[a,i,this]))return!0;i++}return!1}},zt=new WeakMap,Zt(Kn,"OrderedDict"),Kn);function Uu(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const s=tC(e,t);return s===-1?void 0:e[s]}Zt(Uu,"at");function tC(e,t){const s=e.length,r=cv(t),i=r>=0?r:s+r;return i<0||i>=s?-1:i}Zt(tC,"toSafeIndex");function cv(e){return e!==e||e===0?0:Math.trunc(e)}Zt(cv,"toSafeInteger");function x2(e){const t=e+"CollectionProvider",[s,r]=_s(t),[i,a]=s(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new zf,setItemMap:Zt(()=>{},"setItemMap")}),l=Zt(({state:w,...y})=>w?n.jsx(c,{...y,state:w}):n.jsx(o,{...y}),"CollectionProvider");l.displayName=t;const o=Zt(w=>{const y=b();return n.jsx(c,{...w,state:y})},"CollectionInit");o.displayName=t+"Init";const c=Zt(w=>{const{scope:y,children:N,state:k}=w,S=d.useRef(null),[C,$]=d.useState(null),R=jt(S,$),[I,z]=k;return d.useEffect(()=>{if(!C)return;const U=rC(()=>{});return U.observe(C,{childList:!0,subtree:!0}),()=>{U.disconnect()}},[C]),n.jsx(i,{scope:y,itemMap:I,setItemMap:z,collectionRef:R,collectionRefObject:S,collectionElement:C,children:N})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",h=fi(u),f=d.forwardRef((w,y)=>{const{scope:N,children:k}=w,S=a(u,N),C=jt(y,S.collectionRef);return n.jsx(h,{ref:C,children:k})});f.displayName=u;const m=e+"CollectionItemSlot",p="data-radix-collection-item",g=fi(m),x=d.forwardRef((w,y)=>{const{scope:N,children:k,...S}=w,C=d.useRef(null),[$,R]=d.useState(null),I=jt(y,C,R),z=a(m,N),{setItemMap:U}=z,A=d.useRef(S);nC(A.current,S)||(A.current=S);const P=A.current;return d.useEffect(()=>{const D=P;return U(O=>$?O.has($)?O.set($,{...D,element:$}).toSorted(Op):(O.set($,{...D,element:$}),O.toSorted(Op)):O),()=>{U(O=>!$||!O.has($)?O:(O.delete($),new zf(O)))}},[$,P,U]),n.jsx(g,{[p]:"",ref:I,children:k})});x.displayName=m;function b(){return d.useState(new zf)}Zt(b,"useInitCollection");function j(w){const{itemMap:y}=a(e+"CollectionConsumer",w);return y}return Zt(j,"useCollection"),[{Provider:l,Slot:f,ItemSlot:x},{createCollectionScope:r,useCollection:j,useInitCollection:b}]}Zt(x2,"createCollection");function nC(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}Zt(nC,"shallowEqual");function sC(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Zt(sC,"isElementPreceding");function Op(e,t){return!e[1].element||!t[1].element?0:sC(e[1].element,t[1].element)?-1:1}Zt(Op,"sortByDocumentPosition");function rC(e){return new MutationObserver(s=>{for(const r of s)if(r.type==="childList"){e();return}})}Zt(rC,"getChildListObserver");var v2=Object.defineProperty,j2=(e,t)=>v2(e,"name",{value:t,configurable:!0}),w2=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pt=w2.reduce((e,t)=>{const s=fi(`Primitive.${t}`),r=d.forwardRef((i,a)=>{const{asChild:l,...o}=i,c=l?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...o,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function gh(e,t){e&&vl.flushSync(()=>e.dispatchEvent(t))}j2(gh,"dispatchDiscreteCustomEvent");var y2=Object.defineProperty,b2=(e,t)=>y2(e,"name",{value:t,configurable:!0});function Sn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}b2(Sn,"useCallbackRef");var k2=Object.defineProperty,Vt=(e,t)=>k2(e,"name",{value:t,configurable:!0}),Lp="dismissableLayer.update",N2="dismissableLayer.pointerDownOutside",S2="dismissableLayer.focusOutside",Gy,uv=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),xh=d.forwardRef(Vt(function(t,s){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:o,onInteractOutside:c,onDismiss:u,...h}=t,f=d.useContext(uv),[m,p]=d.useState(null),g=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=d.useState({}),b=jt(s,p),j=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=v?j.indexOf(v):-1,y=m?j.indexOf(m):-1,N=f.layersWithOutsidePointerEventsDisabled.size>0,k=y>=w,S=d.useRef(!1),C=aC(z=>{l==null||l(z),c==null||c(z),z.defaultPrevented||u==null||u()},{ownerDocument:g,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(z=>{if(!(z instanceof Node))return!1;const U=[...f.branches].some(A=>A.contains(z));return k&&!U},[f.branches,k])}),$=lC(z=>{if(i&&S.current)return;const U=z.target;[...f.branches].some(P=>P.contains(U))||(o==null||o(z),c==null||c(z),z.defaultPrevented||u==null||u())},g),R=m?y===j.length-1:!1,I=Sn(z=>{z.key==="Escape"&&(a==null||a(z),!z.defaultPrevented&&u&&(z.preventDefault(),u()))});return d.useEffect(()=>{if(R)return g.addEventListener("keydown",I,{capture:!0}),()=>g.removeEventListener("keydown",I,{capture:!0})},[g,R,I]),d.useEffect(()=>{if(m)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Gy=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(m)),f.layers.add(m),_p(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(m),f.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Gy))}},[m,g,r,f]),d.useEffect(()=>()=>{m&&(f.layers.delete(m),f.layersWithOutsidePointerEventsDisabled.delete(m),_p())},[m,f]),d.useEffect(()=>{const z=Vt(()=>x({}),"handleUpdate");return document.addEventListener(Lp,z),()=>document.removeEventListener(Lp,z)},[]),n.jsx(pt.div,{...h,ref:b,style:{pointerEvents:N?k?"auto":"none":void 0,...t.style},onFocusCapture:Pe(t.onFocusCapture,$.onFocusCapture),onBlurCapture:Pe(t.onBlurCapture,$.onBlurCapture),onPointerDownCapture:Pe(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),C2=d.forwardRef(Vt(function(t,s){const r=d.useContext(uv),i=d.useRef(null),a=jt(s,i);return d.useEffect(()=>{const l=i.current;if(l)return r.branches.add(l),()=>{r.branches.delete(l)}},[r.branches]),n.jsx(pt.div,{...t,ref:a})},"DismissableLayerBranch"));function iC(){const e=d.useContext(uv),[t,s]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}Vt(iC,"useDismissableLayerSurface");var E2=Vt(()=>!0,"IS_TRUE");function aC(e,t){const{ownerDocument:s=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:l=E2}=t,o=Sn(e),c=d.useRef(!1),u=d.useRef(!1),h=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function m(){u.current=!1,i.current=!1,h.current.clear()}Vt(m,"resetOutsideInteraction");function p(){return Array.from(h.current.values()).some(Boolean)}Vt(p,"isOutsideInteractionIntercepted");function g(w){if(!u.current)return;const y=w.target;y instanceof Node&&[...a].some(k=>k.contains(y))||h.current.set(w.type,!0),w.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}Vt(g,"handleInteractionCapture");function x(w){u.current&&h.current.set(w.type,!1)}Vt(x,"handleInteractionBubble");const b=Vt(w=>{if(w.target&&!c.current){let y=function(){s.removeEventListener("click",f.current);const k=p();m(),k||dv(N2,o,N,{discrete:!0})};if(Vt(y,"handleAndDispatchPointerDownOutsideEvent"),!l(w.target)){s.removeEventListener("click",f.current),m(),c.current=!1;return}const N={originalEvent:w};u.current=!0,i.current=r&&w.button===0,h.current.clear(),!r||w.button!==0?y():(s.removeEventListener("click",f.current),f.current=y,s.addEventListener("click",f.current,{once:!0}))}else s.removeEventListener("click",f.current),m();c.current=!1},"handlePointerDown"),j=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const w of j)s.addEventListener(w,g,!0),s.addEventListener(w,x);const v=window.setTimeout(()=>{s.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(v),s.removeEventListener("pointerdown",b),s.removeEventListener("click",f.current);for(const w of j)s.removeEventListener(w,g,!0),s.removeEventListener(w,x)}},[s,o,r,i,a,l]),{onPointerDownCapture:Vt(()=>c.current=!0,"onPointerDownCapture")}}Vt(aC,"usePointerDownOutside");function lC(e,t=globalThis==null?void 0:globalThis.document){const s=Sn(e),r=d.useRef(!1);return d.useEffect(()=>{const i=Vt(a=>{a.target&&!r.current&&dv(S2,s,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,s]),{onFocusCapture:Vt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Vt(()=>r.current=!1,"onBlurCapture")}}Vt(lC,"useFocusOutside");function _p(){const e=new CustomEvent(Lp);document.dispatchEvent(e)}Vt(_p,"dispatchUpdate");function dv(e,t,s,{discrete:r}){const i=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?gh(i,a):i.dispatchEvent(a)}Vt(dv,"handleAndDispatchCustomEvent");var A2=xh,T2=C2,Ln=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},R2=Object.defineProperty,$2=(e,t)=>R2(e,"name",{value:t,configurable:!0}),vh=d.forwardRef($2(function(t,s){var c;const{container:r,...i}=t,[a,l]=d.useState(!1);Ln(()=>l(!0),[]);const o=r||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?vl.createPortal(n.jsx(pt.div,{...i,ref:s}),o):null},"Portal")),I2=Object.defineProperty,Mr=(e,t)=>I2(e,"name",{value:t,configurable:!0});function oC(e,t){return d.useReducer((s,r)=>t[s][r]??s,e)}Mr(oC,"useStateMachine");var ur=Mr(e=>{const{present:t,children:s}=e,r=cC(t),i=typeof s=="function"?s({present:r.isPresent}):d.Children.only(s),a=uC(r.ref,dC(i));return typeof s=="function"||r.isPresent?d.cloneElement(i,{ref:a}):null},"Presence");function cC(e){const[t,s]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef("none"),l=d.useRef(void 0),o=e?"mounted":"unmounted",[c,u]=oC(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(a.current=l.current??ka(r.current),l.current=void 0):a.current="none"},[c]),Ln(()=>{const h=r.current,f=i.current;if(f!==e){const p=a.current,g=ka(h);e?(l.current=g,u("MOUNT")):g==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),Ln(()=>{if(t){let h;const f=t.ownerDocument.defaultView??window,m=Mr(g=>{const b=ka(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(u("ANIMATION_END"),!i.current)){const j=t.style.animationFillMode;t.style.animationFillMode="forwards",h=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=j)})}},"handleAnimationEnd"),p=Mr(g=>{g.target===t&&(a.current=ka(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{f.clearTimeout(h),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(h=>{if(h){const f=getComputedStyle(h);r.current=f,l.current=ka(f)}else r.current=null;s(h)},[])}}Mr(cC,"usePresence");function Fp(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Mr(Fp,"setRef");function uC(...e){const t=d.useRef(e);return t.current=e,d.useCallback(s=>{const r=t.current;let i=!1;const a=r.map(l=>{const o=Fp(l,s);return!i&&typeof o=="function"&&(i=!0),o});if(i)return()=>{for(let l=0;l<a.length;l++){const o=a[l];typeof o=="function"?o():Fp(r[l],null)}}},[])}Mr(uC,"useStableComposedRefs");function ka(e){return(e==null?void 0:e.animationName)||"none"}Mr(ka,"getAnimationName");function dC(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}Mr(dC,"getElementRef");var P2=Object.defineProperty,M2=(e,t)=>P2(e,"name",{value:t,configurable:!0}),Yy=pl[" useEffectEvent ".trim().toString()],qy=pl[" useInsertionEffect ".trim().toString()];function hC(e){if(typeof Yy=="function")return Yy(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof qy=="function"?qy(()=>{t.current=e}):Ln(()=>{t.current=e}),d.useMemo(()=>(...s)=>{var r;return(r=t.current)==null?void 0:r.call(t,...s)},[])}M2(hC,"useEffectEvent");var D2=Object.defineProperty,xc=(e,t)=>D2(e,"name",{value:t,configurable:!0}),O2=pl[" useInsertionEffect ".trim().toString()]||Ln;function Ni({prop:e,defaultProp:t,onChange:s=xc(()=>{},"onChange"),caller:r}){const[i,a,l]=fC({defaultProp:t,onChange:s}),o=e!==void 0,c=o?e:i,u=d.useCallback(h=>{var f;if(o){const m=mC(h)?h(e):h;m!==e&&((f=l.current)==null||f.call(l,m))}else a(h)},[o,e,a,l]);return[c,u]}xc(Ni,"useControllableState");function fC({defaultProp:e,onChange:t}){const[s,r]=d.useState(e),i=d.useRef(s),a=d.useRef(t);return O2(()=>{a.current=t},[t]),d.useEffect(()=>{var l;i.current!==s&&((l=a.current)==null||l.call(a,s),i.current=s)},[s,i]),[s,r,a]}xc(fC,"useUncontrolledState");function mC(e){return typeof e=="function"}xc(mC,"isFunction");var Qy=Symbol("RADIX:SYNC_STATE");function L2(e,t,s,r){const{prop:i,defaultProp:a,onChange:l,caller:o}=t,c=i!==void 0,u=hC(l),h=[{...s,state:a}];r&&h.push(r);const[f,m]=d.useReducer((b,j)=>{if(j.type===Qy)return{...b,state:j.state};const v=e(b,j);return c&&!Object.is(v.state,b.state)&&u(v.state),v},...h),p=f.state,g=d.useRef(p);d.useEffect(()=>{g.current!==p&&(g.current=p,c||u(p))},[p,g,c]);const x=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&m({type:Qy,state:i})},[i,f.state,c]),[x,m]}xc(L2,"useControllableStateReducer");var _2=Object.defineProperty,F2=(e,t)=>_2(e,"name",{value:t,configurable:!0}),z2=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hv=d.forwardRef(F2(function(t,s){return n.jsx(pt.span,{...t,ref:s,style:{...z2,...t.style}})},"VisuallyHidden")),U2=hv,B2=Object.defineProperty,xt=(e,t)=>B2(e,"name",{value:t,configurable:!0}),pC="ToastProvider",[fv,gC,W2]=ph("Toast"),[xC,rQ]=_s("Toast",[W2]),[H2,jh]=xC(pC),K2=xt(e=>{const{__scopeToast:t,label:s="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:a=50,announcerContainer:l,children:o}=e,[c,u]=d.useState(null),[h,f]=d.useState(0),m=d.useRef(!1);return s.trim()||console.error(`Invalid prop \`label\` supplied to \`${pC}\`. Expected non-empty \`string\`.`),n.jsx(fv.Provider,{scope:t,children:n.jsx(H2,{scope:t,label:s,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:h,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(p=>p+1),[]),onToastRemove:d.useCallback(()=>f(p=>p-1),[]),isClosePausedRef:m,announcerContainer:l,children:o})})},"ToastProvider"),V2="ToastViewport",G2=["F8"],zp="toast.viewportPause",Up="toast.viewportResume",Y2=d.forwardRef(xt(function(t,s){const{__scopeToast:r,hotkey:i=G2,label:a="Notifications ({hotkey})",...l}=t,o=jh(V2,r),c=gC(r),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),m=d.useRef(null),p=jt(s,m,o.onViewportChange),g=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=o.toastCount>0;d.useEffect(()=>{const j=xt(v=>{var y;i.length!==0&&i.every(N=>v[N]||v.code===N)&&((y=m.current)==null||y.focus())},"handleKeyDown");return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[i]),d.useEffect(()=>{const j=u.current,v=m.current;if(x&&j&&v){const w=xt(()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(zp);v.dispatchEvent(S),o.isClosePausedRef.current=!0}},"handlePause"),y=xt(()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(Up);v.dispatchEvent(S),o.isClosePausedRef.current=!1}},"handleResume"),N=xt(S=>{!j.contains(S.relatedTarget)&&y()},"handleFocusOutResume"),k=xt(()=>{j.contains(document.activeElement)||y()},"handlePointerLeaveResume");return j.addEventListener("focusin",w),j.addEventListener("focusout",N),j.addEventListener("pointermove",w),j.addEventListener("pointerleave",k),window.addEventListener("blur",w),window.addEventListener("focus",y),()=>{j.removeEventListener("focusin",w),j.removeEventListener("focusout",N),j.removeEventListener("pointermove",w),j.removeEventListener("pointerleave",k),window.removeEventListener("blur",w),window.removeEventListener("focus",y)}}},[x,o.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:j})=>{const w=c().map(y=>{const N=y.ref.current,k=[N,...yC(N)];return j==="forwards"?k:k.reverse()});return(j==="forwards"?w.reverse():w).flat()},[c]);return d.useEffect(()=>{const j=m.current;if(j){const v=xt(w=>{var k,S,C;const y=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!y){const $=document.activeElement,R=w.shiftKey;if(w.target===j&&R){(k=h.current)==null||k.focus();return}const U=b({tabbingDirection:R?"backwards":"forwards"}),A=U.findIndex(P=>P===$);Bu(U.slice(A+1))?w.preventDefault():R?(S=h.current)==null||S.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return j.addEventListener("keydown",v),()=>j.removeEventListener("keydown",v)}},[c,b]),n.jsxs(T2,{ref:u,role:"region","aria-label":a.replace("{hotkey}",g),tabIndex:-1,style:{pointerEvents:x?void 0:"none"},children:[x&&n.jsx(Xy,{ref:h,onFocusFromOutsideViewport:()=>{const j=b({tabbingDirection:"forwards"});Bu(j)}}),n.jsx(fv.Slot,{scope:r,children:n.jsx(pt.ol,{tabIndex:-1,...l,ref:p})}),x&&n.jsx(Xy,{ref:f,onFocusFromOutsideViewport:()=>{const j=b({tabbingDirection:"backwards"});Bu(j)}})]})},"ToastViewport")),q2="ToastFocusProxy",Xy=d.forwardRef(xt(function(t,s){const{__scopeToast:r,onFocusFromOutsideViewport:i,...a}=t,l=jh(q2,r);return n.jsx(hv,{tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:o=>{var h;const c=o.relatedTarget;!((h=l.viewport)!=null&&h.contains(c))&&i()}})},"ToastFocusProxy")),wh="Toast",Q2="toast.swipeStart",X2="toast.swipeMove",J2="toast.swipeCancel",Z2="toast.swipeEnd",eM=d.forwardRef(xt(function(t,s){const{forceMount:r,open:i,defaultOpen:a,onOpenChange:l,...o}=t,[c,u]=Ni({prop:i,defaultProp:a??!0,onChange:l,caller:wh});return n.jsx(ur,{present:r||c,children:n.jsx(sM,{open:c,...o,ref:s,onClose:()=>u(!1),onPause:Sn(t.onPause),onResume:Sn(t.onResume),onSwipeStart:Pe(t.onSwipeStart,h=>{h.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Pe(t.onSwipeMove,h=>{const{x:f,y:m}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","move"),h.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${m}px`)}),onSwipeCancel:Pe(t.onSwipeCancel,h=>{h.currentTarget.setAttribute("data-swipe","cancel"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Pe(t.onSwipeEnd,h=>{const{x:f,y:m}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","end"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${m}px`),u(!1)})})})},"Toast")),[tM,nM]=xC(wh,{onClose(){}}),sM=d.forwardRef(xt(function(t,s){const{__scopeToast:r,type:i="foreground",duration:a,open:l,onClose:o,onEscapeKeyDown:c,onPause:u,onResume:h,onSwipeStart:f,onSwipeMove:m,onSwipeCancel:p,onSwipeEnd:g,...x}=t,b=jh(wh,r),j=gC(r),[v,w]=d.useState(null),y=jt(s,w),N=d.useRef(null),k=d.useRef(null),S=a||b.duration,C=d.useRef(0),$=d.useRef(S),R=d.useRef(0),{onToastAdd:I,onToastRemove:z}=b,U=Sn(()=>{var O;(v==null?void 0:v.contains(document.activeElement))&&((O=b.viewport)==null||O.focus()),o()}),A=d.useCallback(D=>{!D||D===1/0||(window.clearTimeout(R.current),C.current=new Date().getTime(),R.current=window.setTimeout(U,D))},[U]);d.useEffect(()=>{const D=b.viewport;if(D){const O=xt(()=>{A($.current),h==null||h()},"handleResume"),M=xt(()=>{const W=new Date().getTime()-C.current;$.current=$.current-W,window.clearTimeout(R.current),u==null||u()},"handlePause");return D.addEventListener(zp,M),D.addEventListener(Up,O),()=>{D.removeEventListener(zp,M),D.removeEventListener(Up,O)}}},[b.viewport,S,u,h,A]),d.useEffect(()=>{l&&!b.isClosePausedRef.current&&A(S)},[l,S,b.isClosePausedRef,A]),d.useEffect(()=>()=>{window.clearTimeout(R.current)},[]),d.useEffect(()=>(I(),()=>z()),[I,z]);const P=d.useMemo(()=>v?mv(v):null,[v]);return b.viewport?n.jsxs(n.Fragment,{children:[P&&n.jsx(rM,{__scopeToast:r,role:"status","aria-live":i==="foreground"?"assertive":"polite",children:P}),n.jsx(tM,{scope:r,onClose:U,children:vl.createPortal(n.jsx(fv.ItemSlot,{scope:r,children:n.jsx(A2,{asChild:!0,onEscapeKeyDown:Pe(c,D=>{j().some(M=>{var W;return(W=M.ref.current)==null?void 0:W.contains(D.target)})||U()}),children:n.jsx(pt.li,{tabIndex:0,"data-state":l?"open":"closed","data-swipe-direction":b.swipeDirection,...x,ref:y,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Pe(t.onKeyDown,D=>{D.key==="Escape"&&(c==null||c(D.nativeEvent),D.nativeEvent.defaultPrevented||U())}),onPointerDown:Pe(t.onPointerDown,D=>{D.button===0&&(N.current={x:D.clientX,y:D.clientY})}),onPointerMove:Pe(t.onPointerMove,D=>{if(!N.current)return;const O=D.clientX-N.current.x,M=D.clientY-N.current.y,W=!!k.current,_=["left","right"].includes(b.swipeDirection),G=["left","up"].includes(b.swipeDirection)?Math.min:Math.max,B=_?G(0,O):0,K=_?0:G(0,M),F=D.pointerType==="touch"?10:2,Q={x:B,y:K},X={originalEvent:D,delta:Q};W?(k.current=Q,lo(X2,m,X,{discrete:!1})):Jy(Q,b.swipeDirection,F)?(k.current=Q,lo(Q2,f,X,{discrete:!1}),D.target.setPointerCapture(D.pointerId)):(Math.abs(O)>F||Math.abs(M)>F)&&(N.current=null)}),onPointerUp:Pe(t.onPointerUp,D=>{const O=k.current,M=D.target;if(M.hasPointerCapture(D.pointerId)&&M.releasePointerCapture(D.pointerId),k.current=null,N.current=null,O){const W=D.currentTarget,_={originalEvent:D,delta:O};Jy(O,b.swipeDirection,b.swipeThreshold)?lo(Z2,g,_,{discrete:!0}):lo(J2,p,_,{discrete:!0}),W.addEventListener("click",G=>G.preventDefault(),{once:!0})}})})})}),b.viewport)})]}):null},"ToastImpl")),rM=xt(e=>{const{__scopeToast:t,children:s,...r}=e,i=jh(wh,t),[a,l]=d.useState(!1),[o,c]=d.useState(!1);return jC(()=>l(!0)),d.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),o?null:n.jsx(vh,{asChild:!0,container:i.announcerContainer||void 0,children:n.jsx(hv,{...r,children:a&&n.jsxs(n.Fragment,{children:[i.label," ",s]})})})},"ToastAnnounce"),iM=d.forwardRef(xt(function(t,s){const{__scopeToast:r,...i}=t;return n.jsx(pt.div,{...i,ref:s})},"ToastTitle")),aM=d.forwardRef(xt(function(t,s){const{__scopeToast:r,...i}=t;return n.jsx(pt.div,{...i,ref:s})},"ToastDescription")),lM="ToastAction",oM=d.forwardRef(xt(function(t,s){const{altText:r,...i}=t;return r.trim()?n.jsx(vC,{altText:r,asChild:!0,children:n.jsx(uM,{...i,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${lM}\`. Expected non-empty \`string\`.`),null)},"ToastAction")),cM="ToastClose",uM=d.forwardRef(xt(function(t,s){const{__scopeToast:r,...i}=t,a=nM(cM,r);return n.jsx(vC,{asChild:!0,children:n.jsx(pt.button,{type:"button",...i,ref:s,onClick:Pe(t.onClick,a.onClose)})})},"ToastClose")),vC=d.forwardRef(xt(function(t,s){const{__scopeToast:r,altText:i,...a}=t;return n.jsx(pt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":i||void 0,...a,ref:s})},"ToastAnnounceExclude"));function mv(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),wC(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",a=r.dataset.radixToastAnnounceExclude==="";if(!i)if(a){const l=r.dataset.radixToastAnnounceAlt;l&&t.push(l)}else t.push(...mv(r))}}),t}xt(mv,"getAnnounceTextContent");function lo(e,t,s,{discrete:r}){const i=s.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:s});t&&i.addEventListener(e,t,{once:!0}),r?gh(i,a):i.dispatchEvent(a)}xt(lo,"handleAndDispatchCustomEvent");var Jy=xt((e,t,s=0)=>{const r=Math.abs(e.x),i=Math.abs(e.y),a=r>i;return t==="left"||t==="right"?a&&r>s:!a&&i>s},"isDeltaInDirection");function jC(e=()=>{}){const t=Sn(e);Ln(()=>{let s=0,r=0;return s=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(r)}},[t])}xt(jC,"useNextFrame");function wC(e){return e.nodeType===e.ELEMENT_NODE}xt(wC,"isHTMLElement");function yC(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xt(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;s.nextNode();)t.push(s.currentNode);return t}xt(yC,"getTabbableCandidates");function Bu(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}xt(Bu,"focusFirst");var Zy=K2,eb=Y2,dM=eM,hM=iM,fM=aM,mM=oM,pM=Object.defineProperty,gM=(e,t)=>pM(e,"name",{value:t,configurable:!0}),xM=pl[" useId ".trim().toString()]||(()=>{}),vM=0;function $s(e){const[t,s]=d.useState(xM());return Ln(()=>{e||s(r=>r??String(vM++))},[e]),e||(t?`radix-${t}`:"")}gM($s,"useId");const jM=["top","right","bottom","left"],mi=Math.min,Cr=Math.max,Sd=Math.round,ru=Math.floor,Er=e=>({x:e,y:e}),wM={left:"right",right:"left",bottom:"top",top:"bottom"};function bC(e,t,s){return Cr(e,mi(t,s))}function Dr(e,t){return typeof e=="function"?e(t):e}function pi(e){return e.split("-")[0]}function wl(e){return e.split("-")[1]}function pv(e){return e==="x"?"y":"x"}function gv(e){return e==="y"?"height":"width"}function er(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function xv(e){return pv(er(e))}function yM(e,t,s){s===void 0&&(s=!1);const r=wl(e),i=xv(e),a=gv(i);let l=i==="x"?r===(s?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=Cd(l)),[l,Cd(l)]}function bM(e){const t=Cd(e);return[Bp(e),t,Bp(t)]}function Bp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const tb=["left","right"],nb=["right","left"],kM=["top","bottom"],NM=["bottom","top"];function SM(e,t,s){switch(e){case"top":case"bottom":return s?t?nb:tb:t?tb:nb;case"left":case"right":return t?kM:NM;default:return[]}}function CM(e,t,s,r){const i=wl(e);let a=SM(pi(e),s==="start",r);return i&&(a=a.map(l=>l+"-"+i),t&&(a=a.concat(a.map(Bp)))),a}function Cd(e){const t=pi(e);return wM[t]+e.slice(t.length)}function EM(e){var t,s,r,i;return{top:(t=e.top)!=null?t:0,right:(s=e.right)!=null?s:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function kC(e){return typeof e!="number"?EM(e):{top:e,right:e,bottom:e,left:e}}function Ed(e){const{x:t,y:s,width:r,height:i}=e;return{width:r,height:i,top:s,left:t,right:t+r,bottom:s+i,x:t,y:s}}function sb(e,t,s){let{reference:r,floating:i}=e;const a=er(t),l=xv(t),o=gv(l),c=pi(t),u=a==="y",h=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,m=r[o]/2-i[o]/2;let p;switch(c){case"top":p={x:h,y:r.y-i.height};break;case"bottom":p={x:h,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-i.width,y:f};break;default:p={x:r.x,y:r.y}}const g=wl(t);return g&&(p[l]+=m*(g==="end"?1:-1)*(s&&u?-1:1)),p}async function AM(e,t){var s;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:l,elements:o,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=Dr(t,e),g=kC(p),b=o[m?f==="floating"?"reference":"floating":f],j=Ed(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(b)))==null||s?b:b.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(o.floating)),boundary:u,rootBoundary:h,strategy:c})),v=f==="floating"?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(o.floating)),y=await(a.isElement==null?void 0:a.isElement(w))&&await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1},N=Ed(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:w,strategy:c}):v);return{top:(j.top-N.top+g.top)/y.y,bottom:(N.bottom-j.bottom+g.bottom)/y.y,left:(j.left-N.left+g.left)/y.x,right:(N.right-j.right+g.right)/y.x}}const TM=50,RM=async(e,t,s)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:l}=s,o=l.detectOverflow?l:{...l,detectOverflow:AM},c=await(l.isRTL==null?void 0:l.isRTL(t));let u=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:f}=sb(u,r,c),m=r,p=0;const g={};for(let x=0;x<a.length;x++){const b=a[x];if(!b)continue;const{name:j,fn:v}=b,{x:w,y,data:N,reset:k}=await v({x:h,y:f,initialPlacement:r,placement:m,strategy:i,middlewareData:g,rects:u,platform:o,elements:{reference:e,floating:t}});h=w??h,f=y??f,g[j]={...g[j],...N},k&&p<TM&&(p++,typeof k=="object"&&(k.placement&&(m=k.placement),k.rects&&(u=k.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:h,y:f}=sb(u,m,c)),x=-1)}return{x:h,y:f,placement:m,strategy:i,middlewareData:g}},$M=e=>({name:"arrow",options:e,async fn(t){const{x:s,y:r,placement:i,rects:a,platform:l,elements:o,middlewareData:c}=t,{element:u,padding:h=0}=Dr(e,t)||{};if(u==null)return{};const f=kC(h),m={x:s,y:r},p=xv(i),g=gv(p),x=await l.getDimensions(u),b=p==="y",j=b?"top":"left",v=b?"bottom":"right",w=b?"clientHeight":"clientWidth",y=a.reference[g]+a.reference[p]-m[p]-a.floating[g],N=m[p]-a.reference[p],k=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let S=k?k[w]:0;(!S||!await(l.isElement==null?void 0:l.isElement(k)))&&(S=o.floating[w]||a.floating[g]);const C=y/2-N/2,$=S/2-x[g]/2-1,R=mi(f[j],$),I=mi(f[v],$),z=S-x[g]-I,U=S/2-x[g]/2+C,A=bC(R,U,z),P=!c.arrow&&wl(i)!=null&&U!==A&&a.reference[g]/2-(U<R?R:I)-x[g]/2<0,D=P?U<R?U-R:U-z:0;return{[p]:m[p]+D,data:{[p]:A,centerOffset:U-A-D,...P&&{alignmentOffset:D}},reset:P}}}),IM=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,r;const{placement:i,middlewareData:a,rects:l,initialPlacement:o,platform:c,elements:u}=t,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:x=!0,...b}=Dr(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const j=pi(i),v=er(o),w=pi(o)===o,y=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=m||(w||!x?[Cd(o)]:bM(o)),k=g!=="none";!m&&k&&N.push(...CM(o,x,g,y));const S=[o,...N],C=await c.detectOverflow(t,b),$=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&$.push(C[j]),f){const A=yM(i,l,y);$.push(C[A[0]],C[A[1]])}if(R=[...R,{placement:i,overflows:$}],!$.every(A=>A<=0)){var I,z;const A=(((I=a.flip)==null?void 0:I.index)||0)+1,P=S[A];if(P&&(!(f==="alignment"?v!==er(P):!1)||R.every(M=>er(M.placement)===v?M.overflows[0]>0:!0)))return{data:{index:A,overflows:R},reset:{placement:P}};let D=(z=R.filter(O=>O.overflows[0]<=0).sort((O,M)=>O.overflows[1]-M.overflows[1])[0])==null?void 0:z.placement;if(!D)switch(p){case"bestFit":{var U;const O=(U=R.filter(M=>{if(k){const W=er(M.placement);return W===v||W==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(W=>W>0).reduce((W,_)=>W+_,0)]).sort((M,W)=>M[1]-W[1])[0])==null?void 0:U[0];O&&(D=O);break}case"initialPlacement":D=o;break}if(i!==D)return{reset:{placement:D}}}return{}}}};function rb(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ib(e){return jM.some(t=>e[t]>=0)}const PM=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:r}=t,{strategy:i="referenceHidden",...a}=Dr(e,t);switch(i){case"referenceHidden":{const l=await r.detectOverflow(t,{...a,elementContext:"reference"}),o=rb(l,s.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:ib(o)}}}case"escaped":{const l=await r.detectOverflow(t,{...a,altBoundary:!0}),o=rb(l,s.floating);return{data:{escapedOffsets:o,escaped:ib(o)}}}default:return{}}}}},NC=new Set(["left","top"]);async function MM(e,t){const{placement:s,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=pi(s),o=wl(s),c=er(s)==="y",u=NC.has(l)?-1:1,h=a&&c?-1:1,f=Dr(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return o&&typeof g=="number"&&(p=o==="end"?g*-1:g),c?{x:p*h,y:m*u}:{x:m*u,y:p*h}}const DM=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,r;const{x:i,y:a,placement:l,middlewareData:o}=t,c=await MM(t,e);return l===((s=o.offset)==null?void 0:s.placement)&&(r=o.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:a+c.y,data:{...c,placement:l}}}}},OM=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:r,placement:i,platform:a}=t,{mainAxis:l=!0,crossAxis:o=!1,limiter:c={fn:v=>{let{x:w,y}=v;return{x:w,y}}},...u}=Dr(e,t),h={x:s,y:r},f=await a.detectOverflow(t,u),m=er(i),p=pv(m);let g=h[p],x=h[m];const b=(v,w)=>bC(w+f[v==="y"?"top":"left"],w,w-f[v==="y"?"bottom":"right"]);l&&(g=b(p,g)),o&&(x=b(m,x));const j=c.fn({...t,[p]:g,[m]:x});return{...j,data:{x:j.x-s,y:j.y-r,enabled:{[p]:l,[m]:o}}}}}},LM=function(e){return e===void 0&&(e={}),{options:e,fn(t){var s,r;const{x:i,y:a,placement:l,rects:o,middlewareData:c}=t,{offset:u=0,mainAxis:h=!0,crossAxis:f=!0}=Dr(e,t),m={x:i,y:a},p=er(l),g=pv(p);let x=m[g],b=m[p];const j=Dr(u,t),v=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:(s=j.mainAxis)!=null?s:0,crossAxis:(r=j.crossAxis)!=null?r:0};if(h){const N=g==="y"?"height":"width",k=o.reference[g]-o.floating[N]+v.mainAxis,S=o.reference[g]+o.reference[N]-v.mainAxis;x<k?x=k:x>S&&(x=S)}if(f){var w,y;const N=g==="y"?"width":"height",k=NC.has(pi(l)),S=o.reference[p]-o.floating[N]+(k&&((w=c.offset)==null?void 0:w[p])||0)+(k?0:v.crossAxis),C=o.reference[p]+o.reference[N]+(k?0:((y=c.offset)==null?void 0:y[p])||0)-(k?v.crossAxis:0);b<S?b=S:b>C&&(b=C)}return{[g]:x,[p]:b}}}},_M=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:s,rects:r,platform:i,elements:a}=t,{apply:l=()=>{},...o}=Dr(e,t),c=await i.detectOverflow(t,o),u=pi(s),h=wl(s),f=er(s)==="y",{width:m,height:p}=r.floating;let g,x;u==="top"||u==="bottom"?(g=u,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=u,g=h==="end"?"top":"bottom");const b=p-c.top-c.bottom,j=m-c.left-c.right,v=mi(p-c[g],b),w=mi(m-c[x],j),y=t.middlewareData.shift,N=!y;let k=v,S=w;y!=null&&y.enabled.x&&(S=j),y!=null&&y.enabled.y&&(k=b),N&&!h&&(f?S=m-2*Cr(c.left,c.right):k=p-2*Cr(c.top,c.bottom)),await l({...t,availableWidth:S,availableHeight:k});const C=await i.getDimensions(a.floating);return m!==C.width||p!==C.height?{reset:{rects:!0}}:{}}}};function yh(){return typeof window<"u"}function yl(e){return SC(e)?(e.nodeName||"").toLowerCase():"#document"}function _n(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ur(e){var t;return(t=(SC(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function SC(e){return yh()?e instanceof Node||e instanceof _n(e).Node:!1}function ir(e){return yh()?e instanceof Element||e instanceof _n(e).Element:!1}function Si(e){return yh()?e instanceof HTMLElement||e instanceof _n(e).HTMLElement:!1}function ab(e){return!yh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof _n(e).ShadowRoot}function bh(e){const{overflow:t,overflowX:s,overflowY:r,display:i}=ar(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+s)&&i!=="inline"&&i!=="contents"}function FM(e){return/^(table|td|th)$/.test(yl(e))}function kh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const zM=/transform|translate|scale|rotate|perspective|filter/,UM=/paint|layout|strict|content/,Ii=e=>!!e&&e!=="none";let Uf;function vv(e){const t=ir(e)?ar(e):e;return Ii(t.transform)||Ii(t.translate)||Ii(t.scale)||Ii(t.rotate)||Ii(t.perspective)||!jv()&&(Ii(t.backdropFilter)||Ii(t.filter))||zM.test(t.willChange||"")||UM.test(t.contain||"")}function BM(e){let t=Zi(e);for(;Si(t)&&!Bo(t);){if(vv(t))return t;if(kh(t))return null;t=Zi(t)}return null}function jv(){return Uf==null&&(Uf=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Uf}function Bo(e){return/^(html|body|#document)$/.test(yl(e))}function ar(e){return _n(e).getComputedStyle(e)}function Nh(e){return ir(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Zi(e){if(yl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ab(e)&&e.host||Ur(e);return ab(t)?t.host:t}function CC(e){const t=Zi(e);return Bo(t)?(e.ownerDocument||e).body:Si(t)&&bh(t)?t:CC(t)}function Wo(e,t,s){var r;t===void 0&&(t=[]),s===void 0&&(s=!0);const i=CC(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),l=_n(i);if(a){const o=Wp(l);return t.concat(l,l.visualViewport||[],bh(i)?i:[],o&&s?Wo(o):[])}else return t.concat(i,Wo(i,[],s))}function Wp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function EC(e){const t=ar(e);let s=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Si(e),a=i?e.offsetWidth:s,l=i?e.offsetHeight:r,o=Sd(s)!==a||Sd(r)!==l;return o&&(s=a,r=l),{width:s,height:r,$:o}}function wv(e){return ir(e)?e:e.contextElement}function Ka(e){const t=wv(e);if(!Si(t))return Er(1);const s=t.getBoundingClientRect(),{width:r,height:i,$:a}=EC(t);let l=(a?Sd(s.width):s.width)/r,o=(a?Sd(s.height):s.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!o||!Number.isFinite(o))&&(o=1),{x:l,y:o}}const WM=Er(0);function AC(e){const t=_n(e);return!jv()||!t.visualViewport?WM:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function HM(e,t,s){return t===void 0&&(t=!1),!!s&&t&&s===_n(e)}function ea(e,t,s,r){t===void 0&&(t=!1),s===void 0&&(s=!1);const i=e.getBoundingClientRect(),a=wv(e);let l=Er(1);t&&(r?ir(r)&&(l=Ka(r)):l=Ka(e));const o=HM(a,s,r)?AC(a):Er(0);let c=(i.left+o.x)/l.x,u=(i.top+o.y)/l.y,h=i.width/l.x,f=i.height/l.y;if(a&&r){const m=_n(a),p=ir(r)?_n(r):r;let g=m,x=Wp(g);for(;x&&p!==g;){const b=Ka(x),j=x.getBoundingClientRect(),v=ar(x),w=j.left+(x.clientLeft+parseFloat(v.paddingLeft))*b.x,y=j.top+(x.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,u*=b.y,h*=b.x,f*=b.y,c+=w,u+=y,g=_n(x),x=Wp(g)}}return Ed({width:h,height:f,x:c,y:u})}function Sh(e,t){const s=Nh(e).scrollLeft;return t?t.left+s:ea(Ur(e)).left+s}function TC(e,t){const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-Sh(e,s),i=s.top+t.scrollTop;return{x:r,y:i}}function KM(e){let{elements:t,rect:s,offsetParent:r,strategy:i}=e;const a=i==="fixed",l=Ur(r),o=t?kh(t.floating):!1;if(r===l||o&&a)return s;let c={scrollLeft:0,scrollTop:0},u=Er(1);const h=Er(0),f=Si(r);if((f||!a)&&((yl(r)!=="body"||bh(l))&&(c=Nh(r)),f)){const p=ea(r);u=Ka(r),h.x=p.x+r.clientLeft,h.y=p.y+r.clientTop}const m=l&&!f&&!a?TC(l,c):Er(0);return{width:s.width*u.x,height:s.height*u.y,x:s.x*u.x-c.scrollLeft*u.x+h.x+m.x,y:s.y*u.y-c.scrollTop*u.y+h.y+m.y}}function VM(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function GM(e){const t=Nh(e),s=e.ownerDocument.body,r=Cr(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),i=Cr(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let a=-t.scrollLeft+Sh(e);const l=-t.scrollTop;return ar(s).direction==="rtl"&&(a+=Cr(e.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:l}}const YM=25;function qM(e,t,s){s===void 0&&(s="viewport");const r=s==="layoutViewport",i=_n(e),a=Ur(e),l=i.visualViewport;let o=a.clientWidth,c=a.clientHeight,u=0,h=0;if(l){const m=!jv()||t==="fixed";r?m||(u=-l.offsetLeft,h=-l.offsetTop):(o=l.width,c=l.height,m&&(u=l.offsetLeft,h=l.offsetTop))}if(Sh(a)<=0){const m=a.ownerDocument,p=m.body,g=getComputedStyle(p),x=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(a.clientWidth-p.clientWidth-x),j=getComputedStyle(a).scrollbarGutter==="stable both-edges"?b/2:b;j<=YM&&(o-=j)}return{width:o,height:c,x:u,y:h}}function QM(e,t){const s=ea(e,!0,t==="fixed"),r=s.top+e.clientTop,i=s.left+e.clientLeft,a=Ka(e),l=e.clientWidth*a.x,o=e.clientHeight*a.y,c=i*a.x,u=r*a.y;return{width:l,height:o,x:c,y:u}}function lb(e,t,s){let r;if(t==="viewport"||t==="layoutViewport")r=qM(e,s,t);else if(t==="document")r=GM(Ur(e));else if(ir(t))r=QM(t,s);else{const i=AC(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Ed(r)}function XM(e,t){const s=t.get(e);if(s)return s;let r=Wo(e,[],!1).filter(o=>ir(o)&&yl(o)!=="body"),i=null;const a=ar(e).position==="fixed";let l=a?Zi(e):e;for(;ir(l)&&!Bo(l);){const o=ar(l),c=vv(l),u=i?i.position:a?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&o.position==="static")?r=r.filter(f=>f!==l):i=o,l=Zi(l)}return t.set(e,r),r}function JM(e){let{element:t,boundary:s,rootBoundary:r,strategy:i}=e;const l=[...s==="clippingAncestors"?kh(t)?[]:XM(t,this._c):[].concat(s),r],o=lb(t,l[0],i);let c=o.top,u=o.right,h=o.bottom,f=o.left;for(let m=1;m<l.length;m++){const p=lb(t,l[m],i);c=Cr(p.top,c),u=mi(p.right,u),h=mi(p.bottom,h),f=Cr(p.left,f)}return{width:u-f,height:h-c,x:f,y:c}}function ZM(e){const{width:t,height:s}=EC(e);return{width:t,height:s}}function eD(e,t,s){const r=Si(t),i=Ur(t),a=s==="fixed",l=ea(e,!0,a,t);let o={scrollLeft:0,scrollTop:0};const c=Er(0);if((r||!a)&&((yl(t)!=="body"||bh(i))&&(o=Nh(t)),r)){const m=ea(t,!0,a,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}!r&&i&&(c.x=Sh(i));const u=i&&!r&&!a?TC(i,o):Er(0),h=l.left+o.scrollLeft-c.x-u.x,f=l.top+o.scrollTop-c.y-u.y;return{x:h,y:f,width:l.width,height:l.height}}function Bf(e){return ar(e).position==="static"}function ob(e,t){if(!Si(e)||ar(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Ur(e)===s&&(s=s.ownerDocument.body),s}function RC(e,t){const s=_n(e);if(kh(e))return s;if(!Si(e)){let i=Zi(e);for(;i&&!Bo(i);){if(ir(i)&&!Bf(i))return i;i=Zi(i)}return s}let r=ob(e,t);for(;r&&FM(r)&&Bf(r);)r=ob(r,t);return r&&Bo(r)&&Bf(r)&&!vv(r)?s:r||BM(e)||s}const tD=async function(e){const t=this.getOffsetParent||RC,s=this.getDimensions,r=await s(e.floating);return{reference:eD(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nD(e){return ar(e).direction==="rtl"}const sD={convertOffsetParentRelativeRectToViewportRelativeRect:KM,getDocumentElement:Ur,getClippingRect:JM,getOffsetParent:RC,getElementRects:tD,getClientRects:VM,getDimensions:ZM,getScale:Ka,isElement:ir,isRTL:nD};function $C(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rD(e,t,s){let r=null,i;const a=Ur(e);function l(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function o(h,f){h===void 0&&(h=!1),f===void 0&&(f=1),l();const m=e.getBoundingClientRect(),{left:p,top:g,width:x,height:b}=m;if(h||t(),!x||!b)return;const j=ru(g),v=ru(a.clientWidth-(p+x)),w=ru(a.clientHeight-(g+b)),y=ru(p),k={rootMargin:-j+"px "+-v+"px "+-w+"px "+-y+"px",threshold:Cr(0,mi(1,f))||1};let S=!0;function C($){const R=$[0].intersectionRatio;if(!$C(m,e.getBoundingClientRect()))return o();if(R!==f){if(!S)return o();R?o(!1,R):i=setTimeout(()=>{o(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...k,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,k)}r.observe(e)}const c=_n(e),u=()=>o(s);return c.addEventListener("resize",u),o(!0),()=>{c.removeEventListener("resize",u),l()}}function iD(e,t,s,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=wv(e),h=i||a?[...u?Wo(u):[],...t?Wo(t):[]]:[];h.forEach(j=>{i&&j.addEventListener("scroll",s),a&&j.addEventListener("resize",s)});const f=u&&o?rD(u,s,a):null;let m=-1,p=null;l&&(p=new ResizeObserver(j=>{let[v]=j;v&&v.target===u&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),s()}),u&&!c&&p.observe(u),t&&p.observe(t));let g,x=c?ea(e):null;c&&b();function b(){const j=ea(e);x&&!$C(x,j)&&s(),x=j,g=requestAnimationFrame(b)}return s(),()=>{var j;h.forEach(v=>{i&&v.removeEventListener("scroll",s),a&&v.removeEventListener("resize",s)}),f==null||f(),(j=p)==null||j.disconnect(),p=null,c&&cancelAnimationFrame(g)}}const aD=DM,lD=OM,oD=IM,cD=_M,uD=PM,cb=$M,dD=LM,hD=(e,t,s)=>{const r=new Map,i=s??{},a={...sD,...i.platform,_c:r};return RM(e,t,{...i,platform:a})};var fD=typeof document<"u",mD=function(){},Wu=fD?d.useLayoutEffect:mD;function Ad(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(r=s;r--!==0;)if(!Ad(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),s=i.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=s;r--!==0;){const a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!Ad(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function IC(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ub(e,t){const s=IC(e);return Math.round(t*s)/s}function Wf(e){const t=d.useRef(e);return Wu(()=>{t.current=e}),t}function pD(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:l}={},transform:o=!0,whileElementsMounted:c,open:u}=e,[h,f]=d.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=d.useState(r);Ad(m,r)||p(r);const[g,x]=d.useState(null),[b,j]=d.useState(null),v=d.useCallback(M=>{M!==k.current&&(k.current=M,x(M))},[]),w=d.useCallback(M=>{M!==S.current&&(S.current=M,j(M))},[]),y=a||g,N=l||b,k=d.useRef(null),S=d.useRef(null),C=d.useRef(h),$=c!=null,R=Wf(c),I=Wf(i),z=Wf(u),U=d.useCallback(()=>{if(!k.current||!S.current)return;const M={placement:t,strategy:s,middleware:m};I.current&&(M.platform=I.current),hD(k.current,S.current,M).then(W=>{const _={...W,isPositioned:z.current!==!1};A.current&&!Ad(C.current,_)&&(C.current=_,vl.flushSync(()=>{f(_)}))})},[m,t,s,I,z]);Wu(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const A=d.useRef(!1);Wu(()=>(A.current=!0,()=>{A.current=!1}),[]),Wu(()=>{if(y&&(k.current=y),N&&(S.current=N),y&&N){if(R.current)return R.current(y,N,U);U()}},[y,N,U,R,$]);const P=d.useMemo(()=>({reference:k,floating:S,setReference:v,setFloating:w}),[v,w]),D=d.useMemo(()=>({reference:y,floating:N}),[y,N]),O=d.useMemo(()=>{const M={position:s,left:0,top:0};if(!D.floating)return M;const W=ub(D.floating,h.x),_=ub(D.floating,h.y);return o?{...M,transform:"translate("+W+"px, "+_+"px)",...IC(D.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:W,top:_}},[s,o,D.floating,h.x,h.y]);return d.useMemo(()=>({...h,update:U,refs:P,elements:D,floatingStyles:O}),[h,U,P,D,O])}const gD=e=>{function t(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:r,padding:i}=typeof e=="function"?e(s):e;return r&&t(r)?r.current!=null?cb({element:r.current,padding:i}).fn(s):{}:r?cb({element:r,padding:i}).fn(s):{}}}},xD=(e,t)=>{const s=aD(e);return{name:s.name,fn:s.fn,options:[e,t]}},vD=(e,t)=>{const s=lD(e);return{name:s.name,fn:s.fn,options:[e,t]}},jD=(e,t)=>({fn:dD(e).fn,options:[e,t]}),wD=(e,t)=>{const s=oD(e);return{name:s.name,fn:s.fn,options:[e,t]}},yD=(e,t)=>{const s=cD(e);return{name:s.name,fn:s.fn,options:[e,t]}},bD=(e,t)=>{const s=uD(e);return{name:s.name,fn:s.fn,options:[e,t]}},kD=(e,t)=>{const s=gD(e);return{name:s.name,fn:s.fn,options:[e,t]}};var ND=Object.defineProperty,SD=(e,t)=>ND(e,"name",{value:t,configurable:!0});function PC(e){const[t,s]=d.useState(void 0);return Ln(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let l,o;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,o=u.blockSize}else l=e.offsetWidth,o=e.offsetHeight;s({width:l,height:o})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else s(void 0)},[e]),t}SD(PC,"useSize");var CD=Object.defineProperty,oi=(e,t)=>CD(e,"name",{value:t,configurable:!0}),MC="Popper",[DC,Ch]=_s(MC),[ED,OC]=DC(MC),AD=oi(e=>{const{__scopePopper:t,children:s}=e,[r,i]=d.useState(null),[a,l]=d.useState(void 0);return n.jsx(ED,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:l,children:s})},"Popper"),TD="PopperAnchor",RD=d.forwardRef(oi(function(t,s){const{__scopePopper:r,virtualRef:i,...a}=t,l=OC(TD,r),o=d.useRef(null),c=l.onAnchorChange,u=d.useCallback(x=>{o.current=x,x&&c(x)},[c]),h=jt(s,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const x=f.current;f.current=i.current,x!==f.current&&c(f.current)});const m=l.placementState&&Eh(l.placementState),p=m==null?void 0:m[0],g=m==null?void 0:m[1];return i?null:n.jsx(pt.div,{"data-radix-popper-side":p,"data-radix-popper-align":g,...a,ref:h})},"PopperAnchor")),LC="PopperContent",[$D,iQ]=DC(LC),ID=d.forwardRef(oi(function(t,s){var _e,Ie,Ue,ee,be,se,Te;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:l="center",alignOffset:o=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:f=0,sticky:m="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:x,...b}=t,j=OC(LC,r),[v,w]=d.useState(null),y=jt(s,w),[N,k]=d.useState(null),S=PC(N),C=(S==null?void 0:S.width)??0,$=(S==null?void 0:S.height)??0,R=i+(l!=="center"?"-"+l:""),I=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},z=Array.isArray(h)?h:[h],U=z.length>0,A={padding:I,boundary:z.filter(_C),altBoundary:U},{refs:P,floatingStyles:D,placement:O,isPositioned:M,middlewareData:W}=pD({strategy:"fixed",placement:R,whileElementsMounted:oi((...pe)=>iD(...pe,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:j.anchor},middleware:[xD({mainAxis:a+$,alignmentAxis:o}),u&&vD({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?jD():void 0,...A}),u&&wD({...A}),yD({...A,apply:oi(({elements:pe,rects:Re,availableWidth:Se,availableHeight:Fe})=>{const{width:Ze,height:Ee}=Re.reference,ze=pe.floating.style;ze.setProperty("--radix-popper-available-width",`${Se}px`),ze.setProperty("--radix-popper-available-height",`${Fe}px`),ze.setProperty("--radix-popper-anchor-width",`${Ze}px`),ze.setProperty("--radix-popper-anchor-height",`${Ee}px`)},"apply")}),N&&kD({element:N,padding:c}),PD({arrowWidth:C,arrowHeight:$}),p&&bD({strategy:"referenceHidden",...A,boundary:U?A.boundary:void 0})]}),_=j.setPlacementState;Ln(()=>(_(O),()=>{_(void 0)}),[O,_]);const[G,B]=Eh(O),K=Sn(x);Ln(()=>{M&&(K==null||K())},[M,K]);const F=(_e=W.arrow)==null?void 0:_e.x,Q=(Ie=W.arrow)==null?void 0:Ie.y,X=((Ue=W.arrow)==null?void 0:Ue.centerOffset)!==0,[Z,de]=d.useState();return Ln(()=>{v&&de(window.getComputedStyle(v).zIndex)},[v]),n.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:M?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(ee=W.transformOrigin)==null?void 0:ee.x,(be=W.transformOrigin)==null?void 0:be.y].join(" "),...((se=W.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:n.jsx($D,{scope:r,placedSide:G,placedAlign:B,onArrowChange:k,arrowX:F,arrowY:Q,shouldHideArrow:X,children:n.jsx(pt.div,{"data-side":G,"data-align":B,...b,ref:y,style:{...b.style,animation:M?(Te=b.style)==null?void 0:Te.animation:"none"}})})})},"PopperContent"));function _C(e){return e!==null}oi(_C,"isNotNull");var PD=oi(e=>({name:"transformOrigin",options:e,fn(t){var b,j,v;const{placement:s,rects:r,middlewareData:i}=t,l=((b=i.arrow)==null?void 0:b.centerOffset)!==0,o=l?0:e.arrowWidth,c=l?0:e.arrowHeight,[u,h]=Eh(s),f={start:"0%",center:"50%",end:"100%"}[h],m=(((j=i.arrow)==null?void 0:j.x)??0)+o/2,p=(((v=i.arrow)==null?void 0:v.y)??0)+c/2;let g="",x="";return u==="bottom"?(g=l?f:`${m}px`,x=`${-c}px`):u==="top"?(g=l?f:`${m}px`,x=`${r.floating.height+c}px`):u==="right"?(g=`${-c}px`,x=l?f:`${p}px`):u==="left"&&(g=`${r.floating.width+c}px`,x=l?f:`${p}px`),{data:{x:g,y:x}}}}),"transformOrigin");function Eh(e){const[t,s="center"]=e.split("-");return[t,s]}oi(Eh,"getSideAndAlignFromPlacement");var yv=AD,FC=RD,zC=ID,MD=Object.defineProperty,tn=(e,t)=>MD(e,"name",{value:t,configurable:!0}),[bv,aQ]=_s("Tooltip",[Ch]),kv=Ch(),DD="TooltipProvider",OD=700,Hp="tooltip.open",[LD,Nv]=bv(DD),_D=tn(e=>{const{__scopeTooltip:t,delayDuration:s=OD,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,l=d.useRef(!0),o=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),n.jsx(LD,{scope:t,isOpenDelayedRef:l,delayDuration:s,onOpen:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),l.current=!1)},[r]),onClose:d.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,r))},[r]),isPointerInTransitRef:o,onPointerInTransitChange:d.useCallback(u=>{o.current=u},[]),disableHoverableContent:i,children:a})},"TooltipProvider"),Kp="Tooltip",[FD,vc]=bv(Kp),zD=tn(e=>{const{__scopeTooltip:t,children:s,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:l,delayDuration:o}=e,c=Nv(Kp,e.__scopeTooltip),u=kv(t),[h,f]=d.useState(null),[m,p]=d.useState(void 0),g=$s(),x=d.useRef(0),b=l??c.disableHoverableContent,j=o??c.delayDuration,v=d.useRef(!1),[w,y]=Ni({prop:r,defaultProp:i??!1,onChange:tn(R=>{R?(c.onOpen(),document.dispatchEvent(new CustomEvent(Hp))):c.onClose(),a==null||a(R)},"onChange"),caller:Kp}),N=d.useMemo(()=>w?v.current?"delayed-open":"instant-open":"closed",[w]),k=d.useCallback(()=>{window.clearTimeout(x.current),x.current=0,v.current=!1,y(!0)},[y]),S=d.useCallback(()=>{window.clearTimeout(x.current),x.current=0,y(!1)},[y]),C=d.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{v.current=!0,y(!0),x.current=0},j)},[j,y]);d.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]);const $=m??g;return n.jsx(yv,{...u,children:n.jsx(FD,{scope:t,contentId:$,setContentId:p,open:w,stateAttribute:N,trigger:h,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():k()},[c.isOpenDelayedRef,C,k]),onTriggerLeave:d.useCallback(()=>{b?S():(window.clearTimeout(x.current),x.current=0)},[S,b]),onOpen:k,onClose:S,disableHoverableContent:b,children:s})})},"Tooltip"),db="TooltipTrigger",UD=d.forwardRef(tn(function(t,s){const{__scopeTooltip:r,...i}=t,a=vc(db,r),l=Nv(db,r),o=kv(r),c=d.useRef(null),u=jt(s,c,a.onTriggerChange),h=d.useRef(!1),f=d.useRef(!1),m=d.useCallback(()=>h.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),n.jsx(FC,{asChild:!0,...o,children:n.jsx(pt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...i,ref:u,onPointerMove:Pe(t.onPointerMove,p=>{p.pointerType!=="touch"&&!f.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),f.current=!0)}),onPointerLeave:Pe(t.onPointerLeave,()=>{a.onTriggerLeave(),f.current=!1}),onPointerDown:Pe(t.onPointerDown,()=>{a.open&&a.onClose(),h.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Pe(t.onFocus,()=>{h.current||a.onOpen()}),onBlur:Pe(t.onBlur,a.onClose),onClick:Pe(t.onClick,a.onClose)})})},"TooltipTrigger")),UC="TooltipPortal",[BD,WD]=bv(UC,{forceMount:void 0}),HD=tn(e=>{const{__scopeTooltip:t,forceMount:s,children:r,container:i}=e,a=vc(UC,t);return n.jsx(BD,{scope:t,forceMount:s,children:n.jsx(ur,{present:s||a.open,children:n.jsx(vh,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),Ho="TooltipContent",KD=d.forwardRef(tn(function(t,s){const r=WD(Ho,t.__scopeTooltip),{forceMount:i=r.forceMount,side:a="top",...l}=t,o=vc(Ho,t.__scopeTooltip);return n.jsx(ur,{present:i||o.open,children:o.disableHoverableContent?n.jsx(BC,{side:a,...l,ref:s}):n.jsx(VD,{side:a,...l,ref:s})})},"TooltipContent")),VD=d.forwardRef(tn(function(t,s){const r=vc(Ho,t.__scopeTooltip),i=Nv(Ho,t.__scopeTooltip),a=d.useRef(null),l=jt(s,a),[o,c]=d.useState(null),{trigger:u,onClose:h}=r,f=a.current,{onPointerInTransitChange:m}=i,p=d.useCallback(()=>{c(null),m(!1)},[m]),g=d.useCallback((x,b)=>{const j=x.currentTarget,v={x:x.clientX,y:x.clientY},w=WC(v,j.getBoundingClientRect()),y=HC(v,w),N=KC(b.getBoundingClientRect()),k=GC([...y,...N]);c(k),m(!0)},[m]);return d.useEffect(()=>()=>p(),[p]),d.useEffect(()=>{if(u&&f){const x=tn(j=>g(j,f),"handleTriggerLeave"),b=tn(j=>g(j,u),"handleContentLeave");return u.addEventListener("pointerleave",x),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",x),f.removeEventListener("pointerleave",b)}}},[u,f,g,p]),d.useEffect(()=>{if(o){const x=tn(b=>{const j=b.target,v={x:b.clientX,y:b.clientY},w=(u==null?void 0:u.contains(j))||(f==null?void 0:f.contains(j)),y=!VC(v,o);w?p():y&&(p(),h())},"handleTrackPointerGrace");return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[u,f,o,h,p]),n.jsx(BC,{...t,ref:l})},"TooltipContentHoverable")),GD=QS("TooltipContent"),BC=d.forwardRef(tn(function(t,s){const{__scopeTooltip:r,children:i,"aria-label":a,id:l,onEscapeKeyDown:o,onPointerDownOutside:c,...u}=t,h=vc(Ho,r),f=kv(r),{onClose:m}=h;d.useEffect(()=>(document.addEventListener(Hp,m),()=>document.removeEventListener(Hp,m)),[m]),d.useEffect(()=>{if(h.trigger){const g=tn(x=>{x.target instanceof Node&&x.target.contains(h.trigger)&&m()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[h.trigger,m]);const{setContentId:p}=h;return Ln(()=>(p(l),()=>{p(void 0)}),[l,p]),n.jsx(xh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:m,children:n.jsxs(zC,{"data-state":h.stateAttribute,role:a?void 0:"tooltip",id:a?void 0:h.contentId,...f,...u,ref:s,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[n.jsx(GD,{children:i}),a?n.jsx(U2,{id:h.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function WC(e,t){const s=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(s,r,i,a)){case a:return"left";case i:return"right";case s:return"top";case r:return"bottom";default:throw new Error("unreachable")}}tn(WC,"getExitSideFromRect");function HC(e,t,s=5){const r=[];switch(t){case"top":r.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":r.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":r.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":r.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return r}tn(HC,"getPaddedExitPoints");function KC(e){const{top:t,right:s,bottom:r,left:i}=e;return[{x:i,y:t},{x:s,y:t},{x:s,y:r},{x:i,y:r}]}tn(KC,"getPointsFromRect");function VC(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const o=t[a],c=t[l],u=o.x,h=o.y,f=c.x,m=c.y;h>r!=m>r&&s<(f-u)*(r-h)/(m-h)+u&&(i=!i)}return i}tn(VC,"isPointInPolygon");function GC(e){const t=e.slice();return t.sort((s,r)=>s.x<r.x?-1:s.x>r.x?1:s.y<r.y?-1:s.y>r.y?1:0),YC(t)}tn(GC,"getHull");function YC(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const a=t[t.length-1],l=t[t.length-2];if((a.x-l.x)*(i.y-l.y)>=(a.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const s=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;s.length>=2;){const a=s[s.length-1],l=s[s.length-2];if((a.x-l.x)*(i.y-l.y)>=(a.y-l.y)*(i.x-l.x))s.pop();else break}s.push(i)}return s.pop(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}tn(YC,"getHullPresorted");var hb=_D,Ko=zD,Vo=UD,Go=HD,Yo=KD;let Bt={time:"auto",date:"auto",locale:void 0};function Sv(e){const t=e.timeFormat===void 0?Bt.time:e.timeFormat==="12h"||e.timeFormat==="24h"?e.timeFormat:"auto",s=e.dateFormat===void 0?Bt.date:e.dateFormat==="short"||e.dateFormat==="long"||e.dateFormat==="iso"?e.dateFormat:"auto";Bt={time:t,date:s,locale:e.locale??Bt.locale}}function qC(){return{time:Bt.time,date:Bt.date}}function jc(e,t){const s=Bt;Sv(e);try{return t()}finally{Bt=s}}const Vp="buddi:formats";function wc(){if(Bt.locale)return Bt.locale;try{return typeof navigator<"u"&&navigator.language?navigator.language:"en-US"}catch{return"en-US"}}const fb=new Map;function bl(e,t){const s=`${e}|${JSON.stringify(t)}`;let r=fb.get(s);if(!r){try{r=new Intl.DateTimeFormat(e,t)}catch{r=new Intl.DateTimeFormat(e,{...t,timeZone:"UTC"})}fb.set(s,r)}return r}function Hf(e,t,s,r){return Object.fromEntries(bl(s,{timeZone:t,...r}).formatToParts(e).map(i=>[i.type,i.value]))}function YD(){return Bt.time==="12h"?{hour:"numeric",minute:"2-digit",hourCycle:"h12"}:Bt.time==="24h"?{hour:"2-digit",minute:"2-digit",hourCycle:"h23"}:{hour:Ah()?"numeric":"2-digit",minute:"2-digit"}}function qD(){return Bt.time==="auto"?wc():"en-US"}function Ht(e,t){return Number.isNaN(e.getTime())?"—":bl(qD(),{timeZone:t,...YD()}).format(e)}function QD(e){return e>=1440&&!Ah()?"24:00":Ht(new Date(Date.UTC(2026,0,1,Math.floor(e/60)%24,e%60)),"UTC")}function Ah(){var e;return Bt.time!=="auto"?Bt.time==="12h":((e=bl(wc(),{hour:"numeric"}).resolvedOptions().hourCycle)==null?void 0:e.startsWith("h1"))===!0}function QC(){return`Profile (${Ah()?"12-hour":"24-hour"})`}function XD(){if(Bt.date!=="auto")return Bt.date==="short";const e=bl(wc(),{month:"short",day:"numeric"}).formatToParts(new Date(Date.UTC(2026,9,1))).map(t=>t.type);return e.indexOf("month")<e.indexOf("day")}function dr(e,t,s={}){return JD(e,t,s).replace(/\bSept\b/g,"Sep")}function JD(e,t,s){if(Number.isNaN(e.getTime()))return"—";const{weekday:r=!1,year:i=!1,compact:a=!1}=s;switch(Bt.date){case"iso":{const l=Hf(e,t,"en-CA",{year:"numeric",month:"2-digit",day:"2-digit",...r?{weekday:a?"short":"long"}:{}}),o=`${l.year}-${l.month}-${l.day}`;return r?`${l.weekday} ${o}`:o}case"short":{const l=Hf(e,t,"en-US",{month:"short",day:"numeric",year:"numeric",weekday:"short"});return`${r?`${l.weekday}, `:""}${l.month} ${l.day}${i?`, ${l.year}`:""}`}case"long":{const l=Hf(e,t,"en-GB",{month:a?"short":"long",day:"numeric",year:"numeric",weekday:a?"short":"long"});return`${r?`${l.weekday}, `:""}${l.day} ${l.month}${i?` ${l.year}`:""}`}default:return bl(wc(),{timeZone:t,month:a?"short":"long",day:"numeric",...i?{year:"numeric"}:{},...r?{weekday:a?"short":"long"}:{}}).format(e)}}function XC(e,t){if(Bt.date==="iso")return`${e}-${String(t).padStart(2,"0")}`;const s=new Date(Date.UTC(e,t-1,15)),r=Bt.date==="auto"?wc():"en-GB";return bl(r,{timeZone:"UTC",month:"long",year:"numeric"}).format(s)}function Th(e,t={}){const s=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!s)return e;const r=new Date(`${s[0]}T12:00:00Z`);return Number.isNaN(r.getTime())?e:dr(r,"UTC",t)}function et(e,t){if(!e)return"—";const s=new Date(e);return Number.isNaN(s.getTime())?String(e):`${dr(s,t,{year:!0,compact:!0})}, ${Ht(s,t)}`}function Cv(e,t){return`${dr(e,t,{weekday:!0,compact:!0})}, ${Ht(e,t)}`}function Oe(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.round((s-t)/1e3),i=Math.abs(r),[a,l]=i<60?[r,"second"]:i<3600?[Math.round(r/60),"minute"]:i<86400?[Math.round(r/3600),"hour"]:[Math.round(r/86400),"day"];return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(a,l)}function Ev(e,t=Date.now()){if(!e)return"";const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.abs(Math.round((t-s)/1e3));return r<60?"now":r<3600?`${Math.floor(r/60)} min`:r<86400?`${Math.floor(r/3600)} h`:`${Math.floor(r/86400)} d`}function ZD(e,t=Date.now()){const s=Ev(e,t);return s===""?"":s==="now"||new Date(e).getTime()>t?"just now":s==="1 d"?"yesterday":`${s} ago`}function eO(e,t){if(e==null||!Number.isFinite(e))return"—";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:0}).format(e)}catch{return e.toFixed(2)}}function Gt(e){return new Intl.NumberFormat("en-US").format(e)}function Gp(e){return[...e.cacheRead?[`cached ${Gt(e.cacheRead)}`]:[],...e.cacheWrite?[`cache write ${Gt(e.cacheWrite)}`]:[]].join(", ")}function tO(e){const t=Gp(e);return`${Gt(e.input)} in${t?` (${t})`:""} / ${Gt(e.output)} out`}function Xn(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function qo(e,t=8){return e.length<=t?e:e.slice(0,t)}function Ds(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Qo(e){if(e.kind!=="agent")return e.title;const t=e.title.replace(/^@[^\s:]+:\s+/,"");return t.trim()===""?e.title:t}const mb="buddi_csrf",kl="x-buddi-csrf",Xo="buddi:agents-changed",Bi="buddi:status-changed",ql=e=>(window.dispatchEvent(new Event(Bi)),e),Yp="buddi:locked",nO="This page's sign-in no longer matches its cookies. Reload the page and try again.";class me extends Error{constructor(t,s,r){super(s),this.status=t,this.detail=r,this.name="ApiError"}}function ia(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${mb}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const s=[...document.cookie.matchAll(new RegExp(`(?:^|; )${mb}(?:_\\d+)?=([^;]*)`,"g"))];return s.length===1&&((r=s[0])!=null&&r[1])?decodeURIComponent(s[0][1]):""}const Td="buddi isn't answering.";let qp=null;const Qp=new Set;function Ql(e){if(e!==(qp===null)){qp=e?null:Date.now();for(const t of Qp)t()}}function Jo(){return qp}function Av(e){return Qp.add(e),()=>Qp.delete(e)}function Rd(e){return e instanceof me&&(e.status===0||e.status===502||e.status===503)&&e.message===Td}async function aa(e,t={}){var l;let s;try{s=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}})}catch(o){throw(o==null?void 0:o.name)==="AbortError"||(l=t.signal)!=null&&l.aborted?o:(Ql(!1),new me(0,Td,o))}if(s.status===401)throw Ql(!0),new me(401,"This session has expired. Run `buddi dashboard` for a fresh link.");if(s.status===423)throw Ql(!0),window.dispatchEvent(new Event(Yp)),new me(423,"This dashboard is locked.");const r=await s.text(),i=r===""?null:sO(r),a=i&&typeof i=="object"&&"error"in i?String(i.error):void 0;if((s.status===502||s.status===503)&&a===void 0)throw Ql(!1),new me(s.status,Td,i);if(Ql(!0),!s.ok){const o=(t.method??"GET").toUpperCase(),c=a??(s.status===403&&o!=="GET"&&o!=="HEAD"?nO:`request failed (${s.status})`);throw new me(s.status,c,i)}return i}function sO(e){try{return JSON.parse(e)}catch{return null}}function Kf(){return qC().time==="auto"?{hour:Ah()?"12":"24"}:{}}function ge(e,t={}){const s=new URLSearchParams;for(const[i,a]of Object.entries(t))a!==void 0&&a!==""&&s.set(i,String(a));const r=s.toString();return aa(`/api${e}${r?`?${r}`:""}`)}function Xp(e,t){return aa(`/api${e}`,{method:"POST",headers:{[kl]:ia()},body:t})}function jr(e){return aa(`/api${e}`,{method:"DELETE",headers:{[kl]:ia()}})}function ne(e,t={}){return aa(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[kl]:ia()},body:JSON.stringify(t??{})})}function JC(e,t,s,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||s;return aa(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[kl]:ia(),"X-Filename":i,...r},body:t})}function pb(e,t,s){return JC(e,t,"backup.tar.gz",{...s.passphrase?{"X-Backup-Passphrase":s.passphrase}:{},...s.confirm?{"X-Backup-Confirm":s.confirm}:{}})}function rO(e,t={}){return aa(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[kl]:ia()},body:JSON.stringify(t??{})})}function Gs(e,t={}){return aa(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[kl]:ia()},body:JSON.stringify(t??{})})}function iO(e){if(e.dismissedAt)return"You said no to this one.";switch(e.lapseReason){case"owner-moved-on":return"The conversation moved on.";case"rolled-over":return"That conversation ended.";case"agent-removed":return"That agent is no longer here.";default:return"It lapsed."}}const Hu="gpt-oss:120b",aO=["approval","question","watcher","reminder","failure","recap","plugin","agent"],Jp=["mon","tue","wed","thu","fri","sat","sun"],Be={agents:()=>ge("/chat/agents"),views:()=>ge("/chat/views"),conversations:(e,t)=>ge(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>ne(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>ge(`/chat/conversations/${encodeURIComponent(e)}`),deleteCarryOver:e=>jr(`/chat/conversations/${encodeURIComponent(e)}/carry-over`),send:(e,t)=>ne(`/chat/${encodeURIComponent(e)}/messages`,t),answerQuestion:(e,t)=>ne(`/chat/questions/${encodeURIComponent(e)}/answer`,t),cancel:e=>ne(`/chat/conversations/${encodeURIComponent(e)}/cancel`),attach:e=>{const t=new FormData;return t.append("file",e,e.name),Xp("/chat/attachments",t)},transcribe:e=>ne("/speech/transcribe",e),say:e=>ne("/speech/say",e),discardAttachment:e=>jr(`/artifacts/${encodeURIComponent(e)}`),groups:()=>ge("/groups"),group:e=>ge(`/groups/${encodeURIComponent(e)}`),createGroup:e=>ne("/groups",e),updateGroup:(e,t)=>rO(`/groups/${encodeURIComponent(e)}`,t),deleteGroup:e=>jr(`/groups/${encodeURIComponent(e)}`),restoreGroup:e=>ne(`/groups/${encodeURIComponent(e)}/restore`),clearGroup:e=>ne(`/groups/${encodeURIComponent(e)}/clear`),groupConversations:e=>ge(`/groups/${encodeURIComponent(e)}/conversations`),startGroupConversation:e=>ne(`/groups/${encodeURIComponent(e)}/conversations`),sendToGroup:(e,t)=>ne(`/groups/${encodeURIComponent(e)}/messages`,t),streamUrl:e=>`/api/chat/conversations/${encodeURIComponent(e)}/stream`};function Tv(e){return e.httpStatus===401||e.httpStatus===403||e.state==="authentication-error"||e.state==="access-denied"}const E={providers:()=>ge("/providers"),providerAccounts:()=>ge("/provider-accounts"),probeModels:e=>ne("/provider-accounts/probe-models",e),accountModels:(e,t=!1)=>ne(`/provider-accounts/${encodeURIComponent(e)}/models`,{refresh:t}),saveProviderAccount:e=>ne("/provider-accounts/save",e),testProviderAccount:e=>ne(`/provider-accounts/${encodeURIComponent(e)}/test`),removeProviderAccount:(e,t)=>ne(`/provider-accounts/${encodeURIComponent(e)}/remove`,{revision:t}),codexAccountAction:(e,t,s)=>ne(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:s}),ollamaConnect:(e,t)=>ne(`/provider-accounts/${encodeURIComponent(e)}/ollama/connect`,{revision:t}),ollamaPoll:(e,t)=>ne(`/provider-accounts/${encodeURIComponent(e)}/ollama/poll`,{attemptId:t}),ollamaDisconnect:(e,t)=>ne(`/provider-accounts/${encodeURIComponent(e)}/ollama/disconnect`,{revision:t}),anthropicAccountAction:(e,t,s,r)=>ne(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:s,...r}),assignProviderAccount:(e,t,s)=>ne(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:s}),configureProvider:(e,t)=>ne(`/providers/${encodeURIComponent(e)}/settings`,t),saveCredential:(e,t)=>ne(`/providers/credentials/${encodeURIComponent(e)}/save`,{value:t}),removeCredential:e=>ne(`/providers/credentials/${encodeURIComponent(e)}/remove`),testProvider:e=>ne(`/providers/${encodeURIComponent(e)}/test`),browserProfiles:e=>ge("/host/browser-profiles",{app:e}),installedApps:()=>ge("/host/apps"),browser:e=>ge(`/browser${e?`?agentId=${encodeURIComponent(e.agentId)}&conversationId=${encodeURIComponent(e.conversationId)}`:""}`),browserControl:(e,t)=>ne(`/browser/${e}`,t===void 0?{}:{sessionId:t}),browserSettings:e=>ne("/browser/settings",e),computerPermissions:(e=!1)=>ne("/browser/permissions",{prompt:e}),browserInstall:()=>ne("/browser/install",{}),browserCheck:()=>ne("/browser/check",{}),previewLink:(e,t)=>ge(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>ge(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>ge("/extension"),pairExtension:e=>ne("/extension/pair",{code:e}),forgetExtension:()=>jr("/extension/pair"),session:()=>ge("/session"),overview:()=>ge("/overview"),events:e=>ge("/events",e),eventKinds:()=>ge("/events/kinds"),conversations:()=>ge("/conversations"),conversation:e=>ge(`/conversations/${encodeURIComponent(e)}`),missions:()=>ge("/missions"),jobs:(e={})=>ge("/jobs",e),approvals:()=>ge("/approvals"),approval:e=>ge(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>ge("/offers"),dismissOffer:e=>ne(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>ne("/offers/dismiss-all",{ids:e}),agentOffers:()=>ge("/agent-offers"),teammates:()=>ge("/teammates"),dismissAgentOffer:(e,t)=>ne(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>ge("/proposals"),setDigestSchedule:(e,t)=>ne("/proposals/digest-schedule",{day:e,hour:t}),keepProposal:(e,t)=>ne(`/proposals/${encodeURIComponent(e)}/keep`,t===void 0?{}:{text:t}),keepAllProposals:e=>ne("/proposals/keep-all",{ids:e}),discardProposal:(e,t)=>ne(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>ge("/reminders"),sentinels:()=>ge("/sentinels"),setSentinelEnabled:(e,t)=>ne(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),widgets:(e="home")=>ge("/widgets",{...e==="lock"?{surface:e}:{},...Kf()}),saveWidgets:(e,t)=>Gs(`/widgets/${e}`,{placements:t.map(({key:s,widget:r,size:i,settings:a})=>({...s?{key:s}:{},widget:r,size:i,settings:a}))}),widgetSettings:e=>ge(`/widgets/settings/${encodeURIComponent(e)}`),previewWidget:e=>ne("/widgets/preview",{...e,...Kf()}),refreshWidget:(e,t="home")=>ne(`/widgets/${encodeURIComponent(e)}/refresh${t==="lock"?"?surface=lock":""}`),setGlanceHidden:(e,t)=>ne(`/home/glances/${encodeURIComponent(e)}/hidden`,{hidden:t}),rail:()=>ge("/rail"),setRailHidden:(e,t,s)=>ne(`/rail/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}/hidden`,{hidden:s}),snoozeAlerts:(e,t,s)=>ne("/alerts/snooze",{keys:e,snoozed:t,...s!==void 0?{days:s}:{}}),muteAlert:(e,t)=>ne("/alerts/mute",{key:e,scope:t}),unmuteAlert:e=>ne(`/alerts/mutes/${encodeURIComponent(e)}/remove`,{}),actOnAlerts:e=>ne("/alerts/act",{entries:e}),askAboutAlerts:e=>ne("/alerts/ask",{keys:e}),agents:()=>ge("/agents"),library:e=>ge("/artifacts",e),libraryEntry:(e,t=0)=>ge(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>ge("/onboarding"),onboardingStep:(e,t={})=>ne("/onboarding/step",{step:e,...t}),takeOn:e=>ne("/onboarding/take-on",{tiles:e}),takeOnProgress:()=>ge("/onboarding/take-on"),completeOnboarding:()=>ne("/onboarding/complete"),skipOnboarding:()=>ne("/onboarding/skip"),createFirstAgent:e=>ne("/onboarding/agent",e),ollama:()=>ge("/onboarding/ollama"),mlxh:()=>ge("/onboarding/mlxh"),firstAgentPersona:()=>ge("/onboarding/agent"),updateFirstAgent:e=>ne("/onboarding/agent/update",e),bindBrain:e=>ne("/onboarding/brain",e),pages:()=>ge("/pages"),pageQuery:(e,t,s={})=>ge(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,s),pageFileUrl:(e,t,s={})=>{const r=new URLSearchParams(Object.entries(s).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>ne(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>ge("/telegram"),saveTelegramToken:e=>ne("/telegram/token",{token:e}),telegramPairing:()=>ne("/telegram/pairing"),telegramBot:()=>ge("/telegram/bot"),telegramDevices:()=>ge("/telegram/devices"),unpairTelegramDevice:e=>jr(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>ge("/notifications",{limit:e}),notificationSeen:e=>ne(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>ge("/notifications/settings"),saveNotificationSettings:e=>Gs("/notifications/settings",e),focus:()=>ge("/notifications/focus"),lockState:()=>ge("/lock"),lockScreen:()=>ge("/lock/screen",Kf()),lockNow:(e="owner")=>ne("/lock",{reason:e}),unlock:e=>ne("/lock/unlock",{pin:e}),lockActivity:()=>ne("/lock/activity"),setPin:(e,t)=>Gs("/lock/pin",t===void 0?{pin:e}:{pin:e,current:t}),removePin:e=>ne("/lock/pin/remove",{current:e}),setLockSettings:e=>Gs("/lock/settings",e),uploadLockBackground:e=>{const t=new FormData;return t.append("file",e),Xp("/lock/background",t)},removeLockBackground:()=>jr("/lock/background"),setFocus:(e,t)=>Gs("/notifications/focus",t?{mode:e,duration:t}:{mode:e}).then(ql),testChannel:e=>ne("/notifications/test",{channel:e}),setAgentMuted:(e,t)=>ne("/notifications/agent-mute",{agentId:e,muted:t}),currentTip:e=>ge(e?`/tips/current?preview=${encodeURIComponent(e)}`:"/tips/current"),tips:()=>ge("/tips"),restoreTip:e=>ne(`/tips/${encodeURIComponent(e)}/restore`),dismissTip:e=>ne(`/tips/${encodeURIComponent(e)}/dismiss`),laterTip:e=>ne(`/tips/${encodeURIComponent(e)}/later`),tipsSeenPage:e=>ne("/tips/seen-page",{page:e}),tipsSettings:()=>ge("/tips/settings"),saveTipsSettings:e=>Gs("/tips/settings",{enabled:e}),presence:e=>ne("/presence",{state:e}),owner:()=>ge("/owner"),setOwner:e=>ne("/owner",e),findPlace:e=>ne("/owner/places/find",{address:e}),savePlace:e=>ne("/owner/places",e),removePlace:e=>ne("/owner/places/remove",{id:e}),memory:e=>ge(e?`/memory?agent=${encodeURIComponent(e)}`:"/memory"),setPreference:e=>ne("/memory/preferences",e),forgetPreference:e=>ne("/memory/preferences/forget",e),updateNote:(e,t)=>ne(`/memory/notes/${encodeURIComponent(e)}`,t),forgetNote:e=>ne(`/memory/notes/${encodeURIComponent(e)}/forget`),setDelegates:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/delegates`,{delegates:t}),agentProfile:e=>ge(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>ge(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>ge("/host",{agentId:e,conversationId:t}),connections:()=>ge("/connections"),connection:e=>ge(`/connections/${e}`),addConnection:(e,t)=>ne("/connections",{url:e,...t?{name:t}:{}}),addProgram:e=>ne("/connections",{transport:"stdio",...e}),updateProgram:(e,t)=>ne(`/connections/${e}/program`,t),connectionConsent:(e,t)=>ne(`/connections/${e}/consent`,t?{clientId:t}:{}),connectionToken:(e,t)=>ne(`/connections/${e}/token`,t),connectionDevice:e=>ne(`/connections/${e}/device`,{}),connectionCallback:e=>ne("/connections/callback",e),connectionReview:e=>ge(`/connections/${e}/review`),saveConnectionReview:(e,t)=>ne(`/connections/${e}/review`,t),grantConnection:(e,t,s=!1)=>ne(`/connections/${e}/grant`,s?{agents:t,exact:!0}:{agents:t}),setConnectionHolder:(e,t,s)=>ne(`/connections/${e}/holders/${encodeURIComponent(t)}`,{held:s}),disconnect:e=>jr(`/connections/${e}`),connectionSignals:()=>ge("/connections/signals"),connectionTools:e=>ge(`/connections/${e}/tools`),rememberedApprovals:e=>ge(`/connections/remembered/${encodeURIComponent(e)}`),setRememberedApproval:(e,t,s)=>ne("/connections/remembered",{agent:e,tool:t,remember:s}),secrets:()=>ge("/secrets"),secretUses:(e,t)=>ge("/secrets/uses",{name:e,limit:t}),secretsAct:(e,t)=>ne("/secrets/act",{tool:e,args:t}),stopHost:(e,t)=>ne("/host/stop",{agentId:e,conversationId:t}),revokeHost:e=>ne("/host/revoke",{id:e}),decide:(e,t,s,r)=>ne(`/approvals/${encodeURIComponent(e)}/${t}`,s||r?{...s?{permissionScope:s}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>ne("/pause",{paused:e}).then(ql),service:()=>ge("/service"),serviceAction:e=>ne(`/service/${e}`),version:()=>ge("/version"),checkVersion:()=>ne("/version/check"),setVersionCheck:e=>Gs("/version/check",{enabled:e}),tailscale:()=>ge("/tailscale"),setTailscale:e=>Gs("/tailscale",e),apiTokens:()=>ge("/api-tokens"),createApiToken:e=>ne("/api-tokens",{name:e}),revokeApiToken:e=>jr(`/api-tokens/${encodeURIComponent(e)}`),startUpgrade:e=>ne("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>ge(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>ge("/backups"),startBackup:e=>ne("/backups",{encrypt:e}),verifyArchive:e=>ne("/backups/verify",{name:e}),restoreArchive:e=>ne("/backups/restore",e),restoreUpload:(e,t)=>pb("/backups/restore",e,t),backupJob:e=>ge(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>ge("/backups/schedule"),setBackupSchedule:e=>Gs("/backups/schedule",e),backupPassphrase:()=>ge("/backups/passphrase"),setBackupPassphrase:e=>Gs("/backups/passphrase",{passphrase:e}),plugins:()=>ge("/plugins"),market:(e=!1)=>ge(`/market${e?"?refresh=1":""}`),marketAssetUrl:e=>`/api/market/asset?url=${encodeURIComponent(e)}`,pluginFolders:e=>ge("/plugins/folders",e?{path:e}:{}),stagePlugin:e=>ne("/plugins/stage",{spec:e}),uploadPlugin:e=>JC("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>ge(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>ne(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>ne(`/plugins/staged/${encodeURIComponent(e)}/reject`),openedStaged:e=>ne(`/plugins/staged/${encodeURIComponent(e)}/opened`),updatePlugin:(e,t,s)=>ne(`/plugins/${encodeURIComponent(e)}/update`,{...t?{version:t}:{},...s?{from:s}:{}}),setPluginEnabled:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/${t?"enable":"disable"}`,{}),uninstallPlugin:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>ge("/recovery"),leaveRecovery:e=>ne("/recovery/leave",e),firstRunRestore:(e,t)=>pb("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>ne(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,s)=>ne(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...s===void 0?{}:{deadlineMinutes:s}}),retryJob:e=>ne(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>ne(`/jobs/${encodeURIComponent(e)}/cancel`),jobFailures:()=>ge("/jobs/failures"),dismissJobs:e=>ne("/jobs/dismiss",e).then(ql),undismissJobs:e=>ne("/jobs/undismiss",{ids:e}).then(ql),retryJobs:e=>ne("/jobs/retry",e).then(ql),setDefaultAgent:e=>ne("/agents/default",{agentId:e}),agentTools:e=>ge(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>ge(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const s=new FormData;return s.append("file",t,t.name),Xp(`/agents/${encodeURIComponent(e)}/avatar`,s)},removeAgentPicture:e=>jr(`/agents/${encodeURIComponent(e)}/avatar`),updateAgentFile:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/file`,t),setAgentEngine:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/engine`,t),takeOffer:(e,t)=>ne(`/offers/${encodeURIComponent(e)}/take`,t?{conversationId:t}:{}),cancelReminder:e=>ne(`/reminders/${encodeURIComponent(e)}/cancel`,{reason:"cancelled from the dashboard"})};function ZC(e){return e==="anthropic"||e==="openai"}function e1(e,t){var i,a;if(!e)return null;const s=e.credentialEnv&&(t!=null&&t.accounts.some(l=>l.id===e.credentialEnv))?e.credentialEnv:(a=(i=t==null?void 0:t.bindings)==null?void 0:i.find(l=>l.agentId===e.id))==null?void 0:a.accountId,r=s?t==null?void 0:t.accounts.find(l=>l.id===s):void 0;return(r==null?void 0:r.kind)??e.provider}const lO="Thinking is up to this model. What it writes while thinking is shown apart and kept out of the answer.";var oO=Object.defineProperty,cO=(e,t)=>oO(e,"name",{value:t,configurable:!0}),uO=d.createContext(void 0);function Rh(e){const t=d.useContext(uO);return e||t||"ltr"}cO(Rh,"useDirection");var dO=Object.defineProperty,Rv=(e,t)=>dO(e,"name",{value:t,configurable:!0}),iu=0,Ys=null;function hO(e){return $h(),e.children}Rv(hO,"FocusGuards");function $h(){d.useEffect(()=>{Ys||(Ys={start:Zp(),end:Zp()});const{start:e,end:t}=Ys;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),iu++,()=>{iu===1&&(Ys==null||Ys.start.remove(),Ys==null||Ys.end.remove(),Ys=null),iu=Math.max(0,iu-1)}},[])}Rv($h,"useFocusGuards");function Zp(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Rv(Zp,"createFocusGuard");var fO=Object.defineProperty,kn=(e,t)=>fO(e,"name",{value:t,configurable:!0}),Vf="focusScope.autoFocusOnMount",Gf="focusScope.autoFocusOnUnmount",gb={bubbles:!1,cancelable:!0},t1=d.forwardRef(kn(function(t,s){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...o}=t,[c,u]=d.useState(null),h=Sn(a),f=Sn(l),m=d.useRef(null),p=jt(s,u),g=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(y){if(g.paused||!c)return;const N=y.target;c.contains(N)?m.current=N:xr(m.current,{select:!0})},j=function(y){if(g.paused||!c)return;const N=y.relatedTarget;N!==null&&(c.contains(N)||xr(m.current,{select:!0}))},v=function(y){if(document.activeElement===document.body)for(const k of y)k.removedNodes.length>0&&xr(c)};kn(b,"handleFocusIn"),kn(j,"handleFocusOut"),kn(v,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",j);const w=new MutationObserver(v);return c&&w.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",j),w.disconnect()}}},[i,c,g.paused]),d.useEffect(()=>{if(c){xb.add(g);const b=document.activeElement;if(!c.contains(b)){const v=new CustomEvent(Vf,gb);c.addEventListener(Vf,h),c.dispatchEvent(v),v.defaultPrevented||(n1(l1($v(c)),{select:!0}),document.activeElement===b&&xr(c))}return()=>{c.removeEventListener(Vf,h),setTimeout(()=>{const v=new CustomEvent(Gf,gb);c.addEventListener(Gf,f),c.dispatchEvent(v),v.defaultPrevented||xr(b??document.body,{select:!0}),c.removeEventListener(Gf,f),xb.remove(g)},0)}}},[c,h,f,g]);const x=d.useCallback(b=>{if(!r&&!i||g.paused)return;const j=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,v=document.activeElement;if(j&&v){const w=b.currentTarget,[y,N]=s1(w);y&&N?!b.shiftKey&&v===N?(b.preventDefault(),r&&xr(y,{select:!0})):b.shiftKey&&v===y&&(b.preventDefault(),r&&xr(N,{select:!0})):v===w&&b.preventDefault()}},[r,i,g.paused]);return n.jsx(pt.div,{tabIndex:-1,...o,ref:p,onKeyDown:x})},"FocusScope"));function n1(e,{select:t=!1}={}){const s=document.activeElement;for(const r of e)if(xr(r,{select:t}),document.activeElement!==s)return}kn(n1,"focusFirst");function s1(e){const t=$v(e),s=eg(t,e),r=eg(t.reverse(),e);return[s,r]}kn(s1,"getTabbableEdges");function $v(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:kn(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;s.nextNode();)t.push(s.currentNode);return t}kn($v,"getTabbableCandidates");function eg(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(s?!r.checkVisibility({checkVisibilityCSS:!0}):r1(r,{upTo:t})))return r}kn(eg,"findVisible");function r1(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}kn(r1,"isHidden");function i1(e){return e instanceof HTMLInputElement&&"select"in e}kn(i1,"isSelectableInput");function xr(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&i1(e)&&t&&e.select()}}kn(xr,"focus");var xb=a1();function a1(){let e=[];return{add(t){const s=e[0];t!==s&&(s==null||s.pause()),e=tg(e,t),e.unshift(t)},remove(t){var s;e=tg(e,t),(s=e[0])==null||s.resume()}}}kn(a1,"createFocusScopesStack");function tg(e,t){const s=[...e],r=s.indexOf(t);return r!==-1&&s.splice(r,1),s}kn(tg,"arrayRemove");function l1(e){return e.filter(t=>t.tagName!=="A")}kn(l1,"removeLinks");var mO=Object.defineProperty,Iv=(e,t)=>mO(e,"name",{value:t,configurable:!0}),Yf=!1;function o1(){const[e,t]=d.useState(Yf);return d.useEffect(()=>{Yf||(Yf=!0,t(!0))},[]),e}Iv(o1,"useIsHydrated");var c1=pl[" useSyncExternalStore ".trim().toString()];function u1(){return()=>{}}Iv(u1,"subscribe");function d1(){return c1(u1,()=>!0,()=>!1)}Iv(d1,"useIsHydratedModern");var pO=typeof c1=="function"?d1:o1,gO=Object.defineProperty,la=(e,t)=>gO(e,"name",{value:t,configurable:!0}),qf="rovingFocusGroup.onEntryFocus",xO={bubbles:!1,cancelable:!0},Ih="RovingFocusGroup",[ng,h1,vO]=ph(Ih),[jO,Ph]=_s(Ih,[vO]),[wO,yO]=jO(Ih),bO=d.forwardRef(la(function(t,s){return n.jsx(ng.Provider,{scope:t.__scopeRovingFocusGroup,children:n.jsx(ng.Slot,{scope:t.__scopeRovingFocusGroup,children:n.jsx(kO,{...t,ref:s})})})},"RovingFocusGroup")),kO=d.forwardRef(la(function(t,s){const{__scopeRovingFocusGroup:r,orientation:i,loop:a=!1,dir:l,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,p=d.useRef(null),g=jt(s,p),x=Rh(l),[b,j]=Ni({prop:o,defaultProp:c??null,onChange:u,caller:Ih}),[v,w]=d.useState(!1),y=Sn(h),N=h1(r),k=d.useRef(!1),[S,C]=d.useState(0);return d.useEffect(()=>{const $=p.current;if($)return $.addEventListener(qf,y),()=>$.removeEventListener(qf,y)},[y]),n.jsx(wO,{scope:r,orientation:i,dir:x,loop:a,currentTabStopId:b,onItemFocus:d.useCallback($=>j($),[j]),onItemShiftTab:d.useCallback(()=>w(!0),[]),onFocusableItemAdd:d.useCallback(()=>C($=>$+1),[]),onFocusableItemRemove:d.useCallback(()=>C($=>$-1),[]),children:n.jsx(pt.div,{tabIndex:v||S===0?-1:0,"data-orientation":i,...m,ref:g,style:{outline:"none",...t.style},onMouseDown:Pe(t.onMouseDown,()=>{k.current=!0}),onFocus:Pe(t.onFocus,$=>{const R=!k.current;if($.target===$.currentTarget&&R&&!v){const I=new CustomEvent(qf,xO);if($.currentTarget.dispatchEvent(I),!I.defaultPrevented){const z=N().filter(O=>O.focusable),U=z.find(O=>O.active),A=z.find(O=>O.id===b),D=[U,A,...z].filter(Boolean).map(O=>O.ref.current);Pv(D,f)}}k.current=!1}),onBlur:Pe(t.onBlur,()=>w(!1))})})},"RovingFocusGroupImpl")),NO="RovingFocusGroupItem",SO=d.forwardRef(la(function(t,s){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:a=!1,tabStopId:l,children:o,...c}=t,u=$s(),h=l||u,f=yO(NO,r),m=f.currentTabStopId===h,p=h1(r),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:b}=f,j=pO();return Ln(()=>{if(!(!j||!i))return g(),()=>x()},[j,i,g,x]),d.useEffect(()=>{if(!(j||!i))return g(),()=>x()},[j,i,g,x]),n.jsx(ng.ItemSlot,{scope:r,id:h,focusable:i,active:a,children:n.jsx(pt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:s,onMouseDown:Pe(t.onMouseDown,v=>{i?f.onItemFocus(h):v.preventDefault()}),onFocus:Pe(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:Pe(t.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const w=m1(v,f.orientation,f.dir);if(w!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let N=p().filter(k=>k.focusable).map(k=>k.ref.current);if(w==="last")N.reverse();else if(w==="prev"||w==="next"){w==="prev"&&N.reverse();const k=N.indexOf(v.currentTarget);N=f.loop?p1(N,k+1):N.slice(k+1)}setTimeout(()=>Pv(N))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:b!=null}):o})})},"RovingFocusGroupItem")),CO={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function f1(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}la(f1,"getDirectionAwareKey");function m1(e,t,s){const r=f1(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return CO[r]}la(m1,"getFocusIntent");function Pv(e,t=!1){const s=document.activeElement;for(const r of e)if(r===s||(r.focus({preventScroll:t}),document.activeElement!==s))return}la(Pv,"focusFirst");function p1(e,t){return e.map((s,r)=>e[(t+r)%e.length])}la(p1,"wrapArray");var g1=bO,x1=SO,EO=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},xa=new WeakMap,au=new WeakMap,lu={},Qf=0,v1=function(e){return e&&(e.host||v1(e.parentNode))},AO=function(e,t){return t.map(function(s){if(e.contains(s))return s;var r=v1(s);return r&&e.contains(r)?r:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},TO=function(e,t,s,r){var i=AO(t,Array.isArray(e)?e:[e]);lu[s]||(lu[s]=new WeakMap);var a=lu[s],l=[],o=new Set,c=new Set(i),u=function(f){!f||o.has(f)||(o.add(f),u(f.parentNode))};i.forEach(u);var h=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(m){if(o.has(m))h(m);else try{var p=m.getAttribute(r),g=p!==null&&p!=="false",x=(xa.get(m)||0)+1,b=(a.get(m)||0)+1;xa.set(m,x),a.set(m,b),l.push(m),x===1&&g&&au.set(m,!0),b===1&&m.setAttribute(s,"true"),g||m.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",m,j)}})};return h(t),o.clear(),Qf++,function(){l.forEach(function(f){var m=xa.get(f)-1,p=a.get(f)-1;xa.set(f,m),a.set(f,p),m||(au.has(f)||f.removeAttribute(r),au.delete(f)),p||f.removeAttribute(s)}),Qf--,Qf||(xa=new WeakMap,xa=new WeakMap,au=new WeakMap,lu={})}},j1=function(e,t,s){s===void 0&&(s="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=EO(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),TO(r,i,s,"aria-hidden")):function(){return null}},Zs=function(){return Zs=Object.assign||function(t){for(var s,r=1,i=arguments.length;r<i;r++){s=arguments[r];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(t[a]=s[a])}return t},Zs.apply(this,arguments)};function w1(e,t){var s={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(s[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(s[r[i]]=e[r[i]]);return s}function RO(e,t,s){if(s||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Ku="right-scroll-bar-position",Vu="width-before-scroll-bar",$O="with-scroll-bars-hidden",IO="--removed-body-scroll-bar-size";function Xf(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function PO(e,t){var s=d.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(r){var i=s.value;i!==r&&(s.value=r,s.callback(r,i))}}}})[0];return s.callback=t,s.facade}var MO=typeof window<"u"?d.useLayoutEffect:d.useEffect,vb=new WeakMap;function DO(e,t){var s=PO(null,function(r){return e.forEach(function(i){return Xf(i,r)})});return MO(function(){var r=vb.get(s);if(r){var i=new Set(r),a=new Set(e),l=s.current;i.forEach(function(o){a.has(o)||Xf(o,null)}),a.forEach(function(o){i.has(o)||Xf(o,l)})}vb.set(s,e)},[e]),s}function OO(e){return e}function LO(e,t){t===void 0&&(t=OO);var s=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var l=t(a,r);return s.push(l),function(){s=s.filter(function(o){return o!==l})}},assignSyncMedium:function(a){for(r=!0;s.length;){var l=s;s=[],l.forEach(a)}s={push:function(o){return a(o)},filter:function(){return s}}},assignMedium:function(a){r=!0;var l=[];if(s.length){var o=s;s=[],o.forEach(a),l=s}var c=function(){var h=l;l=[],h.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),s={push:function(h){l.push(h),u()},filter:function(h){return l=l.filter(h),s}}}};return i}function _O(e){e===void 0&&(e={});var t=LO(null);return t.options=Zs({async:!0,ssr:!1},e),t}var y1=function(e){var t=e.sideCar,s=w1(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return d.createElement(r,Zs({},s))};y1.isSideCarExport=!0;function FO(e,t){return e.useMedium(t),y1}var b1=_O(),Jf=function(){},Mh=d.forwardRef(function(e,t){var s=d.useRef(null),r=d.useState({onScrollCapture:Jf,onWheelCapture:Jf,onTouchMoveCapture:Jf}),i=r[0],a=r[1],l=e.forwardProps,o=e.children,c=e.className,u=e.removeScrollBar,h=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,g=e.noIsolation,x=e.inert,b=e.allowPinchZoom,j=e.as,v=j===void 0?"div":j,w=e.gapMode,y=w1(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=m,k=DO([s,t]),S=Zs(Zs({},y),i);return d.createElement(d.Fragment,null,h&&d.createElement(N,{sideCar:b1,removeScrollBar:u,shards:f,noRelative:p,noIsolation:g,inert:x,setCallbacks:a,allowPinchZoom:!!b,lockRef:s,gapMode:w}),l?d.cloneElement(d.Children.only(o),Zs(Zs({},S),{ref:k})):d.createElement(v,Zs({},S,{className:c,ref:k}),o))});Mh.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Mh.classNames={fullWidth:Vu,zeroRight:Ku};var zO=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function UO(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=zO();return t&&e.setAttribute("nonce",t),e}function BO(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function WO(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var HO=function(){var e=0,t=null;return{add:function(s){e==0&&(t=UO())&&(BO(t,s),WO(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},KO=function(){var e=HO();return function(t,s){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},k1=function(){var e=KO(),t=function(s){var r=s.styles,i=s.dynamic;return e(r,i),null};return t},VO={left:0,top:0,right:0,gap:0},Zf=function(e){return parseInt(e||"",10)||0},GO=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Zf(s),Zf(r),Zf(i)]},YO=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return VO;var t=GO(e),s=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-s+t[2]-t[0])}},qO=k1(),Va="data-scroll-locked",QO=function(e,t,s,r){var i=e.left,a=e.top,l=e.right,o=e.gap;return s===void 0&&(s="margin"),`
|
|
41
|
+
.`.concat($O,` {
|
|
42
|
+
overflow: hidden `).concat(r,`;
|
|
43
|
+
padding-right: `).concat(o,"px ").concat(r,`;
|
|
44
|
+
}
|
|
45
|
+
body[`).concat(Va,`] {
|
|
46
|
+
overflow: hidden `).concat(r,`;
|
|
47
|
+
overscroll-behavior: contain;
|
|
48
|
+
`).concat([t&&"position: relative ".concat(r,";"),s==="margin"&&`
|
|
49
|
+
padding-left: `.concat(i,`px;
|
|
50
|
+
padding-top: `).concat(a,`px;
|
|
51
|
+
padding-right: `).concat(l,`px;
|
|
52
|
+
margin-left:0;
|
|
53
|
+
margin-top:0;
|
|
54
|
+
margin-right: `).concat(o,"px ").concat(r,`;
|
|
55
|
+
`),s==="padding"&&"padding-right: ".concat(o,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.`).concat(Ku,` {
|
|
59
|
+
right: `).concat(o,"px ").concat(r,`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.`).concat(Vu,` {
|
|
63
|
+
margin-right: `).concat(o,"px ").concat(r,`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.`).concat(Ku," .").concat(Ku,` {
|
|
67
|
+
right: 0 `).concat(r,`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.`).concat(Vu," .").concat(Vu,` {
|
|
71
|
+
margin-right: 0 `).concat(r,`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
body[`).concat(Va,`] {
|
|
75
|
+
`).concat(IO,": ").concat(o,`px;
|
|
76
|
+
}
|
|
77
|
+
`)},jb=function(){var e=parseInt(document.body.getAttribute(Va)||"0",10);return isFinite(e)?e:0},XO=function(){d.useEffect(function(){return document.body.setAttribute(Va,(jb()+1).toString()),function(){var e=jb()-1;e<=0?document.body.removeAttribute(Va):document.body.setAttribute(Va,e.toString())}},[])},JO=function(e){var t=e.noRelative,s=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;XO();var a=d.useMemo(function(){return YO(i)},[i]);return d.createElement(qO,{styles:QO(a,!t,i,s?"":"!important")})},sg=!1;if(typeof window<"u")try{var ou=Object.defineProperty({},"passive",{get:function(){return sg=!0,!0}});window.addEventListener("test",ou,ou),window.removeEventListener("test",ou,ou)}catch{sg=!1}var va=sg?{passive:!1}:!1,ZO=function(e){return e.tagName==="TEXTAREA"},N1=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!ZO(e)&&s[t]==="visible")},eL=function(e){return N1(e,"overflowY")},tL=function(e){return N1(e,"overflowX")},wb=function(e,t){var s=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=S1(e,r);if(i){var a=C1(e,r),l=a[1],o=a[2];if(l>o)return!0}r=r.parentNode}while(r&&r!==s.body);return!1},nL=function(e){var t=e.scrollTop,s=e.scrollHeight,r=e.clientHeight;return[t,s,r]},sL=function(e){var t=e.scrollLeft,s=e.scrollWidth,r=e.clientWidth;return[t,s,r]},S1=function(e,t){return e==="v"?eL(t):tL(t)},C1=function(e,t){return e==="v"?nL(t):sL(t)},rL=function(e,t){return e==="h"&&t==="rtl"?-1:1},iL=function(e,t,s,r,i){var a=rL(e,window.getComputedStyle(t).direction),l=a*r,o=s.target,c=t.contains(o),u=!1,h=l>0,f=0,m=0;do{if(!o)break;var p=C1(e,o),g=p[0],x=p[1],b=p[2],j=x-b-a*g;(g||j)&&S1(e,o)&&(f+=j,m+=g);var v=o.parentNode;o=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&o!==document.body||c&&(t.contains(o)||t===o));return(h&&Math.abs(f)<1||!h&&Math.abs(m)<1)&&(u=!0),u},cu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},yb=function(e){return[e.deltaX,e.deltaY]},bb=function(e){return e&&"current"in e?e.current:e},aL=function(e,t){return e[0]===t[0]&&e[1]===t[1]},lL=function(e){return`
|
|
78
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
79
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
80
|
+
`)},oL=0,ja=[];function cL(e){var t=d.useRef([]),s=d.useRef([0,0]),r=d.useRef(),i=d.useState(oL++)[0],a=d.useState(k1)[0],l=d.useRef(e);d.useEffect(function(){l.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=RO([e.lockRef.current],(e.shards||[]).map(bb),!0).filter(Boolean);return x.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var o=d.useCallback(function(x,b){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!l.current.allowPinchZoom;var j=cu(x),v=s.current,w="deltaX"in x?x.deltaX:v[0]-j[0],y="deltaY"in x?x.deltaY:v[1]-j[1],N,k=x.target,S=Math.abs(w)>Math.abs(y)?"h":"v";if("touches"in x&&S==="h"&&k.type==="range")return!1;var C=window.getSelection(),$=C&&C.anchorNode,R=$?$===k||$.contains(k):!1;if(R)return!1;var I=wb(S,k);if(!I)return!0;if(I?N=S:(N=S==="v"?"h":"v",I=wb(S,k)),!I)return!1;if(!r.current&&"changedTouches"in x&&(w||y)&&(r.current=N),!N)return!0;var z=r.current||N;return iL(z,b,x,z==="h"?w:y)},[]),c=d.useCallback(function(x){var b=x;if(!(!ja.length||ja[ja.length-1]!==a)){var j="deltaY"in b?yb(b):cu(b),v=t.current.filter(function(N){return N.name===b.type&&(N.target===b.target||b.target===N.shadowParent)&&aL(N.delta,j)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var w=(l.current.shards||[]).map(bb).filter(Boolean).filter(function(N){return N.contains(b.target)}),y=w.length>0?o(b,w[0]):!l.current.noIsolation;y&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(x,b,j,v){var w={name:x,delta:b,target:j,should:v,shadowParent:uL(j)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(y){return y!==w})},1)},[]),h=d.useCallback(function(x){s.current=cu(x),r.current=void 0},[]),f=d.useCallback(function(x){u(x.type,yb(x),x.target,o(x,e.lockRef.current))},[]),m=d.useCallback(function(x){u(x.type,cu(x),x.target,o(x,e.lockRef.current))},[]);d.useEffect(function(){return ja.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,va),document.addEventListener("touchmove",c,va),document.addEventListener("touchstart",h,va),function(){ja=ja.filter(function(x){return x!==a}),document.removeEventListener("wheel",c,va),document.removeEventListener("touchmove",c,va),document.removeEventListener("touchstart",h,va)}},[]);var p=e.removeScrollBar,g=e.inert;return d.createElement(d.Fragment,null,g?d.createElement(a,{styles:lL(i)}):null,p?d.createElement(JO,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function uL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const dL=FO(b1,cL);var Mv=d.forwardRef(function(e,t){return d.createElement(Mh,Zs({},e,{ref:t,sideCar:dL}))});Mv.classNames=Mh.classNames;var hL=Object.defineProperty,rt=(e,t)=>hL(e,"name",{value:t,configurable:!0}),rg=["Enter"," "],fL=["ArrowDown","PageUp","Home"],E1=["ArrowUp","PageDown","End"],mL=[...fL,...E1],pL={ltr:[...rg,"ArrowRight"],rtl:[...rg,"ArrowLeft"]},gL={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Dh="Menu",[Zo,xL,vL]=ph(Dh),[oa,A1]=_s(Dh,[vL,Ch,Ph]),Oh=Ch(),T1=Ph(),[R1,Ci]=oa(Dh),[jL,yc]=oa(Dh),wL=rt(e=>{const{__scopeMenu:t,open:s=!1,children:r,dir:i,onOpenChange:a,modal:l=!0}=e,o=Oh(t),[c,u]=d.useState(null),h=d.useRef(!1),f=Sn(a),m=Rh(i);return d.useEffect(()=>{const p=rt(()=>{h.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},"handleKeyDown"),g=rt(()=>h.current=!1,"handlePointer");return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),d.useEffect(()=>{if(!s)return;const p=rt(()=>f(!1),"handleBlur");return window.addEventListener("blur",p),()=>window.removeEventListener("blur",p)},[s,f]),n.jsx(yv,{...o,children:n.jsx(R1,{scope:t,open:s,onOpenChange:f,content:c,onContentChange:u,children:n.jsx(jL,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:h,dir:m,modal:l,children:r})})})},"Menu"),$1=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,...i}=t,a=Oh(r);return n.jsx(FC,{...a,...i,ref:s})},"MenuAnchor")),I1="MenuPortal",[yL,P1]=oa(I1,{forceMount:void 0}),bL=rt(e=>{const{__scopeMenu:t,forceMount:s,children:r,container:i}=e,a=Ci(I1,t);return n.jsx(yL,{scope:t,forceMount:s,children:n.jsx(ur,{present:s||a.open,children:n.jsx(vh,{asChild:!0,container:i,children:r})})})},"MenuPortal"),Is="MenuContent",[kL,Dv]=oa(Is),NL=d.forwardRef(rt(function(t,s){const r=P1(Is,t.__scopeMenu),{forceMount:i=r.forceMount,...a}=t,l=Ci(Is,t.__scopeMenu),o=yc(Is,t.__scopeMenu);return n.jsx(Zo.Provider,{scope:t.__scopeMenu,children:n.jsx(ur,{present:i||l.open,children:n.jsx(Zo.Slot,{scope:t.__scopeMenu,children:o.modal?n.jsx(SL,{...a,ref:s}):n.jsx(CL,{...a,ref:s})})})})},"MenuContent")),SL=d.forwardRef(rt(function(t,s){const r=Ci(Is,t.__scopeMenu),i=d.useRef(null),a=jt(s,i);return d.useEffect(()=>{const l=i.current;if(l)return j1(l)},[]),n.jsx(Ov,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Pe(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),CL=d.forwardRef(rt(function(t,s){const r=Ci(Is,t.__scopeMenu);return n.jsx(Ov,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),EL=fi("MenuContent.ScrollLock"),Ov=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,loop:i=!1,trapFocus:a,onOpenAutoFocus:l,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:p,onDismiss:g,disableOutsideScroll:x,...b}=t,j=Ci(Is,r),v=yc(Is,r),w=Oh(r),y=T1(r),N=xL(r),[k,S]=d.useState(null),C=d.useRef(null),$=jt(s,C,j.onContentChange),R=d.useRef(0),I=d.useRef(""),z=d.useRef(0),U=d.useRef(null),A=d.useRef("right"),P=d.useRef(0),D=x?Mv:d.Fragment,O=x?{as:EL,allowPinchZoom:!0}:void 0,M=rt(_=>{var de,_e;const G=I.current+_,B=N().filter(Ie=>!Ie.disabled),K=document.activeElement,F=(de=B.find(Ie=>Ie.ref.current===K))==null?void 0:de.textValue,Q=B.map(Ie=>Ie.textValue),X=W1(Q,G,F),Z=(_e=B.find(Ie=>Ie.textValue===X))==null?void 0:_e.ref.current;rt(function Ie(Ue){I.current=Ue,window.clearTimeout(R.current),Ue!==""&&(R.current=window.setTimeout(()=>Ie(""),1e3))},"updateSearch")(G),Z&&setTimeout(()=>Z.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(R.current),[]),$h();const W=d.useCallback(_=>{var B,K;return A.current===((B=U.current)==null?void 0:B.side)&&K1(_,(K=U.current)==null?void 0:K.area)},[]);return n.jsx(kL,{scope:r,searchRef:I,onItemEnter:d.useCallback(_=>{W(_)&&_.preventDefault()},[W]),onItemLeave:d.useCallback(_=>{var G;W(_)||((G=C.current)==null||G.focus(),S(null))},[W]),onTriggerLeave:d.useCallback(_=>{W(_)&&_.preventDefault()},[W]),pointerGraceTimerRef:z,onPointerGraceIntentChange:d.useCallback(_=>{U.current=_},[]),children:n.jsx(D,{...O,children:n.jsx(t1,{asChild:!0,trapped:a,onMountAutoFocus:Pe(l,_=>{var G;_.preventDefault(),(G=C.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:n.jsx(xh,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:f,onFocusOutside:m,onInteractOutside:p,onDismiss:g,children:n.jsx(g1,{asChild:!0,...y,dir:v.dir,orientation:"vertical",loop:i,currentTabStopId:k,onCurrentTabStopIdChange:S,onEntryFocus:Pe(u,_=>{v.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(zC,{role:"menu","aria-orientation":"vertical","data-state":Lv(j.open),"data-radix-menu-content":"",dir:v.dir,...w,...b,ref:$,style:{outline:"none",...b.style},onKeyDown:Pe(b.onKeyDown,_=>{const B=_.target.closest("[data-radix-menu-content]")===_.currentTarget,K=_.ctrlKey||_.altKey||_.metaKey,F=_.key.length===1;B&&(_.key==="Tab"&&_.preventDefault(),!K&&F&&M(_.key));const Q=C.current;if(_.target!==Q||!mL.includes(_.key))return;_.preventDefault();const Z=N().filter(de=>!de.disabled).map(de=>de.ref.current);E1.includes(_.key)&&Z.reverse(),U1(Z)}),onBlur:Pe(t.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(R.current),I.current="")}),onPointerMove:Pe(t.onPointerMove,rl(_=>{const G=_.target,B=P.current!==_.clientX;if(_.currentTarget.contains(G)&&B){const K=_.clientX>P.current?"right":"left";A.current=K,P.current=_.clientX}}))})})})})})})},"MenuContentImpl")),M1=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(pt.div,{role:"group",...i,ref:s})},"MenuGroup")),AL=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(pt.div,{...i,ref:s})},"MenuLabel")),ig="MenuItem",kb="menu.itemSelect",D1=d.forwardRef(rt(function(t,s){const{disabled:r=!1,onSelect:i,...a}=t,l=d.useRef(null),o=yc(ig,t.__scopeMenu),c=Dv(ig,t.__scopeMenu),u=jt(s,l),h=d.useRef(!1),f=rt(()=>{const m=l.current;if(!r&&m){const p=new CustomEvent(kb,{bubbles:!0,cancelable:!0});m.addEventListener(kb,g=>i==null?void 0:i(g),{once:!0}),gh(m,p),p.defaultPrevented?h.current=!1:o.onClose()}},"handleSelect");return n.jsx(O1,{...a,ref:u,disabled:r,onClick:Pe(t.onClick,f),onPointerDown:m=>{var p;(p=t.onPointerDown)==null||p.call(t,m),h.current=!0},onPointerUp:Pe(t.onPointerUp,m=>{var p;h.current||(p=m.currentTarget)==null||p.click()}),onKeyDown:Pe(t.onKeyDown,m=>{r||m.target!==m.currentTarget||c.searchRef.current!==""&&m.key===" "||rg.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})},"MenuItem")),O1=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,disabled:i=!1,textValue:a,...l}=t,o=Dv(ig,r),c=T1(r),u=d.useRef(null),h=jt(s,u),[f,m]=d.useState(!1),[p,g]=d.useState("");return d.useEffect(()=>{const x=u.current;x&&g((x.textContent??"").trim())},[l.children]),n.jsx(Zo.ItemSlot,{scope:r,disabled:i,textValue:a??p,children:n.jsx(x1,{asChild:!0,...c,focusable:!i,children:n.jsx(pt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...l,ref:h,onPointerMove:Pe(t.onPointerMove,rl(x=>{i?o.onItemLeave(x):(o.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(t.onPointerLeave,rl(x=>o.onItemLeave(x))),onFocus:Pe(t.onFocus,()=>m(!0)),onBlur:Pe(t.onBlur,()=>m(!1))})})})},"MenuItemImpl")),TL="MenuRadioGroup",[RL,$L]=oa(TL,{value:void 0,onValueChange:rt(()=>{},"onValueChange")}),IL=d.forwardRef(rt(function(t,s){const{value:r,onValueChange:i,...a}=t,l=Sn(i);return n.jsx(RL,{scope:t.__scopeMenu,value:r,onValueChange:l,children:n.jsx(M1,{...a,ref:s})})},"MenuRadioGroup")),PL="MenuRadioItem",ML=d.forwardRef(rt(function(t,s){const{value:r,...i}=t,a=$L(PL,t.__scopeMenu),l=r===a.value;return n.jsx(OL,{scope:t.__scopeMenu,checked:l,children:n.jsx(D1,{role:"menuitemradio","aria-checked":l,...i,ref:s,"data-state":z1(l),onSelect:Pe(i.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),DL="MenuItemIndicator",[OL,lQ]=oa(DL,{checked:!1}),LL=d.forwardRef(rt(function(t,s){const{__scopeMenu:r,...i}=t;return n.jsx(pt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:s})},"MenuSeparator")),L1="MenuSub",[_L,_1]=oa(L1),FL=rt(e=>{const{__scopeMenu:t,children:s,open:r=!1,onOpenChange:i}=e,a=Ci(L1,t),l=Oh(t),[o,c]=d.useState(null),[u,h]=d.useState(null),f=Sn(i);return d.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),n.jsx(yv,{...l,children:n.jsx(R1,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:h,children:n.jsx(_L,{scope:t,contentId:$s(),triggerId:$s(),trigger:o,onTriggerChange:c,children:s})})})},"MenuSub"),uu="MenuSubTrigger",zL=d.forwardRef(rt(function(t,s){const r=Ci(uu,t.__scopeMenu),i=yc(uu,t.__scopeMenu),a=_1(uu,t.__scopeMenu),l=Dv(uu,t.__scopeMenu),o=d.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=l,h={__scopeMenu:t.__scopeMenu},f=d.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);d.useEffect(()=>f,[f]),d.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),u(null)}},[c,u]);const m=jt(s,a.onTriggerChange);return n.jsx($1,{asChild:!0,...h,children:n.jsx(O1,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":r.open?a.contentId:void 0,"data-state":Lv(r.open),...t,ref:m,onClick:p=>{var g;(g=t.onClick)==null||g.call(t,p),!(t.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Pe(t.onPointerMove,rl(p=>{l.onItemEnter(p),!p.defaultPrevented&&!t.disabled&&!r.open&&!o.current&&(l.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:Pe(t.onPointerLeave,rl(p=>{var x,b;f();const g=(x=r.content)==null?void 0:x.getBoundingClientRect();if(g){const j=(b=r.content)==null?void 0:b.dataset.side,v=j==="right",w=v?-5:5,y=g[v?"left":"right"],N=g[v?"right":"left"];l.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:y,y:g.top},{x:N,y:g.top},{x:N,y:g.bottom},{x:y,y:g.bottom}],side:j}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.onPointerGraceIntentChange(null),300)}else{if(l.onTriggerLeave(p),p.defaultPrevented)return;l.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(t.onKeyDown,p=>{var x;t.disabled||p.target!==p.currentTarget||l.searchRef.current!==""&&p.key===" "||pL[i.dir].includes(p.key)&&(r.onOpenChange(!0),(x=r.content)==null||x.focus(),p.preventDefault())})})})},"MenuSubTrigger")),UL="MenuSubContent",BL=d.forwardRef(rt(function(t,s){const r=P1(Is,t.__scopeMenu),{forceMount:i=r.forceMount,align:a="start",...l}=t,o=Ci(Is,t.__scopeMenu),c=yc(Is,t.__scopeMenu),u=_1(UL,t.__scopeMenu),h=d.useRef(null),f=jt(s,h);return n.jsx(Zo.Provider,{scope:t.__scopeMenu,children:n.jsx(ur,{present:i||o.open,children:n.jsx(Zo.Slot,{scope:t.__scopeMenu,children:n.jsx(Ov,{id:u.contentId,"aria-labelledby":u.triggerId,...l,ref:f,align:a,side:c.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var p;c.isUsingKeyboardRef.current&&((p=h.current)==null||p.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Pe(t.onFocusOutside,m=>{m.target!==u.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Pe(t.onEscapeKeyDown,m=>{c.onClose(),m.preventDefault()}),onKeyDown:Pe(t.onKeyDown,m=>{var x;const p=m.currentTarget.contains(m.target),g=gL[c.dir].includes(m.key);p&&g&&(o.onOpenChange(!1),(x=u.trigger)==null||x.focus(),m.preventDefault())})})})})})},"MenuSubContent"));function Lv(e){return e?"open":"closed"}rt(Lv,"getOpenState");function F1(e){return e==="indeterminate"}rt(F1,"isIndeterminate");function z1(e){return F1(e)?"indeterminate":e?"checked":"unchecked"}rt(z1,"getCheckedState");function U1(e){const t=document.activeElement;for(const s of e)if(s===t||(s.focus(),document.activeElement!==t))return}rt(U1,"focusFirst");function B1(e,t){return e.map((s,r)=>e[(t+r)%e.length])}rt(B1,"wrapArray");function W1(e,t,s){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=s?e.indexOf(s):-1;let l=B1(e,Math.max(a,0));i.length===1&&(l=l.filter(u=>u!==s));const c=l.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==s?c:void 0}rt(W1,"getNextMatch");function H1(e,t){const{x:s,y:r}=e;let i=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const o=t[a],c=t[l],u=o.x,h=o.y,f=c.x,m=c.y;h>r!=m>r&&s<(f-u)*(r-h)/(m-h)+u&&(i=!i)}return i}rt(H1,"isPointInPolygon");function K1(e,t){if(!t)return!1;const s={x:e.clientX,y:e.clientY};return H1(s,t)}rt(K1,"isPointerInGraceArea");function rl(e){return t=>t.pointerType==="mouse"?e(t):void 0}rt(rl,"whenMouse");var WL=wL,HL=$1,KL=bL,VL=NL,GL=M1,YL=AL,qL=D1,QL=IL,XL=ML,JL=LL,ZL=FL,e_=zL,t_=BL,n_=Object.defineProperty,ts=(e,t)=>n_(e,"name",{value:t,configurable:!0}),_v="DropdownMenu",[s_,oQ]=_s(_v,[A1]),ns=A1(),[r_,V1]=s_(_v),i_=ts(e=>{const{__scopeDropdownMenu:t,children:s,dir:r,open:i,defaultOpen:a,onOpenChange:l,modal:o=!0}=e,c=ns(t),u=d.useRef(null),[h,f]=Ni({prop:i,defaultProp:a??!1,onChange:l,caller:_v});return n.jsx(r_,{scope:t,triggerId:$s(),triggerRef:u,contentId:$s(),open:h,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(m=>!m),[f]),modal:o,children:n.jsx(WL,{...c,open:h,onOpenChange:f,dir:r,modal:o,children:s})})},"DropdownMenu"),a_="DropdownMenuTrigger",l_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,disabled:i=!1,...a}=t,l=V1(a_,r),o=ns(r),c=jt(s,l.triggerRef);return n.jsx(HL,{asChild:!0,...o,children:n.jsx(pt.button,{type:"button",id:l.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":l.open?l.contentId:void 0,"data-state":l.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...a,ref:c,onPointerDown:Pe(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:Pe(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),o_=ts(e=>{const{__scopeDropdownMenu:t,...s}=e,r=ns(t);return n.jsx(KL,{...r,...s})},"DropdownMenuPortal"),c_="DropdownMenuContent",u_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=V1(c_,r),l=ns(r),o=d.useRef(!1);return n.jsx(VL,{id:a.contentId,"aria-labelledby":a.triggerId,...l,...i,ref:s,onCloseAutoFocus:Pe(t.onCloseAutoFocus,c=>{var u;o.current||(u=a.triggerRef.current)==null||u.focus(),o.current=!1,c.preventDefault()}),onInteractOutside:Pe(t.onInteractOutside,c=>{const u=c.detail.originalEvent,h=u.button===0&&u.ctrlKey===!0,f=u.button===2||h;(!a.modal||f)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),d_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(GL,{...a,...i,ref:s})},"DropdownMenuGroup")),h_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(YL,{...a,...i,ref:s})},"DropdownMenuLabel")),f_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(qL,{...a,...i,ref:s})},"DropdownMenuItem")),m_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(QL,{...a,...i,ref:s})},"DropdownMenuRadioGroup")),p_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(XL,{...a,...i,ref:s})},"DropdownMenuRadioItem")),g_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(JL,{...a,...i,ref:s})},"DropdownMenuSeparator")),x_=ts(e=>{const{__scopeDropdownMenu:t,children:s,open:r,onOpenChange:i,defaultOpen:a}=e,l=ns(t),[o,c]=Ni({prop:r,defaultProp:a??!1,onChange:i,caller:"DropdownMenuSub"});return n.jsx(ZL,{...l,open:o,onOpenChange:c,children:s})},"DropdownMenuSub"),v_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(e_,{...a,...i,ref:s})},"DropdownMenuSubTrigger")),j_=d.forwardRef(ts(function(t,s){const{__scopeDropdownMenu:r,...i}=t,a=ns(r);return n.jsx(t_,{...a,...i,ref:s,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent")),bc=i_,kc=l_,Nl=o_,Nc=u_,G1=d_,ta=h_,us=f_,w_=m_,y_=p_,Nr=g_,b_=x_,k_=v_,N_=j_,S_=Object.defineProperty,Sl=(e,t)=>S_(e,"name",{value:t,configurable:!0}),Fv="Tabs",[C_,cQ]=_s(Fv,[Ph]),Y1=Ph(),[E_,zv]=C_(Fv),A_=d.forwardRef(Sl(function(t,s){const{__scopeTabs:r,value:i,onValueChange:a,defaultValue:l,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=Rh(c),[m,p]=Ni({prop:i,onChange:a,defaultProp:l??"",caller:Fv});return n.jsx(E_,{scope:r,baseId:$s(),value:m,onValueChange:p,orientation:o,dir:f,activationMode:u,children:n.jsx(pt.div,{dir:f,"data-orientation":o,...h,ref:s})})},"Tabs")),T_="TabsList",R_=d.forwardRef(Sl(function(t,s){const{__scopeTabs:r,loop:i=!0,...a}=t,l=zv(T_,r),o=Y1(r);return n.jsx(g1,{asChild:!0,...o,orientation:l.orientation,dir:l.dir,loop:i,children:n.jsx(pt.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:s})})},"TabsList")),$_="TabsTrigger",I_=d.forwardRef(Sl(function(t,s){const{__scopeTabs:r,value:i,disabled:a=!1,...l}=t,o=zv($_,r),c=Y1(r),u=Uv(o.baseId,i),h=Bv(o.baseId,i),f=i===o.value;return n.jsx(x1,{asChild:!0,...c,focusable:!a,active:f,children:n.jsx(pt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:u,...l,ref:s,onMouseDown:Pe(t.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?o.onValueChange(i):m.preventDefault()}),onKeyDown:Pe(t.onKeyDown,m=>{a||m.target!==m.currentTarget||[" ","Enter"].includes(m.key)&&o.onValueChange(i)}),onFocus:Pe(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!a&&m&&o.onValueChange(i)})})})},"TabsTrigger")),P_="TabsContent",M_=d.forwardRef(Sl(function(t,s){const{__scopeTabs:r,value:i,forceMount:a,children:l,...o}=t,c=zv(P_,r),u=Uv(c.baseId,i),h=Bv(c.baseId,i),f=i===c.value,m=d.useRef(f);return d.useEffect(()=>{const p=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(p)},[]),n.jsx(ur,{present:a||f,children:({present:p})=>n.jsx(pt.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!p,id:h,tabIndex:0,...o,ref:s,style:{...t.style,animationDuration:m.current?"0s":void 0},children:p&&l})})},"TabsContent"));function Uv(e,t){return`${e}-trigger-${t}`}Sl(Uv,"makeTriggerId");function Bv(e,t){return`${e}-content-${t}`}Sl(Bv,"makeContentId");var D_=A_,O_=R_,L_=I_,__=M_;function Qt(e,t,s){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?F_(r,s):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${Nb(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Gt(r):Nb(r):String(e)}case"date":return z_(String(e));default:return typeof e=="string"?e:typeof e=="number"?Gt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function F_(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return eO(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function z_(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return t?Th(t[0],{year:!0,compact:!0}):e}function ag(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return t?Th(t[0],{compact:!0}):e}function Nb(e){return String(Math.round(e*100)/100)}function $d(e,t,s=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,s),i=10**Math.floor(Math.log10(r)),a=[1,2,2.5,5,10].map(o=>o*i).find(o=>o>=r)??i*10,l=[];for(let o=Math.ceil(e/a)*a;o<=t+a/1e3;o+=a)l.push(Math.round(o*1e6)/1e6);return l.filter(o=>o>=e&&o<=t)}function U_({props:e}){if(e.bars.length===0)return n.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(a=>a.value),s=Math.max(0,...t),r=Math.min(0,...t),i=s-r||1;return n.jsx("div",{className:"wb-bars",children:e.bars.map(a=>{const l=Math.abs(a.value)/i;return n.jsxs("div",{className:"wb-bar-row",children:[n.jsx("div",{className:"wb-bar-cat",title:a.category,children:a.category}),n.jsx("div",{className:"wb-bar-track",children:n.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,l*100)}%`,background:a.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),n.jsx("div",{className:"wb-bar-val",children:Qt(a.value,e.unit,e.currency)})]},a.category)})})}const B_=/^(diff --git |index [0-9a-f]|--- (a\/|\/dev\/null)|\+\+\+ (b\/|\/dev\/null)|new file mode|deleted file mode|similarity index|rename (from|to) |old mode|new mode|Binary files )/,W_=/^(… |\.\.\. |\(no change\)$|\)/;function H_(e){return e.replace(/\n$/,"").split(`
|
|
81
|
+
`).map(s=>({kind:K_(s),text:s}))}function K_(e){return e.startsWith("@@")?"hunk":B_.test(e)||W_.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function V_({text:e,marks:t}){const s=e.toLowerCase(),r=[];for(const l of t){const o=l.trim().toLowerCase();if(o!=="")for(let c=s.indexOf(o);c!==-1;c=s.indexOf(o,c+o.length))r.push([c,c+o.length])}if(r.length===0)return n.jsx(n.Fragment,{children:e===""?" ":e});r.sort((l,o)=>l[0]-o[0]);const i=[];let a=0;for(const[l,o]of r)l<a||(l>a&&i.push(n.jsx("span",{children:e.slice(a,l)},`t${a}`)),i.push(n.jsx("mark",{className:"wb-diff-mark",children:e.slice(l,o)},`m${l}`)),a=o);return a<e.length&&i.push(n.jsx("span",{children:e.slice(a)},`t${a}`)),n.jsx(n.Fragment,{children:i})}function Id({text:e,limit:t,more:s,label:r="Diff",marks:i}){const a=H_(e),l=t===void 0?a:a.slice(0,t),o=a.length-l.length;return n.jsxs("div",{className:"wb-diff-wrap",children:[n.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:l.map((c,u)=>n.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?n.jsx(V_,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),o>0?n.jsxs("p",{className:"wb-diff-more",children:[o," more line",o===1?"":"s",s?n.jsxs(n.Fragment,{children:[" · ",n.jsx("button",{type:"button",className:"wb-diff-open",onClick:s.onClick,children:s.label})]}):null]}):null]})}function G_({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:Qt(t.value,t.unit,null)})]},t.label))}):null,e.diff?n.jsx(Id,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):n.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const sn="#/",Lh="#/needs",ci="#/chat",Et="#/agents",vt="#/activity",en="#/settings",Or="#/files",Y_="#/welcome";function Gu(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function du(e,t={}){const s=new URLSearchParams;t.q&&s.set("q",t.q),t.origin&&s.set("origin",t.origin),t.family&&s.set("family",t.family);const r=s.toString();return`${Or}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function q_(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[2]??""),r={};return s.get("q")&&(r.q=s.get("q")),s.get("origin")&&(r.origin=s.get("origin")),s.get("family")&&(r.family=s.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function at(e,t,s){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function Q_(e){if(q1(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const s=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...s?{tab:s}:{}}}catch{return null}}function Oi(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function q1(e){const t=/^#\/chat\/g\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{groupId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{}}}catch{return null}}function At(e,t,s){return`${Et}/${encodeURIComponent(e)}${t?`/${t}${s?`/${s}`:""}`:""}`}function X_(e){const t=/^#\/agents\/([^/]+)(?:\/([a-z-]+)(?:\/([a-z-]+))?)?$/.exec(e);if(!t)return null;try{return{agentId:decodeURIComponent(t[1]),...t[2]?{tab:t[2]}:{},...t[3]?{section:t[3]}:{}}}catch{return null}}function il(e){return`${vt}/conversations/${encodeURIComponent(e)}`}const J_="#/p";function lr(e,t,s){const r=`${J_}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return s?`${r}/${encodeURIComponent(s)}`:r}function Wv(e){const t=/^#\/p\/([^/?]+)\/([^/?]+)(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(!t)return null;try{return{plugin:decodeURIComponent(t[1]),page:decodeURIComponent(t[2]),...t[3]?{item:decodeURIComponent(t[3])}:{}}}catch{return null}}const Z_="p.";function gi(e,t,s){const r=s?new URLSearchParams(s).toString():"";return`${en}/${encodeURIComponent(X1(e,t))}${r?`?${r}`:""}`}function Q1(e){const t=e.indexOf("?");if(t===-1)return{};try{const s={};for(const[r,i]of new URLSearchParams(e.slice(t+1)))i!==""&&(s[r]=i);return s}catch{return{}}}function eF(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const s=decodeURIComponent(t[1]);return{plugin:s,page:t[2]?decodeURIComponent(t[2]):s}}function X1(e,t){return`${Z_}${e}${t===e?"":`.${t}`}`}function De(e){return e?`${en}/${e}`:en}function J1(e){return`${De("accounts")}?account=${encodeURIComponent(e)}`}function tF(e){const t=/^#\/settings\/accounts\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("account")||null}catch{return null}}function Hv(e,t,s){const r=new RegExp(`^#/settings/${t}\\?(.*)$`).exec(e);if(!r)return null;try{return new URLSearchParams(r[1]).get(s)||null}catch{return null}}function Z1(e){return`${De("connections")}?connection=${encodeURIComponent(e)}`}function nF(e){return Hv(e,"connections","connection")}function sF(e){return Hv(e,"secrets","secret")}const Sb=`${De("secrets")}?add=1`;function rF(e){return Hv(e,"secrets","add")==="1"}function iF(e){return`${De("plugins")}?install=${encodeURIComponent(e)}`}const aF=`${De("plugins")}?tab=browse`;function lF(e){return`${De("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function oF(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}function eE(e){const t=/^#\/settings\/plugins\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1])}catch{return null}}function cF(e){var s,r;const t=(r=(s=eE(e))==null?void 0:s.get("install"))==null?void 0:r.trim();return t||null}function Cb(e){const t=eE(e);return t!=null&&t.get("install")?"installed":(t==null?void 0:t.get("tab"))==="browse"?"browse":"installed"}const uF=[{route:sn,label:"Home"},{route:ci,label:"Chat"},{route:Et,label:"Agents"},{route:vt,label:"Activity"},{route:Or,label:"Files"},{route:en,label:"Settings"}],dF=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],hF=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",group:"you"},{id:"telegram",label:"Telegram",group:"you"},{id:"memory",label:"Memory",group:"you"},{id:"proposals",label:"Proposals",group:"you"},{id:"accounts",label:"Model accounts",group:"access"},{id:"computer",label:"Computer & browser",group:"access"},{id:"secrets",label:"Keys and secrets",group:"access"},{id:"connections",label:"Connections",group:"access"},{id:"lock",label:"Lock screen",group:"access"},{id:"api",label:"API tokens",group:"access"},{id:"watchers",label:"Watchers",group:"running"},{id:"backup",label:"Backup",group:"running"},{id:"system",label:"System",group:"running"},{id:"plugins",label:"All plugins",group:"plugins"}];function fF(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const tE="#/settings/notifications/recent",mF=De("backup");function pF(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return il(decodeURIComponent(t[1]));const s=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(s)try{return lr("email","mail",s[1]?decodeURIComponent(s[1]):null)}catch{return lr("email","mail")}return e==="#/settings/email"?gi("email","settings"):{"#/overview":sn,"#/approvals":sn,"#/events":`${vt}/events`,"#/jobs":`${vt}/jobs`,"#/conversations":vt,"#/missions":`${Et}?tab=missions`,"#/offers":`${Et}?tab=offers`,"#/reminders":`${Et}?tab=reminders`,"#/providers":De("accounts"),"#/browser":De("computer"),"#/sentinels":De("watchers"),"#/settings/sentinels":De("watchers")}[e]??null}function nE(e){if(e===""||e==="#"||e===sn)return sn;if(e.startsWith(ci))return ci;if(e.startsWith(Et))return Et;if(e.startsWith(vt))return vt;if(e.startsWith(Or))return Or;if(e.startsWith(en))return en;const t=Wv(e);return t?lr(t.plugin,t.page):sn}const gF="#/chat?group=new";function xF(e){const t=e.replace(/^#\/?/,"").split("?")[0].toLowerCase();if(t==="")return"home";const[s,r]=t.split("/");return!s||!/^[a-z0-9-]+$/.test(s)?null:(s==="settings"||s==="p")&&r&&/^[a-z0-9.-]+$/.test(r)?`${s}/${r}`:s}const Kv="front-desk",Vv=[{id:Kv,label:"Front desk",meaning:"Where things go when you do not say who."},{id:"overview",label:"Overview",meaning:"Answers /status and speaks for the watchers."},{id:"recap",label:"Recap",meaning:"Runs /recap."},{id:"maker",label:"Maker",meaning:"/new opens its interview."}],sE=new Set(Vv.map(e=>e.id)),Eb=e=>sE.has(e);function Ab(e,t){const s=t.filter(r=>!sE.has(r));return[...Vv.filter(r=>e.has(r.id)).map(r=>r.id),...s.filter((r,i)=>s.indexOf(r)===i)]}function vF(e,t){return e.find(s=>(s.roles??[]).includes(t))}const Tb=["coding","finance","mail","research","calendar","files","memory"],jF={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[Kv]:"buddi"},wF=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function yF(e){const t=new Set(e.map(s=>s.split(".")[0]??s));for(const[s,r]of wF)if(r.some(i=>t.has(i)))return s;return t.size>0&&[...t].every(s=>s==="memory")?"memory":null}let lg=null;function bF(e){lg=e}function Sc(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const s of e.roles??[]){const r=jF[s];if(r)return{key:r}}const t=yF(e.tools??[]);return t?{key:t}:lg!==null&&e.id===lg?{key:"buddi"}:{key:Tb[kF(e.id)%Tb.length]??"coding"}}function Cc(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function kF(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t}const NF=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","reaction","live","live.settle","live.snapshot","attention","closing","ping"];function SF(e){const s=e.replace(/\r\n/g,`
|
|
82
|
+
`).split(`
|
|
83
|
+
|
|
84
|
+
`),r=s.pop()??"",i=[];for(const a of s){let l=null,o="message";const c=[];for(const u of a.split(`
|
|
85
|
+
`)){if(u===""||u.startsWith(":"))continue;const h=u.indexOf(":"),f=h===-1?u:u.slice(0,h),m=h===-1?"":u.slice(h+1).replace(/^ /,"");f==="id"?l=m:f==="event"?o=m:f==="data"&&c.push(m)}c.length===0&&o==="message"||i.push({id:l,name:NF.includes(o)?o:"ping",data:CF(c.join(`
|
|
86
|
+
`))})}return{events:i,rest:r}}function CF(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function _h(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),s=e.wait??(u=>new Promise(h=>setTimeout(h,u))),r=e.retryMs??1500;let i=e.lastEventId??null,a=!1,l=!1,o=null;return(async()=>{var u,h,f,m,p;for(;!a;){(u=e.onStatus)==null||u.call(e,"connecting"),o=new AbortController;try{const g=await t(e.url,{credentials:"same-origin",signal:o.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!g.ok||!g.body)throw new Error(`stream ${g.status}`);(h=e.onStatus)==null||h.call(e,"open"),l&&((f=e.onReconnect)==null||f.call(e));const x=g.body.getReader(),b=new TextDecoder;let j="";for(;;){const{done:v,value:w}=await x.read();if(v)break;j+=b.decode(w,{stream:!0});const{events:y,rest:N}=SF(j);j=N;for(const k of y)e.onEvent(k),k.id!==null&&(i=k.id);if(a)break}}catch{}if(a)break;l=!0,(m=e.onStatus)==null||m.call(e,"closed"),await s(r)}(p=e.onStatus)==null||p.call(e,"closed")})(),{close:()=>{a=!0,o==null||o.abort()},lastEventId:()=>i}}const Gv="0.1.0+ff321a8";function Yv(e,t=Gv){return typeof e=="string"&&e!==""&&typeof t=="string"&&t!==""&&e!==t}function EF(){var e;try{if((e=window.matchMedia)!=null&&e.call(window,"(display-mode: standalone)").matches)return!0}catch{}return window.navigator.standalone===!0}const AF=5*6e4,TF=6e4,RF=5e3,ec="buddi:stream-reconnected",rE="buddi.autoReloadedFor";function $F(){window.dispatchEvent(new Event(ec))}const Rb=["keydown","pointerdown","pointermove","wheel","touchstart","input"];let qv=Date.now(),hu=0;const $b=()=>{qv=Date.now()};function IF(){if(hu===0){qv=Date.now();for(const e of Rb)window.addEventListener(e,$b,{capture:!0,passive:!0})}return hu+=1,()=>{if(hu-=1,hu===0)for(const e of Rb)window.removeEventListener(e,$b,{capture:!0})}}function PF(e=Date.now()){return e-qv}function iE(e=document){return e.querySelector('.wb-composer[data-busy="true"]')!==null||e.querySelector('.wb-listening, [data-recording="true"]')!==null||e.querySelector('[role="dialog"], [role="alertdialog"], dialog[open]')!==null}function MF(e){return e.hidden?!0:e.idleMs>=TF&&!e.busy}function DF(e){try{return window.sessionStorage.getItem(rE)===e}catch{return!1}}function OF(e){try{window.sessionStorage.setItem(rE,e)}catch{}}function LF(e){const t=d.useRef(e);t.current=e,d.useEffect(()=>{const s=()=>t.current();return window.addEventListener(ec,s),()=>window.removeEventListener(ec,s)},[])}function _F(e,t=()=>window.location.reload(),s=Gv){const r=Yv(e,s),i=d.useRef(t);i.current=t,d.useEffect(()=>IF(),[]),d.useEffect(()=>{if(!r||e===void 0||DF(e))return;let a=!1;const l=()=>{if(a)return;const c=document.visibilityState==="hidden";MF({hidden:c,idleMs:PF(),busy:iE()})&&(a=!0,OF(e),i.current())};l();const o=window.setInterval(l,RF);return document.addEventListener("visibilitychange",l),()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",l)}},[r,e])}const FF=9e4,aE=5*6e4,zF=500,UF=2e3,BF=3e3,WF="/_buddi/ready",Ga={reload:()=>window.location.reload(),now:()=>Date.now()};let xi=null,Oa=null,oo=null;const og=new Set;function Pd(e){xi=e;for(const t of og)t()}function Ib(){return xi}function HF(e){return og.add(e),()=>og.delete(e)}function KF(){const e=new Uint8Array(32);return crypto.getRandomValues(e),[...e].map(t=>t.toString(16).padStart(2,"0")).join("")}async function Qv(e=BF){const t=new AbortController,s=setTimeout(()=>t.abort(),e);try{const r=await fetch(`${WF}?challenge=${KF()}`,{cache:"no-store",credentials:"omit",redirect:"error",signal:t.signal,headers:{Accept:"application/json"}});if(r.status!==200)return null;const i=await r.json().catch(()=>null);return typeof(i==null?void 0:i.boot)=="string"?i.boot:""}catch{return null}finally{clearTimeout(s)}}async function VF(){const e=await Qv();e&&(Oa=e)}function GF(){let e=Oa,t=!1,s=!1,r=zF,i;const a=async()=>{if(t)return;const l=await Qv();if(!t){if(l===null)s=!0;else if(e!==null?l!==e:s){t=!0,Ga.reload();return}else e===null&&l!==""&&(e=l);r=Math.min(Math.round(r*1.5),UF),i=setTimeout(()=>void a(),r)}};return i=setTimeout(()=>void a(),r),()=>{t=!0,clearTimeout(i)}}function Fh(e){if(xi){if(e.kind==="detected")return;Pd({...xi,...e});return}Pd({...e,startedAt:Ga.now()}),oo=GF()}function lE(e){xi&&Pd({...xi,...e})}function al(){oo==null||oo(),oo=null,Pd(null)}async function zh(e,t){Fh(e);try{return await t()}catch(s){if(Rd(s))return;throw al(),s}}function YF(e){Fh({kind:e.for==="stop"?"stop":"detected"})}async function Pb(){if(xi)return;const e=await Qv();if(Oa===null){e&&(Oa=e);return}if(!(!e||e===Oa||xi)){if(iE()){Oa=e;return}Fh({kind:"detected"})}}function qF(e){const[t,s]=e;if(!t)return null;const r=`${t.name} ${t.version}`;return s?e.length===2?`${r} and ${s.name} ${s.version}`:`${r} and ${e.length-1} more`:r}const QF="/api/chat/attention/stream";function oE(e,t){const s=(a,l)=>a.name.localeCompare(l.name),r=a=>e.filter(l=>l.anchor===a).sort(s),i=e.filter(a=>a.anchor!=="top"&&a.anchor!=="bottom").sort((a,l)=>a.id===t?l.id===t?0:-1:l.id===t?1:s(a,l));return{top:r("top"),middle:i,bottom:r("bottom")}}function cE(e,t){const s=oE(e,t);return[...s.top,...s.middle,...s.bottom]}function Uh(e){if(!e)return null;const t=[];return e.approvals>0&&t.push(e.approvals===1?"one approval is waiting for you":`${e.approvals} approvals are waiting for you`),e.question&&t.push("asked you a question and is holding for the answer"),t.length===0?null:t.join(", and ")}function XF(e){if(!e)return null;const t=e.approvals,s=t===1?"1 approval":`${t} approvals`;return t>0&&e.question?`${s} and a question`:t>0?`${s} waiting`:e.question?"Has a question":null}function JF(e,t){return e&&(e.approvals>0||e.question)?"needs":t?"working":null}function ZF(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function e4(){const[e,t]=d.useState(null);return d.useEffect(()=>{let s=!1;const r=()=>{ge("/chat/attention").then(a=>{s||t(a)}).catch(()=>{})};r();const i=_h({url:QF,onEvent:a=>a.name==="closing"?YF(a.data):r(),onReconnect:$F});return()=>{s=!0,i.close()}},[]),ZF(e)}const Bh="maker";function Xv(e){return e.filter(t=>t.available&&!t.roles.includes(Bh))}function uE(e){return Xv(e).length>=2}function t4(e){var t;return((t=e.find(s=>s.roles.includes(Bh)))==null?void 0:t.name)??"the agent maker"}const n4="{{default}}";function s4(e,t){return e.split(n4).join(t??"your assistant")}function r4(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(s=>s4(s,t))}function i4(e){var s,r;const t=(s=e==null?void 0:e.intro)==null?void 0:s.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function a4(e){const t=(e??"·").trim().split(/\s+/).filter(Boolean);return t.length===0?"·":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function dE(e){var r,i;const t=(r=e.heldBack)==null?void 0:r.message.trim();if(t!==void 0&&t!=="")return`${e.name??"This agent"} is held back. ${t}`;const s=(i=e.unavailableReason)==null?void 0:i.trim();return s&&s!==""?`${e.name??"This agent"} cannot run: ${s}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const l4="Settings → Model accounts",o4="Install it in Settings → Plugins";function cg(e){return e!=null&&e.heldBack?{section:"plugins",label:o4}:{section:"accounts",label:l4}}const c4={home:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),n.jsx("path",{d:"M5.2 8.4v7.4a1 1 0 0 0 1 1h2.6v-4.6h2.4v4.6h2.6a1 1 0 0 0 1-1V8.4"})]})],chat:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M17 10.6a4.9 4.9 0 0 1-4.9 4.9H7.8L3.6 18l.9-3A4.9 4.9 0 0 1 3 11V8.2A4.9 4.9 0 0 1 7.9 3.3h4.2A4.9 4.9 0 0 1 17 8.2Z"}),n.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),n.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),n.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),n.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,n.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),n.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 2.8h5.2L16.5 6.6v8.6a1.2 1.2 0 0 1-1.2 1.2H7.5a1.2 1.2 0 0 1-1.2-1.2V4a1.2 1.2 0 0 1 1.2-1.2z"}),n.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),n.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),n.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),n.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),n.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,n.jsx("path",{d:"M3.2 16.4V8.6M8.4 16.4V3.9M13.6 16.4v-5.8M3.2 16.4h13.6"})],bell:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),n.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),n.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),n.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),n.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),n.jsx("path",{d:"M2.9 10h14.2M10 2.9c3.4 3.7 3.4 10.5 0 14.2-3.4-3.7-3.4-10.5 0-14.2Z"})]})],terminal:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"12.8",rx:"1.6"}),n.jsx("path",{d:"M6.2 8l2.6 2.4-2.6 2.4M10.6 12.8h3.4"})]})],person:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),n.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],briefcase:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"6",width:"14.4",height:"10.2",rx:"1.6"}),n.jsx("path",{d:"M7.4 6V4.6a1 1 0 0 1 1-1h3.2a1 1 0 0 1 1 1V6M2.8 10.4h14.4"})]})],pin:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M10 17.2s5.2-4.9 5.2-9a5.2 5.2 0 0 0-10.4 0c0 4.1 5.2 9 5.2 9Z"}),n.jsx("circle",{cx:"10",cy:"8.2",r:"1.9"})]})],sun:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),n.jsx("path",{d:"M10 2.6v1.6M10 15.8v1.6M2.6 10h1.6M15.8 10h1.6M4.8 4.8l1.1 1.1M14.1 14.1l1.1 1.1M4.8 15.2l1.1-1.1M14.1 5.9l1.1-1.1"})]})],notebook:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5.5 3.2h8.3a1 1 0 0 1 1 1v11.6a1 1 0 0 1-1 1H5.5a1 1 0 0 1-1-1V4.2a1 1 0 0 1 1-1Z"}),n.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),n.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),n.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],lock:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"4",y:"8.6",width:"12",height:"8.6",rx:"2.2"}),n.jsx("path",{d:"M6.8 8.6V6.2a3.2 3.2 0 0 1 6.4 0v2.4"})]})],eye:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.4 10S5.2 4.8 10 4.8 17.6 10 17.6 10 14.8 15.2 10 15.2 2.4 10 2.4 10Z"}),n.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),n.jsx("path",{d:"M4 7.2v8a1.2 1.2 0 0 0 1.2 1.2h9.6a1.2 1.2 0 0 0 1.2-1.2v-8M8.2 10.4h3.6"})]})],chip:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),n.jsx("path",{d:"M8 2.8v2.6M12 2.8v2.6M8 14.6v2.6M12 14.6v2.6M2.8 8h2.6M2.8 12h2.6M14.6 8h2.6M14.6 12h2.6"})]})],"partly-cloudy":[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7.4",cy:"7.4",r:"2.4"}),n.jsx("path",{d:"M7.4 2.8v1M2.8 7.4h1M4.2 4.2l.7.7M10.6 4.2l-.7.7"}),n.jsx("path",{d:"M7.8 16.8h6.4a2.9 2.9 0 0 0 .3-5.8 4 4 0 0 0-7.6 1.1 2.4 2.4 0 0 0 .9 4.7Z"})]})],cloud:[20,1.6,n.jsx("path",{d:"M6 15.6h8.2a3.3 3.3 0 0 0 .4-6.6 4.6 4.6 0 0 0-8.9 1A2.8 2.8 0 0 0 6 15.6Z"})],rain:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7.2 14.6l-.8 2M10.4 14.6l-.8 2M13.6 14.6l-.8 2"})]})],drizzle:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7 15.2v.3M10 16.4v.3M13 15.2v.3"})]})],snow:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M7.4 14.4v2.4M6.2 15.6h2.4M12.6 14.4v2.4M11.4 15.6h2.4"})]})],storm:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6 12.2h8.2a3 3 0 0 0 .4-6 4.3 4.3 0 0 0-8.3.9A2.6 2.6 0 0 0 6 12.2Z"}),n.jsx("path",{d:"M10.8 13.2 9 15.6h2.4l-1.8 2.6"})]})],fog:[20,1.6,n.jsx("path",{d:"M3.6 7.2h12.8M5.2 10.2h9.6M3.6 13.2h12.8M6.4 16.2h7.2"})],wind:[20,1.6,n.jsx("path",{d:"M3 8h9.4a2.2 2.2 0 1 0-2.2-2.2M3 12h11.6a2.2 2.2 0 1 1-2.2 2.2M3 10h5.4"})],"moon-clear":[20,1.6,n.jsx("path",{d:"M15.8 12.2A6.2 6.2 0 0 1 7.8 4.2a6.2 6.2 0 1 0 8 8Z"})],"moon-cloud":[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M9.4 6.8A3.6 3.6 0 0 1 4.6 2a3.6 3.6 0 1 0 4.8 4.8Z"}),n.jsx("path",{d:"M7.8 16.8h6.4a2.9 2.9 0 0 0 .3-5.8 4 4 0 0 0-7.6 1.1 2.4 2.4 0 0 0 .9 4.7Z"})]})],clock:[20,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),n.jsx("path",{d:"M10 5.8V10l2.8 1.8"})]})],dot:[20,1.6,n.jsx("circle",{cx:"10",cy:"10",r:"2.2"})],camera:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.6 6.2a1.4 1.4 0 0 1 1.4-1.4h2l1.1-1.6h2.8l1.1 1.6h2a1.4 1.4 0 0 1 1.4 1.4v6.4a1.4 1.4 0 0 1-1.4 1.4H4a1.4 1.4 0 0 1-1.4-1.4z"}),n.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,n.jsx("path",{d:"M13.2 8 8.4 12.8a3 3 0 0 1-4.2-4.2l5.1-5.1a2 2 0 1 1 2.8 2.8l-5 5"})],mic:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"6.3",y:"2.4",width:"4.4",height:"7.6",rx:"2.2"}),n.jsx("path",{d:"M3.9 8.4a4.6 4.6 0 0 0 9.2 0M8.5 13v2"})]})],speaker:[17,1.5,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M2.8 6.6h2.4l3.4-2.8v9.4l-3.4-2.8H2.8z"}),n.jsx("path",{d:"M11.2 6.2a3.2 3.2 0 0 1 0 4.6M13.2 4.4a5.8 5.8 0 0 1 0 8.2"})]})],send:[16,1.8,n.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],check:[16,1.8,n.jsx("path",{d:"M3.5 8.4 6.6 11.4 12.5 4.8"})],close:[16,1.8,n.jsx("path",{d:"M4.5 4.5l7 7M11.5 4.5l-7 7"})],thought:[13,1.4,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),n.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,n.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],copy:[16,1.5,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"5.6",y:"5.6",width:"7.6",height:"7.6",rx:"1.4"}),n.jsx("path",{d:"M10.4 5.6V4a1.2 1.2 0 0 0-1.2-1.2H4A1.2 1.2 0 0 0 2.8 4v5.2A1.2 1.2 0 0 0 4 10.4h1.6"})]})],play:[16,1.5,n.jsx("path",{d:"M5.2 3.4v9.2L12.6 8z"})],pause:[16,1.5,n.jsx("path",{d:"M5.6 3.6v8.8M10.4 3.6v8.8"})],stop:[16,1.5,n.jsx("rect",{x:"4.2",y:"4.2",width:"7.6",height:"7.6",rx:"1.2"})],download:[16,1.5,n.jsx("path",{d:"M8 2.8v7.2M4.9 7 8 10.1 11.1 7M3 12.8h10"})],out:[12,1.6,n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),n.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,n.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,n.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,n.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],grip:[16,0,n.jsxs("g",{fill:"currentColor",stroke:"none",children:[n.jsx("circle",{cx:"6",cy:"4",r:"1.2"}),n.jsx("circle",{cx:"10",cy:"4",r:"1.2"}),n.jsx("circle",{cx:"6",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"10",cy:"8",r:"1.2"}),n.jsx("circle",{cx:"6",cy:"12",r:"1.2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1.2"})]})],more:[16,0,n.jsxs("g",{fill:"currentColor",stroke:"none",children:[n.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})],drop:[28,1.8,n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),n.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})],folder:[20,1.6,n.jsx("path",{d:"M2.8 5.6a1.4 1.4 0 0 1 1.4-1.4h3.4l1.7 1.9h6.5a1.4 1.4 0 0 1 1.4 1.4v7.3a1.4 1.4 0 0 1-1.4 1.4H4.2a1.4 1.4 0 0 1-1.4-1.4Z"})],"chevron-down":[14,1.4,n.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),n.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),n.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,n.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,n.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,n.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,n.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-tiles":[16,1.4,n.jsx("path",{d:"M2.4 3.4h4.8v4.2H2.4zM8.8 3.4h4.8v4.2H8.8zM2.4 9.2h4.8v4.2H2.4zM8.8 9.2h4.8v4.2H8.8z"})],"shape-document":[16,1.4,n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,n.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 11l3.6-3.4 2.6 2.4 2-1.8 3.4 3M10.6 6.2h.01"})],"shape-preview":[16,1.4,n.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM2.2 6h11.6M4.1 4.7h.01M6 4.7h.01"})],"shape-envelope":[16,1.4,n.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],moon:[16,1.5,n.jsx("path",{d:"M12.9 9.7A5.3 5.3 0 0 1 6.3 3.1a5.3 5.3 0 1 0 6.6 6.6z"})],"shape-structured":[16,1.4,n.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function ue({name:e,size:t,className:s,...r}){const[i,a,l,o]=c4[e],c=t??o??i;return n.jsx("svg",{className:s,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:l})}const hE="buddi.rosterCollapsed";function u4(){try{return window.localStorage.getItem(hE)==="1"}catch{return!1}}function d4(e){try{window.localStorage.setItem(hE,e?"1":"0")}catch{}}function fE({agents:e,currentId:t,attention:s,onSelect:r,orientation:i="vertical",lastActivity:a,working:l,groups:o=[],currentGroupId:c=null,onSelectGroup:u,onNewGroup:h}){const f=[...e.top,...e.middle,...e.bottom],m=i==="vertical"?"right":"bottom",[p,g]=d.useState(u4),x=b=>n.jsx(h4,{agent:b,active:b.id===t,attention:s.get(b.id),side:m,onSelect:r,lastAt:(a==null?void 0:a.get(b.id))??null,working:(l==null?void 0:l.has(b.id))??!1},b.id);return n.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&p?"true":void 0,children:[e.top.map(x),e.top.length>0&&e.middle.length>0?n.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!p&&e.middle.length>0?n.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,n.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(x),u&&uE(f)?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsxs("div",{className:"wb-groups-head",children:[n.jsx("span",{className:"wb-groups-label",children:"Groups"}),h?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:h,children:n.jsx(ue,{name:"plus"})}):null]}),o.map(b=>n.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":b.id===c?"true":void 0,"aria-current":b.id===c?"true":void 0,"aria-label":`${b.name}, ${b.members.length} agents`,onClick:()=>u(b.id),children:[n.jsx("span",{className:"wb-group-stack","aria-hidden":"true",children:b.members.slice(0,2).map(j=>{const v=f.find(w=>w.id===j);return n.jsx(Wh,{className:"wb-group-chip",id:j,name:(v==null?void 0:v.name)??"?",face:v,initials:1},j)})}),n.jsxs("span",{className:"wb-face-text",children:[n.jsx("span",{className:"wb-face-name",children:b.name}),n.jsx("span",{className:"wb-face-status",children:b.members.map(j=>{var v;return((v=f.find(w=>w.id===j))==null?void 0:v.name)??j}).join(", ")})]})]},b.id))]}):u?n.jsxs("div",{className:"wb-groups","data-testid":"group-rail-hint",children:[n.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),n.jsx("div",{className:"wb-groups-head",children:n.jsx("span",{className:"wb-groups-label",children:"Groups"})}),n.jsxs("p",{className:"wb-groups-hint",children:["A group needs two agents; ",n.jsx("a",{href:Et,children:"add a teammate"}),"."]})]}):null]}),e.bottom.map(x),i==="vertical"?n.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":p?"Show agent names":"Hide agent names","aria-pressed":p,onClick:()=>g(b=>(d4(!b),!b)),children:n.jsx(ue,{name:p?"chevron-right":"chevron-left"})}):null]})}function h4({agent:e,active:t,attention:s,side:r,onSelect:i,lastAt:a=null,working:l=!1}){const o=Uh(s),c=XF(s)??(e.available?a?ZD(a):e.description:e.unavailableReason??"Cannot run right now"),u=JF(s,l&&e.available),h=e.unavailableReason??"This agent cannot run on this machine right now.",f=[`${e.name} @${e.handle}`,e.available?null:"unavailable",o,u==="working"?"working now":null,t?"current":null].filter(m=>m!==null&&m!=="").join(" — ");return n.jsxs(Ko,{children:[n.jsx(Vo,{asChild:!0,children:n.jsxs("button",{className:"wb-face",...Cc(Sc(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":f,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[n.jsxs("span",{className:"wb-face-frame",children:[n.jsx(Wh,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),u?n.jsx("span",{className:"wb-face-dot","data-state":u,"data-testid":`agent-dot-${e.id}`,"aria-hidden":"true"}):null]}),n.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[n.jsx("span",{className:"wb-face-name",children:e.name}),n.jsx("span",{className:"wb-face-status","data-tone":o?"critical":void 0,children:c})]}),e.available?null:n.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:n.jsx(ue,{name:"out"})})]})}),n.jsx(Go,{children:n.jsxs(Yo,{className:"ui-tip",side:r,sideOffset:8,children:[n.jsx("span",{className:"ui-tip-title",children:e.name}),n.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:h}),o?n.jsx("span",{className:"ui-tip-alert",children:f4(o)}):null]})})]})}function f4(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function m4(e){let t=0;for(const s of e)t=(t*31+s.charCodeAt(0))%997;return t%6+1}const p4="modulepreload",g4=function(e,t){return new URL(e,t).href},Mb={},x4=function(t,s,r){let i=Promise.resolve();if(s&&s.length>0){const l=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),c=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(s.map(u=>{if(u=g4(u,r),u in Mb)return;Mb[u]=!0;const h=u.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!r)for(let g=l.length-1;g>=0;g--){const x=l[g];if(x.href===u&&(!h||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${f}`))return;const p=document.createElement("link");if(p.rel=h?"stylesheet":p4,h||(p.as="script"),p.crossOrigin="",p.href=u,c&&p.setAttribute("nonce",c),document.head.appendChild(p),h)return new Promise((g,x)=>{p.addEventListener("load",g),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function a(l){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=l,window.dispatchEvent(o),!o.defaultPrevented)throw l}return i.then(l=>{for(const o of l||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})},v4="buddi",j4=["core","coding","finance","garage","mail","maker","playground","research"],ca=e=>`./mascot/${e}.png`,w4=["core"],ug=(e,t)=>w4.includes(e)?`./mascot/anim/${e}-${t}.json`:null,y4=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],b4="Introduce yourself by name and say one thing you can do today.",k4=["Hello","A brain","What I take on","Reach me","Your assistant"],Xl=(e,t=!1)=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")}${t&&e.length>2?", and ":" and "}${e[e.length-1]}`,em=e=>e.charAt(0).toUpperCase()+e.slice(1),N4=["No","One","Two","Three","Four","Five","Six","Seven","Eight"],Ya=[{id:"days",title:"My days",plugins:"Weather · Calendar",line:"Weather and your calendars. A morning brief from Planner.",mate:"Planner",note:"Weather needs nothing. Calendar asks for your calendar’s private link later, on its own page."},{id:"mail",title:"My mail",plugins:"Mail Triage (built in)",line:"Mail Triage reads new mail and brings you only what needs you.",mate:"Mail Triage",note:"Mail asks for a mailbox in chapter 4."},{id:"money",title:"My money",plugins:"Finance",line:"Accounts, cards and cash flow. Ledger answers “can I afford this?”.",mate:"Ledger",note:"Finance asks for your bank on its own page."},{id:"voice",title:"Voice",plugins:"Speech",line:"Talk to me and hear me back, here and on your phone. Runs on this computer.",note:"Speech needs nothing."},{id:"code",title:"My code",plugins:"Developer",line:"Developer works in one folder you name, and shows you what it changed.",mate:"Developer",note:"Developer asks for its folder the first time you talk."},{id:"pictures",title:"Pictures",plugins:"Image",line:"Illustrator makes one image from a prompt, with an account you pick.",mate:"Illustrator",note:"Image asks which account to draw with."}],S4=["days","mail"],Db=[{id:"buddi",role:"core",label:"Blue"},{id:"mail",role:"mail",label:"Orange"},{id:"finance",role:"finance",label:"Green"},{id:"coding",role:"coding",label:"Violet"},{id:"research",role:"research",label:"Purple"}],L={tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",chapters:k4,mapNotes:["Two minutes. Everything can be changed later in Settings, and nothing leaves this computer until you say so.","One line decides which company sees your assistant’s conversations. You can add more brains later and give each agent its own.","Each choice installs a plugin from withbuddi.com and proposes an agent for it. Only plugins made by buddi are installed for you; you can remove any of them later.","All three are optional. The mailbox is what “My mail” needs; the phone is how I reach you when you are away.","The persona is a plain text file the assistant grows over time. Keep it, rewrite it, or let Agent Father write one after an interview."],count:e=>`Chapter ${e} of 5`,back:"Back",change:"change",later:"Set up later",startOver:{link:"Start over",said:e=>`Starting again. What you already connected stays in Settings: ${e}.`,telegram:"Telegram",browser:"the browser"},strip:(e,t)=>`${e} · ${t}`,hello:{title:"Hi. I’m buddi.",opening:["I live on this computer and I’m about to introduce you to your first assistant. Nothing you tell me leaves this machine, except what your assistant sends to the AI you pick next.","First, what should we call you, and what time is it where you are?"],foot:"Your agents use your name in every reply, and your clock for reminders and the morning brief.",submit:"That’s me",answer:e=>e},name:{label:"Your first name",placeholder:"Sam"},clock:{label:"Your clock",hint:e=>`What this browser says. ${e} right now.`,change:"Change"},brain:{title:"Which AI should your team think with?",ask:"Pick what you already have. I test it with one small call before we go on.",submit:"Use this brain",cards:{free:{title:"Free to start, no key",line:"Ollama Cloud, one tap. Good enough to meet your assistant today.",pill:"Recommended to begin"},claude:{title:"I pay for Claude",line:"Sign in with your Claude account. Uses its extra usage."},chatgpt:{title:"I pay for ChatGPT",line:"Sign in with a code on openai.com. Uses your plan."},key:{title:"I have an API key",line:"Anthropic, OpenAI, Google AI, or another service with an address."},local:{title:"On this computer",line:"Free and private. Looking on this computer…"}},keyKinds:{label:"Which key",key:"Anthropic or OpenAI",gemini:"Google AI",service:"Another service"},claude:{label:"Claude",start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in on the claude.ai page that just opened, then paste the code Claude shows you."},chatgpt:{label:"ChatGPT",codeBefore:"Here is your code: ",codeAfter:". Type it on the openai.com page that just opened and approve buddi. I’ll notice.",code:"Your code",open:"Open openai.com",again:"Try again",failed:"The sign-in did not finish. Try again."},cloud:{label:"Ollama Cloud",waiting:"Press Connect on the ollama.com page that just opened. Sign in there first if it asks. I’ll notice.",open:"Open the ollama.com page",again:"Try again"},gemini:{label:"Gemini",field:"Your Google AI key",placeholder:"Paste it here",submit:"Use this key",get:"Get a key at aistudio.google.com"},key:{field:"Your key",placeholder:"Paste it here",hint:"I can tell which AI it belongs to from the key. It stays on this computer.",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},local:{looking:"Free and private. Looking on this computer…",found:e=>{const t=r=>r===1?"one model":`${r} models`;return`Free and private. I found ${[e.ollama!==void 0?`Ollama with ${t(e.ollama)}`:null,e.mlxh!==void 0?`mlxh with ${t(e.mlxh)}`:null].filter(Boolean).join(" and ")}; the first answer takes a minute.`},missing:"Nothing local answered; Ollama or mlxh, once installed, shows here."},mlxh:{label:"mlxh",connect:"Use mlxh",noBrain:"mlxh has no language model installed. Pull one with `mlxh pull`, then come back."},ollama:{label:"Ollama",connect:"Use Ollama",download:"Get Ollama"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one",retry:"Try again",change:"Think with another"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking the first model one small question. It can take a minute.",cloud:"Asking Ollama Cloud…",claude:"Checking with Claude…",chatgpt:"Asking ChatGPT…",gemini:"Asking Gemini…"},service:{label:"Another service",address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,worksOnFlash:e=>`That works. Google's free tier has no Pro allowance, so your assistant will think with ${e}; turn on billing at Google to use Pro.`,answer:e=>e},takeOn:{title:"What should I take on for you?",ask:"Pick a few. Each one brings a plugin and, for some, a teammate who owns that job. Skip this and I stay a plain assistant; you can add any of it later.",submit:"Take these on",none:"Just an assistant for now",nothing:"Nothing picked. I’ll be a plain assistant, and Home will offer these again.",builtIn:"Mail is built in.",nothingToFetch:"Nothing to fetch.",fetching:(e,t,s)=>`Fetching ${Xl(e)} from withbuddi.com and reading them. ${t} of ${s}.`,ready:e=>`${Xl(e)} ${e.length>1?"are":"is"} in, read and ready.`,failed:(e,t)=>`${e} did not come: ${t}.`,installing:(e,t)=>`Installing, ${e} of ${t} ready`,installed:"Installed",answer:e=>e.length===0?"Just an assistant":em(e.join(", ").toLowerCase())},reach:{title:"How do we reach each other?",ask:"Three things, each a minute. Do the ones you want; the rest wait in Settings.",submit:"Continue",phone:{title:"Your phone, through Telegram",line:"Scan the code with your phone and press Start. Approvals, voice notes and the morning brief land there.",setUp:"Set up Telegram",paired:"Paired",hello:"✓ That is your phone, talking to me. Approvals reach you there from now on."},mailbox:{title:"A mailbox",forTriage:"A mailbox, for Mail Triage",line:"Gmail, iCloud, Fastmail or any IMAP account. Reading only; sending always stops at a card you approve.",add:"Add a mailbox",sheet:"Add a mailbox",added:"Mailbox added",unavailable:"Mail is not ready on this computer yet. Settings → Mail can add one later."},app:{title:"buddi as an app, and a browser of its own",line:"Keep buddi in your Dock; give your assistant Chrome or its own Chromium (150 MB) so it can look at websites.",install:"Install app",installed:"App installed",chrome:"Use Chrome",chromium:"Use its Chromium",fetch:"Fetch a browser",ready:e=>e==="chrome"?"Chrome, ready":"Chromium, ready"},answer:e=>e.length===0?"Later, in Settings":em(e.join(", ")),done:{phone:"phone paired",mailbox:"mailbox added",app:"app and browser"}},browser:{chrome:"Your assistant will browse with Google Chrome.",chromium:"Your assistant will browse with its own Chromium.",needs:"Your assistant needs a browser of its own to look at websites. I am fetching one now, about 150 MB.",installing:"Fetching the browser…",launching:"Making sure it opens…",installed:"Installed.",failed:e=>`That did not work: ${e}`,retry:"Try again"},telegram:{sheet:"Your phone, through Telegram",how:"Two minutes: open Telegram, message @BotFather, send /newbot, paste the token it gives you here.",field:"The token",submit:"Save it",restart:"Saved. It will be ready the next time buddi starts.",scan:"Scan this with your phone and press Start.",expired:"That code has run out. I can make you another one.",newCode:"Show a new code",paired:"That is your phone, talking to me. You can close this and carry on.",close:"Done",notNow:"Not now"},assistant:{title:"Meet your assistant.",ask:"I’ve picked a name, a face and a way of working. Change any of it, or keep them.",team:e=>` Your team so far: ${Xl(e)}, waiting to be introduced.`,name:"Name",face:"A face",colour:"A colour for the face",swatch:e=>`Colour: ${e.toLowerCase()}`,mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"How it works",purposeHint:"Plain text. It becomes the assistant’s file, which is yours from then on.",purposeValue:["You're not a chatbot. You're becoming someone this person can count on.","","Some starting truths:","",`- Help for real. No "Great question", no "I'd be happy to". Do the thing, then say what you did.`,"- Have a view. Prefer things, disagree when you should, say when something is a bad idea. A search engine with manners is not a colleague.","- Look before you ask. Read the file, check what you remember, try it. Come back with an answer and one question at most.","- You are a guest here. You can see messages, files and a calendar. Treat that with care, keep what you learn to yourself, and never lecture.","- Remember what matters. Names, preferences, the things they said once and expect you to keep.","- When you change how you work, say so. This file is yours to grow, and the owner should always know what it says."].join(`
|
|
87
|
+
`),submit:"Introduce us"},restore:{offer:"I have a backup",sheet:"Restore from a backup",lede:"Pick the backup file buddi made and type its passphrase. Your agents, memory and settings come back as they were; this chapter map is skipped.",file:"Backup file",passphrase:"Passphrase",passphraseHint:"The one you typed when you turned backups on, if it was locked with one. I can’t recover it.",submit:"Restore",cancel:"Never mind",title:"Bringing your buddi back.",started:"Right. Give me a couple of minutes.",phases:{stopping:"Putting everything down for a moment.",snapshot:"Keeping a copy of what is here now, just in case.",database:"Bringing back your conversations and everything you told it to remember.",recovery:"Almost there. Nothing will run on its own until you say so.",files:"Bringing back your files.",starting:"Starting back up.",done:"That is everything.","rolled-back":"That did not work, so I put everything back the way it was.",failed:"That did not work."},welcome:e=>`Welcome back, ${e}.`,keys:"A backup never carries keys, so the AI you think with needs its key one more time."},handover:{waiting:"One moment.",looking:e=>`${e} is looking around…`,slow:"Still waking up. A brain on this computer takes a minute the first time.",silent:"Your assistant isn't answering. The AI you picked may be down; try again, or pick another brain.",again:"Pick another brain",starters:(e,t)=>[e.days?"What’s my day like?":"What can you do?",t.length>0?`Meet ${Xl(t)}`:"Show me around",e.days?"Link my calendar":e.mail&&!e.mailbox?"Add my mailbox":"What do you know about me?","Remind me at 9 tomorrow"],starterLabel:"Ask first",waitingTitle:e=>`${N4[e]??String(e)} ${e===1?"thing":"things"} still waiting.`,waitingBody:e=>`${em(Xl(e,!0))}. ${e.length>1?e.length===2?"Both are":"They are all":"It’s"} on Home whenever you like.`,home:"Open Home"},done:{open:"Open buddi"}};let fu=null;const Ob=new Map;function C4(){return fu??(fu=x4(()=>import("./lottie_light-Ls7i1ATS.js").then(e=>e.l),[],import.meta.url).then(e=>e.default)),fu.catch(()=>{fu=null}),fu}function E4(e){let t=Ob.get(e);return t||(t=fetch(e).then(s=>s.ok?s.text():null).catch(()=>null),Ob.set(e,t)),t}const Lb="(prefers-reduced-motion: reduce)";function mE(){const[e,t]=d.useState(()=>typeof window.matchMedia=="function"&&!window.matchMedia(Lb).matches);return d.useEffect(()=>{var i;if(typeof window.matchMedia!="function")return;const s=window.matchMedia(Lb),r=()=>t(!s.matches);return(i=s.addEventListener)==null||i.call(s,"change",r),()=>{var a;return(a=s.removeEventListener)==null?void 0:a.call(s,"change",r)}},[]),e}function Ec({role:e="core",state:t,size:s,still:r,className:i,onStillError:a}){const l=d.useRef(null),o=mE(),[c,u]=d.useState(!1),h=s==="xs"?null:ug(e,t);return d.useEffect(()=>{if(u(!1),!o||!h)return;let f=!1,m=null;return Promise.all([C4(),E4(h)]).then(([p,g])=>{if(f||!g||!l.current)return;const x=p.loadAnimation({container:l.current,renderer:"svg",loop:!0,autoplay:!document.hidden,animationData:JSON.parse(g),rendererSettings:{preserveAspectRatio:"xMidYMid meet"}}),b=()=>{document.hidden?x.pause():x.play()};document.addEventListener("visibilitychange",b),m=()=>{document.removeEventListener("visibilitychange",b),x.destroy()},u(!0)}).catch(()=>{}),()=>{f=!0,m==null||m()}},[o,h]),n.jsx("span",{ref:l,className:i?`ui-blob ${i}`:"ui-blob","data-size":s,"data-playing":c?"true":void 0,"data-testid":"blob","data-state":t,"aria-hidden":"true",children:c?null:n.jsx("img",{src:r??ca(e),alt:"",onError:a})})}async function _b(e){const t=new Image;t.src=e,await t.decode();const s=document.createElement("canvas");s.width=8,s.height=8;const r=s.getContext("2d");return r?(r.fillStyle="#fff",r.fillRect(0,0,8,8),r.drawImage(t,0,0,8,8),Array.from(r.getImageData(0,0,8,8).data)):null}function pE(e,t="core"){const s=mE(),r=e!==null&&A4(e,t),[i,a]=d.useState(!1);return d.useEffect(()=>{if(a(!1),!e||r||!s||!ug(t,"idle"))return;let l=!1;return Promise.all([_b(e),_b(ca(t))]).then(([o,c])=>{if(l||!o||!c||o.length!==c.length)return;const u=o.reduce((h,f,m)=>h+Math.abs(f-c[m]),0)/o.length;a(u<12)}).catch(()=>{}),()=>{l=!0}},[e,r,s,t]),s&&ug(t,"idle")!==null&&(r||i)}function A4(e,t){const s=ca(t);if(e===s)return!0;try{const r=typeof window>"u"?"http://localhost/":window.location.href;return new URL(e,r).href===new URL(s,r).href}catch{return!1}}function Wh({className:e,id:t,name:s,face:r,tint:i,size:a,unavailable:l,initials:o=2}){const[c,u]=d.useState(null),h=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,m=h?"image":f==null?void 0:f.kind,p=t?Cc(Sc({id:t,accent:r==null?void 0:r.accent,roles:r==null?void 0:r.roles,tools:r==null?void 0:r.tools})):void 0;return n.jsx("span",{className:e,"data-tint":p?void 0:i,"data-size":a,"data-kind":m,"data-unavailable":l?"true":void 0,...p,"aria-hidden":"true",children:h?n.jsx("img",{src:h,alt:"",onError:()=>u(h)}):(f==null?void 0:f.kind)==="image"?n.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:a4(s).slice(0,o)})}function zs({id:e,name:t,size:s,unavailable:r,face:i}){return n.jsx(Wh,{className:"ui-avatar",id:e,tint:m4(e),name:t,size:s,unavailable:r,face:i})}function gn({agents:e,id:t,size:s}){const r=e.find(i=>i.id===t);return n.jsx(zs,{id:t,name:(r==null?void 0:r.name)??t,size:s,unavailable:r?!r.available:!1,face:r})}const gE=d.createContext(null);function T4({picture:e,children:t}){return n.jsx(gE.Provider,{value:e??null,children:t})}function xE({size:e,anim:t}){const s=d.useContext(gE),[r,i]=d.useState(null),a=pE(t?s:null);return!s||s===r?null:n.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:t&&a?n.jsx(Ec,{state:t,still:s,className:"ui-mascot-blob",onStillError:()=>i(s)}):n.jsx("img",{src:s,alt:"",onError:()=>i(s)})})}const vE=d.createContext([]);function Lr({text:e,className:t}){const s=dg(e.replace(/\r\n/g,`
|
|
88
|
+
`).split(`
|
|
89
|
+
`));return n.jsx("div",{className:t??"wb-md",children:s.map((r,i)=>n.jsx(hg,{block:r},i))})}const Fb=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,zb=/^(#{1,6})\s+(.*?)\s*#*\s*$/,Ub=/^\s*([-*_])(\s*\1){2,}\s*$/,mu=/^(\s*)([-*+])\s+(.*)$/,Jl=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,pu=/^\s*>\s?(.*)$/,tm=/^\s*\|.*\|\s*$/,Bb=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function dg(e){const t=[];let s=0;for(;s<e.length;){const r=e[s];if(r.trim()===""){s+=1;continue}const i=Fb.exec(r);if(i){const o=i[2],c=[];for(s+=1;s<e.length&&!new RegExp(`^\\s*${o}\\s*$`).test(e[s]);)c.push(e[s]),s+=1;s+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
|
|
90
|
+
`)});continue}const a=zb.exec(r);if(a){t.push({type:"h",level:a[1].length,text:a[2]}),s+=1;continue}if(Ub.test(r)){t.push({type:"hr"}),s+=1;continue}if(pu.test(r)){const o=[];for(;s<e.length&&pu.test(e[s]);)o.push(pu.exec(e[s])[1]),s+=1;t.push({type:"quote",blocks:dg(o),raw:o.join(`
|
|
91
|
+
`)});continue}if(tm.test(r)&&s+1<e.length&&Bb.test(e[s+1])){const o=sm(r),c=sm(e[s+1]).map(h=>{const f=h.startsWith(":"),m=h.endsWith(":");return f&&m?"center":m?"right":f?"left":null});s+=2;const u=[];for(;s<e.length&&tm.test(e[s]);)u.push(sm(e[s])),s+=1;t.push({type:"table",head:o,rows:u,align:c});continue}if(mu.test(r)||Jl.test(r)){const o=Jl.exec(r)??mu.exec(r),c=Jl.test(r),u=o[1].length,h=c?Number(o[2]):1,f=[];for(;s<e.length;){const m=c?Jl.exec(e[s]):mu.exec(e[s]);if(!m||m[1].length!==u)break;const p=[m[3]];for(s+=1;s<e.length;){const g=e[s],x=g.trim()!==""&&nm(g)>u,b=g.trim()===""&&s+1<e.length&&e[s+1].trim()!==""&&nm(e[s+1])>u;if(!x&&!b)break;p.push(g.trim()===""?"":g.slice(Math.min(nm(g),u+2))),s+=1}f.push(dg(p))}t.push({type:"list",ordered:c,start:h,items:f});continue}const l=[];for(;s<e.length;){const o=e[s];if(o.trim()===""||Fb.test(o)||zb.test(o)||Ub.test(o)||pu.test(o)||mu.test(o)||Jl.test(o)||tm.test(o)&&s+1<e.length&&Bb.test(e[s+1]))break;l.push(o.trim()),s+=1}l.length>0&&t.push({type:"p",text:l.join(`
|
|
92
|
+
`)})}return t}function nm(e){return e.length-e.trimStart().length}function sm(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),s=[];let r="";for(let i=0;i<t.length;i+=1){const a=t[i];if(a==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(a==="|"){s.push(r.trim()),r="";continue}r+=a}return s.push(r.trim()),s}function hg({block:e}){switch(e.type){case"p":return n.jsx("p",{children:As(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),s=`h${Math.min(t+2,6)}`;return n.jsx(s,{className:"wb-md-h","data-level":t,children:As(e.text)})}case"code":return n.jsxs("div",{className:"wb-md-code-frame",children:[n.jsxs("div",{className:"wb-md-code-head",children:[n.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),n.jsx(Wb,{text:e.text,what:"code",always:!0})]}),n.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:n.jsx("code",{children:e.text})})]});case"quote":return n.jsxs("div",{className:"wb-md-copyable",children:[n.jsx("blockquote",{children:e.blocks.map((t,s)=>n.jsx(hg,{block:t},s))}),n.jsx(Wb,{text:e.raw,what:"quote"})]});case"hr":return n.jsx("hr",{});case"list":{const t=e.items.map((s,r)=>n.jsx("li",{children:s.map((i,a)=>i.type==="p"?n.jsx(d.Fragment,{children:As(i.text)},a):n.jsx(hg,{block:i},a))},r));return e.ordered?n.jsx("ol",{start:e.start,children:t}):n.jsx("ul",{children:t})}case"table":return n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table wb-md-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.head.map((t,s)=>n.jsx("th",{style:e.align[s]?{textAlign:e.align[s]}:void 0,children:As(t)},s))})}),n.jsx("tbody",{children:e.rows.map((t,s)=>n.jsx("tr",{children:t.map((r,i)=>n.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:As(r)},i))},s))})]})})}}function Wb({text:e,what:t,always:s=!1}){const[r,i]=d.useState("idle"),a=()=>{var l;if(!((l=navigator.clipboard)!=null&&l.writeText)){i("failed");return}navigator.clipboard.writeText(e).then(()=>i("done"),()=>i("failed")),window.setTimeout(()=>i("idle"),1500)};return n.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":s||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:a,children:r==="done"?"Copied":r==="failed"?"Select to copy":n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),n.jsx("path",{d:"M8.5 4.5V3a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4.5a1 1 0 0 0 1 1h1.5"})]})})}function R4({handle:e}){const s=d.useContext(vE).find(r=>r.handle.toLowerCase()===e.toLowerCase());return s?n.jsxs(Ko,{children:[n.jsx(Vo,{asChild:!0,children:n.jsxs("a",{className:"wb-mention-link",href:at(s.id),children:["@",s.handle]})}),n.jsx(Go,{children:n.jsxs(Yo,{className:"wb-agent-card",sideOffset:6,children:[n.jsx(zs,{id:s.id,name:s.name,face:s,unavailable:!s.available}),n.jsxs("span",{className:"wb-agent-card-text",children:[n.jsx("span",{className:"wb-agent-card-name",children:s.name}),n.jsx("span",{className:"wb-agent-card-desc",children:s.description}),n.jsxs("span",{className:"wb-agent-card-meta",children:[s.model,s.available?"":" · unavailable"]})]})]})})]}):n.jsxs(n.Fragment,{children:["@",e]})}const $4=new RegExp("(`+)([\\s\\S]*?[^`])\\1(?!`)|\\*\\*([^*]+?)\\*\\*|__([^_]+?)__|~~([^~]+?)~~|(?<![\\w*])\\*([^*\\n]+?)\\*(?![\\w*])|(?<![\\w_])_([^_\\n]+?)_(?![\\w_])|\\[([^\\]\\n]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)|<?(https?:\\/\\/[^\\s<>)\\]]+[^\\s<>)\\].,;:!?'\"])>?|(?<![\\w@/])@([a-z0-9][a-z0-9_-]{0,63})(?![\\w-])","i");function As(e){const t=[];let s=e,r=0;for(;s!=="";){const i=$4.exec(s);if(!i){t.push(...Hb(s,r));break}i.index>0&&t.push(...Hb(s.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(n.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(n.jsx("strong",{children:As(i[3])},r)):i[4]!==void 0?t.push(n.jsx("strong",{children:As(i[4])},r)):i[5]!==void 0?t.push(n.jsx("s",{children:As(i[5])},r)):i[6]!==void 0?t.push(n.jsx("em",{children:As(i[6])},r)):i[7]!==void 0?t.push(n.jsx("em",{children:As(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(n.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:As(i[8])},r)):i[10]!==void 0?t.push(n.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(n.jsx(R4,{handle:i[11]},r)),s=s.slice(i.index+i[0].length)}return t}function Hb(e,t){return e.split(`
|
|
93
|
+
`).flatMap((r,i)=>i===0?[r]:[n.jsx("br",{},`${t}-br-${i}`),r])}function I4({props:e}){return n.jsxs("div",{children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:Qt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?n.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?n.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:n.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?n.jsx("div",{className:"wb-doc",children:n.jsx(Lr,{text:e.text})}):n.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}const P4=["mail","money","calendar","people","file","chart","bell","plug","key","globe","sun","partly-cloudy","cloud","rain","drizzle","snow","storm","fog","wind","moon-clear","check","clock","moon-cloud"];function Ne(e,t){if(t===""||t==="$")return e;let s=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,a="",l=""]=i;if(a!==""){if(s===null||typeof s!="object")return;s=s[a]}for(const o of l.match(/\d+/g)??[]){if(!Array.isArray(s))return;s=s[Number(o)]}if(s===void 0)return}return s}function He(e,t){if(t)return"const"in t?t.const:Ne(e,t.path)}function qn(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function ut(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function ui(e){return Array.isArray(e)?e:[]}function M4(e,t){const s=ui(Ne(e,t.points)).map(i=>{const a=qn(Ne(i,t.y)),l=ut(Ne(i,t.x));return a===null||l===null?null:{x:l,y:a}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const a=qn(He(e,i.value));return a===null?null:{value:a,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:s,unit:t.unit??"number",currency:ut(He(e,t.currency)),label:ut(He(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:qn(He(e,t.shadeBelow)),events:D4(e,t)}}function D4(e,t){const s=t.events;if(!s)return[];const r=[],i=(a,l)=>{const o=ut(Ne(a,s.label));if(o===null)return;const c=ut(Ne(a,s.at))??l;c!==null&&r.push({at:c,label:o,amount:s.amount?qn(Ne(a,s.amount)):null})};if(s.parent){for(const a of ui(Ne(e,t.points))){const l=ut(Ne(a,t.x));for(const o of ui(Ne(a,s.parent)))i(o,l)}return r}for(const a of ui(Ne(e,s.path??t.points)))i(a,null);return r}function O4(e,t){const s=(t.columns??[]).map(o=>({key:o.key,label:o.label,type:o.type??"text"})),r=o=>(t.columns??[]).map(c=>{const u=Ne(o,c.key);let h=null;if(c.bar){const f=qn(He(o,c.bar.max))??qn(He(e,c.bar.max)),m=qn(u);if(f!==null&&f>0&&m!==null){const p=Math.max(0,Math.min(1,m/f));h={fraction:p,tone:_4(p*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:ut(He(o,c.currency))??ut(He(e,c.currency)),bar:h}}),i=ui(Ne(e,t.rows)),a=t.groupBy?L4(i,t.groupBy,r):[{label:null,rows:i.map(r)}],l=(t.summary??[]).map(o=>({label:o.label,value:He(e,o.value),unit:o.unit??"text",currency:ut(He(e,o.currency)),tone:o.tone??"neutral"}));return{columns:s,groups:a,summary:l,empty:t.empty??"Nothing to show."}}function L4(e,t,s){const r=new Map;for(const i of e){const a=String(Ne(i,t.key)??""),l=r.get(a);l?l.push(i):r.set(a,[i])}return[...r.entries()].map(([i,a])=>{var l;return{label:((l=t.labels)==null?void 0:l[i])??i,rows:a.map(s)}})}function _4(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,a)=>a.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function F4(e,t){return{bars:ui(Ne(e,t.bars)).map(r=>{const i=qn(Ne(r,t.value)),a=ut(Ne(r,t.category));return i===null||a===null?null:{category:a,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:ut(He(e,t.currency))}}function z4(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:He(e,r.value),unit:r.unit??"text",currency:ut(He(e,r.currency)),tone:r.tone??"neutral"}))};const s=Ne(e,t.from??"$");return s===null||typeof s!="object"||Array.isArray(s)?{pairs:[]}:{pairs:Object.entries(s).map(([r,i])=>({label:xn(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}const U4=new Set(["good","warning","critical","neutral","accent"]),B4=new Set(P4);function fg(e){return typeof e=="string"&&B4.has(e)?e:null}function Jv(e,t,s=""){const r=t.empty??"Nothing to show.",i=s.split(".")[0]??"";if(t.notice){const l=ut(Ne(e,t.notice.text));if(l!==null&&l.trim()!==""){const o=t.notice.link&&i!==""?{plugin:i,page:t.notice.link.page}:null;return{tiles:[{icon:fg(t.notice.icon??"bell"),value:"",label:l.trim(),lines:[],tone:"neutral",link:o}],notice:!0,empty:r}}}return{tiles:ui(Ne(e,t.items)).map(l=>{const o=ut(Ne(l,t.value))??"",c=ut(Ne(l,t.label))??"";if(o===""&&c==="")return null;const u=t.tone?ut(Ne(l,t.tone)):null;return{icon:fg(He(l,t.icon)),value:o,label:c,lines:(t.lines??[]).slice(0,2).map(h=>ut(Ne(l,h))).filter(h=>h!==null&&h.trim()!==""),tone:u!==null&&U4.has(u)?u:"neutral",link:null}}).filter(l=>l!==null),notice:!1,empty:r}}function W4(e,t){const s=ut(He(e,t.kind)),r=s==="image"||s==="pdf"?s:"text",i=t.src?ut(Ne(e,t.src)):null;return{kind:r,text:t.text?ut(Ne(e,t.text)):null,src:i&&wE(i)?i:null,title:ut(He(e,t.title)),metadata:(t.metadata??[]).map(a=>({label:a.label,value:He(e,a.value),unit:a.unit??"text"}))}}function H4(e,t){const s=t.diff?Ne(e,t.diff):void 0;return{diff:typeof s=="string"&&s.trim()!==""?s:null,title:ut(He(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:He(e,r.value),unit:r.unit??"text"}))}}function K4(e,t){const s=t.output?Ne(e,t.output):void 0,r=l=>{const o=l?Ne(e,l):void 0;return typeof o=="number"&&Number.isInteger(o)?o:null},i=r(t.omittedBytes),a=t.elapsedMs?Ne(e,t.elapsedMs):void 0;return{command:ut(He(e,t.command)),output:typeof s=="string"?s:null,exitCode:r(t.exitCode),elapsedMs:typeof a=="number"&&Number.isFinite(a)&&a>=0?a:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(l=>({label:l.label,value:He(e,l.value),unit:l.unit??"text"}))}}const V4=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function jE(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&V4.test(t)?t.toLowerCase():null}function G4(e,t){return{artifactId:t.src?jE(Ne(e,t.src)):null,title:ut(He(e,t.title)),caption:ut(He(e,t.caption)),...t.captionLabel?{captionLabel:ut(He(e,t.captionLabel))}:{}}}function Kb(e){if(!wE(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const s=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return s?{plugin:s[1],name:s[2]}:null}function Y4(e,t){const s=t.src?ut(Ne(e,t.src)):null,r=t.port?Ne(e,t.port):null,i=t.awaiting?ut(Ne(e,t.awaiting)):null;return{target:s?Kb(s):null,title:ut(He(e,t.title)),output:t.output?ut(Ne(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?Kb(i):null,reloadsItself:t.reloadsItself?Ne(e,t.reloadsItself)===!0:!1,ports:t.ports?q4(Ne(e,t.ports)):[]}}function q4(e){const t=ui(e).filter(s=>typeof s=="number"&&Number.isInteger(s)&&s>0&&s<=65535);return[...new Set(t)].sort((s,r)=>s-r)}function wE(e){return e.startsWith("/")&&!e.startsWith("//")}function xn(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function yE(e,t){const s=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:M4(t,s)};case"table":return{renderer:"table",props:O4(t,s)};case"bars":return{renderer:"bars",props:F4(t,s)};case"keyvalue":return{renderer:"keyvalue",props:z4(t,s)};case"tiles":return{renderer:"tiles",props:Jv(t,s,e.tool)};case"document":return{renderer:"document",props:W4(t,s)};case"diff":return{renderer:"diff",props:H4(t,s)};case"terminal":return{renderer:"terminal",props:K4(t,s)};case"image":return{renderer:"image",props:G4(t,s)};case"preview":return{renderer:"preview",props:Y4(t,s)};default:return{renderer:"structured",props:{value:t}}}}var Q4=Object.defineProperty,js=(e,t)=>Q4(e,"name",{value:t,configurable:!0}),Zv="Dialog",[bE,uQ]=_s(Zv),[X4,hr]=bE(Zv),Hh=js(e=>{const{__scopeDialog:t,children:s,open:r,defaultOpen:i,onOpenChange:a,modal:l=!0}=e,o=d.useRef(null),c=d.useRef(null),[u,h]=Ni({prop:r,defaultProp:i??!1,onChange:a,caller:Zv}),[f,m]=d.useState(0),[p,g]=d.useState(0);return n.jsx(X4,{scope:t,triggerRef:o,contentRef:c,contentId:$s(),titleId:$s(),descriptionId:$s(),titlePresent:f>0,descriptionPresent:p>0,setTitleCount:m,setDescriptionCount:g,open:u,onOpenChange:h,onOpenToggle:d.useCallback(()=>h(x=>!x),[h]),modal:l,children:s})},"Dialog"),J4="DialogTrigger",Z4=d.forwardRef(js(function(t,s){const{__scopeDialog:r,...i}=t,a=hr(J4,r),l=jt(s,a.triggerRef);return n.jsx(pt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":Yh(a.open),...i,ref:l,onClick:Pe(t.onClick,a.onOpenToggle)})},"DialogTrigger")),kE="DialogPortal",[ez,NE]=bE(kE,{forceMount:void 0}),Kh=js(e=>{const{__scopeDialog:t,forceMount:s,children:r,container:i}=e,a=hr(kE,t);return n.jsx(ez,{scope:t,forceMount:s,children:d.Children.map(r,l=>n.jsx(ur,{present:s||a.open,children:n.jsx(vh,{asChild:!0,container:i,children:l})}))})},"DialogPortal"),mg="DialogOverlay",ej=d.forwardRef(js(function(t,s){const r=NE(mg,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=hr(mg,t.__scopeDialog);return l.modal?n.jsx(ur,{present:i||l.open,children:n.jsx(nz,{...a,ref:s})}):null},"DialogOverlay")),tz=fi("DialogOverlay.RemoveScroll"),nz=d.forwardRef(js(function(t,s){const{__scopeDialog:r,...i}=t,a=hr(mg,r),l=iC(),o=jt(s,l);return n.jsx(Mv,{as:tz,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(pt.div,{"data-state":Yh(a.open),...i,ref:o,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),tc="DialogContent",Vh=d.forwardRef(js(function(t,s){const r=NE(tc,t.__scopeDialog),{forceMount:i=r.forceMount,...a}=t,l=hr(tc,t.__scopeDialog);return n.jsx(ur,{present:i||l.open,children:l.modal?n.jsx(sz,{...a,ref:s}):n.jsx(rz,{...a,ref:s})})},"DialogContent")),sz=d.forwardRef(js(function(t,s){const r=hr(tc,t.__scopeDialog),i=d.useRef(null),a=jt(s,r.contentRef,i);return d.useEffect(()=>{const l=i.current;if(l)return j1(l)},[]),n.jsx(SE,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Pe(t.onCloseAutoFocus,l=>{var o;l.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(t.onPointerDownOutside,l=>{const o=l.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&l.preventDefault()}),onFocusOutside:Pe(t.onFocusOutside,l=>l.preventDefault())})},"DialogContentModal")),rz=d.forwardRef(js(function(t,s){const r=hr(tc,t.__scopeDialog),i=d.useRef(!1),a=d.useRef(!1);return n.jsx(SE,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var o,c;(o=t.onCloseAutoFocus)==null||o.call(t,l),l.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),l.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:l=>{var u,h;(u=t.onInteractOutside)==null||u.call(t,l),l.defaultPrevented||(i.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=l.target;((h=r.triggerRef.current)==null?void 0:h.contains(o))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})},"DialogContentNonModal")),SE=d.forwardRef(js(function(t,s){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:l,...o}=t,c=hr(tc,r);return $h(),n.jsx(n.Fragment,{children:n.jsx(t1,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:l,children:n.jsx(xh,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":Yh(c.open),...o,ref:s,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),iz="DialogTitle",Gh=d.forwardRef(js(function(t,s){const{__scopeDialog:r,...i}=t,a=hr(iz,r),{setTitleCount:l}=a;return Ln(()=>(l(o=>o+1),()=>l(o=>o-1)),[l]),n.jsx(pt.h2,{id:a.titleId,...i,ref:s})},"DialogTitle")),az="DialogClose",tj=d.forwardRef(js(function(t,s){const{__scopeDialog:r,...i}=t,a=hr(az,r);return n.jsx(pt.button,{type:"button",...i,ref:s,onClick:Pe(t.onClick,()=>a.onOpenChange(!1))})},"DialogClose"));function Yh(e){return e?"open":"closed"}js(Yh,"getState");const lz=5;function ce(e,t,s){const[r,i]=d.useState(void 0),[a,l]=d.useState(null),[o,c]=d.useState(!0),[u,h]=d.useState(0),[f,m]=d.useState(0),p=d.useRef(e);return p.current=e,d.useEffect(()=>{let g=!1;return c(!0),p.current().then(x=>{g||(i(x),l(null),m(0))}).catch(x=>{g||(l(x instanceof me?x.message:String(x)),m(b=>b+1))}).finally(()=>{g||c(!1)}),()=>{g=!0}},[...t,u]),d.useEffect(()=>{if(!s||f>=lz)return;const g=window.setTimeout(()=>h(x=>x+1),s*2**f);return()=>window.clearTimeout(g)},[s,f,u]),{data:r,error:a,loading:o,reload:()=>{m(0),h(g=>g+1)}}}const CE={width:480,height:160,top:10,right:10,bottom:22,left:40},EE={width:1200,height:180,top:10,right:40,bottom:22,left:40};function oz({xs:e,series:t}){const s=EE,r=s.width-s.left-s.right,i=s.height-s.top-s.bottom,a=U=>U.filter(A=>A!==null&&Number.isFinite(A)),l=t.filter(U=>U.type!=="bar"),o=t.filter(U=>U.type==="bar"),c=l.flatMap(U=>a(U.values)),u=c.length>0?Math.min(...c):0,h=c.length>0?Math.max(...c):1;let f=u,m=h;if(f===m)f-=1,m+=1;else{const U=(m-f)*.08;f-=U,m+=U}const p=U=>ds(s.top+i-(U-f)/(m-f)*i),g=o.length>0&&o.every(U=>U.unit==="percent"),x=g?100:Math.max(1,...o.flatMap(U=>a(U.values))),b=U=>ds(s.top+i-Math.max(0,U)/x*i),j=e.length,v=j>0?r/j:r,w=U=>ds(s.left+v*(U+.5)),y=t.map(U=>{if(U.type==="bar")return"";let A="M";const P=[];return U.values.forEach((D,O)=>{if(D===null||!Number.isFinite(D)){A="M";return}P.push(`${A}${w(O)},${p(D)}`),A="L"}),P.join(" ")}),N=[],k=v*.6/Math.max(1,o.length),S=s.height-s.bottom;let C=0;t.forEach((U,A)=>{if(U.type!=="bar")return;const P=C++;U.values.forEach((D,O)=>{if(D===null||!Number.isFinite(D)||D<=0)return;const M=b(D);N.push({series:A,index:O,x:ds(w(O)-v*.3+k*P),y:M,width:ds(k),height:ds(S-M)})})});const $=c.length>0?$d(u,h,2).map(U=>({value:U,y:p(U)})):[],R=o.length===0?[]:(g?[0,50,100]:$d(0,x,2)).map(U=>({value:U,y:b(U),percent:g})),I=Math.max(1,Math.ceil(j/8)),z=e.flatMap((U,A)=>A%I===0?[{index:A,x:w(A)}]:[]);return{lines:y,bars:N,targetY:null,ticks:$,xLabels:z,rightTicks:R}}function cz({xs:e,series:t,type:s="line",target:r=null}){const i=CE,a=i.width-i.left-i.right,l=i.height-i.top-i.bottom,o=t.flatMap(w=>w.values.filter(y=>y!==null&&Number.isFinite(y)));r!==null&&Number.isFinite(r)&&o.push(r),s==="bar"&&o.push(0);let c=o.length>0?Math.min(...o):0,u=o.length>0?Math.max(...o):1;if(c===u)c-=1,u+=1;else if(s==="line"){const w=(u-c)*.08;c-=w,u+=w}const h=w=>ds(i.top+l-(w-c)/(u-c)*l),f=e.length,m=f>0?a/f:a,p=w=>ds(s==="bar"?i.left+m*(w+.5):i.left+(f<=1?a/2:w/(f-1)*a)),g=s==="line"?t.map(w=>{let y="M";const N=[];return w.values.forEach((k,S)=>{if(k===null||!Number.isFinite(k)){y="M";return}N.push(`${y}${p(S)},${h(k)}`),y="L"}),N.join(" ")}):[],x=[];if(s==="bar"&&f>0){const w=m*.7,y=w/Math.max(1,t.length),N=h(0);t.forEach((k,S)=>{k.values.forEach((C,$)=>{if(C===null||!Number.isFinite(C))return;const R=h(C);x.push({series:S,index:$,x:ds(i.left+m*$+(m-w)/2+y*S),y:Math.min(R,N),width:ds(y),height:ds(Math.abs(N-R))})})})}const j=(o.length>0?$d(Math.min(...o),Math.max(...o),2):[]).map(w=>({value:w,y:h(w)})),v=f===0?[]:f===1?[0]:f<5?[0,f-1]:[0,Math.floor((f-1)/2),f-1];return{lines:g,bars:x,targetY:r!==null&&Number.isFinite(r)?h(r):null,ticks:j,xLabels:v.map(w=>({index:w,x:p(w)}))}}function uz(e){const t=e.formatX??(o=>o),s=e.formatY??(o=>String(o)),r=e.xs.length;if(r===0)return`${e.label??"Chart"}: nothing recorded yet.`;const i=r===1?`on ${t(e.xs[0])}`:`from ${t(e.xs[0])} to ${t(e.xs[r-1])}`,a=e.series.map(o=>{const c=o.values.filter(h=>h!==null&&Number.isFinite(h));if(c.length===0)return`${o.label}: no values`;const u=c[c.length-1];return`${o.label}: latest ${s(u)}, lowest ${s(Math.min(...c))}, highest ${s(Math.max(...c))}`}),l=e.target!==null&&e.target!==void 0&&Number.isFinite(e.target)?` Target ${s(e.target)}.`:"";return`${e.label??"Chart"}, ${r} ${r===1?"point":"points"} ${i}. ${a.join("; ")}.${l}`}function dz({xs:e,series:t,type:s="line",target:r=null,label:i,formatX:a=o=>o,formatY:l=o=>String(o)}){const o=s==="mixed",c=o?EE:CE,u=o?oz({xs:e,series:t}):cz({xs:e,series:t,type:s,target:r}),h=uz({xs:e,series:t,target:r,...i?{label:i}:{},formatX:a,formatY:l});return n.jsxs("figure",{className:"ui-chart","data-type":s,children:[n.jsxs("svg",{viewBox:`0 0 ${c.width} ${c.height}`,"aria-hidden":"true",focusable:"false","data-testid":"chart-svg",children:[u.ticks.map(f=>n.jsxs("g",{children:[n.jsx("line",{className:"ui-chart-grid",x1:c.left,x2:c.width-c.right,y1:f.y,y2:f.y}),n.jsx("text",{x:c.left-6,y:f.y,textAnchor:"end",dominantBaseline:"middle",children:l(f.value)})]},f.value)),(u.rightTicks??[]).map(f=>n.jsx("text",{x:c.width-c.right+6,y:f.y,textAnchor:"start",dominantBaseline:"middle",children:f.percent?`${f.value}%`:l(f.value)},`r-${f.value}`)),n.jsx("line",{className:"ui-chart-axis",x1:c.left,x2:c.width-c.right,y1:c.height-c.bottom,y2:c.height-c.bottom}),u.bars.map(f=>n.jsx("rect",{className:"ui-chart-bar","data-series":f.series,x:f.x,y:f.y,width:f.width,height:f.height},`${f.series}-${f.index}`)),u.lines.map((f,m)=>f?n.jsx("path",{className:"ui-chart-line","data-series":m,d:f},m):null),u.targetY!==null?n.jsx("line",{className:"ui-chart-target","data-testid":"chart-target",x1:c.left,x2:c.width-c.right,y1:u.targetY,y2:u.targetY}):null,u.xLabels.map(f=>n.jsx("text",{x:f.x,y:c.height-6,textAnchor:o?"middle":u.xLabels.length>1&&f.index===0?"start":f.index===e.length-1&&e.length>1?"end":"middle",children:a(e[f.index])},f.index))]}),n.jsx("figcaption",{className:"sr-only",children:h}),t.length>1?n.jsx("ul",{className:"ui-chart-legend","aria-hidden":"true",children:t.map((f,m)=>n.jsx("li",{"data-series":m,"data-type":o?f.type??"line":void 0,children:f.label},f.label))}):null]})}function ds(e){return Math.round(e*10)/10}const nj="(max-width: 900px)";function Ps(e){const[t,s]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var a;let r;try{r=window.matchMedia(e)}catch{return}const i=l=>s(l.matches);return(a=r.addEventListener)==null||a.call(r,"change",i),()=>{var l;return(l=r.removeEventListener)==null?void 0:l.call(r,"change",i)}},[e]),t}function Ei(...e){return e.filter(Boolean).join(" ")}function T({variant:e,size:t,className:s,type:r="button",...i}){return n.jsx("button",{type:r,className:Ei("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Tt({variant:e,size:t,className:s,...r}){return n.jsx("a",{className:Ei("ui-btn",s),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function le({children:e,align:t,valign:s,className:r}){return n.jsx("div",{className:Ei("ui-toolbar",r),"data-align":t,"data-valign":s,children:e})}function _t(){return n.jsx("span",{className:"ui-toolbar-spacer"})}function ie({label:e,hint:t,inline:s,grow:r,wide:i,group:a,action:l,after:o,children:c}){const u=d.useId();return n.jsxs("div",{className:"ui-field","data-inline":s?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[l?n.jsxs("div",{className:"ui-field-row",children:[n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),l]}):a?n.jsxs("div",{className:"ui-field-control",role:"group","aria-labelledby":u,children:[n.jsx("span",{className:"ui-field-label",id:u,children:e}),c]}):n.jsxs("label",{className:"ui-field-control",children:[n.jsx("span",{className:"ui-field-label",children:e}),c]}),t?n.jsx("span",{className:"ui-field-hint",children:t}):null,o]})}function Os({children:e,dense:t,columns:s}){return n.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,"data-columns":s===3?"3":void 0,children:e})}function ve({tone:e,mono:t,dot:s,children:r,className:i,title:a}){return n.jsxs("span",{className:Ei("ui-pill",t&&"mono",i),"data-tone":e,title:a,children:[s?n.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function pg({children:e}){return n.jsx("span",{className:"ui-tag",children:e})}function Ac({state:e}){const t=e==="succeeded"||e==="approved"||e==="fired"||e==="running"||e==="leased"?"good":e==="failed"||e==="rejected"||e==="unknown"||e==="error"||e==="refused"?"critical":e==="pending"||e==="suspended"||e==="expired"||e==="paused"?"warning":void 0;return n.jsx(ve,{tone:t,children:e})}function V({tone:e,title:t,children:s,role:r,action:i}){return i?n.jsx("div",{className:"ui-notice","data-tone":e,role:r,children:n.jsxs("div",{className:"ui-notice-row",children:[n.jsxs("div",{className:"ui-notice-body",children:[t?n.jsx("div",{className:"ui-notice-title",children:t}):null,s]}),i]})}):n.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?n.jsx("div",{className:"ui-notice-title",children:t}):null,s]})}function ae({message:e}){return e?n.jsx(V,{tone:"critical",role:"alert",children:e}):null}function xe({mascot:e,warm:t,title:s,action:r,children:i}){return t||s?n.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[s?n.jsx("div",{className:"ui-empty-title",children:s}):null,n.jsx("div",{children:i}),r]}):e?n.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[n.jsx(xE,{size:"sm"}),n.jsx("p",{children:i})]}):n.jsx("p",{className:"ui-empty",children:i})}function jn({icon:e,title:t,action:s,children:r}){return n.jsxs("div",{className:"ui-empty-state",children:[e?n.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?n.jsx(ue,{name:e}):e}):null,n.jsx("div",{className:"ui-empty-state-title",children:t}),r?n.jsx("p",{className:"ui-empty-state-line",children:r}):null,s?n.jsx("div",{className:"ui-empty-state-action",children:s}):null]})}function hz({children:e}){return n.jsx("div",{className:"ui-page",children:e})}function nc({title:e,lede:t,actions:s,before:r}){return n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[r,n.jsx("span",{children:e})]}),s?n.jsx("div",{className:"ui-page-actions",children:s}):null]}),t?n.jsx("p",{className:"ui-page-lede",children:t}):null]})}function An({embedded:e,title:t,lede:s,actions:r,children:i}){return e?n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):n.jsxs(hz,{children:[n.jsx(nc,{title:t,lede:s,actions:r}),i]})}function oe({title:e,aside:t,actions:s,panel:r,flush:i,foot:a,children:l}){const o=e||t||s?n.jsxs("div",{className:"ui-section-head",children:[e?n.jsx("h3",{className:"ui-section-title",children:e}):n.jsx("span",{}),t||s?n.jsxs("div",{className:"ui-section-side",children:[t?n.jsx("span",{className:"ui-section-aside",children:t}):null,s?n.jsx("div",{className:"ui-section-actions",children:s}):null]}):null]}):null;return n.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[o,r?n.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[l,a?n.jsx("div",{className:"ui-panel-foot",children:a}):null]}):n.jsxs(n.Fragment,{children:[l,a?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:a}):null]})]})}function qe({title:e,tool:t,actions:s,flush:r,children:i}){return n.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||s?n.jsxs("header",{className:"ui-panel-head",children:[e?n.jsx("h3",{className:"ui-panel-title",children:e}):n.jsx("span",{}),t?n.jsx("span",{className:"ui-panel-tool",children:t}):null,s?n.jsx("div",{className:"ui-panel-actions",children:s}):null]}):null,i]})}function ws({tone:e,title:t,meta:s,actions:r,children:i,foot:a,onClick:l,label:o,as:c="div"}){const u=l?{"data-interactive":"true",tabIndex:0,"aria-label":o,onClick:l,onKeyDown:h=>{h.target!==h.currentTarget||h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),l())}}:{};return n.jsxs(c,{className:"ui-card","data-tone":e,...u,children:[t||s||r?n.jsxs("div",{className:"ui-card-head",children:[t?n.jsx("h3",{className:"ui-card-title",children:t}):null,s,r?n.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,a?n.jsx("div",{className:"ui-card-foot",children:a}):null]})}function re({gap:e,divided:t,children:s}){return n.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:s})}function fz({children:e}){return n.jsx("div",{className:"ui-row",children:e})}function qh({inline:e,children:t}){return n.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function tr({label:e,value:t,note:s,tone:r,size:i}){return n.jsxs("div",{className:"ui-stat",children:[n.jsx("div",{className:"ui-stat-k",children:e}),n.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),s?n.jsx("div",{className:"ui-stat-n",children:s}):null]})}function Wt({items:e}){return n.jsx("dl",{className:"ui-kv",children:e.map((t,s)=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{children:t.value})]},t.key??s))})}function vs({children:e}){return n.jsx("div",{className:"ui-table-wrap",children:n.jsx("table",{className:"ui-table",children:e})})}function AE({value:e,label:t}){const s=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return n.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s,"aria-valuetext":`${s}%`,children:n.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${s}%`}})})}function Pt({children:e,label:t}){return n.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function St({summary:e,boxed:t,open:s,className:r,onToggle:i,children:a}){return n.jsxs("details",{className:Ei("ui-details",r),"data-boxed":t?"true":void 0,open:s,onToggle:i?l=>i(l.currentTarget.open):void 0,children:[n.jsx("summary",{children:e}),a]})}function ht({title:e,onClose:t,size:s,foot:r,children:i}){return n.jsx(Hh,{open:!0,onOpenChange:a=>{a||t()},children:n.jsxs(Kh,{children:[n.jsx(ej,{className:"ui-sheet-overlay"}),n.jsxs(Vh,{className:"ui-sheet","data-size":s,"aria-describedby":void 0,children:[n.jsxs("div",{className:"ui-sheet-head",children:[n.jsx(Gh,{className:"ui-sheet-title",children:e}),n.jsx(tj,{asChild:!0,children:n.jsx(T,{size:"sm",children:"Close"})})]}),i,r?n.jsx("div",{className:"ui-sheet-foot",children:r}):null]})]})})}function un({title:e,onClose:t,foot:s,children:r}){return n.jsx(Hh,{open:!0,onOpenChange:i=>{i||t()},children:n.jsxs(Kh,{children:[n.jsx(ej,{className:"ui-sheet-overlay","data-layer":"modal"}),n.jsxs(Vh,{className:"ui-modal",role:"alertdialog","aria-describedby":void 0,children:[n.jsx(Gh,{className:"ui-modal-title",children:e}),r,s?n.jsx("div",{className:"ui-modal-foot",children:s}):null]})]})})}function Cl({label:e,items:t,note:s,trigger:r,sheet:i}){const a=Ps(mz);return i&&a&&!r?n.jsx(pz,{label:e,items:t,title:i.title,sub:i.sub}):n.jsx(gz,{label:e,items:t,note:s,trigger:r})}const mz="(max-width: 720px)";function pz({label:e,items:t,title:s,sub:r}){const[i,a]=d.useState(!1);return n.jsxs(Hh,{open:i,onOpenChange:a,children:[n.jsx(Z4,{asChild:!0,children:n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":e,title:e,onClick:l=>l.stopPropagation(),children:n.jsx(ue,{name:"more"})})}),n.jsxs(Kh,{children:[n.jsx(ej,{className:"ui-sheet-overlay",onClick:l=>l.stopPropagation()}),n.jsxs(Vh,{className:"ui-action-sheet","aria-describedby":void 0,onClick:l=>l.stopPropagation(),children:[n.jsxs("div",{className:"ui-action-sheet-head",children:[n.jsx(Gh,{className:"ui-action-sheet-title",children:s}),r?n.jsx("span",{className:"ui-action-sheet-sub",children:r}):null]}),n.jsx("div",{className:"ui-menu ui-action-sheet-list",role:"menu",children:t.map((l,o)=>l?l==="separator"?n.jsx("div",{className:"ui-menu-sep",role:"separator"},`sep-${o}`):"heading"in l?n.jsx("div",{className:"ui-menu-label",children:l.heading},`head-${o}`):n.jsxs("button",{type:"button",role:"menuitem",className:"ui-menu-item","data-tone":l.tone,onClick:()=>{a(!1),l.onSelect()},children:[n.jsx("span",{children:l.label}),l.hint?n.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},o):null)}),n.jsx(tj,{asChild:!0,children:n.jsx(T,{className:"ui-action-sheet-cancel",children:"Cancel"})})]})]})]})}function gz({label:e,items:t,note:s,trigger:r}){const i=l=>l.stopPropagation(),a=d.useRef(!1);return n.jsxs(bc,{modal:!1,onOpenChange:l=>{l&&(a.current=!1)},children:[n.jsx(kc,{asChild:!0,children:r??n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":e,title:e,onClick:i,children:n.jsx(ue,{name:"more"})})}),n.jsx(Nl,{children:n.jsxs(Nc,{className:"ui-menu",align:"end",sideOffset:4,onClick:i,onKeyDown:i,onCloseAutoFocus:l=>{a.current&&l.preventDefault()},children:[s?n.jsx(ta,{className:"ui-menu-label",children:s}):null,t.map((l,o)=>l?l==="separator"?n.jsx(Nr,{className:"ui-menu-sep"},`sep-${o}`):"heading"in l?n.jsx(ta,{className:"ui-menu-label",children:l.heading},`head-${o}`):n.jsxs(us,{className:"ui-menu-item","data-tone":l.tone,onSelect:()=>{a.current=!0,l.onSelect()},children:[n.jsx("span",{children:l.label}),l.hint?n.jsx("span",{className:"ui-menu-item-hint",children:l.hint}):null]},o):null)]})})]})}function xz({title:e,actions:t,onClose:s,onCloseAutoFocus:r,onOpenAutoFocus:i,label:a,children:l}){return n.jsx(Hh,{open:!0,modal:!1,onOpenChange:o=>{o||s()},children:n.jsx(Kh,{children:n.jsxs(Vh,{className:"ui-dock","aria-describedby":void 0,...a?{"aria-label":a}:{},onInteractOutside:o=>o.preventDefault(),...r?{onCloseAutoFocus:r}:{},...i?{onOpenAutoFocus:i}:{},children:[n.jsxs("div",{className:"ui-dock-head",children:[n.jsx(Gh,{className:"ui-dock-title",children:e}),n.jsxs("div",{className:"ui-dock-actions",children:[t,n.jsx(tj,{asChild:!0,children:n.jsx(T,{size:"sm",variant:"ghost",children:"Close"})})]})]}),n.jsx("div",{className:"ui-dock-body",children:l})]})})})}function Tc({level:e,label:t,children:s}){return n.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:s})}function ll({href:e,active:t,count:s,onClick:r,children:i}){return n.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,s?n.jsx("span",{className:"ui-count",children:s}):null]})}function rn({label:e,options:t,value:s,onChange:r}){return n.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>n.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===s,onClick:()=>r(i.value),children:i.label},i.value))})}function dt({children:e}){return n.jsx("div",{className:"ui-list",children:e})}function it({href:e,onClick:t,lead:s,title:r,sub:i,side:a,dimmed:l,label:o}){const c=n.jsxs(n.Fragment,{children:[s,n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:r}),i?n.jsx("span",{className:"ui-list-sub",children:i}):null]}),a?n.jsx("span",{className:"ui-list-side",children:a}):null]}),u=l?"true":void 0;return e?n.jsx("a",{className:"ui-list-row","data-dimmed":u,href:e,onClick:t?h=>{h.preventDefault(),t()}:void 0,children:c}):t?n.jsx("div",{className:"ui-list-row","data-interactive":"true","data-dimmed":u,tabIndex:0,"aria-label":o,onClick:t,onKeyDown:h=>{h.target!==h.currentTarget||h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),t())},children:c}):n.jsx("div",{className:"ui-list-row","data-dimmed":u,children:c})}function TE({href:e,onClick:t,current:s,lead:r,title:i,meta:a,sub:l,snippet:o,side:c}){return n.jsxs("a",{className:"ui-pick",href:e,"aria-current":s?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?n.jsx("span",{className:"ui-pick-lead",children:r}):null,n.jsxs("span",{className:"ui-pick-main",children:[n.jsxs("span",{className:"ui-pick-top",children:[n.jsx("span",{className:"ui-pick-title",children:i}),a?n.jsx("span",{className:"ui-pick-meta",children:a}):null]}),l||c?n.jsxs("span",{className:"ui-pick-line",children:[l?n.jsx("span",{className:"ui-pick-sub",children:l}):null,c?n.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,o?n.jsx("span",{className:"ui-pick-snippet",children:o}):null]})]})}function RE({list:e,detail:t,empty:s,label:r,className:i}){return n.jsxs("div",{className:Ei("ui-split",i),"data-open":t?"true":void 0,children:[n.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),n.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??n.jsx("p",{className:"ui-empty ui-split-empty",children:s})})]})}function Md({children:e,onRemove:t,label:s,disabled:r}){return n.jsxs("span",{className:"ui-chip",children:[e,n.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${s}`,onClick:t,disabled:r,children:"×"})]})}const vz=8;function jz({label:e,options:t,value:s,onChange:r,max:i,disabled:a,id:l}){const[o,c]=d.useState(!1),[u,h]=d.useState(""),[f,m]=d.useState(0),p=d.useRef(null),g=d.useRef(null),x=d.useRef(null),b=d.useRef(null),j=d.useId(),v=A=>{var P;return((P=t.find(D=>D.value===A))==null?void 0:P.label)??A},w=i!==void 0&&s.length>=i,y=t.filter(A=>!s.includes(A.value)),N=t.length>vz,k=u.trim().toLowerCase(),S=k===""?y:y.filter(A=>A.label.toLowerCase().includes(k)),C=Math.min(f,Math.max(0,S.length-1)),$=A=>{var P;c(!1),h(""),m(0),A&&((P=g.current)==null||P.focus())};d.useEffect(()=>{var P;if(!o)return;(P=N?x.current:b.current)==null||P.focus();const A=D=>{p.current&&!p.current.contains(D.target)&&$(!1)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[o,N]);const R=A=>{const P=[...s,A];r(P),h(""),m(0);const D=i!==void 0&&P.length>=i;(D||P.length>=t.length)&&$(!D)},I=A=>{if(A.key==="Escape")A.preventDefault(),$(!0);else if(A.key==="ArrowDown")A.preventDefault(),m(S.length===0?0:(C+1)%S.length);else if(A.key==="ArrowUp")A.preventDefault(),m(S.length===0?0:(C-1+S.length)%S.length);else if(A.key==="Enter"){A.preventDefault();const P=S[C];P&&R(P.value)}else A.key==="Backspace"&&u===""&&s.length>0&&(A.preventDefault(),r(s.slice(0,-1)))},z=A=>`${j}-${A}`,U=o&&S.length>0?z(C):void 0;return n.jsxs("div",{className:"ui-chippicker",ref:p,id:l,children:[s.map(A=>n.jsx(Md,{label:v(A),disabled:a,onRemove:()=>r(s.filter(P=>P!==A)),children:v(A)},A)),n.jsxs("div",{className:"ui-chippicker-add",children:[n.jsx("button",{ref:g,type:"button",className:"ui-btn","data-size":"sm","data-variant":"ghost","aria-haspopup":"listbox","aria-expanded":o,"aria-controls":o?j:void 0,disabled:a||w||y.length===0,onClick:()=>o?$(!1):c(!0),children:"Add…"}),o?n.jsxs("div",{className:"ui-menu ui-chippicker-menu",onKeyDown:I,children:[N?n.jsx("input",{ref:x,type:"search",className:"ui-chippicker-filter","aria-label":`Filter ${e}`,"aria-controls":j,"aria-activedescendant":U,value:u,onChange:A=>{h(A.target.value),m(0)}}):null,n.jsxs("div",{ref:b,id:j,role:"listbox","aria-multiselectable":"true","aria-label":e,"aria-activedescendant":N?void 0:U,tabIndex:N?-1:0,className:"ui-chippicker-list",children:[S.map((A,P)=>n.jsx("div",{id:z(P),role:"option","aria-selected":"false",className:"ui-menu-item","data-highlighted":P===C?"":void 0,onMouseEnter:()=>m(P),onMouseDown:D=>D.preventDefault(),onClick:()=>R(A.value),children:A.label},A.value)),S.length===0?n.jsx("p",{className:"ui-menu-empty",children:"Nothing matches"}):null]})]}):null]})]})}function wz({label:e,options:t,value:s,onChange:r}){return n.jsx("div",{className:"ui-filter-chips",role:"group","aria-label":e,children:t.map(i=>n.jsx("button",{type:"button",className:"ui-btn ui-filter-chip","data-size":"sm","aria-pressed":i.value===s,onClick:()=>r(i.value),children:i.label},i.value))})}function $E({label:e,value:t,onChange:s,placeholder:r,grow:i}){return n.jsx("span",{className:"ui-search","data-grow":i?"true":void 0,children:n.jsx("input",{type:"search","aria-label":e,value:t,placeholder:r,onChange:a=>s(a.target.value)})})}function _r({svg:e,icon:t="plug",letter:s,size:r}){return n.jsx("span",{className:"ui-app-icon","data-size":r,"data-tone":e||s?"accent":void 0,"aria-hidden":"true",children:e?n.jsx("span",{className:"ui-app-icon-svg",dangerouslySetInnerHTML:{__html:e}}):s?n.jsx("span",{className:"ui-app-icon-letter",children:s}):n.jsx(ue,{name:t})})}function gg({items:e,label:t="Where this is",inline:s}){const r=e.map((i,a)=>{const l=i.key??String(a);if(i.current)return n.jsx("span",{className:"ui-crumb","aria-current":"page",children:i.label},l);const o=i.href?n.jsx("a",{className:"ui-crumb",href:i.href,onClick:i.onClick?c=>{var u;c.preventDefault(),(u=i.onClick)==null||u.call(i)}:void 0,children:i.label}):n.jsx("button",{type:"button",className:"ui-crumb",onClick:i.onClick,children:i.label});return n.jsxs("span",{className:"ui-crumb-step",children:[o,n.jsx(ue,{name:"chevron-right",size:12})]},l)});return s?n.jsx("span",{className:"ui-crumbs","aria-label":t,children:r}):n.jsx("nav",{className:"ui-crumbs","aria-label":t,children:r})}function IE({main:e,filters:t,filtersOpen:s,onToggleFilters:r,active:i,chips:a,actions:l,onSubmit:o,label:c}){return n.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),o()},children:[n.jsxs("div",{className:"ui-searchbar-row",children:[e?n.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?n.jsxs(T,{"aria-expanded":s===!0,"aria-pressed":s===!0,onClick:r,children:["Filters",i?n.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?n.jsx("div",{className:"ui-searchbar-inline",children:t}):null,l?n.jsx("div",{className:"ui-searchbar-actions",children:l}):null]}),t&&r&&s?n.jsx("div",{className:"ui-searchbar-filters",children:t}):null,a?n.jsx("div",{className:"ui-searchbar-chips",children:a}):null]})}function sc({size:e}){return n.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function PE({quiet:e,still:t,className:s,children:r}){return n.jsx("div",{className:Ei("ui-fieldbg",s),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function yz({dock:e,className:t,children:s}){return n.jsxs("div",{className:Ei("ui-float",t),children:[n.jsx("div",{className:"ui-float-body",children:s}),e?n.jsx("div",{className:"ui-float-dock",children:e}):null]})}function bz(e){const t={};for(const s of e??[])t[s.key]=s.default;return t}function sj(e){const[t,s]=d.useState({}),r=e??[],i={...bz(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:n.jsx("div",{className:"ui-choices",children:r.map(a=>n.jsx(ie,{label:a.label,inline:!0,children:n.jsx("select",{value:i[a.key],onChange:l=>s(o=>({...o,[a.key]:l.target.value})),children:a.options.map(l=>n.jsx("option",{value:l,children:l},l))})},a.key))})}}function kz({props:e,timezone:t="UTC",onDecided:s}){var w;const[r,i]=d.useState(null),[a,l]=d.useState(null),[o,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let y=!1;return i(null),l(null),E.approval(e.approvalId).then(N=>{y||i(N)}).catch(N=>{y||l(N instanceof me?N.message:String(N))}),()=>{y=!0}},[e.approvalId]);const{values:f,controls:m}=sj(r==null?void 0:r.choices),p=(y,N)=>{h(y),l(null),(f&&y==="approve"?E.decide(e.approvalId,y,N,f):E.decide(e.approvalId,y,N)).then(k=>{i(k.action),s==null||s(k.action)}).catch(k=>l(k instanceof me?k.message:String(k))).finally(()=>h(null))};if(a&&!r)return n.jsx("p",{className:"wb-empty",children:a});if(!r)return n.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const g=r.state==="pending",x=(w=r.permissionScopes)==null?void 0:w.includes("always"),b=Nz(r),j=(r.preview??"").split(`
|
|
94
|
+
`).length>12||(r.preview??"").length>900,v=[r.decidedBy?`by ${r.decidedBy}`:"",r.decidedVia?`via ${r.decidedVia}`:""].filter(Boolean).join(" ");return n.jsxs("div",{className:"wb-envelope",children:[n.jsxs("div",{className:"envelope",children:[n.jsxs("dl",{className:"envelope-head",children:[n.jsx("dt",{children:"Action"}),n.jsx("dd",{className:"wb-envelope-action",children:r.tool.split(".").map(y=>xn(y)).join(" · ")}),n.jsx("dt",{children:"Status"}),n.jsxs("dd",{children:[g?n.jsx(ve,{tone:"warning",dot:!0,children:"waiting for you"}):n.jsx(Ac,{state:r.state}),!g&&v?n.jsxs("span",{className:"wb-envelope-note",children:[" ",v]}):null]}),n.jsx("dt",{children:g?"Expires":"Decided"}),n.jsx("dd",{children:et(g?r.expiresAt:r.decidedAt,t)})]}),n.jsxs("div",{className:"envelope-body","data-clamp":j&&!o?"true":void 0,children:[r.preview||"(this tool wrote no preview)",j&&!o?n.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]})]}),n.jsx(ae,{message:a}),g?m:null,g?n.jsxs("div",{className:"wb-envelope-decide",children:[n.jsx("p",{className:"wb-envelope-note",children:x?"Auto and Always also approve later calls to this tool in that scope; you can take it back on the agent's Tools tab.":"This runs the action exactly as shown above."}),n.jsxs("div",{className:"wb-envelope-buttons",children:[n.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>p("reject"),children:u==="reject"?"Rejecting…":"Reject"}),x?n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>p("approve","conversation"),children:"Auto: this conversation"}),n.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>p("approve","always"),children:"Always: this agent"})]}):null,n.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>p("approve"),children:u==="approve"?"Approving…":x?"Allow once":"Approve"})]})]}):null,n.jsxs("details",{className:"ui-details",children:[n.jsx("summary",{children:"The envelope, field by field"}),n.jsx("dl",{className:"ui-kv wb-envelope-fields",children:b.map(y=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:y.label}),y.block?n.jsx("dd",{className:"wb-envelope-block",children:n.jsx("pre",{className:"mono",children:y.value})}):n.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function Nz(e){const t=[],s=e.envelope;if(s!==null&&typeof s=="object"&&!Array.isArray(s))for(const[i,a]of Object.entries(s))t.push(Vb(xn(i),a));else s!=null&&t.push({label:"Envelope",value:rj(s)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,a]of Object.entries(r)){const l=`Argument · ${xn(i)}`;t.some(o=>o.label===l)||t.push(Vb(l,a))}return t.push({label:"Action id",value:e.id,mono:!0},{label:"Tool version",value:e.toolVersion,mono:!0},{label:"Agent",value:e.agentId,mono:!0},{label:"Args hash",value:e.argsHash,mono:!0},{label:"Policy version",value:String(e.policyVersion)}),e.conversationId&&t.push({label:"Conversation",value:e.conversationId,mono:!0}),e.jobId&&t.push({label:"Job",value:e.jobId,mono:!0}),t}function Vb(e,t){return t!==null&&typeof t=="object"&&(!Array.isArray(t)||t.some(r=>r!==null&&typeof r=="object"))?{label:e,value:JSON.stringify(t,null,2),block:!0}:{label:e,value:rj(t)}}function rj(e){return e==null?"—":Array.isArray(e)?e.map(t=>rj(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):Qt(e,"text",null)}const Sz=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Cz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Dd(e){const t=e!==null&&typeof e=="object"?e.artifacts:null;return Array.isArray(t)?t.flatMap(s=>{if(s===null||typeof s!="object")return[];const r=s;return typeof r.id!="string"||!Cz.test(r.id)?[]:[{type:"attachment",artifactId:r.id,filename:typeof r.filename=="string"?r.filename:null,mime:typeof r.mime=="string"?r.mime:"application/octet-stream",kind:typeof r.kind=="string"?r.kind:"other",sizeBytes:null}]}):[]}function ij(e){return Sz.has(e.toLowerCase())}function Fr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function vi(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function Fn(e){return e==null||!Number.isFinite(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function aj(e,t){const s=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return s.startsWith("image/")?"image":s==="application/pdf"?"pdf":s.startsWith("audio/")?"audio":s.startsWith("video/")?"video":s==="text/csv"||s==="text/tab-separated-values"||s.includes("spreadsheet")||s.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":s.includes("zip")||s.includes("tar")||s.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":s==="application/json"||s.includes("javascript")||s.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":s.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Vi={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Yu(e){return`artifact:${e}`}function Ez(e){const t=aj(e.mime,e.filename);return{id:Yu(e.artifactId),tool:Vi[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function Az({props:e}){const t=jE(e.artifactId),[s,r]=d.useState(null),[i,a]=d.useState(null),[l,o]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let h=!0;return r(null),a(null),o(!1),E.libraryEntry(t).then(f=>{h&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{h=!1}},[t]),t===null)return n.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(s==null?void 0:s.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,s!=null&&s.sizeBytes?Fn(s.sizeBytes):null].filter(h=>h!==null);return n.jsxs("figure",{className:"wb-image",children:[n.jsx("div",{className:"wb-image-frame",children:l?n.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):n.jsx("a",{href:Fr(t),className:"wb-image-link",title:"Open at full size",children:n.jsx("img",{src:Fr(t),alt:e.caption??c,onLoad:h=>{const f=h.currentTarget;f.naturalWidth>0&&a({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>o(!0)})})}),n.jsxs("figcaption",{className:"wb-image-caption",children:[n.jsxs(le,{children:[n.jsx("span",{className:"wb-image-name",children:c}),u.length>0?n.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(Tt,{size:"sm",href:vi(t),download:(s==null?void 0:s.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?n.jsx(St,{summary:e.captionLabel,className:"wb-image-note",children:n.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?n.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function Tz({props:e}){return e.pairs.length===0?n.jsx("p",{className:"wb-empty",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:Qt(t.value,t.unit,t.currency)})]},t.label))})}const Rz=8;function ME({text:e,label:t="Output",className:s}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const a=r.current;a&&i.current&&(a.scrollTop=a.scrollHeight)},[e]),n.jsx("pre",{ref:r,className:s?`wb-terminal-body ${s}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:a=>{const l=a.currentTarget;i.current=l.scrollHeight-l.scrollTop-l.clientHeight<=Rz},children:e})}function $z(e){if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?1:0)} s`;const s=Math.floor(t/60);return`${s} min ${Math.round(t-s*60)} s`}function Iz({text:e}){const[t,s]=d.useState("");return n.jsxs(n.Fragment,{children:[t?n.jsx("span",{role:"status",className:"wb-hint",children:t}):null,n.jsx(T,{size:"sm",onClick:()=>{var r;if(s(""),!((r=navigator.clipboard)!=null&&r.writeText)){s("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>s("Copied"),()=>s("Copy failed; select the text to copy."))},children:"Copy"})]})}function Pz({props:e}){const t=e.output??"";return n.jsxs("div",{className:"wb-terminal",children:[n.jsxs(le,{className:"wb-terminal-head",children:[e.command!==null?n.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?n.jsxs(ve,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?n.jsx("span",{className:"wb-terminal-fact",children:$z(e.elapsedMs)}):null,n.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?n.jsx(Iz,{text:t}):null]}),e.omittedBytes!==null?n.jsxs("p",{className:"wb-terminal-note",children:["First ",Fn(e.omittedBytes)," not shown."]}):null,t!==""?n.jsx(ME,{text:t}):n.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?n.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(s=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:s.label}),n.jsx("dd",{children:Qt(s.value,s.unit,null)})]},s.label))}):null]})}function Mz(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function Gb(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function Dz(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((s,r)=>s-r)}function Oz({props:e}){var N;const[t,s]=d.useState(null),[r,i]=d.useState(null),[a,l]=d.useState(null),[o,c]=d.useState(!1),u=((N=e.target)==null?void 0:N.plugin)??null,h=Dz(e),[f,m]=d.useState(null),p=f!==null&&h.includes(f)?f:e.port,g=e.target?p!==null&&p!==e.port?`${e.target.name}.${p}`:e.target.name:null,x=e.changes??0,b=d.useRef(x),[j,v]=d.useState(0);d.useEffect(()=>{x<=b.current||(b.current=x,e.reloadsItself||v(k=>k+1))},[x,e.reloadsItself]),d.useEffect(()=>{if(u===null||g===null)return;let k=!0;return s(null),i(null),l(null),v(0),E.previewLink(u,g).then(S=>{k&&(s(S.url),i(Gb(S.url)))}).catch(S=>{k&&l(S instanceof Error?S.message:"That preview could not be opened.")}),()=>{k=!1}},[u,g]);const w=()=>{u===null||g===null||E.previewLink(u,g).then(k=>i(k.url)).catch(()=>{})};if(e.target===null)return n.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",n.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const y=!(e.output===null||e.output==="");return n.jsxs("div",{className:"wb-preview","data-output":o||void 0,children:[n.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?n.jsx("h4",{className:"wb-doc-title",children:e.title}):null,h.length>1?n.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:p??"",onChange:k=>m(Number(k.target.value)),children:h.map(k=>n.jsxs("option",{value:k,children:[":",k]},k))}):null,y?n.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":o,onClick:()=>c(k=>!k),children:o?"Hide output":"Output"}):null,r?n.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:w,onFocus:w,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,p!==null&&Mz()?n.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${p}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",p]}):null]}),n.jsxs("div",{className:"wb-preview-body",children:[t?n.jsx("iframe",{className:"wb-preview-frame",src:j===0?t:Gb(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},j):n.jsx("p",{className:"wb-empty wb-preview-frame",children:a??"Opening the preview…"}),y&&o?n.jsx(ME,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const Lz=50,_z=9,Fz=24,zz=.6,Uz=48,Bz=/(amount|total|balance|price|cost|paid|pay|payment|net|spend|spent|due|limit|owed|fee|income|charge|burn|minimum|principal|interest|worth|cash|debt|deposit|credit|debit|value|revenue|budget|floor|avg|mean|median)/i,Wz=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,Hz=/^id$|(^|[a-z0-9])Id$|_id$/;function La(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Gn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function DE(...e){for(const t of e)if(Gn(t))for(const s of["currency","currencyCode"]){const r=t[s];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function OE(e,t,s){const r=t.filter(i=>i!=null&&i!=="");return r.length===0?"text":r.every(i=>typeof i=="boolean")?"boolean":r.every(i=>typeof i=="number"&&Number.isFinite(i))?s!==null&&Bz.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&Wz.test(i))?"date":"text"}function Kz(e,t){if(!Hz.test(e))return!1;const s=t.filter(r=>!El(r));return s.length<2?!1:new Set(s.map(r=>String(r))).size===s.length}function El(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:Gn(e)?Object.keys(e).length===0:!1}function Yb(e,t){const s=e.filter(Gn);if(s.length===0||s.length/e.length<.8)return null;const r=s.slice(0,Lz),i=new Map,a=[];for(const h of r)for(const f of Object.keys(h))i.has(f)||a.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>Fz||[...i.values()].reduce((h,f)=>h+f,0)/(i.size*r.length)<zz)return null;const o=[...i.keys()].sort((h,f)=>{const m=(i.get(f)??0)-(i.get(h)??0);return m!==0?m:a.indexOf(h)-a.indexOf(f)}),c=[],u=[];for(const h of o){const f=r.map(x=>x[h]),m=f.filter(x=>!El(x));if(m.length===0||Kz(h,f))continue;const p=DE(r[0],t),g=OE(h,f,p);if(r.length>=4&&m.length===f.length&&f.every(x=>La(x)&&x===f[0])){u.push({label:xn(h),value:f[0],type:g,currency:p});continue}if(c.push({key:h,label:xn(h),type:g,currency:g==="currency"?p:null}),c.length===_z)break}return c.length===0?null:{columns:c,rows:s,constants:u}}function Vz(e,t,s){const r=DE(s);return{label:xn(e),value:t,type:OE(e,[t],r),currency:r}}function LE(e){return typeof e=="string"&&e.length>Uz}function Gz(e){return e==null?"This tool returned nothing.":typeof e=="string"&&e.trim()===""?"This tool returned an empty string.":Array.isArray(e)&&e.length===0?"This tool returned no items.":Gn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function xg(e){if(typeof e=="string"&&e.trim()!=="")return e;if(Gn(e))for(const t of["message","error","reason","detail","description"]){const s=e[t];if(typeof s=="string"&&s.trim()!=="")return s;if(Gn(s)){const r=xg(s);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function lj(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const m=JSON.parse(e.replace(/^tool-error:\s*/,""));Gn(m)&&(f=m)}catch{}return{kind:"error",summary:xg(f),detail:qb(f)}}if(Gn(e)){const f=e.error,m=e.ok;if(typeof f=="string"&&f.trim()!==""||m===!1)return{kind:"error",summary:xg(e),detail:qb(e)}}const s=Gz(e);if(s)return{kind:"empty",note:s,stats:[]};if(Array.isArray(e)){const f=Yb(e,e);return f?{kind:"table",label:null,columns:f.columns,rows:f.rows,total:f.rows.length,stats:f.constants,notes:[],asides:[]}:e.every(La)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!Gn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,a=null;for(const[f,m]of r){if(!Array.isArray(m))continue;const p=Yb(m,e);if(p){(!i||p.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:p});continue}m.length>0&&m.every(La)&&(!a||m.length>a.items.length)&&(a={key:f,items:m})}const l=(i==null?void 0:i.key)??(a==null?void 0:a.key)??null,o=[],c=[],u=[];for(const[f,m]of r)if(f!==l){if(LE(m)){c.push(m);continue}if(La(m)){if(m==="")continue;o.push(Vz(f,m,e));continue}m!==void 0&&u.push({label:xn(f),value:m})}if(i)return{kind:"table",label:xn(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...o,...i.candidate.constants],notes:c,asides:u};if(a)return{kind:"list",label:xn(a.key),items:a.items,total:a.items.length,stats:o,notes:c,asides:u};const h=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return h.length>0&&h.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${h.map(([m])=>xn(m).toLowerCase()).join(", ")} to show.`,stats:o}:r.every(([,f])=>La(f)||Gn(f)||Array.isArray(f))?{kind:"record",pairs:o,notes:c,asides:u}:{kind:"tree",value:e}}function qb(e){if(!Gn(e))return null;const t=Object.entries(e).filter(([s])=>s!=="message"&&s!=="error");return t.length===0?null:Object.fromEntries(t)}const Od=25,Yz=3,vg=8,_E=6;function jg(e,t=0){if(t>_E||El(e)||LE(e))return 0;if(La(e))return 1;if(Array.isArray(e)){let s=0;for(const r of e)if(s+=jg(r,t+1),s>=vg)return s;return s}if(Gn(e)){let s=0;for(const r of Object.values(e))if(s+=jg(r,t+1),s>=vg)return s;return s}return 0}function wg(e,t=0){if(t>_E)return!1;if(Array.isArray(e))return e.some(a=>wg(a,t+1));if(!Gn(e))return!1;const s=e.artifactId??e.artifact_id;if(typeof s=="string"&&s.trim()!=="")return!0;const r=e.mime??e.mimeType??e.contentType,i=e.url??e.src??e.downloadUrl??e.path;return typeof r=="string"&&r.includes("/")&&typeof i=="string"&&i.trim()!==""?!0:Object.values(e).some(a=>wg(a,t+1))}function qz(e){if(wg(e))return!0;const t=lj(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=Yz;case"record":case"tree":return jg(e)>=vg;default:return!1}}function rm(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function oj(e){const t=rm(e);if(!t)return null;const s=rm(t.output)??t;if(typeof s.state!="string"||typeof s.stdout!="string"||typeof s.stderr!="string"||!(s.exitCode===null||typeof s.exitCode=="number"&&Number.isFinite(s.exitCode)))return null;const r=s===t?null:rm(t.input),i=(r==null?void 0:r.command)??s.command;return{command:typeof i=="string"?i:null,input:r,result:s}}function Qz({text:e,label:t}){const[s,r]=d.useState("");return n.jsxs("span",{className:"wb-command-copy",children:[n.jsx("button",{className:"ui-btn",onClick:()=>{var i;if(r(""),!((i=navigator.clipboard)!=null&&i.writeText)){r("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>r("Copied"),()=>r("Copy failed; select the text to copy."))},children:t}),s&&n.jsx("span",{role:"status",className:"wb-hint",children:s})]})}function im({title:e,text:t,error:s=!1}){return n.jsxs("section",{className:"wb-command-stream","data-error":s||void 0,children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("h4",{children:e}),n.jsx(Qz,{text:t,label:`Copy ${e.toLowerCase()}`})]}),n.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function Xz({value:e,children:t}){const{result:s,command:r,input:i}=e,a=s.state==="completed"&&s.exitCode!==null&&s.exitCode!==0,l=typeof s.signal=="string"&&s.signal?s.signal:null,o=s.state==="completed"&&s.exitCode===0,c=Object.fromEntries(Object.entries(s).filter(([h,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(h)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(s.outputErrors)?s.outputErrors.filter(h=>typeof h=="string"):[];return n.jsxs("div",{className:"wb-command-result",children:[n.jsxs("div",{className:"wb-command-bar",children:[n.jsx("span",{className:"ui-pill","data-tone":o?"good":"critical",children:a?"Failed":s.state==="completed"&&l?"Terminated":s.state}),s.exitCode!==null&&n.jsxs("span",{className:"mono",children:["Exit code ",s.exitCode]}),l&&n.jsxs("span",{className:"mono",children:["Signal ",l]}),n.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&n.jsx(im,{title:"Command",text:r}),s.state==="output-limit"&&n.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),s.state==="timed-out"&&n.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),s.state==="cancelled"&&n.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),s.stdout?n.jsx(im,{title:"Output",text:s.stdout}):n.jsx("p",{className:"wb-note",children:"No standard output."}),s.stderr?n.jsx(im,{title:"Standard error",text:s.stderr,error:!0}):null,u.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"File export errors"}),u.map((h,f)=>n.jsx("p",{className:"wb-fail",children:h},f))]}),t,(Object.keys(c).length>0||i!==null)&&n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Execution details"}),n.jsx("pre",{children:Xn({...c,...i?{input:i}:{}})})]})]})}const gu=2,Qb=64;function Jz({props:e}){const[t,s]=d.useState(!1),r=oj(e.value),i=Zz((r==null?void 0:r.result)??e.value),a=d.useMemo(()=>lj(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return n.jsxs("div",{children:[!r&&n.jsx(Xb,{files:i}),t?n.jsx("pre",{className:"ui-code",children:Xn(e.value)}):r?n.jsx(Xz,{value:r,children:i.length>0&&n.jsxs("section",{children:[n.jsx("h4",{children:"Generated files"}),n.jsx(Xb,{files:i})]})}):i.length?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"Tool details"}),n.jsx(Jb,{shape:a})]}):n.jsx(Jb,{shape:a}),n.jsx("div",{className:"wb-row-end wb-section",children:n.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>s(l=>!l),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function Zz(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(s=>s&&typeof s.id=="string"&&/^[0-9a-f-]{36}$/i.test(s.id)&&typeof s.filename=="string"):[]}function Xb({files:e}){return e.length?n.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var s;return n.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?n.jsx(eU,{file:t}):null,n.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(s=t.mime)!=null&&s.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function eU({file:e}){const[t,s]=d.useState(!1);return t?n.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):n.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>s(!0)})}function Jb({shape:e}){switch(e.kind){case"error":return n.jsxs("div",{children:[n.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:"What came back with it"}),n.jsx("div",{className:"wb-tree",children:rc(e.detail,1)})]})]});case"empty":return n.jsxs("div",{children:[n.jsx(am,{stats:e.stats}),n.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=aU(e.columns,e.rows);return n.jsxs("div",{children:[n.jsx(am,{stats:e.stats}),n.jsx(lm,{notes:e.notes}),t?n.jsx(lU,{label:e.label,plan:t,rows:e.rows,total:e.total}):n.jsx(nU,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),n.jsx(om,{asides:e.asides})]})}case"list":return n.jsxs("div",{children:[n.jsx(am,{stats:e.stats}),n.jsx(lm,{notes:e.notes}),e.label?n.jsx("h4",{className:"wb-sub",children:e.label}):null,n.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,s)=>n.jsx("li",{children:Qt(t,"text",null)},s))}),e.total>100?n.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,n.jsx(om,{asides:e.asides})]});case"record":return n.jsxs("div",{children:[n.jsx(lm,{notes:e.notes}),n.jsx(tU,{pairs:e.pairs}),n.jsx(om,{asides:e.asides})]});default:return n.jsx("div",{className:"wb-tree",children:rc(e.value,0)})}}function am({stats:e}){return e.length===0?null:n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:t.label}),n.jsx("div",{className:"ui-stat-v",children:cj(t.value,t.type,t.currency)})]},t.label))})}const Zb=200;function lm({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Zb),s=e.filter(r=>r.length>Zb);return n.jsxs(n.Fragment,{children:[t.map(r=>n.jsx("p",{className:"wb-note",children:r},r)),s.length>0?n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:s.length===1?"A note that came with this result":`${s.length} notes that came with this result`}),s.map(r=>n.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function tU({pairs:e}){return e.length===0?n.jsx("p",{className:"wb-note",children:"Nothing to show."}):n.jsx("dl",{className:"ui-kv",children:e.map(t=>n.jsxs("div",{className:"contents",children:[n.jsx("dt",{children:t.label}),n.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:cj(t.value,t.type,t.currency)})]},t.label))})}function om({asides:e}){return e.length===0?null:n.jsx("div",{className:"wb-section",children:e.map(t=>n.jsxs("details",{className:"wb-aside",children:[n.jsx("summary",{children:t.label}),n.jsx("div",{className:"wb-tree",children:rc(t.value,1)})]},t.label))})}function nU({label:e,columns:t,rows:s,total:r}){const[i,a]=d.useState(!1),l=r<=Od+5?r:Od,o=i?s:s.slice(0,l);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:t.map(c=>n.jsx("th",{className:zE(c.type)?"num":void 0,children:c.label},c.key))})}),n.jsx("tbody",{children:o.map((c,u)=>n.jsx("tr",{children:t.map(h=>n.jsx(oU,{value:c[h.key],column:h},h.key))},u))})]})}),r>o.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",o.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}const sU=/^(title|name|headline|subject|label|heading)$/i,rU=/^(url|link|href|uri|permalink)$/i;function Ld(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function iU(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function FE(e,t=48){try{const s=new URL(e),r=s.pathname==="/"?"":s.pathname,i=`${s.hostname.replace(/^www\./,"")}${r}${s.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function xu(e,t){const s=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return s.length===0?0:s.reduce((r,i)=>r+i.length,0)/s.length}function aU(e,t){if(t.length===0)return null;const s=e.filter(h=>h.type==="text"),r=s.find(h=>rU.test(h.key)&&t.some(f=>Ld(f[h.key])))??s.find(h=>{const f=t.map(m=>m[h.key]).filter(m=>!El(m));return f.length>0&&f.filter(Ld).length/f.length>=.6});if(!r)return null;const i=s.filter(h=>h.key!==r.key),a=i.find(h=>sU.test(h.key))??i.find(h=>xu(t,h.key)>0);if(!a)return null;const o=[...i.filter(h=>h.key!==a.key)].sort((h,f)=>xu(t,f.key)-xu(t,h.key)),c=o[0]&&xu(t,o[0].key)>40?o[0]:null,u=e.filter(h=>h.key!==r.key&&h.key!==a.key&&h.key!==(c==null?void 0:c.key)).map(h=>h.key);return{url:r.key,title:a.key,description:(c==null?void 0:c.key)??null,meta:u}}function lU({label:e,plan:t,rows:s,total:r}){const[i,a]=d.useState(!1),l=r<=Od+5?r:Od,o=i?s:s.slice(0,l);return n.jsxs("div",{children:[e?n.jsx("h4",{className:"wb-sub",children:e}):null,n.jsx("ol",{className:"wb-records",children:o.map((c,u)=>{const h=c[t.url],f=Ld(h)?h.trim():null,m=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?FE(f):"Untitled",p=t.description&&typeof c[t.description]=="string"?c[t.description]:null,g=f?iU(f):null,x=t.meta.map(b=>c[b]).filter(b=>!El(b)&&typeof b!="object").map(b=>String(b)).filter(b=>g===null||b.replace(/^www\./,"")!==g);return n.jsxs("li",{className:"wb-record",children:[f?n.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:m}):n.jsx("span",{className:"wb-record-title",children:m}),n.jsxs("div",{className:"wb-record-meta",children:[g?n.jsx("span",{className:"wb-record-host",title:f??void 0,children:g}):null,x.map((b,j)=>n.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},j))]}),p?n.jsx("p",{className:"wb-record-desc",children:p.length>280?`${p.slice(0,279)}…`:p}):null]},u)})}),r>o.length?n.jsxs("p",{className:"wb-note wb-note-row",children:[n.jsxs("span",{children:["Showing ",o.length," of ",r]}),n.jsxs("button",{className:"ui-btn",onClick:()=>a(!0),children:["Show all ",r]})]}):null]})}function oU({value:e,column:t}){if(El(e))return n.jsx("td",{className:"wb-cell-soft",children:"—"});if(Ld(e)){const i=e.trim();return n.jsx("td",{className:"wb-cell-link",children:n.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:FE(i)})})}if(e!==null&&typeof e=="object"){const i=Array.isArray(e)?`${e.length} item${e.length===1?"":"s"}`:`${Object.keys(e).length} fields`;return n.jsx("td",{className:"wb-cell-soft",title:Xn(e),children:i})}const s=cj(e,t.type,t.currency),r=s.length>Qb?`${s.slice(0,Qb-1)}…`:s;return n.jsx("td",{className:zE(t.type)?"num":"wb-cell-text",...r===s?{}:{title:s},children:r})}function zE(e){return e==="number"||e==="currency"}function cj(e,t,s){return e==null?"—":t==="boolean"?e?"yes":"no":Qt(e,t==="text"?"text":t,s)}function rc(e,t){if(e===null)return n.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return n.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return n.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return n.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return n.jsx("span",{children:e===""?n.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return n.jsx("span",{className:"wb-tree-null",children:"none"});const i=n.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((a,l)=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[l,". "]}),rc(a,t+1)]},l)),e.length>50?n.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=gu?n.jsx(ek,{summary:`${e.length} items`,open:t===gu,children:i}):i}const s=Object.entries(e);if(s.length===0)return n.jsx("span",{className:"wb-tree-null",children:"empty"});const r=n.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:s.map(([i,a])=>n.jsxs("div",{children:[n.jsxs("span",{className:"wb-tree-key",children:[xn(i),": "]}),rc(a,t+1)]},i))});return t>=gu?n.jsx(ek,{summary:`${s.length} fields`,open:t===gu,children:r}):r}function ek({summary:e,open:t,children:s}){return n.jsxs("details",{open:t,children:[n.jsx("summary",{className:"wb-tree-key",children:e}),s]})}function cU({props:e}){const t=e.groups.every(s=>s.rows.length===0);return n.jsxs("div",{children:[e.summary.length>0?n.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(s=>n.jsxs("div",{children:[n.jsx("div",{className:"ui-stat-k",children:s.label}),n.jsx("div",{className:"ui-stat-v","data-tone":s.tone,children:Qt(s.value,s.unit,s.currency)})]},s.label))}):null,t?n.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((s,r)=>n.jsxs("div",{className:r>0?"wb-section":void 0,children:[s.label?n.jsx("h4",{className:"ui-stat-k wb-label",children:s.label}):null,n.jsx("div",{className:"ui-table-wrap",children:n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:e.columns.map(i=>n.jsx("th",{className:UE(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),n.jsx("tbody",{children:s.rows.map((i,a)=>n.jsx("tr",{children:i.map((l,o)=>{var c;return n.jsx(uU,{cell:l},((c=e.columns[o])==null?void 0:c.key)??o)})},a))})]})})]},s.label??r))]})}function uU({cell:e}){const t=Qt(e.value,e.type,e.currency);return e.bar?n.jsx("td",{className:"num",children:n.jsxs("div",{className:"wb-row wb-row-end",children:[n.jsx("div",{className:"ui-meter",role:"meter","aria-valuenow":Math.round(e.bar.fraction*100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,children:n.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),n.jsx("span",{className:"tnum",children:t})]})}):n.jsx("td",{className:UE(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function UE(e){return e==="number"||e==="currency"||e==="percent"}const tk={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe",sun:"sun","partly-cloudy":"partly-cloudy",cloud:"cloud",rain:"rain",drizzle:"drizzle",snow:"snow",storm:"storm",fog:"fog",wind:"wind","moon-clear":"moon-clear","moon-cloud":"moon-cloud",check:"check",clock:"clock"};function Al(e){return(e&&Object.prototype.hasOwnProperty.call(tk,e)?tk[e]:void 0)??"dot"}function nk(e,t){return(e??[]).filter(s=>s.place===t).map((s,r)=>({page:s,index:r})).sort((s,r)=>(s.page.order??0)-(r.page.order??0)||s.index-r.index).map(s=>s.page)}const _d="buddi:plugin-pages-changed";function dU(){window.dispatchEvent(new Event(_d))}function BE(e=!1){const[t,s]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;const i=()=>{Promise.resolve().then(()=>E.pages()).then(l=>{r||s(Array.isArray(l==null?void 0:l.pages)?l.pages:[])}).catch(()=>{})};i();const a=()=>{document.visibilityState==="visible"&&i()};return window.addEventListener(_d,i),document.addEventListener("visibilitychange",a),()=>{r=!0,window.removeEventListener(_d,i),document.removeEventListener("visibilitychange",a)}},[e]),{all:t,rail:nk(t,"rail"),settings:nk(t,"settings"),find:(r,i)=>t.find(a=>a.plugin===r&&a.id===i)}}let qu=null;typeof window<"u"&&window.addEventListener(_d,()=>{qu=null});function hU(){return qu??(qu=Promise.resolve().then(()=>E.pages()).then(e=>Array.isArray(e==null?void 0:e.pages)?e.pages:[]).catch(()=>(qu=null,[]))),qu}function uj(e,t,s){return s==="settings"?gi(e,t):lr(e,t)}function fU(e){const[t,s]=d.useState(null),r=e==null?void 0:e.plugin,i=e==null?void 0:e.page;return d.useEffect(()=>{if(!r||!i)return;let a=!1;return hU().then(l=>{const o=l.find(c=>c.plugin===r&&c.id===i);a||s(o?{href:uj(r,i,o.place),label:o.place==="settings"?`Settings → ${o.title}`:o.title}:null)}),()=>{a=!0}},[r,i]),t}function WE({props:e,layout:t,selected:s,onPick:r}){return e.tiles.length===0?n.jsx("p",{className:"wb-empty",children:e.empty}):n.jsx("ul",{className:"wb-tiles","data-notice":e.notice?"true":void 0,"data-layout":t&&t!=="grid"?t:void 0,style:t==="row"?{"--tiles-n":e.tiles.length}:void 0,children:e.tiles.map((i,a)=>n.jsx(mU,{tile:i,...r?{picked:a===s,onPick:()=>r(a)}:{}},`${a}-${i.label}`))})}function mU({tile:e,picked:t,onPick:s}){const r=fU(e.link),i=[e.label,e.value,...e.lines].filter(l=>l!=="").join(", "),a=n.jsxs("div",{className:"wb-tile-body","aria-hidden":"true",children:[n.jsx("span",{className:"wb-tile-icon","data-icon":e.icon??"dot",children:n.jsx(ue,{name:Al(e.icon),size:22})}),e.value!==""?n.jsx("span",{className:"wb-tile-value tnum",children:e.value}):null,n.jsx("span",{className:"wb-tile-label",children:e.label}),e.lines.map((l,o)=>n.jsx("span",{className:"wb-tile-line",children:l},o))]});return s?n.jsx("li",{className:"wb-tile",children:n.jsx("button",{type:"button",className:"ui-card","data-tone":t?"accent":e.tone==="neutral"?void 0:e.tone,"data-selected":t?"true":void 0,"aria-pressed":t===!0,"aria-label":i,onClick:s,children:a})}):n.jsxs("li",{className:"wb-tile",children:[n.jsx("span",{className:"sr-only",children:i}),n.jsxs(ws,{tone:e.tone==="neutral"?void 0:e.tone,children:[a,r?n.jsx("a",{className:"wb-tile-link",href:r.href,children:r.label}):null]})]})}const wa=760,cm=400,Ot={top:18,right:18,bottom:36,left:66},pU=5;function gU({props:e}){const{points:t,referenceLines:s,unit:r,currency:i}=e;if(t.length===0)return n.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const a=[...t.map(y=>y.y),...s.map(y=>y.value)],l=Math.min(...a),o=Math.max(...a),c=o-l||Math.abs(o)||1,u=l-c*.08,h=o+c*.08,f=wa-Ot.left-Ot.right,m=cm-Ot.top-Ot.bottom,p=y=>Ot.left+(t.length===1?f/2:y/(t.length-1)*f),g=y=>Ot.top+m-(y-u)/(h-u)*m,x=$d(l,o,4),b=vU(t.map(y=>y.y),e.mark),j=e.shadeBelow===null?[]:jU(t.map(y=>y.y),e.shadeBelow),v=t.map((y,N)=>`${N===0?"M":"L"}${p(N)},${g(y.y)}`).join(" "),w=y=>Qt(y,r,i);return n.jsxs("div",{children:[e.label?n.jsx("p",{className:"ui-panel-sub",children:e.label}):null,n.jsxs("div",{className:"wb-chart-layout",children:[n.jsx("div",{className:"wb-chart-plot",children:n.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${wa} ${cm}`,role:"img","aria-label":xU(e,w),preserveAspectRatio:"xMidYMid meet",children:[j.map(y=>n.jsx("rect",{className:"wb-chart-breach",x:p(y.from),width:Math.max(2,p(y.to)-p(y.from)),y:Ot.top,height:m},`band-${y.from}`)),x.map(y=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-grid",x1:Ot.left,x2:wa-Ot.right,y1:g(y),y2:g(y)}),n.jsx("text",{x:Ot.left-8,y:g(y)+4,textAnchor:"end",children:w(y)})]},`tick-${y}`)),s.map(y=>n.jsxs("g",{children:[n.jsx("line",{className:"wb-chart-floor",x1:Ot.left,x2:wa-Ot.right,y1:g(y.value),y2:g(y.value)}),n.jsxs("text",{x:wa-Ot.right,y:g(y.value)-6,textAnchor:"end",children:[y.label," ",w(y.value)]})]},`rule-${y.label}`)),n.jsx("line",{className:"wb-chart-axis",x1:Ot.left,x2:Ot.left,y1:Ot.top,y2:Ot.top+m}),n.jsx("line",{className:"wb-chart-axis",x1:Ot.left,x2:wa-Ot.right,y1:Ot.top+m,y2:Ot.top+m}),n.jsx("path",{className:"wb-chart-series",d:v}),b!==null?n.jsxs("g",{children:[n.jsx("circle",{className:"wb-chart-min",cx:p(b),cy:g(t[b].y),r:4.5}),n.jsx("text",{x:p(b),y:g(t[b].y)+20,textAnchor:"middle",children:w(t[b].y)})]}):null,wU(t.length).map(y=>n.jsx("text",{x:p(y),y:cm-10,textAnchor:"middle",children:ag(t[y].x)},`x-${y}`))]})}),e.events.length>0?n.jsxs("aside",{className:"wb-chart-events",children:[n.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),n.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((y,N)=>n.jsxs("li",{className:"wb-chart-event",children:[n.jsxs("span",{children:[n.jsx("span",{className:"wb-chart-event-day",children:ag(y.at)}),y.label]}),y.amount===null?null:n.jsx("span",{className:y.amount<0?"tnum critical":"tnum good",children:Qt(y.amount,r,i)})]},`${y.at}-${y.label}-${N}`))})]}):null]})]})}function xU(e,t){const s=e.points.map(l=>l.y),r=e.points[0],i=e.points[e.points.length-1],a=e.referenceLines.map(l=>`${l.label} at ${t(l.value)}`).join(", ");return[`${e.points.length} points from ${r==null?void 0:r.x} to ${i==null?void 0:i.x}`,`low ${t(Math.min(...s))}, high ${t(Math.max(...s))}`,a].filter(Boolean).join("; ")}function vU(e,t){if(!t||e.length===0)return null;let s=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[s]:e[r]>e[s])&&(s=r);return s}function jU(e,t){const s=[];let r=null;return e.forEach((i,a)=>{i<t?r===null&&(r=a):r!==null&&(s.push({from:r,to:a}),r=null)}),r!==null&&s.push({from:r,to:e.length-1}),s}function wU(e,t=pU){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const s=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*s));return[...r].sort((i,a)=>i-a)}const is=e=>e,yg={timeseries:is(gU),table:is(cU),bars:is(U_),keyvalue:is(Tz),tiles:is(WE),document:is(I4),diff:is(G_),terminal:is(Pz),image:is(Az),preview:is(Oz),envelope:is(kz),structured:is(Jz)},yU="structured";function bU(e){return(Fd(e)?yg[e]:void 0)??yg[yU]}function Fd(e){return Object.prototype.hasOwnProperty.call(yg,e)}function kU({renderer:e,props:t,timezone:s,onDecided:r}){const i=bU(e),l=Fd(e)?t:{value:t};return n.jsx(i,{props:l,timezone:s,onDecided:r})}function NU({profile:e,onChange:t}){return n.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[n.jsx("p",{className:"wb-prof-lead",children:e.description}),n.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?n.jsx(um,{children:"Opens by default"}):null,n.jsx(um,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(s=>n.jsx(um,{title:`A surface command that asks for "${s}" lands on this agent.`,children:xn(s)},s))]}),e.available?null:n.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[n.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),(e.disabled??[]).map(s=>n.jsx("p",{className:"wb-prof-blocked","data-testid":"agent-profile-disabled",children:s},s)),n.jsx(Zl,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:n.jsxs("ul",{className:"wb-prof-list",children:[n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),n.jsx("span",{className:"wb-prof-row-desc",children:"When it knows the likely answers, it can show one-tap choices in the dashboard and Telegram. You can still write a different answer when the question allows it."})]}),n.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),n.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),n.jsx("span",{className:"wb-prof-row-desc",children:"A request to send, spend, publish or otherwise affect the world appears in the conversation with the exact action. Answering a question never approves it."})]}),n.jsxs("span",{className:"wb-prof-gate",children:[n.jsx(HE,{}),"Exact action"]})]})]})}),n.jsx(Zl,{title:"What it can do",note:SU(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?n.jsx("p",{className:"wb-prof-empty",children:"No tools at all. It answers from the conversation and from what it remembers, and it can change nothing."}):[...e.tools].sort((s,r)=>+(r.gated>0)-+(s.gated>0)).map(s=>n.jsx(CU,{family:s},s.family))}),n.jsx(Zl,{title:"What it runs on",children:n.jsxs("dl",{className:"wb-prof-kv",children:[n.jsx(eo,{label:"Provider",children:e.engine.provider}),n.jsx(eo,{label:"Model",children:n.jsx("span",{className:"mono",children:e.engine.model})}),n.jsxs(eo,{label:"Credential",children:[e.engine.credentialKind," from"," ",n.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),n.jsxs(eo,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),n.jsx(eo,{label:"Language",children:$U(e.engine.language)})]})}),e.skills.length>0?n.jsx(Zl,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:n.jsx("ul",{className:"wb-prof-list",children:e.skills.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:s.name}),s.description?n.jsx("span",{className:"wb-prof-row-desc",children:s.description}):null]}),n.jsxs("span",{className:"wb-prof-row-side",title:s.file,children:[s.scope==="private"?"its own":"shared"," · ",s.provenance]})]},s.file))})}):null,e.delegates.length>0?n.jsx(Zl,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:n.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(s=>n.jsxs("li",{className:"wb-prof-row",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsxs("span",{className:"wb-prof-row-name mono",children:["@",s.handle]}),n.jsx("span",{className:"wb-prof-row-desc",children:s.description})]}),n.jsx("span",{className:"wb-prof-row-side",children:s.available?s.name:`${s.name} · cannot run`})]},s.id))})}):null,n.jsxs("footer",{className:"wb-prof-foot",children:[n.jsx("p",{className:"wb-prof-note",children:e.note}),n.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?n.jsxs("button",{className:"ui-btn","data-testid":"agent-profile-change",title:e.changeVia.prompt,onClick:()=>t({agentId:e.changeVia.agentId,prompt:e.changeVia.prompt}),children:["Ask @",e.changeVia.handle," to change this"]}):null]})]})}function SU(e){if(e.toolCount===0)return"Nothing. This agent holds no tools.";const t=`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`;if(e.gatedCount===0)return`${t}, every one of them running without asking you. None of them can send, spend or write to the world.`;const s=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${s}.`}function CU({family:e}){const t=[...e.tools].sort((s,r)=>Number(r.gated)-Number(s.gated));return n.jsxs("section",{className:"wb-prof-family",children:[n.jsxs("h4",{className:"wb-prof-family-head",children:[n.jsx("span",{className:"wb-prof-family-name",children:xn(e.family)}),n.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),n.jsx("ul",{className:"wb-prof-list",children:t.map(s=>n.jsx(EU,{tool:s},s.name))})]})}function EU({tool:e}){return n.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[n.jsxs("span",{className:"wb-prof-row-main",children:[n.jsx("span",{className:"wb-prof-row-name mono",children:RU(e.name)}),n.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?n.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[n.jsx(HE,{}),"Needs your approval"]}):n.jsx("span",{className:"wb-prof-auto",title:TU(e.tier),children:AU(e.tier)})]})}function AU(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function TU(e){return e==="auto"?"Called during a run without asking you. It reads, or records something you can see.":`Tier "${e}" does not execute in this build; a call to it is refused.`}function RU(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function $U(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function Zl({title:e,note:t,tone:s,children:r}){return n.jsxs("section",{className:"wb-prof-section",children:[n.jsx("h3",{className:"wb-prof-title",children:e}),t?n.jsx("p",{className:"wb-prof-note-lead","data-tone":s,children:t}):null,r]})}function eo({label:e,children:t}){return n.jsxs(n.Fragment,{children:[n.jsx("dt",{className:"wb-prof-k",children:e}),n.jsx("dd",{className:"wb-prof-v",children:t})]})}function um({children:e,title:t}){return n.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function HE(){return n.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),n.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const sk=16e3,IU=10*6e4,PU="The microphone is blocked for this page: allow it in the browser’s site settings to talk.",KE="This browser cannot record here: talking needs a microphone and a secure page (https or localhost).";function MU(){const e=window;return e.AudioContext??e.webkitAudioContext}function DU(e){const t=e&&typeof e=="object"&&"name"in e?String(e.name):"";return t==="NotAllowedError"||t==="SecurityError"||t==="PermissionDeniedError"?PU:t==="NotFoundError"||t==="DevicesNotFoundError"?"No microphone was found on this computer.":t==="NotReadableError"?"The microphone is in use by another app.":KE}async function OU(e){var c;const t=MU();if(!((c=navigator.mediaDevices)!=null&&c.getUserMedia)||!t)throw Object.assign(new Error(KE),{name:"Unsupported"});const s=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),r=new t,i=r.createMediaStreamSource(s),a=r.createScriptProcessor(4096,1,1),l=[];a.onaudioprocess=u=>{const h=u.inputBuffer.getChannelData(0);l.push(new Float32Array(h));let f=0;for(let m=0;m<h.length;m++)f+=h[m]*h[m];e(Math.min(1,Math.sqrt(f/h.length)*6))},i.connect(a),a.connect(r.destination),r.state==="suspended"&&await r.resume().catch(()=>{});const o=()=>{a.onaudioprocess=null;try{i.disconnect(),a.disconnect()}catch{}s.getTracks().forEach(u=>u.stop()),r.close().catch(()=>{})};return{async stop(){const u=r.sampleRate;return o(),FU(_U(LU(l),u,sk),sk)},cancel:o}}function LU(e){const t=new Float32Array(e.reduce((r,i)=>r+i.length,0));let s=0;for(const r of e)t.set(r,s),s+=r.length;return t}function _U(e,t,s){if(t<=s)return e;const r=t/s,i=new Float32Array(Math.floor(e.length/r));for(let a=0;a<i.length;a++){const l=Math.floor(a*r),o=Math.min(e.length,Math.floor((a+1)*r));let c=0;for(let u=l;u<o;u++)c+=e[u];i[a]=o>l?c/(o-l):0}return i}function FU(e,t){const s=new ArrayBuffer(44+e.length*2),r=new DataView(s),i=(a,l)=>{for(let o=0;o<l.length;o++)r.setUint8(a+o,l.charCodeAt(o))};i(0,"RIFF"),r.setUint32(4,36+e.length*2,!0),i(8,"WAVEfmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,"data"),r.setUint32(40,e.length*2,!0);for(let a=0;a<e.length;a++){const l=Math.max(-1,Math.min(1,e[a]));r.setInt16(44+a*2,Math.round(l<0?l*32768:l*32767),!0)}return new Blob([s],{type:"audio/wav"})}const bg="buddi.readAloud";function VE(){try{return window.localStorage.getItem(bg)==="on"}catch{return!1}}function GE(e){try{e?window.localStorage.setItem(bg,"on"):window.localStorage.removeItem(bg)}catch{}}let Xs=null,wo=null,ic=0,kg=null;const Ng=new Set;function zd(e){kg!==e&&(kg=e,Ng.forEach(t=>t()))}function zU(){return kg}function UU(e){return Ng.add(e),()=>Ng.delete(e)}function YE(e){return Tl(),zd(e),ic}function rk(e){return e===ic}function Tl(){ic++,Xs&&(Xs.pause(),Xs.removeAttribute("src")),wo&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(wo),wo=null,zd(null)}async function BU(e,t,s=null){var i;const r=YE(s);try{const a=await fetch(e,{credentials:"same-origin"});if(!a.ok)throw new Error(`The spoken reply could not be fetched (${a.status}).`);const l=new Blob([await a.arrayBuffer()],{type:t});if(r!==ic)return;Xs||(Xs=new Audio,(i=Xs.addEventListener)==null||i.call(Xs,"ended",()=>zd(null))),wo=URL.createObjectURL(l),Xs.src=wo,await Xs.play()}catch(a){throw r===ic&&zd(null),a}}const WU=new Set(["audio/ogg","audio/mpeg","audio/mp4","audio/wav","audio/x-wav","audio/webm"]);function qE(e){return WU.has(e.toLowerCase().split(";")[0].trim())}function ik(e){if(e===null||!Number.isFinite(e)||e<0)return"–:––";const t=Math.floor(e);return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function QE({artifactId:e,name:t,mime:s,sizeBytes:r}){const i=d.useRef(null),a=d.useRef(null),[l,o]=d.useState(!1),[c,u]=d.useState(!1),[h,f]=d.useState(!1),[m,p]=d.useState(0),[g,x]=d.useState(null);d.useEffect(()=>()=>{var v;(v=i.current)==null||v.pause(),a.current&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(a.current)},[]);const b=async()=>{const v=i.current;if(v){if(l){v.pause();return}Tl(),f(!1);try{if(!a.current){u(!0);const w=await fetch(vi(e),{credentials:"same-origin"});if(!w.ok)throw new Error(String(w.status));a.current=URL.createObjectURL(new Blob([await w.arrayBuffer()],{type:s})),v.src=a.current}await v.play()}catch{f(!0)}finally{u(!1)}}},j=h?"Could not play. Download it instead.":`${ik(m)} / ${ik(g)}`;return n.jsxs("span",{className:"wb-audio","data-testid":"audio-card","data-playing":l?"true":void 0,children:[n.jsx("button",{type:"button",className:"ui-icon-btn wb-audio-play","data-size":"sm","aria-label":l?`Pause ${t}`:`Play ${t}`,disabled:c,onClick:()=>void b(),children:n.jsx(ue,{name:l?"pause":"play",size:14})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:t,children:t}),n.jsxs("span",{className:"wb-file-meta","data-testid":"audio-time",children:[c?"Loading…":j,!h&&Fn(r)?` · ${Fn(r)}`:""]})]}),n.jsx("a",{className:"ui-icon-btn wb-audio-download","data-size":"sm",href:vi(e),download:t,"aria-label":`Download ${t}`,title:"Download",children:n.jsx(ue,{name:"download",size:14})}),n.jsx("audio",{ref:i,preload:"none",onPlay:()=>o(!0),onPause:()=>o(!1),onEnded:()=>{o(!1),p(0)},onTimeUpdate:v=>p(v.currentTarget.currentTime),onLoadedMetadata:v=>x(Number.isFinite(v.currentTarget.duration)?v.currentTarget.duration:null),onDurationChange:v=>x(Number.isFinite(v.currentTarget.duration)?v.currentTarget.duration:null)})]})}const dm=1e5,hm=200,fm=30;function XE({artifactId:e,filename:t,mime:s,family:r,available:i=!0}){const[a,l]=d.useState(!1);return i?r==="image"&&!a?n.jsx("figure",{className:"file-preview file-preview-image",children:n.jsx("img",{src:Fr(e),alt:t??"Image",onError:()=>l(!0)})}):r==="audio"&&qE(s)?n.jsx("div",{className:"file-preview file-preview-audio",children:n.jsx(QE,{artifactId:e,name:t??"Audio",mime:s})}):r==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:Fr(e),type:"application/pdf","aria-label":t??"PDF",children:n.jsx(V,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?n.jsx(HU,{artifactId:e,filename:t,mime:s,family:r}):n.jsx(V,{children:"Preview not supported for this kind of file. Download it to open it."}):n.jsx(V,{children:"The file is no longer available; its record is kept."})}function HU({artifactId:e,filename:t,mime:s,family:r}){const[i,a]=d.useState("loading");if(d.useEffect(()=>{let o=!1;return a("loading"),fetch(Fr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();o||a({text:u.slice(0,dm),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>dm})}).catch(()=>{o||a("failed")}),()=>{o=!0}},[e]),i==="loading")return n.jsx("div",{className:"file-preview",children:n.jsx(xe,{children:"Loading preview…"})});if(i==="failed")return n.jsx(V,{children:"The preview could not be loaded. Download the file to open it."});const l=r==="table"&&(/csv|tab-separated/.test(s)||/\.(csv|tsv)$/i.test(t??""));return n.jsxs("div",{className:"file-preview",children:[l?n.jsx(VU,{text:i.text,delimiter:/tab|\.tsv$/i.test(s+(t??""))?" ":","}):n.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?n.jsxs("p",{className:"muted",children:["Showing the first ",dm.toLocaleString()," characters. The download has the whole file."]}):null]})}function KU(e,t,s,r){const i=[];let a=[],l="",o=!1,c=!1,u=!1;const h=()=>{a.length<r?a.push(l):c=!0,l=""},f=()=>{h(),i.push(a),a=[]};let m=0;for(;m<e.length;m+=1){if(i.length>=s){u=e.slice(m).trim()!=="";break}const p=e[m];if(o){p==='"'?e[m+1]==='"'?(l+='"',m+=1):o=!1:l+=p;continue}if(p==='"'){o=!0;continue}if(p===t){h();continue}if(p!=="\r"){if(p===`
|
|
95
|
+
`){f();continue}l+=p}}return i.length<s&&(l!==""||a.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function VU({text:e,delimiter:t}){const s=d.useMemo(()=>KU(e,t,hm+1,fm),[e,t]),[r,...i]=s.rows;if(!r)return n.jsx("p",{className:"muted",children:"The file is empty."});const a=Math.min(fm,s.rows.reduce((o,c)=>Math.max(o,c.length),0)),l=Array.from({length:a},(o,c)=>c);return n.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[n.jsxs("table",{className:"ui-table",children:[n.jsx("thead",{children:n.jsx("tr",{children:l.map(o=>n.jsx("th",{children:r[o]??""},o))})}),n.jsx("tbody",{children:i.slice(0,hm).map((o,c)=>n.jsx("tr",{children:l.map(u=>n.jsx("td",{children:o[u]??""},u))},c))})]}),s.truncatedRows||s.truncatedCols?n.jsxs("p",{className:"muted",children:["Showing the first ",hm," rows",s.truncatedCols?` and ${fm} columns`:"",". The download has the whole file."]}):null]})}function GU({attachment:e}){const t=aj(e.mime,e.filename),s=e.filename??"Untitled file";return n.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[n.jsx(XE,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),n.jsxs("dl",{className:"ui-kv",children:[n.jsx("dt",{children:"Type"}),n.jsxs("dd",{children:[Vi[t],n.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Size"}),n.jsx("dd",{children:Fn(e.sizeBytes)})]}):null,n.jsx("dt",{children:"Id"}),n.jsx("dd",{className:"mono",children:e.artifactId})]}),n.jsx("div",{className:"ui-toolbar","data-align":"end",children:n.jsx("a",{className:"ui-btn",href:vi(e.artifactId),download:s,children:"Download"})})]})}const ak=80,YU=["query","path","url","dir"],qU=["message","task"];function dj(e,t){const s=QU(t);if(!s)return null;const r=ya(s.command);if(r!==null){const l=ya(s.name);return vu(l===null?r:`${l}: ${r}`)}for(const l of YU){const o=ya(s[l]);if(o!==null)return vu(o)}const i=ya(s.action);if(i!==null){const l=qU.map(o=>ya(s[o])).find(o=>o!==null)??null;return vu(l===null?i:`${i} · ${l}`)}const a=Object.values(s).filter(l=>typeof l=="string");return a.length===1?vu(ya(a[0])):null}function ya(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function vu(e){return e===null?null:e.length>ak?`${e.slice(0,ak-1)}…`:e}function QU(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const JE="owner.notify",wr=e=>typeof e=="string"&&e.trim()!==""?e:null;function XU(e){const t=e!==null&&typeof e=="object"?e:{};return{title:wr(t.title)??"(no title)",text:wr(t.text),urgency:wr(t.urgency)??"now",key:wr(t.key),link:wr(t.link)}}function ZE(e){if(e===null||typeof e!="object")return wr(e);const t=e;return wr(t.delivered)??wr(t.message)??wr(t.error)}function JU(e,t){if(!t||!e)return"critical";const s=e.toLowerCase();return/^(refused|not sent)/.test(s)?"critical":/^sent\b/.test(s)?"good":"warning"}const ji="agent.delegate";function ZU(e){if(e===null||typeof e!="object")return null;const t=e,s=t.conversationId;if(typeof s!="string"||s==="")return null;const r=t.agentId??t.agent;return{conversationId:s,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function e3(e){if(typeof e=="string")return e;if(e===null||typeof e!="object")return null;const t=e.text;return typeof t=="string"?t:null}const Sg="canvas.show",lk="canvas.clear",ok=12;function qa(e){return`${e.plugin}/${e.name}`}function t3(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function n3({messages:e,descriptors:t}){const s=new Map(t.filter(a=>a.renderer==="preview").map(a=>[a.tool,a]));if(s.size===0)return[];const r=new Map,i=[];for(const a of e)for(const l of a.blocks??[]){if(l.type==="tool_use"&&r.set(l.id,l.name),l.type!=="tool_result"||l.ok===!1)continue;const o=s.get(l.name||r.get(l.toolUseId)||"");if(!o)continue;const c=yE(o,eA(l.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:a.at??null})}return i}function s3({messages:e,descriptors:t,awaiting:s,folded:r,served:i}){var u;const a=new Map(t.map(h=>[h.tool,h])),l=new Map;let o=[],c=0;for(const h of e)for(const f of h.blocks??[]){if(f.type==="tool_use"){if(l.set(f.id,{name:f.name,input:f.input,at:h.at??null}),f.name===Sg){const y=i3(f.id,f.input,h.at??null);y&&o.push(y)}if(f.name===lk&&(o=[]),f.name===ji){const y=ZU(f.input);y&&o.push({id:f.id,tool:ji,title:"Delegation",renderer:"delegate",props:{...y,result:null},at:h.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===Sg||f.name===lk)continue;const m=l.get(f.toolUseId),p=h.at??(m==null?void 0:m.at)??null,g=f.name||(m==null?void 0:m.name)||"tool",x=o.find(y=>y.source==="delegate"&&y.id===f.toolUseId);if(x&&((u=f.delegation)==null?void 0:u.state)==="waiting"){x.props={...x.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(x.tone="warning");continue}if(x){x.props={...x.props,result:{ok:f.ok,text:e3(f.ok?f.output:f.error??f.output),...f.ok&&Dd(f.output).length>0?{files:Dd(f.output)}:{}}},f.ok||(x.tone="critical");continue}const b=f.approval?Eg(f):(s==null?void 0:s.get(f.toolUseId))??Eg(f);if(b){o.push({id:f.toolUseId,tool:g,title:"Approval",renderer:"envelope",props:{approvalId:b},at:p,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(g))continue;if(g===JE){o.push({id:f.toolUseId,tool:g,title:"Message to you",renderer:"notify",props:{input:(m==null?void 0:m.input)??null,output:f.output??null,ok:f.ok!==!1},at:p,tone:f.ok===!1?"critical":void 0,source:"notify",substantial:!1});continue}const j=eA(f.output);if(f.ok===!1){o.push({id:f.toolUseId,tool:g,title:rr(g),renderer:"structured",props:{value:f.error??j??null,failed:!0},at:p,tone:"critical",source:"fallback",substantial:!1});continue}t3(j)&&(c+=1);const v=a.get(g);if(v){const y=yE(v,j),{renderer:N}=y;let{props:k}=y;if(N==="preview"){const S=k,C=S.target??(S.awaiting&&(i!=null&&i.has(qa(S.awaiting)))?S.awaiting:null);if(C===null)continue;k={...S,target:C,awaiting:null};const $=qa(C);o=o.filter(R=>!(R.source==="descriptor"&&R.renderer==="preview"&&R.props.target!==null&&qa(R.props.target)===$))}o.push({id:f.toolUseId,tool:g,title:v.title??rr(g),renderer:N,props:k,at:p,source:"descriptor",substantial:Cg(N,k)});continue}const w={value:oj(j)?{input:m==null?void 0:m.input,output:j}:j};a3("structured",w)&&o.push({id:f.toolUseId,tool:g,title:rr(g),renderer:"structured",props:w,at:p,source:"fallback",substantial:Cg("structured",w)})}for(const h of o)h.source==="descriptor"&&h.renderer==="preview"&&(h.props={...h.props,changes:c});return r3(o)}const ck="forAgent";function eA(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(ck in e))return e;const{[ck]:t,...s}=e;return s}function r3(e){if(e.length<=ok)return e;const t=e.length-ok;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function i3(e,t,s){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:a}=t,l=typeof r=="string"&&Fd(r)?r:"structured";return{id:e,tool:Sg,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:l,props:l==="structured"&&!Fd(String(r))?{value:a}:a,at:s,substantial:!0,source:"canvas"}}function a3(e,t){const s=t??{};return!!(s.failed===!0||Cg(e,t)||lj(s.value).kind==="error")}function Cg(e,t){const s=t??{};switch(e){case"timeseries":return to(s.points)>0;case"bars":return to(s.bars)>0;case"keyvalue":return to(s.pairs)>0;case"tiles":return s.notice!==!0&&to(s.tiles)>0;case"document":return!!s.text||!!s.src;case"diff":return!!s.diff;case"terminal":return!!s.output||!!s.command;case"image":return!!s.artifactId;case"preview":return!!s.target;case"envelope":return!0;case"table":return(Array.isArray(s.groups)?s.groups:[]).some(i=>to(i.rows)>0);default:return oj(s.value)?!0:s.failed===!0?!1:qz(s.value)}}function to(e){return Array.isArray(e)?e.length:0}function Eg(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const s=nA(t,0);if(s)return s}return null}function l3(e,t,s={}){var o,c;const r=e.flatMap(u=>u.blocks),i=r.find(u=>u.type==="tool_use"&&u.id===t);if((i==null?void 0:i.type)!=="tool_use")return null;const a=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),l=(o=s.redactInputOf)!=null&&o.has(i.name)?tA(i.input):i.input;return{id:t,tool:i.name,title:rr(i.name),renderer:"structured",props:{value:{input:l,...(a==null?void 0:a.type)==="tool_result"?{status:((c=a.approval)==null?void 0:c.state)??(a.ok?"completed":"failed"),output:a.output,...a.error?{error:a.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const o3=new Set(["value","text","password","secret","code"]);function tA(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[s,r]of Object.entries(e))t[s]=o3.has(s)&&typeof r=="string"?"— withheld —":tA(r);return t}function nA(e,t){if(t>3||e===null||typeof e!="object")return null;const s=e,r=s.reason,i=s.actionId??s.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const a of Object.values(s)){const l=nA(a,t+1);if(l)return l}return null}function rr(e){const t=e.split(".");return t.length===1?xn(e):t.map(s=>xn(s)).join(" · ")}function Qh({name:e,mime:t,sizeBytes:s,thumbnail:r,state:i,error:a,onOpen:l,onRemove:o,size:c="md"}){const u=aj(t,e),h=[Vi[u],Fn(s)].filter(Boolean).join(" · "),f=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-file-visual","data-family":u,children:r?n.jsx("img",{src:r,alt:""}):n.jsx(hj,{family:u})}),n.jsxs("span",{className:"wb-file-text",children:[n.jsx("span",{className:"wb-file-name",title:e,children:e}),n.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":h})]})]});return n.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?a:void 0,children:[l?n.jsx("button",{type:"button",className:"wb-file-open",onClick:l,"aria-label":`Open ${e}`,children:f}):n.jsx("span",{className:"wb-file-open",children:f}),o?n.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:o,children:n.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:n.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function hj({family:e}){const t={width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"};switch(e){case"image":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),n.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),n.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),n.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"}),n.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return n.jsx("svg",{...t,children:n.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),n.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return n.jsxs("svg",{...t,children:[n.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),n.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return n.jsxs("svg",{...t,children:[n.jsx("path",{d:"M6 2.5h5.5L16 7v9.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"}),n.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function c3(e,t,s){const r=dk(e),i=dk(t==null?void 0:t.input),a=Pi(r==null?void 0:r.name)??m3(Pi(r==null?void 0:r.handle))??Pi(r==null?void 0:r.agent)??Pi(i==null?void 0:i.agent),l=typeof e=="string"?e.trim()||null:Pi(r==null?void 0:r.text)??Pi(r==null?void 0:r.note),o=uk(r==null?void 0:r.durationMs)??uk(r==null?void 0:r.elapsedMs),c=t!=null&&t.at?Date.parse(t.at):NaN,u=s?Date.parse(s):NaN,h=Number.isFinite(c)&&Number.isFinite(u)&&u>=c?u-c:null;return{who:a,question:Pi(i==null?void 0:i.task),answer:l,files:Dd(e),durationMs:o??h}}function u3(e,t){var r;let s=null;for(const i of e)for(const a of i.blocks??[])a.type==="tool_result"&&a.name===ji&&((r=a.delegation)==null?void 0:r.approvalId)===t&&(s=a.toolUseId);if(s===null)return null;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===s)return{input:a.input,at:i.at||null};return null}function d3({block:e,messages:t,answeredAt:s}){const r=c3(e.output,u3(t,e.actionId),s),i=[r.who?`Asked ${r.who}`:null,r.durationMs===null?null:`took ${h3(r.durationMs)}`].filter(a=>a!==null);return n.jsxs("div",{className:"wb-delegation-result","data-testid":"delegation-result",children:[i.length>0?n.jsx("p",{className:"wb-delegation-facts",children:i.join(" · ")}):null,r.question?n.jsx("blockquote",{className:"wb-delegation-question",children:r.question}):null,r.answer?n.jsx("div",{className:"wb-delegation-answer","data-testid":"delegation-answer",children:n.jsx(Lr,{text:r.answer})}):n.jsx("p",{className:"wb-delegation-facts",children:"No answer came back."}),r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${r.who??"the colleague"} made`,children:r.files.map(a=>n.jsx("a",{role:"listitem",href:vi(a.artifactId),download:!0,children:n.jsx(Qh,{name:a.filename??"Untitled file",mime:a.mime,sizeBytes:a.sizeBytes,thumbnail:ij(a.mime)?Fr(a.artifactId):null,size:"sm"})},a.artifactId))}):null,n.jsx(St,{summary:"Raw JSON",children:n.jsx("pre",{className:"wb-approval-output mono",children:f3(e.output)})})]})}function h3(e){if(e<1e3)return`${Math.round(e)}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60);return s<60?`${s}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function f3(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function m3(e){return e===null?null:`@${e.replace(/^@/,"")}`}function Pi(e){return typeof e=="string"&&e.trim()!==""?e:null}function uk(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function dk(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const p3=1e3;function g3({messageId:e,text:t,onReadAloud:s}){const[r,i]=d.useState(!1),a=d.useRef(null),l=d.useSyncExternalStore(UU,zU)===e;d.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const o=()=>{var c;(c=navigator.clipboard)==null||c.writeText(t).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),p3)},()=>{})};return n.jsxs("div",{className:"wb-reply-actions","data-testid":"reply-actions",children:[n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",onClick:o,children:n.jsx(ue,{name:r?"check":"copy",size:14})}),r?n.jsx("span",{className:"wb-reply-copied",role:"status",children:"Copied"}):null,s?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":l?"Stop reading aloud":"Read aloud",title:l?"Stop reading aloud":"Read aloud","aria-pressed":l,onClick:()=>l?Tl():s(e,t),children:n.jsx(ue,{name:l?"stop":"play",size:14})}):null]})}function x3(e){const t=v3(e);if(!t)return null;const s=mm(t.diff);if(s!==null)return{kind:"diff",diff:s};const r=mm(t.command),i=mm(t.plain),a=pm(t.exitCode);return r!==null&&(i!==null||a!==null||pm(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:a,elapsedMs:pm(t.elapsedMs)}:null}function mm(e){return typeof e=="string"&&e.trim()!==""?e:null}function pm(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function v3(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const hk="offer:",sA="owner:interjection";function j3(e){return e===sA}function w3(e){if(typeof e!="string"||!e.startsWith(hk))return null;const t=e.slice(hk.length).trim();return t===""?null:t}const fk="brief:";function y3(e){if(typeof e!="string"||!e.startsWith(fk))return null;const t=e.slice(fk.length).trim();return t===""?null:t}function fj({messages:e,live:t,now:s,onOpen:r,working:i=!1,partial:a=null,agents:l,agentId:o,speakers:c,coordinatorId:u,workingAs:h,onOpenFile:f,onReadAloud:m,children:p,agentName:g,emptyHint:x,empty:b,plain:j=!1,workingLine:v,runs:w,onContinue:y}){var F;const N=d.useRef(null);d.useEffect(()=>{var Q;(Q=N.current)==null||Q.scrollIntoView({block:"end"})},[e.length,t.length,i,a==null?void 0:a.text.length,a==null?void 0:a.thinking.length,!!p]);const k=a&&!a.settled&&(a.text!==""||a.thinking!==""),S=e.filter(Q=>(Q.blocks??[]).some(I3)),C=R3(S,w??[]),$=c??l??[],R=Q=>(o&&!c?$.find(X=>X.id===o):void 0)??$.find(X=>X.name===Q)??null,I=o?$.find(Q=>Q.id===o)??null:null,z=i||t.length>0,U=z||!!k,A=!!k&&a.text!=="",P=z&&!A,D=S.at(-1),O=(D==null?void 0:D.role)!=="assistant"||!!h,M=h??g??"Assistant",W=S.filter((Q,X)=>{var Z;return X===0||(c?(((Z=S[X-1])==null?void 0:Z.speaker)??null)!==(Q.speaker??null):S[X-1].role!==Q.role)}),_=U&&!O?((F=W.at(-1))==null?void 0:F.id)??null:null,G=(w??[]).reduce((Q,X)=>Q===null||(X.startedAt??"")>(Q.startedAt??"")?X:Q,null),B=(w??[]).some(Q=>Q.finishedAt===null),K=y&&!U&&!B&&D&&(G==null?void 0:G.stopped)==="max_turns"&&C.get(D.id)===G?D.id:null;return n.jsx(vE.Provider,{value:l??c??[],children:n.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[S.length===0&&t.length===0?b??n.jsx("p",{className:"wb-chat-empty",children:x}):null,S.map((Q,X)=>{const Z=Q.speaker??null,de=c?Z==="owner"||Z===null&&Q.role==="user":Q.role==="user",_e=c&&Z==="room",Ie=c&&Z&&Z!=="owner"&&Z!=="room"?c.find(Ee=>Ee.id===Z)??null:null,Ue=S[X-1],ee=X===0||(c?((Ue==null?void 0:Ue.speaker)??null)!==Z:Ue.role!==Q.role);if(_e)return n.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(Q.blocks??[]).filter(Ee=>Ee.type==="text").map((Ee,ze)=>n.jsx("span",{children:Ee.text},ze))},Q.id);const be=(Q.blocks??[]).filter(Ee=>Ee.type==="approval_result");if(be.length>0)return n.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:be.map((Ee,ze)=>n.jsx(P3,{block:Ee,messages:e,at:Q.at||null},ze))},Q.id);const se=Q.role==="user"&&j3(Z),Te=Q.role==="user"?y3(Z):null;if(Te)return n.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:n.jsx("div",{className:"wb-bubble wb-bubble-offer",children:Te})},Q.id);const pe=Q.role==="user"?w3(Z):null;if(pe){const Ee=(Q.blocks??[]).filter(ze=>ze.type==="text").map(ze=>ze.text).join(`
|
|
96
|
+
`);return n.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:n.jsx("div",{className:"wb-bubble wb-bubble-offer",title:Ee,children:pe})},Q.id)}const Re=c&&Ie&&Q.role==="user"?E3(Q):null;if(Re){const Ee=S.slice(X+1).find(nt=>nt.role==="assistant"&&nt.speaker&&nt.speaker!==Ie.id),ze=Ee!=null&&Ee.speaker?c.find(nt=>nt.id===Ee.speaker):void 0;return n.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[n.jsxs("summary",{children:[Ie.name," asked ",(ze==null?void 0:ze.name)??"a member",Re.request?`: ${Re.request.length>120?`${Re.request.slice(0,119)}…`:Re.request}`:""]}),Re.request?n.jsx("p",{children:Re.request}):null]},Q.id)}const Se=C.get(Q.id)??null,Fe=T3(Q,e),Ze=!de&&!se&&!j?A3(Q):"";return n.jsxs("div",{className:"wb-msg","data-role":de||se?"user":"assistant",children:[se?n.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,ee&&!de&&!se?n.jsx(mk,{name:Ie?Ie.name:c&&Z&&Z!=="owner"&&Z!=="room"?Z:g??"Assistant",face:Ie??I??R(g),moving:P&&_===Q.id,children:Ie&&u===Ie.id?n.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null}):null,Fe.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Fe.map(Ee=>n.jsx("span",{role:"listitem",children:qE(Ee.mime)?n.jsx(QE,{artifactId:Ee.artifactId,name:Ee.filename??"Untitled file",mime:Ee.mime,sizeBytes:Ee.sizeBytes}):n.jsx(Qh,{name:Ee.filename??"Untitled file",mime:Ee.mime,sizeBytes:Ee.sizeBytes,thumbnail:ij(Ee.mime)?Fr(Ee.artifactId):null,...f?{onOpen:()=>f(Ee)}:{}})},Ee.artifactId))}):null,(Q.blocks??[]).map((Ee,ze)=>{const nt=N3(Q.blocks??[],ze,e);if(nt==="inside")return null;if(nt)return n.jsx(S3,{refusals:nt.refusals},ze);if(Ee.type==="thinking")return j||Ee.text.trim()===""?null:n.jsx(Ag,{text:Ee.text},ze);if(Ee.type==="text")return Ee.text.trim()===""?null:de?n.jsx("div",{className:"wb-bubble",children:Ee.text},ze):n.jsx("div",{className:"wb-bubble","data-rich":"true",children:n.jsx(Lr,{text:Ee.text})},ze);if(Ee.type==="attachment")return null;if(Ee.type==="tool_use"){if(j)return null;const Ye=mj(e,Ee.id),J=Ye?O3(Ye):null,je=!J&&Ee.name===JE&&Ye?ZE(Ye.output):null;return n.jsx(Tg,{label:J&&!(Ye!=null&&Ye.delegation)?`Approval · ${Ee.name}`:rr(Ee.name),tool:Ee.name,ok:(Ye==null?void 0:Ye.ok)??null,running:Ye===null,...J?{status:J.status,waiting:J.waiting,approval:!0}:je?{status:je}:{},gist:dj(Ee.name,Ee.input),body:Ye?x3(Ye.output):null,opens:!0,onOpen:()=>r(Ee.id)},ze)}return null}),Se?n.jsxs("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:[n.jsx("span",{children:$3(Se)}),K===Q.id?n.jsx(T,{size:"sm",className:"wb-msg-budget-continue","data-testid":"budget-continue",onClick:y,children:"Continue"}):null]}):null,Q.feedback&&!de&&!se?n.jsx(F3,{feedback:Q.feedback}):null,Ze!==""?n.jsx(g3,{messageId:Q.id,text:Ze,onReadAloud:m}):null]},Q.id)}),U?n.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[O?n.jsx(mk,{name:M,face:R(M)??I,moving:P}):null,k&&a.thinking!==""&&!j?n.jsx(Ag,{text:a.thinking,live:a.text==="",seconds:C3(a.thinkingStartedAt,a.textStartedAt??s)}):null,A?n.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[n.jsx(Lr,{text:a.text}),n.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null,i&&t.length===0&&!k?n.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite","data-testid":"working",children:[v??`${h??g??"The agent"} is working`,n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):null,t.map(Q=>n.jsx(Tg,{label:rr(Q.name),tool:Q.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((s-Q.startedAt)/1e3)),opens:!1,onOpen:()=>r(Q.toolUseId)},Q.toolUseId))]}):null,p,n.jsx("div",{ref:N})]})})}function mk({name:e,face:t,moving:s=!1,children:r}){const i=(t==null?void 0:t.picture)??null,a=pE(s?i:null);return n.jsxs("div",{className:"wb-msg-who","data-testid":"turn-head",children:[n.jsx("span",{className:"wb-msg-mark","data-moving":s?a&&i?"blob":"ring":void 0,children:s&&a&&i?n.jsx(Ec,{state:"working",size:"sm",still:i,className:"wb-msg-blob"}):n.jsx(zs,{id:(t==null?void 0:t.id)??e,name:(t==null?void 0:t.name)??e,unavailable:t?!t.available:!1,...t?{face:t}:{}})}),n.jsx("span",{children:e}),r]})}function b3(e){var t,s;return((s=(t=/ may delegate to ([^;]*);/.exec(e)??/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:s.trim())||null}const k3="delegation refused:";function N3(e,t,s){const r=a=>{const l=e[a];if(!l||l.type!=="tool_use"||l.name!==ji)return null;const o=mj(s,l.id);if(!o||o.ok!==!1)return null;const c=typeof o.error=="string"?o.error:String(o.error??"");if(!c.trimStart().startsWith(k3))return null;const u=l.input??{};return{target:typeof u.agent=="string"&&u.agent!==""?u.agent:"a colleague",message:c}};if(!r(t))return null;if(r(t-1))return"inside";const i=[];for(let a=t;;a+=1){const l=r(a);if(!l)break;i.push(l)}return i.length<2?null:{refusals:i}}function S3({refusals:e}){const[t,s]=d.useState(!1),r=e.map(o=>b3(o.message)).find(o=>o!==null)??null,i=e.map(o=>o.target),a=i.slice(0,3),l=`Delegation refused ${e.length} times: ${a.join(", ")}${i.length>a.length?", …":""}`+(r?` (allowed: ${r})`:"");return n.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>s(o=>!o),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:l}),n.jsx(ue,{name:"arrow",className:"wb-tool-arrow"})]}),t?n.jsx("div",{className:"wb-refusals-list",children:e.map((o,c)=>n.jsxs("div",{className:"wb-refusal",children:[n.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[n.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),n.jsxs("span",{className:"wb-tool-label",children:[rr(ji)," · ",o.target]}),n.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),n.jsx("p",{className:"wb-refusal-why",children:o.message})]},c))}):null]})}function C3(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function Ag({text:e,live:t=!1,seconds:s=null}){const[r,i]=d.useState(!1),a=t?`Thinking${s!==null&&s>0?` · ${s}s`:""}`:s!==null&&s>0?`Thought for ${s}s`:"Thoughts";return n.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(l=>!l),children:[t?n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}):n.jsx(ue,{name:"thought"}),n.jsx("span",{children:a}),n.jsx(ue,{name:"arrow",className:"wb-tool-arrow"})]}),r?n.jsx("div",{className:"wb-thought-text",children:n.jsx(Lr,{text:e})}):null]})}function E3(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",s=/You are a member of the group "[^"]*"\. @([\w-]+), the coordinator, asks you now:\n\n([\s\S]*?)(?:\n\nAnswer for the room|$)/.exec(t);return s?{handle:s[1],request:s[2].trim()}:null}function A3(e){return(e.blocks??[]).filter(t=>t.type==="text").map(t=>t.text.trim()).filter(t=>t!=="").join(`
|
|
97
|
+
|
|
98
|
+
`)}function T3(e,t){const s=[],r=new Set,i=a=>{r.has(a.artifactId)||(r.add(a.artifactId),s.push(a))};for(const a of e.blocks??[])if(a.type==="attachment"&&i(a),a.type==="tool_use"&&a.name===ji){const l=mj(t,a.id);l!=null&&l.ok&&Dd(l.output).forEach(i)}return s}function R3(e,t){const s=t.filter(l=>l.startedAt!==null&&l.finishedAt!==null),r=(l,o)=>o.at!==""&&o.at>=l.startedAt&&o.at<=l.finishedAt,i=(l,o)=>l!==o&&l.startedAt>=o.startedAt&&l.finishedAt<=o.finishedAt&&(l.startedAt>o.startedAt||l.finishedAt<o.finishedAt),a=new Map;for(const l of s){if(l.stopped!=="max_turns"&&l.stopped!=="max_tokens"||l.noticed!==!0||l.runId===null)continue;let o=null;for(const c of e)c.role!=="assistant"||!r(l,c)||(o=c);o===null||s.some(c=>i(c,l)&&r(c,o))||a.has(o.id)||a.set(o.id,l)}return a}function $3(e){if(e.stopped==="max_tokens")return"Length limit reached · answer cut off";const t=e.turns;return t===null?"Turn budget reached":`Turn budget reached · ${t} ${t===1?"step":"steps"}`}function I3(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function P3({block:e,messages:t,at:s}){const[r,i]=d.useState(!1),a=e.state==="succeeded";return n.jsxs("div",{className:"wb-approval","data-open":r||void 0,children:[n.jsxs("button",{type:"button",className:"wb-tool","data-ok":a,"aria-expanded":r,onClick:()=>i(l=>!l),children:[n.jsx("span",{className:"wb-tool-mark","data-ok":a?"true":"false","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":rr(e.name)}),n.jsx("span",{className:"wb-tool-elapsed",children:e.state}),n.jsx(ue,{name:"arrow",className:"wb-tool-arrow"})]}),r&&e.name===ji?n.jsx(d3,{block:e,messages:t,answeredAt:s}):null,r&&e.name!==ji?n.jsx("pre",{className:"wb-approval-output mono",children:M3(e.output)}):null]})}function M3(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const D3=40;function O3(e){var s,r;if(((s=e.delegation)==null?void 0:s.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(Eg(e))return{status:"waiting",waiting:!0};const t=(r=e.approval)==null?void 0:r.state;return t?t==="approved"||t==="executing"?{status:"approved",waiting:!0}:t==="succeeded"?{status:"approved",waiting:!1}:{status:t,waiting:!1}:null}function Tg({label:e,tool:t,ok:s,running:r,elapsed:i,opens:a,onOpen:l,status:o,waiting:c=!1,approval:u=!1,gist:h=null,body:f=null}){const[m,p]=d.useState(!1),g=n.jsxs(n.Fragment,{children:[r?n.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):n.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":s===!1?"false":"true","aria-hidden":"true"}),n.jsx("span",{className:"wb-tool-label",children:e}),h?n.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:h}):null,i===void 0?null:n.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),o||s===!1?n.jsx("span",{className:"wb-tool-elapsed",children:o??"failed"}):null]}),x={"data-ok":s===null?void 0:s,"data-running":r,"data-gist":h?!0:void 0,"data-approval":u||void 0};return f?n.jsxs("div",{className:"wb-toolcall","data-open":m||void 0,children:[n.jsxs("div",{className:"wb-tool","data-split":"true",...x,children:[n.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":m,onClick:()=>p(b=>!b),children:[n.jsx(ue,{name:"chevron",className:"wb-tool-chevron"}),g]}),a?n.jsxs(Ko,{children:[n.jsx(Vo,{asChild:!0,children:n.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:l,children:n.jsx(ue,{name:"arrow",className:"wb-tool-arrow"})})}),n.jsx(Go,{children:n.jsxs(Yo,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),m?n.jsx(L3,{body:f,onOpen:a?l:null}):null]}):a?n.jsxs(Ko,{children:[n.jsx(Vo,{asChild:!0,children:n.jsxs("button",{className:"wb-tool",...x,onClick:l,children:[g,n.jsx(ue,{name:"arrow",className:"wb-tool-arrow"})]})}),n.jsx(Go,{children:n.jsxs(Yo,{className:"ui-tip",sideOffset:6,children:[n.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),n.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):n.jsx("span",{className:"wb-tool","data-static":"true",...x,children:g})}function L3({body:e,onOpen:t}){const s=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return n.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:n.jsx(Id,{text:e.diff,limit:D3,...s?{more:s}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:_3(e.elapsedMs)].filter(i=>i!==null);return n.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[n.jsxs("div",{className:"wb-tool-command",children:[n.jsx("code",{className:"mono",children:e.command}),r.length>0?n.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?n.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function _3(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function mj(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function F3({feedback:e}){const t=e.source==="telegram"?"on Telegram":`on ${e.source}`;return n.jsxs("div",{className:"wb-msg-feedback","data-value":e.value,"data-testid":"message-feedback",title:`You reacted ${e.emoji} ${t}`,children:[n.jsx("span",{className:"wb-msg-feedback-emoji","aria-label":`You reacted ${e.emoji} ${t}`,children:e.emoji}),n.jsx("span",{children:t}),e.note?n.jsxs("span",{className:"wb-msg-feedback-note",children:["“",e.note,"”"]}):null]})}const rA="approval-dock";function z3(){var t;const e=document.getElementById(rA);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const U3=["workspace","cwd","workdir","root"];function B3({approvals:e,timezone:t,now:s,version:r,onDecided:i,onSay:a,onOpenFull:l}){const[o,c]=d.useState([]),u=e.filter(m=>!o.includes(m.approvalId)),h=u[0];if(!h)return null;const f=m=>c(p=>p.includes(m)?p:[...p,m]);return n.jsx(W3,{item:h,count:u.length,timezone:t,now:s,version:r,onSettled:m=>{f(h.approvalId),m&&i(m)},onSay:a,onOpenFull:()=>l(h.toolUseId)},h.approvalId)}function W3({item:e,count:t,timezone:s,now:r,version:i,onSettled:a,onSay:l,onOpenFull:o}){var C;const[c,u]=d.useState(null),[h,f]=d.useState(null),[m,p]=d.useState(null),[g,x]=d.useState("");d.useEffect(()=>{let $=!1;return E.approval(e.approvalId).then(R=>{$||(u(R),R.state!=="pending"&&a(R))}).catch(R=>{$||f(R instanceof me?R.message:String(R))}),()=>{$=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&a({...c,state:"expired"})},[b]);const{values:j,controls:v}=sj(c==null?void 0:c.choices),w=($,R)=>{const I=g.trim();p($),f(null),(j&&$==="approve"?E.decide(e.approvalId,$,R,j):E.decide(e.approvalId,$,R)).then(z=>{a(z.action),I&&l(I)}).catch(z=>{f(z instanceof me?z.message:String(z)),p(null)})},y=m!==null||c===null||c.state!=="pending",N=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,k=c?dj(c.tool,c.canonicalArgs)??K3(c.preview):null,S=c?H3(c):null;return n.jsxs("section",{id:rA,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?n.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,n.jsx("strong",{children:c?rr(c.tool):"Loading the request…"}),e.askedBy?n.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),k||S?n.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[k?n.jsx("code",{className:"wb-dock-gist",children:k}):null,S?n.jsxs("span",{className:"wb-dock-where",children:["in ",n.jsx("span",{className:"mono",children:S})]}):null]}):null,v?n.jsx("div",{className:"wb-dock-section",children:v}):null,n.jsx(ae,{message:h}),n.jsx("div",{className:"wb-dock-section",children:n.jsx("input",{className:"wb-dock-instead",value:g,onChange:$=>x($.target.value),onKeyDown:$=>{$.key==="Enter"&&$.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:m!==null})}),n.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[n.jsxs("span",{className:"wb-dock-meta",children:[c?n.jsxs(n.Fragment,{children:["Expires ",et(c.expiresAt,s)," · "]}):null,n.jsx("button",{type:"button",className:"wb-link",onClick:o,children:"See the full request on the Canvas"})]}),n.jsx(T,{variant:"ghost",size:"sm",disabled:y,onClick:()=>w("reject"),children:m==="reject"?"Rejecting…":"Reject"}),N?n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",size:"sm",disabled:y,onClick:()=>w("approve","conversation"),children:"Auto: this conversation"}),n.jsx(T,{size:"sm",disabled:y,onClick:()=>w("approve","always"),children:"Always: this agent"})]}):null,n.jsx(T,{variant:"good",size:"sm",disabled:y,onClick:()=>w("approve"),children:m==="approve"?"Approving…":N?"Allow once":"Approve"})]})]})}function H3(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const s of U3){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function K3(e){const t=(e??"").split(`
|
|
99
|
+
`).map(s=>s.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const V3=2e3;function G3({conversationId:e,agentId:t,runId:s=null,result:r=null,waiting:i=null,agents:a=[]}){const l=r!==null,[o,c]=d.useState(l),u=!o||i!==null,{data:h,error:f}=ce(()=>Be.conversation(e),[e,o,(i==null?void 0:i.approvalId)??null],u?V3:void 0),m=(h==null?void 0:h.runs)??[],p=s===null?null:m.find(y=>y.runId===s)??null,g=l||i===null&&(s!==null?p!==null&&p.finishedAt!==null:m.length>0&&m.every(y=>y.finishedAt!==null));d.useEffect(()=>{g&&c(!0)},[g]);const x=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":g?"done":"working",b=a.find(y=>y.id===t)??null,j=(b==null?void 0:b.name)??(h==null?void 0:h.agentId)??t,v=(h==null?void 0:h.messages)??[],w=(r==null?void 0:r.text)??Y3(v);return n.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":x,children:[n.jsxs("header",{className:"wb-delegate-head",children:[n.jsx(gn,{agents:a,id:t}),n.jsxs("div",{className:"wb-delegate-who",children:[n.jsx("strong",{children:j}),n.jsx("span",{className:"wb-delegate-status","data-status":x,role:"status",children:x==="working"?n.jsxs(n.Fragment,{children:["Working",n.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]})]}):x==="waiting"?"Waiting for your approval":x==="failed"?"Failed":"Done"})]})]}),f?n.jsx("p",{className:"muted",children:f}):null,n.jsx("div",{className:"wb-delegate-work",children:v.map((y,N)=>n.jsx("div",{className:"wb-delegate-turn",children:(y.blocks??[]).map((k,S)=>{if(k.type==="thinking")return k.text.trim()===""?null:n.jsx(Ag,{text:k.text},S);if(k.type==="tool_use"){const C=Q3(q3(v,k.id));return n.jsx(Tg,{label:rr(k.name),tool:k.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:dj(k.name,k.input),opens:!1,onOpen:()=>{}},S)}return null})},y.id??N))}),w?n.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:n.jsx(Lr,{text:w})}):x==="working"||x==="waiting"?n.jsxs("p",{className:"muted",children:[j," has not answered yet."]}):null,r!=null&&r.files&&r.files.length>0?n.jsx("div",{className:"wb-msg-files",role:"list","aria-label":`Files ${j} made`,"data-testid":"delegate-files",children:r.files.map(y=>n.jsx("a",{role:"listitem",href:vi(y.artifactId),download:!0,children:n.jsx(Qh,{name:y.filename??"Untitled file",mime:y.mime,sizeBytes:y.sizeBytes,thumbnail:ij(y.mime)?Fr(y.artifactId):null})},y.artifactId))}):null,n.jsxs("div",{className:"wb-delegate-actions",children:[x==="waiting"?n.jsx(T,{variant:"accent",onClick:()=>z3(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,n.jsx("a",{className:"ui-btn",href:at(t||(h==null?void 0:h.agentId)||"",e),children:"Open this conversation"})]})]})}function Y3(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t];if(s.role!=="assistant")continue;const r=(s.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
|
|
100
|
+
|
|
101
|
+
`);if(r!=="")return r}return null}function q3(e,t){for(const s of e)for(const r of s.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function Q3(e){var s;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(s=e.approval)==null?void 0:s.state;return t==="pending"?{running:!1,ok:null,waiting:!0,status:"waiting approval"}:t==="approved"||t==="executing"?{running:!0,ok:null,waiting:!1,status:"running"}:t==="succeeded"?{running:!1,ok:!0,waiting:!1,status:void 0}:t?{running:!1,ok:!1,waiting:!1,status:t}:{running:!1,ok:e.ok,waiting:!1,status:void 0}}const pk=1024*1024;function X3({files:e,agentId:t,root:s,revision:r}){const[i,a]=d.useState({kind:"dir",path:""});return d.useEffect(()=>a({kind:"dir",path:""}),[e.plugin,t]),n.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?n.jsx(J3,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a}):n.jsx(Z3,{files:e,agentId:t,root:s,path:i.path,revision:r,go:a})})}function iA({root:e,path:t,go:s}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((a,l)=>({label:a,path:r.slice(0,l+1).join("/")}))];return n.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((a,l)=>{const o=l===i.length-1;return n.jsxs("span",{className:"wb-files-crumb",children:[l>0?n.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,o?n.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:a.label}):n.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>s({kind:"dir",path:a.path}),children:a.label})]},a.path)})})}function J3({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1),[m,p]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),E.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(j=>{b||o(j.data)}).catch(j=>{b||u(j instanceof Error?j.message:String(j))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>p(null),[r]);const g=async()=>{f(!0),p(null);try{const b=await fetch(E.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const y=await b.json().catch(()=>null);p((y==null?void 0:y.error)??"The archive could not be made.");return}const j=await b.blob(),v=URL.createObjectURL(j),w=document.createElement("a");w.href=v,w.download=`${r===""?s:r.split("/").at(-1)}.zip`,w.click(),window.setTimeout(()=>URL.revokeObjectURL(v),1e4)}catch{p("The archive could not be made.")}finally{f(!1)}},x=l&&l.path===r?l.entries:null;return n.jsxs(n.Fragment,{children:[n.jsxs(le,{children:[n.jsx(iA,{root:s,path:r,go:a}),n.jsx(_t,{}),n.jsx(T,{size:"sm",onClick:()=>void g(),disabled:h||x===null||x.length===0,children:h?"Packing…":"Download as archive"})]}),m?n.jsx(V,{tone:"warning",role:"alert",children:m}):null,c?n.jsx(V,{tone:"critical",role:"alert",children:c}):null,x===null?c?null:n.jsx(xe,{children:"Reading the folder…"}):x.length===0?n.jsx(xe,{children:r===""?n.jsxs(n.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",n.jsx("a",{href:Or,children:"Files library"})," and mention it here."]}):"This folder is empty."}):n.jsx(dt,{children:x.map(b=>n.jsx(it,{href:"#",onClick:()=>a({kind:b.kind,path:b.path}),lead:n.jsx(t6,{kind:b.kind}),title:n.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?Fn(b.bytes):void 0},b.path))}),l&&l.path===r&&(l.skipped>0||l.truncated)?n.jsxs("p",{className:"wb-files-note",children:[l.truncated?`Only the first ${l.entries.length} entries are shown. `:"",l.skipped>0?`${l.skipped} ${l.skipped===1?"entry is":"entries are"} not shown: symbolic links and protected paths are never read.`:""]}):null]})}function Z3({files:e,agentId:t,root:s,path:r,revision:i,go:a}){const[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1);d.useEffect(()=>{let j=!1;return u(null),E.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(v=>{j||o(v.data)}).catch(v=>{j||u(v instanceof Error?v.message:String(v))}),()=>{j=!0}},[e.plugin,e.stat,t,r,i]);const m=l&&l.path===r?l:null,p=m?`${m.bytes}-${Math.round(m.mtimeMs)}`:"",g=m?E.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:p}):"",x=E.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(m==null?void 0:m.type)==="text"&&m.bytes<=pk;return n.jsxs(n.Fragment,{children:[n.jsxs(le,{children:[n.jsx(iA,{root:s,path:r,go:a}),n.jsx(_t,{}),b?n.jsx(T,{size:"sm","aria-pressed":h,onClick:()=>f(j=>!j),children:"Wrap"}):null,n.jsx(Tt,{size:"sm",href:x,download:(m==null?void 0:m.name)??r.split("/").at(-1),children:"Download"})]}),c?n.jsx(V,{tone:"critical",role:"alert",children:c}):null,m===null?c?null:n.jsx(xe,{children:"Reading the file…"}):m.type==="image"?n.jsx("figure",{className:"wb-files-picture",children:n.jsx("img",{src:g,alt:m.name})}):m.type==="pdf"?n.jsx("div",{className:"file-preview file-preview-pdf",children:n.jsx("object",{data:g,type:"application/pdf","aria-label":m.name,children:n.jsx(V,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?n.jsx(e6,{src:g,wrap:h}):n.jsxs(n.Fragment,{children:[n.jsx(V,{children:m.type==="text"?`This file is over ${Fn(pk)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),n.jsx(Wt,{items:[{label:"Size",value:Fn(m.bytes)},{label:"Type",value:n.jsx("span",{className:"mono",children:m.mime})}]})]})]})}function e6({src:e,wrap:t}){const[s,r]=d.useState(null),[i,a]=d.useState(!1);return d.useEffect(()=>{let l=!1;return a(!1),fetch(e,{credentials:"same-origin"}).then(async o=>{if(!o.ok)throw new Error(String(o.status));const c=await o.text();l||r(c)}).catch(()=>{l||a(!0)}),()=>{l=!0}},[e]),i?n.jsx(V,{tone:"critical",children:"The file could not be read."}):s===null?n.jsx(xe,{children:"Reading the file…"}):s===""?n.jsx(xe,{children:"This file is empty."}):n.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:s})}function t6({kind:e}){return n.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:e==="dir"?n.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):n.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}function n6({input:e,output:t,ok:s}){const r=XU(e),i=ZE(t)??(s?"sent":"not sent");return n.jsxs("div",{className:"wb-envelope",children:[n.jsxs("div",{className:"envelope",children:[n.jsxs("dl",{className:"envelope-head",children:[n.jsx("dt",{children:"To"}),n.jsx("dd",{className:"wb-envelope-action",children:"You"}),n.jsx("dt",{children:"Status"}),n.jsx("dd",{children:n.jsx(ve,{tone:JU(i,s),dot:!0,children:i})})]}),n.jsxs("div",{className:"envelope-body",children:[n.jsx("strong",{children:r.title}),r.text?`
|
|
102
|
+
|
|
103
|
+
${r.text}`:null]})]}),n.jsx(St,{summary:"The call",children:n.jsxs("dl",{className:"ui-kv wb-envelope-fields",children:[n.jsx("dt",{children:"Urgency"}),n.jsx("dd",{children:r.urgency}),r.link?n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Link"}),n.jsx("dd",{className:"mono",children:r.link})]}):null,r.key?n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:"Key"}),n.jsx("dd",{className:"mono",children:r.key})]}):null]})})]})}const s6=3,r6=152,i6=104,a6=100,l6=2,gk=5;function o6({renderables:e,activeId:t,onActivate:s,timezone:r,onDecided:i,onChangeAgent:a,face:l,descriptors:o,grantedTools:c,agentName:u,maxTabs:h,browserPanel:f,agents:m,onClose:p,loading:g=!1}){const[x,b]=c6(h);if(e.length===0)return n.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[n.jsx("div",{className:"wb-canvas-tabs",ref:x,"aria-hidden":"true",children:n.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),n.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:g?null:n.jsxs("div",{className:"wb-empty",children:[l?n.jsx("span",{className:"wb-empty-face",children:l}):null,n.jsx("p",{className:"ui-empty wb-empty-line",children:m6(u,p6(o??[],c??[]))})]})})]});const j=e.some(y=>y.id===t)?t:e[e.length-1].id,{shown:v,hidden:w}=u6(e,j,b);return n.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:n.jsxs(D_,{value:j,onValueChange:s,className:"contents",children:[n.jsxs("div",{className:"wb-canvas-tabs",ref:x,children:[n.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),n.jsx(O_,{className:"wb-tabstrip","aria-label":"Canvas",children:v.map(y=>n.jsxs("div",{className:"wb-tab-item",children:[n.jsxs(L_,{value:y.id,className:"wb-tab","data-tone":y.tone,onKeyDown:N=>{N.key==="Delete"&&p&&xk(y)&&(N.preventDefault(),p(y.id))},children:[y.tone==="warning"||y.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":y.tone,"aria-hidden":"true"}):null,n.jsx("span",{className:"wb-tab-text",children:y.title})]}),p&&xk(y)?n.jsx("button",{className:"wb-tab-close","aria-label":`Close ${y.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>p(y.id),children:"×"}):null]},y.id))}),n.jsx(d6,{items:w,onActivate:s,timezone:r})]}),e.map(y=>n.jsx(__,{value:y.id,className:"wb-canvas-body","data-renderer":y.source==="descriptor"&&y.renderer==="preview"?"preview":void 0,"data-dense":x6.has(y.renderer)?"true":void 0,children:n.jsxs("section",{className:"ui-panel","data-flush":y.source==="descriptor"&&y.renderer==="preview"?"true":void 0,children:[y.source!=="browser"&&y.source!=="files"&&!(y.source==="descriptor"&&y.renderer==="preview")?n.jsxs("header",{className:"ui-panel-head",children:[n.jsx("h2",{className:"ui-panel-title",children:y.title}),n.jsx("span",{className:"ui-panel-tool mono",children:y.tool})]}):null,y.tone==="critical"?n.jsxs("p",{className:"muted",children:["Recorded tool failure",y.at?` · ${et(y.at,Intl.DateTimeFormat().resolvedOptions().timeZone)}`:"",". This is history, not live session status."]}):null,y.source==="browser"?f:y.source==="profile"?n.jsx(NU,{...y.props,...a?{onChange:a}:{}}):y.source==="artifact"?n.jsx(GU,{...y.props}):y.source==="files"?n.jsx(X3,{...y.props}):y.source==="notify"?n.jsx(n6,{...y.props}):y.source==="delegate"?n.jsx(G3,{...y.props,agents:m??[]}):n.jsx(kU,{renderer:y.renderer,props:y.props,timezone:r,onDecided:i})]})},y.id))]})})}function xk(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function c6(e){const[t,s]=d.useState(gk),r=d.useRef(null);return[d.useCallback(a=>{var o;if((o=r.current)==null||o.disconnect(),r.current=null,!a||e!==void 0||typeof ResizeObserver>"u")return;const l=()=>{const c=a.clientWidth;if(c===0)return;const u=Math.floor((c-a6-i6)/r6);s(Math.max(l6,Math.min(gk,u)))};l(),r.current=new ResizeObserver(l),r.current.observe(a)},[e]),e??t]}function u6(e,t,s){const r=new Set(e.filter(a=>a.id===t||a.source==="approval"||a.pinned===!0).map(a=>a.id)),i=new Set(r);for(let a=e.length-1;a>=0&&i.size<s;a-=1)i.add(e[a].id);return{shown:e.filter(a=>i.has(a.id)),hidden:e.filter(a=>!i.has(a.id))}}function d6({items:e,onActivate:t,timezone:s}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return n.jsxs(bc,{modal:!1,children:[n.jsx(kc,{asChild:!0,children:n.jsxs("button",{className:"wb-tab wb-tab-more","data-tone":r??void 0,"aria-label":`${e.length} more ${e.length===1?"view":"views"} in this conversation`,children:[r?n.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,n.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),n.jsx(ue,{name:"chevron-down"})]})}),n.jsx(Nl,{children:n.jsxs(Nc,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[n.jsx(ta,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>n.jsxs(us,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[n.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?n.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),n.jsx("span",{className:"ui-menu-note mono",children:h6(i.at,s)??i.tool})]},i.id))]})})]})}function h6(e,t){if(!e)return null;const s=new Date(e);return Number.isNaN(s.getTime())?null:Ht(s,t)}const f6={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",tiles:"cards",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function m6(e,t){const s=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>f6[i.renderer]??"results"))].slice(0,3);return r.length>0?`${s} lands here: ${r.join(", ")}.`:`${s} lands here.`}function p6(e,t){const s=new Set(t),r=new Set,i=e.filter(c=>{if(!s.has(c.tool))return!1;const u=g6(c);return r.has(u)?!1:(r.add(u),!0)}),a=new Set,l=i.filter(c=>a.has(c.renderer)?!1:(a.add(c.renderer),!0)),o=i.filter(c=>!l.includes(c));return[...l,...o].slice(0,s6)}function g6(e){return e.title&&e.title.trim()!==""?e.title:e.tool.split(".").map(t=>t.replace(/[_-]+/g," ")).join(" · ").replace(/\b\w/,t=>t.toUpperCase())}const x6=new Set(["table","diff","files"]),v6=3.5*6e4,j6=2e3;function w6(e,t,s={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),a=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};a.current=u.served,i(u)}const l=s.check??E.previewCheck,o=s.everyMs??j6,c=e.map(u=>`${qa(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const p of e){const g=qa(p);if(a.current.has(g))continue;const x=p.at===null?Number.NaN:Date.parse(p.at),b=Number.isNaN(x)?0:x+v6,j=u.get(g);(!j||b>j.until)&&u.set(g,{plugin:p.plugin,name:p.name,until:b})}if(u.size===0)return;let h=!1,f;const m=async()=>{const p=Date.now();for(const[g,x]of[...u]){const b=await l(x.plugin,x.name).catch(()=>null);if(h)return;const j=p<=x.until;b!=null&&b.ok?(u.delete(g),i(v=>{const w={served:new Set(v.served).add(g),live:j?new Set(v.live).add(g):v.live,scope:v.scope};return a.current=w.served,w})):j||u.delete(g)}!h&&u.size>0&&(f=setTimeout(()=>void m(),o))};return m(),()=>{h=!0,f!==void 0&&clearTimeout(f)}},[c,t,l,o]),r}const Rg="workspace-files";function y6(e){let t=0;for(const s of e)for(const r of s.blocks??[]){if(r.type!=="tool_result"||r.ok===!1)continue;const i=r.output;if(i===null||typeof i!="object"||Array.isArray(i))continue;const{diff:a,path:l}=i;typeof a=="string"&&a.trim()!==""&&typeof l=="string"&&l!==""&&(t+=1)}return t}function b6(e){const[t,s]=d.useState(null);return d.useEffect(()=>{if(s(null),!e)return;let r=!1;return(async()=>{var a;const i=await E.pages();for(const l of Array.isArray(i==null?void 0:i.files)?i.files:[]){const o=await E.pageQuery(l.plugin,l.workspace,{agent:e}).catch(()=>null),c=(a=o==null?void 0:o.data)==null?void 0:a.workspace;if(c&&typeof c.name=="string")return{files:l,agentId:e,root:c.name}}return null})().then(i=>{r||s(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function k6(e,t){return{id:Rg,tool:"",title:"Files",renderer:"files",props:{files:e.files,agentId:e.agentId,root:e.root,revision:t},at:null,source:"files",pinned:!0,substantial:!1}}function $g(e){return`agent-properties:${e}`}function N6(e){return{id:$g(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function S6(e){return!e||e.download===0?"Fetching the browser…":e.phase==="downloading"?`Fetching ${e.what}… ${e.percent}%`:e.phase==="installing"?`Setting up ${e.what}…`:e.phase==="done"?"Installed.":"The install stopped."}function aA({progress:e}){return n.jsxs(re,{gap:"sm",children:[n.jsx("span",{role:"status",children:S6(e)}),n.jsx(AE,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function C6(e,t,s,r){const i=e.width||1,a=e.height||1,l=t.pageScaleFactor||1,o=(s-e.left)*(t.deviceWidth/i)/l,c=((r-e.top)*(t.deviceHeight/a)-t.offsetTop)/l,u=(h,f)=>Math.max(0,Math.min(Math.round(h),Math.round(f)));return{x:u(o,t.deviceWidth),y:u(c,t.deviceHeight)}}function gm(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function vk(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const E6=4e3;function A6(e){return e.replace(/\r\n?/g,`
|
|
104
|
+
`).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,E6)}const T6=["left","middle","right"],R6=33;function $6(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function I6(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const s=t.getUint16(1);if(e.byteLength<3+s)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,s))),jpeg:new Blob([new Uint8Array(e,3+s)],{type:"image/jpeg"})}}catch{return null}}function P6(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function M6({sessionId:e,csrf:t,onGiveBack:s,connect:r}){const[i,a]=d.useState("connecting"),[l,o]=d.useState(null),[c,u]=d.useState(!1),[h,f]=d.useState(null),[m,p]=d.useState(!1),[g,x]=d.useState(0),b=d.useRef(null),j=d.useRef(null),v=d.useRef(null),w=d.useRef({at:0});d.useEffect(()=>{const A=r??(O=>new WebSocket(O));let P=!0,D;try{D=A(P6())}catch{a("lost");return}return D.binaryType="arraybuffer",b.current=D,D.onopen=()=>D.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),D.onmessage=O=>{if(!P)return;if(typeof O.data!="string"){const W=I6(O.data);if(!W||(f(_=>_&&$6(_,W.metadata)?_:W.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(W.jpeg).then(_=>{var B,K,F;const G=j.current;if(!P||!G){(B=_.close)==null||B.call(_);return}(G.width!==_.width||G.height!==_.height)&&(G.width=_.width,G.height=_.height),(K=G.getContext("2d"))==null||K.drawImage(_,0,0),(F=_.close)==null||F.call(_)}).catch(()=>{});return}const M=JSON.parse(O.data);if(M.type==="driving"){a("driving"),o(null);return}(M.type==="refused"||M.type==="ended")&&(o(M.error??"The screen cannot be driven from here."),a("refused"))},D.onclose=()=>{P&&a(O=>O==="refused"?O:"lost")},D.onerror=()=>{P&&a(O=>O==="refused"?O:"lost")},()=>{P=!1,b.current=null;try{D.close()}catch{}}},[e,t,g,r]),d.useEffect(()=>()=>{clearTimeout(w.current.timer)},[]);const y=d.useCallback(A=>{const P=b.current;if(P)try{P.send(JSON.stringify({type:"input",input:A}))}catch{}},[]),N=A=>{var O;const P=j.current;if(!P||!h)return null;const D=(O=P.getBoundingClientRect)==null?void 0:O.call(P);return D?C6(D,h,A.clientX,A.clientY):null},k=A=>{const P=w.current,D=Date.now();clearTimeout(P.timer),P.timer=void 0;const O=P.at+R6-D;if(O<=0){P.at=D,P.pending=void 0,y(A);return}P.pending=A,P.timer=setTimeout(()=>{const M=w.current.pending;w.current.timer=void 0,w.current.pending=void 0,w.current.at=Date.now(),M&&y(M)},O)},S=()=>{const A=w.current;clearTimeout(A.timer),A.timer=void 0;const P=A.pending;A.pending=void 0,P&&(A.at=Date.now(),y(P))},C=A=>P=>{var M,W;const D=N(P);if(!D)return;A==="mousePressed"&&(P.preventDefault(),(W=(M=j.current)==null?void 0:M.focus)==null||W.call(M));const O={kind:"mouse",type:A,x:D.x,y:D.y,button:T6[P.button]??"left",clickCount:A==="mouseMoved"?0:Math.min(3,Math.max(1,P.detail||1)),modifiers:gm(P)};if(A==="mouseMoved"){k(O);return}S(),y(O)},$=A=>{const P=N(A);P&&(S(),y({kind:"wheel",x:P.x,y:P.y,deltaX:Math.round(A.deltaX),deltaY:Math.round(A.deltaY)}))},R=A=>A.ctrlKey||A.metaKey||A.altKey,I=A=>{var D,O;if(A.key==="Escape"&&R(A)){p(!1),(O=(D=A.target).blur)==null||O.call(D);return}if(A.preventDefault(),(A.metaKey||A.ctrlKey)&&(A.key==="v"||A.key==="V"))return;const P=gm(A);if(vk(A.key)&&!R(A)){y({kind:"key",type:"char",key:A.key,code:A.code,text:A.key,modifiers:P});return}y({kind:"key",type:"keyDown",key:A.key,code:A.code,modifiers:P})},z=A=>{A.key==="Escape"&&R(A)||(A.preventDefault(),!((A.metaKey||A.ctrlKey)&&(A.key==="v"||A.key==="V"))&&(vk(A.key)&&!R(A)||y({kind:"key",type:"keyUp",key:A.key,code:A.code,modifiers:gm(A)})))},U=A=>{var D;A.preventDefault();const P=A6(((D=A.clipboardData)==null?void 0:D.getData("text/plain"))??"");P!==""&&y({kind:"text",text:P})};return n.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[n.jsxs("div",{className:"hand-bar",children:[n.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),n.jsxs(le,{align:"end",children:[n.jsx(T,{size:"sm",variant:m?"accent":"ghost","aria-pressed":m,onClick:()=>{var P,D,O,M;const A=!m;p(A),A?(D=(P=v.current)==null?void 0:P.focus)==null||D.call(P):(M=(O=v.current)==null?void 0:O.blur)==null||M.call(O)},children:"Keyboard"}),n.jsx(T,{size:"sm",variant:"accent",onClick:s,children:"Give it back"})]})]}),i==="lost"?n.jsxs(V,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",n.jsx(le,{align:"end",children:n.jsx(T,{size:"sm",variant:"accent",onClick:()=>{a("connecting"),x(A=>A+1)},children:"Reconnect"})})]}):null,i==="refused"&&l?n.jsx(V,{tone:"warning",role:"status",children:l}):null,n.jsx("div",{className:"hand-screen",children:c?n.jsx("canvas",{ref:j,className:"hand-picture",role:"img","aria-label":"The host browser, live","data-testid":"hand-picture",tabIndex:0,onMouseDown:C("mousePressed"),onMouseUp:C("mouseReleased"),onMouseMove:C("mouseMoved"),onWheel:$,onKeyDown:I,onKeyUp:z,onPaste:U,onContextMenu:A=>A.preventDefault()}):n.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),n.jsx("input",{ref:v,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:I,onKeyUp:z,onPaste:U,onBlur:()=>p(!1)})]})}function D6(e){return e==="darwin"?"this Mac":"this computer"}let xm=null;function pj(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let s=!0;return xm??(xm=E.session().then(r=>r.platform,()=>{xm=null})),xm.then(r=>{s&&t(r)}),()=>{s=!1}},[]),D6(e)}function O6({embedded:e,timezone:t}={}){var c;const{data:s,error:r,reload:i}=ce(()=>E.browser(),[],3e3),a=ce(()=>E.session(),[]),l=(c=a.data)!=null&&c.platform?a.data.platform==="darwin":!0,o=!!a.data||!!a.error;return n.jsxs(An,{embedded:e,title:"Computer & browser",children:[n.jsx(ae,{message:r}),!s||!o?n.jsx(xe,{children:"Checking the host…"}):n.jsx(L6,{data:s,macOS:l,reload:i,timezone:t},JSON.stringify(s.settings??null))]})}function L6({data:e,macOS:t,reload:s,timezone:r}){var S,C,$;const[i,a]=d.useState(!1),[l,o]=d.useState(null),[c,u]=d.useState(!1),h=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(h==null?void 0:h.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),m=f==="computer",p=(S=e.sessions)!=null&&S.length?e.sessions:e.session?[e]:[],g=p.length>0||e.busy,x=async R=>{a(!0),o(null);try{await R()}catch(I){o(I instanceof Error?I.message:String(I))}finally{a(!1),s()}},b=R=>void x(()=>E.browserSettings(R)),j=e.permissions,v=f==="playwright"?e.browser:void 0,w=((C=v==null?void 0:v.install)==null?void 0:C.state)==="running",y=(v==null?void 0:v.engine)==="none",N=!!e.enabled&&!y&&!(v!=null&&v.problem)&&(!m||!(j!=null&&j.supported)||j.accessibility&&j.screenRecording),k=m?"Ready. Agents can use your computer within the apps you allow below.":f==="extension"?"Ready. Agents work in your Chrome, in background tabs, through the buddi extension.":(v==null?void 0:v.engine)==="chrome"?"Ready. Agents work in their own browser, a separate Google Chrome profile. Your apps are never touched.":"Ready. Agents work in their own browser. Your apps are never touched.";return n.jsxs(re,{gap:"lg",children:[n.jsx(ae,{message:l}),n.jsx(oe,{title:"Status",panel:!0,actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",disabled:i,onClick:()=>void x(()=>E.computerPermissions(!1)),children:"Check again"}),m&&!N&&(j!=null&&j.supported)?n.jsx(T,{size:"sm",variant:"accent",disabled:i||g,onClick:()=>void x(()=>E.computerPermissions(!0)),children:"Request macOS permissions"}):null,y||w?n.jsx(T,{size:"sm",variant:"accent",disabled:i||w,onClick:()=>void x(()=>E.browserInstall()),children:w?"Installing…":"Install Chromium"}):null]}),children:n.jsxs(re,{children:[e.enabled?y?n.jsxs(V,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",n.jsx("code",{children:"buddi browser install"})," on this machine."]}):v!=null&&v.problem?n.jsx(V,{tone:"warning",children:v.message}):N?n.jsx(V,{tone:"good",children:k}):n.jsx(V,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):n.jsx(V,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),m?j!=null&&j.supported?n.jsxs("ul",{className:"perm-list",children:[n.jsxs("li",{className:"perm-row",children:[n.jsx(ve,{tone:j.accessibility?"good":"warning",children:j.accessibility?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Accessibility"}),n.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),n.jsxs("li",{className:"perm-row",children:[n.jsx(ve,{tone:j.screenRecording?"good":"warning",children:j.screenRecording?"Granted":"Needed"}),n.jsx("span",{className:"perm-name",children:"Screen Recording"}),n.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):j?n.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,(($=v==null?void 0:v.install)==null?void 0:$.state)==="running"?n.jsx(aA,{progress:v.install.progress}):v!=null&&v.install?n.jsx("p",{className:"muted",role:"status",children:v.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${v.install.line??"no reason given"}`}):null,v!=null&&v.headless&&!y?n.jsx("p",{className:"muted",children:"The agents’ browser runs headless on this machine, since it has no display. Watch it and take over from the conversation’s Canvas."}):null,m&&(j!=null&&j.message)?n.jsx("p",{className:"muted",children:j.message}):null,m&&(j!=null&&j.supported)&&!N?n.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),n.jsx(oe,{title:"Who is driving",panel:!0,actions:p.length>0?n.jsx(T,{variant:"danger",size:"sm",disabled:i,onClick:()=>void x(()=>E.browserControl("stop")),children:m?"Stop computer control":"Stop all browsers"}):void 0,children:p.length===0?n.jsx("p",{className:"ui-card-meta",children:"Nobody right now. Ask an agent to open a website or one of the allowed apps, and you will see it working on that conversation’s Canvas."}):n.jsx("div",{className:"ui-list",children:p.map(R=>n.jsxs("a",{className:"ui-list-row",href:at(R.session.agentId,R.session.conversationId),children:[n.jsx(zs,{id:R.session.agentId,name:R.session.agentId,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:R.session.task}),n.jsxs("span",{className:"ui-list-sub",children:[R.session.agentId,", ",R.busy?"working":R.state,", ",R.session.steps," of ",R.session.maxSteps," steps"]})]}),n.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},R.session.id))})}),h?n.jsxs(n.Fragment,{children:[n.jsx(oe,{title:"How agents get a screen",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?n.jsx(vm,{current:h.mode,value:"computer",disabled:i||g||!e.enabled,title:"Use my apps",body:"Agents work in your own windows, signed in as you, in the browser profile you choose below. One agent at a time. Releasing control leaves everything open.",onPick:()=>b({...h,mode:"computer"})}):null,n.jsx(vm,{current:h.mode,value:"playwright",disabled:i||g||!e.enabled,title:"Give agents their own browser",body:"A separate browser profile with its own tabs, one per conversation. Your apps are never touched.",onPick:()=>b({...h,mode:"playwright"})}),n.jsx(vm,{current:h.mode,value:"extension",disabled:i||g||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...h,mode:"extension"})})]}),t?null:n.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),g?n.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,h.mode==="extension"?n.jsx(H6,{busy:i,timezone:r}):null]})}),t?n.jsx(oe,{title:"Apps agents may use",panel:!0,children:n.jsxs(re,{children:[h.mode!=="computer"?n.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,n.jsx(K6,{settings:h,disabled:i||g||!e.enabled,onChange:b,onAdd:()=>u(!0)}),n.jsx(St,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[n.jsx("p",{children:"Agents see what is on screen in these apps, and what they see goes to the agent’s model provider. Allow only apps you want operated."}),n.jsx("p",{children:"Never type a password or a sign-in code in chat. Sign in yourself, in the app, while you have taken over."}),n.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?n.jsx(Q6,{chosen:h.allowedApps,onClose:()=>u(!1),onPick:R=>{u(!1),h.allowedApps.includes(R)||b({...h,allowedApps:[...h.allowedApps,R]})}}):null]}):null]})}const _6="kmbckpnnjfggeffkkbmkggojnolkdokb",F6="",z6=[_6,F6].filter(Boolean);function U6(e){const t=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(e.trim());if(!t)return e;const s=t[4]?/^pre\.(\d+)$/.exec(t[4]):null;return[t[1],t[2],t[3],...s?[s[1]]:[]].map(Number).join(".")}async function B6(){var e;try{if(typeof chrome>"u"||!((e=chrome==null?void 0:chrome.runtime)!=null&&e.sendMessage))return null;for(const t of z6)try{const s=await chrome.runtime.sendMessage(t,{type:"buddi.status"});if(s!=null&&s.installed)return s}catch{}return null}catch{return null}}function W6(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function H6({busy:e,timezone:t}){const{data:s,error:r,reload:i}=ce(()=>E.extension(),[],3e3),a=pj(),l=ce(()=>B6(),[],3e3).data??null,[o,c]=d.useState(""),[u,h]=d.useState(!1),[f,m]=d.useState(null),p=(l==null?void 0:l.state)==="pairing"?l.code??"":"";d.useEffect(()=>{p&&c(p)},[p]);const g=async v=>{h(!0),m(null);try{await v()}catch(w){m(w instanceof Error?w.message:String(w))}finally{h(!1),i()}},x=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,j=n.jsxs("div",{className:"ui-prose muted",children:[n.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),n.jsx(Pt,{label:"The unpacked extension",children:(s==null?void 0:s.path)??"…"})]});return n.jsxs(re,{divided:!0,children:[n.jsx(ae,{message:r??f}),n.jsxs(le,{children:[n.jsx(ve,{tone:s!=null&&s.connected?"good":"warning",children:s!=null&&s.connected?"Connected":"Not connected"}),n.jsxs("span",{className:"muted",children:[s!=null&&s.connected&&s.pairedAt?`Paired with Chrome on ${a} since ${et(s.pairedAt,b)}`:s!=null&&s.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",s!=null&&s.extension?` · extension ${s.extension}`:""]})]}),n.jsxs(re,{children:[n.jsxs("p",{className:"muted",children:[l?`The browser you are reading this in has the extension, version ${l.version}.`:s!=null&&s.connected?"The browser you are reading this in has no buddi extension. You only need it here to pair this browser instead.":"The browser you are reading this in has no buddi extension yet.",(l==null?void 0:l.state)==="paired"?" It is already paired with a buddi.":"",(l==null?void 0:l.state)==="disconnected"?" It is not connected yet: press Connect in its popup.":""]}),l&&(s!=null&&s.buddi)&&U6(s.buddi)!==l.version?n.jsx("p",{className:"muted",children:`buddi is ${s.buddi}; the extension is ${l.version}. Update it from chrome://extensions or the store.`}):null,l&&!W6(l.gateway)?n.jsx(V,{tone:"warning",children:`The extension is pointed at ${l.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),s!=null&&s.pending?n.jsxs(le,{valign:"end",children:[n.jsx(ie,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:n.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:o,onChange:v=>c(v.target.value)})}),n.jsx(_t,{}),n.jsx(T,{variant:"accent",disabled:x||o.replace(/[^0-9]/g,"").length!==6,onClick:()=>void g(async()=>{await E.pairExtension(o),c("")}),children:"Pair"})]}):null,s!=null&&s.connected?n.jsx(St,{summary:"Pair a different browser",children:j}):j,n.jsx(le,{align:"end",children:n.jsx(T,{variant:"danger",disabled:x||!(s!=null&&s.pairedAt),onClick:()=>void g(()=>E.forgetExtension()),children:"Forget this browser"})})]})}function vm({current:e,value:t,title:s,body:r,disabled:i,onPick:a}){const l=e===t;return n.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:"mode-option",disabled:i,onClick:()=>{l||a()},children:[n.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),n.jsxs("span",{className:"mode-option-text",children:[n.jsx("span",{className:"mode-option-title",children:s}),n.jsx("span",{className:"mode-option-body",children:r})]})]})}function K6({settings:e,disabled:t,onChange:s,onAdd:r}){const i=ce(()=>E.installedApps(),[]),a=l=>{var o,c;return((c=(o=i.data)==null?void 0:o.apps.find(u=>u.id===l))==null?void 0:c.name)??l};return n.jsxs(n.Fragment,{children:[e.allowedApps.length===0?n.jsx(xe,{children:"No apps yet. Agents cannot touch anything until you add one."}):n.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(l=>n.jsxs("li",{className:"ui-list-row",children:[n.jsx(zs,{id:l,name:a(l),size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[a(l),l===e.browserApp?n.jsx(ve,{tone:"accent",className:"app-role",children:"browser"}):null]}),n.jsx("span",{className:"ui-list-sub mono",children:l})]}),n.jsxs(le,{children:[l!==e.browserApp&&q6(l)?n.jsx(T,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,browserApp:l}),children:"Use as browser"}):null,l===e.browserApp?n.jsx("span",{className:"muted",children:"In use as the browser"}):n.jsx(T,{size:"sm",variant:"ghost",disabled:t,onClick:()=>s({...e,allowedApps:e.allowedApps.filter(o=>o!==l)}),children:"Remove"})]})]},l))}),n.jsxs(le,{children:[n.jsx(T,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),n.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&V6.includes(e.browserApp)?n.jsx(G6,{settings:e,disabled:t,onChange:s}):null]})}const V6=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function G6({settings:e,disabled:t,onChange:s}){var l;const i=((l=ce(()=>E.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:l.profiles)??[],a=e.browserProfile?i.some(o=>o.directory===e.browserProfile):!0;return n.jsx(ie,{label:"Browser profile",hint:e.browserProfile?"Websites open in this profile, signed in as it is.":"Not chosen: websites open in whichever profile’s window is in front, or the last one you used.",children:n.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:o=>{const{browserProfile:c,...u}=e;s(o.target.value?{...u,browserProfile:o.target.value}:u)},children:[n.jsx("option",{value:"",children:"Whichever is in front"}),!a&&e.browserProfile?n.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(o=>n.jsxs("option",{value:o.directory,children:[o.name,o.directory==="Default"?"":` (${o.directory})`]},o.directory))]})})}const Y6=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function q6(e){return Y6.includes(e)}function Q6({chosen:e,onClose:t,onPick:s}){const r=ce(()=>E.installedApps(),[]),[i,a]=d.useState(""),[l,o]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],h=i.trim().toLowerCase();return u.filter(m=>!h||m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h)).slice(0,60)},[r.data,i]);return n.jsxs(ht,{title:"Add an app",onClose:t,children:[n.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>a(u.target.value)}),n.jsx(ae,{message:r.error}),r.data?c.length===0?n.jsx(xe,{children:"No app matches."}):n.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const h=e.includes(u.id);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx(zs,{id:u.id,name:u.name,size:"sm"}),n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title",children:u.name}),n.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),n.jsx(T,{size:"sm",disabled:h,onClick:()=>s(u.id),children:h?"Allowed":"Allow"})]},u.id)})}):n.jsx(xe,{children:"Reading your Applications folder…"}),n.jsx(St,{summary:"Add by bundle identifier instead",children:n.jsxs(le,{children:[n.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:l,onChange:u=>o(u.target.value)}),n.jsx(T,{disabled:!l.trim(),onClick:()=>s(l.trim()),children:"Allow this identifier"})]})})]})}function X6({data:e,error:t,reload:s,compact:r=!1,refresh:i,screenshotSrc:a,onScreenshotError:l,onScreenshotLoad:o,controls:c=!0}){var $,R,I;const[u,h]=d.useState(!1),[f,m]=d.useState(null),[p,g]=d.useState(null),[x,b]=d.useState(null),j=async z=>{h(!0),m(null),b(null);try{const U=z!=="stop"&&(e!=null&&e.session)?await E.browserControl(z,e.session.id):await E.browserControl(z);z==="takeover"?U.hand&&U.session?g(U.session.id):b(U.handMessage??null):g(null)}catch(U){m(U instanceof Error?U.message:String(U))}finally{h(!1),s()}},v=p&&(($=e==null?void 0:e.session)==null?void 0:$.id)===p&&e.state==="paused"?p:null,w=!!(e!=null&&e.enabled)&&!u,y=(e==null?void 0:e.mode)==="computer",N=(e==null?void 0:e.mode)==="extension",k=y?"Stop computer control interrupts native input and revokes access. Take over pauses agent input. Release ends this conversation’s control without closing your apps. Already dispatched actions cannot be undone. Avoid using the same mouse and keyboard while the agent is working.":"Stop all browsers closes every session and revokes access until you resume. Take over, Resume and Close & release affect only the selected conversation. An in-flight action is interrupted by closing its tabs. Actions already submitted cannot be undone.",S=e!=null&&e.busy?"Working":(e==null?void 0:e.state)==="running"?"Ready":(e==null?void 0:e.state)??"Connecting",C=e!=null&&e.busy||(e==null?void 0:e.state)==="running"?"good":(e==null?void 0:e.state)==="stopped"||(e==null?void 0:e.state)==="error"?"critical":void 0;return n.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[n.jsxs("div",{className:"browser-heading",children:[n.jsxs("div",{children:[r?null:n.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),n.jsx("h2",{className:"browser-title",children:y?"Computer":N?"Your browser":"Browser"})]}),n.jsx(ve,{tone:C,children:n.jsx("span",{role:"status",children:S})})]}),r?n.jsx("a",{className:"browser-full-view",href:"#/browser",children:y?"Open computer view & settings ↗":"Open full browser view ↗"}):n.jsx("p",{className:"ui-page-lede",children:y?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":N?"Your own Chrome, signed in as you, working in background tabs grouped as “buddi”. You keep browsing.":"A real browser window, driven by your assistant. You stay in control."}),n.jsx(ae,{message:t??f}),c?n.jsxs(le,{children:[n.jsx(T,{variant:"danger",disabled:!w||(e==null?void 0:e.state)==="stopped",onClick:()=>void j("stop"),children:y?"Stop computer control":"Stop all browsers"}),n.jsx(T,{disabled:!w||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void j("takeover"),children:"Take over"}),n.jsx(T,{disabled:!w||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void j("resume"),children:"Resume access"}),n.jsx(T,{disabled:!w||!(e!=null&&e.session),onClick:()=>void j("release"),children:y?"Release control":"Close & release"})]}):null,c?r?n.jsx(St,{summary:"About these controls",children:n.jsx("p",{className:"muted",children:k})}):n.jsx("p",{className:"muted",children:k}):null,x?n.jsx(V,{tone:"warning",role:"status",children:x}):null,e!=null&&e.message&&!v?n.jsx(V,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?n.jsxs("div",{className:"browser-task",children:[n.jsxs("div",{className:"ui-row",children:[n.jsx("strong",{children:e.session.agentId}),n.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:n.jsx("p",{children:e.session.task}),n.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",Ht(new Date(e.session.expiresAt),Intl.DateTimeFormat().resolvedOptions().timeZone)]})]}):n.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?y?"No agent is driving. Ask an agent granted browser.* to open a website or an allowed native app.":"No agent is driving. Ask an agent granted browser.* to open a website.":"The host browser is unavailable. Start buddi serve on a machine with a desktop session."}),v?n.jsx(M6,{sessionId:v,csrf:ia(),onGiveBack:()=>void j("resume")}):null,n.jsxs("div",{className:"browser-window",hidden:!!v,children:[n.jsxs("div",{className:"browser-address",children:[n.jsx("span",{"aria-hidden":"true",children:"◉"}),n.jsx("span",{children:((R=e==null?void 0:e.page)==null?void 0:R.url)??(y?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?n.jsxs("figure",{children:[n.jsx("img",{src:a??`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:""}${i?`&tick=${i}`:""}`,alt:`Last browser observation: ${e.page.title||e.page.url}`,...l?{onError:l}:{},...o?{onLoad:o}:{}},a??e.page.id),n.jsxs("figcaption",{children:["Last observation · ",Ht(new Date(e.page.capturedAt),Intl.DateTimeFormat().resolvedOptions().timeZone)," · ",e.page.title||"Untitled page"]})]}):n.jsxs("div",{className:"browser-empty",children:[n.jsx("strong",{children:y?"Your selected app will appear here":"Your browser activity will appear here"}),n.jsx("p",{children:y?"Only the selected app window is captured, not the whole desktop. This preview is not interactive.":"This is a view of the host browser, not a second browser or a remote desktop."})]})]}),(((I=e==null?void 0:e.page)==null?void 0:I.tabs.length)??0)>1?n.jsx(St,{summary:`${e.page.tabs.length} open tabs`,children:n.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(z=>n.jsxs("li",{children:[z.title||z.id," — ",z.url]},z.id))})}):null,n.jsxs("p",{className:"muted",children:[y?"Sign in directly in the host app during takeover. Don’t send passwords or MFA codes in chat. Native apps retain your existing logins and documents. Secure accessibility fields are masked; other sensitive window content can still appear in screenshots.":"Sign in directly in this conversation’s host tab during takeover. Don’t send passwords or MFA codes in chat. Agent tabs share saved logins and cookies."," ",v?"While you are driving this is a live view of the page; nothing you type is kept.":"Screenshots update after agent actions; this is not a live video feed."]})]})}const J6=2e3,Z6=5;function eB(e,t){if(!e.hasScreenshot||!e.page)return null;const s=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${s}`}function tB({status:e,error:t,reload:s,steps:r,live:i,focusedStepId:a=null}){var w;const[l,o]=d.useState(0),[c,u]=d.useState(0),h=c>=Z6;d.useEffect(()=>{if(!i||h)return;const y=window.setInterval(()=>{typeof document<"u"&&document.hidden||o(N=>N+1)},J6);return()=>window.clearInterval(y)},[i,h]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[m,p]=d.useState(null),g=d.useRef(null),x=((w=e==null?void 0:e.page)==null?void 0:w.id)??null;d.useEffect(()=>{const y=i&&e?eB(e):null;if(!y||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let N=!1;return(async()=>{try{const k=await fetch(y);if(!k.ok||N)return;const S=await k.blob();if(N)return;const C=URL.createObjectURL(S);g.current&&URL.revokeObjectURL(g.current),g.current=C,p(C)}catch{}})(),()=>{N=!0}},[i,x]),d.useEffect(()=>()=>{g.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(g.current)},[]);const b=f.current,j=i?e:b?m?b:{...b,hasScreenshot:!1}:e,v=r.at(-1)??null;return n.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[n.jsx(X6,{data:j,error:t,reload:s,compact:!0,controls:i,...i?{refresh:l}:{},...!i&&m?{screenshotSrc:m}:{},onScreenshotError:()=>u(y=>y+1),onScreenshotLoad:()=>u(0)}),i?h?n.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:n.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"This session has ended. What is on this panel is the last thing it showed."}),n.jsx(nB,{steps:r,newestId:(v==null?void 0:v.id)??null,focusedId:a??null,live:i})]})}function nB({steps:e,newestId:t,focusedId:s,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var l;if(!s||!i.current)return;const a=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(s):s}"]`);(l=a==null?void 0:a.scrollIntoView)==null||l.call(a,{block:"nearest"})},[s]),e.length===0?n.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):n.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:n.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((a,l)=>{const o=a.awaiting?"awaiting":a.ok===null?"running":a.ok?"ok":"failed";return n.jsxs("li",{"data-step":a.id,className:"wb-browser-step","data-state":o,"data-newest":a.id===t?"true":void 0,"data-focused":a.id===s?"true":void 0,children:[n.jsx("span",{className:"wb-browser-index mono",children:l+1}),n.jsxs("span",{className:"wb-browser-what",children:[n.jsx("strong",{children:a.action}),a.target?n.jsx("span",{className:"muted wb-browser-target",children:a.target}):null,a.error?n.jsx("span",{className:"wb-browser-error",children:a.error}):null]}),n.jsx("span",{className:"wb-browser-outcome","data-state":o,children:o==="awaiting"?"Awaiting approval":o==="running"?"Working":o==="ok"?"Done":"Failed"})]},a.id)})})})}function sB({agentId:e,conversationId:t}){const{data:s,error:r,reload:i}=ce(()=>E.host(e,t),[e,t],2e3),[a,l]=d.useState(null),[o,c]=d.useState(!1),u=async p=>{c(!0),l(null);try{await p(),i()}catch(g){l(g instanceof Error?g.message:String(g))}finally{c(!1)}},h=(s==null?void 0:s.permissions)??[],f=(s==null?void 0:s.runs)??[],m=h.some(p=>!p.conversationId)?"Always allowed":h.length?"Conversation auto-mode":"Ask each time";return n.jsx(St,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":m}${f.length?` · ${f.length} running`:""}`,children:n.jsxs(re,{gap:"sm",children:[n.jsx("p",{className:"muted",children:"Commands run as your user, not in a sandbox. Auto-mode covers all commands within its scope. Stop interrupts a command; revoke also ends the permission. Neither undoes completed changes."}),n.jsx(ae,{message:a??r}),h.map(p=>n.jsxs(le,{children:[n.jsxs("span",{children:[p.agentId,": ",p.conversationId?"conversation auto-mode":"always allowed"]}),n.jsx(T,{size:"sm",disabled:o,onClick:()=>void u(()=>E.revokeHost(p.id)),children:"Revoke permission"})]},p.id)),h.length?null:n.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(p=>n.jsxs(re,{gap:"sm",children:[n.jsxs("p",{children:[p.agentId," · ",n.jsx("span",{className:"mono",children:p.cwd})]}),n.jsx(Pt,{children:p.command}),n.jsx(Pt,{label:"Command output",children:p.stdout||p.stderr?`${p.stdout}
|
|
105
|
+
${p.stderr}`:"Waiting for output…"}),n.jsx(le,{children:n.jsx(T,{size:"sm",variant:"danger",disabled:o,onClick:()=>void u(()=>E.stopHost(p.agentId,p.conversationId)),children:"Stop command"})})]},p.actionId))]})})}const lA="browser.act",rB="browser.status",Qu=new Set([lA,rB]);function iB(e,t,s){const r=e==null?void 0:e.session;return!r||!t||!s||r.agentId!==t||r.conversationId!==s?null:{id:`host-browser:${r.id}`,title:e.mode==="computer"?"Computer":"Browser",tool:"Host browser",renderer:"browser",source:"browser",pinned:!0,props:{},at:null,substantial:!1}}function aB(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function lB(e){var r;const t=[],s=new Map;for(const i of e)for(const a of i.blocks??[]){if(a.type==="tool_use"&&a.name===lA){const o={id:a.id,action:oB(a.input)??"act",target:cB(a.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(o),s.set(a.id,o);continue}if(a.type!=="tool_result")continue;const l=s.get(a.toolUseId);if(l){if(((r=a.approval)==null?void 0:r.state)==="pending"){l.awaiting=!0,l.ok=null,l.error=null;continue}l.awaiting=!1,l.ok=a.ok,l.error=a.ok?null:uB(a)}}return t}function jk(e,t){var r;let s=!1;for(const i of e)for(const a of i.blocks??[])if(a.type==="tool_use"&&a.id===t&&(s=Qu.has(a.name)),a.type==="tool_result"&&a.toolUseId===t&&((r=a.approval)==null?void 0:r.state)==="pending")return null;return s?t:null}function oB(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function cB(e){if(e===null||typeof e!="object")return null;const t=e;for(const r of["url","appId","direction","key","tabId"]){const i=t[r];if(typeof i=="string"&&i!=="")return i}const s=t.target;if(s!==null&&typeof s=="object"){const r=s,i=r.name;if(typeof i=="string"&&i!=="")return i;const a=r.ref;if(typeof a=="string"&&a!=="")return a;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function uB(e){for(const t of[e.error,e.output]){if(typeof t=="string"&&t.trim()!=="")return t.trim();if(t!==null&&typeof t=="object")for(const s of["message","error","reason"]){const r=t[s];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function dB({agentId:e,groupId:t,currentId:s,timezone:r,onSelect:i,onNew:a}){const[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(0);return d.useEffect(()=>{let m=!1;return o(null),u(null),(t?Be.groupConversations(t):Be.conversations(e,100)).then(p=>{m||o(p.conversations)}).catch(p=>{m||u(p instanceof Error?p.message:String(p))}),()=>{m=!0}},[e,t,h]),n.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[n.jsxs("div",{className:"ui-toolbar",children:[n.jsx("strong",{children:"Past conversations"}),n.jsx("button",{className:"ui-btn",onClick:a,children:"New conversation"})]}),c?n.jsxs("p",{role:"alert",children:[c," ",n.jsx("button",{className:"ui-btn",onClick:()=>f(m=>m+1),children:"Retry"})]}):l===null?n.jsx("p",{className:"muted",children:"Loading conversations…"}):l.length===0?n.jsx("p",{className:"muted",children:"No conversations yet."}):n.jsx("ul",{children:l.map(m=>n.jsx("li",{children:n.jsxs("a",{href:t?Oi(t,m.id):at(e,m.id),"aria-current":m.id===s?"page":void 0,onClick:p=>{p.button===0&&!p.metaKey&&!p.ctrlKey&&!p.shiftKey&&!p.altKey&&(p.preventDefault(),i(m.id))},children:[n.jsx("span",{children:m.preview||m.opening||"Untitled conversation"}),n.jsxs("small",{children:[et(m.lastMessageAt??m.startedAt??m.createdAt??null,r)," · ",m.messageCount," messages",m.id===s?" · Current":""]})]})},m.id))}),n.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(l==null?void 0:l.length)===100?n.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const oA="buddi.dismissedTabs";function hB(){try{const e=JSON.parse(sessionStorage.getItem(oA)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(s=>typeof s=="string")))}catch{return{}}}function wk(e){try{sessionStorage.setItem(oA,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const fB=350,mB=60;function pB({conversationId:e,onText:t,onNotice:s}){const[r,i]=d.useState("idle"),a=d.useRef("idle"),l=v=>{a.current=v,i(v)},o=d.useRef(null),c=d.useRef(null),u=d.useRef(null),h=d.useRef(null),f=d.useRef(null),m=d.useRef({onText:t,onNotice:s,conversationId:e});m.current={onText:t,onNotice:s,conversationId:e};const p=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},g=async()=>{if(a.current!=="idle")return;m.current.onNotice(null),l("starting"),c.current=null;let v;try{v=await OU(N=>{var k;return(k=f.current)==null?void 0:k.call(f,N)})}catch(N){h.current=null,l("idle"),m.current.onNotice(DU(N));return}const w=c.current;c.current=null;const y=a.current;if(w==="discard"||y!=="starting"){v.cancel(),y==="starting"&&l("idle");return}o.current=v,l("recording"),u.current=window.setTimeout(()=>void x(!1),IU),w&&x(w.sendNow)},x=async v=>{h.current=null;const w=o.current;if(!w){a.current==="starting"&&(c.current={sendNow:v});return}o.current=null,p(),l("transcribing");try{const y=await w.stop();if(y.size<=44){m.current.onNotice("Nothing was recorded.");return}const N=new File([y],`recording-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.wav`,{type:"audio/wav"}),k=await Be.attach(N),S=m.current.conversationId,C=await Be.transcribe({artifactId:k.artifactId,...S?{conversationId:S}:{}});m.current.onText(C.text,v)}catch(y){m.current.onNotice(y instanceof me||y instanceof Error?y.message:String(y))}finally{l("idle")}},b=()=>{h.current=null;const v=o.current;if(!v){a.current==="starting"&&(c.current="discard");return}o.current=null,p(),v.cancel(),l("idle")};d.useEffect(()=>{const v=w=>{if(h.current===null)return;const y=Date.now()-h.current;h.current=null,y>=fB&&x(w.shiftKey)};return window.addEventListener("pointerup",v),()=>window.removeEventListener("pointerup",v)},[]);const j=r==="starting"||r==="recording";return d.useEffect(()=>{if(!j)return;const v=w=>{w.isComposing||w.repeat||(w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),b()):w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),x(w.shiftKey)))};return window.addEventListener("keydown",v,!0),()=>window.removeEventListener("keydown",v,!0)},[j]),d.useEffect(()=>()=>{var v;(v=o.current)==null||v.cancel(),p()},[]),{state:r,hold:()=>{h.current=Date.now(),g()},start:()=>{h.current=null,g()},finish:v=>void x(v),discard:b,levels:f}}function gB({disabled:e,voice:t}){const s=i=>{e||i.button>0||t.state!=="idle"||(i.preventDefault(),t.hold())},r=i=>{i.detail!==0||e||t.state!=="idle"||t.start()};return n.jsx("button",{type:"button",className:"ui-icon-btn wb-mic","data-size":"sm","aria-label":"Talk",title:"Talk: click to start, or hold to speak and let go to stop",disabled:e,onPointerDown:s,onClick:r,onContextMenu:i=>i.preventDefault(),children:n.jsx(ue,{name:"mic"})})}function xB({voice:e}){const t=d.useRef(null),s=e.state==="transcribing";return d.useEffect(()=>{var r;(r=t.current)==null||r.focus()},[]),n.jsxs("div",{className:"wb-listening",role:"group","aria-label":"Recording","data-phase":s?"transcribing":"listening",children:[n.jsx("p",{className:"wb-listening-label","aria-live":"polite",children:s?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wb-listening-spinner","aria-hidden":"true"}),"Transcribing…"]}):"Listening…"}),n.jsxs("div",{className:"wb-listening-row",children:[n.jsx(vB,{sink:e.levels,frozen:s}),n.jsx("button",{type:"button",className:"wb-send","data-variant":"quiet","aria-label":"Discard recording",title:"Discard (Escape)",disabled:s,onClick:()=>e.discard(),children:n.jsx(ue,{name:"close"})}),n.jsx("button",{ref:t,type:"button",className:"wb-send","aria-label":"Stop and transcribe",title:"Stop and transcribe (Enter); Shift sends at once",disabled:s,onClick:r=>e.finish(r.shiftKey),children:n.jsx(ue,{name:"check"})})]})]})}function vB({sink:e,frozen:t}){const[s,r]=d.useState(()=>Array(mB).fill(0));return d.useEffect(()=>{if(!t)return e.current=i=>r(a=>[...a.slice(1),i]),()=>{e.current=null}},[t]),n.jsx("div",{className:"wb-wave","aria-hidden":"true","data-testid":"waveform",children:s.map((i,a)=>n.jsx("span",{className:"wb-wave-bar",style:{"--level":i.toFixed(3)}},a))})}const jB="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",ju="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",wB=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function yB(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(jB);let s;try{s=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(wB(i))return null;throw new Error(ju)}try{const i=e.document??document,a=i.createElement("video");a.muted=!0,a.playsInline=!0,a.srcObject=s,await new Promise((h,f)=>{a.onloadedmetadata=()=>h(),a.onerror=()=>f(new Error(ju))}),await a.play(),await new Promise(h=>{const f=a.requestVideoFrameCallback;typeof f=="function"?f.call(a,()=>h()):setTimeout(h,120)});const l=i.createElement("canvas");l.width=a.videoWidth,l.height=a.videoHeight;const o=l.getContext("2d");if(!o||l.width===0)throw new Error(ju);o.drawImage(a,0,0);const c=await new Promise(h=>l.toBlob(h,"image/png"));if(!c)throw new Error(ju);const u=(((r=e.now)==null?void 0:r.call(e))??new Date).toISOString().slice(0,19).replace("T"," ").replace(/:/g,".");return new File([c],`Tab ${u}.png`,{type:"image/png"})}finally{s.getTracks().forEach(i=>i.stop())}}const yk="Send files once the agent has answered.",Ig="wb-composer-input",gj=d.forwardRef(function({disabled:t,running:s,onSend:r,onStop:i,agentName:a,draft:l,model:o,setupHref:c,thinking:u,onThinking:h,onOpenFile:f,mentions:m,history:p,threadKey:g,conversationId:x,readAloud:b,onReadAloud:j,placeholder:v,slim:w},y){var Bs;const N=g?`buddi.draft.${g}`:null,k=Y=>{if(!Y)return"";try{return window.localStorage.getItem(Y)??""}catch{return""}},[S,C]=d.useState(()=>k(N)),[$,R]=d.useState([]),[I,z]=d.useState(!1),[U,A]=d.useState(null),[P,D]=d.useState(!1),O=d.useRef(null),M=d.useRef(null),[W,_]=d.useState(null),[G,B]=d.useState(0),K=W&&m?m.filter(Y=>Y.handle.toLowerCase().startsWith(W.query.toLowerCase())||Y.name.toLowerCase().startsWith(W.query.toLowerCase())).slice(0,6):[],F=(Y,$e)=>{if(!m||m.length===0){_(null);return}const Je=Y.slice(0,$e),bt=/(^|\s)@([\w-]*)$/.exec(Je);if(!bt){_(null);return}_({start:$e-bt[2].length-1,query:bt[2]}),B(0)},Q=Y=>{if(!W)return;const $e=M.current,Je=$e?$e.selectionStart:S.length,bt=`${S.slice(0,W.start)}@${Y} ${S.slice(Je)}`;C(bt),Z<0&&Ue(bt),_(null),window.requestAnimationFrame(()=>{if(!$e)return;const gt=W.start+Y.length+2;$e.focus(),$e.setSelectionRange(gt,gt),J()})},X=p??[],[Z,de]=d.useState(-1),_e=d.useRef(S),Ie=d.useRef(N);if(Ie.current!==N){Ie.current=N;const Y=k(N);_e.current=Y,Y!==S&&(C(Y),de(-1),_(null))}const Ue=Y=>{if(_e.current=Y,!!N)try{Y===""?window.localStorage.removeItem(N):window.localStorage.setItem(N,Y)}catch{}},ee=Y=>{C(Y),_(null);const $e=M.current;$e&&($e.value=Y,$e.setSelectionRange(Y.length,Y.length)),window.requestAnimationFrame(J)},be=Y=>!Y.value.slice(0,Y.selectionStart??Y.value.length).includes(`
|
|
106
|
+
`),se=()=>S===""||Z>=0&&S===X[Z],Te=()=>{Z<0||(de(-1),ee(_e.current))},pe=$.some(Y=>Y.state==="uploading"),Re=$.length>0,Se=s&&Re,Fe=!t&&!pe&&!Se&&S.trim()!=="",Ze=Y=>{for(const $e of Array.from(Y??[])){const Je=`${$e.name}:${$e.size}:${Math.random().toString(36).slice(2,8)}`,bt=$e.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL($e):null;R(gt=>[...gt,{key:Je,filename:$e.name||"Pasted image",mime:$e.type||"application/octet-stream",sizeBytes:$e.size,thumbnail:bt,state:"uploading"}]),Be.attach($e).then(gt=>R(we=>we.map(We=>We.key===Je?{...We,state:"ready",uploaded:gt}:We))).catch(gt=>R(we=>we.map(We=>We.key===Je?{...We,state:"failed",error:gt instanceof me?gt.message:String(gt)}:We)))}},Ee=Y=>{Y.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(Y.thumbnail)},ze=Y=>{const $e=$.find(Je=>Je.key===Y);$e&&(Ee($e),$e.state==="ready"&&$e.uploaded&&Be.discardAttachment($e.uploaded.artifactId).catch(()=>{})),R(Je=>Je.filter(bt=>bt.key!==Y))};d.useImperativeHandle(y,()=>({addFiles:Y=>{var $e;Ze(Y),($e=M.current)==null||$e.focus()},focus:()=>{var Y;return(Y=M.current)==null?void 0:Y.focus()}}));const nt=d.useRef($);nt.current=$,d.useEffect(()=>()=>nt.current.forEach(Ee),[]);const Ye=d.useRef(0);d.useEffect(()=>{if(!l||l.at===Ye.current)return;Ye.current=l.at,C($e=>$e.trim()===""?l.text:$e),Z<0&&S.trim()===""&&Ue(l.text);const Y=M.current;Y&&(Y.focus(),window.requestAnimationFrame(()=>{Y.style.height="auto",Y.style.height=`${Math.min(Y.scrollHeight,200)}px`,Y.setSelectionRange(Y.value.length,Y.value.length)}))},[l]);const J=()=>{const Y=M.current;Y&&(Y.style.height="auto",Y.style.height=`${Math.min(Y.scrollHeight,200)}px`)},je=Y=>{const $e=(Y??S).trim();if(Y===void 0?!Fe:t||pe||Se||$e==="")return;const Je=$.filter(bt=>bt.state==="ready"&&bt.uploaded).map(bt=>bt.uploaded);r($e,Je),$.forEach(Ee),de(-1),Ue(""),C(""),R([]),window.requestAnimationFrame(J)},Ge=Y=>{if(W&&K.length>0){if(Y.key==="ArrowDown"){Y.preventDefault(),B($e=>($e+1)%K.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),B($e=>($e-1+K.length)%K.length);return}if(Y.key==="Enter"||Y.key==="Tab"){Y.preventDefault(),Q(K[G].handle);return}if(Y.key==="Escape"){Y.preventDefault(),_(null);return}}if(Y.key==="ArrowUp"&&!Y.shiftKey&&!Y.altKey&&!Y.metaKey&&!Y.ctrlKey){const $e=Y.currentTarget;if(X.length>0&&Z+1<X.length&&be($e)&&se()){Y.preventDefault(),Z<0&&(_e.current=S),de(Z+1),ee(X[Z+1]);return}}if(Y.key==="ArrowDown"&&!Y.shiftKey&&!Y.altKey&&!Y.metaKey&&!Y.ctrlKey&&Z>=0&&S===X[Z]){if(Y.preventDefault(),Z===0){Te();return}de(Z-1),ee(X[Z-1]);return}if(Y.key==="Escape"&&Z>=0){Y.preventDefault(),Te();return}Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),je())},lt=Y=>{var Je;const $e=Array.from(((Je=Y.clipboardData)==null?void 0:Je.files)??[]);$e.length!==0&&(Y.preventDefault(),Ze($e))},ot=$.filter(Y=>Y.state==="failed"),q=ot.length,ft=pB({conversationId:x??null,onNotice:A,onText:(Y,$e)=>{const Je=S.trim()===""?Y:`${S.replace(/\s+$/,"")} ${Y}`;if($e){je(Je);return}ee(Je),Z<0&&Ue(Je)}}),yt=ft.state!=="idle",zn=d.useRef(!1);return d.useEffect(()=>{var Y;zn.current&&!yt&&((Y=M.current)==null||Y.focus(),window.requestAnimationFrame(J)),zn.current=yt},[yt]),n.jsx("div",{className:"wb-composer","data-testid":"composer","data-slim":w||void 0,"data-busy":S.trim()!==""||Re||yt?"true":void 0,children:n.jsxs("div",{className:"wb-composer-box","data-focused":P||yt,"data-disabled":t,"data-listening":yt||void 0,children:[$.length>0?n.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:$.map(Y=>n.jsx("span",{role:"listitem",children:n.jsx(Qh,{name:Y.filename,mime:Y.mime,sizeBytes:Y.sizeBytes,thumbnail:Y.thumbnail,state:Y.state,error:Y.error,onRemove:()=>ze(Y.key),...f&&Y.state==="ready"&&Y.uploaded?{onOpen:()=>f(bB(Y.uploaded))}:{},size:"sm"})},Y.key))}):null,n.jsxs("label",{className:"sr-only",htmlFor:Ig,children:["Message ",a]}),n.jsx("textarea",{id:Ig,ref:M,value:S,rows:w?1:2,placeholder:s?`${a} is working…`:v??`Message ${a}`,onChange:Y=>{C(Y.target.value),Z<0&&Ue(Y.target.value),F(Y.target.value,Y.target.selectionStart??Y.target.value.length),J()},onFocus:()=>D(!0),onBlur:()=>D(!1),onKeyDown:Ge,onPaste:lt,disabled:t,hidden:yt}),yt?n.jsx(xB,{voice:ft}):null,!yt&&W&&K.length>0?n.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:K.map((Y,$e)=>n.jsxs("button",{type:"button",role:"option","aria-selected":$e===G,className:"wb-mention","data-active":$e===G||void 0,onMouseDown:Je=>{Je.preventDefault(),Q(Y.handle)},children:[n.jsxs("span",{className:"wb-mention-handle",children:["@",Y.handle]}),n.jsx("span",{className:"wb-mention-name",children:Y.name})]},Y.handle))}):null,n.jsxs("div",{className:"wb-composer-row",hidden:yt,children:[n.jsx("input",{ref:O,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:Y=>{Ze(Y.target.files),Y.target.value=""}}),n.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Attach a file",title:"Attach a file — or paste one, or drop it anywhere on the chat",onClick:()=>{var Y;return(Y=O.current)==null?void 0:Y.click()},disabled:t,children:n.jsx(ue,{name:"clip"})}),n.jsx(gB,{disabled:t,voice:ft}),n.jsx("button",{className:"ui-icon-btn","data-size":"sm","aria-label":"Snap a tab",title:"Snap a tab — one picture of another tab in this browser, attached here",onClick:()=>{A(null),z(!0),yB().then(Y=>{var $e;Y&&(Ze([Y]),($e=M.current)==null||$e.focus())}).catch(Y=>A(Y instanceof Error?Y.message:String(Y))).finally(()=>z(!1))},disabled:t||I,children:n.jsx(ue,{name:"camera"})}),o?c?n.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),o]}):n.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[n.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),o]}):null,h?n.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":wu(u),disabled:t||s,title:s?`Wait for ${a} to finish — this run started with thinking ${wu(u)?"on":"off"}`:wu(u)?"Reasoning before the answer is on. Click to turn it off — answers come back faster.":"Reasoning before the answer is off. Click to turn it on.",onClick:()=>h(wu(u)?"off":"on"),children:[n.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,j?n.jsx("button",{type:"button",className:"ui-icon-btn wb-read-aloud","data-size":"sm","aria-label":"Read replies aloud","aria-pressed":!!b,title:b?"Replies are read aloud. Click to stop.":"Read replies aloud, through the voice chosen in Settings → Speech",onClick:()=>j(!b),children:n.jsx(ue,{name:"speaker"})}):null,n.jsx("span",{className:"wb-hint","data-shown":S!==""&&!s||q>0||Se||U!==null,"data-tone":q>0||U!==null?"critical":void 0,children:q>0?q===1&&((Bs=ot[0])!=null&&Bs.error)?ot[0].error:`${q} files failed to upload and will not be sent`:U!==null?U:Se?yk:"Enter sends, Shift+Enter for a new line"}),s?n.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,n.jsx("button",{className:"wb-send","aria-label":"Send",title:Se?yk:pe?"Waiting for the upload to finish":s?`Send — ${a} picks it up between steps`:"Send",onClick:()=>je(),disabled:!Fe,children:n.jsx(ue,{name:"send"})})]})]})})});function wu(e){return(e??"on")==="on"}function bB(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function kB({question:e,disabled:t,onAnswer:s,onSkip:r}){const[i,a]=d.useState("");return d.useEffect(()=>{if(t)return;const l=o=>{o.key!=="Escape"||o.defaultPrevented||(o.preventDefault(),r())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,r]),n.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[n.jsxs("div",{className:"wb-question-head",children:[n.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),n.jsx(T,{className:"wb-question-skip",variant:"ghost",size:"sm",disabled:t,onClick:r,title:"Skip this question (Esc). The agent carries on without an answer.",children:"Skip"}),n.jsx("strong",{children:NB(e.question)})]}),e.options.length>0?n.jsx("div",{className:"wb-question-options",children:e.options.map((l,o)=>n.jsxs("button",{className:"wb-question-option","data-recommended":l.recommended||void 0,disabled:t,onClick:()=>s(l.label,l.id),children:[n.jsx("span",{className:"wb-question-number",children:o+1}),n.jsxs("span",{children:[n.jsxs("span",{className:"wb-question-label",children:[l.label,l.recommended?n.jsx("em",{children:"Recommended"}):null]}),l.hint?n.jsx("small",{children:l.hint}):null]})]},l.id))}):null,e.allowOther?n.jsxs("form",{className:"wb-question-other",onSubmit:l=>{l.preventDefault(),i.trim()&&s(i.trim())},children:[n.jsx("input",{value:i,onChange:l=>a(l.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),n.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,n.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function NB(e){const t=[];let s=0;for(const r of e.matchAll(/https:\/\/[^\s<>"']+/g)){const i=r[0].replace(/[.,;:!?)\]]+$/,""),a=r.index??0;a>s&&t.push(e.slice(s,a)),t.push(n.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i},a)),s=a+i.length}return s<e.length&&t.push(e.slice(s)),t}function SB(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null||e.idleTimeoutMs===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function CB(e){const t=e/864e5;if(t>=1&&Number.isInteger(t))return t===7?"1 week":`${t} day${t===1?"":"s"}`;const s=e/36e5;if(s>=1&&Number.isInteger(s))return`${s} hour${s===1?"":"s"}`;const r=Math.round(e/6e4);return`${r} minute${r===1?"":"s"}`}function EB(e){const{lifetime:t,startedAt:s,now:r,timezone:i}=e;if(!t||t.messages<=0)return{text:"New conversation",title:"Nothing has been said in this one yet.",tone:"quiet"};const a=`${Math.round(t.maxChars/1e3)}k characters`,l=(t.idleTimeoutMs===null?`A conversation ends once its transcript grows past ${a}. `:`A conversation ends after ${CB(t.idleTimeoutMs)} idle, or once its transcript grows past ${a}. `)+"What the agent remembers about you carries over.",o=`${t.messages} message${t.messages===1?"":"s"}`;if(SB(t,r))return{text:`${o} · your next message starts a fresh one`,title:l,tone:"note"};const c=s?Oe(s,r):"";return{text:c===""?o:`${o} · started ${c}`,title:s?`Started ${et(s,i)}. ${l}`:l,tone:"quiet"}}function AB({text:e,onDelete:t}){const[s,r]=d.useState(!1),[i,a]=d.useState(null);return n.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:n.jsxs(St,{summary:"Carried over from the previous conversation",children:[n.jsx("p",{className:"wb-carryover-text",children:e}),n.jsxs(le,{align:"end",children:[i?n.jsx("span",{className:"critical",role:"alert",children:i}):null,n.jsx(T,{size:"sm",variant:"danger-ghost",disabled:s,onClick:()=>{r(!0),a(null),t().catch(l=>{a(l instanceof Error?l.message:String(l)),r(!1)})},children:"Delete note"})]})]})})}function cA(e){return e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function uA(e,t){return e.members.map(s=>t.find(r=>r.id===s)).filter(s=>s!==void 0)}function TB(e,t){var i;const s=uA(e,t),r=e.members.filter(a=>!t.some(l=>l.id===a));if(!t.some(a=>a.id===e.coordinator))return{kind:"coordinator",text:`${e.coordinator} coordinated this group and is no longer in buddi, so the group can't take requests.`,action:"Choose a coordinator"};if(s.length<2){const a=r.length>0?`: ${r.join(", ")} ${r.length===1?"was":"were"} removed from buddi`:"";return{kind:"alone",text:`Only ${((i=s[0])==null?void 0:i.name)??e.coordinator} is left here${a}.`,action:"Add a member"}}return null}function RB(){return n.jsx("span",{className:"ui-avatar group-gone-face","aria-hidden":"true",children:"?"})}function $B({group:e,agents:t,onClose:s,onSaved:r}){const[i,a]=d.useState(!1),[l,o]=d.useState(null),c=[e.coordinator,...e.members.filter(g=>g!==e.coordinator)],u=e.members.length>2,h=Xv(t).filter(g=>!e.members.includes(g.id)),f=!t.some(g=>g.id===e.coordinator),m=async g=>{a(!0),o(null);try{r(await Be.updateGroup(e.id,g))}catch(x){o(x instanceof me?x.message:String(x))}finally{a(!1)}},p=g=>void m({members:e.members.filter(x=>x!==g)});return n.jsxs(ht,{title:"Members",onClose:s,children:[n.jsxs("p",{className:"group-lede",children:[e.name," · ",e.members.length," agents. Each keeps its own account, tools and approvals; being here grants nothing."]}),f?n.jsxs(V,{tone:"warning",children:[e.coordinator," coordinated this group and is no longer in buddi. Pick who coordinates now."]}):null,l?n.jsx(V,{tone:"critical",children:l}):null,n.jsx(dt,{children:c.map(g=>{const x=t.find(j=>j.id===g),b=g===e.coordinator;return x?n.jsx(it,{lead:n.jsx(gn,{agents:t,id:g}),title:x.name,sub:x.description,side:n.jsxs(n.Fragment,{children:[b?n.jsx(ve,{tone:"accent",children:"Coordinator"}):null,f&&x.available?n.jsx(T,{size:"sm",disabled:i,onClick:()=>void m({coordinator:g}),children:"Make coordinator"}):null,n.jsx(Cl,{label:`More for ${x.name}`,...b?{note:"Coordinates the group"}:{},items:[!b&&x.available&&{label:"Make coordinator",hint:"Reads your requests, answers for the room",onSelect:()=>void m({coordinator:g})},{label:`Open ${x.name}'s page`,onSelect:()=>{window.location.hash=At(g)}},!b&&"separator",!b&&{label:"Remove from group",hint:u?"What it said stays":"A group needs two",tone:"critical",onSelect:()=>{u?p(g):o("A group needs two agents. Add someone before taking this one out.")}}]})]})},g):n.jsx(it,{lead:n.jsx(RB,{}),title:n.jsx("span",{className:"group-gone-id",children:g}),sub:n.jsxs("span",{className:"group-gone-line",children:["No longer in buddi",b?" · was the coordinator":u?"":" · add a member to take it out"]}),side:u&&!b?n.jsx(T,{size:"sm",disabled:i,onClick:()=>p(g),children:"Remove"}):void 0},g)})}),n.jsxs("div",{className:"group-add",children:[n.jsx("h3",{className:"group-add-title",children:"Add a member"}),h.length>0?n.jsx(dt,{children:h.map(g=>n.jsx(it,{lead:n.jsx(gn,{agents:t,id:g.id,size:"sm"}),title:g.name,sub:g.description,side:n.jsx(T,{size:"sm",disabled:i,onClick:()=>void m({members:[...e.members,g.id]}),children:"Add"})},g.id))}):n.jsx("p",{className:"group-quiet",children:"Everyone who can join a group is here."})]}),n.jsx("p",{className:"group-quiet",children:"Members read what is said here and what they recall from shared and group memory; nothing an agent knows privately comes in on its own. Taking a member out leaves what it said in the history."})]})}function IB({group:e,onClose:t,onSaved:s}){const[r,i]=d.useState(e.name),[a,l]=d.useState(!1),[o,c]=d.useState(null),u=r.trim()!==""&&r.trim()!==e.name&&!a,h=async()=>{if(u){l(!0),c(null);try{s(await Be.updateGroup(e.id,{name:r.trim()}))}catch(f){c(f instanceof me?f.message:String(f)),l(!1)}}};return n.jsx(un,{title:"Rename group",onClose:t,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!u,onClick:()=>void h(),children:a?"Renaming…":"Rename"})]}),children:n.jsx("form",{onSubmit:f=>{f.preventDefault(),h()},children:n.jsxs(re,{children:[n.jsx(ie,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:n.jsx("input",{value:r,autoFocus:!0,maxLength:80,onFocus:f=>f.currentTarget.select(),onChange:f=>i(f.target.value)})}),o?n.jsx(V,{tone:"critical",children:o}):null]})})})}function dA(e){const[t,s]=d.useState(null);return d.useEffect(()=>{let r=!0;return Be.group(e).then(i=>{var a;r&&s(((a=i.history)==null?void 0:a.conversations)??null)}).catch(()=>{}),()=>{r=!1}},[e]),t}function PB(e){return e===null?"Its conversations":e===0?"Nothing has been said yet, and its next conversation":`Its ${e} ${e===1?"conversation":"conversations"}`}function MB({group:e,onClose:t,onCleared:s}){const r=dA(e.id),[i,a]=d.useState(!1),[l,o]=d.useState(null),c=async()=>{a(!0),o(null);try{await Be.clearGroup(e.id),s()}catch(h){o(h instanceof me?h.message:String(h)),a(!1)}},u=r===0;return n.jsxs(un,{title:`Clear the history of ${e.name}?`,onClose:t,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:i||u,"data-testid":"group-clear-confirm",onClick:()=>void c(),children:i?"Clearing…":"Clear history"})]}),children:[n.jsx("p",{className:"group-dialog-text",children:u?"Nothing has been said in this group yet, so there is nothing to clear.":`${PB(r)} ${r===1?"is":"are"} deleted for good, and anything it is doing now stops. The group, its members and what it remembers stay; files it made stay in Files.`}),l?n.jsx(V,{tone:"critical",children:l}):null]})}function DB({group:e,agents:t,onClose:s,onDeleted:r}){const i=dA(e.id),[a,l]=d.useState(!1),[o,c]=d.useState(null),u=uA(e,t).map(m=>m.name),h=async()=>{l(!0),c(null);try{const{undoUntil:m}=await Be.deleteGroup(e.id);r(m)}catch(m){c(m instanceof me?m.message:String(m)),l(!1)}},f=i===null?"its conversations":i===0?"nothing said yet":`its ${i} ${i===1?"conversation":"conversations"}`;return n.jsxs(un,{title:`Delete ${e.name}?`,onClose:s,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:a,"data-testid":"group-delete-confirm",onClick:()=>void h(),children:a?"Deleting…":"Delete group"})]}),children:[n.jsxs("p",{className:"group-dialog-text",children:["The group goes with ",f," and what it remembers."," ",u.length>0?`${cA(u)} ${u.length===1?"is":"are"} not touched, and files it made stay in Files.`:"Files it made stay in Files."]}),o?n.jsx(V,{tone:"critical",children:o}):null]})}const Xu=320,hA="buddi.chatWidth";function OB({timezone:e,agents:t,agentId:s,defaultAgentId:r=null,group:i=null,onGroupAction:a,onSelectAgent:l,onWorking:o,attention:c,agentsInHeader:u,narrow:h,canvasOpen:f,onOpenCanvas:m,onCloseCanvas:p,newConversationSignal:g,requestedConversationId:x,requestedTab:b,onConversationOpened:j}){var Aw,Tw,Rw,$w,Iw,Pw;const v=pj(),[w,y]=d.useState([]),[N,k]=d.useState(null),[S,C]=d.useState(null),[$,R]=d.useState(null),[I,z]=d.useState([]),[U,A]=d.useState([]),[P,D]=d.useState(null),[O,M]=d.useState(!1),[W,_]=d.useState(new Map),[G,B]=d.useState(null),[K,F]=d.useState(hB),[Q,X]=d.useState([]),[Z,de]=d.useState(!1),_e=d.useRef(0),Ie=d.useRef(null),[Ue,ee]=d.useState(!1),be=d.useRef(g??0),se=d.useRef(s),Te=d.useRef({agentId:s,conversationId:N});Te.current={agentId:s,conversationId:N};const pe=K[N??""]??[],[Re,Se]=d.useState(null),[Fe,Ze]=d.useState(null),[Ee,ze]=d.useState(null),[nt,Ye]=d.useState([]),[J,je]=d.useState(!1),[Ge,lt]=d.useState(()=>Date.now()),[ot,q]=d.useState(LB),ft=d.useRef(null),[yt,zn]=d.useState(null),[Bs,Y]=d.useState(!1),[$e,Je]=d.useState(null),[bt,gt]=d.useState(VE),we=d.useRef(bt);we.current=bt;const We=d.useRef(null),[Le,Xt]=d.useState(null),ys=d.useCallback(H=>{gt(H),GE(H),H||Tl()},[]),[wn,bs]=d.useState(null),[ks,ye]=d.useState(null);d.useEffect(()=>{if(!s)return;const H=zB(s);H&&Je({text:H,at:Date.now()})},[s]);const Ce=i?`group:${i.id}`:s??null,Ke=[...t.top,...t.middle,...t.bottom],fe=Ke.find(H=>H.id===s)??null,Un=ce(()=>E.providerAccounts(),[]),Rn=i?i.members.map(H=>Ke.find(te=>te.id===H)).filter(H=>!!H):[],[Ws,Ll]=d.useState(null),Ti=O?Ws??s??null:null;d.useEffect(()=>{o==null||o(Ti)},[Ti,o]),d.useEffect(()=>()=>o==null?void 0:o(null),[o]),d.useEffect(()=>{let H=!1;return Be.views().then(te=>{H||y(te.views??[])}).catch(()=>{}),()=>{H=!0}},[]),d.useEffect(()=>{if(!s)return;const H=se.current===s;if(se.current=s,H&&x&&x===Te.current.conversationId)return;let te=!1;return k(null),C(null),R(null),z([]),Se(null),M(!1),B(null),X([]),Pc(null),ee(!1),zn(null),x?(x!=="new"?k(x):R(Ce),()=>{te=!0}):((i?Be.groupConversations(i.id):Be.conversations(s)).then(ke=>{if(te)return;const Me=[...ke.conversations??[]].sort(_B)[0];Me?(k(Me.id),j==null||j(s,Me.id)):R(Ce)}).catch(()=>{te||R(Ce)}),()=>{te=!0})},[s,i==null?void 0:i.id,Ce,x,j]);const $n=d.useCallback(H=>Be.conversation(H).then(te=>{if(Te.current.conversationId===H){if(te.agentId!==Te.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");C(te),z(ke=>ke.filter(Me=>!jm(te,Me)))}}).catch(te=>{Te.current.conversationId===H&&Se(Kr(te))}),[]);d.useEffect(()=>{if(!N)return;let H=!1;return _(new Map),A([]),Be.conversation(N).then(te=>{if(!H){if(te.agentId!==s)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");C(te),z(ke=>ke.filter(Me=>!jm(te,Me)))}}).catch(te=>{H||Se(Kr(te))}),()=>{H=!0}},[N,s]),d.useEffect(()=>{if(!N)return;let H=!1;const te=window.setInterval(()=>{Be.conversation(N).then(ke=>{H||ke.agentId!==Te.current.agentId||(C(ke),z(Me=>Me.filter(Xe=>!jm(ke,Xe))))}).catch(()=>{})},3e3);return()=>{H=!0,window.clearInterval(te)}},[N,s]),d.useEffect(()=>{if(!N)return;const H=_h({url:Be.streamUrl(N),onEvent:te=>{var ke;switch(te.name){case"run.started":We.current=null,M(!0),D(null),Ll(an(te.data.agentId));break;case"live":{const Me=an(te.data.runId)??"",Xe=Number(te.data.turn??0),Ve=te.data.kind==="thinking"?"thinking":"text",yn=an(te.data.text)??"",pr=Date.now();if(Ve==="text"){const Ks=We.current;We.current=Ks&&Ks.runId===Me&&Ks.turn===Xe?{...Ks,text:Ks.text+yn}:{runId:Me,turn:Xe,text:yn}}D(Ks=>{const pa=Ks&&Ks.runId===Me&&Ks.turn===Xe?Ks:{runId:Me,turn:Xe,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Ve==="thinking"?{...pa,thinking:pa.thinking+yn,thinkingStartedAt:pa.thinkingStartedAt??pr}:{...pa,text:pa.text+yn,textStartedAt:pa.textStartedAt??pr}});break}case"live.snapshot":{const Me=an(te.data.runId)??"",Xe=Number(te.data.turn??0),Ve=an(te.data.text)??"",yn=an(te.data.thinking)??"",pr=Number(te.data.startedAt??Date.now());We.current={runId:Me,turn:Xe,text:Ve},D({runId:Me,turn:Xe,text:Ve,thinking:yn,thinkingStartedAt:yn?pr:null,textStartedAt:Ve?pr:null,settled:!1});break}case"live.settle":{const Me=an(te.data.runId)??"",Xe=Number(te.data.turn??0);D(Ve=>Ve&&Ve.runId===Me&&Ve.turn===Xe?{...Ve,settled:!0}:Ve);break}case"tool.called":{const Me=an(te.data.toolUseId)??an(te.data.id),Xe=an(te.data.name)??an(te.data.tool)??"tool";Me&&A(Ve=>[...Ve.filter(yn=>yn.toolUseId!==Me),{toolUseId:Me,name:Xe,startedAt:Date.now()}]);break}case"tool.result":{const Me=an(te.data.toolUseId)??an(te.data.id);Me&&A(Xe=>Xe.filter(Ve=>Ve.toolUseId!==Me)),$n(N);break}case"reaction":$n(N);break;case"message.appended":$n(N).then(()=>{D(Me=>Me!=null&&Me.settled?null:Me)});break;case"awaiting-approval":{const Me=an(te.data.approvalId)??an(te.data.actionId),Xe=an(te.data.toolUseId);Me&&Xe&&_(Ve=>new Map(Ve).set(Xe,Me)),A(Ve=>Ve.filter(yn=>yn.toolUseId!==Xe)),$n(N);break}case"run.finished":{M(!1),A([]),D(null),Ll(null);const Me=an(te.data.message);Se(Me??null);const Xe=((ke=We.current)==null?void 0:ke.text.trim())??"";We.current=null,!Me&&Xe!==""&&we.current&&Ud(Xe,N).then(Ve=>{Ve&&Xt(Ve)}),$n(N);break}}}});return()=>H.close()},[N,$n]),d.useEffect(()=>{const H=window.setInterval(()=>lt(Date.now()),U.length===0?6e4:1e3);return()=>window.clearInterval(H)},[U.length]);const Ri=ce(()=>s&&N?E.browser({agentId:s,conversationId:N}):Promise.resolve(void 0),[s,N],1500),mr=Ri.error?void 0:Ri.data,Wr=mr!=null&&mr.session&&mr.session.agentId===s&&mr.session.conversationId===N?mr:void 0,Ft=iB(Wr,s,N),Hs=(Ft==null?void 0:Ft.id)??null,[_l,x$]=d.useState(null),uw=Wr==null?void 0:Wr.mode;d.useEffect(()=>{Ft&&s&&N&&x$({agentId:s,conversationId:N,tab:aB(Ft,uw)})},[Hs,uw,s,N]);const v$=_l&&_l.agentId===s&&_l.conversationId===N&&!pe.includes(_l.tab.id)?_l.tab:null,dn=Ft??v$,j$=d.useMemo(()=>lB((S==null?void 0:S.messages)??[]),[S]),[w$,Pc]=d.useState(null),y$=d.useMemo(()=>n3({messages:(S==null?void 0:S.messages)??[],descriptors:w}),[S,w]),fa=w6(y$,N??null),of=b6(i?null:s),dw=d.useMemo(()=>y6((S==null?void 0:S.messages)??[]),[S]),Bn=d.useMemo(()=>{const te=s3({messages:(S==null?void 0:S.messages)??[],descriptors:w,awaiting:W,served:fa.served,...dn?{folded:Qu}:{}}).filter(ke=>ke.source==="approval"||!pe.includes(ke.id));if(G&&!pe.includes(G)&&!te.some(ke=>ke.id===G)){const ke=l3((S==null?void 0:S.messages)??[],G,{redactInputOf:Qu});ke&&!Qu.has(ke.tool)&&te.push(ke)}dn&&te.push(dn);for(const ke of Q)te.push(Ez(ke));return of&&te.unshift(k6(of,dw)),yt?[...te,N6(yt)]:te},[S,w,W,yt,Hs,dn==null?void 0:dn.title,G,K,N,Q,fa.served,of,dw]),b$=d.useMemo(()=>{var te;const H=[];for(const ke of(S==null?void 0:S.messages)??[]){if(ke.role!=="user"||ke.speaker&&ke.speaker!=="owner")continue;const Me=(te=ke.blocks.find(Xe=>Xe.type==="text"))==null?void 0:te.text.trim();Me&&H.unshift(Me)}return H},[S]),cf=d.useMemo(()=>Bn.filter(H=>H.source==="approval"),[Bn]),Mc=cf.at(-1)??null,Dc=d.useMemo(()=>[...cf.map(H=>({approvalId:H.props.approvalId,toolUseId:H.id})),...((S==null?void 0:S.delegatedApprovals)??[]).map(H=>({approvalId:H.approvalId,toolUseId:H.toolUseId??"",askedBy:WB(H.chain,Ke)}))],[cf,S==null?void 0:S.delegatedApprovals]),Fl=d.useMemo(()=>{for(let H=Bn.length-1;H>=0;H-=1){const te=Bn[H];if(te!=null&&te.substantial)return te.id}return null},[Bn]),Oc=d.useRef(null),uf=((Aw=Bn.filter(H=>(H.source!=="browser"||H.pinned===!0)&&H.id!==Rg).at(-1))==null?void 0:Aw.id)??((Tw=Bn.filter(H=>H.id!==Rg).at(-1))==null?void 0:Tw.id)??null;d.useEffect(()=>{if(Fl&&Fl!==Oc.current){Oc.current=Fl,B(Fl);return}G===null&&uf&&B(uf)},[Fl,G,uf]);const hw=d.useRef(fa.live);d.useEffect(()=>{const H=hw.current;hw.current=fa.live;const te=[...fa.live].filter(Xe=>!H.has(Xe));if(te.length===0||Mc||G!==null&&G!==Oc.current)return;const Me=[...Bn].reverse().find(Xe=>Xe.source==="descriptor"&&Xe.renderer==="preview"&&Xe.props.target!==null&&te.includes(qa(Xe.props.target)));Me&&B(Me.id)},[fa.live,Bn,Mc,G]);const fw=d.useRef(null);d.useEffect(()=>{Hs!==fw.current&&(fw.current=Hs,Hs&&!Mc&&B(Hs))},[Hs,Mc]);const mw=d.useRef(null),zl=b==="browser"?(dn==null?void 0:dn.id)??null:null;d.useEffect(()=>{!zl||mw.current===zl||(mw.current=zl,B(zl))},[zl]);const df=(dn==null?void 0:dn.id)??null;d.useEffect(()=>{!df||!G||jk((S==null?void 0:S.messages)??[],G)!==null&&(Pc(G),B(df))},[df,G,S]);const pw=H=>{X(te=>te.some(ke=>ke.artifactId===H.artifactId)?te:[...te,H]),B(Yu(H.artifactId)),h&&(m==null||m())},Lc=!i&&fe&&!fe.available?dE(fe):null,gw=i?n.jsx("span",{className:"wb-group-stack","aria-hidden":"true",children:i.members.slice(0,2).map(H=>{const te=Ke.find(ke=>ke.id===H);return n.jsx(Wh,{className:"wb-group-chip",id:H,name:(te==null?void 0:te.name)??"?",face:te,initials:1},H)})}):null,$i=i&&Ke.length>0?TB(i,Ke):null,xw=($i==null?void 0:$i.kind)==="coordinator",vw=cg(i?null:fe),jw=((S==null?void 0:S.offers)??[]).filter(H=>!nt.includes(H.id)&&Date.parse(H.expiresAt)>Ge),k$=fe&&ks===fe.id?wn:(fe==null?void 0:fe.thinking)??null,N$=H=>{if(!fe)return;const te=fe.id;ye(te),bs(H),E.setAgentEngine(te,{thinking:H}).catch(ke=>{ye(null),Se(ke instanceof me?ke.message:String(ke))})},hf=(H,te)=>{if(!s)return;const ke=te.map(Ve=>Ve.artifactId),Me=O,Xe={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:H},...te.map(Ve=>({type:"attachment",artifactId:Ve.artifactId,filename:Ve.filename,mime:Ve.mime,kind:Ve.kind,sizeBytes:Ve.sizeBytes}))],...Me?{speaker:sA}:{}};z(Ve=>Me?[...Ve,Xe]:[Xe]),Se(null),Ze(null),M(!0),(i?Be.sendToGroup(i.id,{...N?{conversationId:N}:{},text:H,attachmentIds:ke}):Be.send(s,{...N?{conversationId:N}:{},text:H,attachmentIds:ke})).then(async Ve=>{Te.current.agentId!==s||Te.current.conversationId!==N||(Ze(Ve.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Ve.conversationId!==N?(C(null),k(Ve.conversationId)):await $n(Ve.conversationId),Ve.queued===!0&&z(yn=>yn.filter(pr=>pr.id!==Xe.id)),j==null||j(s,Ve.conversationId))}).catch(Ve=>{z(yn=>yn.filter(pr=>pr.id!==Xe.id)),Se(Kr(Ve)),M(!1)})},S$=H=>{Se(null),ze(H),Ye(te=>[...te,H]),E.takeOffer(H,N??void 0).then(te=>{te.runId&&(Ze(null),M(!0)),N&&$n(N)}).catch(te=>{Ye(ke=>ke.filter(Me=>Me!==H)),Se(Kr(te)),N&&$n(N)}).finally(()=>ze(null))},C$=(H,te)=>ww({answer:H,...te?{optionId:te}:{}}),E$=()=>ww({answer:"",skipped:!0}),ww=H=>{const te=S==null?void 0:S.question;te&&(Se(null),je(!0),M(!0),Be.answerQuestion(te.id,H).then(()=>{if(N)return $n(N)}).catch(ke=>{Se(Kr(ke)),M(!1)}).finally(()=>je(!1)))},A$=()=>{if(s){if(yt){zn(null);return}Y(!0),E.agentProfile(s).then(H=>{zn(H),B($g(H.id)),h&&(m==null||m())}).catch(H=>Se(Kr(H))).finally(()=>Y(!1))}},T$=H=>{Je({text:H.prompt,at:Date.now()}),l(H.agentId),h&&(p==null||p())},R$=()=>{N&&Be.cancel(N).catch(H=>Se(Kr(H))).finally(()=>{M(!1),A([])})},_c=d.useCallback(()=>{if(k(null),C(null),z([]),M(!1),Se(null),Ze(null),A([]),_(new Map),B(null),X([]),Pc(null),Oc.current=null,i){Be.startGroupConversation(i.id).then(({conversationId:H})=>{k(H),s&&(j==null||j(s,H))}).catch(H=>Se(Kr(H)));return}R(Ce),s&&(j==null||j(s,"new"))},[s,i,Ce,j]);d.useEffect(()=>{g&&g!==be.current&&(be.current=g,_c())},[g,_c]);const yw=H=>{N&&$n(N),E.overview().catch(()=>{}),H.state!=="pending"&&_(te=>new Map([...te].filter(([,ke])=>ke!==H.id)))},Fc=d.useRef(!1);d.useEffect(()=>{const H=ke=>{if(!Fc.current)return;const Me=Math.max(Xu,Math.min(720,ke.clientX-52));q(Me)},te=()=>{if(Fc.current){Fc.current=!1;try{ot!==null&&window.localStorage.setItem(hA,String(ot))}catch{}}};return window.addEventListener("pointermove",H),window.addEventListener("pointerup",te),()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",te)}},[ot]);const $$=((Rw=Ke.find(H=>H.id===r))==null?void 0:Rw.name)??null,bw=i?[]:r4(fe,$$),kw=!(S&&S.conversationId===N)&&!(!N&&$!==null&&$===Ce),Nw=kw?n.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&fe?n.jsx(PE,{quiet:!0,still:!0,className:"wb-chat-field",children:n.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[n.jsx(gn,{agents:Ke,id:fe.id,size:"xl"}),n.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${fe.name}.`}),n.jsx("p",{className:"wb-chat-intro",children:i4(fe)}),bw.length>0?n.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${fe.name}`,children:bw.map(H=>n.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var te;Je({text:H,at:Date.now()}),(te=Ie.current)==null||te.focus()},children:H},H))}):null]})}):null,Sw=n.jsx(o6,{renderables:Bn,activeId:G,onActivate:B,onClose:H=>{yt&&H===$g(yt.id)?zn(null):Q.some(te=>Yu(te.artifactId)===H)?X(te=>te.filter(ke=>Yu(ke.artifactId)!==H)):N&&F(te=>{const ke={...te,[N]:[...new Set([...te[N]??[],H])]};return wk(ke),ke}),G===H&&B(null)},timezone:e,onDecided:yw,onChangeAgent:T$,agents:Ke,browserPanel:dn?n.jsx(tB,{status:Wr,error:Ri.error,reload:Ri.reload,steps:j$,live:Ft!==null,focusedStepId:w$},dn.id):null,descriptors:w,grantedTools:i?Rn.flatMap(H=>H.tools??[]):(fe==null?void 0:fe.tools)??[],...fe?{agentName:fe.name}:{},loading:kw,...!i&&fe?{face:n.jsx(gn,{agents:Ke,id:fe.id,size:"xl"})}:{}}),Cw=(Iw=($w=[...(S==null?void 0:S.messages)??[],...I].find(H=>H.role==="user"))==null?void 0:$w.blocks.find(H=>H.type==="text"))==null?void 0:Iw.text.trim(),Ew=Cw?Cw.split(`
|
|
107
|
+
`)[0]:"New conversation",ma=EB({lifetime:(S==null?void 0:S.lifetime)??null,startedAt:(S==null?void 0:S.startedAt)??null,now:Ge,timezone:e});return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"wb-chat",ref:ft,style:h||ot===null?void 0:{width:ot},"data-sized":!h&&ot!==null?"true":void 0,"data-testid":"chat-column","data-dropping":Z||void 0,onDragEnter:H=>{yu(H)&&(H.preventDefault(),_e.current+=1,de(!0))},onDragOver:H=>{yu(H)&&(H.preventDefault(),H.dataTransfer.dropEffect="copy")},onDragLeave:H=>{yu(H)&&(_e.current=Math.max(0,_e.current-1),_e.current===0&&de(!1))},onDrop:H=>{var te;yu(H)&&(H.preventDefault(),_e.current=0,de(!1),s&&((te=Ie.current)==null||te.addFiles(H.dataTransfer.files)))},children:[Z?n.jsx("div",{className:"wb-drop","aria-hidden":"true",children:n.jsxs("div",{className:"wb-drop-card",children:[n.jsx(FB,{}),n.jsx("strong",{children:"Drop to attach"}),n.jsx("span",{children:fe?`It goes with your next message to ${fe.name}`:"Pick an agent first"})]})}):null,n.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&fe?Cc(Sc(fe)):{},children:[n.jsxs("div",{className:"wb-head-row",children:[i?n.jsx("span",{className:"wb-head-face","aria-hidden":"true",children:gw}):fe?n.jsx("a",{className:"wb-head-face",href:At(fe.id),"aria-label":`${fe.name}'s page`,children:n.jsx(gn,{agents:Ke,id:fe.id})}):null,n.jsxs("div",{className:"wb-head-text",children:[i?n.jsx("span",{className:"wb-head-title",children:i.name}):n.jsx("span",{className:"wb-head-title",title:Ew,children:Ew}),n.jsx("span",{className:"wb-head-meta","data-tone":ma.tone,title:i?`${Rn.map(H=>H.name).join(", ")}. Coordinator: ${(fe==null?void 0:fe.name)??i.coordinator}.`:ma.title,children:i?`${Rn.map(H=>H.name).join(", ")} · ${ma.text}`:fe?n.jsxs(n.Fragment,{children:[n.jsx("a",{className:"wb-head-name",href:At(fe.id),title:`${fe.name}'s page`,children:fe.name})," ",n.jsxs("span",{className:"wb-head-handle",children:["@",fe.handle]}),` · ${ma.tone==="quiet"&&ma.text==="New conversation"?`on ${v}`:ma.text}`]}):"No agent"})]}),n.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!s,onClick:()=>{ee(!1),_c()},children:n.jsx(ue,{name:"plus",size:16})}),n.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":Ue,"data-open":Ue?"true":void 0,disabled:!s,onClick:()=>ee(H=>!H),children:n.jsx(UB,{})}),h?n.jsxs("button",{className:"ui-btn",onClick:m,disabled:Bn.length===0,children:["Canvas",Bn.length>0?` (${Bn.length})`:""]}):null,i?n.jsx(kk,{disabled:!1,label:"More about this group",title:i.name,sub:cA(Rn.map(H=>H.name)),face:gw,items:[{label:"Members",hint:`${i.members.length} agents · ${fe?`${fe.name} coordinates`:"no coordinator"}`,testId:"group-members",onSelect:()=>a==null?void 0:a("members")},{label:"Rename…",hint:"What this team is for",testId:"group-rename",onSelect:()=>a==null?void 0:a("rename")},"separator",{label:"Clear history…",hint:"Keeps the group and its members",testId:"group-clear",onSelect:()=>a==null?void 0:a("clear")},{label:"Delete group…",hint:"With its history; the agents stay",tone:"critical",testId:"group-delete",onSelect:()=>a==null?void 0:a("delete")}]}):n.jsx(kk,{disabled:!s,label:"More about this agent",title:(fe==null?void 0:fe.name)??"Agent",...fe?{sub:`@${fe.handle}`,face:n.jsx(gn,{agents:Ke,id:fe.id,size:"sm"})}:{},items:[{label:yt?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:Bs,onSelect:A$},...fe?[{label:"Set up",hint:"Identity, model and access",href:At(fe.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:At(fe.id)}]:[]]})]}),u?n.jsx(fE,{agents:t,currentId:s,attention:c,onSelect:l,orientation:"horizontal",...Ti?{working:new Set([Ti])}:{}}):null]}),Ue&&s?n.jsx(dB,{agentId:s,...i?{groupId:i.id}:{},currentId:N,timezone:e,onNew:()=>{ee(!1),_c()},onSelect:H=>{if(H===N){ee(!1);return}ee(!1),C(null),z([]),M(!1),B(null),Se(null),Ze(null),X([]),k(H),j==null||j(s,H,!1)}}):null,s&&N?n.jsx(sB,{agentId:s,conversationId:N},`${s}:${N}`):null,Re?n.jsx("div",{className:"wb-chat-notice",children:n.jsx(ae,{message:Re})}):null,Fe?n.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:Fe}):null,S!=null&&S.carriedOver?n.jsx(AB,{text:S.carriedOver,onDelete:async()=>{const H=S.conversationId;await Be.deleteCarryOver(H),C(te=>{if(!te||te.conversationId!==H)return te;const{carriedOver:ke,...Me}=te;return Me})}},S.conversationId):null,n.jsx(fj,{messages:[...(S==null?void 0:S.messages)??[],...I],live:U,now:Ge,working:O,partial:P,agents:Ke,...S!=null&&S.runs?{runs:S.runs}:{},...s&&N?{onContinue:()=>hf("continue",[])}:{},...i?{speakers:Ke,coordinatorId:i.coordinator}:{},...Ws?{workingAs:((Pw=Ke.find(H=>H.id===Ws))==null?void 0:Pw.name)??Ws}:{},onOpenFile:pw,onReadAloud:(H,te)=>{Xt(null),Ud(te,N??void 0,H).then(ke=>{ke&&Xt(ke)})},onOpen:H=>{if(dn){const te=jk([...(S==null?void 0:S.messages)??[],...I],H);if(te){Pc(te),B(dn.id),h&&(m==null||m());return}}N&&F(te=>{const ke={...te,[N]:(te[N]??[]).filter(Me=>Me!==H)};return wk(ke),ke}),B(H),h&&(m==null||m())},...fe?{agentName:fe.name,agentId:fe.id}:{},...Nw?{empty:Nw}:{},emptyHint:i?`Give the team a task once; ${fe?fe.name:"the coordinator"} brings members in. @ addresses one of them.`:fe?`Nothing here yet. Ask ${fe.name} for something.`:"Loading agents…"}),jw.length>0?n.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:jw.map(H=>n.jsx("button",{className:"ui-btn",disabled:Ee!==null,title:H.prompt,onClick:()=>S$(H.id),children:H.label},H.id))}):null,$i?n.jsx("div",{className:"wb-composer-blocked","data-testid":"group-problem","data-kind":$i.kind,children:n.jsx(V,{tone:xw?"warning":void 0,role:"status",children:n.jsxs("span",{children:[$i.text," ",n.jsx("button",{type:"button",className:"wb-link-btn",onClick:()=>a==null?void 0:a("members"),children:$i.action})]})})}):null,Lc?n.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:n.jsxs(V,{tone:"warning",role:"status",children:[Lc," ",n.jsx("a",{href:De(vw.section),children:vw.label})]})}):Dc.length>0?n.jsx(B3,{approvals:Dc,timezone:e,now:Ge,version:S,onDecided:yw,onSay:H=>hf(H,[]),onOpenFull:H=>{B(H),h&&(m==null||m())}}):null,Lc||Dc.length>0?null:S!=null&&S.question?n.jsx(kB,{question:S.question,disabled:J||O,onAnswer:C$,onSkip:E$},S.question.id):null,Lc||xw?null:n.jsxs("div",{hidden:Dc.length>0||!!(S!=null&&S.question),"data-testid":"composer-slot",children:[n.jsx(gj,{ref:Ie,disabled:!s,running:O,onSend:hf,onStop:R$,agentName:i?i.name:(fe==null?void 0:fe.name)??"the agent",draft:$e,history:b$,threadKey:N??(i?`group:${i.id}`:s),model:i?null:(fe==null?void 0:fe.model)??null,setupHref:i?null:fe?At(fe.id,"setup","brain"):null,thinking:k$,...!i&&fe&&ZC(e1(fe,Un.data))?{onThinking:N$}:{},...i?{mentions:Rn.map(H=>({handle:H.handle,name:H.name}))}:{},onOpenFile:pw,conversationId:N??null,readAloud:bt,onReadAloud:ys}),Le?n.jsx("p",{className:"wb-voice-note",role:"status",children:Le}):null]})]}),h?f?n.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[n.jsxs("div",{className:"wb-sheet-head",children:[n.jsx("strong",{children:"Canvas"}),n.jsx("button",{className:"ui-btn",onClick:p,children:"Close"})]}),Sw]}):null:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:H=>{var te,ke;Fc.current=!0,(ke=(te=H.currentTarget).setPointerCapture)==null||ke.call(te,H.pointerId)},onKeyDown:H=>{const te=ke=>{var Me;return ke??((Me=ft.current)==null?void 0:Me.offsetWidth)??Xu};H.key==="ArrowLeft"&&q(ke=>Math.max(Xu,te(ke)-16)),H.key==="ArrowRight"&&q(ke=>Math.min(720,te(ke)+16))}}),Sw]})]})}function LB(){try{const e=window.localStorage.getItem(hA),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Xu?t:null}catch{return null}}function _B(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function an(e){return typeof e=="string"&&e!==""?e:null}function Kr(e){return e instanceof me||e instanceof Error?e.message:String(e)}function jm(e,t){var r;const s=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!s)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const a=e.messages[i];if(a.role!=="user")continue;const l=a.blocks.find(o=>o.type==="text");if(l)return l.text.trim()===s}return!1}function yu(e){var s;const t=(s=e.dataTransfer)==null?void 0:s.types;return!!(t&&Array.from(t).includes("Files"))}function FB(){return n.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),n.jsx("path",{d:"M5 19.5v2a2.5 2.5 0 0 0 2.5 2.5h13a2.5 2.5 0 0 0 2.5-2.5v-2"})]})}const bk="buddi.chatDraft";function zB(e){try{const t=window.sessionStorage.getItem(bk);if(!t)return null;const s=JSON.parse(t);return s.agentId!==e||typeof s.text!="string"?null:(window.sessionStorage.removeItem(bk),s.text)}catch{return null}}function UB(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),n.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function BB(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[n.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),n.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function kk({items:e,disabled:t,label:s,title:r,sub:i,face:a}){const[l,o]=d.useState(!1),c=d.useRef(null);d.useEffect(()=>{if(!l)return;const h=m=>{c.current&&!c.current.contains(m.target)&&o(!1)},f=m=>{m.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",h),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",f)}},[l]);const u=h=>{const f=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-menu-item-text",children:h.label}),h.hint?n.jsx("span",{className:"ui-menu-item-hint",children:h.hint}):null]});return h.href?n.jsx("a",{className:"ui-menu-item",role:"menuitem",href:h.href,"data-tone":h.tone,onClick:()=>o(!1),children:f},h.label):n.jsx("button",{className:"ui-menu-item",role:"menuitem","data-testid":h.testId,"data-tone":h.tone,disabled:h.disabled,onClick:()=>{var m;o(!1),(m=h.onSelect)==null||m.call(h)},children:f},h.label)};return n.jsxs("div",{className:"wb-head-menu",ref:c,children:[n.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":s,"aria-haspopup":"menu","aria-expanded":l,"data-open":l?"true":void 0,disabled:t,onClick:()=>o(h=>!h),children:n.jsx(BB,{})}),l?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"wb-head-menu-scrim","aria-hidden":"true",onClick:()=>o(!1)}),n.jsxs("div",{className:"ui-menu wb-head-menu-list",role:"menu","aria-label":r,children:[n.jsxs("div",{className:"wb-head-menu-head","aria-hidden":"true",children:[a,n.jsxs("span",{className:"wb-head-menu-heading",children:[n.jsx("span",{className:"wb-head-menu-title",children:r}),i?n.jsx("span",{className:"wb-head-menu-sub",children:i}):null]})]}),e.map((h,f)=>h==="separator"?n.jsx("div",{className:"ui-menu-sep",role:"separator"},`sep-${f}`):u(h)),n.jsx("button",{type:"button",className:"ui-btn wb-head-menu-cancel",onClick:()=>o(!1),children:"Cancel"})]})]}):null]})}function WB(e,t){const s=a=>{var l;return`@${((l=t.find(o=>o.id===a))==null?void 0:l.handle)??a}`},[r,...i]=e;return r===void 0?"":[s(r),...i.map(a=>`asked by ${s(a)}`)].join(", ")}let Nk=!1;const HB=new Set(["missing","unconfigured","not-english"]);async function Ud(e,t,s=null){const r=YE(s);try{const i=await Be.say({text:e,...t?{conversationId:t}:{}});return rk(r)&&await BU(i.audioUrl,i.mime,s),null}catch(i){rk(r)&&Tl();const a=i instanceof me&&i.detail&&typeof i.detail=="object"?i.detail.reason:void 0;return typeof a=="string"&&HB.has(a)&&(s!==null||!Nk)?(Nk=!0,i.message):null}}let as=null;function KB(e){if(Gu(e)!==null)return!1;const t=nE(e);return t!==sn&&t!==ci}function VB({agent:e,agents:t,open:s,onOpenChange:r,navigate:i}){const a=d.useRef(null),l=d.useRef(s),o=`Ask ${e.name}`,[c,u]=d.useState(!1);return d.useEffect(()=>{if(s||!c||!as)return;const h=_h({url:Be.streamUrl(as.conversationId),lastEventId:as.lastEventId??null,onEvent:f=>{f.name==="run.finished"&&u(!1)}});return()=>h.close()},[s,c]),d.useEffect(()=>{const h=f=>{!f.altKey||f.ctrlKey||f.metaKey||f.code!=="Slash"||(f.preventDefault(),r(!s))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s,r]),d.useEffect(()=>{var h;l.current&&!s&&((h=a.current)==null||h.focus()),l.current=s},[s]),s?n.jsx(YB,{agent:e,agents:t,navigate:i,onClose:()=>r(!1),onBusy:u}):n.jsxs(Ko,{children:[n.jsx(Vo,{asChild:!0,children:n.jsx("button",{ref:a,type:"button",className:"wb-ask-fab","data-busy":c?"true":void 0,"aria-label":o,onClick:()=>r(!0),children:n.jsx(GB,{busy:c})})}),n.jsx(Go,{children:n.jsx(Yo,{className:"ui-tip",side:"left",sideOffset:8,children:o})})]})}function GB({busy:e}){const[t,s]=d.useState(!1);return t?n.jsx(sc,{size:"lg"}):n.jsx(Ec,{state:e?"working":"idle",className:"wb-ask-fab-face",onStillError:()=>s(!0)})}function YB({agent:e,agents:t,navigate:s,onClose:r,onBusy:i}){const a=d.useRef(null),[l,o]=d.useState(as&&as.agentId===e.id?as.conversationId:null),[c,u]=d.useState(null),[h,f]=d.useState([]),[m,p]=d.useState([]),[g,x]=d.useState(null),[b,j]=d.useState(!1),[v,w]=d.useState(!1),[y,N]=d.useState(null),[k,S]=d.useState(null),[C,$]=d.useState(Date.now()),[R,I]=d.useState(VE),z=d.useRef(R);z.current=R;const[U,A]=d.useState(null),P=d.useRef(null),D=d.useCallback(async K=>{try{const F=await Be.conversation(K);u(F),f(Q=>Q.filter(X=>!qB(F,X)))}catch{}},[]);d.useEffect(()=>{l&&D(l)},[l,D]),d.useEffect(()=>{if(!l)return;const K=_h({url:Be.streamUrl(l),onEvent:F=>{var Q;switch(F.name){case"run.started":P.current=null,j(!0),x(null);break;case"live":{const X=Wn(F.data.runId)??"",Z=Number(F.data.turn??0),de=F.data.kind==="thinking"?"thinking":"text",_e=Wn(F.data.text)??"",Ie=Date.now();if(de==="text"){const Ue=P.current;P.current=Ue&&Ue.runId===X&&Ue.turn===Z?{...Ue,text:Ue.text+_e}:{runId:X,turn:Z,text:_e}}x(Ue=>{const ee=Ue&&Ue.runId===X&&Ue.turn===Z?Ue:{runId:X,turn:Z,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return de==="thinking"?{...ee,thinking:ee.thinking+_e,thinkingStartedAt:ee.thinkingStartedAt??Ie}:{...ee,text:ee.text+_e,textStartedAt:ee.textStartedAt??Ie}});break}case"live.snapshot":{const X=Wn(F.data.runId)??"",Z=Number(F.data.turn??0),de=Wn(F.data.text)??"",_e=Wn(F.data.thinking)??"",Ie=Number(F.data.startedAt??Date.now());P.current={runId:X,turn:Z,text:de},j(!0),x({runId:X,turn:Z,text:de,thinking:_e,thinkingStartedAt:_e?Ie:null,textStartedAt:de?Ie:null,settled:!1});break}case"live.settle":{const X=Wn(F.data.runId)??"",Z=Number(F.data.turn??0);x(de=>de&&de.runId===X&&de.turn===Z?{...de,settled:!0}:de);break}case"tool.called":{const X=Wn(F.data.toolUseId)??Wn(F.data.id),Z=Wn(F.data.name)??Wn(F.data.tool)??"tool";X&&p(de=>[...de.filter(_e=>_e.toolUseId!==X),{toolUseId:X,name:Z,startedAt:Date.now()}]);break}case"tool.result":{const X=Wn(F.data.toolUseId)??Wn(F.data.id);X&&p(Z=>Z.filter(de=>de.toolUseId!==X)),D(l);break}case"message.appended":case"awaiting-approval":D(l).then(()=>x(X=>X!=null&&X.settled?null:X));break;case"run.finished":{j(!1),p([]),x(null);const X=Wn(F.data.message);N(X??null);const Z=((Q=P.current)==null?void 0:Q.text.trim())??"";P.current=null,!X&&Z!==""&&z.current&&Ud(Z,l).then(de=>{de&&A(de)}),D(l);break}}}});return()=>{as&&as.conversationId===l&&(as.lastEventId=K.lastEventId()),K.close()}},[l,D]),d.useEffect(()=>{i(b||v)},[b,v,i]),d.useEffect(()=>{if(m.length===0)return;const K=window.setInterval(()=>$(Date.now()),1e3);return()=>window.clearInterval(K)},[m.length]);const O=(K,F)=>{w(!0),N(null);const Q={id:`local-${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:K}]};f(X=>[...X,Q]),(async()=>{try{const X=l??(await Be.startConversation(e.id)).conversationId;X!==l&&(as={agentId:e.id,conversationId:X},o(X));const Z=await Be.send(e.id,{conversationId:X,text:K,...F.length>0?{attachmentIds:F.map(de=>de.artifactId)}:{}});Z.conversationId!==X&&(as={agentId:e.id,conversationId:Z.conversationId},o(Z.conversationId)),j(!0),D(Z.conversationId)}catch(X){f(Z=>Z.filter(de=>de.id!==Q.id)),N(X instanceof me?X.message:String(X)),S({text:K,at:Date.now()})}finally{w(!1)}})()},M=()=>{l&&Be.cancel(l).catch(K=>N(String(K))).finally(()=>j(!1))},W=()=>{var K;as=null,o(null),u(null),f([]),p([]),x(null),j(!1),N(null),(K=a.current)==null||K.focus()},_=K=>{I(K),GE(K),K||Tl()},G=l?at(e.id,l):at(e.id),B=[...(c==null?void 0:c.messages)??[],...h];return n.jsxs(xz,{title:e.name,label:`${e.name}, a quick chat`,onClose:r,onOpenAutoFocus:K=>{var F;K.preventDefault(),(F=a.current)==null||F.focus()},onCloseAutoFocus:K=>K.preventDefault(),actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",variant:"ghost",onClick:W,disabled:l===null&&h.length===0,children:"New"}),n.jsx(Tt,{size:"sm",variant:"ghost",href:G,onClick:K=>{K.preventDefault(),s(G)},children:"Open in Chat"})]}),children:[n.jsx("div",{className:"wb-ask-thread",children:n.jsx(fj,{messages:B,live:m,now:C,working:b||v,partial:g,agents:t,agentName:e.name,agentId:e.id,onOpen:()=>s(G),onReadAloud:(K,F)=>{A(null),Ud(F,l??void 0,K).then(Q=>{Q&&A(Q)})},emptyHint:`Ask ${e.name} anything, without leaving this page.`})}),n.jsxs("div",{className:"wb-ask-compose",children:[y?n.jsx(ae,{message:y}):null,n.jsx(gj,{ref:a,disabled:v||!e.available,running:b,onSend:O,onStop:M,agentName:e.name,placeholder:`Message ${e.name}…`,draft:k,threadKey:`dock.${l??e.id}`,conversationId:l,readAloud:R,onReadAloud:_}),U?n.jsx("p",{className:"wb-voice-note",role:"status",children:U}):null]})]})}function Wn(e){return typeof e=="string"?e:null}function qB(e,t){var r;const s=(r=t.blocks)==null?void 0:r.find(i=>i.type==="text");return!s||s.type!=="text"?!1:e.messages.some(i=>i.role==="user"&&(i.blocks??[]).some(a=>a.type==="text"&&a.text.includes(s.text)))}const fA=3;function QB(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function XB(e,t){return e?t?"above-dock":"above-button":"corner"}function JB({placement:e,children:t}){return n.jsx("div",{className:"wb-toast-stack","data-placement":e,children:t})}function ZB(e){return e.state==="shown"&&e.seenAt===null}function e5(e){const[t,s]=d.useState([]),r=d.useRef(new Set),i=d.useRef(new Set),a=d.useCallback(()=>{e&&E.notifications(20).then(({notifications:o})=>{const c=o.filter(u=>ZB(u)&&!r.current.has(u.id));s(u=>{const h=new Set(u.map(m=>m.id)),f=c.filter(m=>!h.has(m.id));return f.length===0?u:[...u,...f].sort((m,p)=>p.createdAt.localeCompare(m.createdAt))})}).catch(()=>{})},[e]);d.useEffect(()=>{for(const o of t.slice(0,fA))i.current.has(o.id)||(i.current.add(o.id),E.notificationSeen(o.id).catch(()=>{}))},[t]);const l=d.useCallback(o=>{r.current.add(o),s(c=>c.filter(u=>u.id!==o))},[]);return{queue:t,refresh:a,dismiss:l}}function t5({queue:e,agents:t,navigate:s,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,fA),a=e.length-i.length;return n.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(l=>n.jsxs("div",{className:"ui-toast nt-toast","data-tone":QB(l.kind),role:"status",children:[l.agentId?n.jsx(gn,{agents:t,id:l.agentId,size:"sm"}):null,n.jsxs("div",{className:"nt-toast-main",children:[n.jsx("div",{className:"ui-toast-title",children:Qo(l)}),l.text?n.jsx("div",{className:"ui-toast-body nt-toast-line",children:n5(l.text)}):null,l.link?n.jsx("a",{className:"nt-toast-link",href:l.link,onClick:o=>{o.preventDefault(),r(l.id),s(l.link)},children:"See"}):null]}),n.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${Qo(l)}`,onClick:()=>r(l.id),children:"×"})]},l.id)),a>0?n.jsxs("p",{className:"nt-toasts-more",children:["and ",a," more"]}):null]})}function n5(e){var t;return((t=e.split(`
|
|
108
|
+
`).find(s=>s.trim()!==""))==null?void 0:t.trim())??""}const s5=3e4,r5=1e3;function i5(e,t,s){const r=d.useRef(t);r.current=t;const i=d.useRef(s);i.current=s,d.useEffect(()=>{if(!e)return;let a=!1,l=-1/0,o=null,c=null,u=!0;const h=()=>document.visibilityState!=="hidden",f=j=>{var v;l=Date.now(),E.presence(j).catch(w=>{var y;w instanceof me&&w.status===401&&(a=!0,(y=i.current)==null||y.call(i))}),j==="active"&&((v=r.current)==null||v.call(r))},m=j=>{if(a||(o=j,c!==null))return;const v=l+r5-Date.now();if(v<=0){o=null,f(j);return}c=window.setTimeout(()=>{if(c=null,a||o===null)return;const w=o;o=null,f(w)},v)},p=()=>{u=!0,h()&&m("active")},g=()=>{u=!1,m("away")},x=()=>m(h()?"active":"away");h()&&m("active");const b=window.setInterval(()=>{h()&&u&&m("active")},s5);return window.addEventListener("focus",p),window.addEventListener("blur",g),document.addEventListener("visibilitychange",x),()=>{a=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",p),window.removeEventListener("blur",g),document.removeEventListener("visibilitychange",x)}},[e])}function a5({agents:e,onClose:t,onCreated:s}){return uE(e)?n.jsx(l5,{agents:Xv(e),onClose:t,...s?{onCreated:s}:{}}):n.jsx(ht,{title:"A new group",onClose:t,children:n.jsxs(V,{children:["A group needs two agents. Make another one with ",t4(e)," first."]})})}function l5({agents:e,onClose:t,onCreated:s}){var j,v;const[r,i]=d.useState(""),[a,l]=d.useState([]),[o,c]=d.useState(((j=e.find(w=>w.roles.includes(Kv)))==null?void 0:j.id)??((v=e[0])==null?void 0:v.id)??""),[u,h]=d.useState(!1),[f,m]=d.useState(null),p=[...new Set([o,...a])].filter(Boolean),g=r.trim()!==""&&o!==""&&p.length>=2,x=w=>l(y=>y.includes(w)?y.filter(N=>N!==w):[...y,w]),b=async()=>{h(!0),m(null);try{s==null||s(await Be.createGroup({name:r.trim(),coordinator:o,members:p.filter(w=>w!==o)}))}catch(w){m(w instanceof me?w.message:String(w))}finally{h(!1)}};return n.jsx(ht,{title:"A new group",onClose:t,children:n.jsxs(re,{children:[n.jsx(ie,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:n.jsx("input",{value:r,autoFocus:!0,maxLength:80,onChange:w=>i(w.target.value),placeholder:"Household finances"})}),n.jsx(ie,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:n.jsx("select",{value:o,onChange:w=>c(w.target.value),children:e.map(w=>n.jsx("option",{value:w.id,children:w.name},w.id))})}),n.jsx(ie,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:n.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(w=>w.id!==o).map(w=>n.jsxs("label",{className:"group-pick-row","data-on":a.includes(w.id)||void 0,children:[n.jsx("input",{type:"checkbox",checked:a.includes(w.id),onChange:()=>x(w.id)}),n.jsx(gn,{agents:e,id:w.id,size:"sm"}),n.jsxs("span",{className:"group-pick-text",children:[n.jsx("span",{className:"group-pick-name",children:w.name}),n.jsx("span",{className:"group-pick-desc",children:w.description})]})]},w.id))})}),n.jsx(V,{children:"Members read what is said in this group and what they recall from shared and group memory. Nothing an agent knows privately is brought in on its own: what enters the room is seen by the room."}),f?n.jsx(V,{tone:"critical",children:f}):null,n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:t,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!g||u,onClick:()=>void b(),children:u?"Creating…":"Create group"})]})]})})}const o5=1e4;function Bd({title:e,body:t,duration:s,onUndo:r,onGone:i}){return n.jsxs(dM,{className:"ui-toast wb-undo-toast",duration:s,onOpenChange:a=>{a||i()},"data-testid":"undo-toast",children:[n.jsx("span",{className:"ui-toast-mark","aria-hidden":"true"}),n.jsxs("div",{className:"ui-toast-main",children:[n.jsx(hM,{className:"ui-toast-title",children:e}),t?n.jsx(fM,{className:"ui-toast-body",children:t}):null]}),r?n.jsx(mM,{altText:"Undo",asChild:!0,children:n.jsx("button",{type:"button",className:"ui-btn wb-undo-toast-action","data-variant":"ghost","data-size":"sm",onClick:r,children:"Undo"})}):null]})}function xj(e){const[t,s]=d.useState(null),[r,i]=d.useState(null),[a,l]=d.useState(null);return{busy:t,note:r,failure:a,decide:async(c,u,h,f)=>{var p,g,x,b;s(c),l(null),i(null);let m;try{const j=f?await E.decide(c,u,h,f):await E.decide(c,u,h);m={decision:u,...(p=j.execution)!=null&&p.state?{state:j.execution.state}:{},...j.execution&&"result"in j.execution?{result:j.execution.result}:{}},i(u==="reject"?`Rejected ${j.action.tool}.`:((g=j.execution)==null?void 0:g.state)==="succeeded"?`Approved and done: ${j.action.tool}.`:`Approved ${j.action.tool}: ${((x=j.execution)==null?void 0:x.state)??"no execution"}${(b=j.execution)!=null&&b.message?` (${j.execution.message})`:""}`)}catch(j){l(j instanceof Error?j.message:String(j))}finally{s(null),e(m)}}}}function vj({action:e,timezone:t,busy:s,onDecide:r,agentName:i}){var h,f;const[a,l]=d.useState(!1),{values:o,controls:c}=sj(e.choices),u=m=>o?r(e.id,"approve",m,o):r(e.id,"approve",m);return n.jsxs(ws,{tone:"accent",title:e.tool,meta:n.jsxs(n.Fragment,{children:[n.jsxs(ve,{children:["v",e.toolVersion]}),n.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[n.jsx(Pt,{children:e.preview}),n.jsxs("p",{className:"ui-card-meta",children:["Expires ",et(e.expiresAt,t)," (",Oe(e.expiresAt),"). Policy v",e.policyVersion,", args ",qo(e.argsHash,12),e.jobId?`, job ${qo(e.jobId)}`:"","."]}),c,n.jsxs(le,{children:[n.jsx(T,{variant:"good",disabled:s,onClick:()=>u(),children:(h=e.permissionScopes)!=null&&h.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?n.jsxs(n.Fragment,{children:[n.jsx(T,{disabled:s,onClick:()=>u("conversation"),children:"Auto: this conversation"}),n.jsx(T,{disabled:s,onClick:()=>u("always"),children:"Always: this agent"})]}):null,n.jsx(T,{variant:"danger",disabled:s,onClick:()=>r(e.id,"reject"),children:"Reject"}),n.jsx(T,{variant:"ghost",onClick:()=>l(m=>!m),"aria-expanded":a,children:a?"Hide envelope":"Show envelope"})]}),a?n.jsxs("div",{className:"ui-card-foot",children:[n.jsx(oe,{title:"Envelope: everything that decides what the world will see",children:n.jsx(Pt,{children:Xn(e.envelope)})}),n.jsx(oe,{title:"Canonical arguments",children:n.jsx(Pt,{children:Xn(e.canonicalArgs)})})]}):null]})}function jj(e,t,s){const[r,i]=d.useState(!1),[a,l]=d.useState(null),[o,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),E.acceptPluginAgent(e,t).then(h=>{l(h.agent)}).catch(h=>c(h instanceof me?h.message:String(h))).finally(()=>i(!1)))},busy:r,created:a,failure:o}}function mA({agent:e}){return n.jsxs(V,{tone:"good",role:"status",children:["@",e.handle," is ready. ",n.jsxs("a",{href:at(e.id),children:["Talk to @",e.handle]})]})}function pA(e,t,s){const r=e.canonicalArgs;return e.tool==="platform.accept_plugin_agent"&&(r==null?void 0:r.plugin)===t&&typeof r.agent=="string"&&r.agent.toLowerCase()===s.toLowerCase()}function c5(e,t){var i;const s=ce(()=>E.approvals(),[e,t],15e3);return{action:((i=s.data)==null?void 0:i.pending.find(a=>pA(a,e,t)))??null,reload:s.reload}}function u5({action:e,onDecided:t}){const{busy:s,failure:r,decide:i}=xj(a=>t(a));return n.jsxs(re,{gap:"sm",children:[n.jsx(vj,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:s===e.id,onDecide:(a,l,o,c)=>{i(a,l,o,c)}}),n.jsx(ae,{message:r})]})}function wj({plugin:e,agent:t,text:s,label:r,handle:i,onDismiss:a}){var f;const l=jj(e,t),o=c5(e,t),[c,u]=d.useState(null),h=l.created??c;if(h)return n.jsx(mA,{agent:h});if(o.action){const m=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return n.jsxs(re,{gap:"sm",children:[n.jsx("span",{children:s}),n.jsx(u5,{action:o.action,onDecided:p=>{(p==null?void 0:p.decision)==="approve"&&p.state==="succeeded"?u({id:t,handle:m,name:m}):o.reload()}})]})}return n.jsxs(re,{gap:"sm",children:[n.jsxs(le,{children:[n.jsx("span",{children:s}),n.jsx(_t,{}),a?n.jsx(T,{variant:"ghost",disabled:l.busy,onClick:a,children:"Not now"}):null,n.jsx(T,{variant:"accent",disabled:l.busy,onClick:l.accept,children:r})]}),n.jsx(ae,{message:l.failure})]})}function gA(){var t;const e=ce(()=>E.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function xA({offers:e,reload:t}){return e.length===0?null:n.jsx(oe,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:n.jsx(re,{gap:"sm",divided:!0,children:e.map(s=>n.jsx(wj,{plugin:s.plugin,agent:s.agent,text:s.text,label:`Create @${s.handle}`,handle:s.handle,onDismiss:()=>{E.dismissAgentOffer(s.plugin,s.agent).then(t,t)}},`${s.plugin}/${s.agent}`))})})}const d5=512*1024,h5=/^[A-Za-z0-9+/]*={0,2}$/;function vA(e){const t=e==null?void 0:e.play;if(typeof t!="object"||t===null)return null;const{mime:s,data:r}=t;return typeof s!="string"||!/^audio\/[a-z0-9.+-]+$/i.test(s.split(";")[0].trim())||typeof r!="string"||r===""||!h5.test(r)||Math.floor(r.length*3/4)>d5+2?null:{mime:s,data:r}}function jA(e){const t=e==null?void 0:e.message;return typeof t=="string"&&t.trim()!==""?t:null}let yr=null,yo=null,ac=null;const Pg=new Set;function wA(){for(const e of Pg)e()}function co(){yr&&(yr.onended=null,yr.onerror=null,yr.pause()),yo&&URL.revokeObjectURL(yo),yo=null,ac!==null&&(ac=null,wA())}async function yA(e,t){co();const s=atob(e.data),r=new Uint8Array(s.length);for(let i=0;i<s.length;i+=1)r[i]=s.charCodeAt(i);yr??(yr=new Audio),yo=URL.createObjectURL(new Blob([r],{type:e.mime})),ac=t,yr.onended=co,yr.onerror=co,yr.src=yo,wA();try{await yr.play()}catch{throw co(),new Error("The browser would not play the sound.")}}function Sk(e){e!==void 0&&ac!==e||co()}function f5(){return d.useSyncExternalStore(e=>(Pg.add(e),()=>Pg.delete(e)),()=>ac,()=>null)}const m5=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],qs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ck=/^\d{4}-\d{2}-\d{2}$/;function Gi(e){return e.split("-").map(Number)}function ua(e,t){const[s,r,i]=Gi(e);return new Date(Date.UTC(s,r-1,i+t)).toISOString().slice(0,10)}function bA(e){const[t,s,r]=Gi(e);return new Date(Date.UTC(t,s-1,r)).getUTCDay()}function kA(e){return m5[bA(e)]}function NA(e){return Gi(e)[2]}function Ek(e){return ua(e,-((bA(e)+6)%7))}function Ar(e){return Th(e,{weekday:!0,compact:!0})}function p5(e,t){return e===t?`Today · ${Ar(e)}`:e===ua(t,1)?`Tomorrow · ${Ar(e)}`:Ar(e)}function Li(e){return QD(e)}const Ak=new Map;function Mg(e,t){let s=Ak.get(t);s||(s=new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),Ak.set(t,s));const r=Object.fromEntries(s.formatToParts(e).map(i=>[i.type,i.value]));return{date:`${r.year}-${r.month}-${r.day}`,minutes:Number(r.hour)*60+Number(r.minute)}}function g5(e,t=new Date){return Mg(t,e).date}function x5(e,t){return e==="week"?{from:Ek(t),days:7}:e==="month"?{from:Ek(`${t.slice(0,8)}01`),days:42}:{from:t,days:7}}function v5(e,t,s){if(e!=="month")return ua(t,s*7);const[r,i]=Gi(t);return new Date(Date.UTC(r,i-1+s,1)).toISOString().slice(0,10)}function j5(e,t,s,r){const[i,a]=Gi(t);if(e==="month")return XC(i,a);const l=ua(s,r-1),[o,c,u]=Gi(s),[h,f,m]=Gi(l);return qC().date==="iso"?`${s} – ${l}`:XD()?c===f&&o===h?`${qs[c-1]} ${u} – ${m}, ${h}`:o===h?`${qs[c-1]} ${u} – ${qs[f-1]} ${m}, ${h}`:`${qs[c-1]} ${u}, ${o} – ${qs[f-1]} ${m}, ${h}`:c===f&&o===h?`${u} – ${m} ${qs[f-1]} ${h}`:o===h?`${u} ${qs[c-1]} – ${m} ${qs[f-1]} ${h}`:`${u} ${qs[c-1]} ${o} – ${m} ${qs[f-1]} ${h}`}function ba(e){return e==null?"":String(e)}function w5(e,t,s,r){const i=[],a=new Set;return e.forEach((l,o)=>{const c=ba(Ne(l,t.id)),u=ba(Ne(l,t.title)),h=ba(Ne(l,t.start)),f=ba(Ne(l,t.end));if(c===""||a.has(c)||h===""){console.warn(`buddi: ${r}: event ${o} has no id, a repeated one, or no start — not drawn`);return}a.add(c);const m=t.allDay===void 0?void 0:Ne(l,t.allDay),p=m===void 0?Ck.test(h):m===!0||m==="true",g=t.tone===void 0?0:Number(Ne(l,t.tone)),x=Number.isFinite(g)?(Math.trunc(g)%4+4)%4:0,b={id:c,title:u,calendar:t.calendar===void 0?"":ba(Ne(l,t.calendar)),tone:x,location:t.location===void 0?"":ba(Ne(l,t.location))};if(p){const N=h.slice(0,10),k=Ck.test(f.slice(0,10))&&f.slice(0,10)>N?f.slice(0,10):ua(N,1);i.push({...b,allDay:!0,startDate:N,startMin:0,endDate:k,endMin:0});return}const j=new Date(h);if(Number.isNaN(j.getTime())){console.warn(`buddi: ${r}: event ${o} starts at "${h}", which is not a time — not drawn`);return}const v=new Date(f),w=Mg(j,s),y=Number.isNaN(v.getTime())||v<j?w:Mg(v,s);i.push({...b,allDay:!1,startDate:w.date,startMin:w.minutes,endDate:y.date,endMin:y.minutes})}),i}function y5(e,t){if(e.allDay)return t>=e.startDate&&t<e.endDate?{from:0,to:1440,allDay:!0}:null;if(t<e.startDate||t>e.endDate)return null;const s=t===e.startDate?e.startMin:0,r=t===e.endDate?e.endMin:1440,i=e.startDate===e.endDate&&e.startMin===e.endMin;return r<=s&&!(i&&t===e.startDate)?null:{from:s,to:r,allDay:s===0&&r===1440}}function yj(e,t){return e.map(s=>({event:s,part:y5(s,t)})).filter(s=>s.part!==null).sort((s,r)=>Number(r.part.allDay)-Number(s.part.allDay)||s.part.from-r.part.from||r.part.to-s.part.to)}function bj(e,t){if(t.allDay)return"All day";const s=e.startDate!==e.endDate;return s&&t.from===0?`until ${Li(t.to)}`:s&&t.to===1440?`from ${Li(t.from)}`:t.from===t.to?Li(t.from):`${Li(t.from)}–${Li(t.to)}`}function Dg(e,t,s){return[bj(e,t),e.title,e.location,e.calendar,Ar(s)].filter(Boolean).join(", ")}const SA=30;function b5(e){const t=[];let s=[],r=-1;const i=[],a=()=>{const l=Math.max(1,...s.map(o=>o.lane+1));for(const o of s)t.push({...o,lanes:l});s=[],i.length=0};for(const l of e){const o=Math.max(l.part.to,l.part.from+SA);s.length>0&&l.part.from>=r&&a();let c=i.findIndex(u=>u<=l.part.from);c===-1?(c=i.length,i.push(o)):i[c]=o,s.push({...l,lane:c,lanes:1}),r=Math.max(r,o)}return s.length>0&&a(),t}const k5={week:"Week",month:"Month",list:"List"},N5=["week","month","list"],S5="(max-width: 720px)";function C5(e){try{return window.localStorage.getItem(e)}catch{return null}}function E5(e,t){try{window.localStorage.setItem(e,t)}catch{}}function A5(e){const t=e.views&&e.views.length>0?e.views:N5,s=Ps(S5),[r,i]=d.useState(()=>{const p=C5(e.storageKey);return p!==null&&t.includes(p)?p:null}),a=s&&t.includes("list")?"list":e.default&&t.includes(e.default)?e.default:t[0],l=r??a,[o,c]=d.useState(e.today),[u,h]=d.useState(null),{from:f,days:m}=x5(l,o);return{views:t,view:l,setView:p=>{i(p),E5(e.storageKey,p),h(null)},anchor:o,today:e.today,go:p=>{c(p===0?e.today:v5(l,o,p)),h(null)},from:f,days:m,to:ua(f,m),selected:u,select:h}}function T5({state:e,events:t,hours:s,empty:r,label:i}){const{view:a,anchor:l,today:o,from:c,days:u}=e,h=d.useMemo(()=>Array.from({length:u},(x,b)=>ua(c,b)),[c,u]),f=a==="month"?"month":"week",m=e.selected??(l.slice(0,7)===o.slice(0,7)?o:`${l.slice(0,8)}01`),p=a==="month"?m:a==="week"?e.selected:null,g=x=>{if(!x.target.closest('input, textarea, select, [contenteditable="true"]')&&!(x.altKey||x.ctrlKey||x.metaKey)){if(x.key==="ArrowLeft")e.go(-1);else if(x.key==="ArrowRight")e.go(1);else if(x.key==="t"||x.key==="T")e.go(0);else return;x.preventDefault()}};return n.jsxs("div",{className:"cal",role:"region","aria-label":i,tabIndex:0,onKeyDown:g,children:[n.jsxs("div",{className:"cal-bar",children:[n.jsx(T,{size:"sm","aria-label":`Previous ${f}`,onClick:()=>e.go(-1),children:n.jsx(ue,{name:"chevron-left",size:14})}),n.jsx(T,{size:"sm",onClick:()=>e.go(0),children:"Today"}),n.jsx(T,{size:"sm","aria-label":`Next ${f}`,onClick:()=>e.go(1),children:n.jsx(ue,{name:"chevron-right",size:14})}),n.jsx("h3",{className:"cal-title","aria-live":"polite",children:j5(a,l,c,u)}),e.views.length>1?n.jsx(rn,{label:"View",options:e.views.map(x=>({value:x,label:k5[x]})),value:a,onChange:e.setView}):null]}),a==="week"?n.jsx(R5,{dates:h,today:o,events:t,hours:s??[7,21],onPick:e.select}):null,a==="month"?n.jsx(I5,{dates:h,month:l.slice(0,7),today:o,events:t,selected:m,onPick:e.select}):null,a==="list"?n.jsx("div",{className:"cal-list",children:h.map(x=>n.jsx(Tk,{date:x,today:o,events:t,empty:r},x))}):null,p?n.jsx(Tk,{date:p,today:o,events:t,empty:r}):null]})}function Tk({date:e,today:t,events:s,empty:r}){const i=yj(s,e);return n.jsx(qe,{flush:!0,title:p5(e,t),children:n.jsx(dt,{children:i.length===0?n.jsx(it,{title:n.jsx("span",{className:"muted",children:r})}):i.map(({event:a,part:l})=>n.jsx(it,{lead:n.jsx("span",{className:"cal-dot","data-tone":a.tone,"aria-hidden":"true"}),title:a.title,sub:a.location||void 0,side:bj(a,l)},a.id))})})}function R5({dates:e,today:t,events:s,hours:r,onPick:i}){const a=d.useRef(null);d.useLayoutEffect(()=>{const c=a.current;c&&(c.scrollTop=c.scrollHeight/24*r[0])},[r[0]]);const l=e.map(c=>({date:c,items:yj(s,c)})),o=c=>c===t?"true":void 0;return n.jsx(qe,{flush:!0,children:n.jsxs("div",{className:"cal-week",role:"grid","aria-label":`Week of ${Ar(e[0])}`,style:{"--cal-span":r[1]-r[0]},children:[n.jsxs("div",{className:"cal-row",role:"row",children:[n.jsx("span",{className:"cal-gutter","aria-hidden":"true"}),e.map(c=>n.jsxs("div",{className:"cal-day-head",role:"columnheader","data-today":o(c),"aria-label":Ar(c),children:[n.jsx("span",{className:"cal-wd",children:kA(c)}),n.jsx("span",{className:"cal-num",children:NA(c)})]},c))]}),n.jsxs("div",{className:"cal-row cal-allday",role:"row",children:[n.jsx("span",{className:"cal-gutter cal-gutter-label",children:"All day"}),l.map(({date:c,items:u})=>n.jsx("div",{className:"cal-allday-cell",role:"gridcell","data-today":o(c),children:u.filter(h=>h.part.allDay).map(({event:h,part:f})=>n.jsx("button",{type:"button",className:"cal-chip","data-tone":h.tone,"aria-label":Dg(h,f,c),onClick:()=>i(c),children:h.title},h.id))},c))]}),n.jsx("div",{className:"cal-scroll",ref:a,children:n.jsxs("div",{className:"cal-row cal-times",role:"row",children:[n.jsx("div",{className:"cal-gutter cal-hours","aria-hidden":"true",children:Array.from({length:23},(c,u)=>u+1).map(c=>n.jsx("span",{className:"cal-hour-label",style:{top:`calc(var(--cal-hour) * ${c})`},children:Li(c*60)},c))}),l.map(({date:c,items:u})=>n.jsx("div",{className:"cal-col",role:"gridcell","aria-label":Ar(c),"data-today":o(c),children:b5(u.filter(h=>!h.part.allDay)).map(({event:h,part:f,lane:m,lanes:p})=>n.jsxs("button",{type:"button",className:"cal-event","data-tone":h.tone,"data-short":f.to-f.from<60?"true":void 0,"data-lane":m,"aria-label":Dg(h,f,c),onClick:()=>i(c),style:{top:`calc(var(--cal-hour) * ${f.from/60})`,height:`calc(var(--cal-hour) * ${Math.max(f.to-f.from,SA)/60})`,left:`calc((100% - var(--space-1)) * ${m/p} + var(--space-0))`,width:`calc((100% - var(--space-1)) / ${p} - var(--space-0))`},children:[n.jsx("span",{className:"cal-event-time",children:bj(h,f)}),n.jsx("span",{className:"cal-event-title",children:h.title})]},h.id))},c))]})})]})})}const $5=3;function I5({dates:e,month:t,today:s,events:r,selected:i,onPick:a}){const l=Array.from({length:6},(h,f)=>e.slice(f*7,f*7+7)),[o,c]=t.split("-").map(Number),u=XC(o,c);return n.jsx(qe,{flush:!0,children:n.jsxs("div",{className:"cal-month",role:"grid","aria-label":u,children:[n.jsx("div",{className:"cal-row",role:"row",children:e.slice(0,7).map(h=>n.jsx("div",{className:"cal-wd-head",role:"columnheader",children:kA(h)},h))}),l.map(h=>n.jsx("div",{className:"cal-row",role:"row",children:h.map(f=>{const m=yj(r,f),p=m.slice(0,$5),g=m.length-p.length,x=m.length===0?"nothing":m.length===1?"1 event":`${m.length} events`;return n.jsxs("div",{className:"cal-cell",role:"gridcell","aria-selected":f===i,"data-date":f,"data-today":f===s?"true":void 0,"data-outside":f.slice(0,7)!==t?"true":void 0,"data-selected":f===i?"true":void 0,onClick:()=>a(f),children:[n.jsx("button",{type:"button",className:"cal-num","aria-label":`${Ar(f)}, ${x}`,"aria-pressed":f===i,children:NA(f)}),p.map(({event:b,part:j})=>n.jsx("button",{type:"button",className:"cal-chip","data-tone":b.tone,"data-timed":j.allDay?void 0:"true","aria-label":Dg(b,j,f),children:j.allDay?b.title:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"cal-dot","data-tone":b.tone,"aria-hidden":"true"}),n.jsx("span",{className:"cal-chip-time",children:Li(j.from)})," ",b.title]})},b.id)),g>0?n.jsxs("button",{type:"button",className:"cal-more","aria-label":`${g} more on ${Ar(f)}`,children:["+",g]}):null]},f)})},h[0]))]})})}const CA={width:1200,height:200,top:28,right:12,bottom:24,left:36};function P5(e,t){if(t==="percent")return[0,50,100];let s=e.length>0?Math.min(...e):0,r=e.length>0?Math.max(...e):1;t!=="temp"&&(s=Math.min(0,s)),s===r&&(s-=1,r+=1);const i=10**Math.floor(Math.log10(Math.max(1,(r-s)/3))),a=c=>Math.ceil(r/c)-Math.floor(s/c);let l=[1,2,5,10].map(c=>c*i).find(c=>a(c)<=3)??i*10;a(l)<2&&(l>1?l/=2:r+=l);const o=[];for(let c=Math.floor(s/l)*l;c<=Math.ceil(r/l)*l+l/1e3;c+=l)o.push(Math.round(c*1e6)/1e6);return o}function bu(e,t){return t==="temp"?`${e}°`:t==="percent"?`${e}%`:String(e)}function M5(e){const t=CA,s=e.values.length,r=t.width-t.left-t.right,i=t.height-t.top-t.bottom,a=t.height-t.bottom,l=s>0?r/s:r,o=j=>_i(t.left+l*(j+.5)),c=e.values.filter(j=>j!==null&&Number.isFinite(j)),u=P5(c,e.unit),h=u[0],f=u[u.length-1],m=j=>_i(t.top+i-(j-h)/(f-h)*i),p=e.values.map((j,v)=>{const w=j!==null&&Number.isFinite(j);return{index:v,x:o(v),y:w?m(j):null,value:w?j:null}}),g=[],x=[];if(e.kind==="area"){let j=[];const v=()=>{if(j.length===0)return;const w=j.map((y,N)=>`${N===0?"M":"L"}${y.x},${y.y}`).join(" ");g.push(w),x.push(`${w} L${j[j.length-1].x},${a} L${j[0].x},${a} Z`),j=[]};for(const w of p)w.y===null?v():j.push(w);v()}const b=e.kind==="bars"?p.flatMap(j=>j.y===null?[]:[{index:j.index,x:_i(j.x-l*.28),y:j.y,width:_i(l*.56),height:_i(a-j.y)}]):[];return{ticks:u.map(j=>({value:j,y:m(j)})),lines:g,areas:x,bars:b,points:p,slot:l,floor:a}}function D5({title:e,note:t,xs:s,series:r,tiles:i,labelEvery:a=3}){var N;const[l,o]=d.useState(((N=r[0])==null?void 0:N.id)??""),[c,u]=d.useState(null),[h,f]=d.useState(null),m=d.useRef(null),p=s.length,g=c??h,x=r.find(k=>k.id===l)??r[0],b=M5(x),j=CA,v=k=>k%a===0||k===g,w=x.values.filter(k=>k!==null&&Number.isFinite(k));d.useEffect(()=>{const k=m.current,S=g===null?null:k==null?void 0:k.children[g];!k||!S||typeof k.scrollTo!="function"||(S.offsetLeft<k.scrollLeft?k.scrollTo({left:S.offsetLeft,behavior:"smooth"}):S.offsetLeft+S.offsetWidth>k.scrollLeft+k.clientWidth&&k.scrollTo({left:S.offsetLeft+S.offsetWidth-k.clientWidth,behavior:"smooth"}))},[g]);const y=k=>{var $,R,I;const S=k.key==="ArrowRight"?1:k.key==="ArrowLeft"?-1:0,C=k.key==="Home"?0:k.key==="End"?p-1:S===0?null:Math.max(0,Math.min(p-1,(h??-S)+S));C!==null&&(k.preventDefault(),f(C),(I=(R=($=m.current)==null?void 0:$.children[C])==null?void 0:R.querySelector("button"))==null||I.focus())};return n.jsxs(qe,{...e?{title:e}:{},children:[t?n.jsx("p",{className:"ui-panel-sub",children:t}):null,n.jsxs("div",{className:"pg-series",onMouseLeave:()=>u(null),children:[r.length>1?n.jsx("div",{className:"pg-series-tabs",role:"tablist","aria-label":"Series",children:r.map(k=>n.jsx("button",{type:"button",role:"tab",className:"ui-tab","aria-selected":k.id===x.id,onClick:()=>o(k.id),children:k.label},k.id))}):null,n.jsxs("figure",{className:"pg-series-chart","data-kind":x.kind,children:[n.jsxs("svg",{viewBox:`0 0 ${j.width} ${j.height}`,"aria-hidden":"true",focusable:"false","data-testid":"series-svg",children:[b.ticks.map(k=>n.jsxs("g",{children:[n.jsx("line",{className:"pg-series-grid",x1:j.left,x2:j.width-j.right,y1:k.y,y2:k.y}),n.jsx("text",{className:"pg-series-tick",x:j.left-8,y:k.y,textAnchor:"end",dominantBaseline:"middle",children:bu(k.value,x.unit)})]},k.value)),b.areas.map((k,S)=>n.jsx("path",{className:"pg-series-area",d:k},`a${S}`)),b.lines.map((k,S)=>n.jsx("path",{className:"pg-series-line",d:k},`l${S}`)),b.bars.map(k=>n.jsx("rect",{className:"pg-series-bar","data-index":k.index,"data-hover":k.index===g?"true":void 0,x:k.x,y:k.y,width:k.width,height:k.height},k.index)),g!==null&&b.points[g]?n.jsx("line",{className:"pg-series-guide","data-index":g,x1:b.points[g].x,x2:b.points[g].x,y1:j.top-4,y2:b.floor}):null,x.kind==="area"?b.points.map(k=>k.y!==null&&v(k.index)?n.jsx("circle",{className:"pg-series-dot","data-index":k.index,"data-hover":k.index===g?"true":void 0,cx:k.x,cy:k.y,r:k.index===g?5:3},k.index):null):null,b.points.map(k=>k.y!==null&&k.value!==null&&v(k.index)?n.jsx("text",{className:"pg-series-value","data-index":k.index,"data-hover":k.index===g?"true":void 0,x:k.x,y:k.y-(x.kind==="area"?10:6),textAnchor:"middle",children:bu(k.value,x.unit)},k.index):null),b.points.map(k=>k.index%a===0?n.jsx("text",{className:"pg-series-x",x:k.x,y:j.height-6,textAnchor:"middle",children:s[k.index]},k.index):null),b.points.map(k=>n.jsx("rect",{className:"pg-series-hit","data-index":k.index,x:_i(j.left+b.slot*k.index),y:0,width:_i(b.slot),height:j.height,onMouseEnter:()=>u(k.index),onClick:()=>f(k.index)},k.index))]}),n.jsx("figcaption",{className:"sr-only",children:w.length===0?`${x.label}: no values.`:`${x.label}, ${p} ${p===1?"point":"points"} from ${s[0]} to ${s[p-1]}: lowest ${bu(Math.min(...w),x.unit)}, highest ${bu(Math.max(...w),x.unit)}.`})]}),n.jsx("ul",{className:"wb-tiles","data-layout":"strip",ref:m,onKeyDown:y,children:i.map((k,S)=>n.jsx("li",{className:"wb-tile",children:n.jsx("button",{type:"button",className:"ui-card","data-index":S,"data-hover":S===g?"true":void 0,"aria-pressed":S===h,"aria-label":[k.label,k.value,...k.lines].filter(C=>C!=="").join(", "),onMouseEnter:()=>u(S),onClick:()=>f(S),children:n.jsxs("div",{className:"wb-tile-body","aria-hidden":"true",children:[n.jsx("span",{className:"wb-tile-icon","data-icon":k.icon??"dot",children:n.jsx(ue,{name:Al(k.icon),size:22})}),k.value!==""?n.jsx("span",{className:"wb-tile-value tnum",children:k.value}):null,n.jsx("span",{className:"wb-tile-label",children:k.label}),k.lines.map((C,$)=>n.jsx("span",{className:"wb-tile-line",children:C},$))]})})},S))})]})]})}function _i(e){return Math.round(e*10)/10}const kj=d.createContext(null),Wd=d.createContext(!1);function Rt(){const e=d.useContext(kj);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function Og(e,t=new Set){if(Array.isArray(e))for(const s of e)Og(s,t);else if(e&&typeof e=="object"){const s=e.query;typeof s=="string"&&t.add(s);for(const r of Object.values(e))Og(r,t)}return t}function EA(e,t){if(t.size===0)return!1;for(const s of Og(e))if(t.has(s))return!0;return!1}function AA(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const s=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",s)}},[e]),[e,()=>t(s=>!s)]}function TA({revealed:e,onToggle:t}){return n.jsx(T,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function RA(){return n.jsx("p",{className:"muted",children:"Hidden until you show it."})}function $A({children:e}){const[t,s]=AA();return n.jsxs(re,{gap:"sm",children:[n.jsx(le,{align:"end",children:n.jsx(TA,{revealed:t,onToggle:s})}),t?n.jsx(Wd.Provider,{value:!0,children:e}):n.jsx(RA,{})]})}function Nj(e){return e===void 0||e==="neutral"?void 0:e}function Lg(e){return Nj(e)}function O5(e){const t=Nj(e);return t==="accent"?void 0:t}function ps(e,t){if(!t)return!0;const s=Ne(e,t.path),r=t.in!==void 0?t.in.includes(s):s===t.equals;return t.not===!0?!r:r}function Sj(e,t,s){if("chat"in t){const a=He(s,t.chat);return a==null?"":at(String(a))}if("proposals"in t)return lF(e.plugin);const r=e.pages.find(a=>a.id===t.page);if((r==null?void 0:r.place)==="settings")return gi(e.plugin,t.page);const i=t.item===void 0?null:He(s,t.item);return lr(e.plugin,t.page,i==null?null:String(i))}function Cj(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(s,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(s,r)=>{const i=Ne(t.row,r);return i==null?"":String(i)})}function _g(e,t){if(e===void 0)return;if(typeof e=="string")return e;const s=He(t,e);return s==="good"||s==="warning"||s==="critical"||s==="neutral"?s:void 0}function IA(e,t,s){const r={};for(const[i,a]of Object.entries(e??{})){let l;"param"in a?l=s.params[a.param]:"route"in a?l=a.route==="plugin"?s.plugin:a.route==="page"?s.page:s.item:l=He(t,a),!(l==null||l==="")&&(r[i]=String(l))}return r}function da(e,t){var r,i,a;const s={};for(const[l,o]of Object.entries(e??{}))if("row"in o)s[l]=Ne(t.row,o.row);else if("field"in o){if((r=t.omit)!=null&&r.has(o.field))continue;const c=(i=t.fields)==null?void 0:i[o.field],u=(a=t.shape)==null?void 0:a.find(h=>h.name===o.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;s[l]=c}else"selected"in o?s[l]=t.selected??[]:"param"in o?s[l]=t.scope.params[o.param]:s[l]=He(t.data,o);return s}function Tn(e,t,s,r){const i=Rt(),a=e?{...IA(e.params,t,i),...r}:{},l=JSON.stringify([(e==null?void 0:e.query)??null,a,i.version]),o=ce(()=>e?E.pageQuery(i.plugin,e.query,a).then(c=>c.data):Promise.resolve(void 0),[l],s);return{data:o.data,error:o.error,loading:o.loading}}function Rc(){const e=Rt(),t=d.useId(),[s,r]=d.useState(null),[i,a]=d.useState(null),[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(null),m=(j,v)=>{if(j.done===void 0)return null;if(typeof j.done=="string")return j.done;const w=He(v,j.done);return w==null?null:String(w)},p=(j,v,w)=>{const y=j??"refresh";if(typeof y=="object"){const N=Sj(e,y.route,v);N===""?e.refresh():e.navigate(N);return}y==="close"&&(w==null||w()),e.refresh()},g=async(j,v,w)=>{r(j.tool),a(null),o(null);try{const y=await E.pageAct(e.plugin,{tool:j.tool,args:v});if(y.approvalId){u(y.approvalId),f({then:j.then,ref:j,...w?{onDone:w}:{}});return}u(null),f(null);const N=vA(y.result);o(m(j,y.result)??(N?jA(y.result):null)),N&&await yA(N,t),p(j.then,y.result,w)}catch(y){a(y instanceof Error?y.message:String(y)),e.refresh()}finally{r(null)}},x=j=>{if(!j){e.refresh();return}const v=h;if(u(null),f(null),v&&j.decision==="approve"&&j.state==="succeeded"){o(m(v.ref,j.result)),p(v.then,void 0,v.onDone);return}e.refresh()},b=()=>{a(null),o(null)};return{running:s,busy:s!==null,error:i,done:l,approvalId:c,waiting:(h==null?void 0:h.ref.pending)??null,settle:x,run:g,reset:b}}function Rl({action:e,args:t,disabled:s,running:r,count:i,row:a,onRun:l}){const[o,c]=d.useState(!1),u=f=>Cj(f,{...i===void 0?{}:{count:i},row:a}),h=u(e.label);return o&&e.confirm?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),n.jsx(T,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),n.jsxs(T,{variant:e.tone==="danger"?"danger":"accent",disabled:s,onClick:()=>{c(!1),l(e,t)},children:["Yes, ",h.toLowerCase()]})]}):n.jsx(T,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:s,onClick:()=>e.confirm?c(!0):l(e,t),children:r&&e.busy?e.busy:h})}function Hd({id:e,onDecided:t}){const s=Rt(),r=ce(()=>E.approval(e),[e,s.version]),{busy:i,note:a,failure:l,decide:o}=xj(c=>{t?t(c):s.refresh()});return r.error?n.jsx(ae,{message:r.error}):r.data?n.jsxs(re,{children:[n.jsx(vj,{action:r.data,timezone:s.timezone,busy:i===e,onDecide:(c,u,h,f)=>{o(c,u,h,f)}}),a?n.jsx(V,{tone:"good",role:"status",children:a}):null,n.jsx(ae,{message:l})]}):n.jsx(xe,{children:"Loading the approval…"})}function $l({act:e}){return e.error?n.jsx(ae,{message:e.error}):e.approvalId?e.waiting?n.jsxs(re,{children:[n.jsx(V,{role:"status",children:e.waiting}),n.jsx(Hd,{id:e.approvalId,onDecided:e.settle})]}):n.jsx(Hd,{id:e.approvalId,onDecided:e.settle}):e.done?n.jsx(V,{tone:"good",role:"status",children:e.done}):null}function lc(e,t){const s={};for(const r of e){const i=r.from===void 0?void 0:Ne(t,r.from);s[r.name]=r.multiple?Array.isArray(i)?i.map(String):[]:i!==void 0?i:r.type==="checkbox"?!1:""}return s}function PA(e,t,s){const r=Rt(),i=e.optionsFrom,a=i?{...IA(i.query.params,s,r),...Object.fromEntries((i.dependsOn??[]).map(c=>[c,String(t[c]??"")]).filter(([,c])=>c!==""))}:{},l=JSON.stringify([(i==null?void 0:i.query.query)??null,a,r.version]),o=ce(()=>i?E.pageQuery(r.plugin,i.query.query,a).then(c=>c.data):Promise.resolve(void 0),[l]);return i?{options:cr(o.data,i.rows).map(c=>({value:String(Ne(c,i.value)??""),label:String(Ne(c,i.label)??"")})),loading:o.loading}:{options:e.options??[],loading:!1}}function L5({field:e,fields:t,value:s,values:r,data:i,disabled:a,compact:l,onChange:o}){const c=PA(e,r,i),u={id:`f-${e.name}`,required:e.required,name:e.name,disabled:a,...l&&e.hint?{title:e.hint}:{}},h=l?void 0:e.hint;if(e.type==="select"&&e.multiple){const m=Array.isArray(s)?s.map(String):[],g=e.max!==void 0&&m.length>=e.max?`Up to ${e.max}; remove one to add another.`:void 0;return n.jsx(ie,{label:e.label,hint:l?void 0:[h,g].filter(Boolean).join(" ")||void 0,group:!0,children:n.jsx(jz,{id:u.id,label:e.label,options:c.options,value:m,max:e.max,disabled:a,onChange:o})})}if(e.type==="select"){const m=n.jsxs("select",{...u,value:String(s??""),onChange:p=>o(p.target.value),children:[n.jsx("option",{value:"",children:c.loading?"Loading…":"—"}),c.options.map(p=>n.jsx("option",{value:p.value,children:p.label},p.value))]});return e.action&&!l?n.jsx(_5,{field:e,action:e.action,fields:t??[e],values:r,data:i,disabled:a,hint:h,children:m}):n.jsx(ie,{label:e.label,hint:h,children:m})}if(e.type==="textarea")return n.jsx(ie,{label:e.label,hint:h,wide:!0,children:n.jsx("textarea",{...u,value:String(s??""),onChange:m=>o(m.target.value),rows:6})});if(e.type==="checkbox")return n.jsx(ie,{label:e.label,hint:h,inline:!0,wide:!l,children:n.jsx("input",{...u,type:"checkbox",checked:s===!0,onChange:m=>o(m.target.checked)})});const f=e.type==="secret"?"password":e.type==="number"?"number":e.type;return n.jsx(ie,{label:e.label,hint:h,children:n.jsx("input",{...u,type:f,value:s==null?"":String(s),min:e.min,max:e.max,step:e.step,...l&&e.hint?{placeholder:e.hint}:{},onChange:m=>o(e.type==="number"?F5(m.target.value):m.target.value)})})}function _5({field:e,action:t,fields:s,values:r,data:i,disabled:a,hint:l,children:o}){const c=Rt(),u=d.useId(),h=f5()===u,[f,m]=d.useState(!1),[p,g]=d.useState(null),[x,b]=d.useState(null),[j,v]=d.useState(null);d.useEffect(()=>()=>Sk(u),[u]);const w=Ej(s,r,i),y=t.args!==void 0?da(t.args,{data:i,fields:r,shape:s,omit:w,scope:c}):Object.fromEntries(Object.entries(r).filter(([S,C])=>!w.has(S)&&C!=="")),N=async()=>{if(h){Sk(u);return}m(!0),g(null),b(null),v(null);try{const S=await E.pageAct(c.plugin,{tool:t.tool,args:y});if(S.approvalId){v(S.approvalId);return}g(jA(S.result));const C=vA(S.result);C&&await yA(C,u)}catch(S){b(S instanceof Error?S.message:String(S))}finally{m(!1)}},k=h?"Stop":t.label;return n.jsx(ie,{label:e.label,hint:l,action:n.jsx(T,{"data-shape":"icon","aria-label":f?`${t.label}: working`:k,title:k,"aria-busy":f||void 0,"aria-pressed":t.icon==="play"?h:void 0,disabled:a===!0||f,onClick:()=>void N(),children:f?n.jsx("span",{className:"ui-spinner","aria-hidden":"true"}):n.jsx(ue,{name:h?"stop":t.icon??"arrow"})}),after:x?n.jsx(ae,{message:x}):j?n.jsx(Hd,{id:j,onDecided:()=>v(null)}):p?n.jsx("span",{className:"ui-field-hint",role:"status",children:p}):null,children:o})}function F5(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function MA(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function Ej(e,t,s){const r=MA(t,s);return new Set(e.filter(i=>i.when!==void 0&&!ps(r,i.when)||i.disabledWhen!==void 0&&ps(r,i.disabledWhen)).map(i=>i.name))}function Xh({fields:e,values:t,data:s,disabled:r,compact:i,columns:a,onChange:l}){const o=MA(t,s);return n.jsx(Os,{dense:i,columns:a,children:e.filter(c=>c.when===void 0||ps(o,c.when)).map(c=>n.jsx(L5,{field:c,fields:e,compact:i,value:t[c.name],values:t,data:s,disabled:r===!0||c.disabledWhen!==void 0&&ps(o,c.disabledWhen),onChange:u=>l(c.name,u)},c.name))})}const oc=d.createContext(!1),DA=d.createContext(!1),OA=d.createContext(!1);function ss({title:e,note:t,actions:s,children:r}){const i=d.useContext(oc);return n.jsx(oe,{title:e,aside:t,actions:s,panel:i,children:n.jsx(oc.Provider,{value:!1,children:n.jsx(DA.Provider,{value:i,children:r})})})}function or({component:e,data:t,choose:s,chosen:r}){const i=Rt(),a=d.useContext(Wd);if(!ps(t,e.when))return null;if(e.kind!=="section"&&!a&&EA(e,i.sensitive))return n.jsx($A,{children:n.jsx(or,{component:e,data:t,...s?{choose:s}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return n.jsx(z5,{component:e,data:t});case"notice":return n.jsx(V,{tone:Nj(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(He(t,e.text)??"")});case"link":return n.jsx(U5,{component:e,data:t});case"progress":return n.jsx(W5,{component:e,data:t});case"chart":return n.jsx(H5,{component:e,data:t});case"stats":return n.jsx(K5,{component:e,data:t});case"list":return n.jsx(G5,{component:e,data:t,...s?{onChoose:s}:{},...r===void 0?{}:{chosen:r}});case"table":return n.jsx(q5,{component:e,data:t});case"detail":return n.jsx(J5,{component:e,data:t});case"form":return n.jsx(Z5,{component:e,data:t});case"search":return n.jsx(n8,{component:e,data:t});case"list-detail":return n.jsx(s8,{component:e,data:t});case"repeat":return n.jsx(r8,{component:e,data:t});case"calendar":return n.jsx(i8,{component:e,data:t});case"tiles":return n.jsx(a8,{component:e,data:t});case"series-panel":return n.jsx(l8,{component:e,data:t});case"hero":return n.jsx(o8,{component:e,data:t});case"tabs":return n.jsx(c8,{component:e,data:t});case"expand":return n.jsx(u8,{component:e,data:t});case"button":return n.jsx(d8,{component:e,data:t});case"approval":return n.jsx(f8,{component:e,data:t});case"artifact":return n.jsx(m8,{component:e,data:t});case"editor":return n.jsx(p8,{component:e,data:t});case"agent-offer":return n.jsx(h8,{component:e});default:return n.jsx(V,{children:"This page uses a part this dashboard does not know yet. Reload buddi to see it."})}}function z5({component:e,data:t}){const s=Rt(),r=d.useContext(Wd),[i,a]=AA(),l=!r&&EA(e.body,s.sensitive),o=l&&!i,c=d.useContext(oc);let u=e.body.length;const h=p=>p.kind==="button"||p.kind==="link"||p.kind==="form"&&p.drawer!==void 0&&!p.title;for(;c&&u>0&&h(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),m=[...e.actions??[],...e.body.slice(u)];return n.jsx(ss,{title:e.title,note:e.note,actions:m.length>0||l?n.jsxs(n.Fragment,{children:[m.map((p,g)=>n.jsx(or,{component:p,data:t},g)),l?n.jsx(TA,{revealed:i,onToggle:a}):null]}):void 0,children:n.jsx(re,{gap:"lg",divided:c,children:o?n.jsx(RA,{}):n.jsx(Wd.Provider,{value:r||l,children:f.map((p,g)=>n.jsx(or,{component:p,data:t},g))})})})}function U5({component:e,data:t}){const s=Rt(),r=Sj(s,e.to,t);return r===""?null:n.jsx(le,{children:n.jsx(Tt,{href:r,onClick:i=>{i.preventDefault(),s.navigate(r)},children:e.label})})}function Rk(e){return Math.round(e/1e6)}function B5(e,t){const s=qn(He(t,e.value))??0,r=e.total?qn(He(t,e.total)):null,i=e.total?r&&r>0?s/r:0:s,a=Math.max(0,Math.min(1,i)),l=Math.floor(a*100),o=i>=1,c=e.total&&r&&r>0?`${Rk(s)} of ${Math.max(1,Rk(r))} MB · ${l}%`:`${l}%`;return{percent:l,full:o,line:c}}function W5({component:e,data:t}){const s=c=>c===void 0?"":typeof c=="string"?c:String(He(t,c)??""),r=s(e.label),i=s(e.done),{percent:a,full:l,line:o}=B5(e,t);return n.jsxs(re,{gap:"sm",children:[r?n.jsx("span",{children:r}):null,l&&i?n.jsx("span",{role:"status",children:i}):n.jsxs(n.Fragment,{children:[n.jsx(AE,{value:a,label:r||"Progress"}),n.jsx("span",{role:"status",children:o})]})]})}function H5({component:e,data:t}){const s=Tn(e.query,t),r=e.rows===void 0?Array.isArray(s.data)?s.data:[]:cr(s.data,e.rows),i=r.map(h=>String(Ne(h,e.x)??"")),a=h=>r.map(f=>qn(Ne(f,h))??null),l=e.series!==void 0,o=e.y===void 0?[]:Array.isArray(e.y)?e.y:[e.y],c=l?e.series.map(h=>({label:h.label,values:a(h.y),type:h.type,...h.unit?{unit:h.unit}:{}})):o.map(h=>({label:o.length===1?e.label??h:h,values:a(h)})),u=e.target?qn(He(s.data,e.target))??null:null;return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:s.error}),r.length===0?s.loading||s.data===void 0?n.jsx(xe,{children:"Loading…"}):n.jsx(Il,{text:e.empty??"Nothing recorded yet."}):n.jsx(dz,{xs:i,series:c,type:l?"mixed":e.type??"line",target:u,...e.label?{label:e.label}:{},formatX:h=>/^\d{4}-\d{2}-\d{2}/.test(h)?ag(h):h,formatY:h=>Qt(h,"number",null)})]})}function K5({component:e,data:t}){const s=Tn(e.query,t);return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:s.error}),s.data===void 0?n.jsx(xe,{children:e.empty??"Loading…"}):n.jsx(qh,{children:e.items.map((r,i)=>n.jsx(tr,{label:r.label,value:Qt(He(s.data,r.value),r.unit??"text",null),tone:O5(r.tone)},i))})]})}function LA(e,t,s,r){const i=(t.meta??[]).map(u=>String(He(s,u)??"")).filter(u=>u!==""),a=String(He(s,t.title)??""),l=t.to&&!r?Sj(e,t.to,s):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,h)=>{const f=He(s,u.value);if(f==null||f==="")return null;const m=V5(u,f,s);return n.jsx(ve,{tone:Lg(m.tone),children:m.text},h)});return{text:a,href:l,pills:n.jsx(n.Fragment,{children:c}),meta:i.join(" · "),title:l?n.jsx("a",{href:l,onClick:u=>{u.preventDefault(),e.navigate(l)},children:a}):a,sub:t.sub?String(He(s,t.sub)??""):null,side:n.jsxs(n.Fragment,{children:[c,i.length>0?n.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function V5(e,t,s){const r=String(t),i=e.labels??{},a=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(a,r)?a[r]:_g(e.tone,s)}}function cr(e,t){const s=Ne(e,t);return Array.isArray(s)?s:[]}function _A(e,t,s){const r=[],i=new Set;return e.forEach((a,l)=>{const o=t===void 0?void 0:Ne(a,t),c=o==null||o===""?null:String(o);if(c===null){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: row ${l} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${s.plugin}, page ${s.page}, ${s.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:a})}),r}function G5({component:e,data:t,onChoose:s,chosen:r}){var k;const i=Rt(),a=d.useContext(OA),l=Tn(e.query,t),o=Rc(),[c,u]=d.useState([]),h=a&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=cr(l.data,e.rows),m=e.collapsed?cr(l.data,e.collapsed.rows):[],p=FA(e.actions,f,o),g={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},x=_A([...f,...m],e.key??((k=e.select)==null?void 0:k.key),g),b=new Map(x.map(S=>[S.row,S.key])),j=new Set(x.map(S=>S.row)),v=new Set(x.filter(({row:S})=>{var C;return((C=e.select)==null?void 0:C.disabledWhen)===void 0||!ps(S,e.select.disabledWhen)}).map(({key:S})=>S)),w=c.filter(S=>v.has(S)),y=d.useMemo(()=>{const S=f.filter($=>j.has($));if(!e.groupBy)return[{label:null,rows:S}];const C=new Map;for(const $ of S){const R=String(Ne($,e.groupBy.key)??"");C.set(R,[...C.get(R)??[],$])}return[...C].map(([$,R])=>{var I,z;return{label:((z=(I=e.groupBy)==null?void 0:I.labels)==null?void 0:z[$])??$,rows:R}})},[f,e.groupBy,x.length]),N=S=>S.map(C=>{var U;const $=LA(i,e.item,C,s),R=b.get(C);if(h&&(s||$.href))return n.jsx(TE,{href:$.href??"#",current:r===R,onClick:()=>s?s(R):i.navigate($.href),title:$.text,meta:$.meta,sub:$.sub,side:$.pills},R);const I=((U=e.select)==null?void 0:U.disabledWhen)!==void 0&&ps(C,e.select.disabledWhen),z=(e.actions??[]).filter(A=>ps(C,A.when));return n.jsx(it,{lead:e.select?n.jsx("input",{type:"checkbox","aria-label":`Select ${$.text}`,disabled:I,checked:c.includes(R),onClick:A=>A.stopPropagation(),onChange:A=>u(P=>A.target.checked?[...P,R]:P.filter(D=>D!==R))}):void 0,title:s?n.jsx("a",{href:"#","aria-current":r===R?"true":void 0,onClick:A=>{A.preventDefault(),s(R)},children:$.text}):$.title,sub:$.sub,side:n.jsxs(n.Fragment,{children:[$.side,z.map((A,P)=>n.jsx(zA,{action:A,row:C,data:l.data,act:o,onForm:p.show},P))]})},R)});return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:l.error}),p.open?null:n.jsx($l,{act:o}),p.open?n.jsx(UA,{open:p.open,data:l.data,act:o,onClose:p.close,onDone:p.finish}):null,y.every(S=>S.rows.length===0)?l.loading?n.jsx(xe,{children:"Loading…"}):n.jsx(Il,{text:e.empty??"Nothing here yet."}):n.jsxs(dt,{children:[e.select?n.jsx(it,{lead:n.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:v.size>0&&w.length===v.size,disabled:v.size===0,onChange:S=>u(S.target.checked?[...v]:[])}),title:n.jsxs("span",{className:"muted",children:[v.size," to choose from"]})}):null,y.map((S,C)=>n.jsxs("div",{children:[S.label?n.jsx("div",{className:"ui-list-group",children:S.label}):null,N(S.rows)]},C))]}),e.collapsed&&m.some(S=>j.has(S))?n.jsx(St,{summary:`${e.collapsed.label} (${m.filter(S=>j.has(S)).length})`,children:n.jsx(dt,{children:N(m.filter(S=>j.has(S)))})}):null,e.bulk&&e.bulk.length>0?n.jsxs(le,{align:"end",children:[n.jsxs("span",{className:"ui-toolbar-note",children:[w.length," selected"]}),e.bulk.map((S,C)=>{const $=w.length>0||S.all!==!0?w:[...v];return n.jsx(Rl,{action:S,args:da(S.args,{data:l.data,selected:$,scope:i}),count:$.length,disabled:o.busy||$.length===0,running:o.running===S.tool,onRun:(R,I)=>{u([]),o.run(R,I)}},C)})]}):null]})}function Y5(e,t,s){return Object.entries(e).every(([r,i])=>{const a=typeof i=="string"?i:Ne(s,i.row);return a!=null&&t[r]===String(a)})}function FA(e,t,s){const r=Rt(),[i,a]=d.useState(null);return d.useEffect(()=>{var l;if(!(i!==null||t.length===0))for(const o of e??[]){const c=(l=o.form)==null?void 0:l.openWhen;if(!c)continue;const u=t.find(h=>ps(h,o.when)&&Y5(c,r.params,h));if(u!==void 0){a({action:o,row:u}),r.setParams(Object.fromEntries(Object.keys(c).map(h=>[h,null])));return}}},[t.length,JSON.stringify(r.params)]),{open:i,show:(l,o)=>{s.reset(),a({action:l,row:o})},close:()=>{s.reset(),a(null)},finish:()=>a(null)}}function zA({action:e,row:t,data:s,act:r,onForm:i}){const a=Rt();return e.form?n.jsx(T,{disabled:r.busy,onClick:()=>i(e,t),children:Cj(e.label,{row:t})}):n.jsx(Rl,{action:e,args:da(e.args,{data:s,row:t,scope:a}),disabled:r.busy,running:r.running===e.tool,row:t,onRun:(l,o)=>void r.run(l,o)})}function UA({open:e,data:t,act:s,onClose:r,onDone:i}){const a=Rt(),{action:l,row:o}=e,c=l.form,[u,h]=d.useState(()=>lc(c.fields,o)),f=c.fields.some(x=>x.required&&(u[x.name]===""||u[x.name]===void 0)),{confirm:m,...p}=l,g={...p,label:c.submit};return n.jsx(ht,{title:Cj(c.title,{row:o}),onClose:r,foot:n.jsxs(le,{align:"end",children:[n.jsx(T,{variant:"ghost",onClick:r,children:"Cancel"}),n.jsx(Rl,{action:g,args:da(l.args,{data:t,row:o,fields:u,shape:c.fields,scope:a}),disabled:s.busy||f,running:s.running===l.tool,row:o,onRun:(x,b)=>void s.run(x,b,i)})]}),children:n.jsxs(re,{children:[n.jsx(Xh,{fields:c.fields,values:u,data:o,onChange:(x,b)=>h(j=>({...j,[x]:b}))}),n.jsx(ae,{message:s.error})]})})}function q5({component:e,data:t}){const s=Tn(e.query,t),r=Rc(),i=cr(s.data,e.rows),a=FA(e.actions,i,r);return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:s.error}),a.open?null:n.jsx($l,{act:r}),a.open?n.jsx(UA,{open:a.open,data:s.data,act:r,onClose:a.close,onDone:a.finish}):null,i.length===0?s.loading?n.jsx(xe,{children:"Loading…"}):n.jsx(Il,{text:e.empty??"Nothing here yet."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[e.columns.map(l=>n.jsx("th",{children:l.label},l.key)),e.actions&&e.actions.length>0?n.jsx("th",{"aria-label":"Actions"}):null]})}),n.jsx("tbody",{children:i.map((l,o)=>n.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:Qt(Ne(l,c.key),c.type??"text",null);return n.jsx("td",{"data-fit":c.fit,title:Q5(c,l,u),children:c.pill?n.jsx(X5,{column:c,row:l}):c.fit==="truncate"?n.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?n.jsx("td",{children:n.jsx(le,{align:"end",children:e.actions.filter(c=>ps(l,c.when)).map((c,u)=>n.jsx(zA,{action:c,row:l,data:s.data,act:r,onForm:a.show},u))})}):null]},o))})]})]})}function Q5(e,t,s){if(e.hint){const r=Ne(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&s?s:void 0}function X5({column:e,row:t}){var l,o;const s=Ne(t,e.key);if(Array.isArray(s))return n.jsx(n.Fragment,{children:s.map((c,u)=>{var x;const h=c,f=typeof h=="object"&&h!==null?h.value:c;if(f==null||f==="")return null;const m=typeof h=="object"&&h!==null?h.tone:void 0,p=(x=e.pill)==null?void 0:x.labels,g=p&&Object.prototype.hasOwnProperty.call(p,String(f))?p[String(f)]:Qt(f,e.type??"text",null);return n.jsx(ve,{tone:Lg(_g(typeof m=="string"?m:void 0,t)),children:g},u)})});const r=(l=e.pill)==null?void 0:l.labels,i=String(s),a=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:Qt(s,e.type??"text",null);return n.jsx(ve,{tone:Lg(_g((o=e.pill)==null?void 0:o.tone,t)),children:a})}function J5({component:e,data:t}){const s=Tn(e.query,t);return s.error?n.jsx(ae,{message:s.error}):s.data===void 0?n.jsx(xe,{children:e.empty??"Loading…"}):n.jsx(ss,{title:e.title,note:e.note,children:n.jsxs(re,{gap:"lg",children:[e.fields.length>0?n.jsx(Wt,{items:e.fields.map(r=>({key:r.label,label:r.label,value:Qt(He(s.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>n.jsx(or,{component:r,data:s.data},i))]})})}function Z5({component:e,data:t}){const s=Rt(),r=Tn(e.initial,t),i=Rc(),[a,l]=d.useState(!1),o=JSON.stringify([r.data??null,s.version]),c=n.jsx(e8,{component:e,data:t,initialData:r.data,act:i,onDone:()=>l(!1)},o);return e.drawer?n.jsxs(oe,{title:e.title,aside:e.note,actions:n.jsx(T,{variant:"accent",onClick:()=>l(!0),children:e.drawer.button}),children:[n.jsx($l,{act:i}),a?n.jsx(ht,{title:e.drawer.title,onClose:()=>l(!1),children:c}):null]}):n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:r.error}),c]})}function e8({component:e,data:t,initialData:s,act:r,onDone:i}){const a=d.useContext(DA),l=Rt(),[o,c]=d.useState(()=>lc(e.fields,s)),u=Ej(e.fields,o,s),h=e.fields.some(f=>f.required&&!u.has(f.name)&&(o[f.name]===""||o[f.name]===void 0||Array.isArray(o[f.name])&&o[f.name].length===0));return n.jsxs(re,{children:[n.jsx(Xh,{fields:e.fields,columns:e.columns,values:o,data:s,onChange:(f,m)=>c(p=>({...p,[f]:m}))}),e.drawer?null:n.jsx($l,{act:r}),n.jsx(le,{align:"end",className:a?"ui-panel-foot":void 0,children:n.jsx(Rl,{action:e.submit,args:da(e.submit.args,{data:t,fields:o,shape:e.fields,omit:u,scope:l}),disabled:r.busy||h,running:r.running===e.submit.tool,onRun:(f,m)=>void r.run(f,m,i)})})]})}function t8(e,t){var r;if(e.type==="checkbox")return e.label;const s=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${s?s.label:t}`}function $k(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function n8({component:e,data:t}){const s=Rt(),[r,i]=d.useState(()=>lc(e.fields,t)),[a,l]=d.useState(e.auto===!0),[o,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),h=Tn(a&&u?e.query:void 0,t),f=cr(h.data,e.rows),m=e.count===void 0?void 0:Ne(h.data,e.count),p=e.note===void 0?void 0:Ne(h.data,e.note),g=e.fields.find(C=>C.type==="text"||C.type==="email")??null,x=e.fields.filter(C=>C!==g),b=C=>{s.setParams(Object.fromEntries(e.fields.map($=>[$.name,String(C[$.name]??"")||null]))),l(!0)},j=(C,$)=>{const R={...r,[C]:$};i(R),e.auto&&b(R)},v=()=>{const C=lc(e.fields,null);i(C),e.auto?b(C):(s.setParams(Object.fromEntries(e.fields.map($=>[$.name,null]))),l(!1))},w=a?x.filter(C=>$k(s.params[C.name])):[],y=g?w.map(C=>n.jsx(Md,{label:C.label,onRemove:()=>{const $={...r,[C.name]:C.type==="checkbox"?!1:""};i($),b($)},children:t8(C,String(s.params[C.name]))},C.name)):[],N=x.filter(C=>$k(r[C.name])).length,k=e.auto&&!e.reset?null:n.jsxs(n.Fragment,{children:[e.reset?n.jsx(T,{variant:"ghost",onClick:v,children:"Clear"}):null,e.auto?null:n.jsx(T,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),S=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return n.jsx(ss,{title:e.title,children:n.jsxs(re,{children:[n.jsx(IE,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:g?n.jsx("input",{id:`f-${g.name}`,name:g.name,type:g.type==="email"?"email":"search","aria-label":g.label,placeholder:g.hint??g.label,title:g.hint,required:g.required,value:String(r[g.name]??""),onChange:C=>j(g.name,C.target.value)}):void 0,filters:x.length>0?n.jsx(Xh,{fields:x,values:r,data:t,compact:!0,onChange:j}):void 0,...g&&x.length>0?{filtersOpen:o,onToggleFilters:()=>c(C=>!C),active:N}:{},chips:y.length>0?y:void 0,actions:k}),n.jsx(ae,{message:h.error}),a&&(m!==void 0||p!==void 0)?n.jsxs("p",{className:"ui-card-meta",children:[m===void 0?"":`${Qt(m,"number",null)} in all. `,p===void 0?"":String(p)]}):null,a?f.length===0?n.jsx(xe,{children:h.loading?"Searching…":e.empty??"Nothing matches."}):n.jsx("div",{className:"ui-panel","data-flush":"true",children:n.jsx(dt,{children:f.map((C,$)=>{const R=LA(s,S,C);return n.jsx(it,{title:R.title,sub:R.sub,side:R.side},$)})})}):null]})})}function s8({component:e,data:t}){const s=Rt(),r=e.selection==="local",[i,a]=d.useState(null),l=r?i:s.params[e.param]??s.item,o=r&&i!==null?{...s,params:{...s.params,[e.param]:i}}:null,c=n.jsx(re,{gap:"lg",divided:!0,children:e.detail.map((u,h)=>n.jsx(or,{component:u,data:t},h))});return n.jsx(oc.Provider,{value:!1,children:n.jsx(RE,{list:n.jsx(OA.Provider,{value:!0,children:n.jsx(or,{component:e.list,data:t,chosen:l??null,...r?{choose:a}:{}})}),detail:l?o?n.jsx(kj.Provider,{value:o,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function r8({component:e,data:t}){const s=Rt(),[r,i]=d.useState(!1),a=Tn(e.query,t,r&&e.poll?e.poll.seconds*1e3:void 0),l=e.poll!==void 0&&a.data!==void 0&&ps(a.data,e.poll.while);d.useEffect(()=>i(l),[l]);const o=cr(a.data,e.rows);return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:a.error}),o.length===0?a.loading?n.jsx(xe,{children:"Loading…"}):n.jsx(Il,{text:e.empty??"Nothing here yet."}):n.jsx(re,{gap:"lg",divided:!0,children:_A(o,e.key,{plugin:s.plugin,page:s.page,component:`repeat "${e.title??e.rows}"`}).map(({key:c,row:u})=>n.jsx(oe,{children:n.jsx(re,{children:e.body.map((h,f)=>n.jsx(or,{component:h,data:u},f))})},c))})]})}function i8({component:e,data:t}){const s=Rt(),r=A5({...e.views?{views:e.views}:{},...e.default?{default:e.default}:{},today:g5(s.timezone),storageKey:`buddi.calendar-view:${s.plugin}/${s.page}`}),i=Tn(e.query,t,void 0,{from:r.from,to:r.to}),a=d.useMemo(()=>w5(cr(i.data,e.events),e.map,s.timezone,`plugin ${s.plugin}, page ${s.page}, calendar`),[i.data,e.events,e.map,s.timezone,s.plugin,s.page]);return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:i.error}),n.jsx(T5,{state:r,events:a,hours:e.hours,empty:e.empty??"Nothing.",label:e.title??"Calendar"})]})}function a8({component:e,data:t}){var f;const s=Rt(),r=Tn(e.query,t),i={items:"$",icon:e.icon,value:e.value,label:e.label,...e.lines?{lines:e.lines}:{},...e.tone?{tone:e.tone}:{}},a=cr(r.data,e.items).flatMap(m=>{const p=Jv([m],i).tiles[0];return p?[{tile:p,key:e.select?String(Ne(m,e.select.key)??""):""}]:[]}),l=e.select,o=l?Math.max(0,a.findIndex(m=>m.key===s.params[l.param])):null,c=((f=a[0])==null?void 0:f.key)??"",u=l?s.params[l.param]:void 0,h=a.some(m=>m.key===u);return d.useEffect(()=>{l&&c!==""&&!h&&s.setParams({[l.param]:c})},[l==null?void 0:l.param,c,h]),n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:r.error}),r.data===void 0?n.jsx(xe,{children:"Loading…"}):a.length===0?n.jsx(Il,{text:e.empty??"Nothing to show."}):n.jsx(WE,{props:{tiles:a.map(m=>m.tile),notice:!1,empty:""},...e.layout?{layout:e.layout}:{},...l?{selected:o,onPick:m=>{var p;return s.setParams({[l.param]:((p=a[m])==null?void 0:p.key)||null})}}:{}})]})}function l8({component:e,data:t}){const s=Tn(e.query,t),r=cr(s.data,e.points);if(s.data===void 0||r.length===0)return n.jsxs(ss,{title:e.title,note:e.note,children:[n.jsx(ae,{message:s.error}),s.data===void 0?n.jsx(xe,{children:"Loading…"}):n.jsx(Il,{text:e.empty??"Nothing to show."})]});const i=r.map(c=>String(Ne(c,e.x)??"")),a={items:"$",icon:e.tiles.icon,value:e.tiles.value,label:e.tiles.label,...e.tiles.lines?{lines:e.tiles.lines}:{}},l=r.map((c,u)=>Jv([c],a).tiles[0]??{icon:null,value:"",label:i[u]??"",lines:[],tone:"neutral",link:null}),o=e.series.map(c=>({id:c.id,label:c.label,kind:c.kind,...c.unit?{unit:c.unit}:{},values:r.map(u=>qn(Ne(u,c.y))??null)}));return n.jsxs(n.Fragment,{children:[n.jsx(ae,{message:s.error}),n.jsx(D5,{...e.title?{title:e.title}:{},...e.note?{note:e.note}:{},...e.labelEvery?{labelEvery:e.labelEvery}:{},xs:i,series:o,tiles:l})]})}function o8({component:e,data:t}){const s=Tn(e.query,t),r=o=>{const c=Ne(s.data,o);return c==null?"":String(c)};if(s.data===void 0||s.data===null)return n.jsxs(n.Fragment,{children:[n.jsx(ae,{message:s.error}),n.jsx(xe,{children:s.loading?"Loading…":e.empty??"Nothing to show."})]});const i=r(e.value),a=r(e.title),l=e.facts.map(o=>({label:o.label,value:r(o.path)})).filter(o=>o.value!=="");return n.jsxs("section",{className:"pg-hero","aria-label":[i,a,...l.map(o=>`${o.label} ${o.value}`)].filter(Boolean).join(", "),children:[n.jsxs("div",{className:"pg-hero-main","aria-hidden":"true",children:[n.jsx("span",{className:"pg-hero-icon",children:n.jsx(ue,{name:Al(fg(He(s.data,e.icon))),size:44})}),n.jsx("span",{className:"pg-hero-value",children:i}),a?n.jsx("span",{className:"pg-hero-title",children:a}):null]}),l.length>0?n.jsx("dl",{className:"pg-hero-facts","aria-hidden":"true",children:l.map(o=>n.jsxs("div",{className:"pg-hero-fact",children:[n.jsx("dt",{children:o.label}),n.jsx("dd",{children:o.value})]},o.label))}):null]})}function c8({component:e,data:t}){var u;const s=Rt(),[r,i]=d.useState(e.default??e.tabs[0].id),a=e.pick,{options:l}=PA({name:(a==null?void 0:a.param)??"",label:(a==null?void 0:a.label)??"",...a!=null&&a.options?{options:a.options}:{},...a!=null&&a.optionsFrom?{optionsFrom:a.optionsFrom}:{}},{},t),o=a?l.some(h=>h.value===s.params[a.param])?s.params[a.param]:((u=l[0])==null?void 0:u.value)??"":"",c=e.tabs.find(h=>h.id===r)??e.tabs[0];return n.jsxs("div",{className:"pg-tabs",children:[n.jsxs("div",{className:"pg-tabs-bar","data-only":e.tabs.length===1?"pick":void 0,children:[a&&l.length>1?n.jsx(rn,{label:a.label,options:l,value:o,onChange:h=>s.setParams({[a.param]:h})}):null,e.tabs.length>1?n.jsx(rn,{label:e.title??"View",options:e.tabs.map(h=>({value:h.id,label:h.label})),value:c.id,onChange:i}):null]}),c.body.map((h,f)=>n.jsx(or,{component:h,data:t},`${c.id}-${f}`))]})}function u8({component:e,data:t}){const[s,r]=d.useState(!1),i=Tn(s?e.query:void 0,t),a=typeof e.label=="string"?e.label:String(He(t,e.label)??"");return n.jsxs(St,{summary:a,boxed:!0,onToggle:l=>r(l),children:[n.jsx(ae,{message:i.error}),i.data===void 0?n.jsx(xe,{children:"Loading…"}):n.jsx(re,{children:e.body.map((l,o)=>n.jsx(or,{component:l,data:i.data},o))})]})}function d8({component:e,data:t}){const s=Rt(),r=Rc();return n.jsxs(n.Fragment,{children:[n.jsx(le,{align:"end",children:n.jsx(Rl,{action:e.action,args:da(e.action.args,{data:t,row:t,scope:s}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,a)=>void r.run(i,a)})}),n.jsx($l,{act:r})]})}function h8({component:e}){const t=Rt();return n.jsx(wj,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function f8({component:e,data:t}){const s=Ne(t,e.path);return typeof s!="string"||s===""?null:n.jsx(Hd,{id:s})}function m8({component:e,data:t}){const s=Ne(t,e.path);return typeof s!="string"||s===""?null:n.jsx(le,{children:n.jsx("a",{href:vi(s),children:e.label})})}function p8({component:e,data:t}){const s=Tn(e.query,t),r=Rc();return s.error?n.jsx(ae,{message:s.error}):s.data===void 0?n.jsx(xe,{children:e.empty??"Loading…"}):n.jsxs(n.Fragment,{children:[n.jsx($l,{act:r}),n.jsx(g8,{component:e,data:t,loaded:s.data,act:r},JSON.stringify(s.data))]})}function g8({component:e,data:t,loaded:s,act:r}){const i=Rt(),[a,l]=d.useState(()=>lc(e.fields,s)),o={...a,version:Ne(s,e.version)},c=Ej(e.fields,a,s),u=e.readOnlyWhen!==void 0&&ps(s,e.readOnlyWhen),h=(e.actions??[]).filter(p=>p.placement==="leading"),f=(e.actions??[]).filter(p=>p.placement!=="leading"),m=(p,g)=>n.jsx(Rl,{action:p,args:da(p.args,{data:t,fields:o,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===p.tool,onRun:(x,b)=>void r.run(x,b)},`${p.tool}-${g}`);return n.jsx(ss,{title:e.title,note:e.note,children:n.jsxs(re,{children:[n.jsx(Xh,{fields:e.fields,values:a,data:s,disabled:u,onChange:(p,g)=>l(x=>({...x,[p]:g}))}),u?null:n.jsxs(le,{align:"end",children:[h.map(m),h.length>0?n.jsx(_t,{}):null,m(e.save,-1),f.map(m)]}),e.footnote?n.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function Aj({page:e,item:t,navigate:s,timezone:r,embedded:i,siblings:a,params:l}){const[o,c]=d.useState(()=>({...l})),u=JSON.stringify(l??{});d.useEffect(()=>{l&&Object.keys(l).length>0&&c(b=>({...b,...l}))},[u]);const[h,f]=d.useState(0),m={plugin:e.plugin,page:e.id,pages:a??[e],item:t??null,params:{...o,...t?{item:t}:{},...v8(e,t)},setParams:b=>c(j=>{const v={...j};for(const[w,y]of Object.entries(b))y===null?delete v[w]:v[w]=y;return v}),navigate:s,timezone:r,version:h,refresh:()=>f(b=>b+1),sensitive:new Set(e.sensitive??[])},p=e.body[0],g=!i&&(p==null?void 0:p.kind)==="notice"&&typeof p.text=="string"&&p.when===void 0&&p.title===void 0&&(p.tone===void 0||p.tone==="neutral")?p.text:void 0,x=g===void 0?e:{...e,body:e.body.slice(1)};return n.jsx(kj.Provider,{value:m,children:n.jsx(An,{embedded:i,title:e.title,lede:g,children:n.jsx(x8,{page:x,boxed:i===!0})})})}function x8({page:e,boxed:t}){const s=Rt();return e.data&&s.sensitive.has(e.data.query)?n.jsx($A,{children:n.jsx(Ik,{page:e,boxed:t})}):n.jsx(Ik,{page:e,boxed:t})}function Ik({page:e,boxed:t}){const s=Tn(e.data,null);return n.jsxs(re,{gap:"lg",divided:!t,children:[n.jsx(ae,{message:s.error}),n.jsx(oc.Provider,{value:t,children:e.body.map((r,i)=>n.jsx(or,{component:r,data:s.data??null},i))})]})}function v8(e,t){if(!t)return{};const s=[],r=i=>{for(const a of i)if(a.kind==="list-detail")s.push(a.param),r(a.detail);else if(a.kind==="section"||a.kind==="detail"||a.kind==="expand")r(a.body);else if(a.kind==="tabs")for(const l of a.tabs)r(l.body)};return r(e.body),Object.fromEntries(s.map(i=>[i,t]))}function j8(e){return n.jsx(Aj,{...e,embedded:!0})}function Il({text:e}){const t=e.search(/[.!?]\s/),s=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return n.jsx(jn,{title:s,children:r||null})}const Pk=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],w8=["","image","pdf","table","text","code","audio","video","archive","file"];function y8({hash:e,timezone:t,navigate:s,agents:r}){var U;const i=q_(e),a=(i==null?void 0:i.artifactId)??null,l=(i==null?void 0:i.filters.origin)??"",o=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,h]=d.useState(c);d.useEffect(()=>{h(c)},[c]);const f=(A,P=!1)=>s(du(a,{q:c,origin:l,family:o,...A}),P);d.useEffect(()=>{if(u===c)return;const A=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(A)},[u]);const[m,p]=d.useState(null),[g,x]=d.useState(null),[b,j]=d.useState(null),[v,w]=d.useState(!1),[y,N]=d.useState(!1),k=A=>{var P;return A?((P=r.find(D=>D.id===A))==null?void 0:P.name)??A:""},S=d.useRef(0);d.useEffect(()=>{const A=++S.current;p(null),x(null),w(!1),j(null),E.library({...c?{q:c}:{},...l?{origin:l}:{},...o?{family:o}:{}}).then(P=>{S.current===A&&(p(P.entries),x(P.next))}).catch(P=>{S.current===A&&j(P instanceof me?P.message:String(P))})},[c,l,o]);const C=()=>{if(!g||v)return;w(!0);const A=S.current;E.library({...c?{q:c}:{},...l?{origin:l}:{},...o?{family:o}:{},cursor:g}).then(P=>{S.current===A&&(p(D=>{const O=new Set((D??[]).map(M=>M.id));return[...D??[],...P.entries.filter(M=>!O.has(M.id))]}),x(P.next))}).catch(P=>{S.current===A&&j(P instanceof me?P.message:String(P))}).finally(()=>{S.current===A&&w(!1)})},$=(l?1:0)+(o?1:0),R=((U=Pk.find(A=>A.id===l))==null?void 0:U.label)??l,I=n.jsxs(n.Fragment,{children:[m===null?n.jsx(xe,{children:"Loading…"}):m.length===0?n.jsx(xe,{children:"No file matches that."}):n.jsx(dt,{children:m.map(A=>n.jsx(TE,{href:du(A.id,{q:c,origin:l,family:o}),current:A.id===a,onClick:()=>s(du(A.id,{q:c,origin:l,family:o})),lead:n.jsx("span",{className:"files-row-visual","data-family":A.family,children:A.family==="image"&&!A.deleted?n.jsx("img",{src:Fr(A.id),alt:"",loading:"lazy"}):n.jsx(hj,{family:A.family})}),title:A.filename??"Untitled file",meta:n.jsx("span",{title:et(A.createdAt,t),children:Oe(A.createdAt)}),sub:`${Vi[A.family]} · ${Fn(A.sizeBytes)} · ${BA(A,k)}${b8(A,k)}`},A.id))}),g?n.jsx("div",{className:"files-more",children:n.jsx(T,{size:"sm",onClick:C,disabled:v,children:v?"Loading…":"Show more"})}):null]}),z=m!==null&&m.length===0&&!c&&!l&&!o&&!u;return n.jsxs("div",{className:"ui-page files","data-selected":a?"true":void 0,children:[n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Files"}),n.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),z?n.jsx(jn,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):n.jsxs(n.Fragment,{children:[n.jsx(IE,{label:"Files",onSubmit:()=>f({q:u},!0),main:n.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:A=>h(A.target.value)}),filters:n.jsxs(Os,{dense:!0,children:[n.jsx(ie,{label:"Origin",children:n.jsx("select",{value:l,"aria-label":"Origin",onChange:A=>f({origin:A.target.value}),children:Pk.map(A=>n.jsx("option",{value:A.id,children:A.label},A.id))})}),n.jsx(ie,{label:"Kind",children:n.jsx("select",{value:o,"aria-label":"Kind",onChange:A=>f({family:A.target.value}),children:w8.map(A=>n.jsx("option",{value:A,children:A===""?"Any kind":Vi[A]},A))})})]}),filtersOpen:y,onToggleFilters:()=>N(A=>!A),active:$,chips:$>0?n.jsxs(n.Fragment,{children:[l?n.jsx(Md,{label:"Origin",onRemove:()=>f({origin:""}),children:R}):null,o?n.jsx(Md,{label:"Kind",onRemove:()=>f({family:""}),children:Vi[o]}):null]}):void 0}),n.jsx(ae,{message:b}),n.jsx(RE,{className:"files-split",label:"Files",list:I,detail:a?n.jsx(k8,{id:a,timezone:t,agents:r,navigate:s,onBack:()=>s(du(null,{q:c,origin:l,family:o}))},a):void 0,empty:"Choose a file to see it here."})]})]})}function b8(e,t){var i,a;const s=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(a=e.context)!=null&&a.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[s,r].filter(Boolean).map(l=>` · ${l}`).join("")}function BA(e,t){return e.origin==="uploaded"?"You sent it":e.origin==="produced"?`Made by ${t(e.agentId)||"an agent"}`:e.agentId?`Saved by ${t(e.agentId)}`:"Origin unknown"}function k8({id:e,timezone:t,agents:s,navigate:r,onBack:i}){const[a,l]=d.useState(null),[o,c]=d.useState(!1),[u,h]=d.useState(null);d.useEffect(()=>{let v=!1;return l(null),h(null),E.libraryEntry(e).then(w=>{v||l(w)}).catch(w=>{v||h(w instanceof me&&w.status===404?"This file is no longer in the library.":w instanceof me?w.message:String(w))}),()=>{v=!0}},[e]);const f=v=>{var w;return v?((w=s.find(y=>y.id===v))==null?void 0:w.name)??v:""};if(u)return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(T,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsx(V,{tone:"critical",children:u})]});if(!a)return n.jsx("div",{className:"files-detail-body",children:n.jsx(xe,{children:"Loading…"})});const{entry:m,contexts:p,contextsTotal:g,available:x}=a,b=m.filename??"Untitled file",j=()=>{c(!0),E.libraryEntry(e,p.length).then(v=>l(w=>w&&{...w,contexts:[...w.contexts,...v.contexts],contextsTotal:v.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return n.jsxs("div",{className:"files-detail-body",children:[n.jsx(T,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),n.jsxs("header",{className:"files-detail-head",children:[n.jsx("span",{className:"files-detail-mark","data-family":m.family,"aria-hidden":"true",children:n.jsx(hj,{family:m.family})}),n.jsxs("div",{className:"files-detail-text",children:[n.jsx("h3",{className:"files-detail-name",children:b}),n.jsxs("p",{className:"files-detail-meta",children:[Vi[m.family]," · ",Fn(m.sizeBytes)," · ",et(m.createdAt,t)]})]}),x?n.jsx("a",{className:"ui-btn","data-variant":"accent",href:vi(m.id),download:b,children:"Download"}):null]}),x?null:n.jsx(V,{tone:"warning",children:"The file's bytes are no longer on this machine. What is known about it stays here; the download will not work."}),n.jsx(XE,{artifactId:m.id,filename:m.filename,mime:m.mime,family:m.family,available:x}),n.jsx(Wt,{items:[{label:"Origin",value:BA(m,f)},...m.agentId&&m.origin==="produced"?[{label:"Made by",value:n.jsxs("span",{className:"files-agent",children:[n.jsx(gn,{agents:s,id:m.agentId,size:"sm"}),f(m.agentId)]})}]:[],{label:"Type",value:n.jsx("span",{className:"mono",children:m.mime})},{label:"Id",value:n.jsx("span",{className:"mono",children:m.id})}]}),n.jsxs("section",{className:"files-conversations",children:[n.jsx("h4",{className:"ui-section-title",children:"Conversations"}),p.length===0?n.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):n.jsx("ul",{className:"files-ctx",role:"list",children:p.map(v=>{const w=v.groupId?Oi(v.groupId,v.conversationId):at(v.conversationAgentId,v.conversationId),y=v.groupId?v.groupName??"a group":f(v.conversationAgentId);return n.jsxs("li",{className:"files-ctx-row",children:[n.jsxs("span",{className:"files-ctx-text",children:[n.jsx("span",{children:v.groupId?`Group: ${y}`:y}),n.jsxs("span",{className:"muted",children:[" · ",v.kind==="produced"?`made by ${f(v.agentId)||"an agent"}`:v.kind==="reused"?"sent again":"sent by you"," · ",Oe(v.at)]})]}),n.jsx("a",{className:"ui-btn","data-size":"sm",href:w,onClick:N=>{N.preventDefault(),r(w)},children:"Open conversation"})]},`${v.conversationId}:${v.kind}`)})}),p.length<g?n.jsx(le,{align:"end",children:n.jsx(T,{size:"sm",onClick:j,disabled:o,children:o?"Loading…":`Show ${g-p.length} more`})}):null]})]})}const N8={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe",sun:"sun",cloud:"cloud"};function WA(e){return e&&N8[e]||"plug"}const HA="buddi.keepClose";let ol=null;const Fg=new Set;function zg(){for(const e of Fg)e()}typeof window<"u"&&(window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),ol=e,zg()}),window.addEventListener("appinstalled",()=>{ol=null,Rj(),zg()}));function Jh(){const[e,t]=d.useState(ol);return d.useEffect(()=>{const s=()=>t(ol);return Fg.add(s),s(),()=>{Fg.delete(s)}},[]),KA()?null:e}async function Tj(e){try{await e.prompt();const t=await e.userChoice;ol===e&&(ol=null);const s=(t==null?void 0:t.outcome)==="accepted";return s&&Rj(),zg(),s}catch{return!1}}function S8(){try{return window.localStorage.getItem(HA)!==null}catch{return!1}}function Rj(){try{window.localStorage.setItem(HA,"dismissed")}catch{}}function KA(){var e;try{return((e=window.matchMedia)==null?void 0:e.call(window,"(display-mode: standalone)").matches)??!1}catch{return!1}}function C8(e=window.location.hostname){const t=e.replace(/^\[|\]$/g,"").toLowerCase();return t==="127.0.0.1"||t==="::1"||t==="localhost"}function VA(e){return/Edg\//.test(e)?"In Edge, choose Apps → Install buddi from the … menu.":/(Chrome|CriOS)\//.test(e)?"In Chrome, click the install icon in the address bar.":/Safari\//.test(e)&&/Mac/.test(e)?"In Safari, choose File → Add to Dock.":null}function E8(e){return/Mac|iPhone|iPad/.test(e)}function A8(){const e=Jh(),[t,s]=d.useState(S8);if(t||!e)return null;const r=()=>{Rj(),s(!0)};return n.jsxs("div",{className:"home-install",role:"region","aria-label":"Install buddi",children:[n.jsx("p",{className:"home-install-text",children:"Install buddi as an app, one click from your dock."}),n.jsxs(le,{align:"end",children:[n.jsx(T,{size:"sm",variant:"ghost",onClick:r,children:"Not now"}),n.jsx(T,{size:"sm",variant:"accent",onClick:()=>{Tj(e).then(i=>{i&&s(!0)})},children:"Install"})]})]})}function T8(){const e=Jh(),[t,s]=d.useState(void 0),[r]=d.useState(KA);if(d.useEffect(()=>{if(r)return;let o=!0;return E.session().then(c=>{o&&s(c.platform)},()=>{}),()=>{o=!1}},[r]),r)return null;const i=typeof navigator>"u"?"":navigator.userAgent,a=C8(),l=e?null:VA(i);return n.jsx(oe,{title:"The dashboard as an app",panel:!0,foot:e?n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",onClick:()=>{Tj(e)},children:"Install the app"})}):void 0,children:n.jsxs(re,{children:[n.jsxs("p",{children:[e?"This browser can install buddi as an app: its own window, the Blob as its icon. ":l?`${l} `:null,"Or bookmark it with ",E8(i)?"⌘D":"Ctrl+D",".",a?null:" This tailnet address installs as its own app, separate from the one on the machine buddi runs on."]}),a&&t==="darwin"?n.jsxs("p",{children:["On this Mac, ",n.jsx("span",{className:"mono",children:"buddi dashboard --install-app"})," puts a double-clickable app in ~/Applications that signs you in each time it opens (docs/cli.md, under Everyday)."]}):null]})})}const R8=""+new URL("earth-2560-Ce3xs8Cb.webp",import.meta.url).href,$8=""+new URL("earth-phone-BqC7cDhk.webp",import.meta.url).href,I8="data:image/webp;base64,UklGRloGAABXRUJQVlA4IE4GAADQKgCdASrAAJAAPpVInUolpKmtqTe6EbASiUdvknkVpMHex+cfn6FpYp/9uZP+p3tPRfzQ/Vd/Sej/8/++pP8bkmkrujVcbfosAWVvo98GPJDgcpdpkar6crJ+OUcccXvyduwiVqZIt11sMX//3JP2wugWcHYMSjhNfw/YXfPBz7/+f4KsYSTyT6uayU6+fROo0TO6X4IyHrF+l6toP//txS0FMPUdRtJ6p+KCT2dP3gpLomT/wObriNY+VMOA0Zv+Tv48yM6/mEHjtXwfON8gBTL8RqQm7vROt+4EPvqHCsf6f1vUb+PxZm8Y0/H4GI68rdhftV4yy/CoatiRgTrzW8ekWPCSt9eJvusnrXMcJruQHwSz5/vX9vG8C1y5aeF5l34kChCD3TSgQUw9kBS9sQ1NbMi1pMKuJqUEgiZd/2y+wAjF/DOKI3FZHBa5Q2qCooTfUj9A0XCixL3kuiAA/vqtztWnhuK0AAUKVrOx4/8K6IntNvzYOatrdU3xfr4QYYAHyIAAE90qDuxwvNSaslOgj1XzeQ7o4CiG+WFb4zwdPY6lyVxnN49hB6ipRsqQgAGt1TM/WHRmZXsFqcgHgXvLRO/p+gY76bpHJq4QeDFM3Q6tVUsq12eA8xdt9XMl/j2W0PHmipASSSIaS5KLMTjz4jtZfUwqTOj0emDBJw60TFqwI7jSvw3mbEwxxbojRIHLx6DfSdsFdhjJvJMS7fn0N+lA61ZOdS0OwUdd69Dt/YuIccchkuSR0QX9woaHISeHgXHlRAF2XLwciGQqbLIy9BogJ/4g+AKroStuCVhcYugjGC2gxUtl2UrwpIDcHI1ccHnGLv68wJ5AAfOSAKcV1RtS2UUbfSRLCnU6xoa6KmV/rAxptF6OJf8GfEOtKNwm6VddtwyPoa9muhJGhR/j6ruJ/kFnMRNLH7WcXtQIhNlVo8xRvRaoH9RGwIfvhwAigF4zejYm1wAynQhgR7ecE/15lbKTsTBb8Y9fEc9zNmZZgMzlto8cNZj+0+k1TTQ0wmrRktZ299Sqko1Ov4yDQRP0iKSe/g8XpiHowGqR5N0lsvJeEojijafpSRp0k3G59maRyl+1LsIb5YW8WfgFHbtRtYszt39yl7EPwLfsYwXOWqPwg0IVemW8v5CMln54J4c9m95OIxJHYL7cQTzWyrY8qgaxhR5vtr+NJyiQTlKN31r1xeJhCmJZKtY9OIGzesGUOdmetfh1jmfh5YtwdxOG900hLMD4vv1jYXAng8YZpjDTRUcuUrlYiO+BtcbnuIUA9SVRzFAdwReo1Rry/Sm7lNWjORAVT0B4dXzkfjv/+SykUdSAYx2evoGEJeUFqXPQt16XiwAduftyvFBUlNVwP8bZv+Hg3wueDwbUZYgaHM2qC7CJdIdf4uB9elmZViV9gssG5C8+Vk1BCJoqMasH9cFJcYjqlpDSWtZ5XcTreCV+dBwxHKh/IfqUOmZWnvYIE6xQ0YlVMc2CZuriPdRDQEoKjgMZ67X1f7XsanRDwL3attVpj5zWBRiXYdoGzt/O4w9zk/qCWUbZyy7ik+prantqxCiKAbRE7jZhTXFGprni/fldU5v5vRozeswfGCVXQzQpmjEMJA5uV4eB1w0ooNYM+ZV9yo/rqYIfhQHnzn3N7N44UBzZl6EI7806lpMMDZMk2Vd7aTc7dapectSczJ1D9mZ0MKvd0Skg1Euq1uGwQNEu1ANTFFUYIOmREj8d3vYHkWlhmuiTLKbQxl4CgDYk4vH6kA9iGe43Mo5BF4WoiQ6OqRJTxel29R6Yc/FWmw/enfMaPdyWgKnVSn6TSLoPcgJ6lu1pd39McpTo92Aw0czVjUXTcdSL3c38q4YyOdJkv6sw+FeXr/DOXP3S3xXjo7SMXD2UED68pQEVkjf4SaSqWUarBkeacGOlssJDsoVFm46XleiI+Ug9j+hAVyLDPKsLDo+8qrFgcEexTGjmonZnow0nKD80SpF+KbZD78vfc4MJN2F5ZhWC+mDVgv6Bj8kTD6MGV+6YllFA/AdnvTw+idzBKLNTYe7PEcq2AWNOAog/43qtjJQbAdxGkS8KewzmlpTP4KIuDoynjBuqv9Y6PR+nv2IZpWyNvqTUkqiFJnCQI/XKogTppN/pcEAOJ+XFqAA=",Ug={desk:R8,phone:$8,thumb:I8},wm={author:"ActionVance",authorUrl:"https://unsplash.com/@actionvance",photoUrl:"https://unsplash.com/photos/outer-space-photography-of-earth-t7EL2iG3jMc"};function P8(e){return e?Ug.phone:Ug.desk}function GA(){const[e,t]=d.useState(()=>new Date);return d.useEffect(()=>{let s;const r=()=>{s=setTimeout(()=>{t(new Date),r()},6e4-Date.now()%6e4+50)};return r(),()=>clearTimeout(s)},[]),e}const M8=3,YA=8e3,D8={hiddenHere:new Set,restoredHere:new Set};function O8(e,t){return t.hiddenHere.has(e.id)?!0:e.hidden&&!t.restoredHere.has(e.id)}function L8(e,t=D8){return(e??[]).filter(s=>!O8(s,t)).slice(0,M8)}function qA(e){const[t,s]=d.useState(new Set),[r,i]=d.useState(new Set),[a,l]=d.useState(null),o=d.useRef(e);o.current=e;const c=(m,p)=>new Set(m).add(p),u=(m,p)=>{const g=new Set(m);return g.delete(p),g};return d.useEffect(()=>{if(!a)return;const m=window.setTimeout(()=>l(null),YA);return()=>window.clearTimeout(m)},[a]),{hiddenHere:t,restoredHere:r,justHidden:a,hide:(m,p)=>{s(g=>c(g,m.id)),i(g=>u(g,m.id)),l({glance:m,spot:p}),E.setGlanceHidden(m.id,!0).then(()=>{var g;return(g=o.current)==null?void 0:g.call(o)},()=>{s(g=>u(g,m.id)),l(g=>(g==null?void 0:g.glance.id)===m.id?null:g)})},undo:()=>{if(!a)return;const{glance:m}=a;l(null),s(p=>u(p,m.id)),i(p=>c(p,m.id)),E.setGlanceHidden(m.id,!1).then(()=>{var p;return(p=o.current)==null?void 0:p.call(o)},()=>{i(p=>u(p,m.id)),s(p=>c(p,m.id))})}}}function _8({hiding:e,spot:t}){const s=e.justHidden;return!s||s.spot!==t?null:n.jsxs("span",{className:"home-glance-undo",role:"status","aria-live":"polite","data-spot":t,children:[n.jsxs("span",{children:[s.glance.title," hidden"]}),n.jsx("span",{className:"home-glance-sep","aria-hidden":"true",children:"·"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:e.undo,children:"Undo"})]})}function F8(e){return e.link?uj(e.link.plugin,e.link.page,e.link.place):null}function z8({glances:e,navigate:t,onChanged:s,except:r,hiding:i}){var u,h;const a=qA(s),l=i??a,o=L8(e,l).filter(f=>!(r!=null&&r.has(f.id))),c=n.jsx(_8,{hiding:l,spot:"line"});return o.length===0&&((u=l.justHidden)==null?void 0:u.spot)!=="line"?null:n.jsxs("span",{className:"home-glances",children:[((h=l.justHidden)==null?void 0:h.spot)==="line"?n.jsxs("span",{className:"home-glance",children:[n.jsx("span",{className:"home-glance-sep","aria-hidden":"true",children:"·"}),c]}):null,o.map(f=>{const m=F8(f),p=n.jsxs(n.Fragment,{children:[n.jsx(ue,{name:Al(f.icon),size:14}),n.jsx("span",{children:f.text})]});return n.jsxs("span",{className:"home-glance",children:[n.jsx("span",{className:"home-glance-sep","aria-hidden":"true",children:"·"}),m?n.jsx("a",{className:"home-glance-text",href:m,onClick:g=>{g.preventDefault(),t(m)},children:p}):n.jsx("span",{className:"home-glance-text",children:p}),n.jsx("button",{type:"button",className:"home-glance-hide","aria-label":`Hide ${f.title} from Home`,title:"Hide from Home",onClick:()=>l.hide(f,"line"),children:n.jsx(ue,{name:"close",size:10})})]},f.id)})]})}function U8(e){const i=Math.min(...e),l=Math.max(...e)-i||1,o=Math.max(e.length-1,1);return e.map((c,u)=>[u/o*100,2+(1-(c-i)/l)*(24-2*2)])}function B8({points:e,className:t="wg-spark"}){const s=U8(e).map(([r,i])=>`${r.toFixed(1)},${i.toFixed(1)}`);return n.jsxs("svg",{className:t,viewBox:"0 0 100 24",preserveAspectRatio:"none","aria-hidden":"true","data-testid":"spark",children:[n.jsx("path",{d:`M0,24 L${s.join(" L")} L100,24 Z`,fill:"currentColor",opacity:"0.12",stroke:"none"}),n.jsx("polyline",{points:s.join(" "),fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})}const W8={small:2,medium:4},Mk=new Map;function H8(e){let t=Mk.get(e);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}),Mk.set(e,t)),t}function Dk(e,t){const s=Object.fromEntries(H8(t).formatToParts(e).map(l=>[l.type,l.value])),r=Number(s.hour)%24,i=Number(s.minute),a=Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),r,i);return{date:`${s.year}-${s.month}-${s.day}`,h:r,m:i,s:Number(s.second),offset:Math.round((a-Math.floor(e.getTime()/6e4)*6e4)/6e4)}}function K8(e){if(e===0)return"Same time";const t=Math.floor(Math.abs(e)/60),s=Math.abs(e)%60;return`${e>0?"+":"−"}${t===0?`${s} min`:s===0?`${t} h`:`${t} h ${s}`}`}function V8(e){if(e===0)return"same time";const t=Math.floor(Math.abs(e)/60),s=Math.abs(e)%60;return`${[t?`${t} hour${t===1?"":"s"}`:"",s?`${s} minute${s===1?"":"s"}`:""].filter(Boolean).join(" ")} ${e>0?"ahead":"behind"}`}function G8(e,t,s,r,i){const a=Dk(e,t.zone),l=Dk(e,s),o=a.date===l.date?"Today":a.date>l.date?"Tomorrow":"Yesterday",c=a.offset-l.offset,u=jc(i?{timeFormat:i}:{},()=>Ht(e,t.zone)),h=r?"your time":V8(c);return{...a,day:o,daytime:a.h>=6&&a.h<18,offsetText:r?"Here":K8(c),time:u,label:`${t.label}, ${u}${o==="Today"?"":` ${o.toLowerCase()}`}, ${h}`}}function Y8(e,t){const s=t?e.s:0;return{hour:(e.h%12+e.m/60+s/3600)*30,minute:(e.m+s/60)*6,second:t?e.s*6:null}}function q8(e){const[t,s]=d.useState(()=>new Date);return d.useEffect(()=>{const r=e?1e3:6e4;let i;const a=()=>{i=setTimeout(()=>{s(new Date),a()},r-Date.now()%r+5)};return s(new Date),a(),()=>clearTimeout(i)},[e]),t}function Ok({angle:e,length:t,width:s}){return n.jsxs("g",{className:"wg-clock-hand",transform:`rotate(${e} 50 50)`,children:[n.jsx("line",{x1:"50",y1:"50",x2:"50",y2:"42",strokeWidth:Math.min(s,1.8)}),n.jsx("line",{x1:"50",y1:"42",x2:"50",y2:50-t,strokeWidth:s})]})}const Q8=Array.from({length:12},(e,t)=>t);function X8({time:e,seconds:t}){const s=Y8(e,t);return n.jsxs("svg",{className:"wg-clock-face",viewBox:"0 0 100 100","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{className:"wg-clock-dial",cx:"50",cy:"50",r:"49.25"}),Q8.map(r=>n.jsx("line",{className:"wg-clock-tick","data-major":r%3===0?"true":void 0,x1:"50",y1:r%3===0?6.5:7.5,x2:"50",y2:r%3===0?14:12,transform:`rotate(${r*30} 50 50)`},r)),n.jsx(Ok,{angle:s.hour,length:24,width:4.6}),n.jsx(Ok,{angle:s.minute,length:37,width:3.4}),s.second===null?null:n.jsx("g",{className:"wg-clock-second","data-testid":"second-hand",transform:`rotate(${s.second} 50 50)`,children:n.jsx("line",{x1:"50",y1:"59",x2:"50",y2:"9"})}),n.jsx("circle",{className:"wg-clock-pin",cx:"50",cy:"50",r:"2.8"}),s.second===null?null:n.jsx("circle",{className:"wg-clock-pin-second",cx:"50",cy:"50",r:"1.5"})]})}function J8({body:e,size:t}){const s=Ps("(prefers-reduced-motion: reduce)"),r=q8(!s),i=e.clocks.slice(0,W8[t]);return n.jsx("div",{className:"wg-clocks","data-count":i.length,children:i.map((a,l)=>{let o;try{o=G8(r,a,e.home,l===0&&a.zone===e.home,e.time)}catch{return null}return n.jsxs("div",{className:"wg-clock","data-night":o.daytime?void 0:"true",role:"img","aria-label":o.label,title:`${a.label} · ${o.time}`,children:[n.jsx(X8,{time:o,seconds:!s}),n.jsxs("span",{className:"wg-clock-words","aria-hidden":"true",children:[n.jsx("span",{className:"wg-clock-city",children:a.label}),n.jsx("span",{className:"wg-clock-day","data-today":o.day==="Today"?"true":void 0,children:o.day}),n.jsx("span",{className:"wg-clock-off",children:o.offsetText})]})]},`${a.label}-${a.zone}`)})})}const Z8=3,eW={small:4,medium:6};function ym({icon:e,size:t}){return e?n.jsx("span",{className:"wg-icon",children:n.jsx(ue,{name:Al(e),size:t})}):null}function $j({body:e,size:t}){switch(e.kind){case"stat":return n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"wg-stat-now",children:[n.jsx(ym,{icon:e.icon,size:24}),n.jsx("span",{className:"wg-value",children:e.value})]}),e.caption?n.jsx("span",{className:"wg-caption",children:e.caption}):null,n.jsx("span",{className:"wg-push"}),e.trend?n.jsxs("span",{className:"wg-trend",children:[n.jsx(B8,{points:e.trend.points,className:"wg-spark"}),e.trend.label?n.jsx("span",{children:e.trend.label}):null]}):null,e.foot?n.jsx("span",{className:"wg-foot",children:e.foot}):null]});case"list":return n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"wg-list",children:e.rows.slice(0,Z8).map((s,r)=>n.jsxs("li",{className:"wg-row",children:[n.jsxs("span",{className:"wg-row-text",children:[n.jsx("span",{className:"wg-row-title",children:s.title}),s.sub&&t==="medium"?n.jsx("span",{className:"wg-row-sub",children:s.sub}):null]}),s.side?n.jsx("span",{className:"wg-row-side","data-tone":s.tone,children:s.side}):null]},`${s.title}-${r}`))}),n.jsx("span",{className:"wg-push"}),e.more?n.jsx("span",{className:"wg-foot",children:e.more}):null]});case"strip":return n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"wg-strip-head",children:[n.jsx(ym,{icon:e.icon,size:20}),e.value?n.jsx("span",{className:"wg-strip-value",children:e.value}):null,e.caption?n.jsx("span",{className:"wg-caption",children:e.caption}):null]}),n.jsx("span",{className:"wg-push"}),n.jsx("span",{className:"wg-strip",children:e.items.slice(0,eW[t]).map((s,r)=>n.jsxs("span",{className:"wg-tile",children:[n.jsx("span",{className:"wg-tile-label",children:s.label}),n.jsx(ym,{icon:s.icon,size:18}),n.jsx("span",{className:"wg-tile-value",children:s.value})]},`${s.label}-${r}`))})]});case"progress":{const s=Math.round(Math.max(0,Math.min(1,e.ratio))*100);return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"wg-value",children:e.value}),e.caption?n.jsx("span",{className:"wg-caption",children:e.caption}):null,n.jsx("span",{className:"wg-push"}),n.jsx("span",{className:"ui-meter",role:"meter","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s,"aria-label":e.caption??e.value,children:n.jsx("span",{className:"ui-meter-fill","data-tone":e.tone,style:{inlineSize:`${s}%`}})}),e.foot?n.jsx("span",{className:"wg-foot",children:e.foot}):null]})}case"clocks":return n.jsx(J8,{body:e,size:t});case"text":return n.jsxs("span",{className:"wg-text",children:[e.icon?n.jsx("span",{className:"wg-text-icon",children:n.jsx(ue,{name:Al(e.icon),size:18})}):null,n.jsxs("span",{className:"wg-text-words",children:[n.jsx("span",{className:"wg-text-main",children:e.text}),e.sub?n.jsx("span",{className:"wg-row-sub",children:e.sub}):null]})]})}}function Bg({label:e,options:t,multiple:s,value:r,onChange:i}){const a=Array.isArray(r)?r:[r],l=c=>a.includes(c),o=c=>{if(!s)return i(c);i(l(c)?a.filter(u=>u!==c):[...a,c])};return n.jsx("div",{className:"wg-options",role:s?"group":"radiogroup","aria-label":e,children:t.map(c=>n.jsxs("button",{type:"button",role:s?"checkbox":"radio","aria-checked":l(c.value),className:"wg-option","data-on":l(c.value)?"true":void 0,onClick:()=>o(c.value),children:[n.jsx("span",{className:"wg-option-mark","data-multiple":s?"true":void 0,"aria-hidden":"true",children:s&&l(c.value)?n.jsx(ue,{name:"check",size:12}):null}),n.jsxs("span",{className:"wg-option-text",children:[n.jsx("span",{className:"wg-option-name",children:c.label}),c.sub?n.jsx("span",{className:"wg-option-sub",children:c.sub}):null]})]},c.value))})}function Lk(e){return"place"in e?e.place:`town:${e.latitude.toFixed(3)},${e.longitude.toFixed(3)}`}function tW(e){var t;return{label:((t=e.name.split(",")[0])==null?void 0:t.trim())||e.name,name:e.name,latitude:e.latitude,longitude:e.longitude,timezone:e.timezone??null}}function nW({field:e,value:t,places:s,onChange:r}){const i=Array.isArray(t)?t:t?[t]:[],[a,l]=d.useState(""),[o,c]=d.useState([]),[u,h]=d.useState(!1),[f,m]=d.useState(null),p=new Map;for(const y of s)p.set(y.id,{value:{place:y.id},label:y.label,sub:y.name});for(const y of[...i,...o])"place"in y||p.set(Lk(y),{value:y,label:y.label,sub:y.name});const g=[...p.entries()].map(([y,N])=>({value:y,label:N.label,sub:N.sub})),x=i.map(Lk),b=s.find(y=>y.id==="home"||y.label.toLowerCase()==="home")??s[0],j=e.multiple?x:x[0]??(b==null?void 0:b.id)??"",v=y=>{const N=(Array.isArray(y)?y:[y]).map(k=>{var S;return(S=p.get(k))==null?void 0:S.value}).filter(k=>!!k);r(e.multiple?N.slice(-3):N[0]??null)},w=()=>{const y=a.trim();y.length<2||(h(!0),m(null),E.findPlace(y).then(({found:N})=>{const k=N.slice(0,3).map(tW);c(k),k.length===0?m(`Nothing found for “${y}”.`):e.multiple?r([...i,k[0]].slice(-3)):r(k[0])}).catch(()=>m("The place finder didn’t answer. Try again in a moment.")).finally(()=>h(!1)))};return n.jsxs("div",{className:"wg-field-stack",children:[g.length>0?n.jsx(Bg,{label:e.label,options:g,multiple:e.multiple,value:j,onChange:v}):null,n.jsxs("div",{className:"wg-find",children:[n.jsx("input",{value:a,placeholder:"Find a town: Tokyo","aria-label":`Find a town for ${e.label}`,onChange:y=>l(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),w())}}),n.jsx(T,{size:"sm",disabled:u||a.trim().length<2,onClick:w,children:u?"Finding…":"Find"})]}),f?n.jsx("span",{className:"ui-field-hint",children:f}):null]})}function sW({field:e,value:t,sheet:s,onChange:r}){var a;let i;switch(e.kind){case"select":{const l=e.options??[],o=typeof t=="string"?t:e.default??((a=l[0])==null?void 0:a.value)??"",c=l.length>0&&l.length<=3&&l.every(u=>u.label.length<=14);i=l.length===0?n.jsx("span",{className:"ui-field-hint",children:"Nothing to choose from yet."}):c?n.jsx(rn,{label:e.label,options:l,value:o,onChange:r}):n.jsx(Bg,{label:e.label,options:l,value:o,onChange:r});break}case"multiselect":{const l=e.options??[];i=l.length===0?n.jsx("span",{className:"ui-field-hint",children:"Nothing to choose from yet."}):n.jsx(Bg,{label:e.label,options:l,multiple:!0,value:Array.isArray(t)?t:e.default??[],onChange:r});break}case"toggle":return n.jsxs("div",{className:"wg-field",children:[n.jsxs("label",{className:"wg-toggle",children:[n.jsx("input",{type:"checkbox",checked:typeof t=="boolean"?t:e.default??!1,onChange:l=>r(l.target.checked)}),n.jsx("span",{children:e.label})]}),e.hint?n.jsx("span",{className:"ui-field-hint",children:e.hint}):null]});case"text":i=n.jsx("input",{"aria-label":e.label,value:typeof t=="string"?t:e.default??"",maxLength:e.max??60,placeholder:e.placeholder,onChange:l=>r(l.target.value)});break;case"place":i=n.jsx(nW,{field:e,value:t,places:s.places,onChange:r});break;case"timeFormat":i=n.jsx(rn,{label:e.label,options:[{value:"profile",label:QC()},{value:"12h",label:"12-hour"},{value:"24h",label:"24-hour"}],value:t==="12h"||t==="24h"?t:"profile",onChange:r});break}return n.jsxs("div",{className:"wg-field",role:"group","aria-label":e.label,children:[n.jsx("span",{className:"wg-field-label",children:e.label}),i,e.hint?n.jsx("span",{className:"ui-field-hint",children:e.hint}):null]})}function rW({info:e,placement:t,surface:s,view:r,label:i}){var u;const a=s==="lock",l=((u=r==null?void 0:r.body)==null?void 0:u.kind)==="text",o=a&&(l||t.size==="small")?"small":t.size,c=r?r.body?e.sensitive?n.jsxs("span",{className:"wg-state",children:[n.jsx("span",{className:"wg-mask","aria-hidden":"true",children:"••••"}),n.jsx("span",{className:"wg-state-sub",children:"Hidden on this screen."})]}):n.jsx($j,{body:r.body,size:o}):n.jsx("span",{className:"wg-state",children:n.jsx("span",{className:"wg-state-sub",children:r.state==="error"?`Couldn't load this${r.error?`: ${r.error}`:""}.`:"Nothing to show right now."})}):n.jsxs("span",{className:"wg-skel-body","aria-hidden":"true",children:[n.jsx("span",{className:"wg-skel","data-w":"half"}),n.jsx("span",{className:"wg-skel","data-w":"third"}),n.jsx("span",{className:"wg-push"}),n.jsx("span",{className:"wg-skel"})]});return n.jsx("div",{className:"wg-preview","data-surface":s,"aria-label":`Preview of ${i}`,role:"img",children:n.jsxs("div",{className:"wg-frame","data-size":o,"data-variant":a?"compact":void 0,"data-kind":r!=null&&r.body&&!e.sensitive?r.body.kind:void 0,"aria-hidden":"true",children:[a?null:n.jsx("div",{className:"wg-head",children:n.jsx("span",{className:"wg-title",children:i})}),n.jsx("div",{className:"wg-body",children:c}),a?n.jsx("span",{className:"wg-compact-title",children:i}):null]})})}function QA({info:e,placement:t,surface:s,onSave:r,onRemove:i,onClose:a}){const l=ce(()=>E.widgetSettings(e.id),[e.id]),[o,c]=d.useState(t.settings??{}),[u,h]=d.useState(null),[f,m]=d.useState(t.label??e.title),[p,g]=d.useState(!1),[x,b]=d.useState(null),j=d.useRef(0),v=d.useMemo(()=>JSON.stringify(o),[o]);d.useEffect(()=>{const N=++j.current,k=window.setTimeout(()=>{E.previewWidget({widget:e.id,size:t.size,settings:o}).then(S=>{N===j.current&&(h(S.view),m(S.label))}).catch(()=>{N===j.current&&h({state:"error",error:"the preview could not be made"})})},u?250:0);return()=>window.clearTimeout(k)},[v,e.id,t.size]);const w=()=>{g(!0),b(null),r(o).then(N=>{g(!1),N||b("Couldn’t keep these settings. Try again.")})},y=s==="lock"?"the lock screen":"Home";return n.jsx(ht,{title:f,onClose:a,foot:n.jsxs(le,{children:[n.jsxs(T,{variant:"danger-ghost",onClick:i,children:["Remove from ",s==="lock"?"lock screen":"Home"]}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",onClick:a,children:"Cancel"}),n.jsx(T,{variant:"accent",onClick:w,disabled:p||!l.data,children:p?"Saving…":"Save"})]}),children:n.jsxs("div",{className:"wg-sheet",children:[n.jsx(rW,{info:e,placement:t,surface:s,view:u,label:f}),n.jsxs("p",{className:"wg-sheet-note",children:[e.builtIn?"Built in":`From the ${e.plugin} plugin`," · on ",y,". These settings are this one’s own",s==="lock"?"; Home keeps its own":"","."]}),n.jsx(ae,{message:x??(l.error?"Couldn’t read this widget’s settings.":null)}),l.data?l.data.fields.map(N=>n.jsx(sW,{field:N,value:o[N.key],sheet:l.data,onChange:k=>c({...o,[N.key]:k})},N.key)):l.error?null:n.jsx("p",{className:"wg-sheet-note","aria-busy":"true",children:"Reading its choices…"})]})})}const iW=6e4,XA="buddi.clock",JA="buddi.home.widgets";function aW(){try{const e=Number(window.localStorage.getItem(JA));return Number.isInteger(e)&&e>0?Math.min(e,6):0}catch{return 0}}function lW(e){try{window.localStorage.setItem(JA,String(e))}catch{}}function ZA(){const e=new Uint8Array(4);return crypto.getRandomValues(e),`w-${Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}`}function eT(e,t){const s=d.useRef(t);s.current=t,d.useEffect(()=>{if(!e)return;let r;const i=()=>{r=setTimeout(()=>{s.current(),i()},6e4-Date.now()%6e4+1e3)};return i(),()=>clearTimeout(r)},[e])}function oW(){const e=ce(()=>E.widgets("home"),[],iW),[t,s]=d.useState(void 0);return d.useEffect(()=>{e.data&&s(e.data)},[e.data]),d.useEffect(()=>{t&&lW(t.home.length)},[t]),eT((t==null?void 0:t.home.some(r=>{var i,a;return r.widget===XA&&((a=(i=t.views[r.key])==null?void 0:i.body)==null?void 0:a.kind)!=="clocks"}))??!1,e.reload),{answer:t,error:e.error,apply:s,reload:e.reload}}function cW(e){return new Set(((e==null?void 0:e.home)??[]).map(t=>t.widget))}function uW(e){const[t,s]=d.useState(!1);return d.useEffect(()=>{if(!e||!t)return;const r=()=>{(document.visibilityState==="hidden"||!document.hasFocus())&&s(!1)};return document.addEventListener("visibilitychange",r),window.addEventListener("blur",r),()=>{document.removeEventListener("visibilitychange",r),window.removeEventListener("blur",r)}},[e,t]),[t,s]}const tT=(e,t)=>e.label??(t==null?void 0:t.title)??e.widget;function dW({info:e,placement:t,view:s,index:r,count:i,editing:a,navigate:l,act:o,onRetry:c,retrying:u,drag:h}){var S;const[f,m]=uW(e.sensitive===!0),p=(s==null?void 0:s.state)??"error",g=e.sensitive===!0&&!f,x=e.link?uj(e.link.plugin,e.link.page,e.link.place):null,b=x!==null&&!a&&p!=="error"&&!g,j=t.size==="small"?"medium":"small",v=tT(t,e),w=t.key,y=(((S=e.settings)==null?void 0:S.length)??0)>0;let N;!s&&a?N=n.jsx("span",{className:"wg-state",children:n.jsx("span",{className:"wg-state-sub",children:"Fills in when you press Done."})}):p==="error"||!s?N=n.jsxs("span",{className:"wg-state",children:[n.jsx("span",{className:"wg-state-title",children:"Couldn't load this."}),s!=null&&s.error?n.jsxs("span",{className:"wg-state-sub",children:[hW(s.error),"."]}):null,a?null:n.jsx(T,{size:"sm",onClick:c,disabled:u,children:u?"Trying…":"Try again"})]}):p==="empty"||!s.body?N=n.jsx("span",{className:"wg-state",children:n.jsx("span",{className:"wg-state-sub",children:"Nothing to show right now."})}):g?N=n.jsxs("span",{className:"wg-state",children:[n.jsx("span",{className:"wg-mask","aria-hidden":"true",children:"••••"}),n.jsx("span",{className:"wg-state-sub",children:"Hidden on this screen."}),a?null:n.jsx(T,{size:"sm",onClick:()=>m(!0),children:"Show"})]}):N=n.jsx($j,{body:s.body,size:t.size});const k=C=>{C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",w),h.start(w)};return n.jsxs("div",{className:"wg-frame",role:"group","aria-label":v,"data-id":e.id,"data-key":w,"data-size":t.size,"data-kind":s!=null&&s.body&&!g&&p!=="error"?s.body.kind:void 0,"data-state":p==="ok"?void 0:p,"data-linked":b?"true":void 0,"data-dragging":h.dragging===w?"true":void 0,"data-over":h.over===w&&h.dragging!==w?"true":void 0,draggable:a?!0:void 0,onDragStart:a?k:void 0,onDragOver:a?C=>{h.dragging&&(C.preventDefault(),h.enter(w))}:void 0,onDrop:a?C=>{C.preventDefault(),h.drop(w)}:void 0,onDragEnd:a?()=>h.end():void 0,children:[n.jsxs("div",{className:"wg-head",children:[a?n.jsx("button",{type:"button",className:"ui-icon-btn wg-grip","data-size":"sm","data-grip":w,"aria-label":`Move ${v}, position ${r+1} of ${i}: arrow keys`,title:"Drag, or use the arrow keys",onKeyDown:C=>{(C.key==="ArrowLeft"||C.key==="ArrowUp")&&(C.preventDefault(),o("earlier")),(C.key==="ArrowRight"||C.key==="ArrowDown")&&(C.preventDefault(),o("later"))},children:n.jsx(ue,{name:"grip",size:14})}):null,n.jsx("span",{className:"wg-title",children:v}),p==="stale"?n.jsx("span",{className:"wg-stale",title:s!=null&&s.error?`Couldn't refresh: ${s.error}.`:void 0,children:s!=null&&s.updatedAt?`${Ev(s.updatedAt)} old`:"Not current"}):null,a&&y?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Settings for ${v}`,title:"Settings",onClick:()=>o("settings"),children:n.jsx(ue,{name:"settings",size:14})}):null,a?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Take ${v} off Home`,title:"Take off Home",onClick:()=>o("hide"),children:n.jsx(ue,{name:"close",size:12})}):n.jsx("span",{className:"wg-more",children:n.jsx(Cl,{label:`More for ${v}`,note:s!=null&&s.updatedAt?`${e.builtIn?"Built in":e.plugin} · ${Oe(s.updatedAt)}`:e.builtIn?"Built in":e.plugin,items:[y?{label:"Settings…",onSelect:()=>o("settings")}:null,r>0?{label:"Move earlier",onSelect:()=>o("earlier")}:null,r<i-1?{label:"Move later",onSelect:()=>o("later")}:null,e.sizes.includes(j)?{label:`Make it ${j}`,onSelect:()=>o("size",j)}:null,{label:"Edit widgets",onSelect:()=>o("edit")},"separator",{label:"Hide from Home",onSelect:()=>o("hide")}]})})]}),b?n.jsx("a",{className:"wg-body",href:x,onClick:C=>{C.preventDefault(),l(x)},children:N}):n.jsx("div",{className:"wg-body",children:N}),a?n.jsxs("div",{className:"wg-edit-bar",children:[e.sizes.length>1?n.jsx("span",{className:"ui-segment",role:"radiogroup","aria-label":`Size of ${v}`,children:["small","medium"].filter(C=>e.sizes.includes(C)).map(C=>n.jsx("button",{type:"button",className:"ui-tab",role:"radio","aria-checked":t.size===C,onClick:()=>o("size",C),children:C==="small"?"Small":"Medium"},C))}):n.jsx("span",{className:"wg-edit-note",children:e.sizes[0]==="small"?"Small only":"Medium only"}),n.jsxs("span",{className:"wg-edit-move",children:[n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","data-move":`${w}:earlier`,"aria-label":`Move ${v} earlier`,title:"Move earlier",disabled:r===0,onClick:()=>o("earlier"),children:n.jsx(ue,{name:"chevron-left"})}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","data-move":`${w}:later`,"aria-label":`Move ${v} later`,title:"Move later",disabled:r===i-1,onClick:()=>o("later"),children:n.jsx(ue,{name:"chevron-right"})})]})]}):null]})}function hW(e){const t=e.replace(/\.$/,"");return t.charAt(0).toUpperCase()+t.slice(1)}function fW({widgets:e,navigate:t}){const{answer:s,apply:r}=e,[i,a]=d.useState(!1),[l,o]=d.useState([]),[c,u]=d.useState(null),[h,f]=d.useState(""),[m,p]=d.useState(null),[g,x]=d.useState(!1),[b,j]=d.useState(null),[v,w]=d.useState(null),[y,N]=d.useState(null),[k,S]=d.useState(null),[C,$]=d.useState(new Set),[R]=d.useState(aW),I=d.useRef(null);if(d.useEffect(()=>{if(!c)return;const ee=window.setTimeout(()=>u(null),YA);return()=>window.clearTimeout(ee)},[c]),d.useEffect(()=>{var be;const ee=I.current;ee&&(I.current=null,(be=document.querySelector(`[data-grip="${CSS.escape(ee)}"], [data-move="${CSS.escape(ee)}"]`))==null||be.focus())}),!s)return R===0?null:n.jsxs("section",{className:"ui-section wg-section","aria-label":"Widgets","aria-busy":"true",children:[n.jsx("div",{className:"ui-section-head",children:n.jsx("h3",{className:"ui-section-title",children:"Widgets"})}),n.jsx("div",{className:"wg-grid",children:Array.from({length:R},(ee,be)=>n.jsxs("div",{className:"wg-frame","data-state":"loading","aria-hidden":"true",children:[n.jsx("div",{className:"wg-head"}),n.jsxs("span",{className:"wg-skel-body",children:[n.jsx("span",{className:"wg-skel","data-w":"half"}),n.jsx("span",{className:"wg-skel","data-w":"third"}),n.jsx("span",{className:"wg-push"}),n.jsx("span",{className:"wg-skel"})]})]},be))})]});if(s.available.every(ee=>ee.builtIn)&&s.home.length===0)return null;const z=new Map(s.available.map(ee=>[ee.id,ee])),U=i?l:s.home,A=ee=>tT(ee,z.get(ee.widget)),P=(ee,be)=>(p(null),r({...be,home:ee,arranged:{...be.arranged,home:!0}}),E.saveWidgets("home",ee).then(se=>(r(se),!0),se=>(r(be),p(`Couldn't save your widgets: ${se instanceof Error?se.message:String(se)}`),!1))),D=(ee,be,se)=>{if(se<0||se>=ee.length||be===se)return null;const Te=ee.slice(),[pe]=Te.splice(be,1);return Te.splice(se,0,pe),f(`${A(pe)}, position ${se+1} of ${Te.length}.`),Te},O=()=>{o(s.home),$(new Set),u(null),p(null),a(!0)},M=ee=>(be,se)=>{const Te=U[ee];if(be==="edit"){O();return}if(be==="settings"){S(Te.key);return}if(i){if(be==="earlier"||be==="later"){const pe=D(l,ee,be==="earlier"?ee-1:ee+1);if(pe){const Re=document.activeElement;I.current=(Re==null?void 0:Re.dataset.grip)??(Re==null?void 0:Re.dataset.move)??null,o(pe)}}be==="size"&&se&&(o(l.map((pe,Re)=>Re===ee?{...pe,size:se}:pe)),$(new Set([...C,Te.key]))),be==="hide"&&(o(l.filter((pe,Re)=>Re!==ee)),f(`${A(Te)} taken off.`));return}if(be==="earlier"||be==="later"){const pe=D(s.home,ee,be==="earlier"?ee-1:ee+1);pe&&P(pe,s)}be==="size"&&se&&P(s.home.map((pe,Re)=>Re===ee?{...pe,size:se}:pe),s),be==="hide"&&P(s.home.filter((pe,Re)=>Re!==ee),s).then(pe=>{pe&&u({item:Te,at:ee})})},W=()=>{if(!c)return;const ee=s.home.filter(be=>be.key!==c.item.key);ee.splice(Math.min(c.at,ee.length),0,c.item),u(null),P(ee,s)},_=()=>{x(!0),P(l,s).then(ee=>{x(!1),ee&&(a(!1),f("Widgets saved."))})},G=ee=>{j(ee),E.refreshWidget(ee).then(r,()=>{}).finally(()=>j(null))},B=ee=>{var Te;const be={key:ZA(),widget:ee.id,size:ee.sizes[0],settings:{}},se=l.some(pe=>pe.widget===ee.id);o([...l,be]),f(`${ee.title} added.`),se&&(((Te=ee.settings)==null?void 0:Te.length)??0)>0&&S(be.key)},K=(ee,be)=>i?(o(l.map(se=>{if(se.key!==ee)return se;const{label:Te,...pe}=se;return{...pe,settings:be}})),$(new Set([...C,ee])),S(null),Promise.resolve(!0)):P(s.home.map(se=>se.key===ee?{...se,settings:be}:se),s).then(se=>(se&&(S(null),f("Settings saved.")),se)),F=ee=>{S(null);const be=U.findIndex(se=>se.key===ee);be>=0&&M(be)("hide")},Q={dragging:v,over:y,start:ee=>w(ee),enter:ee=>{y!==ee&&N(ee)},end:()=>{w(null),N(null)},drop:ee=>{const be=l.findIndex(pe=>pe.key===v),se=l.findIndex(pe=>pe.key===ee),Te=be>=0&&se>=0?D(l,be,se):null;Te&&o(Te),w(null),N(null)}},X=c?n.jsxs("div",{className:"wg-undo","data-size":c.item.size,role:"status","aria-live":"polite",children:[n.jsxs("span",{children:[A(c.item)," hidden"]}),n.jsx("span",{className:"home-glance-sep","aria-hidden":"true",children:"·"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:W,children:"Undo"})]},"undo"):null,Z=[];U.forEach((ee,be)=>{const se=z.get(ee.widget);if(!se)return;c&&!i&&c.at===be&&Z.push(X);const Te=i&&(C.has(ee.key)||!s.home.some(pe=>pe.key===ee.key));Z.push(n.jsx(dW,{info:se,placement:ee,view:Te?void 0:s.views[ee.key],index:be,count:U.length,editing:i,navigate:t,act:M(be),onRetry:()=>G(ee.key),retrying:b===ee.key,drag:Q},ee.key))}),c&&!i&&c.at>=U.length&&Z.push(X);const de=s.available.filter(ee=>!ee.builtIn),_e=de.length-2,Ie=k?U.find(ee=>ee.key===k):void 0,Ue=Ie?z.get(Ie.widget):void 0;return n.jsxs("section",{className:"ui-section wg-section","aria-label":"Widgets",children:[n.jsxs("div",{className:"ui-section-head",children:[n.jsx("h3",{className:"ui-section-title",children:"Widgets"}),i?n.jsxs("div",{className:"ui-toolbar","data-align":"end",children:[n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>{a(!1),o([])},disabled:g,children:"Cancel"}),n.jsx(T,{size:"sm",variant:"accent",onClick:_,disabled:g,children:g?"Saving…":"Done"})]}):U.length>0?n.jsx("div",{className:"ui-toolbar","data-align":"end",children:n.jsx(T,{size:"sm",variant:"ghost",onClick:O,children:"Edit"})}):null]}),n.jsx("p",{className:"sr-only","aria-live":"polite",children:h}),m?n.jsx(V,{tone:"critical",role:"alert",children:m}):null,U.length===0&&!i&&!c?n.jsxs("div",{className:"wg-empty",children:[n.jsxs("div",{className:"wg-empty-text",children:[n.jsx("p",{className:"wg-empty-title",children:"Add widgets to Home"}),n.jsxs("p",{className:"wg-empty-sub",children:["Small live panels from your plugins:"," ",(de.length>0?de:s.available).slice(0,2).map(ee=>ee.title).join(", "),_e>0?` and ${_e} more`:"","."]})]}),n.jsx(T,{size:"sm",variant:"accent",onClick:O,children:"Add widgets"})]}):Z.length>0?n.jsx("div",{className:"wg-grid","data-editing":i?"true":void 0,children:Z}):null,i?n.jsxs("div",{className:"wg-gallery",role:"region","aria-label":"Add widgets",children:[n.jsxs("div",{className:"wg-gallery-head",children:[n.jsx("p",{className:"wg-gallery-title",children:"Add widgets"}),n.jsx("a",{className:"wg-gallery-aside",href:De("lock"),onClick:ee=>{ee.preventDefault(),t(De("lock"))},children:"The lock screen has its own pick"})]}),n.jsx("ul",{className:"wg-gallery-list",children:s.available.map(ee=>{var Se;const be=l.filter(Fe=>Fe.widget===ee.id).length,se=(((Se=ee.settings)==null?void 0:Se.length)??0)>0,Te=ee.builtIn?"Built in":`${ee.plugin} plugin`,pe=ee.sizes.length>1?"small or medium":`${ee.sizes[0]} only`,Re=be>1?` · ${be} on Home`:be===1&&se?" · on Home":"";return n.jsxs("li",{className:"wg-add",children:[n.jsxs("span",{className:"wg-add-text",children:[n.jsx("span",{className:"wg-add-title",children:ee.title}),n.jsxs("span",{className:"wg-add-sub",children:[Te," · ",pe,ee.sensitive?" · hidden until you show it":"",Re]})]}),be>0&&!se?n.jsx("span",{className:"wg-add-note",children:"On Home"}):n.jsxs(T,{size:"sm","aria-label":`${be>0?"Add another":"Add"} ${ee.title}`,onClick:()=>B(ee),children:[n.jsx(ue,{name:"plus",size:12})," ",be>0?"Add another":"Add"]})]},ee.id)})})]}):null,Ie&&Ue?n.jsx(QA,{info:Ue,placement:Ie,surface:"home",onClose:()=>S(null),onSave:ee=>K(Ie.key,ee),onRemove:()=>F(Ie.key)}):null]})}function Ij(e,t){return!e||e==="image"&&!t?"earth":e}const mW="(max-width: 720px)",pW=3e4,gW={1:"a minute",5:"5 minutes",15:"15 minutes",60:"an hour"};function bm(e,t){return{time:Ht(e,t),day:dr(e,t,{weekday:!0})}}function Pj(e,t){return e?jc({timeFormat:e.time,...e.date==="off"?{}:{dateFormat:e.date}},t):t()}function xW(e,t,s=new Date,r){return Pj(r,()=>vW(e,t,s))}function vW(e,t,s){if(!e.lockedAt)return"Locked";const r=new Date(e.lockedAt),a=bm(r,t).day===bm(s,t).day?bm(r,t).time:Cv(r,t);return e.reason==="idle"?`Locked after ${e.delayMinutes?gW[e.delayMinutes]??`${e.delayMinutes} minutes`:"a while"} away, at ${a}`:e.reason==="start"?`Locked since this session began, at ${a}`:`Locked by you at ${a}`}function jW(e){const t=()=>e?Math.max(0,Math.ceil((Date.parse(e)-Date.now())/1e3)):0,[s,r]=d.useState(t);return d.useEffect(()=>{if(r(t()),!e)return;const i=window.setInterval(()=>r(t()),500);return()=>window.clearInterval(i)},[e]),s}const wW=e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`;function _k({size:e=16}){return n.jsx(ue,{name:"lock",size:e})}function nT({size:e=16}){return n.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.jsx("path",{d:"M3 8h9.6M8.6 4l4 4-4 4"})})}function yW(){return n.jsxs("svg",{width:18,height:18,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M7.6 5h8a1.4 1.4 0 0 1 1.4 1.4v7.2A1.4 1.4 0 0 1 15.6 15h-8L3 10z"}),n.jsx("path",{d:"M9.6 8l4 4M13.6 8l-4 4"})]})}function Fk({text:e}){const[t,s]=d.useState(!1),r=()=>{var i;(i=navigator.clipboard)==null||i.writeText(e).then(()=>{s(!0),window.setTimeout(()=>s(!1),1600)}).catch(()=>{})};return n.jsxs("div",{className:"so-cmd",children:[n.jsx("code",{className:"so-cmd-text",children:e}),n.jsx(T,{size:"sm",onClick:r,children:t?"Copied":"Copy"})]})}function bW({onClose:e}){return n.jsx(un,{title:"Forgot your PIN?",onClose:e,foot:n.jsx(T,{variant:"accent",onClick:e,children:"Done"}),children:n.jsxs("div",{className:"lk-forgot",children:[n.jsx("p",{className:"lk-forgot-text",children:"The PIN covers this dashboard; it doesn’t sign you in. On the computer buddi runs on, run one of these:"}),n.jsxs("div",{className:"lk-forgot-way",children:[n.jsx(Fk,{text:"buddi dashboard --unlock"}),n.jsx("p",{className:"lk-forgot-hint",children:"Opens buddi without the PIN, once. It prints a link for your other devices too, good for five minutes."})]}),n.jsxs("div",{className:"lk-forgot-way",children:[n.jsx(Fk,{text:"buddi dashboard --remove-pin"}),n.jsx("p",{className:"lk-forgot-hint",children:"Removes the PIN on every device. Set a new one in Settings → Lock screen."})]})]})})}function kW({approvals:e,unread:t,after:s,onPick:r}){const i=[];return e>0&&i.push({key:"approvals",n:e,text:e===1?"approval waiting":"approvals waiting"}),t>0&&i.push({key:"unread",n:t,text:t===1?"notification":"notifications"}),i.length===0?null:n.jsx("ul",{className:"lk-badges","aria-label":"Waiting for you",children:i.map(a=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"lk-chip","data-kind":a.key,"aria-pressed":s===a.key,disabled:!r,title:r?a.key==="unread"?"Open your notifications once unlocked":"Open your approvals once unlocked":void 0,onClick:()=>r==null?void 0:r(s===a.key?null:a.key),children:[n.jsx("span",{className:"ui-badge","aria-hidden":"true",children:a.n>99?"99+":a.n}),n.jsxs("span",{children:[n.jsxs("span",{className:"lk-sr",children:[a.n," "]}),a.text]})]})},a.key))})}function NW(e,t){const s=t?2:4;let r=0,i=0;for(const a of e){const l=Math.min(a==="medium"?2:1,s);i+l>s&&(i=0),i+=l,r=Math.max(r,i)}return r}function SW({widgets:e,phone:t}){if(e.length===0)return null;const s=e.map(i=>({w:i,size:t||i.view.body.kind==="text"?"small":i.size})),r=NW(s.map(({size:i})=>i),t);return n.jsx("div",{className:"lk-widgets",children:n.jsx("div",{className:"lk-grid","data-phone":t?"true":void 0,"data-cols":r,children:s.map(({w:i,size:a})=>n.jsxs("div",{className:"wg-frame","data-variant":"compact","data-size":a,"data-kind":i.view.body.kind,role:"group","aria-label":i.title,children:[n.jsx("div",{className:"wg-body",children:n.jsx($j,{body:i.view.body,size:a})}),n.jsx("span",{className:"wg-compact-title",children:i.title})]},i.key??i.id))})})}function CW({text:e}){const t=/^(.*?)[\s\u202f]?([AaPp]\.?[Mm]\.?)$/.exec(e);return n.jsx("p",{className:"lk-time","aria-label":e,children:t?n.jsxs(n.Fragment,{children:[t[1],n.jsx("span",{className:"lk-ampm","aria-hidden":"true",children:t[2]})]}):e})}function zk(e,t){const s=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e).map(i=>[i.type,i.value])),r=Date.UTC(Number(s.year),Number(s.month)-1,Number(s.day),Number(s.hour)%24,Number(s.minute));return Math.round((r-Math.floor(e.getTime()/6e4)*6e4)/6e4)}function EW(e,t,s){try{const r=zk(e,t)-zk(e,s);if(r===0)return"Same time";const i=u=>new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit"}).format(e),a=i(t)!==i(s)?r>0?", tomorrow":", yesterday":"",l=Math.floor(Math.abs(r)/60),o=Math.abs(r)%60;return`${o===0?`${l} h`:l===0?`${o} min`:`${l} h ${o}`} ${r>0?"ahead":"behind"}${a}`}catch{return""}}function AW(e,t,s){const r=s??{date:null,zone:null};return Pj(s,()=>({time:Ht(e,t),day:r.date==="off"?null:dr(e,t,{weekday:!0}),zone:r.zone?{label:r.zone.label,time:Ht(e,r.zone.timezone),offset:EW(e,r.zone.timezone,t)}:null}))}function sT({data:e,now:t,phone:s,pad:r=!1,after:i,onPick:a}){const l=(e==null?void 0:e.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone,o=AW(t,l,e==null?void 0:e.clockView),c=Ij(e==null?void 0:e.background,e==null?void 0:e.image),u=(e==null?void 0:e.focus)??null,h=u?Pj(e==null?void 0:e.clockView,()=>s?$W(cc(u,l,t)):`${Wi[u.mode]} ${cc(u,l,t)}`):"";return n.jsxs(n.Fragment,{children:[c==="earth"?n.jsxs("div",{className:"lk-ground","aria-hidden":"true",children:[n.jsx("img",{className:"lk-photo","data-earth":"true",src:P8(s),alt:"",decoding:"async"}),n.jsx("div",{className:"lk-scrim"})]}):c==="image"&&(e!=null&&e.image)?n.jsxs("div",{className:"lk-ground","aria-hidden":"true",children:[n.jsx("img",{className:"lk-photo",src:e.image,alt:""}),n.jsx("div",{className:"lk-scrim"})]}):n.jsx("div",{className:"ui-fieldbg lk-ground","aria-hidden":"true"}),n.jsxs("header",{className:"lk-top",children:[n.jsxs("span",{className:"lk-brand",children:[n.jsx(sc,{size:"sm"}),n.jsx("span",{children:"buddi"})]}),n.jsx("span",{className:"lk-top-spacer"}),u?n.jsxs("span",{className:"lk-chip","data-kind":"focus",children:[n.jsx(ue,{name:"moon",size:13}),n.jsx("span",{children:h})]}):null]}),n.jsxs("div",{className:"lk-main",children:[o.day?n.jsx("p",{className:"lk-date",children:o.day}):null,n.jsx(CW,{text:o.time}),o.zone?n.jsxs("p",{className:"lk-zone",children:[n.jsx("span",{className:"lk-zone-name",children:o.zone.label}),n.jsx("span",{className:"lk-zone-time",children:o.zone.time}),o.zone.offset?n.jsx("span",{className:"lk-zone-off",children:o.zone.offset}):null]}):null,r||!e?null:n.jsx(kW,{approvals:e.approvals,unread:e.unread,after:i??null,...a?{onPick:a}:{}}),r||!e?null:n.jsx(SW,{widgets:e.widgets,phone:s})]})]})}function TW({value:e,disabled:t,onDigit:s,onBack:r,onSubmit:i}){return n.jsxs("div",{className:"lk-pad",role:"group","aria-label":"PIN pad",children:[["1","2","3","4","5","6","7","8","9"].map(a=>n.jsx("button",{type:"button",className:"lk-key",disabled:t,onClick:()=>s(a),children:a},a)),n.jsx("button",{type:"button",className:"lk-key","data-kind":"quiet","aria-label":"Delete",disabled:t||e.length===0,onClick:r,children:n.jsx(yW,{})}),n.jsx("button",{type:"button",className:"lk-key",disabled:t,onClick:()=>s("0"),children:"0"}),n.jsx("button",{type:"button",className:"lk-key","data-kind":"go","aria-label":"Unlock",disabled:t||e.length<4,onClick:i,children:n.jsx(nT,{size:18})})]})}function RW({initial:e,onUnlocked:t}){const s=Ps(mW),r=GA(),[i,a]=d.useState(null),l=i??e,[o,c]=d.useState(""),[u,h]=d.useState(null),[f,m]=d.useState((e==null?void 0:e.waitUntil)??null),[p,g]=d.useState(!1),[x,b]=d.useState(!1),[j,v]=d.useState(!1),[w,y]=d.useState(!1),[N,k]=d.useState(!1),[S,C]=d.useState(null),$=d.useRef(null),R=jW(f),I=R>0,z=d.useRef(t),U=d.useRef(S);U.current=S,z.current=K=>{U.current&&(window.location.hash=U.current==="unread"?tE:Lh),t(K)};const A=K=>{var F;C(K),s&&K?y(!0):(F=$.current)==null||F.focus()},P=d.useCallback(()=>{E.lockScreen().then(K=>{b(!1),a(K),m(K.waitUntil),K.locked||z.current(K)}).catch(K=>{K instanceof me&&K.status===401?window.location.reload():Rd(K)&&b(!0)})},[]);d.useEffect(()=>{P();const K=window.setInterval(P,pW),F=()=>{document.visibilityState==="visible"&&P()};return document.addEventListener("visibilitychange",F),()=>{window.clearInterval(K),document.removeEventListener("visibilitychange",F)}},[P]),eT((i==null?void 0:i.widgets.some(K=>K.id===XA&&K.view.body.kind!=="clocks"))??!1,P),d.useEffect(()=>{var K;!s&&!j&&!I&&((K=$.current)==null||K.focus())},[s,j,I,p]),d.useEffect(()=>{!I&&f&&h(null)},[I,f]);const D=K=>{K==null||K.preventDefault(),!(p||I||o.length<4)&&(g(!0),E.unlock(o).then(F=>{var X;if(c(""),F.locked){g(!1);return}if((X=window.matchMedia)==null?void 0:X.call(window,"(prefers-reduced-motion: reduce)").matches){z.current(F);return}k(!0),window.setTimeout(()=>z.current(F),240)}).catch(F=>{if(g(!1),c(""),!(F instanceof me))return h("Something went wrong. Try again.");const Q=F.detail??{};if(F.status===403||F.status===429){Q.waitUntil&&m(Q.waitUntil);const X=Q.triesLeft??0;h(Q.waitUntil?"That PIN isn’t right.":`That PIN isn’t right. ${X} ${X===1?"try":"tries"} left.`)}else Rd(F)?h("buddi isn’t answering. Try again in a moment."):h(F.message)}))},O=(i==null?void 0:i.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone,M=Ij(l==null?void 0:l.background,l==null?void 0:l.image),W=(i==null?void 0:i.owner)??null,_=x?{tone:"critical",text:"buddi isn’t answering. The lock stays until it does."}:I?{tone:"critical",text:`Too many tries. Try again in ${wW(R)}.`}:u?{tone:"critical",text:u}:S?{tone:void 0,text:S==="unread"?"Unlock to open your notifications.":"Unlock to open your approvals."}:{tone:void 0,text:l?xW(l,O,r,i==null?void 0:i.clockView):"Locked"},G=K=>K.replace(/\D/g,"").slice(0,8),B=n.jsxs("div",{className:"lk-who",children:[n.jsx("span",{className:"lk-face","aria-hidden":"true",children:(W??"You").slice(0,1).toUpperCase()}),W?n.jsx("span",{className:"lk-owner",children:W}):null]});return n.jsxs("div",{className:"lk","data-bg":M,"data-phone":s?"true":void 0,"data-view":w?"pad":"glance","data-opening":N?"true":void 0,role:"dialog","aria-modal":"true","aria-label":"buddi is locked","data-testid":"lock-screen",children:[n.jsx(sT,{data:i??(l?{...IW(l)}:null),now:r,phone:s,pad:w,after:S,onPick:A}),n.jsx("footer",{className:"lk-unlock",children:s&&!w?n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:"lk-chip lk-enter",onClick:()=>y(!0),children:[n.jsx(_k,{size:14}),n.jsx("span",{children:"Enter PIN"})]}),n.jsx("p",{className:"lk-note","data-tone":_.tone,role:"status","aria-live":"polite",children:_.text})]}):s?n.jsxs(n.Fragment,{children:[B,n.jsx("div",{className:"lk-dots","aria-hidden":"true","data-state":u?"wrong":void 0,children:o.length===0?n.jsx("span",{className:"lk-dots-empty",children:"Enter your PIN"}):Array.from(o).map((K,F)=>n.jsx("span",{className:"lk-dot"},F))}),n.jsx("span",{className:"lk-sr","aria-live":"polite",children:o.length===1?"1 digit entered":`${o.length} digits entered`}),n.jsx("p",{className:"lk-note","data-tone":_.tone,role:"status","aria-live":"polite",children:_.text}),n.jsx(TW,{value:o,disabled:I||p,onDigit:K=>{h(null),c(G(o+K))},onBack:()=>c(o.slice(0,-1)),onSubmit:()=>D()}),n.jsxs("div",{className:"lk-pad-foot",children:[n.jsx("button",{type:"button",className:"lk-link",onClick:()=>v(!0),children:"Forgot PIN?"}),n.jsx("button",{type:"button",className:"lk-link",onClick:()=>{y(!1),c(""),h(null)},children:"Cancel"})]})]}):n.jsxs(n.Fragment,{children:[B,n.jsxs("form",{className:"lk-pin","data-state":u&&!I?"wrong":I?"wait":void 0,onSubmit:D,children:[n.jsx(_k,{size:15}),n.jsx("input",{ref:$,type:"password",inputMode:"numeric",autoComplete:"off",maxLength:8,"aria-label":"PIN","aria-describedby":"lk-note",placeholder:I?"Wait a moment":"Enter your PIN",disabled:I,value:o,onChange:K=>{h(null),c(G(K.target.value))}}),n.jsx("button",{type:"submit",className:"lk-go","aria-label":"Unlock",disabled:p||I||o.length<4,children:n.jsx(nT,{})})]}),n.jsx("p",{className:"lk-note",id:"lk-note","data-tone":_.tone,role:"status","aria-live":"polite",children:_.text}),n.jsx("button",{type:"button",className:"lk-link",onClick:()=>v(!0),children:"Forgot PIN?"})]})}),j?n.jsx(bW,{onClose:()=>v(!1)}):null]})}function $W(e){return e.slice(0,1).toUpperCase()+e.slice(1)}function IW(e){return{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,background:e.background,image:e.image,focus:null,approvals:0,unread:0,widgets:[]}}const PW=3e4,MW=5e3,DW="buddi-lock",Wg="buddi-locked",OW=De("lock");function rT(){var t;const e=navigator;return/mac|iphone|ipad|ipod/i.test(((t=e.userAgentData)==null?void 0:t.platform)||navigator.platform||navigator.userAgent)}function LW(e=rT()){return e?"⌃⌘L":"Ctrl+Alt+L"}function _W(e,t=rT()){return!(e.code==="KeyL"||e.key.toLowerCase()==="l")||!e.ctrlKey||e.shiftKey?!1:t?e.metaKey&&!e.altKey:e.altKey&&!e.metaKey}const iT=d.createContext({pin:!1,state:null,lockNow:()=>{},update:()=>{},shortcut:"⌃⌘L"});function Zh(){return d.useContext(iT)}function ku(e){try{e?localStorage.setItem(Wg,"1"):localStorage.removeItem(Wg)}catch{}}function FW(){try{return localStorage.getItem(Wg)==="1"}catch{return!1}}function zW(){try{return typeof BroadcastChannel>"u"?null:new BroadcastChannel(DW)}catch{return null}}function UW({children:e}){const[t,s]=d.useState("checking"),[r,i]=d.useState(null),a=d.useRef(null),l=d.useRef(Date.now()),o=d.useRef(0),c=d.useRef(0),u=d.useRef(0),h=d.useCallback((x,b)=>{x&&i(x),s(b?"locked":"open"),ku(b),b||(l.current=Date.now())},[]),f=d.useCallback(()=>{E.lockState().then(x=>h(x,x.locked)).catch(x=>{if(x instanceof me&&x.status===401)return s("open");h(null,FW())})},[h]);d.useEffect(()=>{f()},[f]);const m=d.useCallback((x="owner")=>{var b;if(!(r!=null&&r.pin)){window.location.hash=OW;return}s("locked"),ku(!0),(b=a.current)==null||b.postMessage({type:"locked"}),E.lockNow(x).then(j=>h(j,j.locked)).catch(()=>f())},[r==null?void 0:r.pin,h,f]);d.useEffect(()=>{const x=()=>{s("locked"),ku(!0),f()};return window.addEventListener(Yp,x),()=>window.removeEventListener(Yp,x)},[f]),d.useEffect(()=>{const x=zW();if(a.current=x,!!x)return x.onmessage=b=>{const j=b.data;(j==null?void 0:j.type)==="locked"?(s("locked"),ku(!0)):(j==null?void 0:j.type)==="unlocked"?f():(j==null?void 0:j.type)==="activity"&&typeof j.at=="number"&&(l.current=Math.max(l.current,j.at))},()=>{x.close(),a.current=null}},[f]),d.useEffect(()=>{const x=b=>{_W(b)&&(b.preventDefault(),t==="open"&&m("owner"))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[t,m]);const p=r!=null&&r.pin?r.delayMinutes:null;d.useEffect(()=>{if(t!=="open"||!(r!=null&&r.pin))return;c.current=l.current;const x=()=>{var k;const N=Date.now();l.current=N,N-u.current>1e4&&(u.current=N,(k=a.current)==null||k.postMessage({type:"activity",at:N}))},b=()=>{const N=Date.now();l.current<=c.current||N-o.current<PW||(o.current=N,c.current=l.current,E.lockActivity().catch(()=>{}))},j=()=>{if(p!==null&&Date.now()-l.current>=p*6e4){m("idle");return}b()},v=["pointerdown","pointermove","keydown","wheel","touchstart"];for(const N of v)window.addEventListener(N,x,{passive:!0,capture:!0});const w=window.setInterval(j,MW),y=()=>{document.visibilityState==="visible"&&j()};return document.addEventListener("visibilitychange",y),()=>{for(const N of v)window.removeEventListener(N,x,{capture:!0});window.clearInterval(w),document.removeEventListener("visibilitychange",y)}},[t,r==null?void 0:r.pin,p,m]);const g=d.useMemo(()=>({pin:(r==null?void 0:r.pin)===!0,state:r,lockNow:()=>m("owner"),update:x=>h(x,x.locked),shortcut:LW()}),[r,m,h]);return t==="checking"?null:t==="locked"?n.jsx(RW,{initial:r,onUnlocked:x=>{var b;(b=a.current)==null||b.postMessage({type:"unlocked"}),h(x,!1)}}):n.jsx(iT.Provider,{value:g,children:e})}const aT="a connection needs you";function BW({attention:e,place:t,onNavigate:s,theme:r,onTheme:i,plugins:a=[],updateAvailable:l=!1,settingsDot:o,version:c,stale:u=!1,reload:h,timezone:f,status:m}){return n.jsxs("nav",{className:"rail","aria-label":"Places",children:[n.jsx("a",{className:"rail-mark",href:sn,onClick:p=>{p.preventDefault(),s(sn)},"aria-label":"buddi home",children:n.jsx(sc,{})}),uF.filter(p=>p.route!==en).map(p=>n.jsx(km,{label:p.label,href:p.route,active:t===p.route,badge:p.route===sn?e:0,onClick:()=>s(p.route),children:Uk[p.route]},p.route)),a.map(p=>{const g=lr(p.plugin,p.id);return n.jsx(km,{label:p.title,href:g,active:t===g,badge:0,onClick:()=>s(g),children:n.jsx(ue,{name:WA(p.icon)})},g)}),n.jsx("div",{className:"rail-spacer"}),n.jsx(km,{label:"Settings",href:en,active:t===en,badge:0,dot:l?"a newer buddi is ready":o,onClick:()=>s(en),children:Uk[en]}),m,n.jsx(HW,{theme:r,onTheme:i,onNavigate:s,version:c,stale:u,reload:h,timezone:f})]})}const WW=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function HW({theme:e,onTheme:t,onNavigate:s,version:r,stale:i,reload:a=()=>window.location.reload(),timezone:l}){var y,N,k;const o=ce(()=>E.owner(),[]),c=Zh(),u=ce(()=>E.focus(),[],6e4),h=((y=u.data)==null?void 0:y.focus)??null,f=(S,C)=>{E.setFocus(S,C).finally(()=>u.reload())},m=((k=(N=o.data)==null?void 0:N.preferredName)==null?void 0:k.trim())||null,p=(m??"You").slice(0,1).toUpperCase(),[g]=d.useState(EF),[x]=d.useState(GW),b=Jh(),j=m?`You: ${m}`:"You",v=h?`${Wi[h.mode]} ${cc(h,l)}`:null,w=[j,v,i?"reload to update":null].filter(Boolean).join(", ");return n.jsx("div",{className:"rail-owner",children:n.jsxs(bc,{modal:!1,children:[n.jsx(kc,{asChild:!0,children:n.jsxs("button",{type:"button",className:"rail-owner-btn","aria-label":w,children:[n.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:p}),i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"owner-dot","aria-hidden":"true"}):null,h?n.jsx("span",{className:"rail-focus","data-testid":"owner-focus","aria-hidden":"true",children:n.jsx(ue,{name:"moon",size:10})}):null]})}),n.jsx(Nl,{children:n.jsxs(Nc,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[n.jsxs("div",{className:"rail-owner-head",children:[n.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:p}),n.jsxs("span",{className:"rail-owner-who",children:[n.jsx("span",{className:"rail-owner-name",children:m??"You"}),n.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),n.jsx(Nr,{className:"ui-menu-sep"}),n.jsx(VW,{focus:h,timezone:l,onSwitch:f}),n.jsx(Nr,{className:"ui-menu-sep"}),n.jsx(ta,{className:"ui-menu-label",children:"Theme"}),n.jsx("div",{className:"rail-owner-theme",children:n.jsx(rn,{label:"Theme",options:WW,value:e,onChange:t})}),n.jsx(Nr,{className:"ui-menu-sep"}),c.pin?n.jsxs(us,{className:"ui-menu-item rail-owner-reload",onSelect:()=>c.lockNow(),children:[n.jsx("span",{children:"Lock now"}),n.jsx("kbd",{className:"rail-owner-kbd",children:c.shortcut})]}):n.jsx(us,{className:"ui-menu-item",onSelect:()=>s(De("lock")),children:"Set up a lock screen…"}),n.jsx(us,{className:"ui-menu-item",onSelect:()=>s(De("appearance")),children:"Change appearance"}),b?n.jsx(us,{className:"ui-menu-item",onSelect:()=>{Tj(b)},children:"Install the app"}):null,g||i?n.jsxs(us,{className:"ui-menu-item rail-owner-reload","data-update":i?"true":void 0,onSelect:()=>a(),children:[n.jsx("span",{children:i?"Reload to update":"Reload"}),x?n.jsx("kbd",{className:"rail-owner-kbd",children:x}):null]}):null,r?n.jsxs(n.Fragment,{children:[n.jsx(Nr,{className:"ui-menu-sep"}),n.jsxs(us,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>s(De("system")),children:[n.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?n.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}const Wi={normal:"Off","urgent-only":"Urgent only","do-not-disturb":"Do not disturb"},KW=[{value:"1h",label:"For 1 hour"},{value:"3h",label:"For 3 hours"},{value:"tomorrow",label:"Until tomorrow morning"},{value:"indefinite",label:"Until I turn it off"}];function cc(e,t,s=new Date){if(!e.until)return"until you turn it off";const r=new Date(e.until),i=t??Intl.DateTimeFormat().resolvedOptions().timeZone,a=c=>new Intl.DateTimeFormat("en-CA",{timeZone:i,dateStyle:"short"}).format(c),l=Ht(r,i);return a(r)===a(s)?`until ${l}`:`until ${new Intl.DateTimeFormat("en-US",{timeZone:i,weekday:"short"}).format(r)} ${l}`}function VW({focus:e,timezone:t,onSwitch:s}){return n.jsxs(b_,{children:[n.jsxs(k_,{className:"ui-menu-item rail-owner-focus",children:[n.jsx("span",{children:"Focus"}),n.jsx("span",{className:"rail-owner-kbd",children:e?Wi[e.mode]:"Off"})]}),n.jsx(Nl,{children:n.jsxs(N_,{className:"ui-menu rail-owner-menu",sideOffset:6,children:[n.jsx("p",{className:"ui-menu-empty",role:"status",children:e?`${Wi[e.mode]} ${cc(e,t)}${e.by==="schedule"?", from a schedule":""}.`:"No focus is on."}),["do-not-disturb","urgent-only"].map(r=>n.jsxs(G1,{children:[n.jsx(Nr,{className:"ui-menu-sep"}),n.jsx(ta,{className:"ui-menu-label",children:Wi[r]}),KW.map(i=>n.jsx(us,{className:"ui-menu-item","aria-label":`${Wi[r]} ${i.label.toLowerCase()}`,onSelect:()=>s(r,i.value),children:i.label},i.value))]},r)),e?n.jsxs(n.Fragment,{children:[n.jsx(Nr,{className:"ui-menu-sep"}),n.jsx(us,{className:"ui-menu-item",onSelect:()=>s("normal"),children:"Turn off"})]}):null]})})]})}function GW(){const e=window.navigator.userAgent;return/iPhone|iPad|Android|Mobile/.test(e)?null:/Mac/.test(e)?"⌘R":"Ctrl+R"}function km({label:e,href:t,active:s,badge:r,dot:i,onClick:a,children:l}){return n.jsxs("a",{className:"rail-link",href:t,"data-active":s?"true":void 0,"aria-current":s?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:o=>{o.preventDefault(),a()},children:[n.jsxs("span",{className:"rail-icon",children:[l,r>0?n.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?n.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),n.jsx("span",{className:"rail-label",children:e})]})}const Uk={[Or]:n.jsx(ue,{name:"files"}),[sn]:n.jsx(ue,{name:"home"}),[ci]:n.jsx(ue,{name:"chat"}),[Et]:n.jsx(ue,{name:"agents"}),[vt]:n.jsx(ue,{name:"activity"}),[en]:n.jsx(ue,{name:"settings"})},uc=e=>`${e.plugin}:${e.id}`,YW=new Set;let Mj=YW,Bk=!1;const Hg=new Set;function Kg(e){Mj=e;for(const t of Hg)t()}function qW(e){return Hg.add(e),()=>Hg.delete(e)}const Wk=()=>Mj;function QW(){Bk||(Bk=!0,Promise.resolve().then(()=>E.rail()).then(e=>Kg(new Set(Array.isArray(e==null?void 0:e.hidden)?e.hidden.filter(t=>typeof t=="string"):[]))).catch(()=>{}))}async function XW(e,t){const s=Mj,r=new Set(s);t?r.add(uc(e)):r.delete(uc(e)),Kg(r);try{await E.setRailHidden(e.plugin,e.id,t)}catch(i){throw Kg(s),i}}function lT(){return d.useEffect(QW,[]),d.useSyncExternalStore(qW,Wk,Wk)}function JW(e,t){return e.filter(s=>!t.has(uc(s)))}function ZW(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function eH(e,t=!0,s){d.useEffect(()=>{if(!t)return;const r=i=>{if(i.key!=="/"||i.defaultPrevented||i.ctrlKey||i.metaKey||i.altKey||ZW(i.target))return;i.preventDefault();const a=document.getElementById(Ig);if(a instanceof HTMLTextAreaElement){!a.disabled&&!a.hidden&&a.focus();return}s?s():e(sn)};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t,s])}const oT="buddi.theme";function tH(e=cT()){try{const t=e==null?void 0:e.getItem(oT);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function nH(e,t=cT()){try{t==null||t.setItem(oT,e)}catch{}}function sH(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function cT(){try{return window.localStorage}catch{return}}const uT="buddi.ground",dT="buddi.pageWidth";function rH(e=mT()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},s=t(uT),r=t(dT);return{theme:tH(e),ground:s==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function hT(e,t=document.documentElement){t&&(sH(e.theme,t),e.ground==="sand"?t.setAttribute("data-ground","sand"):t.removeAttribute("data-ground"),e.width==="wide"?t.removeAttribute("data-width"):t.setAttribute("data-width",e.width))}function iH(e,t=mT()){nH(e.theme,t);try{t==null||t.setItem(uT,e.ground),t==null||t.setItem(dT,e.width)}catch{}}let Qa=null;const Vg=new Set;function Gg(){return Qa||(Qa=rH()),Qa}function aH(e){return Vg.add(e),()=>Vg.delete(e)}function lH(e){Qa={...Gg(),...e},hT(Qa),iH(Qa);for(const t of Vg)t()}function fT(){return[d.useSyncExternalStore(aH,Gg,Gg),lH]}function mT(){try{return window.localStorage}catch{return}}const Hk=7,oH=1e4;function cH({timezone:e,embedded:t,agents:s=[],navigate:r}){const{data:i,error:a,reload:l}=ce(()=>E.sentinels(),[],3e4),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState(null),[p,g]=d.useState(null),[x,b]=d.useState(!1),[j,v]=d.useState(null),w=i==null?void 0:i.alerts,y=(w==null?void 0:w.open)??[],N=O=>{r?r(O):window.location.hash=O},k=O=>{var M;return O?((M=s.find(W=>W.id===O))==null?void 0:M.name)??null:null},S=async O=>{c(null);try{await O()}catch(M){c(M instanceof me||M instanceof Error?M.message:String(M))}finally{l()}},C=O=>h({...O,id:Date.now()}),$=(O,M,W)=>S(async()=>{const{keys:_}=await E.snoozeAlerts(O,!0,W);C({title:M,undo:()=>E.snoozeAlerts(_,!1)})}),R=O=>S(async()=>{const{id:M}=await E.muteAlert(O.keys[0],O.stop.scope);C({title:"You won’t hear about this again",body:"Turn it back on in Settings → Watchers.",undo:()=>E.unmuteAlert(M)})}),I=O=>S(async()=>{const{agentId:M,conversationId:W}=await E.askAboutAlerts(O.keys);N(at(M,W))}),z=O=>S(async()=>{const[M]=(await E.actOnAlerts([{key:O.key,action:O.index}])).results;if(M!=null&&M.error)throw new Error(M.error);M!=null&&M.approvalId?C({title:"Waiting for your approval",body:"Decide it in Needs you on Home."}):C({title:`${O.label}: done`})}),U=(O,M)=>{M.kind==="open"?N(M.place==="files"?Or:M.plugin&&M.page?lr(M.plugin,M.page,M.item):Or):M.kind==="ask"?I(O):M.kind==="dismiss"?$(O.keys,"Set aside until it changes"):M.kind==="fill"?m(M):M.confirm?g(M):z(M)},A=()=>{const O=y.flatMap(M=>M.keys);$(O,`Cleared ${y.length} for a week`,Hk)},P=w==null?void 0:w.recap,D=uH((P==null?void 0:P.nextAt)??null,e);return n.jsxs(An,{embedded:t,title:"Alerts",lede:"What needs a decision from you.",children:[n.jsx(ae,{message:a??o}),n.jsxs(qe,{flush:!0,title:"Needs a decision",tool:y.length>0?String(y.length):void 0,actions:y.length>1?n.jsx(T,{size:"sm",variant:"ghost",onClick:A,children:"Clear all"}):void 0,children:[i?y.length===0?n.jsxs("div",{className:"al-empty",children:[n.jsx(ue,{name:"check"}),n.jsxs("div",{children:[n.jsx("p",{className:"al-empty-title",children:"Nothing needs a decision."}),n.jsxs("p",{className:"al-empty-line",children:["Your watchers are quiet. What they notice in passing waits for ",D,"."]})]})]}):n.jsx("ul",{className:"al-list",children:y.map(O=>n.jsx(Kk,{group:O,agentName:k(O.agentId),onAct:U,onStop:R,onNotNow:M=>void $(M.keys,"Snoozed for a week",Hk)},O.id))}):null,P&&P.count>0?n.jsxs("p",{className:"al-recap","data-testid":"recap-line",children:[n.jsxs("span",{children:[P.count," ",P.count===1?"note":"notes"," saved for ",D]}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("button",{type:"button",className:"wb-link",onClick:()=>b(!0),children:"Preview"})]}):null]}),w&&(w.snoozed.length>0||w.resolved.length>0)?n.jsxs("p",{className:"al-quiet",children:[w.snoozed.length>0?n.jsxs("button",{type:"button",className:"wb-link","aria-expanded":j==="snoozed",onClick:()=>v(j==="snoozed"?null:"snoozed"),children:[w.snoozed.length," snoozed"]}):null,w.snoozed.length>0&&w.resolved.length>0?n.jsx("span",{"aria-hidden":"true",children:"·"}):null,w.resolved.length>0?n.jsxs("button",{type:"button",className:"wb-link","aria-expanded":j==="resolved",onClick:()=>v(j==="resolved"?null:"resolved"),children:[w.resolved.length," resolved this week"]}):null]}):null,j==="snoozed"&&w?n.jsx(qe,{flush:!0,title:"Snoozed",children:n.jsx("ul",{className:"al-list",children:w.snoozed.map(O=>n.jsxs("li",{className:"al-row",children:[n.jsxs("div",{className:"al-main",children:[n.jsx("p",{className:"al-title",children:O.title}),n.jsx("p",{className:"al-sub",children:O.snoozedUntil?`Back ${Oe(O.snoozedUntil)}`:"Until it changes"})]}),n.jsx("div",{className:"al-actions",children:n.jsx(T,{size:"sm",onClick:()=>void S(async()=>{await E.snoozeAlerts(O.keys,!1)}),children:"Bring back"})})]},O.id))})}):null,j==="resolved"&&w?n.jsx(qe,{flush:!0,title:"Resolved this week",children:n.jsx("ul",{className:"al-list",children:w.resolved.map(O=>n.jsx("li",{className:"al-row",children:n.jsxs("div",{className:"al-main",children:[n.jsx("p",{className:"al-title",children:O.title}),n.jsx("p",{className:"al-sub",children:O.resolvedAt?`Resolved ${Oe(O.resolvedAt)}`:null})]})},O.id))})}):null,x&&P?n.jsxs(ht,{title:dH(D),onClose:()=>b(!1),children:[n.jsxs("p",{className:"al-form-note",children:["What the watchers noted. buddi reads them out in ",D,"; nothing here needs you now, but you can act on one early."]}),n.jsx("ul",{className:"al-list al-list-sheet",children:P.groups.map(O=>n.jsx(Kk,{group:O,agentName:k(O.agentId),recap:!0,onAct:(M,W)=>{W.kind!=="fill"&&b(!1),U(M,W)},onStop:M=>{R(M)}},O.id))})]}):null,f?n.jsx(hH,{action:f,onClose:()=>m(null),onSaved:O=>{m(null),b(!1),C({title:`Saved ${O}`}),l()}}):null,p?n.jsx(un,{title:p.label,onClose:()=>g(null),foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:()=>g(null),children:"Cancel"}),n.jsx(T,{variant:p.tone==="danger"?"danger":"accent",onClick:()=>{const O=p;g(null),z(O)},children:p.label})]}),children:n.jsx("p",{children:p.confirm})}):null,u?n.jsx(Bd,{title:u.title,...u.body?{body:u.body}:{},duration:oH,...u.undo?{onUndo:()=>{const O=u.undo;S(async()=>{await O()})}}:{},onGone:()=>h(null)},u.id):null]})}function uH(e,t,s=Date.now()){if(!e)return"the weekly recap";const r=new Date(e);return Number.isNaN(r.getTime())||r.getTime()-s>7*864e5?"the weekly recap":`${new Intl.DateTimeFormat("en",{weekday:"long",timeZone:t}).format(r)}’s recap`}function dH(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Nu(e,t){return e.kind==="ask"?e.label??(t?`Ask ${t}`:"Ask about it"):e.label}function Kk({group:e,agentName:t,recap:s,onAct:r,onNotNow:i,onStop:a}){const[l,o]=d.useState(!1),[c,u,...h]=e.actions,f=e.actions.some(p=>p.kind==="ask"),m=e.items.length>1;return n.jsxs("li",{className:"al-row","data-urgent":e.urgent&&!s?"true":void 0,children:[n.jsxs("div",{className:"al-main",children:[n.jsx("p",{className:"al-title",children:e.title}),e.line?n.jsx("p",{className:"al-line",children:e.line}):null,n.jsxs("p",{className:"al-sub",children:[t?n.jsx("span",{children:t}):null,t&&!s?n.jsx("span",{"aria-hidden":"true",children:"·"}):null,s?null:n.jsxs("span",{children:["noticed ",Oe(e.since)]}),m?n.jsxs(n.Fragment,{children:[t||!s?n.jsx("span",{"aria-hidden":"true",children:"·"}):null,n.jsx("button",{type:"button",className:"wb-link al-toggle","aria-expanded":l,onClick:()=>o(p=>!p),children:l?"Hide":`Show the ${e.items.length}`})]}):null]}),l&&m?n.jsx("ul",{className:"al-items",children:e.items.map(p=>n.jsxs("li",{className:"al-item",children:[p.subject?n.jsx("span",{className:"al-item-who",children:p.subject.label}):null,n.jsx("span",{className:"al-item-note",children:p.subject?p.note:p.line}),p.actions&&p.actions.length>0?n.jsx("span",{className:"al-item-actions",children:p.actions.map((g,x)=>n.jsx(T,{size:"sm",variant:g.kind==="run"&&g.tone==="danger"?"danger-ghost":"ghost",onClick:()=>r(e,g),children:Nu(g,t)},x))}):null]},p.key))}):null]}),n.jsxs("div",{className:"al-actions",children:[c?n.jsx(T,{size:"sm",variant:"accent",onClick:()=>r(e,c),children:Nu(c,t)}):null,u?n.jsx(T,{size:"sm",variant:u.kind==="run"&&u.tone==="danger"?"danger-ghost":void 0,onClick:()=>r(e,u),children:Nu(u,t)}):null,i?n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>i(e),children:"Not now"}):null,n.jsx("span",{className:"al-more",children:n.jsx(Cl,{label:`More for ${e.title}`,sheet:{title:e.title},items:[...h.map(p=>({label:Nu(p,t),...p.kind==="run"&&p.tone==="danger"?{tone:"critical"}:{},onSelect:()=>r(e,p)})),!f&&{label:t?`Ask ${t}`:"Ask about it",onSelect:()=>r(e,{kind:"ask",label:null})},"separator",{label:"Stop telling me this",hint:"Undo in Settings → Watchers",onSelect:()=>a(e)}]})})]})]})}function hH({action:e,onClose:t,onSaved:s}){const r=e.fields.length===1,[i,a]=d.useState(()=>Object.fromEntries(e.fields.map(p=>[p.key,r&&p.value!==null?String(p.value):""]))),[l,o]=d.useState({}),[c,u]=d.useState(!1),[h,f]=d.useState(null),m=async()=>{const p=e.fields.filter(g=>(i[g.key]??"").trim()!=="").map(g=>({key:g.key,action:g.index,value:(i[g.key]??"").trim()}));if(p.length===0){t();return}u(!0),f(null);try{const{results:g}=await E.actOnAlerts(p),x=Object.fromEntries(g.filter(b=>b.error).map(b=>[b.key,b.error]));o(x),Object.keys(x).length===0&&s(p.length)}catch(g){f(g instanceof Error?g.message:String(g))}finally{u(!1)}};return n.jsx(ht,{title:e.title,onClose:t,foot:n.jsxs("div",{className:"al-form-foot",children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:c,onClick:()=>void m(),children:c?"Saving…":"Save"})]}),children:n.jsxs("div",{className:"al-form",children:[n.jsx(ae,{message:h}),n.jsx("p",{className:"al-form-note",children:r?"Check it and save.":"Type what each is today. Leave the ones you don’t know; they stay as they are."}),n.jsx("div",{className:"al-form-rows",children:e.fields.map(p=>n.jsxs("label",{className:"al-form-row",children:[n.jsxs("span",{className:"al-form-label",children:[n.jsx("span",{children:p.label}),p.hint?n.jsx("span",{className:"al-form-hint",children:p.hint}):null]}),n.jsx("input",{type:p.type==="date"?"date":"text",inputMode:p.type==="number"?"decimal":void 0,value:i[p.key]??"",placeholder:"—","aria-label":p.label,onChange:g=>a(x=>({...x,[p.key]:g.target.value}))}),l[p.key]?n.jsx("span",{className:"al-form-error",children:l[p.key]}):null]},p.key))})]})})}function fH({mutes:e,onChanged:t}){const[s,r]=d.useState(null);return e.length===0?null:n.jsxs(qe,{flush:!0,title:"Silenced",tool:String(e.length),children:[n.jsx(ae,{message:s}),n.jsx("ul",{className:"al-list",children:e.map(i=>n.jsxs("li",{className:"al-row",children:[n.jsxs("div",{className:"al-main",children:[n.jsx("p",{className:"al-title al-silenced-label",children:i.label}),n.jsxs("p",{className:"al-sub",children:["You said “Stop telling me this” ",Oe(i.createdAt)]})]}),n.jsx("div",{className:"al-actions",children:n.jsx(T,{size:"sm",onClick:()=>{r(null),E.unmuteAlert(i.id).then(t,a=>r(a instanceof Error?a.message:String(a)))},children:"Tell me again"})})]},i.id))})]})}const Vk=5e3,Gk=50;function mH({timezone:e,embedded:t}){var j;const[s,r]=d.useState(""),[i,a]=d.useState(""),[l,o]=d.useState(null),c=ce(()=>E.eventKinds(),[]),{data:u,error:h}=ce(()=>E.events({kind:s||void 0,q:i||void 0,limit:Gk}),[s,i],Vk),[f,m]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{m({events:[],cursor:null,busy:!1,error:null})},[s,i]);const p=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,g=async()=>{if(p){m(v=>({...v,busy:!0,error:null}));try{const v=await E.events({kind:s||void 0,q:i||void 0,before:p,limit:Gk});m(w=>({events:[...w.events,...v.events],cursor:v.nextCursor,busy:!1,error:null}))}catch(v){m(w=>({...w,busy:!1,error:v instanceof Error?v.message:String(v)}))}}},x=new Set(((u==null?void 0:u.events)??[]).map(v=>v.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(v=>!x.has(v.id))];return n.jsxs(An,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[n.jsxs(le,{children:[n.jsxs("select",{"aria-label":"Event kind",value:s,onChange:v=>r(v.target.value),children:[n.jsx("option",{value:"",children:"every kind"}),(((j=c.data)==null?void 0:j.kinds)??[]).map(v=>n.jsxs("option",{value:v.kind,children:[v.kind," (",v.count,")"]},v.kind))]}),n.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:v=>a(v.target.value),size:28}),s||i?n.jsx(T,{onClick:()=>{r(""),a("")},children:"Clear"}):null,n.jsxs("span",{className:"muted",children:["refreshes every ",Vk/1e3,"s"]})]}),n.jsx(ae,{message:h}),n.jsx(qe,{flush:!0,children:!u||b.length===0?n.jsx(xe,{children:"No events match."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"#"}),n.jsx("th",{children:"When"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Payload"})]})}),n.jsx("tbody",{children:b.map(v=>n.jsxs("tr",{"data-clickable":"true",onClick:()=>o(v),children:[n.jsx("td",{className:"mono muted",children:v.id}),n.jsxs("td",{className:"nowrap",children:[et(v.createdAt,e),n.jsx("div",{className:"sub",children:Oe(v.createdAt)})]}),n.jsx("td",{className:"mono nowrap",children:v.kind}),n.jsx("td",{className:"mono muted",children:Ds(Xn(v.payload).replace(/\s+/g," "),120)})]},v.id))})]})}),p||f.error?n.jsxs(le,{children:[n.jsxs("span",{className:"muted",children:[b.length," shown",p?", older ones are kept":"","."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),f.error?n.jsx("span",{className:"critical",children:f.error}):null,p?n.jsx(T,{disabled:f.busy,onClick:()=>void g(),children:f.busy?"Loading…":"Load older"}):null]}):null,l?n.jsxs(ht,{title:l.kind,onClose:()=>o(null),children:[n.jsxs("p",{className:"muted",children:["Event ",l.id," · ",et(l.createdAt,e),l.conversationId?n.jsxs(n.Fragment,{children:[" · ",n.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"conversation"})]}):null]}),n.jsx(Pt,{children:Xn(l.payload)})]}):null]})}const Yk=["pending","leased","suspended","failed","succeeded","cancelled"],no=50,pH=1e4,gH=(e,t,s=`${t}s`)=>e===1?t:s;function xH({timezone:e,embedded:t,initialState:s}){var _,G;const[r,i]=d.useState(s??""),[a,l]=d.useState(null),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState(!1),p=r==="failed",{data:g,error:x,reload:b}=ce(()=>E.jobs({...r?{state:r}:{},...r?{}:{dismissed:"0"},limit:String(no)}),[r],1e4),j=ce(()=>E.jobFailures(),[],1e4),[v,w]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{w({jobs:[],done:!1,busy:!1})},[r]);const y=async()=>{w(B=>({...B,busy:!0}));try{const B=await E.jobs({...r?{state:r}:{dismissed:"0"},limit:String(no),offset:String(no+v.jobs.length)});w(K=>({jobs:[...K.jobs,...B.jobs],done:B.jobs.length<no,busy:!1}))}catch(B){c(B instanceof Error?B.message:String(B)),w(K=>({...K,busy:!1}))}},N=new Set(((g==null?void 0:g.jobs)??[]).map(B=>B.id)),k=[...(g==null?void 0:g.jobs)??[],...v.jobs.filter(B=>!N.has(B.id))],S=(g==null?void 0:g.counts)??{},C=r?S[r]??0:Yk.reduce((B,K)=>B+(S[K]??0),0),$=!v.done&&k.length<C&&((g==null?void 0:g.jobs.length)??0)>=no,R=((_=j.data)==null?void 0:_.open)??[],I=((G=j.data)==null?void 0:G.dismissed)??[],z=R.reduce((B,K)=>B+K.count,0),U=I.reduce((B,K)=>B+K.count,0),A=()=>{b(),j.reload()},P=B=>h({...B,id:Date.now()}),D=async B=>{c(null);try{await B()}catch(K){c(K instanceof Error?K.message:String(K))}finally{A()}},O=async B=>{await D(async()=>{await B,l(null)})},M=B=>D(async()=>{const{ids:K}=await E.dismissJobs(B==="all"?{all:!0}:{ids:B});K.length!==0&&P({title:`Dismissed ${K.length===1?"it":K.length}`,body:"Kept under Dismissed, below.",undo:()=>E.undismissJobs(K)})}),W=(B,K)=>D(async()=>{const{jobs:F}=await E.retryJobs({ids:B});if(F.length===0)return;const Q=F.length===1;P({title:`Retrying ${Q?"it":F.length}`,body:K?`${Q?"It runs":"They run"} as soon as a worker is free.`:`If what broke ${Q?"it":"them"} hasn’t changed, ${Q?"it":"they"} will fail the same way.`})});return n.jsxs(An,{embedded:t,title:"Jobs",lede:`${g!=null&&g.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:n.jsx(T,{size:"sm",variant:g!=null&&g.paused?"accent":void 0,onClick:()=>O(E.setPaused(!((g==null?void 0:g.paused)??!1))),children:g!=null&&g.paused?"Resume the queue":"Pause the queue"}),children:[n.jsx(ae,{message:x??j.error??o}),R.length>0?n.jsxs(qe,{flush:!0,title:"Gave up",tool:String(z),actions:z>1?n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>void M("all"),children:"Dismiss all"}):void 0,children:[n.jsx("ul",{className:"al-list",children:R.map(B=>n.jsx(Qk,{group:B,timezone:e,onOpen:l,onRetry:K=>void W(K,B.likelyFixed),onDismiss:K=>void M(K)},B.key))}),n.jsx("p",{className:"al-recap",children:n.jsx("span",{children:"These will not run again on their own. Dismissed jobs stay on record; any failed job older than 14 days is dismissed for you."})})]}):p&&j.data?n.jsx(qe,{flush:!0,children:n.jsxs("div",{className:"al-empty",children:[n.jsx(ue,{name:"check"}),n.jsxs("div",{children:[n.jsx("p",{className:"al-empty-title",children:"No failed job needs you."}),n.jsx("p",{className:"al-empty-line",children:U>0?"The ones you dismissed stay on record, below.":"Every job either ran or is still on its way."})]})]})}):null,U>0||p?n.jsxs("p",{className:"al-quiet jb-quiet",children:[U>0?n.jsxs("button",{type:"button",className:"wb-link","aria-expanded":f,onClick:()=>m(B=>!B),children:[U," dismissed"]}):null,U>0&&p?n.jsx("span",{"aria-hidden":"true",children:"·"}):null,p?n.jsx("button",{type:"button",className:"wb-link",onClick:()=>i(""),children:"Show the whole queue"}):null]}):null,f&&I.length>0?n.jsx(qe,{flush:!0,title:"Dismissed",children:n.jsx("ul",{className:"al-list",children:I.map(B=>n.jsx(Qk,{group:B,timezone:e,dismissed:!0,onOpen:l,onRetry:K=>void W(K,B.likelyFixed)},B.key))})}):null,p?null:n.jsx(qe,{flush:!0,title:"Queue",actions:n.jsxs("select",{"aria-label":"Job state",value:r,onChange:B=>i(B.target.value),children:[n.jsx("option",{value:"",children:"every state"}),Yk.map(B=>n.jsxs("option",{value:B,children:[B," (",S[B]??0,")"]},B))]}),children:!g||k.length===0?n.jsx(xe,{children:"No jobs match."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"State"}),n.jsx("th",{className:"num",children:"Attempts"}),n.jsx("th",{children:"Last error"}),n.jsx("th",{children:"Updated"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:k.map(B=>n.jsxs("tr",{children:[n.jsxs("td",{className:"clickable",onClick:()=>l(B),children:[B.kind,n.jsx("div",{className:"sub mono",children:qo(B.id)})]}),n.jsxs("td",{children:[n.jsx(Ac,{state:B.state}),B.suspendedReason?n.jsx("div",{className:"sub",children:Ds(B.suspendedReason,40)}):null,B.acknowledgedAt?n.jsx("div",{className:"sub",children:"dismissed"}):null]}),n.jsxs("td",{className:"num",children:[B.attempts,"/",B.maxAttempts]}),n.jsx("td",{className:B.lastError?"critical":"muted",children:B.lastError?Ds(B.lastError,80):"—"}),n.jsxs("td",{className:"nowrap",children:[et(B.updatedAt,e),n.jsx("div",{className:"sub",children:Oe(B.updatedAt)})]}),n.jsx("td",{children:n.jsxs(le,{align:"end",children:[["failed","cancelled","suspended"].includes(B.state)?n.jsx(T,{size:"sm",onClick:()=>O(E.retryJob(B.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(B.state)?n.jsx(T,{size:"sm",variant:"danger",onClick:()=>O(E.cancelJob(B.id)),children:"Cancel"}):null]})})]},B.id))})]})}),$&&!p?n.jsxs(le,{children:[n.jsxs("span",{className:"muted",children:[k.length," of ",C," shown."]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(T,{disabled:v.busy,onClick:()=>void y(),children:v.busy?"Loading…":"Load older"})]}):null,a?n.jsxs(ht,{title:a.kind,onClose:()=>l(null),children:[n.jsx("p",{className:"muted mono",children:a.id}),a.lastError?n.jsx(oe,{title:"Last error",children:n.jsx(Pt,{children:a.lastError})}):null,n.jsx(oe,{title:"Payload",children:n.jsx(Pt,{children:Xn(a.payload)})}),n.jsx(oe,{title:"Result",children:n.jsx(Pt,{children:Xn(a.result)})}),a.conversationId?n.jsx("p",{children:n.jsx("a",{href:`#/conversations/${a.conversationId}`,children:"open the transcript"})}):null]}):null,u?n.jsx(Bd,{title:u.title,...u.body?{body:u.body}:{},duration:pH,...u.undo?{onUndo:()=>{const B=u.undo;D(async()=>{await B()})}}:{},onGone:()=>h(null)},u.id):null]})}function qk(e){var s;if(e.missionName)return e.missionName;const t=(s=e.job.payload)==null?void 0:s.prompt;return typeof t=="string"&&t.trim()!==""?Ds(t.trim().split(`
|
|
109
|
+
`)[0],48):e.job.kind==="agent-run"?"Agent run":e.job.kind}function Qk({group:e,timezone:t,dismissed:s,onOpen:r,onRetry:i,onDismiss:a}){var g;const[l,o]=d.useState(!1),c=e.jobs.length>1,u=e.jobs.map(x=>x.job.id),h=e.agents.map(x=>x.name??x.id),f=e.jobs[0],m=e.jobs.every(x=>x.job.acknowledgedBy==="auto"),p=s?m?"dismissed on its own after 14 days":`dismissed ${Oe(((g=e.jobs[0])==null?void 0:g.job.acknowledgedAt)??e.lastAt)}`:`gave up ${Oe(e.lastAt)}`;return n.jsxs("li",{className:"al-row","data-urgent":s?void 0:"true",children:[n.jsxs("div",{className:"al-main",children:[n.jsx("p",{className:"al-title",children:c?`${e.label} · ${e.count}`:e.label}),s?null:n.jsx("p",{className:"al-line",children:e.reason}),n.jsxs("p",{className:"al-sub",children:[h.length>0?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:h.join(", ")}),n.jsx("span",{"aria-hidden":"true",children:"·"})]}):null,!c&&f?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"wb-link",onClick:()=>r(f.job),children:qk(f)}),n.jsx("span",{"aria-hidden":"true",children:"·"})]}):null,n.jsx("span",{title:et(e.lastAt,t),children:p}),c?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("button",{type:"button",className:"wb-link al-toggle","aria-expanded":l,onClick:()=>o(x=>!x),children:l?"Hide":`Show the ${e.count}`})]}):null]}),l&&c?n.jsx("ul",{className:"al-items",children:e.jobs.map(x=>n.jsxs("li",{className:"al-item jb-item",children:[x.agentName||x.agentId?n.jsx("span",{className:"al-item-who",children:x.agentName??x.agentId}):null,n.jsxs("span",{className:"al-item-note",children:[n.jsx("button",{type:"button",className:"wb-link",onClick:()=>r(x.job),children:qk(x)})," · ",Cv(new Date(x.job.updatedAt),t)," · tried ",x.job.attempts," ",gH(x.job.attempts,"time")]}),n.jsxs("span",{className:"jb-item-acts",children:[n.jsx("button",{type:"button",className:"wb-link",onClick:()=>i([x.job.id]),children:"Retry"}),a?n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("button",{type:"button",className:"wb-link",onClick:()=>a([x.job.id]),children:"Dismiss"})]}):null]})]},x.job.id))}):null]}),n.jsxs("div",{className:"al-actions",children:[n.jsx(T,{size:"sm",variant:e.likelyFixed&&!s?"accent":void 0,onClick:()=>i(u),children:c?"Retry all":"Retry"}),a?n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>a(u),children:"Dismiss"}):null]})]})}const vH=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function jH({hash:e,timezone:t,navigate:s,agents:r}){var u,h;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),a=f=>{var m;return((m=r.find(p=>p.id===f))==null?void 0:m.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return n.jsx(bH,{id:f,timezone:t,navigate:s,nameOf:a})}const l=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",o=(h=/[?&]state=([a-z]+)/.exec(e))==null?void 0:h[1],c=f=>m=>{m.preventDefault(),s(f)};return n.jsxs("div",{className:"ui-page",children:[n.jsx(nc,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:n.jsx(SH,{})}),n.jsx(CH,{}),n.jsx(Tc,{children:vH.map(f=>{const m=f.id==="conversations"?vt:`${vt}/${f.id}`;return n.jsx(ll,{href:m,active:l===f.id,onClick:c(m),children:f.label},f.id)})}),l==="conversations"?n.jsx(wH,{timezone:t,navigate:s,nameOf:a,agents:r}):null,l==="jobs"?n.jsx(xH,{timezone:t,embedded:!0,initialState:o},o??""):null,l==="approvals"?n.jsx(yH,{timezone:t,nameOf:a}):null,l==="alerts"?n.jsx(cH,{timezone:t,embedded:!0,agents:r,navigate:s}):null,l==="events"?n.jsx(mH,{timezone:t,embedded:!0}):null]})}function wH({timezone:e,navigate:t,nameOf:s,agents:r}){const{data:i,error:a}=ce(()=>E.conversations(),[],3e4);return n.jsxs(n.Fragment,{children:[n.jsx(ae,{message:a}),n.jsx(qe,{flush:!0,children:i?i.conversations.length===0?n.jsx(jn,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):n.jsx(dt,{children:i.conversations.map(l=>n.jsx(it,{href:il(l.id),onClick:()=>t(il(l.id)),lead:n.jsx(gn,{agents:r,id:l.agentId,size:"sm"}),title:l.opening?Ds(l.opening,100):"Untitled conversation",sub:`${s(l.agentId)}, ${l.messageCount} message${l.messageCount===1?"":"s"}, ${l.runs} run${l.runs===1?"":"s"}, ${tO(l.usage)}`,side:n.jsx("span",{title:et(l.lastMessageAt??l.createdAt,e),children:Oe(l.lastMessageAt??l.createdAt)})},l.id))}):n.jsx(xe,{children:"Loading…"})})]})}function yH({timezone:e,nameOf:t}){const{data:s,error:r}=ce(()=>E.approvals(),[],1e4),i=[...(s==null?void 0:s.pending)??[],...(s==null?void 0:s.recent)??[]];return n.jsxs(n.Fragment,{children:[n.jsx(ae,{message:r}),n.jsx(qe,{flush:!0,children:s?i.length===0?n.jsx(jn,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Tool"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Asked by"}),n.jsx("th",{children:"Decided"}),n.jsx("th",{children:"Created"})]})}),n.jsx("tbody",{children:i.map(a=>n.jsxs("tr",{children:[n.jsxs("td",{children:[a.tool,n.jsx("div",{className:"sub mono",children:qo(a.id)})]}),n.jsx("td",{children:n.jsx(Ac,{state:a.state})}),n.jsx("td",{children:t(a.agentId)}),n.jsx("td",{className:"nowrap",children:a.decidedAt?n.jsxs(n.Fragment,{children:[et(a.decidedAt,e),n.jsxs("div",{className:"sub",children:["via ",a.decidedVia??"—"]})]}):n.jsx("span",{className:"muted",children:"—"})}),n.jsxs("td",{className:"nowrap",children:[et(a.createdAt,e),n.jsx("div",{className:"sub",children:Oe(a.createdAt)})]})]},a.id))})]}):n.jsx(xe,{children:"Loading…"})})]})}function bH({id:e,timezone:t,navigate:s,nameOf:r}){const[i,a]=d.useState(null),[l,o]=d.useState(null);d.useEffect(()=>{let u=!1;return E.conversation(e).then(h=>{u||a(h)}).catch(h=>{u||o(h instanceof Error?h.message:String(h))}),()=>{u=!0}},[e]);const c=u=>h=>{h.preventDefault(),s(u)};return n.jsxs("div",{className:"ui-page",children:[n.jsx("p",{className:"page-crumbs",children:n.jsx("a",{href:vt,onClick:c(vt),children:"Activity"})}),n.jsxs("header",{className:"ui-page-head",children:[n.jsxs("div",{className:"ui-page-head-row",children:[n.jsxs("h2",{className:"ui-page-title",children:[n.jsx(T,{size:"sm",onClick:()=>s(vt),children:"← Back"}),n.jsx("span",{children:"Transcript"})]}),i?n.jsx("div",{className:"ui-page-actions",children:n.jsx(Tt,{size:"sm",href:at(i.agentId,e),onClick:c(at(i.agentId,e)),children:"Open in chat"})}):null]}),n.jsx("p",{className:"ui-page-lede mono",children:e})]}),n.jsx(ae,{message:l}),i?n.jsxs(n.Fragment,{children:[n.jsxs(qh,{children:[n.jsx(tr,{label:"Agent",value:r(i.agentId),size:"sm"}),n.jsx(tr,{label:"Runs",value:i.runs.length}),n.jsx(tr,{label:"Tokens",value:`${Gt(i.usage.input)} / ${Gt(i.usage.output)}`,note:Gp(i.usage)?`input / output, ${Gp(i.usage)}`:"input / output"}),n.jsx(tr,{label:"Started",value:et(i.createdAt,t),size:"sm"})]}),i.runs.length>0?n.jsx(qe,{title:"Runs",flush:!0,children:n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Started"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{className:"num",children:"Turns"}),n.jsx("th",{children:"Stopped"}),n.jsx("th",{className:"num",children:"Tokens"}),n.jsx("th",{className:"num",children:"Cached"})]})}),n.jsx("tbody",{children:i.runs.map((u,h)=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[et(u.startedAt,t)," ",u.resumed?n.jsx(ve,{children:"resumed"}):null]}),n.jsx("td",{className:"nowrap",children:et(u.finishedAt,t)}),n.jsx("td",{className:"num",children:u.turns??"—"}),n.jsxs("td",{children:[u.stopped??"—",u.actionId?n.jsxs("div",{className:"sub mono",children:["action ",qo(u.actionId)]}):null]}),n.jsxs("td",{className:"num muted nowrap",children:[Gt(u.usage.input)," / ",Gt(u.usage.output)]}),n.jsx("td",{className:"num muted nowrap",children:u.usage.cacheRead||u.usage.cacheWrite?Gt((u.usage.cacheRead??0)+(u.usage.cacheWrite??0)):"—"})]},h))})]})}):null,n.jsx(oe,{title:"Messages",children:n.jsx(re,{children:i.messages.map(u=>n.jsxs("article",{className:"transcript-msg",children:[n.jsxs("header",{className:"transcript-who",children:[u.speaker===Xk?"approved action, result":u.role,", ",et(u.createdAt,t)]}),n.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?n.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===Xk?u.blocks.map((h,f)=>n.jsx(kH,{block:h},f)):u.blocks.map((h,f)=>n.jsx(NH,{block:h},f))]})]},u.id))})})]}):n.jsx(xe,{children:"Loading…"})]})}const Xk="approval:resume";function kH({block:e}){return n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),n.jsx(Pt,{children:e.type==="text"?e.text??"":Xn(e)})]})}function NH({block:e}){return e.type==="text"?n.jsx("div",{className:"transcript-text",children:n.jsx(Lr,{text:e.text??""})}):e.type==="thinking"?n.jsxs("details",{className:"transcript-thinking",children:[n.jsx("summary",{children:"Thoughts"}),n.jsx("div",{className:"transcript-thinking-text",children:n.jsx(Lr,{text:e.text??""})})]}):e.type==="tool_use"?n.jsxs("div",{className:"transcript-tool",children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),n.jsx(Pt,{children:Xn(e.input)})]}):e.type==="tool_result"?n.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[n.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),n.jsx(Pt,{children:e.content??""})]}):n.jsxs("div",{className:"transcript-tool",children:[n.jsx("div",{className:"transcript-tool-name mono",children:e.type}),n.jsx(Pt,{children:Xn(e.ref)})]})}function SH(){const{data:e,reload:t}=ce(()=>E.overview(),[],1e4),[s,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),E.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return n.jsx(T,{size:"sm",variant:e.paused?"accent":void 0,disabled:s,onClick:i,children:e.paused?"Resume all":"Pause all"})}function CH(){const{data:e,reload:t}=ce(()=>E.overview(),[],1e4);if(d.useEffect(()=>(window.addEventListener(Bi,t),()=>window.removeEventListener(Bi,t)),[t]),!e)return null;const s=i=>e.jobs[i]??0,r=s("leased");return n.jsxs(qh,{children:[n.jsx(tr,{label:"Jobs done",value:Gt(s("succeeded"))}),n.jsx(tr,{label:"Failed",value:Gt(s("failed")),...s("failed")>0?{tone:"critical"}:{}}),n.jsx(tr,{label:"Queued",value:Gt(s("pending")),note:`${r} running`}),n.jsx(tr,{label:"Approvals",value:Gt(e.approvals.pending),note:"waiting for you"})]})}const EH=["replay-all","coalesce","latest-only","skip-after-deadline"];function pT({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=ce(()=>E.missions(),[],3e4),l=((r==null?void 0:r.missions)??[]).filter(h=>!s||h.agentId===s),[o,c]=d.useState(null),u=async h=>{c(null);try{await h,a()}catch(f){c(f instanceof Error?f.message:String(f))}};return n.jsxs(An,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[n.jsx(ae,{message:i??o}),!r||l.length===0?n.jsxs(jn,{icon:"calendar",title:"No missions yet",children:["Run ",n.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):n.jsx(re,{children:l.map(h=>n.jsx(AH,{mission:h,timezone:e,onRun:u},h.id))})]})}function AH({mission:e,timezone:t,onRun:s}){const[r,i]=d.useState(!1);return n.jsxs(ws,{tone:e.enabled&&!e.pausedReason?"good":"muted",title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"mono muted",children:e.id})]}),meta:n.jsxs(n.Fragment,{children:[n.jsx(ve,{mono:!0,children:e.agentId}),e.alwaysDeliver?n.jsx(ve,{children:"always delivers"}):null,e.enabled?null:n.jsx(ve,{tone:"warning",children:"disabled"}),e.pausedReason?n.jsx(ve,{tone:"warning",children:e.pausedReason}):null]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",onClick:()=>s(E.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>i(a=>!a),"aria-expanded":r,children:r?"Less":"More"})]}),children:[n.jsxs("p",{className:"ui-card-meta",children:[e.schedule?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${et(e.nextRun,t)} (${Oe(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",n.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Oe(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?n.jsxs("div",{className:"ui-card-foot",children:[e.schedule?n.jsxs(le,{children:[n.jsx(ie,{inline:!0,label:"Misfire policy",children:n.jsx("select",{value:e.schedule.misfirePolicy,onChange:a=>s(E.setMisfirePolicy(e.id,a.target.value)),children:EH.map(a=>n.jsx("option",{value:a,children:a},a))})}),n.jsx("span",{className:"muted",children:"What a week asleep does: replay every instant, coalesce into one, keep only the latest, or skip past a deadline."})]}):null,n.jsx(oe,{title:"Prompt",children:n.jsx(Pt,{children:e.prompt})}),n.jsx(oe,{title:"Recent occurrences",children:n.jsx(qe,{flush:!0,children:e.occurrences.length===0?n.jsx(xe,{children:"Never run."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Scheduled"}),n.jsx("th",{children:"State"}),n.jsx("th",{children:"Finished"}),n.jsx("th",{children:"Detail"})]})}),n.jsx("tbody",{children:e.occurrences.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"nowrap",children:et(a.scheduledAt,t)}),n.jsx("td",{children:n.jsx(Ac,{state:a.state})}),n.jsx("td",{className:"nowrap",children:et(a.finishedAt,t)}),n.jsxs("td",{className:a.error?"critical":"muted",children:[a.error?Ds(a.error,120):null,a.runConversationId?n.jsx("a",{href:`#/conversations/${a.runConversationId}`,children:"transcript"}):null]})]},a.id))})]})})})]}):null]})}function TH(e,t){const s=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${s}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function gT({ids:e,agentName:t,onDone:s}){const r=e.length,[i,a]=d.useState(!1),[l,o]=d.useState(!1);return r<=0?null:i?n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:TH(r,t)}),n.jsx(T,{size:"sm",variant:"danger",disabled:l,onClick:()=>{o(!0),E.dismissOffers(e).then(()=>{a(!1),s()}).finally(()=>o(!1))},children:`Dismiss ${r}`}),n.jsx(T,{size:"sm",variant:"ghost",disabled:l,onClick:()=>a(!1),children:"Keep them"})]}):n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>a(!0),children:"Dismiss all"})}function xT({embedded:e,agentId:t,agentName:s}){const{data:r,error:i,reload:a}=ce(()=>E.offers(),[],2e4),l=j=>!t||j.agentId===t,o=((r==null?void 0:r.offers)??[]).filter(l),c=((r==null?void 0:r.closed)??[]).filter(l),[u,h]=d.useState(null),[f,m]=d.useState(null),[p,g]=d.useState(null),x=async(j,v)=>{h(null),m(j);try{const w=await E.takeOffer(j);g(w.jobId?`On it — ${v}. Started as job ${w.jobId}.`:`Taken — ${v}. No worker is running here, so nothing has started yet.`),a()}catch(w){h(w instanceof Error?w.message:String(w))}finally{m(null)}},b=async(j,v)=>{h(null),m(j);try{await E.dismissOffer(j),g(`Dismissed — ${v}. It will not come back.`),a()}catch(w){h(w instanceof Error?w.message:String(w))}finally{m(null)}};return n.jsxs(An,{embedded:e,title:"Offers",lede:"Things an agent already worked out that you might want done. Taking one asks that agent the sentence it wrote. It authorizes nothing, and anything that would leave this machine still comes back to you as an approval.",children:[n.jsx(ae,{message:i??u}),p?n.jsx(V,{tone:"good",role:"status",children:p}):null,o.length>0?n.jsxs(le,{children:[n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(gT,{ids:o.map(j=>j.id),agentName:s,onDone:()=>{g(null),a()}})]}):null,!r||o.length===0?n.jsx(jn,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):n.jsx(re,{children:o.map(j=>n.jsx(ws,{tone:"accent",title:j.label,meta:n.jsxs(n.Fragment,{children:[n.jsx(ve,{mono:!0,children:j.agentId}),n.jsxs("span",{className:"muted",children:["expires ",Oe(j.expiresAt)]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",variant:"ghost",disabled:f===j.id,onClick:()=>void b(j.id,j.label),children:"Not now"}),n.jsx(T,{variant:"accent",size:"sm",disabled:f===j.id,onClick:()=>void x(j.id,j.label),children:"Take"})]}),children:n.jsx("p",{className:"ui-card-meta",children:j.prompt})},j.id))}),c.length>0?n.jsxs(St,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[n.jsx(qe,{flush:!0,children:n.jsx(dt,{children:c.map(j=>n.jsx(it,{title:j.label,sub:`${j.agentId} — ${iO(j)}`,side:Oe(j.dismissedAt??j.lapsedAt??j.createdAt)},j.id))})}),n.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const RH="Add a teammate",$H="Each one keeps its own memory and tools, and can work on a schedule. Add the ones you want; Agent Father can make others.",IH="front-desk";function vT(e,t){return e.length>0&&e.every(s=>s.id===t||s.roles.includes(IH)||s.roles.includes(Bh))}const PH={plugins:{label:"Plugins",route:De("plugins")},mailbox:{label:"Add a mailbox",route:gi("email","settings")},accounts:{label:"Accounts",route:De("accounts")}},MH="Your starter team is complete. Agent Father can make others.";function Yg({navigate:e,standing:t=!1}){var h;const s=ce(()=>E.teammates(),[]),[r,i]=d.useState(new Set),a=(((h=s.data)==null?void 0:h.teammates)??[]).filter(f=>!r.has(`${f.plugin}/${f.agent}`));if(a.length===0)return null;const l=f=>{i(m=>new Set(m).add(`${f.plugin}/${f.agent}`)),E.dismissAgentOffer(f.plugin,f.agent).then(s.reload,s.reload)},o=f=>m=>{m.preventDefault(),e(f)},c=t?a.filter(f=>f.state!=="added"):a,u=t?a.filter(f=>f.state==="added"):[];return n.jsx(oe,{title:RH,children:c.length===0?n.jsx("p",{className:"teammates-lede","data-testid":"teammates-complete",children:MH}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"teammates-lede",children:$H}),n.jsx("div",{className:"teammates-grid","data-testid":"teammates",children:c.map(f=>n.jsx(DH,{row:f,navigate:e,onDismiss:()=>l(f)},`${f.plugin}/${f.agent}`))}),u.length>0?n.jsx("ul",{className:"teammates-added","data-testid":"teammates-added",children:u.map(f=>n.jsx("li",{children:n.jsxs("a",{className:"teammates-added-chip",href:At(f.agent),onClick:o(At(f.agent)),children:["Added · open @",f.handle]})},`${f.plugin}/${f.agent}`))}):null]})})}function DH({row:e,navigate:t,onDismiss:s}){const r=jj(e.plugin,e.agent),i=c=>u=>{u.preventDefault(),t(c)},a=r.created??(e.state==="added"?{id:e.agent,handle:e.handle,name:e.name}:null),l=a?"added":e.state,o=e.fix?PH[e.fix]:null;return n.jsx("div",{className:"teammate","data-state":l,"data-testid":`teammate-${e.agent}`,children:n.jsxs(ws,{title:e.name,actions:n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Dismiss ${e.name}`,title:"Not now",onClick:s,children:n.jsx(ue,{name:"close"})}),foot:n.jsxs(n.Fragment,{children:[n.jsxs(le,{children:[l==="unavailable"?n.jsx("span",{className:"teammate-reason",children:e.reason}):null,n.jsx(_t,{}),a?n.jsxs("a",{href:At(a.id),onClick:i(At(a.id)),children:["Added, open @",a.handle]}):l==="unavailable"?o?n.jsx("a",{href:o.route,onClick:i(o.route),children:o.label}):null:n.jsx(T,{variant:"accent",size:"sm",disabled:r.busy,onClick:r.accept,"aria-label":`Add ${e.name}`,children:"Add"})]}),n.jsx(ae,{message:r.failure})]}),children:[n.jsx("p",{className:"ui-card-meta",children:e.text}),n.jsx("p",{className:"teammate-needs",children:e.needs})]})})}const OH=["fact","observation","todo"];function jT({embedded:e,agents:t,timezone:s,agentId:r}){const{data:i,error:a,reload:l}=ce(()=>E.memory(r),[r],3e4),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState(null),p=y=>{var N;return y==="shared"?"Everyone":((N=t.find(k=>k.id===y))==null?void 0:N.name)??y},g=async y=>{m(null);try{await y,l()}catch(N){m(N instanceof me?N.message:String(N))}},x={nameOf:p,timezone:s,onChangePreference:y=>c({key:y.key,scope:y.scope}),onForgetPreference:y=>void g(E.forgetPreference({key:y.key,scope:y.scope})),onEditNote:y=>h(y),onForgetNote:y=>void g(E.forgetNote(y.id))},b=r?p(r):"",j=r&&i?{preferences:i.preferences.filter(y=>y.scope===r),notes:i.notes.filter(y=>y.scope===r)}:null,v=r&&i?{preferences:i.preferences.filter(y=>y.scope==="shared"),notes:i.notes.filter(y=>y.scope==="shared")}:null,w=n.jsx(T,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return n.jsxs(An,{embedded:e,title:"Memory",lede:"What your agents have kept about you. Correct anything here; they see the change on their next turn.",children:[n.jsx(ae,{message:a??f}),j&&v?n.jsxs(re,{gap:"lg",children:[n.jsx(oe,{title:"Preferences",aside:`what you told ${b} alone`,actions:w,panel:!0,flush:!0,children:n.jsx(Nm,{preferences:j.preferences,empty:`Nothing stated to ${b} alone yet.`,...x})}),n.jsx(oe,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:n.jsx(Sm,{notes:j.notes,empty:`${b} has kept no private notes yet.`,...x})}),n.jsx(St,{summary:`Shared with every agent, which ${b} also reads · ${v.preferences.length} preferences, ${v.notes.length} notes`,children:n.jsxs(re,{gap:"lg",children:[n.jsx(oe,{title:"Shared preferences",panel:!0,flush:!0,children:n.jsx(Nm,{preferences:v.preferences,empty:"No shared preferences.",...x})}),n.jsx(oe,{title:"Shared notes",panel:!0,flush:!0,children:n.jsx(Sm,{notes:v.notes,empty:"No shared notes.",...x})})]})})]}):n.jsxs(re,{gap:"lg",children:[n.jsx(oe,{title:"Preferences",aside:"what you said you want, one current value each",actions:w,panel:!0,flush:!0,children:i?n.jsx(Nm,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...x}):n.jsx(xe,{children:"Loading…"})}),n.jsx(oe,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?n.jsx(Sm,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...x}):n.jsx(xe,{children:"Loading…"})})]}),o?n.jsx(LH,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:o,onClose:()=>c(null),onSave:async y=>{await g((async()=>{await E.setPreference(y),o.key===y.key&&o.scope!==y.scope&&await E.forgetPreference({key:o.key,scope:o.scope})})()),c(null)}}):null,u?n.jsx(_H,{note:u,agents:t,onClose:()=>h(null),onSave:y=>g(E.updateNote(u.id,y)).then(()=>h(null))}):null]})}function Nm({preferences:e,empty:t,nameOf:s,onChangePreference:r,onForgetPreference:i}){return e.length===0?n.jsx(xe,{children:t}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Preference"}),n.jsx("th",{children:"Value"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{className:"num",children:"Since"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:a.key}),n.jsx("td",{children:a.value}),n.jsx("td",{children:n.jsx(wT,{scope:a.scope,name:s(a.scope)})}),n.jsxs("td",{className:"num muted",title:a.updatedAt??"",children:[a.updatedAt?Oe(a.updatedAt,Date.now()):"",a.revision>1?` · rev ${a.revision}`:""]}),n.jsx("td",{className:"num",children:n.jsxs(le,{align:"end",children:[n.jsx(T,{size:"sm",onClick:()=>r(a),title:"Store a new value for this key",children:"Change"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>i(a),children:"Forget"})]})})]},`${a.scope}:${a.key}`))})]})}function Sm({notes:e,empty:t,nameOf:s,timezone:r,onEditNote:i,onForgetNote:a}){return e.length===0?n.jsx(xe,{children:t}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Note"}),n.jsx("th",{children:"Kind"}),n.jsx("th",{children:"Who sees it"}),n.jsx("th",{children:"Written by"}),n.jsx("th",{className:"num",children:"When"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:e.map(l=>n.jsxs("tr",{children:[n.jsx("td",{className:"memory-note",children:l.content}),n.jsx("td",{children:n.jsx(ve,{tone:l.kind==="todo"?"warning":l.kind==="fact"?"good":void 0,children:l.kind})}),n.jsx("td",{children:n.jsx(wT,{scope:l.scope,name:s(l.scope)})}),n.jsx("td",{className:"muted",children:l.createdByAgent?s(l.createdByAgent):""}),n.jsxs("td",{className:"num muted",title:l.createdAt??"",children:[l.createdAt?Oe(l.createdAt,Date.now()):"",l.expiresAt?n.jsxs("span",{className:"memory-expires",children:[" · until ",dr(new Date(l.expiresAt),r,{year:!0,compact:!0})]}):null]}),n.jsx("td",{className:"num",children:n.jsxs(le,{align:"end",children:[n.jsx(T,{size:"sm",onClick:()=>i(l),children:"Edit"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>a(l),children:"Forget"})]})})]},l.id))})]})}function wT({scope:e,name:t}){return n.jsx(ve,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function yT({value:e,agents:t,onChange:s}){return n.jsxs("select",{value:e,onChange:r=>s(r.target.value),children:[n.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>n.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function LH({agents:e,existing:t,initial:s,onClose:r,onSave:i}){const a=t.find(v=>v.key===s.key&&v.scope===s.scope),[l,o]=d.useState(s.key),[c,u]=d.useState((a==null?void 0:a.value)??""),[h,f]=d.useState(s.scope),[m,p]=d.useState(!1),g=l.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),x=t.find(v=>v.key===g&&v.scope===h),b=!a||g!==a.key||c.trim()!==a.value||h!==a.scope,j=g!==""&&c.trim()!==""&&b;return n.jsx(ht,{title:"A preference",onClose:r,children:n.jsxs(re,{children:[n.jsx(V,{children:'A preference is a standing choice, in your words: "paid biweekly on Thursdays", "answers short, numbers first". Storing the same key again records a correction and keeps the old value in the history.'}),n.jsx(ie,{label:"Key",hint:g&&g!==l?`Stored as ${g}`:"Short and stable, like reporting_currency or tone.",children:n.jsx("input",{value:l,autoFocus:s.key==="",onChange:v=>o(v.target.value),placeholder:"reporting_currency"})}),n.jsx(ie,{label:"Value",children:n.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:s.key!=="",onChange:v=>u(v.target.value),placeholder:"EUR"})}),n.jsx(ie,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:n.jsx(yT,{value:h,agents:e,onChange:f})}),x&&x!==a?n.jsxs(V,{tone:"warning",children:['This replaces the value already stored for this key here, "',x.value,'" (revision ',x.revision,")."]}):null,a&&h!==a.scope?n.jsxs(V,{children:["It moves: the copy for ",a.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:r,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!j||m,onClick:()=>{p(!0),i({key:g,value:c.trim(),scope:h}).finally(()=>p(!1))},children:a?"Save change":"Save"})]})]})})}function _H({note:e,agents:t,onClose:s,onSave:r}){var p;const[i,a]=d.useState(e.content),[l,o]=d.useState(e.scope),[c,u]=d.useState(e.kind),[h,f]=d.useState(!1),m=i.trim()!==e.content||l!==e.scope||c!==e.kind;return n.jsx(ht,{title:"A note",onClose:s,children:n.jsxs(re,{children:[n.jsx(ie,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:n.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:g=>a(g.target.value)})}),n.jsxs(Os,{children:[n.jsx(ie,{label:"Kind",children:n.jsx("select",{value:c,onChange:g=>u(g.target.value),children:OH.map(g=>n.jsx("option",{value:g,children:g},g))})}),n.jsx(ie,{label:"Who sees it",children:n.jsx(yT,{value:l,agents:t,onChange:o})})]}),e.createdByAgent?n.jsxs("p",{className:"muted",children:["Written by ",((p=t.find(g=>g.id===e.createdByAgent))==null?void 0:p.name)??e.createdByAgent,e.createdAt?`, ${Oe(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:s,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!m||i.trim()===""||h,onClick:()=>{f(!0);const g={};i.trim()!==e.content&&(g.content=i.trim()),l!==e.scope&&(g.scope=l),c!==e.kind&&(g.kind=c),r(g).finally(()=>f(!1))},children:"Save"})]})]})})}function FH({agentId:e,agentName:t}){const{data:s,error:r,reload:i}=ce(()=>E.agentSkills(e),[e],3e4),[a,l]=d.useState(null),[o,c]=d.useState(null),[u,h]=d.useState(null),f=async g=>{l(null),c(null),h(g.name);try{const x=await E.removeSkill(e,g.name);c(`Removed ${x.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(x){l(x instanceof me?x.message:String(x))}finally{h(null)}};if(!s)return r?n.jsx(ae,{message:r}):n.jsx(xe,{children:"Loading…"});const m=s.skills.filter(g=>g.learned!==null),p=s.skills.filter(g=>g.learned===null);return n.jsxs(re,{divided:!0,children:[n.jsx(ae,{message:r??a}),o?n.jsx(V,{tone:"good",role:"status",children:o}):null,n.jsx(oe,{title:"Learned",aside:n.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:m.length===0?n.jsx(jn,{icon:"bulb",title:"Nothing learned yet",children:s.writable?`When ${t} proposes a procedure and you keep it on Settings → Proposals, it appears here.`:`${t} ships with buddi, so it keeps no learned skills of its own until it is yours.`}):n.jsx(qe,{flush:!0,children:n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"Version"}),n.jsx("th",{children:"Came from"}),n.jsx("th",{className:"num",children:"Kept"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:m.map(g=>n.jsx(UH,{skill:g,busy:u===g.name,onRemove:()=>void f(g)},g.name))})]})})}),n.jsx(oe,{title:"From files and plugins",aside:n.jsx("span",{className:"muted",children:"read-only here"}),children:p.length===0?n.jsx(xe,{children:"No other skills."}):n.jsx(qe,{flush:!0,children:n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Skill"}),n.jsx("th",{children:"What it is for"}),n.jsx("th",{children:"Whose"})]})}),n.jsx("tbody",{children:p.map(g=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(St,{summary:n.jsx("span",{className:"mono",children:g.name}),children:[n.jsx(Pt,{children:g.body}),n.jsx("p",{className:"muted mono skill-file",children:g.file})]})}),n.jsx("td",{children:g.description}),n.jsx("td",{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ve,{children:g.scope==="shared"?"shared":`${t} only`}),n.jsx("span",{className:"muted",children:zH(g)})]})})]},`${g.scope}:${g.name}`))})]})})})]})}function zH(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function UH({skill:e,busy:t,onRemove:s}){const r=e.learned;return n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs(St,{summary:n.jsxs("span",{children:[r.title," ",n.jsx("span",{className:"muted mono",children:e.name})]}),children:[n.jsxs("p",{className:"muted",children:["When: ",e.description]}),n.jsx(Pt,{children:e.body}),n.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),n.jsx("td",{children:n.jsxs(re,{gap:"sm",children:[n.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?n.jsx(ve,{tone:"warning",children:"untrusted text in view"}):null]})}),n.jsx("td",{children:n.jsxs(re,{gap:"sm",children:[r.conversation?n.jsx("a",{href:il(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):n.jsx("span",{className:"muted",children:"no conversation"}),n.jsx("a",{href:De("proposals"),children:"the proposal"}),r.sources.length>0?n.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>n.jsx("li",{className:"mono",children:i},i))}):null]})}),n.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Oe(r.keptAt,Date.now()):""}),n.jsx("td",{className:"num",children:n.jsx(le,{align:"end",children:n.jsx(T,{size:"sm",variant:"ghost",disabled:t,onClick:s,children:"Remove"})})})]})}function bT({timezone:e,embedded:t,agentId:s}){const{data:r,error:i,reload:a}=ce(()=>E.reminders(),[],3e4),l=((r==null?void 0:r.reminders)??[]).filter(h=>!s||h.agentId===s),[o,c]=d.useState(null),u=async h=>{c(null);try{await E.cancelReminder(h),a()}catch(f){c(f instanceof Error?f.message:String(f))}};return n.jsxs(An,{embedded:t,title:"Reminders",lede:"A reminder wakes an agent with a note and the instruction to check before it speaks, never a message queued for delivery.",children:[n.jsx(ae,{message:i??o}),n.jsx(qe,{flush:!0,children:r?l.length===0?n.jsx(jn,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Due"}),n.jsx("th",{children:"Agent"}),n.jsx("th",{children:"Note"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:l.map(h=>n.jsxs("tr",{children:[n.jsxs("td",{className:"nowrap",children:[et(h.dueAt,e),n.jsx("div",{className:"sub",children:Oe(h.dueAt)})]}),n.jsx("td",{className:"mono",children:h.agentId}),n.jsxs("td",{children:[h.text,h.context?n.jsx(St,{summary:"context",children:n.jsx(Pt,{children:Xn(h.context)})}):null]}),n.jsxs("td",{children:[n.jsx(Ac,{state:h.state}),h.cancelReason?n.jsx("div",{className:"sub",children:h.cancelReason}):null]}),n.jsx("td",{children:h.state==="pending"?n.jsx(T,{size:"sm",variant:"danger",onClick:()=>u(h.id),children:"Cancel"}):null})]},h.id))})]}):n.jsx(xe,{children:"Loading…"})})]})}const BH=/(flux|klein|schnell|qwen[-_]?image|image)/i;function kT(e){return e.kind==="image"||e.kind===void 0&&BH.test(e.id)}function WH(e){const t=((e==null?void 0:e.models)??[]).filter(s=>!kT(s));return[...t.filter(s=>s.loaded),...t.filter(s=>!s.loaded)].map(s=>s.id)}function qg(e){return WH(e)[0]}function Dj(e){return(e==null?void 0:e.detectedContextWindowSource)==="mlxh"}function HH(e){return(e??0)<40960?"mlxh’s max_prompt_tokens; raise it with `mlxh config max_prompt_tokens 40960` for long conversations":"mlxh’s max_prompt_tokens"}function NT(e){let t=e;try{t=new URL(e).host}catch{}return`mlxh is not answering on ${t}. Start it with \`mlxh serve\`, or \`mlxh service install\` to keep it running.`}const ST="an image model; pick it in the Image plugin, not here";function Oj({accountId:e,label:t,value:s,onChange:r,disabled:i=!1}){const[a,l]=d.useState(null),[o,c]=d.useState(!1),[u,h]=d.useState(""),[f,m]=d.useState(!1),p=d.useRef(0),g=async v=>{if(!e)return;const w=++p.current;c(!0),h("");try{const y=await E.accountModels(e,v);w===p.current&&l(y)}catch(y){w===p.current&&h(y instanceof Error?y.message:"Could not load models. Custom entry is still available.")}finally{w===p.current&&c(!1)}};if(d.useEffect(()=>(l(null),m(!1),h(""),g(!1),()=>{p.current++}),[e]),!e)return n.jsxs(n.Fragment,{children:[n.jsx(ie,{label:t,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:v=>r(v.target.value)})}),n.jsx("p",{className:"ui-toolbar-note",children:"Save and connect the account to load its model list. You can enter a model manually now."})]});const x=(a==null?void 0:a.models)??[],b=!!s&&!x.some(v=>v.id===s),j=[a&&!x.length?"This account returned no models. You can enter a custom model.":null,a!=null&&a.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,a?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return n.jsxs(n.Fragment,{children:[n.jsx(ie,{label:t,children:n.jsxs("select",{value:f?"__buddi_custom__":s,disabled:i,onChange:v=>{v.target.value==="__buddi_custom__"?m(!0):(m(!1),r(v.target.value))},children:[n.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&n.jsxs("option",{value:s,children:[s," (current",a?", not listed":"",")"]}),x.map(v=>n.jsxs("option",{value:v.id,children:[v.name===v.id?v.id:`${v.name} — ${v.id}`,v.isDefault?" (provider default)":"",v.image?` — ${ST}`:""]},v.id)),n.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),n.jsx(T,{disabled:i||o,onClick:()=>void g(!0),children:o?"Loading models…":"Refresh models"}),f&&n.jsx(ie,{label:`Custom ${t.toLowerCase()}`,children:n.jsx("input",{required:!0,maxLength:150,value:s,disabled:i,onChange:v=>r(v.target.value)})}),u&&n.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),j.length>0&&n.jsx("p",{className:"ui-toolbar-note",children:j.join(" ")})]})}function KH(e,t){const s=new Set(t),r=[],i=new Set;for(const a of e){for(const o of a.tools)i.add(o.name);const l=a.tools.filter(o=>s.has(o.name));l.length!==0&&(a.glob&&l.length===a.tools.length?r.push(a.glob):r.push(...l.map(o=>o.name)))}return r.push(...t.filter(a=>!i.has(a))),r}function VH(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const GH="This agent will not remember anything between conversations.";function YH({view:e,chosen:t,onChange:s,disabled:r}){var N;const[i,a]=d.useState(""),[l,o]=d.useState(null),[c,u]=d.useState(()=>new Set),h=k=>u(S=>{const C=new Set(S);return C.has(k)?C.delete(k):C.add(k),C}),f=k=>{a(k),u(new Set)},m=d.useId(),p=new Set(t),g=new Set(e.groups.flatMap(k=>k.tools.filter(S=>S.core).map(S=>S.name))),x=(k,S)=>{const C=S.filter($=>p.has($));if(C.length!==0){if(C.some($=>g.has($))){o({plugin:k,names:C});return}s(t.filter($=>!C.includes($)))}},b=k=>{s([...t,...k.filter(S=>!p.has(S))])},j=i.trim().toLowerCase(),v=(k,S)=>j===""||k.toLowerCase().includes(j)||S.toLowerCase().includes(j),w=e.groups.map(k=>({group:k,tools:k.tools.filter(S=>v(S.name,S.description))})).filter(k=>k.tools.length>0),y=(((N=e.suggested)==null?void 0:N.tools)??[]).filter(k=>!p.has(k.name));return n.jsxs("div",{className:"tool-picker",children:[e.suggested&&y.length>0?n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${m}-suggested`,children:[n.jsx("div",{className:"tool-picker-head",children:n.jsx("span",{id:`${m}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),n.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:y.map(k=>n.jsxs("li",{className:"ui-list-row",children:[n.jsxs("span",{className:"ui-list-main",children:[n.jsx("span",{className:"ui-list-title mono",children:k.name}),n.jsx("span",{className:"ui-list-sub",children:k.description})]}),n.jsx(T,{size:"sm",disabled:r,"aria-label":`Add ${k.name}`,onClick:()=>b([k.name]),children:"Add"})]},k.name))})]}):null,n.jsxs("label",{className:"tool-picker-search",children:[n.jsx("span",{className:"ui-field-label",children:"Find a tool"}),n.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:k=>f(k.target.value)})]}),w.length===0?n.jsxs(xe,{children:["No installed tool matches “",i.trim(),"”."]}):null,w.map(({group:k,tools:S})=>{const C=k.tools.filter(A=>A.grantable).map(A=>A.name),$=k.tools.filter(A=>p.has(A.name)).length,R=!!k.glob&&$===k.tools.length,I=`${m}-${k.plugin}`,z=`${m}-${k.plugin}-list`,U=j!==""?!c.has(k.plugin):c.has(k.plugin);return n.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":I,"data-open":U?"true":void 0,children:[n.jsxs("div",{className:"tool-picker-head",children:[n.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":U,"aria-controls":z,onClick:()=>h(k.plugin),children:[n.jsx(qH,{}),n.jsx("span",{id:I,className:"tool-picker-plugin",children:k.plugin}),n.jsx("span",{className:"muted",children:R?`all ${k.tools.length}`:`${$} of ${k.tools.length} granted`})]}),n.jsx(T,{size:"sm",variant:"ghost","aria-label":`All ${k.plugin} tools`,disabled:r||C.every(A=>p.has(A)),onClick:()=>b(C),children:"all"}),n.jsx(T,{size:"sm",variant:"ghost","aria-label":`No ${k.plugin} tools`,disabled:r||!C.some(A=>p.has(A)),onClick:()=>x(k.plugin,C),children:"none"})]}),(l==null?void 0:l.plugin)===k.plugin?n.jsx(V,{tone:"warning",role:"alert",children:n.jsxs("div",{className:"tool-picker-confirm",children:[n.jsx("span",{children:GH}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(T,{size:"sm",onClick:()=>o(null),children:"Keep"}),n.jsx(T,{size:"sm",variant:"danger",onClick:()=>{s(t.filter(A=>!l.names.includes(A))),o(null)},children:"Remove"})]})}):null,n.jsx("ul",{id:z,className:"ui-list tool-picker-list",hidden:!U,children:S.map(A=>{const P=`${m}-${A.name}`;return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:P,checked:p.has(A.name),disabled:r||!A.grantable,onChange:D=>D.target.checked?b([A.name]):x(k.plugin,[A.name])}),n.jsxs("label",{htmlFor:P,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[n.jsx("span",{className:"mono",children:A.name}),A.core?n.jsx(ve,{tone:"accent",children:"core"}):null,A.gated?n.jsx(ve,{tone:"warning",children:"asks you"}):null]}),n.jsx("span",{className:"ui-list-sub",children:A.grantable?A.description:`${A.description} Granted only by editing the file by hand.`})]})]},A.name)})})]},k.plugin)})]})}function qH(){return n.jsx("svg",{className:"tool-picker-chevron",viewBox:"0 0 11 11","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const ls={json:"That is not JSON. Paste the whole block, braces included.",empty:"There is no server in it.",command:'It starts a program on this computer rather than naming an address. Use "A program on this computer" instead.',sse:"buddi speaks Streamable HTTP; this server is SSE-only.",url:"It has no url. buddi connects to a server by its https:// address."},Jr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function CT(e){let t;try{t=JSON.parse(e.trim())}catch{throw new Error(ls.json)}if(!Jr(t))throw new Error(ls.json);let s,r=t;if("mcpServers"in t){const u=t.mcpServers;if(!Jr(u))throw new Error(ls.empty);const h=Object.keys(u);if(h.length===0)throw new Error(ls.empty);if(h.length>1)throw new Error(`It names ${h.length} servers (${h.join(", ")}). Paste one at a time.`);s=h[0];const f=u[s];if(!Jr(f))throw new Error(ls.url);r=f}if("command"in r)throw new Error(ls.command);if(typeof r.type=="string"&&r.type.toLowerCase()==="sse")throw new Error(ls.sse);const i=typeof r.url=="string"?r.url.trim():"";if(i==="")throw new Error(ls.url);const a=Jr(r.headers)?Object.entries(r.headers).filter(u=>typeof u[1]=="string"&&u[0].trim()!==""):[],l=a.find(([u])=>u.toLowerCase()==="authorization")??a[0];let o,c=!1;if(l){const[u,h]=l,f=/^(Bearer|Basic)\s+/i.exec(h.trim()),m=f?`${f[1].charAt(0).toUpperCase()}${f[1].slice(1).toLowerCase()} `:"";let p=f?h.trim().slice(f[0].length).trim():h.trim();/\$\{[^}]*\}|^\$[A-Z_][A-Z0-9_]*$|^<[^>]+>$/i.test(p)&&(c=!0,p=""),o={name:u.trim(),prefix:m,value:p}}return{url:i,...s?{name:s}:{},...o?{header:o}:{},dropped:a.filter(u=>u!==l).map(([u])=>u),placeholder:c}}const bo={command:"It names no command to run.",claude:"That claude mcp add line names no server and no command. It looks like: claude mcp add <name> -- <command> <args…>",quote:"A quote in that line is never closed.",env:"An environment variable is written NAME=value."};function ET(e){return/TOKEN|KEY|SECRET|PASSWORD|PASSWD|CREDENTIAL|AUTH/i.test(e)}const AT=/^[A-Za-z_][A-Za-z0-9_]*$/;function QH(e){return/\$\{[^}]*\}|^\$[A-Z_][A-Z0-9_]*$|^<[^>]+>$|^your[_-]/i.test(e.trim())}function TT(e,t){const s=QH(t);return{name:e,value:s?"":t,secret:ET(e),placeholder:s}}function RT(e){const t=[];let s="",r=!1,i=null;for(let a=0;a<e.length;a+=1){const l=e[a];if(i==="'"){l==="'"?i=null:s+=l;continue}if(i==='"'){if(l==='"')i=null;else if(l==="\\"&&a+1<e.length&&'"\\$`\n'.includes(e[a+1])){const o=e[++a];o!==`
|
|
110
|
+
`&&(s+=o)}else s+=l;continue}if(l==="\\"){const o=e[a+1];if(o===void 0)continue;if(a+=1,o===`
|
|
111
|
+
`||o==="\r"&&e[a+1]===`
|
|
112
|
+
`){o==="\r"&&(a+=1);continue}s+=o,r=!0;continue}if(l==="'"||l==='"'){i=l,r=!0;continue}if(/\s/.test(l)){r&&(t.push(s),s="",r=!1);continue}s+=l,r=!0}if(i)throw new Error(bo.quote);return r&&t.push(s),t}function XH(e){const t=RT(e.trim());let s=0;t[s]==="claude"&&(s+=1),t[s]==="mcp"&&(s+=1),t[s]==="add"&&(s+=1);const r=[],i=[];let a="stdio",l,o;const c=h=>{const f=h.indexOf("="),m=f>0?h.slice(0,f).trim():"";if(!AT.test(m))throw new Error(bo.env);r.push(TT(m,h.slice(f+1)))},u=[];for(;s<t.length;s+=1){const h=t[s];if(h==="--"){o=t.slice(s+1);break}const[f,m]=h.startsWith("--")&&h.includes("=")?[h.slice(0,h.indexOf("=")),h.slice(h.indexOf("=")+1)]:[h,void 0];if(f==="-e"||f==="--env"){if(m!==void 0){c(m);continue}let p=!1;for(;s+1<t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[s+1]);)c(t[++s]),p=!0;if(!p)throw new Error(bo.env);continue}if(f==="-s"||f==="--scope"){m===void 0&&(s+=1);continue}if(f==="-t"||f==="--transport"){a=(m??t[++s]??"stdio").toLowerCase();continue}if(f==="-H"||f==="--header"){const p=m??t[++s];p&&i.push(p);continue}if(!(f.startsWith("-")&&l===void 0)){if(l===void 0){l=h;continue}u.push(h)}}if(o===void 0?o=u:u.length>0&&(o=[...u,...o]),a==="http"||a==="sse"||o.length===1&&/^https?:\/\//i.test(o[0])){const h=o[0];if(!h)throw new Error(ls.url);const f={};for(const m of i){const p=m.indexOf(":");p>0&&(f[m.slice(0,p).trim()]=m.slice(p+1).trim())}return{kind:"remote",config:CT(JSON.stringify({mcpServers:{[l??"server"]:{type:a,url:h,headers:f}}}))}}if(!l||o.length===0)throw new Error(bo.claude);return{kind:"program",program:{name:l,command:o[0],args:o.slice(1),env:r}}}function JH(e){const t=e.trim();if(/^claude\s+mcp\s+add\b/.test(t))return XH(t);let s;try{s=JSON.parse(t)}catch{throw new Error(ls.json)}if(!Jr(s))throw new Error(ls.json);let r,i=s;if("mcpServers"in s){const c=s.mcpServers;if(!Jr(c))throw new Error(ls.empty);const u=Object.keys(c);u.length===1&&Jr(c[u[0]])&&(r=u[0],i=c[r])}if(!("command"in i))return{kind:"remote",config:CT(t)};const a=typeof i.command=="string"?i.command.trim():"";if(a==="")throw new Error(bo.command);const l=Array.isArray(i.args)?i.args.map(c=>String(c)):[],o=Jr(i.env)?Object.entries(i.env).filter(([c])=>AT.test(c)).map(([c,u])=>TT(c,String(u??""))):[];return{kind:"program",program:{...r?{name:r}:{},command:a,args:l,env:o}}}function Lj({code:e,label:t="Your code",large:s=!1}){const[r,i]=d.useState(!1),a=async()=>{var l;try{await((l=navigator.clipboard)==null?void 0:l.writeText(e)),i(!0)}catch{}};return n.jsxs(le,{valign:"end",children:[n.jsx(ie,{label:t,grow:!0,children:n.jsx("input",{readOnly:!0,value:e,"data-code":s?"large":void 0,spellCheck:!1,onFocus:l=>l.currentTarget.select()})}),n.jsx(T,{onClick:()=>void a(),children:r?"Copied":"Copy"})]})}function $T(e){if(e.phase==="starting")return{label:"Starting",tone:"accent"};switch(e.state){case"connected":return{label:"Connected",tone:"good",dot:!0};case"needs-reconnect":return{label:"Sign in again",tone:"warning"};case"needs-review":return{label:"Needs review",tone:"warning"};case"unreachable":return{label:e.transport==="stdio"?"Failed":"Unreachable",tone:"critical"};default:return{label:"Not finished",tone:"muted"}}}const ZH="It can delete or destroy something, so it asks you every time and is never remembered.";function eK(e){return e.tier==="auto"?{label:"Runs on its own",tone:"good"}:e.destructive?{label:"Asks you every time",tone:"critical"}:{label:"Asks you first",tone:"warning"}}const IT="buddi-connections",tK="/connections/callback",nK="This service does not let buddi register itself. Create an app in its developer settings with the redirect address below, and paste its client id here. A token is usually simpler.",PT="Services and programs your team can use, and the tools each one brings.",_j=(e,t,s)=>`${e} ${e===1?t:s}`;function Jk(e,t){return e.transport==="stdio"?void 0:t.find(s=>zj(s.url,e.url))}function Fj({connection:e,card:t,size:s}){return t?n.jsx(_r,{letter:t.name.slice(0,1).toUpperCase(),size:s}):n.jsx(_r,{icon:(e==null?void 0:e.transport)==="stdio"?"terminal":"globe",size:s})}function MT({connection:e}){const t=$T(e);return n.jsx(ve,{tone:t.tone,dot:t.dot,children:t.label})}const Cm=e=>t=>{t.stopPropagation(),e()},Ju=[{value:"address",label:"An address",text:"Any server on the web, by its https:// address. buddi opens it and reads what it offers, and nothing else until you have read its tools.",button:"Give its address"},{value:"program",label:"A program",text:"A server buddi starts itself on this computer, like npx or uvx, with its arguments and variables.",button:"Describe it"},{value:"paste",label:"A config",text:"The mcpServers block another app uses for it, or the claude mcp add line its docs print.",button:"Paste it"}],DT="buddi.connections.add-way";function sK(){try{const e=window.localStorage.getItem(DT);return Ju.some(t=>t.value===e)?e:"address"}catch{return"address"}}function rK({embedded:e,timezone:t,connection:s}={}){const r=ce(()=>E.connections(),[],3e4),[i,a]=d.useState(null),[l,o]=d.useState(s??null);d.useEffect(()=>{s&&o(s)},[s]);const[c,u]=d.useState(null),[h,f]=d.useState(null),m=r.data,p=k=>{var S;return((S=m==null?void 0:m.agents.find(C=>C.id===k))==null?void 0:S.name)??k},g=t??Intl.DateTimeFormat().resolvedOptions().timeZone,x=(m==null?void 0:m.connections)??[],b=(m==null?void 0:m.catalog)??[],j=b.filter(k=>!x.some(S=>S.transport!=="stdio"&&zj(k.url,S.url))),v=l?x.find(k=>k.id===l):void 0,w=c?x.find(k=>k.id===c):void 0,y=h?x.find(k=>k.id===h):void 0,N=k=>{o(null),a(k)};return n.jsxs(An,{embedded:e,title:"Connections",lede:PT,children:[n.jsxs(re,{gap:"lg",children:[n.jsxs("p",{className:"plugins-quiet connections-quiet",children:[n.jsx(ue,{name:"plug",size:14}),n.jsxs("span",{children:["A connection is a service or program buddi talks to; a plugin is code buddi installs and runs."," ",n.jsx("a",{href:De("plugins"),children:"Plugins"})]})]}),!m&&!r.error?n.jsx(xe,{children:"Reading your connections…"}):null,n.jsx(ae,{message:r.error}),m&&!m.vault?n.jsx(V,{tone:"warning",children:"This installation has no vault, so a service that asks for a sign-in cannot be connected. Turn the vault on first."}):null,m?n.jsx(qe,{flush:!0,title:"Your connections",tool:x.length>0?_j(x.length,"connection","connections"):void 0,children:x.length===0?n.jsx(xe,{title:"Nothing connected yet",children:"Pick a service below, or add your own: an address, a program on this computer, or a config you already have."}):n.jsx("div",{className:"connections-rows",children:n.jsx(dt,{children:x.map(k=>n.jsx(iK,{connection:k,card:Jk(k,b),twin:k.slug!==null&&x.some(S=>S.id!==k.id&&S.name===k.name),onOpen:()=>o(k.id),onFlow:N},k.id))})})}):null,m&&j.length>0?n.jsx(qe,{title:"Connect a service",children:n.jsx("div",{className:"connections-tiles",children:j.map(k=>n.jsxs("div",{className:"connections-tile",children:[n.jsx(Fj,{card:k}),n.jsxs("span",{className:"connections-tile-main",children:[n.jsx("span",{className:"connections-tile-name",children:k.name}),n.jsx("span",{className:"connections-tile-blurb",children:k.blurb})]}),n.jsx(T,{size:"sm",onClick:()=>N({step:"address",card:k}),"aria-label":`Connect ${k.name}`,children:"Connect"})]},k.id))})}):null,m?n.jsx(uK,{onFlow:k=>N({step:k})}):null]}),v?n.jsx(lK,{connection:v,card:Jk(v,b),agentName:p,timezone:g,onClose:()=>o(null),onFlow:N,onDisconnect:()=>u(v.id),onHolders:()=>f(v.id)}):null,y&&m?n.jsx(oK,{connection:y,agents:m.agents,onCancel:()=>f(null),onDone:()=>{f(null),r.reload()}},y.id):null,w?n.jsx(cK,{connection:w,agentName:p,onCancel:()=>u(null),onDone:()=>{u(null),o(null),r.reload()}},w.id):null,i&&m?n.jsx(dK,{start:i,agents:m.agents,catalog:m.catalog,tokens:m.tokens??m.vault,onClose:()=>{a(null),r.reload()}}):null]})}function iK({connection:e,card:t,twin:s,onOpen:r,onFlow:i}){const a=e.state==="pending-review",l=s?`${e.name} (${e.slug})`:e.name,o=e.transport==="stdio"?e.program:void 0,c=o?o.line:e.host,u=a?"its tools are not reviewed yet":_j(e.toolCount,"tool","tools");return n.jsx(it,{onClick:r,label:`${l}: details`,lead:n.jsx(Fj,{connection:e,card:t}),title:l,sub:n.jsx("span",{className:"connections-sub","data-kind":o?"program":void 0,children:`${c} · ${u}`}),side:n.jsxs("span",{className:"plugins-side",children:[a?n.jsx("span",{className:"connections-act",children:n.jsx(T,{size:"sm",variant:"accent",onClick:Cm(()=>i({step:e.signedIn?"review":"consent",connection:e})),children:"Finish"})}):e.state==="needs-reconnect"&&e.authKind!=="none"?n.jsx("span",{className:"connections-act",children:n.jsx(T,{size:"sm",onClick:Cm(()=>i({step:"consent",connection:e,keepGrants:!0})),children:"Sign in"})}):e.state==="needs-review"?n.jsx("span",{className:"connections-act",children:n.jsx(T,{size:"sm",onClick:Cm(()=>i({step:"review",connection:e,keepGrants:!0})),children:"Review"})}):null,n.jsx(MT,{connection:e}),n.jsx(ue,{name:"chevron-right",size:14})]})})}const aK={oauth:"Its own sign-in page. buddi keeps the sign-in in its vault.",token:"A token you pasted, kept in buddi’s vault and sent only here.",none:"Nothing; it asks for no sign-in."};function lK({connection:e,card:t,agentName:s,timezone:r,onClose:i,onFlow:a,onHolders:l,onDisconnect:o}){const c=e.state==="pending-review",u=e.transport==="stdio"?e.program:void 0,h=()=>a({step:"consent",connection:e,keepGrants:!0}),f=()=>a({step:"review",connection:e,keepGrants:!0}),m=()=>a({step:e.signedIn?"review":"consent",connection:e});return n.jsxs(ht,{title:n.jsxs("span",{className:"plugins-sheet-title",children:[n.jsx(Fj,{connection:e,card:t,size:"lg"}),n.jsxs("span",{className:"plugins-sheet-name",children:[n.jsx("span",{children:e.name}),n.jsxs("span",{className:"plugins-sheet-by",children:[u?"A program on this computer":"A service at an address"," · ",n.jsx(MT,{connection:e})]})]})]}),onClose:i,foot:n.jsxs(le,{children:[n.jsx(T,{variant:"danger-ghost",onClick:o,children:"Disconnect…"}),n.jsx(_t,{}),u?n.jsx(T,{onClick:()=>a({step:"program",connection:e,keepGrants:!0}),children:"Change"}):null,e.authKind!=="none"&&!c?n.jsx(T,{variant:e.state==="needs-reconnect"?"accent":void 0,onClick:h,children:"Reconnect"}):null,c?n.jsx(T,{variant:"accent",onClick:m,children:"Finish"}):n.jsx(T,{variant:e.state==="needs-review"?"accent":void 0,onClick:f,children:"Review again"})]}),children:[c?n.jsx(V,{children:"Not finished: its tools are not reviewed yet, so no agent can use them."}):null,e.state==="needs-reconnect"?n.jsx(V,{tone:"warning",action:e.authKind!=="none"?n.jsx(T,{size:"sm",variant:"accent",onClick:h,children:"Sign in again"}):void 0,children:"Its sign-in ran out or was refused. Until you reconnect, each of its tools answers with one sentence instead of running."}):null,e.state==="needs-review"?n.jsxs(V,{tone:"warning",action:n.jsx(T,{size:"sm",variant:"accent",onClick:f,children:"Review it"}),children:["It changed its tools since you reviewed them. The new and changed ones wait until you review it again",e.heldTools?` (${e.heldTools} of the ones you kept ${e.heldTools===1?"waits":"wait"})`:"","; the others keep working."]}):null,e.state==="unreachable"&&e.unreachableSince?n.jsx(V,{tone:"critical",children:u?`It stopped answering at ${et(e.unreachableSince,r)}; the next call starts it again.`:`Unreachable since ${et(e.unreachableSince,r)}, retrying.`}):null,u!=null&&u.changedSinceReview?n.jsx(V,{tone:"warning",children:"Its command changed since you reviewed it, so its tools wait until you review it again."}):null,e.phase==="starting"?n.jsx(V,{tone:"accent",role:"status",children:"Starting it… The first start can take a minute or two while it downloads."}):null,n.jsx("div",{className:"plugins-facts",children:n.jsx(Wt,{items:[u?{label:"Command",value:n.jsx("span",{className:"connections-line",children:u.line})}:{label:"Address",value:n.jsx("span",{className:"connections-line",children:e.url})},...u?[{label:"Runs",value:"On this computer as you, with your PATH and only the variables you named. It stops after ten quiet minutes."}]:[],...u&&u.env.length>0?[{label:"Variables",value:n.jsx("span",{className:"mono",children:u.env.map(p=>`${p.name}${p.secret?" (secret)":""}`).join(", ")})}]:[],...u?[]:[{label:"Signs in with",value:aK[e.authKind]}],{label:"Tools",value:c?"Not reviewed yet":`${_j(e.toolCount,"tool","tools")}${e.reviewedAt?` · reviewed ${Oe(e.reviewedAt)}`:""}`},...c?[]:[{label:"Held by",value:n.jsxs("span",{className:"connections-holders",children:[n.jsx("span",{children:e.agents.length===0?"No agent holds these tools yet.":e.agents.map(s).join(", ")}),n.jsx(T,{size:"sm",onClick:l,"aria-label":"Change who holds it",children:e.agents.length===0?"Give them":"Change"})]})}]]})}),e.stderr&&e.stderr.length>0?n.jsx(oe,{title:"What the program last said",children:n.jsx(Pt,{label:"Its last lines on stderr",children:e.stderr.join(`
|
|
113
|
+
`)})}):null,t&&!c?n.jsxs("div",{className:"connections-another",children:[n.jsxs("p",{children:["Another ",t.name," account or workspace? It connects beside this one, with its own sign-in and its own name. In the browser, sign in as that other account."]}),n.jsx(T,{size:"sm",onClick:()=>a({step:"address",card:t}),children:"Add another account"})]}):null]})}function oK({connection:e,agents:t,onCancel:s,onDone:r}){const[i,a]=d.useState(()=>new Set(e.agents)),[l,o]=d.useState(!1),[c,u]=d.useState(null),h=(p,g)=>a(x=>{const b=new Set(x);return g?b.add(p):b.delete(p),b}),f=i.size===e.agents.length&&e.agents.every(p=>i.has(p)),m=async()=>{o(!0),u(null);try{const p=await E.grantConnection(e.id,[...i],!0);p.failed.length>0?u(p.failed.map(g=>`${g.agent}: ${g.message}`).join("; ")):r()}catch(p){u(Ls(p))}finally{o(!1)}};return n.jsxs(un,{title:`Who holds ${e.name}`,onClose:s,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",disabled:l,onClick:s,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:l||f,onClick:()=>void m(),children:"Save"})]}),children:[n.jsx("p",{className:"plugins-dialog-text",children:"Each agent you tick can use its tools; untick one to take them away. Approvals still ask as before."}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Agents",children:t.map(p=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:i.has(p.id),onChange:g=>h(p.id,g.target.checked)}),n.jsxs("span",{children:[p.name,p.frontDesk?" (front desk)":""]})]},p.id))}),n.jsx(ae,{message:c})]})}function cK({connection:e,agentName:t,onCancel:s,onDone:r}){const[i,a]=d.useState(!1),[l,o]=d.useState(null),c=e.agents.map(t),u=async()=>{a(!0),o(null);try{await E.disconnect(e.id),r()}catch(h){o(Ls(h))}finally{a(!1)}};return n.jsxs(un,{title:`Disconnect ${e.name}?`,onClose:s,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",disabled:i,onClick:s,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:i,onClick:()=>void u(),children:"Disconnect"})]}),children:[n.jsxs("p",{className:"plugins-dialog-text",children:["buddi forgets its sign-in and its tools."," ",c.length>0?`${c.join(" and ")} ${c.length===1?"loses":"lose"} them.`:"No agent holds its tools."]}),n.jsx(ae,{message:l})]})}function uK({onFlow:e}){const[t,s]=d.useState(sK),r=Ju.find(a=>a.value===t)??Ju[0],i=a=>{s(a);try{window.localStorage.setItem(DT,a)}catch{}};return n.jsx(qe,{title:"Add your own",actions:n.jsx(rn,{label:"How to add it",options:Ju.map(({value:a,label:l})=>({value:a,label:l})),value:t,onChange:i}),children:n.jsxs("div",{className:"connections-add",children:[n.jsx("p",{className:"connections-add-text",children:r.text}),n.jsx(T,{variant:"accent",onClick:()=>e(t),children:r.button})]})})}function dK({start:e,agents:t,catalog:s=[],tokens:r=!0,onClose:i,pollMs:a=2e3}){const[l,o]=d.useState(e.step),[c,u]=d.useState(e.connection),[h,f]=d.useState("unknown"),[m,p]=d.useState(null),[g,x]=d.useState(null),b=(m==null?void 0:m.url)??(c==null?void 0:c.url),j=e.card??s.find(y=>b!==void 0&&zj(y.url,b)),v=(c==null?void 0:c.name)??(j==null?void 0:j.name)??(m==null?void 0:m.name)??"the service",w=l==="paste"?"Paste a config":l==="address"?"Connect a service":l==="program"?c?`Change ${c.name}`:"A program on this computer":l==="consent"?`Sign in to ${v}`:l==="review"?`What ${v} brings`:"Who gets these tools";return n.jsxs(ht,{title:w,onClose:i,size:"wide",children:[l==="paste"?n.jsx(hK,{onRead:y=>{y.kind==="program"?(x(y.program),o("program")):(p(y.config),o("address"))}}):null,l==="address"?n.jsx(fK,{card:j,pasted:m,onDone:(y,N)=>{u(y),N==="none"?o("review"):(f(N),o("consent"))}}):null,l==="program"?n.jsx(yK,{connection:c,pasted:g,tokens:r,onDone:y=>{var N;x(null),u(y),e.keepGrants&&!((N=y.program)!=null&&N.changedSinceReview)&&y.state!=="pending-review"?i():o("review")}}):null,l==="consent"&&c?n.jsx(gK,{connection:c,signIn:h,card:j,pasted:m==null?void 0:m.header,placeholder:(m==null?void 0:m.placeholder)??!1,tokens:r,pollMs:a,onSignedIn:y=>{p(null),u(y),e.keepGrants?i():o("review")}}):null,l==="review"&&c?n.jsx(bK,{connection:c,onKept:y=>{u(y),e.keepGrants?i():o("grant")}}):null,l==="grant"&&c?n.jsx(kK,{connection:c,agents:t,onDone:i}):null]})}function zj(e,t){const s=r=>r.trim().replace(/\/+$/,"").toLowerCase();return s(e)===s(t)}function Ls(e){return e instanceof Error?e.message:String(e)}function hK({onRead:e}){const[t,s]=d.useState(""),[r,i]=d.useState(null),a=()=>{try{const l=JH(t);s(""),i(null),e(l)}catch(l){i(Ls(l))}};return n.jsxs("form",{className:"ui-stack",onSubmit:l=>{l.preventDefault(),a()},children:[n.jsxs("p",{children:["Paste the block another app uses for this server, the one with ",n.jsx("span",{className:"mono",children:"mcpServers"}),", or the"," ",n.jsx("span",{className:"mono",children:"claude mcp add"})," line its docs print. A remote server gives its address, name and one header; a program its command, arguments and variables. Nothing is kept before you have read it on the next screen."]}),n.jsx(ie,{label:"Config",hint:"A url for a remote server, or a command for a program on this computer.",children:n.jsx("textarea",{className:"mono",rows:8,required:!0,autoFocus:!0,spellCheck:!1,autoComplete:"off",value:t,placeholder:'{ "mcpServers": { "github": { "url": "…", "headers": { "Authorization": "Bearer …" } } } }',onChange:l=>s(l.target.value)})}),n.jsx(ae,{message:r}),n.jsx(le,{align:"end",children:n.jsx(T,{type:"submit",variant:"accent",disabled:t.trim()==="",children:"Read it"})})]})}function fK({card:e,pasted:t,onDone:s}){var m,p;const[r,i]=d.useState((t==null?void 0:t.url)??(e==null?void 0:e.url)??""),[a,l]=d.useState(!1),[o,c]=d.useState(null),u=async()=>{l(!0),c(null);try{const g=await E.addConnection(r.trim(),(e==null?void 0:e.name)??(t==null?void 0:t.name));s(g.connection,g.signIn)}catch(g){c(Ls(g))}finally{l(!1)}},h=((m=e==null?void 0:e.auth)==null?void 0:m.recommended)==="token",f=((p=e==null?void 0:e.auth)==null?void 0:p.recommended)==="device"&&e.auth.device!==void 0;return n.jsxs("form",{className:"ui-stack",onSubmit:g=>{g.preventDefault(),u()},children:[e?n.jsxs("p",{children:["buddi opens ",e.name,"’s server, reads its name and what it offers, and asks whether it wants you to sign in. Nothing else is sent."]}):n.jsx("p",{children:"Where is the server? buddi opens it, reads its name and what it offers, and nothing else until you have read its tools."}),n.jsx(ie,{label:"Address",hint:"An https:// address. A server you start with npx, uvx or a local command is “A program on this computer” instead.",children:n.jsx("input",{required:!0,autoFocus:!e&&!t,spellCheck:!1,value:r,placeholder:"https://",onChange:g=>i(g.target.value)})}),e&&!e.verified?n.jsxs("p",{className:"ui-card-meta",children:["This address is the one ",e.name," published; buddi has not checked it since."]}):null,f?n.jsxs("p",{className:"ui-card-meta",children:[e.name," signs in with a code you type on its site. The next screen shows it."]}):h?n.jsxs("p",{className:"ui-card-meta",children:[e.name," signs in with a token you make on its site. The next screen links to the page."]}):e!=null&&e.clientIdRequired?n.jsxs("p",{className:"ui-card-meta",children:[e.name," does not let buddi register itself: signing in needs a token, or a client id from its developer settings."]}):null,t!=null&&t.header?n.jsx("p",{className:"ui-card-meta",children:t.placeholder?`Your config has a placeholder where the ${t.header.name} header's token goes. You paste the token itself on the next screen.`:`The ${t.header.name} header from your config waits for the sign-in screen. buddi tries it before it keeps it.`}):null,t&&t.dropped.length>0?n.jsxs("p",{className:"ui-card-meta",children:["buddi sends one header, so ",t.dropped.join(", ")," ",t.dropped.length===1?"was":"were"," left out."]}):null,n.jsx(ae,{message:o}),n.jsx(le,{align:"end",children:n.jsx(T,{type:"submit",variant:"accent",disabled:a||r.trim()==="",children:a?"Opening…":"Continue"})})]})}const mK={device:"Device",oauth:"Sign in",token:"Token",client:"Client id"};function pK(e,t,s="none"){const r=e==="manual"?["token","client"]:["oauth","token"],i=t?r:r.filter(a=>a!=="token");return s==="first"?["device",...i]:s==="offered"?[...i.filter(a=>a!=="client"),"device",...i.filter(a=>a==="client")]:i}function gK({connection:e,signIn:t,card:s,pasted:r,placeholder:i,tokens:a,pollMs:l,onSignedIn:o}){var W,_;const[c,u]=d.useState(t),h=(W=s==null?void 0:s.auth)!=null&&W.device?s.auth.recommended==="device"?"first":"offered":"none",f=pK(c,a,h),m=r!==void 0||h!=="first"&&(e.authKind==="token"||((_=s==null?void 0:s.auth)==null?void 0:_.recommended)==="token"),[p,g]=d.useState(()=>m&&f.includes("token")?"token":f[0]),x=f.includes(p)?p:f[0],[b,j]=d.useState(nK),[v,w]=d.useState(""),[y,N]=d.useState(null),[k,S]=d.useState(!1),[C,$]=d.useState(null),[R,I]=d.useState(!1),[z,U]=d.useState(null),A=`${location.origin}${tK}`,P=d.useRef(o);P.current=o,d.useEffect(()=>{if(!R)return;let G=!1;const B=async()=>{if(!G){G=!0;try{P.current(await E.connection(e.id))}catch(Z){$(Ls(Z))}}},K=typeof BroadcastChannel=="function"?new BroadcastChannel(IT):null;K&&(K.onmessage=Z=>{var de;((de=Z.data)==null?void 0:de.id)===e.id&&B()});let F;const Q=Date.now(),X=async()=>{if(!G){try{const Z=await E.connection(e.id);if((!e.signedIn||e.authKind==="token")&&Z.signedIn&&Z.authKind==="oauth"){B();return}}catch{}if(Date.now()-Q>10*6e4){I(!1),$("The sign-in did not come back within ten minutes. Start it again.");return}F=window.setTimeout(()=>void X(),l)}};return F=window.setTimeout(()=>void X(),l),()=>{G=!0,K==null||K.close(),window.clearTimeout(F)}},[R,e,l]);const D=async G=>{var B;S(!0),$(null);try{const{authorizeUrl:K}=await E.connectionConsent(e.id,G);N(K)}catch(K){K instanceof me&&((B=K.detail)==null?void 0:B.code)==="client-id"?(j(K.message),u("manual"),g("client")):$(Ls(K))}finally{S(!1)}};d.useEffect(()=>{x!=="oauth"||y!==null||D()},[x]);const O=G=>{const B=window.open(G,"_blank");B?(B.opener=null,U(null)):U(G),I(!0)},M=G=>{g(G),N(null),$(null),I(!1),U(null)};return n.jsxs("div",{className:"ui-stack",children:[f.length>1?n.jsx(rn,{label:"How to sign in",options:f.map(G=>({value:G,label:mK[G]})),value:x,onChange:M}):null,x==="oauth"?n.jsxs(n.Fragment,{children:[n.jsxs("p",{children:["buddi opens ",e.name,"’s own sign-in page in a new tab. You say yes there, the tab comes back here, and buddi keeps the sign-in in its vault. No agent ever sees it."]}),k?n.jsxs(xe,{children:["Getting ",e.name,"’s sign-in page…"]}):null]}):null,x==="client"?n.jsxs(n.Fragment,{children:[n.jsx(V,{tone:"warning",children:b}),n.jsx(ie,{label:"Client id",children:n.jsx("input",{required:!0,spellCheck:!1,value:v,onChange:G=>{w(G.target.value),N(null),I(!1)}})}),n.jsxs("p",{className:"ui-card-meta",children:["Its redirect address: ",n.jsx("span",{className:"mono",children:A})]})]}):null,x==="token"?n.jsx(jK,{connection:e,card:s,pasted:r,placeholder:i,onSignedIn:o}):null,x==="device"?n.jsx(vK,{connection:e,service:(s==null?void 0:s.name)??e.name,pollMs:l,onSignedIn:o}):null,(x==="oauth"||x==="client")&&R?n.jsxs(V,{tone:"accent",role:"status",children:["Waiting for you to say yes on ",e.name,"’s page…"]}):null,(x==="oauth"||x==="client")&&z?n.jsx("p",{children:n.jsxs("a",{href:z,target:"_blank",rel:"noopener noreferrer",children:["Open ",e.name,"’s sign-in page"]})}):null,x==="oauth"||x==="client"?n.jsx(ae,{message:C}):null,x==="oauth"?n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",onClick:()=>{y&&O(y)},disabled:y===null,children:R?"Open it again":`Sign in to ${e.name}`})}):null,x==="client"?n.jsx(le,{align:"end",children:y===null?n.jsx(T,{variant:"accent",onClick:()=>void D(v.trim()),disabled:k||v.trim()==="",children:k?"Checking…":"Continue"}):n.jsx(T,{variant:"accent",onClick:()=>O(y),children:R?"Open it again":`Open ${e.name}’s sign-in page`})}):null]})}function xK(e){try{const t=new URL(e);return`${t.host}${t.pathname==="/"?"":t.pathname.replace(/\/$/,"")}`}catch{return e}}function vK({connection:e,service:t,pollMs:s,onSignedIn:r}){const[i,a]=d.useState(null),[l,o]=d.useState(null),[c,u]=d.useState(0),[h,f]=d.useState(null),m=d.useRef(r);m.current=r,d.useEffect(()=>{let x=!1,b;a(null),o(null),f(null);const j=async()=>{var v,w;if(!x){try{const y=await E.connection(e.id);if(x)return;if(((v=y.device)==null?void 0:v.state)==="done"){m.current(y);return}if(((w=y.device)==null?void 0:w.state)==="failed"){o(y.device.reason??"The sign-in did not finish. Start again.");return}}catch{}b=window.setTimeout(()=>void j(),s)}};return(async()=>{try{const v=await E.connectionDevice(e.id);if(x)return;a({userCode:v.userCode,verificationUri:v.verificationUri}),b=window.setTimeout(()=>void j(),s)}catch(v){x||o(Ls(v))}})(),()=>{x=!0,window.clearTimeout(b)}},[e.id,s,c]);const p=x=>{const b=window.open(x,"_blank");b?(b.opener=null,f(null)):f(x)},g=i?xK(i.verificationUri):"";return n.jsxs(n.Fragment,{children:[n.jsxs("p",{children:["Type this code on ",t,"’s site and say yes there. buddi keeps the sign-in in its vault and sends it only to"," ",n.jsx("span",{className:"mono",children:e.host}),". No agent ever sees it."]}),i===null&&l===null?n.jsxs(xe,{children:["Asking ",t," for a code…"]}):null,i&&l===null?n.jsxs(n.Fragment,{children:[n.jsx(Lj,{code:i.userCode,label:`Your code for ${t}`,large:!0}),n.jsxs(V,{tone:"accent",role:"status",children:["Waiting for you to approve on ",t,"…"]}),h?n.jsx("p",{children:n.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:["Open ",g]})}):null,n.jsx(le,{align:"end",children:n.jsxs(T,{variant:"accent",onClick:()=>p(i.verificationUri),children:["Open ",g]})})]}):null,l!==null?n.jsxs(n.Fragment,{children:[n.jsx(ae,{message:l}),n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",onClick:()=>u(x=>x+1),children:"Start again"})})]}):null]})}function jK({connection:e,card:t,pasted:s,placeholder:r,onSignedIn:i}){var j,v;const[a,l]=d.useState((s==null?void 0:s.value)??""),[o,c]=d.useState((s==null?void 0:s.name)??"Authorization"),[u,h]=d.useState((s==null?void 0:s.prefix)??(s?"":"Bearer ")),[f,m]=d.useState(!1),[p,g]=d.useState(null),x=async()=>{m(!0),g(null);try{const w=await E.connectionToken(e.id,{token:a.trim(),header:o.trim(),prefix:u});l(""),i(w.connection)}catch(w){g(Ls(w))}finally{m(!1)}},b=(j=t==null?void 0:t.auth)==null?void 0:j.tokenPage;return n.jsxs("form",{className:"ui-stack",onSubmit:w=>{w.preventDefault(),x()},children:[n.jsxs("p",{children:[b?`Make a token on ${e.name}’s site and paste it here.`:`Paste a token ${e.name} gave you.`," buddi tries it on"," ",n.jsx("span",{className:"mono",children:e.host})," first, keeps it in its vault, and sends it only there. No agent ever sees it."]}),b?n.jsx("p",{children:n.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",children:["Make a token on ",e.name]})}):null,r?n.jsx(V,{tone:"accent",children:"Your config had a placeholder where the token goes. Paste the token itself."}):null,n.jsx(ie,{label:"Token",hint:(v=t==null?void 0:t.auth)==null?void 0:v.tokenHint,children:n.jsx("input",{type:"password",required:!0,autoFocus:!(s!=null&&s.value),autoComplete:"off",spellCheck:!1,value:a,onChange:w=>l(w.target.value)})}),n.jsxs(Os,{columns:2,dense:!0,children:[n.jsx(ie,{label:"Header",hint:"Most services want Authorization.",children:n.jsx("input",{required:!0,spellCheck:!1,value:o,onChange:w=>c(w.target.value)})}),n.jsx(ie,{label:"Before the token",hint:"Usually “Bearer ”, with its space. Empty for none.",children:n.jsx("input",{spellCheck:!1,value:u,onChange:w=>h(w.target.value)})})]}),n.jsx(ae,{message:p}),n.jsx(le,{align:"end",children:n.jsx(T,{type:"submit",variant:"accent",disabled:f||a.trim()===""||o.trim()==="",children:f?"Trying it…":"Try it and keep it"})})]})}function wK(e){return e!==""&&/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function yK({connection:e,pasted:t,tokens:s=!0,onDone:r}){const i=e==null?void 0:e.program,a=d.useRef(0),l=()=>(a.current+=1,a.current),[o,c]=d.useState((e==null?void 0:e.name)??(t==null?void 0:t.name)??""),[u,h]=d.useState((i==null?void 0:i.command)??(t==null?void 0:t.command)??""),[f,m]=d.useState(()=>((i==null?void 0:i.args)??(t==null?void 0:t.args)??[]).map(A=>({key:l(),value:A}))),[p,g]=d.useState(()=>i?i.env.map(A=>({key:l(),name:A.name,value:A.value??"",secret:A.secret,kept:A.secret})):((t==null?void 0:t.env)??[]).map(A=>({key:l(),name:A.name,value:A.value,secret:A.secret,kept:!1}))),[x,b]=d.useState(!1),[j,v]=d.useState(null),w=/\s/.test(u.trim())?RT(u.trim()):[u.trim()],y=w[0]??"",N=[...w.slice(1),...f.map(A=>A.value)],k=[y,...N].filter((A,P)=>P>0||A!==""),S=()=>{w.length<2||(h(y),m(A=>[...w.slice(1).map(P=>({key:l(),value:P})),...A]))},C=k.map(wK).join(" "),$=p.filter(A=>A.secret&&A.value===""&&!A.kept).map(A=>A.name||"a variable"),R=((t==null?void 0:t.env)??[]).filter(A=>A.placeholder).map(A=>A.name),I=(A,P)=>m(D=>D.map(O=>O.key===A?{...O,value:P}:O)),z=(A,P)=>g(D=>D.map(O=>O.key===A?{...O,...P}:O)),U=async()=>{b(!0),v(null);const A={name:o.trim(),command:y,args:N,env:p.filter(P=>P.name.trim()!=="").map(P=>({name:P.name.trim(),value:P.value,secret:P.secret}))};try{r(e?await E.updateProgram(e.id,A):(await E.addProgram(A)).connection),g(P=>P.map(D=>D.secret?{...D,value:""}:D))}catch(P){v(Ls(P))}finally{b(!1)}};return n.jsxs("form",{className:"ui-stack",onSubmit:A=>{A.preventDefault(),U()},children:[n.jsx("p",{children:"A server buddi starts itself on this computer, as you, when an agent needs it, and stops after ten quiet minutes. It runs with your PATH and only the variables you name here. The review screen is the first time it runs, only to list its tools."}),n.jsxs(Os,{columns:2,children:[n.jsx(ie,{label:"Name",children:n.jsx("input",{required:!0,autoFocus:!t&&!e,maxLength:80,spellCheck:!1,value:o,onChange:A=>c(A.target.value)})}),n.jsx(ie,{label:"Command",hint:"The program that starts the server: npx, uvx, node, or a full path. A whole line is split into it and its arguments.",children:n.jsx("input",{required:!0,spellCheck:!1,autoComplete:"off",className:"mono",value:u,placeholder:"npx",onChange:A=>h(A.target.value),onBlur:S})})]}),n.jsx(ie,{label:"Arguments",group:!0,hint:"One per row, exactly as the server's docs give them. No shell: quotes and $VARIABLES are passed as they are.",children:n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[f.map((A,P)=>n.jsxs("div",{className:"connections-row",children:[n.jsx("input",{"aria-label":`Argument ${P+1}`,className:"mono",spellCheck:!1,autoComplete:"off",value:A.value,onChange:D=>I(A.key,D.target.value)}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>m(D=>D.filter(O=>O.key!==A.key)),"aria-label":`Remove argument ${P+1}`,children:"Remove"})]},A.key)),n.jsx(le,{children:n.jsx(T,{size:"sm",onClick:()=>m(A=>[...A,{key:l(),value:""}]),children:"Add an argument"})})]})}),n.jsx(ie,{label:"Environment variables",group:!0,hint:"A secret is kept in buddi's vault and handed to the program only when it starts. Names with TOKEN, KEY, SECRET or PASSWORD start as secrets.",children:n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[p.map((A,P)=>n.jsxs("div",{className:"connections-row","data-kind":"env",children:[n.jsx("input",{"aria-label":`Variable ${P+1} name`,className:"mono",spellCheck:!1,autoComplete:"off",placeholder:"NAME",value:A.name,onChange:D=>{const O=D.target.value;z(A.key,A.value===""&&!A.kept?{name:O,secret:ET(O)}:{name:O})}}),n.jsx("input",{"aria-label":`Variable ${P+1} value`,type:A.secret?"password":"text",spellCheck:!1,autoComplete:"off",placeholder:A.kept&&A.value===""?"Kept. Type to replace it.":"value",value:A.value,onChange:D=>z(A.key,{value:D.target.value})}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:A.secret,onChange:D=>z(A.key,{secret:D.target.checked,kept:D.target.checked&&A.kept})}),n.jsx("span",{children:"Secret"})]}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>g(D=>D.filter(O=>O.key!==A.key)),"aria-label":`Remove variable ${P+1}`,children:"Remove"})]},A.key)),n.jsx(le,{children:n.jsx(T,{size:"sm",onClick:()=>g(A=>[...A,{key:l(),name:"",value:"",secret:!1,kept:!1}]),children:"Add a variable"})})]})}),R.length>0?n.jsxs(V,{tone:"accent",children:["Your config had a placeholder for ",R.join(", "),". Type the value itself."]}):null,!s&&p.some(A=>A.secret)?n.jsx(V,{tone:"warning",children:"This installation has no vault, so a secret cannot be kept. Turn the vault on first, or switch Secret off."}):null,n.jsx("p",{className:"ui-card-meta",children:"A server that signs you in through a browser opens it on this computer, so it needs a screen. On a machine without one, give it a token as a secret variable instead."}),n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsx("span",{className:"ui-field-label",children:"It will run"}),n.jsx(Pt,{label:"The command line",children:C||"…"})]}),n.jsx(ae,{message:j}),n.jsx(le,{align:"end",children:n.jsx(T,{type:"submit",variant:"accent",disabled:x||o.trim()===""||u.trim()===""||$.length>0,title:$.length>0?`Give ${$.join(", ")} a value.`:void 0,children:x?"Saving…":e?"Save":"Continue"})})]})}function bK({connection:e,onKept:t}){const s=ce(()=>E.connectionReview(e.id),[e.id]),[r,i]=d.useState(null),[a,l]=d.useState(!1),[o,c]=d.useState(null),u=s.data,h=r??(u==null?void 0:u.slug)??"",f=async()=>{var p;if(u){l(!0),c(null);try{t(await E.saveConnectionReview(e.id,{hash:u.hash,...u.slugEditable?{slug:h}:{}}))}catch(g){g instanceof me&&((p=g.detail)==null?void 0:p.code)==="changed"&&s.reload(),c(Ls(g))}finally{l(!1)}}};if(!u)return s.error?n.jsx(ae,{message:s.error}):e.transport==="stdio"?n.jsxs(xe,{children:["Starting ",e.name,"… The first start can take a minute or two while it downloads."]}):n.jsxs(xe,{children:["Reading what ",e.name," offers…"]});const m=u.tools.filter(p=>p.problem===null).length;return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:["Read what ",e.name," brings before it brings it. Each tool gets a buddi name and a tier from what the server says it does; anything that changes something asks you first, on the same approval card as every other tool."]}),u.program?n.jsx(V,{tone:"warning",title:"This runs on this computer as you",children:n.jsxs(re,{gap:"sm",children:[n.jsx(Pt,{label:"The command",children:u.program.line}),n.jsx("p",{children:"It can read and change what you can, and reach the network. buddi starts it with only the variables below, stops it after ten quiet minutes, and asks you again if its command changes."}),u.program.env.length>0?n.jsxs("p",{className:"ui-card-meta",children:["Variables: ",u.program.env.map(p=>`${p.name}${p.secret?" (secret)":""}`).join(", ")]}):null]})}):n.jsxs("p",{className:"ui-card-meta",children:["buddi talks to ",n.jsx("span",{className:"mono",children:u.host})," for these tools, and nowhere else."]}),u.annotatedNothing?n.jsxs(V,{tone:"warning",children:[e.name," says nothing about what its tools do, so every one of them asks you first."]}):null,u.changes&&u.changes.added.length+u.changes.changed.length+u.changes.removed.length>0?n.jsxs(V,{tone:"warning",title:`${e.name} changed its tools since your last review.`,children:[n.jsxs("ul",{className:"connections-changes","aria-label":"What changed",children:[u.changes.added.length>0?n.jsxs("li",{children:["New: ",n.jsx("span",{className:"mono",children:u.changes.added.join(", ")})]}):null,u.changes.changed.length>0?n.jsxs("li",{children:["Changed: ",n.jsx("span",{className:"mono",children:u.changes.changed.join(", ")})]}):null,u.changes.removed.length>0?n.jsxs("li",{children:["Gone: ",n.jsx("span",{className:"mono",children:u.changes.removed.join(", ")})]}):null]}),n.jsx("p",{children:"Until you keep this list, the new and changed tools wait; the others keep working."})]}):null,u.slugEditable?n.jsx(ie,{label:"Its name in buddi",hint:`Tools are called mcp.${h||"…"}.<tool>. Lower case, letters, digits, _ and -.`,children:n.jsx("input",{required:!0,spellCheck:!1,maxLength:24,value:h,onChange:p=>i(p.target.value.toLowerCase())})}):null,u.tools.length===0?n.jsxs(xe,{children:[e.name," lists no tools."]}):n.jsx("div",{className:"ui-list","aria-label":"Tools",children:u.tools.map(p=>{const g=eK(p),x=u.slugEditable?p.fullName.replace(/^mcp\.[^.]+\./,`mcp.${h||u.slug}.`):p.fullName;return n.jsx("div",{className:"ui-list-row connections-tool",children:n.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("span",{className:"mono",children:x}),p.problem?n.jsx(ve,{tone:"muted",children:"Cannot be used"}):n.jsx(ve,{tone:g.tone,children:g.label}),p.change==="added"?n.jsx(pg,{children:"New"}):p.change==="changed"?n.jsx(pg,{children:"Changed"}):null]}),p.description?n.jsx("p",{className:"ui-card-meta",children:p.description}):null,!p.problem&&p.tier==="gated"?n.jsx("p",{className:"ui-card-meta",children:p.destructive?ZH:"You can remember its approval for an agent when you give it the tools, or later on the agent’s Tools tab."}):null,p.problem?n.jsxs("p",{className:"ui-card-meta",children:["Left out: ",p.problem,"."]}):null]})},p.name)})}),n.jsx(ae,{message:o}),n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",onClick:()=>void f(),disabled:a||u.slugEditable&&h.trim()==="",children:m===1?"Keep this tool":`Keep these ${m} tools`})})]})}function kK({connection:e,agents:t,onDone:s}){var b;const r=t.find(j=>j.frontDesk)??t[0],[i,a]=d.useState(()=>new Set(r?[r.id]:[])),o=(((b=ce(()=>E.connectionTools(e.id),[e.id]).data)==null?void 0:b.tools)??[]).filter(j=>j.tier==="gated"),[c,u]=d.useState(()=>new Set),[h,f]=d.useState(!1),[m,p]=d.useState(null),g=(j,v)=>{a(w=>{const y=new Set(w);return v?y.add(j):y.delete(j),y})},x=async()=>{f(!0),p(null);try{const j=await E.grantConnection(e.id,[...i]);if(j.failed.length>0){p(j.failed.map(v=>`${v.agent}: ${v.message}`).join(" "));return}for(const v of j.granted)for(const w of c)await E.setRememberedApproval(v,w,!0);s()}catch(j){p(Ls(j))}finally{f(!1)}};return n.jsxs("div",{className:"ui-stack",children:[n.jsxs("p",{children:[r?`Give these tools to ${r.name}?`:"Which agents get these tools?"," Each one you tick gets ",n.jsx("span",{className:"mono",children:e.grant})," on its tools line."]}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Agents",children:t.map(j=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:i.has(j.id),onChange:v=>g(j.id,v.target.checked)}),n.jsxs("span",{children:[j.name,j.frontDesk?" (front desk)":""]})]},j.id))}),n.jsx("p",{className:"ui-card-meta",children:"No one is fine too: the connection waits here until you give it to someone."}),o.length>0?n.jsxs("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approval",children:[n.jsx("p",{children:"These ask you first. Tick one to remember your approval for the agents above, so it asks only once."}),o.map(j=>n.jsxs(re,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",disabled:!j.rememberable,checked:c.has(j.tool),onChange:v=>u(w=>{const y=new Set(w);return v.target.checked?y.add(j.tool):y.delete(j.tool),y})}),n.jsx("span",{className:"mono",children:j.tool})]}),j.why?n.jsx("p",{className:"ui-card-meta",children:j.why}):null]},j.tool))]}):null,n.jsx(ae,{message:m}),n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:s,disabled:h,children:"Not now"}),n.jsx(T,{variant:"accent",onClick:()=>void x(),disabled:h||i.size===0,children:"Give them"})]})]})}const NK=(e,t,s)=>`${e} ${e===1?t:s}`;function SK(e){return e.state==="pending-review"||!e.slug?"Not finished: its tools are not reviewed yet.":e.state==="needs-review"?"Its tools changed and need your review.":e.state==="needs-reconnect"?"Its sign-in ended; sign in again first.":null}function CK({agentId:e,agentName:t,readOnly:s,version:r,onSaved:i}){const[a,l]=d.useState({}),o=ce(()=>E.connections().then(w=>(l({}),w)),[r]),[c,u]=d.useState(null),[h,f]=d.useState(null),m=De("connections"),p=async(w,y)=>{u(w.id),f(null);try{const N=await E.setConnectionHolder(w.id,e,y);l(k=>({...k,[w.id]:N.held})),i==null||i()}catch(N){f(N instanceof Error?N.message:String(N))}finally{u(null)}},g=o.data,x=(g==null?void 0:g.connections)??[],b=w=>a[w.id]??w.agents.includes(e),j=g?g.agents.some(w=>w.id===e):!0,v=x.filter(b).length;return n.jsxs(oe,{title:"Connections",aside:g&&x.length>0?`holds ${v} of ${x.length} · saved as you change them`:void 0,panel:!0,children:[n.jsx(ae,{message:o.error??h}),g?x.length===0?n.jsxs("p",{className:"ui-card-meta",children:["Nothing is connected yet. ",n.jsx("a",{href:m,children:"Connect a service in Connections"})]}):j?n.jsxs(n.Fragment,{children:[s?n.jsx(V,{tone:"warning",children:"This agent ships with buddi, so its connections are read-only here. Ask Agent Father to make it yours, then it can change."}):null,n.jsx("ul",{className:"ui-list delegate-list","aria-label":`Connections ${t} holds`,children:x.map(w=>{const y=b(w),N=SK(w),k=w.transport==="stdio"?"on this computer":w.host,S=w.slug?NK(w.toolCount,"tool","tools"):"tools not reviewed",C=`holds-${e}-${w.id}`;return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",role:"switch",id:C,checked:y,"aria-checked":y,disabled:s||c!==null||N!==null&&!y,onChange:$=>void p(w,$.target.checked)}),n.jsxs("label",{htmlFor:C,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[w.name,N?n.jsxs(n.Fragment,{children:[" ",n.jsx(ve,{tone:"warning",children:$T(w).label})]}):null]}),n.jsx("span",{className:"ui-list-sub",children:`${k} · ${S}`}),N?n.jsxs("span",{className:"ui-list-sub",children:[N," ",n.jsx("a",{href:m,children:"Open Connections"})]}):null]})]},w.id)})})]}):n.jsxs("p",{className:"ui-card-meta",children:[t," makes and changes agents, so it holds no connections."]}):o.error?null:n.jsx(xe,{children:"Loading the connections…"})]})}const EK=(e,t)=>!!e&&!!t&&e.kind===t.kind&&(e.kind==="mascot"?e.role===t.role:e.kind==="emoji"?e.value===t.value:!0);async function OT(e){const t=await fetch(ca(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const s=await t.blob();return new File([s],`buddi-blob-${e}.png`,{type:"image/png"})}function AK({face:e,onPick:t,label:s=L.assistant.face,kept:r,disabled:i,disableEmoji:a,children:l}){return n.jsxs("div",{className:"meet-faces",role:"group","aria-label":s,children:[n.jsxs("div",{className:"meet-face-row",children:[r?n.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":(e==null?void 0:e.kind)==="kept"?"true":void 0,"aria-pressed":(e==null?void 0:e.kind)==="kept","aria-label":"The current picture",disabled:i,onClick:()=>t({kind:"kept",url:r}),children:n.jsx("img",{src:r,alt:""})}):null,j4.map(o=>{const c={kind:"mascot",role:o},u=EK(e,c);return n.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":L.assistant.mascot(o),disabled:i,onClick:()=>t(c),children:n.jsx("img",{src:ca(o),alt:""})},o)})]}),n.jsx("div",{className:"meet-face-row",children:y4.map(o=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===o;return n.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||a,onClick:()=>t({kind:"emoji",value:o}),children:o},o)})}),l]})}const TK=["mirror","en","fr"],RK=[{value:"3h",label:"3 hours"},{value:"1d",label:"A day"},{value:"1w",label:"A week"},{value:"never",label:"Never"}],Em=10,Am=500,LT=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"tools",label:"Tools"},{id:"team",label:"Team"}],Zk=e=>{var t;return e==="access"?"tools":((t=LT.find(s=>s.id===e))==null?void 0:t.id)??"identity"};function $K({agentId:e,section:t,navigate:s}){var x,b,j;const{data:r,error:i,reload:a}=ce(()=>E.agents(),[]),[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(Zk(t));d.useEffect(()=>f(Zk(t)),[t]);const m=v=>{f(v),s==null||s(At(e,"setup",v))},p=async v=>{o(null),u(null);try{const w=await v;u(w.changed.length===0?`No file change needed. ${w.note}.`:`Changed ${w.changed.join(", ")}. ${w.note}.`),a()}catch(w){o(w instanceof Error?w.message:String(w))}},g=r==null?void 0:r.agents.find(v=>v.id===e);return n.jsxs(re,{gap:"lg",children:[n.jsx(Tc,{level:"secondary",label:"Setup",children:LT.map(v=>n.jsx(ll,{href:At(e,"setup",v.id),active:h===v.id,onClick:w=>{w.preventDefault(),m(v.id)},children:v.label},v.id))}),n.jsx(ae,{message:i??l}),c?n.jsx(V,{tone:"good",role:"status",children:c}):null,r?g?n.jsx(IK,{agent:g,all:r.agents,engine:r.engines.find(v=>v.id===g.id),providers:r.providers,accounts:r.providerAccounts,shown:h,onShow:m,onRun:p,onSaved:a},`${g.id}:${(x=r.engines.find(v=>v.id===g.id))==null?void 0:x.model}:${(j=(b=r.providerAccounts)==null?void 0:b.bindings.find(v=>v.agentId===g.id))==null?void 0:j.accountId}`):n.jsx(xe,{children:"This agent is not installed as a file."}):n.jsx(xe,{children:"Loading…"})]})}function IK({agent:e,all:t,engine:s,providers:r,accounts:i,shown:a,onShow:l,onRun:o,onSaved:c}){const u=(s==null?void 0:s.provider)??e.provider.kind,h=r.find(k=>k.kind===u),f=(s==null?void 0:s.model)??e.model,[m,p]=d.useState(String((s==null?void 0:s.maxTurns)??e.maxTurns)),[g,x]=d.useState(null),b=k=>{o(E.setAgentEngine(e.id,k))},j=k=>{const S=r.find(C=>C.kind===k);b({provider:k,model:(S==null?void 0:S.defaultModel)??f})},v=(h==null?void 0:h.models.map(k=>k.id))??[],w=v.includes(f)?v:[f,...v],y=s?s.available:!0,N=(s==null?void 0:s.unavailableReason)??"no credential";return n.jsxs(n.Fragment,{children:[n.jsx("div",{hidden:a!=="identity",children:n.jsxs(re,{gap:"lg",children:[y?null:n.jsxs(V,{tone:"warning",children:["This agent cannot run right now."," ",n.jsx("a",{href:At(e.id,"setup","brain"),onClick:k=>{k.preventDefault(),l("brain")},children:"See Brain."})]}),n.jsx(PK,{agent:e,onSaved:c})]})}),n.jsx("div",{hidden:a!=="brain",children:n.jsxs(re,{gap:"lg",children:[y?null:n.jsxs(V,{tone:"warning",children:["This agent cannot run right now: ",N,"."]}),n.jsx(oe,{panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsxs(oe,{title:"Runs on",children:[i?n.jsx(zK,{agentId:e.id,accounts:i,onRun:o}):n.jsxs(Os,{children:[n.jsx(ie,{label:"Provider",children:n.jsx("select",{value:u,onChange:k=>j(k.target.value),children:r.map(k=>n.jsxs("option",{value:k.kind,children:[k.kind,k.usable?"":" (no credential)"]},k.kind))})}),n.jsxs(ie,{label:"Model",children:[n.jsx("input",{list:`models-${e.id}`,defaultValue:f,onBlur:k=>{k.target.value.trim()!==""&&k.target.value.trim()!==f&&b({model:k.target.value.trim()})}}),n.jsx("datalist",{id:`models-${e.id}`,children:w.map(k=>n.jsx("option",{value:k},k))})]})]}),i?null:n.jsxs("p",{className:"ui-card-meta",children:[(s==null?void 0:s.credentialKind)??e.provider.credentialKind," from"," ",n.jsx("span",{className:"mono",children:(s==null?void 0:s.credentialEnv)??e.provider.credentialEnv}),h&&!h.usable?` · default model ${h.defaultModel} (${h.defaultFrom})`:""]}),s!=null&&s.restartRequired?n.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),n.jsx(oe,{title:"Behaviour",aside:"saved as you change them",children:n.jsxs(Os,{children:[n.jsx(ie,{label:"Steps per reply",hint:`${s!=null&&s.maxTurnsIsDefault?`Default ${s.defaultMaxTurns??40}. `:""}Each tool call is a step; a reply that uses them all stops and offers Continue.`,after:g?n.jsx("span",{className:"critical save-error",role:"alert",children:g}):null,children:n.jsx("input",{type:"number",min:Em,max:Am,value:m,onChange:k=>{p(k.target.value),x(null)},onBlur:()=>{const k=Number(m);if(!Number.isInteger(k)||k<Em||k>Am){x(`Between ${Em} and ${Am}.`);return}k!==((s==null?void 0:s.maxTurns)??e.maxTurns)&&b({maxTurns:k})}})}),n.jsx(ie,{label:"Language",hint:"Mirror answers in whatever language you write.",children:n.jsx("select",{value:(s==null?void 0:s.language)??e.language,onChange:k=>b({language:k.target.value}),children:TK.map(k=>n.jsx("option",{value:k,children:k},k))})}),s?n.jsx(ie,{label:"New chat after",hint:"Idle time before your next message starts a fresh conversation, with a carried-over note. A transcript that grows too long starts one either way.",children:n.jsx("select",{"aria-label":"New chat after",value:s.idleRollover??"3h",onChange:k=>b({idleRollover:k.target.value==="3h"?null:k.target.value}),children:RK.map(k=>n.jsx("option",{value:k.value,children:k.label},k.value))})}):null,ZC(e1(s??{id:e.id,provider:u},i))?n.jsx(ie,{label:"Thinking",hint:"Reasoning before the answer. Off is faster and cheaper.",children:n.jsxs("select",{"aria-label":"Thinking",value:(s==null?void 0:s.thinking)??"default",onChange:k=>b({thinking:k.target.value==="default"?null:k.target.value}),children:[n.jsx("option",{value:"default",children:"Model default"}),n.jsx("option",{value:"on",children:"On"}),n.jsx("option",{value:"off",children:"Off"})]})}):n.jsx(ie,{label:"Thinking",hint:lO,children:n.jsx("span",{className:"ui-card-meta",children:"Up to the model"})})]})})]})}),n.jsx(St,{summary:"Built-in context",boxed:!0,children:n.jsx("p",{className:"ui-card-meta",children:"Every agent receives current time, owner timezone and server-host information. system.time and system.info are always available, without grants or approval. Host and browser access still require their own permissions."})})]})}),n.jsx("div",{hidden:a!=="tools",children:n.jsxs(re,{gap:"lg",children:[n.jsx(MK,{agent:e,all:t,onSaved:c}),n.jsx(CK,{agentId:e.id,agentName:e.name,readOnly:e.isExample===!0,version:e.tools.join(","),onSaved:c})]})}),n.jsx("div",{hidden:a!=="team",children:n.jsx(re,{gap:"lg",children:n.jsx(HK,{agent:e,all:t,onSaved:c})})})]})}function _T({dirty:e,busy:t,failure:s,label:r,onSave:i}){return n.jsxs(n.Fragment,{children:[s?n.jsx("span",{className:"critical save-error",role:"alert",children:s}):n.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(T,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const FT=n.jsx(V,{tone:"warning",children:"This agent ships with buddi, so its file is read-only here. Ask Agent Father to make it yours, then these fields can change."});function PK({agent:e,onSaved:t}){var U;const[s,r]=d.useState(e.name),[i,a]=d.useState(e.handle),[l,o]=d.useState(e.description),[c,u]=d.useState(e.avatar??""),[h,f]=d.useState(!1),m=ce(()=>E.agentFile(e.id),[e.id]),[p,g]=d.useState(null),x=((U=m.data)==null?void 0:U.persona.trim())??"",b=p??x,j=m.data!==void 0&&p!==null&&p.trim()!==x,[v,w]=d.useState(!1),[y,N]=d.useState(null),[k,S]=d.useState(null),C=s.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||l.trim()!==e.description||c.trim()!==(e.avatar??"")||j,$=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),R=Qg($?{...e,avatar:c.trim()}:e),I={...R?{avatar:R}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!$&&e.picture?{picture:e.picture}:{}},z=async()=>{w(!0),N(null),S(null);try{const A=await E.updateAgentFile(e.id,{name:s.trim(),handle:i.trim().replace(/^@/,""),description:l.trim(),...c.trim()===""?{}:{avatar:c.trim()},...j&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await E.removeAgentPicture(e.id),window.dispatchEvent(new Event(Xo))),g(null),m.reload(),S(A.message),t()}catch(A){N(A instanceof Error?A.message:String(A))}finally{w(!1)}};return n.jsx(oe,{title:"Who it is",aside:n.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:n.jsx(_T,{dirty:C,busy:v,failure:y,label:"Save who it is",onSave:()=>void z()}),children:n.jsxs(re,{children:[e.isExample?FT:null,k?n.jsx(V,{tone:"good",role:"status",children:k}):null,n.jsxs(Os,{children:[n.jsx(ie,{label:"Name",hint:"What it is called, everywhere.",children:n.jsx("input",{value:s,disabled:v||e.isExample,onChange:A=>r(A.target.value)})}),n.jsx(ie,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:n.jsx("input",{value:i,disabled:v||e.isExample,onChange:A=>a(A.target.value)})})]}),n.jsxs(le,{children:[n.jsx(zs,{id:e.id,name:s.trim()||e.name,size:"xl",face:I}),n.jsx(T,{"aria-expanded":h,onClick:()=>f(A=>!A),children:h?"Hide faces":"Change face"})]}),h?n.jsx(_K,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:v}):null,n.jsx(ie,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:n.jsx("textarea",{rows:2,value:l,disabled:v||e.isExample,onChange:A=>o(A.target.value)})}),n.jsx(ie,{label:"Persona",hint:n.jsxs(n.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",n.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:m.error?n.jsx(ae,{message:m.error}):m.data?n.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
|
|
114
|
+
`).length+1),disabled:v||e.isExample,onChange:A=>g(A.target.value)}):n.jsx(xe,{children:"Reading its file…"})})]})})}function MK({agent:e,all:t,onSaved:s}){var $;const r=ce(()=>E.agentTools(e.id),[e.id,e.tools.join(",")]),[i,a]=d.useState(null),[l,o]=d.useState(()=>new Set((e.roles??[]).filter(Eb))),[c,u]=d.useState((e.roles??[]).filter(R=>!Eb(R)).join(", ")),[h,f]=d.useState(!1),[m,p]=d.useState(null),[g,x]=d.useState(null),b=(R,I)=>R.split(I).map(z=>z.trim()).filter(z=>z!==""),j=(($=r.data)==null?void 0:$.granted)??e.tools,v=i??j,w=r.data!==void 0&&!VH(v,j),y=Ab(l,b(c,/[\n,]/)),N=R=>o(I=>{const z=new Set(I);return z.has(R)?z.delete(R):z.add(R),z}),S=w||!((R,I)=>R.join(",")===I.join(","))(y,Ab(new Set(e.roles??[]),e.roles??[])),C=async()=>{f(!0),p(null),x(null);try{const R=await E.updateAgentFile(e.id,{...w&&r.data?{tools:KH(r.data.groups,v)}:{},roles:y});x(R.message),a(null),r.reload(),s()}catch(R){p(R instanceof Error?R.message:String(R))}finally{f(!1)}};return n.jsx(oe,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:n.jsx(_T,{dirty:S,busy:h,failure:m,label:"Save roles and tools",onSave:()=>void C()}),children:n.jsxs(re,{children:[e.isExample?FT:null,g?n.jsx(V,{tone:"good",role:"status",children:g}):null,n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),n.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:Vv.map(R=>{const I=vF(t,R.id),z=I&&I.id!==e.id?I:void 0;return n.jsxs("button",{type:"button",className:"role-chip","aria-pressed":l.has(R.id),"data-on":l.has(R.id)?"true":void 0,disabled:h||e.isExample,onClick:()=>N(R.id),children:[n.jsx("span",{className:"role-chip-label",children:R.label}),n.jsx("span",{className:"role-chip-meaning",children:R.meaning}),z?n.jsxs("span",{className:"role-chip-holder",children:["Held by ",z.name,". If both claim it, the one listed first keeps it."]}):null]},R.id)})}),n.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),n.jsx(ie,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:n.jsx("input",{value:c,disabled:h||e.isExample,onChange:R=>u(R.target.value)})}),n.jsxs("div",{className:"ui-field",children:[n.jsxs("span",{className:"ui-field-label",children:["Tools · ",j.length," granted"]}),r.error?n.jsx(ae,{message:r.error}):r.data?n.jsx(YH,{view:r.data,chosen:v,onChange:a,disabled:h||e.isExample}):n.jsx(xe,{children:"Loading the installed tools…"})]}),n.jsx(DK,{agentId:e.id,version:j.join(","),disabled:h||e.isExample}),OK(j)?n.jsx(LK,{agentId:e.id}):null]})})}function DK({agentId:e,version:t,disabled:s}){var g;const r=ce(()=>Promise.resolve().then(()=>E.rememberedApprovals(e)),[e,t]),i=ce(()=>Promise.resolve().then(()=>E.connections()).catch(()=>null),[]),[a,l]=d.useState(null),[o,c]=d.useState(null),u=((g=r.data)==null?void 0:g.tools)??[];if(u.length===0)return null;const h=async(x,b)=>{l(x),c(null);try{await E.setRememberedApproval(e,x,b),r.reload()}catch(j){c(j instanceof Error?j.message:String(j))}finally{l(null)}},f=new Map;for(const x of u)f.set(x.connection,[...f.get(x.connection)??[],x]);const m=x=>{var b,j;return((j=(b=i.data)==null?void 0:b.connections.find(v=>v.slug===x))==null?void 0:j.name)??x},p=x=>x.tool.split(".").slice(2).join(".")||x.tool;return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Connection tools that ask first"}),n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Remembered approvals",children:[...f].map(([x,b])=>{const j=b.filter(N=>N.rememberable),v=b.filter(N=>!N.rememberable),w=j.filter(N=>N.remembered),y=n.jsxs("span",{className:"remembered-summary",children:[n.jsx("span",{className:"remembered-name",children:m(x)}),n.jsxs("span",{className:"ui-card-meta",children:[` · ${b.length} ask first`,w.length>0?` · ${w.length} remembered: ${w.map(p).join(", ")}`:""]})]});return n.jsxs(St,{summary:y,boxed:!0,children:[n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":`${m(x)}: remember my approval`,children:j.map(N=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:N.remembered,disabled:s||a!==null,onChange:k=>void h(N.tool,k.target.checked),"aria-label":`Remember my approval for ${N.tool}`}),n.jsx("span",{className:"mono",children:p(N)})]},N.tool))}),v.length>0?n.jsxs("p",{className:"ui-card-meta remembered-always",children:["These can delete or destroy something, so they always ask and are never remembered:"," ",n.jsx("span",{className:"mono",children:v.map(p).join(", ")})]}):null]},x)})}),n.jsx(ae,{message:o}),n.jsx("span",{className:"ui-field-hint",children:"Tick a tool to remember your approval: it asks once, then runs for this agent."})]})}function OK(e){return e.some(t=>t==="owner.notify"||t==="owner.*"||t==="owner.notify?"||t==="owner.*?")}function LK({agentId:e}){var h,f;const t=ce(()=>E.notificationSettings(),[]),[s,r]=d.useState(null),[i,a]=d.useState(!1),[l,o]=d.useState(null),c=s??((f=(h=t.data)==null?void 0:h.settings.agents)==null?void 0:f.muted.includes(e))??!1,u=m=>{a(!0),o(null),r(m),E.setAgentMuted(e,m).then(p=>r(p.agents.muted.includes(e))).catch(p=>{r(!m),o(p instanceof Error?p.message:String(p))}).finally(()=>a(!1))};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Messages to you"}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:c,disabled:i||!t.data,onChange:m=>u(m.target.checked),"aria-label":"Mute this agent's messages"}),n.jsx("span",{children:"Mute its messages"})]}),n.jsx(ae,{message:t.error??l}),n.jsx("span",{className:"ui-field-hint",children:"With owner.notify it can message you itself; muted, it is refused and told so."})]})}function Qg(e){if(e.avatar)return/^[A-Za-z0-9_-]+\.(png|jpe?g|gif|webp)$/i.test(e.avatar)?{kind:"image",url:`/api/agents/${encodeURIComponent(e.id)}/avatar`}:{kind:"emoji",value:e.avatar.slice(0,8)}}function _K({agent:e,avatar:t,onEmoji:s,onChanged:r,disabled:i}){const[a,l]=d.useState(null),[o,c]=d.useState(!1),[u,h]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),m=a??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),p=async g=>{if(h(null),g.kind==="emoji"){s(g.value);return}if(g.kind==="kept"){s(e.avatar??"");return}l(g),c(!0);try{await E.uploadAgentPicture(e.id,await OT(g.role)),s(e.avatar??""),r(),window.dispatchEvent(new Event(Xo))}catch(x){h(x instanceof Error?x.message:String(x))}finally{l(null),c(!1)}};return n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Face"}),n.jsx(AK,{face:m,label:"Face",kept:e.picture,disabled:i||o,disableEmoji:e.isExample,onPick:g=>void p(g),children:n.jsx(FK,{agent:e,onChanged:r})}),u?n.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function FK({agent:e,onChanged:t}){const[s,r]=d.useState(null),[i,a]=d.useState(null),[l,o]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[m,p]=d.useState(0);d.useEffect(()=>{if(!s)return a(null);const S=URL.createObjectURL(s);return a(S),()=>URL.revokeObjectURL(S)},[s]);const g=S=>{r(null),p(C=>C+1),f(S),t(),window.dispatchEvent(new Event(Xo))},x=async S=>{o(!0),u(null),f(null);try{g(await S())}catch(C){u(C instanceof Error?C.message:String(C))}finally{o(!1)}},b=()=>x(async()=>(await E.uploadAgentPicture(e.id,s)).note??null),j=()=>x(async()=>(await E.removeAgentPicture(e.id),null)),v={avatar:Qg(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[w,y]=d.useState(!1),N=d.useRef(null),k=S=>{u(null),f(null),r(S??null)};return n.jsxs("div",{className:"setup-upload","data-dragging":w?"true":void 0,onDragOver:S=>{S.preventDefault(),l||y(!0)},onDragLeave:()=>y(!1),onDrop:S=>{var C;S.preventDefault(),y(!1),l||k((C=S.dataTransfer.files)==null?void 0:C[0])},children:[n.jsxs(le,{children:[n.jsx(zs,{id:e.id,name:e.name,size:"xl",face:v}),n.jsx("input",{ref:N,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:l,onChange:S=>{var C;return k((C=S.target.files)==null?void 0:C[0])}},m),n.jsx(T,{disabled:l,onClick:()=>{var S;return(S=N.current)==null?void 0:S.click()},children:"Upload a picture"}),n.jsx("span",{className:"setup-upload-name",children:s?s.name:"or drop one here"}),n.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!s?n.jsx(T,{variant:"ghost",disabled:l,onClick:()=>void j(),children:"Remove picture"}):null,n.jsx(T,{variant:"accent",disabled:!s||l,onClick:()=>void b(),children:"Save picture"})]}),c?n.jsx("span",{className:"critical save-error",role:"alert",children:c}):n.jsx("span",{className:"ui-field-hint",children:h??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function zK({agentId:e,accounts:t,onRun:s}){const r=t.bindings.find(p=>p.agentId===e),[i,a]=d.useState((r==null?void 0:r.accountId)??""),[l,o]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),h=t.accounts.find(p=>p.id===i),f=i!==((r==null?void 0:r.accountId)??"")||l!==((r==null?void 0:r.model)??""),m=t.accounts.find(p=>p.id===(r==null?void 0:r.accountId));return n.jsxs("div",{className:"ui-stack",children:[n.jsxs(le,{valign:"end",children:[n.jsx(ie,{label:"Account",children:n.jsxs("select",{value:i,disabled:c,onChange:p=>{var g;a(p.target.value),o(((g=t.accounts.find(x=>x.id===p.target.value))==null?void 0:g.defaultModel)??"")},children:[n.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(p=>n.jsxs("option",{value:p.id,disabled:!p.enabled,children:[p.label,p.enabled?p.configured?"":" (needs credential)":" (disabled)"]},p.id))]})}),n.jsx(Oj,{accountId:h!=null&&h.configured?i:void 0,label:"Model",value:l,onChange:o,disabled:c},`${i}:${h==null?void 0:h.revision}`)]}),n.jsxs(le,{children:[f&&i&&l.trim()?n.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",m?`${m.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):n.jsx("span",{className:"muted",children:m?`Running on ${m.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsx(T,{variant:"accent",disabled:c||!i||!l.trim()||!f,onClick:()=>{u(!0),s(E.assignProviderAccount(e,i,l).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const UK=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],Tm=e=>e.tools.some(t=>UK.includes(t)),BK=["front-desk","maker"],WK={"front-desk":"Can ask: everyone, as the front desk",maker:"Can ask: everyone, as the maker",list:"Can ask: everyone"};function HK({agent:e,all:t,onSaved:s}){const[r,i]=d.useState(e.delegates),[a,l]=d.useState(!1),[o,c]=d.useState(null),[u,h]=d.useState(!1),[f,m]=d.useState(e.delegates),[p,g]=d.useState(e.asksEveryone),[x,b]=d.useState(!1),j=t.filter(R=>R.id!==e.id),v=BK.find(R=>{var I;return(I=e.roles)==null?void 0:I.includes(R)}),w=p===void 0||x,y=x||[...r].sort().join(",")!==[...f].sort().join(","),N=t.filter(R=>R.id!==e.id&&(R.delegates.includes(e.id)||R.asksEveryone!==void 0&&!Tm(e))),k=R=>i(I=>I.includes(R)?I.filter(z=>z!==R):[...I,R]),S=async R=>{l(!0),c(null),h(!1);try{const I=await E.setDelegates(e.id,R);m(I.delegates),i(I.delegates),g(I.asksEveryone),b(!1),h(!0),s()}catch(I){c(I instanceof Error?I.message:String(I))}finally{l(!1)}},C=()=>{i(j.filter(R=>!Tm(R)).map(R=>R.id)),b(!0),h(!1)},$=y?"Not saved yet.":u?"Saved. Applies to the next run.":w?r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`:"Asks everyone.";return n.jsx(oe,{title:"Delegation",aside:e.tools.includes("agent.delegate")?"holds agent.delegate":"no agent.delegate tool: it cannot ask anyone until granted",panel:!0,foot:e.isExample?void 0:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:y?"warning":"muted",children:$}),n.jsx("span",{className:"ui-toolbar-spacer"}),w&&v!==void 0?n.jsx(T,{disabled:a,onClick:()=>void S(["*"]),children:"Let it ask everyone"}):null,w?n.jsx(T,{variant:"accent",disabled:!y||a,onClick:()=>void S(r),children:"Save who it can ask"}):n.jsx(T,{variant:"accent",disabled:a,onClick:C,children:"Limit to…"})]}),children:n.jsxs(re,{divided:!0,children:[n.jsxs(oe,{title:"Can ask",children:[e.isExample?n.jsx(V,{tone:"warning",children:"This agent ships with buddi, so its allowlist is read-only here. Ask Agent Father to make it yours, then it can change."}):null,n.jsx(ae,{message:o}),w?j.length===0?n.jsx(xe,{children:"Nobody else is installed."}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Only the agents ticked here. New teammates must be added here before it can ask them."}),n.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:j.map(R=>{const I=Tm(R);return n.jsxs("li",{className:"ui-list-row",children:[n.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${R.id}`,checked:r.includes(R.id),disabled:I||e.isExample||a,onChange:()=>k(R.id)}),n.jsxs("label",{htmlFor:`can-ask-${e.id}-${R.id}`,className:"ui-list-main",children:[n.jsxs("span",{className:"ui-list-title",children:[R.name," ",n.jsxs("span",{className:"mono muted",children:["@",R.handle]})]}),n.jsx("span",{className:"ui-list-sub",children:I?"Makes and changes agents. Never reachable by delegation.":R.description})]})]},R.id)})})]}):n.jsxs("p",{className:"ui-card-meta",children:[WK[p??"list"],". New agents are included without being added here; agents that make and change agents are never reachable by delegation."]})]}),n.jsx(oe,{title:"Asked by",children:N.length===0?n.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):n.jsx(fz,{children:N.map(R=>n.jsx(ve,{children:R.name},R.id))})})]})})}const KK=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],VK=[{id:"conversations",label:"Conversations"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"},{id:"memory",label:"Memory"},{id:"skills",label:"Skills"},{id:"setup",label:"Setup"}];function GK({hash:e,timezone:t,navigate:s,agents:r,attention:i,defaultAgentId:a}){var j,v,w,y,N;const l=X_(e),o=((j=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:j[1])??"team",c=k=>S=>{S.preventDefault(),s(k)},u=ce(()=>E.agents(),[]),h=pj(),f=ce(()=>E.offers(),[],2e4),m=gA(),p=(((v=f.data)==null?void 0:v.offers.length)??0)+m.offers.length,g=((y=(w=u.data)==null?void 0:w.default)==null?void 0:y.defaultAgentId)??a??null,x=r.find(k=>k.roles.includes(Bh)),b=vT(r,g);return n.jsxs("div",{className:"ui-page",children:[n.jsx(nc,{title:"Agents",lede:`Your team. Each one is a file on ${h} — what it can reach is listed on its page.`,actions:x?n.jsx(Tt,{variant:"accent",href:at(x.id),onClick:c(at(x.id)),children:"Add an agent"}):null}),n.jsx(Tc,{children:KK.map(k=>n.jsx(ll,{href:k.id==="team"?Et:`${Et}?tab=${k.id}`,active:o===k.id,count:k.id==="offers"?p:void 0,onClick:c(k.id==="team"?Et:`${Et}?tab=${k.id}`),children:k.label},k.id))}),o==="missions"?n.jsx(pT,{timezone:t,embedded:!0}):null,o==="offers"?n.jsx(xA,{offers:m.offers,reload:m.reload}):null,o==="offers"?n.jsx(xT,{embedded:!0}):null,o==="reminders"?n.jsx(bT,{timezone:t,embedded:!0}):null,o==="team"&&b?n.jsx(Yg,{navigate:s,standing:!0}):null,o==="team"?n.jsx(YK,{data:u.data,error:u.error,reload:u.reload}):null,o==="team"?r.length===0?n.jsx(jn,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):n.jsx("div",{className:"agents-grid",children:cE(r,g).map(k=>{const S=Uh(i.get(k.id));return n.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...Cc(Sc(k)),"data-unavailable":k.available?void 0:"true",children:[n.jsx("div",{className:"agent-card-top"}),n.jsx("div",{className:"agent-card-face",children:n.jsx(zs,{id:k.id,name:k.name,size:"xl",unavailable:!k.available,face:k})}),n.jsxs("div",{children:[n.jsxs("div",{className:"ui-card-title",children:[n.jsx("a",{className:"agent-card-link",href:At(k.id,"conversations"),onClick:c(At(k.id,"conversations")),children:k.name}),n.jsxs("span",{className:"agent-card-handle mono faint",children:["@",k.handle]})]}),n.jsx("p",{className:"ui-card-meta agent-card-desc",children:k.description})]}),n.jsxs("div",{className:"ui-row",children:[k.id===g?n.jsx(pg,{children:"front desk"}):null,S?n.jsx(ve,{tone:"critical",dot:!0,children:"waiting for you"}):k.available?n.jsx(ve,{tone:"good",dot:!0,children:"ready"}):n.jsx(ve,{tone:"warning",children:Ds(k.unavailableReason??"cannot run",60)}),n.jsx(ve,{mono:!0,children:k.model}),n.jsx(Tt,{className:"agent-card-talk",size:"sm",href:at(k.id),onClick:c(at(k.id)),"aria-label":`Talk to ${k.name}`,children:"Talk"})]})]},k.id)})}):null,o==="team"&&!b?n.jsx(Yg,{navigate:s,standing:!0}):null,l?n.jsx(ht,{title:((N=r.find(k=>k.id===l.agentId))==null?void 0:N.name)??l.agentId,size:"wide",onClose:()=>s(Et),children:n.jsx(qK,{agentId:l.agentId,agent:r.find(k=>k.id===l.agentId),agents:r,tab:l.tab??"conversations",...l.section?{section:l.section}:{},timezone:t,navigate:s,attention:i})}):null]})}function YK({data:e,error:t,reload:s}){const r=e==null?void 0:e.default,[i,a]=d.useState(null),[l,o]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null);if(t)return n.jsx(ae,{message:t});if(!r||r.choices.length===0)return null;const m=r.defaultAgentId,p=i??m??"",g=p!==""&&p!==m,x=r.problem,b=v=>v.map(w=>{var y;return((y=r.choices.find(N=>N.id===w))==null?void 0:y.name)??w}).join(" and "),j=async()=>{o(!0),u(null),f(null);try{const v=await E.setDefaultAgent(p);f(v.note),a(null),s()}catch(v){u(v instanceof Error?v.message:String(v))}finally{o(!1)}};return n.jsx(qe,{children:n.jsxs("div",{className:"ui-stack",children:[n.jsx(ae,{message:c}),(x==null?void 0:x.code)==="multiple-defaults"?n.jsx(V,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(x.agents)}. The one chosen here wins.`}):(x==null?void 0:x.code)==="no-default-agent"?n.jsx(V,{tone:"warning",role:"status",children:"No agent file claims the default and this installation has not recorded one. Choose who answers when you name nobody."}):null,h?n.jsx(V,{tone:"good",role:"status",children:h}):null,n.jsxs(le,{children:[n.jsxs("div",{className:"default-agent-text",children:[n.jsx("h3",{className:"default-agent-title",children:"Default agent"}),n.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),n.jsx("span",{className:"ui-toolbar-spacer"}),n.jsxs("select",{"aria-label":"Default agent",value:p,disabled:l,onChange:v=>a(v.target.value),children:[p===""?n.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(v=>n.jsxs("option",{value:v.id,disabled:!v.available,children:[v.name," @",v.handle,v.available?"":" (cannot run)"]},v.id))]}),n.jsx(T,{variant:"accent",disabled:l||!g,onClick:()=>void j(),children:"Save"})]})]})})}function qK({agentId:e,agent:t,agents:s,tab:r,section:i,timezone:a,navigate:l,attention:o}){const c=f=>m=>{m.preventDefault(),l(f)},u=Uh(o.get(e)),h=(t==null?void 0:t.name)??e;return n.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[n.jsxs("header",{className:"agent-head",children:[n.jsx(zs,{id:e,name:h,size:"xl",unavailable:t?!t.available:!1,face:t}),n.jsxs("div",{className:"agent-head-text",children:[n.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),n.jsxs("div",{className:"ui-row",children:[t?n.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?n.jsx("span",{className:"muted",children:t.model}):null,u?n.jsx(ve,{tone:"critical",children:u}):t&&!t.available?n.jsx(ve,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),n.jsx("div",{className:"ui-page-actions",children:n.jsxs(Tt,{variant:"accent",href:at(e),onClick:c(at(e)),children:["Talk to ",h]})})]}),t&&!t.available?n.jsxs(V,{tone:"warning",role:"status",children:[dE(t)," ",n.jsx("a",{href:De(cg(t).section),children:cg(t).label})]}):null,n.jsx(Tc,{children:VK.map(f=>n.jsx(ll,{href:At(e,f.id),active:r===f.id,onClick:c(At(e,f.id)),children:f.label},f.id))}),r==="conversations"?n.jsx(QK,{agentId:e,navigate:l}):null,r==="missions"?n.jsx(pT,{timezone:a,embedded:!0,agentId:e}):null,r==="offers"?n.jsx(xT,{embedded:!0,agentId:e,agentName:h}):null,r==="reminders"?n.jsx(bT,{timezone:a,embedded:!0,agentId:e}):null,r==="memory"?n.jsx(jT,{embedded:!0,agents:s,timezone:a,agentId:e}):null,r==="skills"?n.jsx(FH,{agentId:e,agentName:h}):null,r==="setup"?n.jsx($K,{agentId:e,section:i,navigate:l}):null]})}function QK({agentId:e,navigate:t}){const{data:s,error:r}=ce(()=>Be.conversations(e,50),[e]);if(r)return n.jsx(xe,{children:r});const i=(s==null?void 0:s.conversations)??[];return n.jsx(qe,{flush:!0,children:s?i.length===0?n.jsx(jn,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):n.jsx(dt,{children:i.map(a=>n.jsx(it,{href:at(e,a.id),onClick:()=>t(at(e,a.id)),title:Ds(a.preview||a.opening||"Untitled conversation",90),sub:`${a.messageCount} message${a.messageCount===1?"":"s"}`,side:Oe(a.lastMessageAt??a.startedAt??a.createdAt??null)},a.id))}):n.jsx(xe,{children:"Loading…"})})}const e0=3,XK=40;function JK({agent:e,navigate:t}){var g;const s=d.useRef(null),[r,i]=d.useState(!1),[a,l]=d.useState(null),[o,c]=d.useState(null),u=ce(()=>Be.conversations(e.id,e0),[e.id],3e4),h=Ps(nj),f=Ps("(pointer: coarse)");d.useEffect(()=>{var x;!h&&!f&&((x=s.current)==null||x.focus())},[]);const m=(x,b)=>{i(!0),l(null),(async()=>{try{const{conversationId:j}=await Be.startConversation(e.id),v=await Be.send(e.id,{conversationId:j,text:x,...b.length>0?{attachmentIds:b.map(w=>w.artifactId)}:{}});t(at(e.id,v.conversationId))}catch(j){l(j instanceof me?j.message:String(j)),c({text:x,at:Date.now()}),i(!1)}})()},p=(((g=u.data)==null?void 0:g.conversations)??[]).slice(0,e0);return n.jsxs("div",{className:"home-ask",children:[a?n.jsx(ae,{message:a}):null,n.jsx(gj,{ref:s,disabled:r||!e.available,running:!1,onSend:m,onStop:()=>{},agentName:e.name,placeholder:`Message ${e.name}…`,draft:o,threadKey:`home.${e.id}`,slim:!0}),p.length>0?n.jsxs("div",{className:"home-continue",children:[n.jsx("span",{className:"home-continue-label",id:`home-continue-${e.id}`,children:"Continue"}),n.jsx("ul",{className:"home-continue-chips","aria-labelledby":`home-continue-${e.id}`,children:p.map(x=>{const b=at(e.id,x.id),j=x.opening??x.preview??"Untitled conversation",v=Ev(x.lastMessageAt??x.createdAt??x.startedAt??null);return n.jsx("li",{children:n.jsxs("a",{className:"home-continue-chip",href:b,title:j,onClick:w=>{w.preventDefault(),t(b)},children:[n.jsx("span",{className:"home-continue-title",children:Ds(j,XK)}),v?n.jsx("span",{className:"home-continue-when",children:v}):null]})},x.id)})})]}):null]})}function ZK(e){const t=e.indexOf("?");if(t===-1)return;const s=new URLSearchParams(e.slice(t+1)).get("tip");return s&&/^[a-z0-9-]{1,40}$/.test(s)?s:void 0}function eV({navigate:e,preview:t,hidden:s}){var c;const r=ce(()=>E.currentTip(t),[t]),[i,a]=d.useState(null),l=((c=r.data)==null?void 0:c.tip)??null;if(!l||i===l.id||s)return null;const o=u=>{a(l.id),!t&&(u==="dismiss"?E.dismissTip(l.id):E.laterTip(l.id)).catch(()=>{})};return n.jsx("div",{className:"home-tip","data-tip":l.id,children:n.jsxs(V,{children:[n.jsxs("div",{className:"ui-notice-row",children:[n.jsx("p",{className:"ui-notice-body",children:l.text}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"Not now",title:"Not now",onClick:()=>o("later"),children:n.jsx(ue,{name:"close"})})]}),n.jsxs(le,{children:[n.jsx(_t,{}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>o("dismiss"),children:"Not this again"}),n.jsx(T,{variant:"accent",size:"sm",onClick:()=>e(l.action.route),children:l.action.label})]})]})})}const Xg="buddi.tipsOpen";function tV(e){return Th(e,{compact:!0})}function nV(e){switch(e.status){case"today":return"Due today";case"holding":return"Waiting";case"quiet":return"Not needed now";case"dismissed":return"Dismissed";case"shown":return e.shownAt?`Shown on ${tV(e.shownAt)}`:"Shown"}}function sV(){try{return window.localStorage.getItem(Xg)==="1"}catch{return!1}}function rV(){const e=ce(()=>E.tips(),[]),[t,s]=d.useState(sV),r=d.useCallback(i=>{s(i);try{i?window.localStorage.setItem(Xg,"1"):window.localStorage.removeItem(Xg)}catch{}},[]);return{open:t,setOpen:r,list:e}}function iV({tips:e}){const{open:t,setOpen:s,list:r}=e,i=!!r.data&&!r.data.enabled&&r.data.tips.some(a=>a.status==="today");return n.jsxs("button",{type:"button",className:"ui-icon-btn home-tips-btn","aria-label":i?"Tips, one due today":"Tips","aria-pressed":t,title:"Tips","data-open":t,onClick:()=>{t||r.reload(),s(!t)},children:[n.jsx(ue,{name:"bulb"}),i?n.jsx("span",{className:"home-tips-dot","data-testid":"tips-dot"}):null]})}function aV({tips:e,navigate:t}){var b,j;const{open:s,setOpen:r,list:i}=e,[a,l]=d.useState(null),[o,c]=d.useState(null),[u,h]=d.useState(null);if(!s)return null;const f=((b=i.data)==null?void 0:b.tips)??null,m=u??((j=i.data)==null?void 0:j.enabled)??!0,p=v=>l(v instanceof me?v.message:String(v)),g=v=>{c(v),l(null),E.restoreTip(v).then(()=>i.reload(),p).finally(()=>c(null))},x=v=>{c("switch"),l(null),h(v),E.saveTipsSettings(v).then(w=>{h(w.enabled),i.reload()}).catch(w=>{h(!v),p(w)}).finally(()=>c(null))};return n.jsx("div",{className:"home-tips","data-testid":"tips-section",children:n.jsxs(oe,{title:"Tips",children:[n.jsx(ae,{message:i.error??a}),n.jsx("div",{className:"tips-grid",children:(f??[]).map(v=>n.jsx("div",{className:"tips-card","data-tip":v.id,"data-status":v.status,children:n.jsxs(ws,{tone:v.status==="today"?"accent":void 0,children:[n.jsx("div",{children:n.jsx(ve,{tone:v.status==="today"?"accent":"muted",children:nV(v)})}),n.jsx("p",{className:"tips-card-text",children:v.text}),n.jsxs(le,{children:[n.jsx(_t,{}),v.status==="dismissed"?n.jsx(T,{size:"sm",disabled:o===v.id,onClick:()=>g(v.id),children:"Bring back"}):n.jsx(T,{size:"sm",variant:v.status==="today"?"accent":void 0,onClick:()=>t(v.action.route),children:v.action.label})]})]})},v.id))}),n.jsxs(le,{children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:m,disabled:o==="switch"||f===null,onChange:v=>x(v.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Close"})]})]})})}const zT="buddi.needsYouView";function lV(){try{return window.localStorage.getItem(zT)==="list"?"list":"deck"}catch{return"deck"}}function oV(e){try{window.localStorage.setItem(zT,e)}catch{}}function cV(e,t,s){const r=(t.alsoFrom??[]).filter(i=>i!==t.agentId).map(s);return r.length===0?e:`${e} · also ${r.join(", ")}`}function uV({rows:e,agents:t,label:s,onOpen:r,onDone:i}){const[a,l]=d.useState(0);if(e.length===0)return n.jsx(xe,{mascot:!0,children:"Nothing needs you. Your agents are on it."});const o=Math.min(a,e.length-1),c=e[o],u=e.length>1,h=x=>l((o+x+e.length)%e.length),f=()=>r(c),m=()=>i(c),p=x=>{const b=x.target;b.closest('input, textarea, select, [contenteditable="true"]')||(x.key==="ArrowRight"&&u?(x.preventDefault(),h(1)):x.key==="ArrowLeft"&&u?(x.preventDefault(),h(-1)):x.key==="Enter"&&!b.closest("button, a")?(x.preventDefault(),c.link&&f()):(x.key==="d"||x.key==="Delete")&&!x.metaKey&&!x.ctrlKey&&!x.altKey&&(x.preventDefault(),m()))},g=n.jsxs("span",{className:"home-deck-from",children:[c.agentId?n.jsx(gn,{agents:t,id:c.agentId,size:"sm"}):null,n.jsx("span",{children:s(c)})]});return n.jsx("div",{className:"home-deck","data-depth":Math.min(e.length-1,2),role:"region","aria-label":"Needs you, one at a time","aria-roledescription":"deck",tabIndex:0,onKeyDown:p,children:n.jsx(ws,{as:"article",title:g,meta:n.jsx("span",{className:"ui-card-meta",children:c.state==="held"?"today":Oe(c.createdAt)}),actions:n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"home-deck-count","aria-live":"polite",children:[o+1," of ",e.length]}),n.jsx(T,{size:"sm",variant:"ghost","aria-label":"Previous",disabled:!u,onClick:()=>h(-1),children:n.jsx(ue,{name:"chevron-left"})}),n.jsx(T,{size:"sm",variant:"ghost","aria-label":"Next",disabled:!u,onClick:()=>h(1),children:n.jsx(ue,{name:"chevron-right"})})]}),foot:n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:m,children:"Done"}),c.link?n.jsx(T,{variant:"accent",onClick:f,children:"Open"}):null]}),children:n.jsxs("div",{className:"home-deck-body",children:[n.jsx("p",{className:"home-deck-title",children:Qo(c)}),c.text?n.jsx("p",{className:"home-deck-text",children:c.text}):null]})})})}function dV({timezone:e,navigate:t,agents:s,defaultAgentId:r,attention:i,update:a,connectionSignals:l=[],hash:o=""}){var pe,Re,Se,Fe,Ze,Ee,ze,nt,Ye,J,je,Ge,lt,ot;const c=ce(()=>E.overview(),[],15e3),u=ce(()=>E.approvals(),[],1e4),h=ce(()=>E.missions(),[],6e4),f=ce(()=>E.reminders(),[],6e4),m=ce(()=>E.conversations(),[],3e4),p=ce(()=>E.offers(),[],3e4),g=ce(()=>E.proposals(),[],6e4),x=ce(()=>E.agentOffers(),[],6e4),b=ce(()=>E.owner(),[]),j=ce(()=>E.notifications(20),[],3e4),v=d.useMemo(()=>cE(s,r??null),[s,r]),{busy:w,note:y,failure:N,decide:k}=xj(()=>{u.reload(),c.reload()}),S=c.data,C=s.find(q=>q.id===r)??null,$=q=>{var ft;return((ft=s.find(yt=>yt.id===q))==null?void 0:ft.name)??q},R=q=>ft=>{ft.preventDefault(),t(q)},I=((pe=u.data)==null?void 0:pe.pending)??[],z=((Re=S==null?void 0:S.jobs)==null?void 0:Re.failed)??0,U=((Se=S==null?void 0:S.sentinels)==null?void 0:Se.openUrgent)??0,A=((Fe=g.data)==null?void 0:Fe.open.length)??0,P=(((Ze=x.data)==null?void 0:Ze.offers)??[]).filter(q=>!I.some(ft=>pA(ft,q.plugin,q.agent))),D=mV(((Ee=j.data)==null?void 0:Ee.notifications)??[],I),[O,M]=d.useState(new Set),[W,_]=d.useState(lV),G=D.filter(q=>!O.has(q.id)),B=q=>{M(ft=>new Set(ft).add(q.id)),E.notificationSeen(q.id).catch(()=>{})},K=q=>{B(q),q.link&&t(q.link)},F=q=>cV(q.agentId?$(q.agentId):q.pluginId??fV[q.kind],q,$),Q=I.length+(z>0?1:0)+(U>0?1:0)+(A>0?1:0)+P.length+D.length;d.useEffect(()=>{var q,ft;o===Lh&&((ft=(q=document.getElementById(Jg))==null?void 0:q.scrollIntoView)==null||ft.call(q,{behavior:"smooth",block:"start"}))},[o]);const X=d.useMemo(()=>{var q,ft;return vV(((q=h.data)==null?void 0:q.missions)??[],((ft=f.data)==null?void 0:ft.reminders)??[])},[h.data,f.data]),Z=(((ze=m.data)==null?void 0:ze.conversations)??[]).slice(0,5),de=((nt=p.data)==null?void 0:nt.offers)??[],_e=de.slice(0,pV),Ie=rV(),Ue=de.length-_e.length,ee=qA(()=>c.reload()),be=oW(),se=d.useMemo(()=>cW(be.answer),[be.answer]),Te=NV({approvals:I.length,failed:z,urgent:U,paused:(S==null?void 0:S.paused)??!1,proposals:A,agentsToSetUp:P.length,messages:D.length});return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"home-band",children:n.jsxs("header",{className:"home-top",children:[n.jsxs("div",{className:"home-top-text",children:[n.jsxs("p",{className:"home-date",children:[n.jsx("span",{children:yV(S==null?void 0:S.now,e)}),n.jsx(z8,{glances:S==null?void 0:S.glances,navigate:t,except:se,hiding:ee}),n.jsx(iV,{tips:Ie})]}),n.jsx("h1",{className:"home-greeting",children:wV(S==null?void 0:S.now,e,((Ye=b.data)==null?void 0:Ye.preferredName)||((J=b.data)==null?void 0:J.displayName))}),n.jsx(SV,{items:Te,navigate:t})]}),n.jsx("div",{className:"home-side",children:n.jsx(xE,{size:"lg",anim:"idle"})})]})}),n.jsxs("div",{className:"home",children:[C?n.jsx(JK,{agent:C,navigate:t},C.id):null,n.jsx(aV,{tips:Ie,navigate:t}),n.jsx(eV,{navigate:t,preview:ZK(o),hidden:Ie.open}),a&&a.updateAvailable&&!a.checkout&&a.latest?n.jsx(V,{tone:"accent",children:n.jsxs("p",{children:["A newer buddi is ready: ",n.jsx("span",{className:"mono",children:a.latest}),"."," ",n.jsx("a",{href:De("system"),onClick:R(De("system")),children:"Upgrade from Settings → Version."})]})}):null,l.map(q=>n.jsx(V,{tone:"accent",children:n.jsxs("p",{children:[q.sentence," ",n.jsx("a",{href:De("connections"),onClick:R(De("connections")),children:"Settings → Connections."})]})},q.id)),n.jsx(ae,{message:c.error??u.error??N}),y?n.jsx(V,{tone:"good",role:"status",children:y}):null,Q>0?n.jsx("div",{id:Jg,className:"home-needs",children:n.jsx(oe,{title:"Needs you",actions:D.length>0?n.jsx(rn,{label:"Show what needs you as",options:[{value:"list",label:"List"},{value:"deck",label:"Deck"}],value:W,onChange:q=>{_(q),oV(q)}}):void 0,children:n.jsxs(re,{children:[I.map(q=>n.jsx(vj,{action:q,timezone:e,busy:w===q.id,onDecide:k,agentName:$(q.agentId)},q.id)),D.length>0&&W==="deck"?n.jsx(uV,{rows:G,agents:s,label:F,onOpen:K,onDone:B}):null,D.length>0&&W==="list"?n.jsx(qe,{flush:!0,children:n.jsx(dt,{children:G.map(q=>n.jsx(it,{href:q.link??void 0,onClick:()=>K(q),lead:q.agentId?n.jsx(gn,{agents:s,id:q.agentId,size:"sm"}):void 0,title:Qo(q),sub:F(q),side:q.state==="held"?"today":Oe(q.createdAt)},q.id))})}):null,z>0?n.jsx(V,{tone:"critical",children:n.jsxs("a",{href:`${vt}/jobs?state=failed`,onClick:R(`${vt}/jobs?state=failed`),children:[z," failed job",z===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,U>0?n.jsx(V,{tone:"warning",children:n.jsx("a",{href:`${vt}/alerts`,onClick:R(`${vt}/alerts`),children:kV(U,((je=S==null?void 0:S.sentinels)==null?void 0:je.decisions)??[])})}):null,P.map(q=>n.jsx(qe,{children:n.jsx(wj,{plugin:q.plugin,agent:q.agent,text:q.text,label:`Create @${q.handle}`,handle:q.handle,onDismiss:()=>{E.dismissAgentOffer(q.plugin,q.agent).then(()=>x.reload())}})},`${q.plugin}/${q.agent}`)),A>0?n.jsx(V,{tone:"accent",children:n.jsxs("a",{href:De("proposals"),onClick:R(De("proposals")),children:[A," proposal",A===1?"":"s"," from your agents to keep or discard."]})}):null,(((Ge=S==null?void 0:S.sentinels)==null?void 0:Ge.errors)??[]).map(q=>n.jsxs(V,{tone:"warning",children:["Watcher ",q.sentinelId," failed: ",q.error]},q.sentinelId)),((S==null?void 0:S.mail)??[]).filter(q=>q.lastError).map(q=>n.jsxs(V,{tone:"warning",children:["Source ",q.sourceId,": ",q.lastError]},q.sourceId))]})})}):null,n.jsx(fW,{widgets:be,navigate:t}),n.jsx(oe,{title:"Your team",aside:n.jsx("a",{href:Et,onClick:R(Et),children:"All agents"}),children:s.length===0?n.jsx(xe,{mascot:!0,children:"No agents yet. Add one under Agents."}):n.jsx("div",{className:"home-team",children:v.map(q=>{const ft=Uh(i.get(q.id));return n.jsxs("a",{className:"home-face",...Cc(Sc(q)),href:at(q.id),onClick:R(at(q.id)),"data-waiting":ft?"true":void 0,"data-unavailable":q.available?void 0:"true",children:[n.jsx(zs,{id:q.id,name:q.name,size:"lg",unavailable:!q.available,face:q}),n.jsxs("span",{className:"home-face-text",children:[n.jsx("span",{className:"home-face-name",children:q.name}),n.jsx("span",{className:"home-face-status",children:ft?CV(ft):q.available?Ds(q.description,60):q.unavailableReason??"Cannot run right now."})]})]},q.id)})})}),vT(s,r)?n.jsx(Yg,{navigate:t}):null,_e.length>0?n.jsx(oe,{title:"On offer",aside:n.jsxs("span",{className:"ui-row",children:[Ue>0?n.jsxs("a",{href:`${Et}?tab=offers`,onClick:R(`${Et}?tab=offers`),children:[Ue," more"]}):null,n.jsx(gT,{ids:de.map(q=>q.id),onDone:()=>p.reload()})]}),children:n.jsx("div",{className:"home-offers",children:_e.map(q=>n.jsx(xV,{offer:q,agents:s,open:R(At(q.agentId,"offers")),onDismissed:()=>p.reload()},q.id))})}):null,n.jsx(A8,{}),(ot=(lt=g.data)==null?void 0:lt.digest)!=null&&ot.latest?n.jsx(bV,{digest:g.data.digest.latest,go:R}):null,n.jsxs("div",{className:"home-columns",children:[n.jsx(oe,{title:"Coming up",aside:n.jsx("a",{href:`${Et}?tab=missions`,onClick:R(`${Et}?tab=missions`),children:"All missions"}),children:n.jsx(qe,{flush:!0,children:X.length===0?n.jsx(xe,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):n.jsx(dt,{children:X.map(q=>n.jsx(it,{href:q.route,onClick:()=>t(q.route),lead:n.jsx(gn,{agents:s,id:q.agentId,size:"sm"}),title:q.title,sub:`${q.kind} for ${$(q.agentId)}`,side:Oe(q.at)},q.key))})})}),n.jsx(oe,{title:"Lately",aside:n.jsx("a",{href:vt,onClick:R(vt),children:"All activity"}),children:n.jsx(qe,{flush:!0,children:Z.length===0?n.jsx(xe,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):n.jsx(dt,{children:Z.map(q=>n.jsx(it,{href:at(q.agentId,q.id),onClick:()=>t(at(q.agentId,q.id)),lead:n.jsx(gn,{agents:s,id:q.agentId,size:"sm"}),title:q.opening?Ds(q.opening,80):"Untitled conversation",sub:`${$(q.agentId)}, ${q.messageCount} message${q.messageCount===1?"":"s"}`,side:Oe(q.lastMessageAt??q.createdAt)},q.id))})})})]}),((S==null?void 0:S.home)??[]).map(q=>n.jsx(EV,{block:q},q.id)),S!=null&&S.jobs&&S.missions?n.jsxs("p",{className:"home-foot muted",children:[Gt(S.jobs.pending??0)," queued, ",Gt(S.jobs.leased??0)," running, ",Gt(S.missions.enabled)," of ",Gt(S.missions.total)," missions on."," ",S.paused?n.jsx(ve,{tone:"warning",children:"paused"}):n.jsx(ve,{tone:"good",children:"running"})," ",n.jsx("a",{href:il("").replace(/\/conversations\/$/,""),onClick:R(vt),children:"Activity"})," · ",n.jsx("a",{href:De("system"),onClick:R(De("system")),children:"System"})]}):null]})]})}const hV=new Set(["watcher","reminder","failure","recap","plugin","agent"]),fV={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin",agent:"Message"};function mV(e,t){const s=new Set(t.map(r=>r.id));return e.filter(r=>hV.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&s.has(r.actionId)))}const pV=6,gV=500;function xV({offer:e,agents:t,open:s,onDismissed:r}){const[i,a]=d.useState(!1),l=d.useRef(null),o=d.useRef(!1),c=()=>{i||(a(!0),E.dismissOffer(e.id).then(r).finally(()=>a(!1)))},u=()=>{l.current!==null&&clearTimeout(l.current),l.current=null};return n.jsxs("span",{className:"home-offer-chip",children:[n.jsxs("a",{className:"home-offer",href:At(e.agentId,"offers"),onClick:h=>{if(o.current){o.current=!1,h.preventDefault();return}s(h)},title:e.prompt,onTouchStart:()=>{o.current=!1,u(),l.current=setTimeout(()=>{o.current=!0,c()},gV)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[n.jsx(gn,{agents:t,id:e.agentId,size:"sm"}),n.jsx("span",{children:e.label})]}),n.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function vV(e,t){const s=[];for(const r of e)r.enabled&&r.nextRun&&s.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:At(r.agentId,"missions")});for(const r of t)r.state==="pending"&&s.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:At(r.agentId,"reminders")});return s.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function jV(e,t){try{const s=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(s)}catch{return new Date().getHours()}}function wV(e,t,s){const r=jV(e,t),i=s!=null&&s.trim()?`, ${s.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function yV(e,t){try{return dr(e?new Date(e):new Date,t,{weekday:!0})}catch{return et(e??null,t)}}function Su(e,t,s){return e.count===0?null:`${e.count} ${e.count===1?t:s}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function bV({digest:e,go:t}){var a,l;const s=[Su(e.memory,"memory note","memory notes"),Su(e.skills,"skill kept","skills kept"),Su(e.rules,"rule kept","rules kept"),Su(e.changes,"change to an agent kept","changes to agents kept")].filter(o=>o!==null),r=e.stopped===null?"Not measured yet.":e.stopped.total>0?`Rules you kept acted ${e.stopped.total} time${e.stopped.total===1?"":"s"} (${Object.entries(e.stopped.byPlugin).filter(([,o])=>o>0).map(([o,c])=>`${o} ${c}`).join(", ")}).`:"No rule you kept acted this week.",i=Object.entries(((a=e.feedback)==null?void 0:a.byAgent)??{}).map(([o,c])=>[o,[c.up>0?`${c.up} 👍`:"",c.down>0?`${c.down} 👎`:"",c.neutral>0?`${c.neutral} other`:""].filter(Boolean).join(" ")]).filter(([,o])=>o!=="").map(([o,c])=>{var u;return`${((u=e.agentNames)==null?void 0:u[o])??o}: ${c}`});return n.jsx(oe,{title:"What buddi learned this week",aside:n.jsx("span",{className:"muted",children:Oe(e.at)}),children:n.jsx(qe,{children:n.jsxs(re,{divided:!0,children:[n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Learned"}),s.length===0?n.jsx("p",{children:"Nothing new."}):n.jsx("ul",{className:"home-digest-list",children:s.map(o=>n.jsx("li",{children:o},o))})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Proposes"}),n.jsx("p",{children:e.open>0?n.jsxs("a",{href:De("proposals"),onClick:t(De("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),n.jsxs("div",{children:[n.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),n.jsx("p",{children:r})]}),i.length>0?n.jsxs("div",{"data-testid":"digest-reactions",children:[n.jsx("p",{className:"ui-card-meta",children:"Your reactions"}),n.jsxs("ul",{className:"home-digest-list",children:[i.map(o=>n.jsx("li",{children:o},o)),(((l=e.feedback)==null?void 0:l.notes)??[]).map((o,c)=>{var u;return n.jsxs("li",{children:["What was off (",((u=e.agentNames)==null?void 0:u[o.agentId])??o.agentId,"): ",o.note]},`note-${c}`)})]})]}):null]})})})}function kV(e,t){const s=t[0];return s?e>1?`${s.title} And ${e-1} more to decide on.`:s.title:`${e} alert${e===1?"":"s"} from your watchers need${e===1?"s":""} a decision.`}const Jg="home-needs";function NV(e){const t=(r,i,a=`${i}s`)=>r===1?i:a,s=[];return e.approvals>0&&s.push({key:"approvals",count:e.approvals,label:t(e.approvals,"approval")}),e.failed>0&&s.push({key:"failed",count:e.failed,label:t(e.failed,"failed job"),tone:"critical",route:`${vt}/jobs?state=failed`}),e.urgent>0&&s.push({key:"urgent",count:e.urgent,label:t(e.urgent,"urgent alert"),tone:"critical",route:`${vt}/alerts`}),e.paused&&s.push({key:"paused",count:null,label:"Paused",route:`${vt}/jobs`}),e.proposals>0&&s.push({key:"proposals",count:e.proposals,label:t(e.proposals,"proposal"),route:De("proposals")}),e.agentsToSetUp>0&&s.push({key:"agents",count:e.agentsToSetUp,label:t(e.agentsToSetUp,"agent to set up","agents to set up")}),e.messages>0&&s.push({key:"messages",count:e.messages,label:t(e.messages,"message")}),s}function SV({items:e,navigate:t}){if(e.length===0)return n.jsx("p",{className:"home-calm",children:"Nothing needs you. Your agents are on it."});const s=()=>{var r,i;(i=(r=document.getElementById(Jg))==null?void 0:r.scrollIntoView)==null||i.call(r,{behavior:"smooth",block:"start"})};return n.jsx("p",{className:"home-counts",children:e.map((r,i)=>{const a=n.jsxs(n.Fragment,{children:[r.count!==null?n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:r.count})," "]}):null,r.label]});return n.jsxs(d.Fragment,{children:[i>0?n.jsx("span",{className:"home-count-sep","aria-hidden":"true",children:"·"}):null,r.route?n.jsx("a",{className:"home-count","data-tone":r.tone,href:r.route,onClick:l=>{l.preventDefault(),t(r.route)},children:a}):n.jsx("button",{type:"button",className:"home-count","data-tone":r.tone,onClick:s,children:a})]},r.key)})})}function CV(e){return e.charAt(0).toUpperCase()+e.slice(1)}function EV({block:e}){const[t,s]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const a=()=>{document.visibilityState==="hidden"&&s(!1)};return document.addEventListener("visibilitychange",a),window.addEventListener("blur",a),()=>{document.removeEventListener("visibilitychange",a),window.removeEventListener("blur",a)}},[e.sensitive,t]);const i=n.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?n.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?n.jsx(T,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>s(a=>!a),children:r?"Show":"Hide"}):null]});return n.jsxs(oe,{title:e.title,aside:i,children:[e.note?n.jsx(V,{tone:"warning",children:e.note}):null,e.stats.length>0?n.jsx(qh,{children:e.stats.map(a=>n.jsx(tr,{label:a.label,value:r?"••••":a.value,note:r?void 0:a.note,tone:r?void 0:a.tone},a.label))}):null,e.rows.length>0?r?n.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):n.jsx(qe,{flush:!0,children:n.jsx(dt,{children:e.rows.map((a,l)=>n.jsx(it,{title:a.title,sub:a.sub,side:a.side?n.jsx("span",{className:a.tone==="critical"?"critical":a.tone==="good"?"good":void 0,children:a.side}):void 0},`${a.title}-${l}`))})}):null]})}const AV=3e4;function UT(){const{data:e,reload:t}=ce(()=>E.recovery(),[],AV),s=d.useRef(t);return s.current=t,d.useEffect(()=>{const r=()=>s.current(),i=()=>{document.visibilityState==="visible"&&r()};return window.addEventListener("focus",r),document.addEventListener("visibilitychange",i),()=>{window.removeEventListener("focus",r),document.removeEventListener("visibilitychange",i)}},[]),{data:e,reload:t}}function t0(e){return e.kind==="account"?e.accountId?J1(e.accountId):De("accounts"):e.kind==="telegram"?De("telegram"):e.kind==="connection"?e.connectionId?Z1(e.connectionId):De("connections"):e.kind==="email"?e.settingsRoute:De("secrets")}function TV(e){return e.install?iF(e.install):aF}const RV=De("system");function $V(e){return e.loadsAtRestart?`installed — loads at the next restart${e.waiting?`; ${e.waiting.note}`:""}`:e.waiting?`${e.name} — ${e.waiting.note}`:e.source}const IV="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function PV({view:e,onLeft:t}){const{secrets:s,plugins:r,pending:i,grants:a}=e.checklist,l=e.checklist.keptTables??[],[o,c]=d.useState(!0),[u,h]=d.useState([]),[f,m]=d.useState(!1),[p,g]=d.useState(null),[x,b]=d.useState(!1),j=r.filter(N=>!N.installed||N.waiting!==void 0||N.loadsAtRestart===!0),v=i.jobs+i.missions+i.approvals+i.telegramChats,w=N=>{h(k=>k.includes(N)?k.filter(S=>S!==N):[...k,N])},y=()=>{m(!0),g(null),zh({kind:"recovery"},()=>E.leaveRecovery({dropPending:o,keepGrants:u})).then(N=>{N&&N.restarting===!1&&al(),b(!0),t==null||t()}).catch(N=>g(N instanceof me?N.message:String(N))).finally(()=>m(!1))};return n.jsx(qe,{title:"Back from a backup",children:n.jsxs(re,{divided:!0,children:[n.jsxs(oe,{children:[n.jsx(Wt,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:n.jsx("span",{className:"mono",children:e.archive??"—"})}]}),n.jsx("p",{className:"ui-card-meta",children:"Nothing runs on its own yet: no schedules, no watchers, no phone. Chat works. Go through what is below, then turn this buddi back on."})]}),n.jsx(oe,{title:"Keys to paste again",children:s.length===0?n.jsx(xe,{children:"Nothing is missing."}):n.jsx(dt,{children:s.map(N=>n.jsx(it,{title:N.label??N.name,sub:N.name?n.jsx("span",{className:"mono",children:N.name}):void 0,side:N.signIn?n.jsx(Tt,{size:"sm",href:t0(N),"aria-label":`Sign in again: ${N.label??N.name}`,children:"Sign in again"}):n.jsx(Tt,{size:"sm",href:t0(N),"aria-label":`Fix ${N.label??N.name}`,children:"Fix"})},`${N.kind}:${N.accountId??N.name}`))})}),n.jsx(oe,{title:"Add-ons to install again",children:j.length===0&&l.length===0?n.jsx(xe,{children:"Everything the backup named is installed."}):n.jsxs(dt,{children:[j.map(N=>n.jsx(it,{title:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"mono",children:N.name})," ",N.version]}),sub:$V(N),side:N.loadsAtRestart?n.jsx(Tt,{size:"sm",href:RV,"aria-label":`Restart to load ${N.name}`,children:"Restart"}):N.installed?void 0:n.jsx(Tt,{size:"sm",href:TV(N),"aria-label":`Install ${N.name} again`,children:N.install?"Install":"Find it"})},N.name)),l.map(N=>n.jsx(it,{title:n.jsx("span",{className:"mono",children:N.table}),sub:N.sentence},`kept:${N.table}`))]})}),n.jsx(oe,{title:"Work that was waiting",children:v===0?n.jsx(xe,{children:"Nothing was in flight when the backup was taken."}):n.jsxs(re,{gap:"sm",children:[n.jsx(Wt,{items:[{label:"Jobs",value:String(i.jobs)},{label:"Missions",value:String(i.missions)},{label:"Waiting for an answer",value:String(i.approvals)},{label:"Phones",value:String(i.telegramChats)}]}),n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:N=>c(N.target.checked)}),n.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),n.jsx(oe,{title:"Standing permissions",children:a.length===0?n.jsx(xe,{children:"No agent had a standing permission."}):n.jsxs(re,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),n.jsx("ul",{className:"recovery-list",children:a.map(N=>n.jsx("li",{children:n.jsxs("label",{className:"recovery-check",children:[n.jsx("input",{type:"checkbox",checked:u.includes(N.id),onChange:()=>w(N.id),"aria-label":`Keep ${N.tool} for ${N.agent}`}),n.jsxs("span",{children:[n.jsx("span",{className:"mono",children:N.tool})," for ",N.agent," ",n.jsx("span",{className:"ui-card-meta",children:N.scope}),N.description?n.jsxs("span",{className:"ui-card-meta",children:[" — ",N.description]}):null]})]})},N.id))})]})}),n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:p}),x?n.jsx(V,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):n.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",disabled:f||x,onClick:y,children:"Leave recovery mode"})})]})})]})})}const MV=2e3,DV={queued:"Getting started.",stopping:"Stopping the gateway. The database stays up.",snapshot:"Taking a copy of what is here now, first.",database:"Putting the database back.",recovery:"Marking this installation as restored.",files:"Putting the files back.",starting:"Starting back up.",encrypt:"Locking it with your passphrase.",done:"Done.",failed:"That did not work.","rolled-back":"That did not work, so everything was put back as it was."};function Zg(e){return DV[e.phase]??e.detail??e.phase}const OV=new Set(["done","failed","rolled-back"]);function BT(e){return e!==void 0&&(OV.has(e.phase)||!!e.finishedAt)}function LV(e,t=!1){const[s,r]=d.useState(void 0),[i,a]=d.useState(!1),[l,o]=d.useState(null),c=d.useRef(!1);return d.useEffect(()=>{if(!e){r(void 0),a(!1),c.current=!1;return}let u=!1;const h=()=>{t&&c.current||E.backupJob(e).then(m=>{if(!u){if(t&&(lE({step:Zg(m)}),(m.phase==="failed"||m.phase==="rolled-back")&&al()),c.current){window.location.reload();return}r(m),o(null),BT(m)&&(u=!0)}}).catch(m=>{if(!u){if(m instanceof me&&m.status!==0&&m.status<500){t&&al(),o(m.message);return}c.current=!0,t||a(!0)}})};h();const f=window.setInterval(h,MV);return()=>{u=!0,window.clearInterval(f)}},[e,t]),{job:s,away:i,error:l}}function _V({job:e,away:t,error:s}){return s?n.jsx(ae,{message:s}):t?n.jsx(V,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="rolled-back"||e.phase==="failed"?n.jsxs(V,{tone:"critical",role:"alert",children:[Zg(e)," ",e.error??""]}):n.jsxs(V,{tone:e.phase==="done"?"good":void 0,role:"status",children:[Zg(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function FV(){var v,w,y,N,k,S,C;const e=ce(()=>E.backups(),[],3e4),t=UT(),s=ce(()=>E.service(),[]),[r,i]=d.useState(null),[a,l]=d.useState(!1),o=LV(r,a),[c,u]=d.useState(null),[h,f]=d.useState(!1),[m,p]=d.useState(null),g=((v=e.data)==null?void 0:v.supervised)??((w=s.data)==null?void 0:w.supervised),x=m!==null||g===!1,b=((y=e.data)==null?void 0:y.archives)??[],j=($,R=!1)=>{f(!0),u(null),l(R),$().then(I=>{var z;R&&I.job&&Fh({kind:"restore",patienceMs:aE}),i(((z=I.job)==null?void 0:z.id)??null)}).catch(I=>{I instanceof me&&I.status===409?p(I.message):u(I instanceof me?I.message:String(I))}).finally(()=>{f(!1),e.reload()})};return d.useEffect(()=>{BT(o.job)&&e.reload()},[(N=o.job)==null?void 0:N.phase]),n.jsxs(re,{gap:"lg",children:[(k=t.data)!=null&&k.active?n.jsx(PV,{view:t.data,onLeft:t.reload}):null,n.jsx(ae,{message:e.error??c}),n.jsx(_V,{...o}),n.jsx(UV,{onSaved:()=>e.reload()}),n.jsx(oe,{title:"Backups",panel:!0,actions:n.jsx(T,{variant:"accent",size:"sm",disabled:h,onClick:()=>j(()=>E.startBackup(!0)),children:"Back up now"}),children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsxs("p",{className:"ui-card-meta",children:["Kept in ",n.jsx("span",{className:"mono",children:((S=e.data)==null?void 0:S.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),n.jsx(oe,{children:e.data&&b.length===0?n.jsx(jn,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?n.jsxs(vs,{children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Name"}),n.jsx("th",{children:"Taken"}),n.jsx("th",{children:"Size"}),n.jsx("th",{children:"State"}),n.jsx("th",{})]})}),n.jsx("tbody",{children:b.map($=>{var R;return n.jsx(BV,{archive:$,busy:h,database:(R=e.data)==null?void 0:R.database,checkout:x,onVerify:()=>j(()=>E.verifyArchive($.name)),onRestore:(I,z)=>j(()=>E.restoreArchive({name:$.name,...I?{passphrase:I}:{},...z?{confirm:z}:{}}),!0)},$.name)})})]}):n.jsx(xe,{children:"Loading…"})})]})}),n.jsx(WV,{}),n.jsx(HV,{busy:h,checkout:x,checkoutSaid:m,database:(C=e.data)==null?void 0:C.database,onRestore:($,R,I)=>j(()=>E.restoreUpload($,{passphrase:R,confirm:I}),!0)})]})}const zV={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function UV({onSaved:e}){var p;const t=ce(()=>E.backupSchedule(),[]),[s,r]=d.useState(null),[i,a]=d.useState(!1),[l,o]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const h={...zV,...s??t.data??{}};if(((p=t.data)==null?void 0:p.supervised)===!1)return n.jsx(oe,{title:"Every night",panel:!0,children:n.jsx(oe,{children:n.jsx(V,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=g=>{u(!1),r({...h,...g})},m=()=>{a(!0),o(null),E.setBackupSchedule(h).then(g=>{r(g),u(!0),e()}).catch(g=>o(g instanceof me?g.message:String(g))).finally(()=>a(!1))};return n.jsx(oe,{title:"Every night",panel:!0,foot:n.jsx(T,{variant:"accent",disabled:i,onClick:m,children:"Save"}),children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:l}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:h.enabled,onChange:g=>f({enabled:g.target.checked})}),n.jsx("span",{children:"Back this buddi up on its own"})]}),n.jsxs(Os,{children:[n.jsx(ie,{label:"At",children:n.jsx("input",{type:"time",value:h.time,onChange:g=>f({time:g.target.value})})}),n.jsx(ie,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:n.jsx("input",{type:"number",min:1,max:365,value:h.keep,onChange:g=>f({keep:Number(g.target.value)||1})})})]}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:h.encryptLocal,onChange:g=>f({encryptLocal:g.target.checked})}),n.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ie,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:n.jsx("input",{type:"text",value:h.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:g=>f({copyTo:g.target.value===""?null:g.target.value})})}),c?n.jsxs(V,{tone:"good",role:"status",children:["Saved.",h.lastRunAt?` Last run ${Oe(h.lastRunAt)}.`:""]}):null]})})]})})}function BV({archive:e,busy:t,database:s,checkout:r,onVerify:i,onRestore:a}){const[l,o]=d.useState(!1),[c,u]=d.useState(""),[h,f]=d.useState("");return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{children:[n.jsx("td",{className:"mono",children:e.name}),n.jsx("td",{children:Oe(e.createdAt)}),n.jsx("td",{children:Fn(e.bytes)}),n.jsxs("td",{children:[e.encrypted?n.jsx(ve,{tone:"good",children:"locked"}):n.jsx(ve,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?n.jsx(ve,{tone:"critical",children:"damaged"}):null]}),n.jsx("td",{children:n.jsxs(le,{align:"end",children:[n.jsx(T,{size:"sm",disabled:t,onClick:i,children:"Verify"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>o(!l),children:"Restore…"})]})})]}),l?n.jsx("tr",{children:n.jsx("td",{colSpan:5,children:r?n.jsx(V,{tone:"warning",children:WT}):n.jsx(HT,{what:`${e.name}, taken ${Oe(e.createdAt)}, ${Fn(e.bytes)}`,database:s,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:h,onConfirm:f,busy:t,onCancel:()=>o(!1),onGo:()=>a(c,h)})})}):null]})}const WT="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function HT({what:e,database:t,needsPassphrase:s,passphrase:r,onPassphrase:i,confirm:a,onConfirm:l,busy:o,onCancel:c,onGo:u}){const h=t??"",f=h===""?a.trim()!=="":a.trim()===h;return n.jsxs(re,{gap:"sm",children:[n.jsxs(V,{tone:"warning",children:["This replaces everything in this buddi with ",e,". What is here now is copied first, so a restore that fails puts it back."]}),s?n.jsx(ie,{label:"The passphrase this one was locked with",children:n.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:m=>i(m.target.value)})}):null,n.jsx(ie,{label:h?`Type ${h} to confirm`:"Type the name of this database to confirm",hint:h?void 0:"The same name buddi shows on the System tab.",children:n.jsx("input",{value:a,onChange:m=>l(m.target.value)})}),n.jsxs(le,{align:"end",children:[n.jsx(T,{variant:"ghost",onClick:c,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:o||!f||s&&r==="",onClick:u,children:"Restore"})]})]})}function WV(){const[e,t]=d.useState(null),[s,r]=d.useState(""),[i,a]=d.useState(!1),[l,o]=d.useState(null),[c,u]=d.useState(!1),h=()=>{a(!0),o(null),E.backupPassphrase().then(m=>t(m.passphrase)).catch(m=>o(m instanceof me?m.message:String(m))).finally(()=>a(!1))},f=()=>{a(!0),o(null),E.setBackupPassphrase(s.trim()).then(m=>{t(m.passphrase),r(""),u(!0)}).catch(m=>o(m instanceof me?m.message:String(m))).finally(()=>a(!1))};return n.jsx(oe,{title:"The passphrase",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:l}),n.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?n.jsx("p",{className:"backup-phrase mono",children:e}):n.jsx(le,{align:"end",children:n.jsx(T,{disabled:i,onClick:h,children:"Show it"})}),c?n.jsx(V,{tone:"good",role:"status",children:"Saved. Backups made from now on use it; older ones keep the one they were made with."}):null]})}),n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ie,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:n.jsx("input",{type:"text",autoComplete:"off",value:s,onChange:m=>{u(!1),r(m.target.value)}})}),n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",disabled:i||s.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function HV({busy:e,checkout:t,checkoutSaid:s,database:r,onRestore:i}){const[a,l]=d.useState(null),[o,c]=d.useState(""),[u,h]=d.useState(""),[f,m]=d.useState(!1);return t?n.jsx(oe,{title:"Restore from a file",panel:!0,children:n.jsx(oe,{children:n.jsx(V,{tone:"warning",children:s??WT})})}):n.jsx(oe,{title:"Restore from a file",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),n.jsxs(Os,{children:[n.jsx(ie,{label:"The backup file",children:n.jsx("input",{type:"file",onChange:p=>{var g;m(!1),l(((g=p.target.files)==null?void 0:g[0])??null)}})}),n.jsx(ie,{label:"Its passphrase",hint:"Only if it was locked with one.",children:n.jsx("input",{type:"password",autoComplete:"off",value:o,onChange:p=>c(p.target.value)})})]}),f?null:n.jsx(le,{align:"end",children:n.jsx(T,{variant:"accent",disabled:e||!a,onClick:()=>m(!0),children:"Restore"})})]})}),f&&a?n.jsx(oe,{children:n.jsx(HT,{what:`${a.name}, ${Fn(a.size)}`,database:r,needsPassphrase:!1,passphrase:o,onPassphrase:c,confirm:u,onConfirm:h,busy:e,onCancel:()=>m(!1),onGo:()=>i(a,o,u)})}):null]})})}const KT="gemini-2.5-pro";function ef(e){return e.replace(/^models\//,"")}const Uj=/(image|tts|audio|live|embedding|vision|robotics|transcribe)/;function VT(e){const t=e.map(ef);let s;for(const r of t){const i=/^gemini-(\d+(?:\.\d+)*)-pro(?:-(.+))?$/.exec(r);if(!i||Uj.test(i[2]??""))continue;const a=i[1].split(".").map(Number),l=(i[2]??"")!=="";(!s||Kd(a,s.version)>0||Kd(a,s.version)===0&&s.preview&&!l)&&(s={id:r,version:a,preview:l})}return(s==null?void 0:s.id)??t.find(r=>r.startsWith("gemini-"))}function GT(e){let t;for(const s of e.map(ef)){const r=/^gemini-(\d+(?:\.\d+)*)-flash(?:-(.+))?$/.exec(s);if(!r||/lite/.test(r[2]??"")||Uj.test(r[2]??""))continue;const i=r[1].split(".").map(Number),a=(r[2]??"")!=="";(!t||Kd(i,t.version)>0||Kd(i,t.version)===0&&t.preview&&!a)&&(t={id:s,version:i,preview:a})}return t==null?void 0:t.id}function YT(e){return/^gemini-[\d.]+-pro(?:-|$)/.test(ef(e))}function KV(e){return[...new Set(e.map(ef).filter(t=>t.startsWith("gemini-")&&!Uj.test(t)))]}function qT(e){return e.httpStatus===429||e.state==="rate-limited"||e.state==="quota-exhausted"}function Kd(e,t){for(let s=0;s<Math.max(e.length,t.length);s+=1){const r=(e[s]??0)-(t[s]??0);if(r!==0)return r}return 0}function QT(e,t){if(!t||e.kind!=="openai-compatible")return!1;const s=r=>r.replace(/\/+$/,"");return s(e.baseUrl)===s(t)}function VV({embedded:e,account:t}={}){const{data:s,error:r,reload:i,loading:a}=ce(()=>E.providerAccounts(),[]),[l,o]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(""),[m,p]=d.useState(!1),[g,x]=d.useState(!1),[b,j]=d.useState(t??null);d.useEffect(()=>{t&&j(t)},[t]);const v=s==null?void 0:s.accounts.some(S=>{var C;return((C=S.login)==null?void 0:C.state)==="pending"&&S.login.expiresAt&&Date.parse(S.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!v)return;const S=setInterval(i,2e3);return()=>clearInterval(S)},[v,i]);const w=async(S,C)=>{o(!0),u(null),f(""),x(!1);try{const $=await S();return f(($==null?void 0:$.warning)??C),i(),!0}catch($){return u($ instanceof Error?$.message:"Could not apply change."),i(),!1}finally{o(!1)}},y=(s==null?void 0:s.accounts)??[],N=y.find(S=>S.id===b)??y[0],k=S=>{var C;return QT(S,(C=s==null?void 0:s.gemini)==null?void 0:C.baseUrl)?"Gemini":XT(S)};return n.jsxs(An,{embedded:e,title:"Model accounts",lede:"Give each API key or subscription a name, then pick one per agent. An account never falls back to another credential on its own.",children:[n.jsx(ae,{message:r??c}),h&&n.jsx(V,{tone:"good",role:"status",children:h}),g&&n.jsx(V,{role:"status",children:a?"Refreshing account status…":r?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!s&&!r&&n.jsx(xe,{children:"Loading accounts…"}),r&&n.jsx(le,{children:n.jsx(T,{onClick:i,children:"Retry"})}),s&&n.jsxs(n.Fragment,{children:[(s.vault.locked||s.vault.kind==="none")&&n.jsx(V,{tone:"warning",children:s.vault.advice||"Run buddi init on the host to configure secure credential storage."}),m&&n.jsx(ht,{title:"Add an account",onClose:()=>p(!1),children:n.jsx("div",{id:"new-provider-account",children:n.jsx(n9,{accounts:y,codexEnabled:s.codexEnabled,anthropicOAuthEnabled:s.anthropicOAuthEnabled,gemini:s.gemini,busy:l,run:w,onDone:S=>{p(!1),S&&j(S)}})})}),n.jsx(oe,{title:"Accounts",aside:`Secrets live in the ${GV(s.vault.kind)}; Postgres holds names and assignments only.`,actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",size:"sm",disabled:l||a,onClick:()=>{u(null),f(""),x(!0),i()},children:a?"Refreshing…":"Refresh status"}),n.jsx(T,{variant:"accent",size:"sm",disabled:l,"aria-expanded":m,"aria-controls":"new-provider-account",onClick:()=>p(!m),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?n.jsx(jn,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):n.jsxs("div",{className:"accounts",children:[n.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(S=>n.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(N==null?void 0:N.id)===S.id,onClick:()=>j(S.id),children:[n.jsx(YV,{kind:S.kind,auth:S.auth}),n.jsxs("span",{className:"accounts-row-text",children:[n.jsx("span",{className:"accounts-row-name",children:S.label}),Vd(S)?n.jsxs("span",{className:"accounts-row-sub","data-tone":"warning",children:[k(S)," · back at ",Bj(Vd(S).until)]}):n.jsxs("span",{className:"accounts-row-sub",children:[k(S)," · ",S.assignedAgents.length===0?"no agents":`${S.assignedAgents.length} agent${S.assignedAgents.length===1?"":"s"}`]})]}),n.jsx(ZT,{account:S})]},S.id))}),N?n.jsx(ZV,{account:N,provider:k(N),anthropicOAuthEnabled:s.anthropicOAuthEnabled,busy:l,run:w},`${N.id}:${N.revision}`):null]})})]})]})}function GV(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function XT(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":"Anthropic API":e.kind==="openai"?"OpenAI API":e.auth==="device-key"?"Ollama Cloud":Dj(e)?"mlxh":"OpenAI-compatible"}function JT(e){return e.detectedContextWindowSource==="mlxh"?HH(e.detectedContextWindowTokens):e.detectedContextWindowSource!=="provider"?"assumed":e.kind==="codex"?"from ChatGPT":"from the provider"}function YV({kind:e,auth:t}){const s=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return n.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:s})}function qV(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function Vd(e,t=Date.now()){const s=e.rateLimit;return e.enabled&&e.configured&&s&&Date.parse(s.until)>t?s:null}const QV=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;function Bj(e,t=new Date,s=QV()){const r=new Date(e),i=a=>a.toLocaleDateString("en-CA",{timeZone:s});return i(r)===i(t)?Ht(r,s):i(r)===i(new Date(t.getTime()+864e5))?`tomorrow at ${Ht(r,s)}`:Cv(r,s)}function ZT({account:e,long:t}){const s=Vd(e);if(s){const a=`Rate-limited until ${Bj(s.until)}`;return n.jsx("span",{title:a,children:n.jsx(ve,{tone:"warning",children:t?a:"Rate-limited"})})}const r=e.enabled?e.configured?"good":"warning":void 0,i=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return n.jsx(ve,{tone:r,children:i})}function XV({id:e}){const[t,s]=d.useState(!1),r=()=>{var i;(i=navigator.clipboard)==null||i.writeText(e).then(()=>{s(!0),window.setTimeout(()=>s(!1),1600)}).catch(()=>{})};return n.jsxs("span",{className:"accounts-id",children:[n.jsx("code",{className:"accounts-id-text",children:e}),n.jsx(T,{variant:"ghost",size:"sm",onClick:r,"aria-label":"Copy the id of this account",children:t?"Copied":"Copy"})]})}function JV({account:e,provider:t}){const s=Vd(e);if(!s)return null;const r=s.provider??t,i=Bj(s.until);if(s.scope==="day"){const a=e.assignedAgents,l=a.length===1?a[0]:"its agents",o=s.provider==="ChatGPT",c=o?"This ChatGPT plan has reached its usage limit":s.limit!==null?`${s.freeTier?`${r}'s free tier allows`:`${r} allows this account`} ${s.limit.toLocaleString()} ${s.unit??"requests"} a day`:`${r} says this account has used today's allowance`,u=s.freeTier&&s.provider==="Gemini"?", or turn on billing for the key at aistudio.google.com":"";return n.jsx(V,{tone:"warning",title:c,action:a.length>0?n.jsx(Tt,{size:"sm",href:a.length===1?At(a[0],"setup","brain"):Et,children:a.length===1?`Change ${a[0]}'s account`:"Change their accounts"}):void 0,children:n.jsxs("p",{children:["It resets ",/^tomorrow/.test(i)?i:`at ${i}`,". Until then buddi doesn't send this account's requests to ",r,", so ",a.length?`${l}'s runs stop with this note`:"a run on it stops with this note"," instead of failing again and again. To keep going ",o?"before then":"today",", ",a.length?`give ${l} another account`:"use another account",u,"."]})})}return n.jsx(V,{tone:"warning",title:`${r} asked buddi to slow down`,children:n.jsxs("p",{children:["It said to wait until ",i,". A run that meets this waits and tries again — up to a minute during a conversation, longer for work in the background."]})})}function Wj(e){return{id:e.id,revision:e.revision,label:e.label,kind:e.kind,auth:e.auth,baseUrl:e.baseUrl,defaultModel:e.defaultModel,enabled:e.enabled,contextWindowTokens:e.contextWindowTokens??null}}function ZV({account:e,provider:t,busy:s,run:r,anthropicOAuthEnabled:i}){const[a,l]=d.useState(!1),[o,c]=d.useState(!1);return n.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[n.jsxs("div",{className:"ui-card-head",children:[n.jsx("h3",{className:"ui-card-title",children:e.label}),n.jsx(ZT,{account:e,long:!0})]}),n.jsx(Wt,{items:[{label:"Provider",value:t},{label:"Default model",value:n.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:n.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":` (${JT(e)})`}`})},...e.baseUrl?[{label:"Endpoint",value:n.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?n.jsx("span",{className:"ui-row",children:e.assignedAgents.map(u=>n.jsx("a",{href:At(u,"setup","brain"),children:u},u))}):n.jsxs("span",{className:"ui-row",children:[n.jsx("span",{className:"muted",children:"No agents"}),n.jsx("a",{href:Et,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${et(e.tokenExpiresAt,Intl.DateTimeFormat().resolvedOptions().timeZone)} (not your subscription renewal date)`}]:[],{label:"ID",value:n.jsx(XV,{id:e.id})}]}),n.jsx(JV,{account:e,provider:t}),e.removalPending&&n.jsx(V,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&n.jsxs(V,{tone:"warning",children:["Token refresh did not finish. Reconnect this ",e.kind==="codex"?"ChatGPT":"Claude"," account."]}),e.auth==="anthropic-oauth"&&n.jsx(nR,{account:e,enabled:!!i,busy:s,run:r}),e.kind==="codex"&&n.jsx(eR,{account:e,busy:s,run:r}),e.auth==="device-key"&&n.jsx(tR,{account:e,busy:s,run:r}),n.jsxs(le,{children:[n.jsx(T,{disabled:s||e.removalPending,onClick:()=>l(!0),children:"Edit account"}),n.jsx(T,{disabled:s||e.removalPending,onClick:()=>void r(()=>E.saveProviderAccount({...Wj(e),enabled:!e.enabled}),e.enabled?"Account disabled. Subsequent model calls will stop; already-sent requests cannot be recalled.":"Account enabled."),children:e.enabled?"Disable":"Enable"}),e.kind!=="codex"&&n.jsx(T,{disabled:s||!e.enabled||!e.configured,onClick:()=>void r(()=>E.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),n.jsx(T,{variant:"danger",disabled:s||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>c(!0),children:"Remove account"})]}),e.test&&n.jsxs(n.Fragment,{children:[n.jsxs(V,{role:"status",tone:qV(e.test.state),children:[n.jsx("p",{children:e.test.message}),e.test.retryAt?n.jsxs("p",{children:["Provider suggested retry time: ",new Date(e.test.retryAt).toLocaleString(),". This is retry advice, not a guaranteed quota reset."]}):["rate-limited","quota-exhausted"].includes(e.test.state)&&n.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),n.jsxs("p",{className:"muted",children:["Tested at ",new Date(e.test.checkedAt).toLocaleString(),e.test.httpStatus?` · HTTP ${e.test.httpStatus}`:"",". This is not a quota reset or subscription renewal date."]})]}),a&&n.jsx(ht,{title:`Edit ${e.label}`,onClose:()=>l(!1),children:n.jsx(e9,{account:e,busy:s,run:r,onDone:()=>l(!1)})}),o&&n.jsxs(V,{tone:"critical",children:[n.jsxs("p",{children:["Remove “",e.label,"” and its stored credential from Buddi? This does not revoke it at the provider or remove it from backups."]}),n.jsxs(le,{children:[n.jsx(T,{variant:"danger",disabled:s,onClick:()=>void r(()=>E.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),n.jsx(T,{disabled:s,onClick:()=>c(!1),children:"Cancel"})]})]}),n.jsx(St,{summary:"Details",children:n.jsxs("div",{className:"ui-prose muted",children:[e.kind==="codex"?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"Talks to OpenAI’s Codex backend directly with your ChatGPT sign-in. The credential stays in buddi’s vault; buddi refreshes it and never reads your own Codex login."}),n.jsx("p",{children:"Native tool-step usage reporting is incomplete. Do not use Buddi’s token or API-cost estimates as subscription billing or remaining quota."}),n.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):n.jsx("p",{children:"Testing sends a small fixed prompt and may incur a charge. No conversation or files are sent. Configured does not mean verified."}),e.auth==="device-key"&&n.jsx("p",{children:"Ollama Cloud with a device key: buddi made a key pair and keeps it in the vault; ollama.com only ever saw the public half and this computer’s name. Each request to ollama.com is signed with the key, and nothing else is sent with it. Disconnect asks ollama.com to forget the device and removes the key from buddi either way."}),e.auth==="anthropic-oauth"&&n.jsx("p",{children:"Claude subscription sign-in. Tokens remain in Buddi’s vault and refresh before use. Uses your plan’s monthly Agent SDK credits; after them, an API key. Remaining credits are unknown here."}),n.jsx("p",{children:"Subscription login is separate from API-key access."})]})})]})}function eR({account:e,busy:t,run:s}){var r,i,a;return n.jsxs(n.Fragment,{children:[n.jsxs(le,{children:[n.jsx(T,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void s(()=>E.codexAccountAction(e.id,"login",e.revision),"Complete device sign-in below."),children:e.configured?"Reconnect ChatGPT":"Connect ChatGPT"}),((i=e.login)==null?void 0:i.state)==="pending"&&n.jsx(T,{disabled:t,onClick:()=>void s(()=>E.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),n.jsx(T,{disabled:t||!e.configured,onClick:()=>void s(()=>E.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((a=e.login)==null?void 0:a.state)==="pending"&&n.jsxs(V,{tone:"accent",role:"status",children:[n.jsxs("p",{children:["Here is your code: ",n.jsx("strong",{children:e.login.userCode}),". Open the link, enter it, and approve buddi on openai.com."]}),e.login.userCode&&n.jsx(Lj,{code:e.login.userCode}),e.login.verificationUrl&&n.jsx(le,{children:n.jsx(Tt,{variant:"accent",href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open openai.com"})}),e.login.expiresAt&&n.jsxs("p",{className:"muted",children:["The code works until ",Ht(new Date(e.login.expiresAt),Intl.DateTimeFormat().resolvedOptions().timeZone),". Start again after that; this is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&n.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function e9({account:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a}){const[l,o]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[h,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[m,p]=d.useState((e==null?void 0:e.baseUrl)??""),[g,x]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,j]=d.useState(""),[v,w]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),y=k=>{u(k),f(k==="codex"?"chatgpt":"api-key"),j(""),p(k==="openai-compatible"?"http://localhost:11434/v1":""),x(k==="anthropic"?"claude-sonnet-5":k==="openai"?"gpt-5":"")},N=!l.trim()||!g.trim();return n.jsxs("form",{className:"ui-stack",onSubmit:k=>{k.preventDefault();const S=b;j(""),s(()=>E.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:l,kind:c,auth:h,baseUrl:m,defaultModel:g,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:v.trim()?Number(v):null,...S.trim()?{secret:S}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(ie,{label:"Account name",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:l,onChange:k=>o(k.target.value),placeholder:"Anthropic — Personal"})}),n.jsx(ie,{label:"Provider",children:n.jsxs("select",{disabled:!!e,value:h==="anthropic-oauth"?"anthropic-oauth":h==="device-key"?"ollama-cloud":c,onChange:k=>{k.target.value==="anthropic-oauth"?(y("anthropic"),f("anthropic-oauth")):y(k.target.value)},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(e==null?void 0:e.auth)==="device-key"&&n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),(a||(e==null?void 0:e.auth)==="anthropic-oauth")&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),c==="openai-compatible"&&h!=="device-key"&&n.jsxs(n.Fragment,{children:[n.jsx(ie,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:n.jsx("input",{required:!0,type:"url",value:m,onChange:k=>p(k.target.value)})}),n.jsx(ie,{label:"Authentication",children:n.jsxs("select",{disabled:!!e,value:h,onChange:k=>{f(k.target.value),j("")},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),n.jsx(le,{valign:"end",children:n.jsx(Oj,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:g,onChange:x,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),n.jsx(ie,{label:"Context window",hint:Dj(e)?"mlxh refuses a prompt over its max_prompt_tokens, and its model manager does not report the number, so buddi assumes 8,192. After `mlxh config max_prompt_tokens 40960`, enter the same number here.":"Tokens this endpoint actually serves. Leave blank unless you run the model yourself and set a window of your own — a conversation is ended once its history would fill half of this.",children:n.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:v,placeholder:e!=null&&e.detectedContextWindowTokens?`${e.detectedContextWindowTokens} (${JT(e)})`:"assumed from the model",onChange:k=>w(k.target.value)})}),c==="codex"&&n.jsx("p",{className:"muted",children:"Pick a model from the list once the account is connected."}),h==="anthropic-oauth"&&n.jsx("p",{className:"muted",children:"Save this account, then choose Connect Claude. You will approve in your browser and paste the authorization code here, not in chat. No existing agent assignment changes."}),h==="api-key"&&n.jsx(ie,{label:e?"Replacement API key (leave blank to keep)":"API key",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:k=>j(k.target.value)})}),e&&n.jsx("p",{className:"muted",children:"Saving changes stops an active run at its next model call. Start a new turn afterward. Changing the default model does not change existing agent assignments."}),n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:r,children:"Cancel"}),n.jsx(T,{type:"submit",variant:"accent",disabled:N,children:"Save account"})]})]}),N&&n.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function tR({account:e,busy:t,run:s}){var o;const r=((o=e.login)==null?void 0:o.state)==="pending"&&e.login.attemptId?e.login:null,i=d.useRef(s);i.current=s,d.useEffect(()=>{if(!(r!=null&&r.attemptId))return;let c=!1,u=!1;const h=setInterval(()=>{c||u||(u=!0,E.ollamaPoll(e.id,r.attemptId).then(f=>{c||f.state==="waiting"||(c=!0,f.state==="connected"?i.current(async()=>{},`Connected as ${f.username}, device ${f.deviceName}.`):i.current(async()=>{throw new Error(f.message)},""))}).catch(()=>{}).finally(()=>{u=!1}))},2e3);return()=>{c=!0,clearInterval(h)}},[e.id,r==null?void 0:r.attemptId]);const a=()=>{const c=typeof window.open=="function"?window.open("","_blank"):null;s(async()=>{try{const u=await E.ollamaConnect(e.id,e.revision);return c&&(c.location.href=u.verificationUrl),u}catch(u){throw c==null||c.close(),u}},"Press Connect on the ollama.com page. This card notices on its own.")},l=e.device;return n.jsxs(n.Fragment,{children:[l&&n.jsx("p",{className:"muted",role:"status",children:l.connectedAt?`Connected as ${l.username||"an ollama.com account"}, device ${l.deviceName}.`:`Not connected yet. Device ${l.deviceName}.`}),n.jsxs(le,{children:[n.jsx(T,{disabled:t||!e.enabled||e.removalPending||!!r,onClick:a,children:e.configured?"Reconnect Ollama":"Connect Ollama"}),n.jsx(T,{disabled:t||!l||e.removalPending,onClick:()=>void s(async()=>({warning:(await E.ollamaDisconnect(e.id,e.revision)).note}),"Disconnected."),children:"Disconnect"})]}),r&&n.jsxs(V,{tone:"accent",role:"status",children:[n.jsxs("p",{children:[n.jsx("a",{href:r.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open the ollama.com page"})," and press Connect. Sign in there first if it asks."]}),n.jsxs("p",{className:"muted",children:["buddi stops waiting at ",r.expiresAt&&Ht(new Date(r.expiresAt),Intl.DateTimeFormat().resolvedOptions().timeZone),"."]})]})]})}function nR({account:e,enabled:t,busy:s,run:r}){var l,o,c,u,h;const[i,a]=d.useState("");return d.useEffect(()=>{a("")},[(l=e.login)==null?void 0:l.attemptId,(o=e.login)==null?void 0:o.state]),n.jsxs(n.Fragment,{children:[!t&&n.jsx(V,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),n.jsxs(le,{children:[n.jsx(T,{disabled:s||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>E.anthropicAccountAction(e.id,"login",e.revision),"Open the Claude consent link below. Existing credentials remain until sign-in succeeds."),children:e.configured?"Reconnect Claude":"Connect Claude"}),((u=e.login)==null?void 0:u.state)==="pending"&&n.jsx(T,{disabled:s,onClick:()=>{a(""),r(()=>E.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),n.jsx(T,{disabled:s||!e.configured||e.removalPending,onClick:()=>{a(""),r(()=>E.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((h=e.login)==null?void 0:h.state)==="pending"&&n.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const m=i;a(""),r(()=>E.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:m}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[n.jsx("p",{children:n.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),n.jsxs("p",{className:"muted",children:["Use the Claude account you want to connect. Paste the entire code including #state. This attempt expires at ",e.login.expiresAt&&Ht(new Date(e.login.expiresAt),Intl.DateTimeFormat().resolvedOptions().timeZone),"; restarting Buddi also ends it."]}),n.jsx(ie,{label:"Claude authorization code",children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>a(f.target.value),disabled:s})}),n.jsx(le,{align:"end",children:n.jsx(T,{type:"submit",variant:"accent",disabled:s||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Rm={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5.5"};function $m(e,t,s){return ex(e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":t==="device-key"?"Ollama Cloud":"Local endpoint",s)}function ex(e,t){const s=new Set(t.map(r=>r.trim().toLowerCase()));if(!s.has(e.toLowerCase()))return e;for(let r=2;r<100;r+=1)if(!s.has(`${e} ${r}`.toLowerCase()))return`${e} ${r}`;return e}const t9="That key was refused. Check it and paste it again.";function n9({accounts:e,busy:t,run:s,onDone:r,codexEnabled:i,anthropicOAuthEnabled:a,gemini:l}){const o=e.map(se=>se.label),[c,u]=d.useState(null),[h,f]=d.useState("anthropic"),[m,p]=d.useState("api-key"),[g,x]=d.useState(()=>$m("anthropic","api-key",o)),[b,j]=d.useState(!1),[v,w]=d.useState(""),[y,N]=d.useState(""),[k,S]=d.useState(null),[C,$]=d.useState(!1),[R,I]=d.useState(""),[z,U]=d.useState(""),[A,P]=d.useState(!1),[D,O]=d.useState(!1),[M,W]=d.useState(!1),[_,G]=d.useState(void 0),B=(se,Te,pe=!1)=>{f(se),p(Te),N(""),S(null),I(""),U(""),P(!1),O(pe),W(!1),G(void 0),w(pe?"":se==="openai-compatible"?"http://localhost:11434/v1":""),b||x(pe?$m(se,"device-key",o):$m(se,Te,o))},K=se=>{B("openai-compatible",se?"api-key":"device-key",!0),se&&E.ollama().then(Te=>w(Te.cloudBaseUrl)).catch(()=>{})},F=()=>{l&&(B("openai-compatible","api-key"),W(!0),w(l.baseUrl),b||x(ex("Gemini",o)))},Q=()=>{B("openai-compatible","none"),G(null),b||x(ex("mlxh",o)),E.mlxh().then(se=>{G(se),w(se.baseUrl)}).catch(()=>G(void 0))},X=_!==void 0,Z=c?e.find(se=>se.id===c):void 0;if(c)return Z?n.jsx(s9,{account:Z,busy:t,run:s,anthropicOAuthEnabled:a,onDone:()=>r(Z.id)}):n.jsx(xe,{children:"Saving…"});const de=h==="openai-compatible"&&m!=="device-key",_e=h==="codex"||m==="anthropic-oauth"||m==="device-key",Ie=!_e&&(m==="none"||y.trim()!=="")&&(!de||v.trim()!==""),Ue=async()=>{var se,Te;$(!0),I("");try{const pe=await E.probeModels({kind:h,auth:m,...de?{baseUrl:v}:{},...y.trim()?{secret:y}:{}});S(pe),z||U(((se=pe.models.find(Re=>Re.isDefault))==null?void 0:se.id)??((Te=pe.models[0])==null?void 0:Te.id)??"")}catch(pe){I(pe instanceof Error?pe.message:"Could not load models. You can still enter a custom model.")}finally{$(!1)}},ee=z.trim(),be=!g.trim()||de&&!v.trim()||de&&!M&&!X&&!ee||M&&!y.trim()||X&&!(_!=null&&_.running);return n.jsxs("form",{className:"ui-stack",onSubmit:se=>{var Se;se.preventDefault();const Te=y;N("");let pe=ee||(X?qg(_)??((Se=_==null?void 0:_.models[0])==null?void 0:Se.id):void 0)||(m==="device-key"?Hu:Rm[h])||"claude-sonnet-5",Re;(async()=>{if(M){pe=KT;try{const nt=(await E.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:v,secret:Te})).models.map(Ye=>Ye.id);pe=VT(nt)??pe,Re=YT(pe)?GT(nt):void 0}catch{}}let Fe,Ze=!1;!await s(async()=>{if(Fe=await E.saveProviderAccount({label:g,kind:h,auth:m,baseUrl:v,defaultModel:pe,enabled:!0,...Te.trim()?{secret:Te}:{}}),m!=="api-key")return Fe;const ze=await E.testProviderAccount(Fe.id);if(ze.state==="connected")return Fe;if(Tv(ze)){const nt=Fe.id;Fe=void 0;try{const Ye=(await E.providerAccounts()).accounts.find(J=>J.id===nt);Ye&&await E.removeProviderAccount(nt,Ye.revision)}catch{}throw new Error(t9)}if(M&&Re&&qT(ze)){const nt=(await E.providerAccounts()).accounts.find(Ye=>Ye.id===Fe.id);if(nt&&(await E.saveProviderAccount({...Wj(nt),defaultModel:Re}),(await E.testProviderAccount(Fe.id)).state==="connected"))return{...Fe,warning:`Account saved. Google's free tier has no Pro allowance, so it starts on ${Re}; turn on billing at Google to use Pro.`}}return Ze=!0,{...Fe,warning:`Account saved. ${ze.message}`}},"Account saved.")||!Fe||(M||X||Ze?u(Fe.id):ee||!_e?r(Fe.id):u(Fe.id))})()},children:[n.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[n.jsx(ie,{label:"Provider",children:n.jsxs("select",{value:m==="anthropic-oauth"?"anthropic-oauth":D?"ollama-cloud":M?"gemini":X?"mlxh":h,onChange:se=>{if(se.target.value==="anthropic-oauth")B("anthropic","anthropic-oauth");else if(se.target.value==="gemini")F();else if(se.target.value==="mlxh")Q();else if(se.target.value==="ollama-cloud")B("openai-compatible","device-key",!0);else{const Te=se.target.value;B(Te,Te==="codex"?"chatgpt":"api-key")}},children:[n.jsx("option",{value:"anthropic",children:"Anthropic API"}),n.jsx("option",{value:"openai",children:"OpenAI API"}),l&&n.jsx("option",{value:"gemini",children:"Gemini (Google AI key)"}),n.jsx("option",{value:"ollama-cloud",children:"Ollama Cloud"}),n.jsx("option",{value:"mlxh",children:"mlxh, local MLX models on this Mac"}),n.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),a&&n.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&n.jsx("option",{value:"codex",children:"ChatGPT subscription"})]})}),n.jsx(ie,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:n.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:g,onChange:se=>{x(se.target.value),j(!0)},placeholder:"Anthropic — Personal"})}),D&&n.jsxs("label",{className:"ui-row",children:[n.jsx("input",{type:"checkbox",checked:m==="api-key",onChange:se=>K(se.target.checked)}),n.jsx("span",{children:"Use a key instead"})]}),de&&n.jsxs(n.Fragment,{children:[n.jsx(ie,{label:"API base URL",hint:"Include the API path, such as /v1 or /api/v1. Conversation data will be sent to this endpoint. The model must support tool calling to use agent tools.",children:n.jsx("input",{required:!0,type:"url",value:v,onChange:se=>{w(se.target.value),S(null)}})}),!M&&!X&&n.jsx(ie,{label:"Authentication",children:n.jsxs("select",{value:m,onChange:se=>{p(se.target.value),N(""),S(null)},children:[n.jsx("option",{value:"api-key",children:"API key"}),n.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),m==="api-key"&&n.jsx(ie,{label:"API key",hint:"Stored in the vault, never shown again.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:y,onChange:se=>{N(se.target.value),S(null)}})}),X?_===null?n.jsx("p",{className:"muted",children:"Looking for mlxh on this computer…"}):_!=null&&_.running?n.jsxs(re,{gap:"sm",children:[n.jsxs("p",{className:"muted",children:["mlxh answers with ",_.models.length===1?"one model":`${_.models.length} models`,". No key: mlxh takes any. buddi starts on ",qg(_)??"the first","; the next step lists the rest. A model that is not loaded takes up to a minute on its first answer."]}),_.models.some(se=>se.kind==="image")?n.jsxs("p",{className:"muted",children:[_.models.filter(se=>se.kind==="image").map(se=>se.id).join(", "),": ",ST,"."]}):null]}):n.jsx(V,{tone:"warning",children:NT((_==null?void 0:_.baseUrl)??v)}):M&&l?n.jsxs("p",{className:"muted",children:[n.jsx("a",{href:l.keyUrl,target:"_blank",rel:"noreferrer",children:"Get a key at aistudio.google.com"}),". buddi picks the newest Gemini Pro your key can reach; the next step lists the rest."]}):_e?n.jsx("p",{className:"muted",children:h==="codex"?"You will connect your ChatGPT subscription on the next step, with a code you enter on openai.com, and pick a model then.":m==="device-key"?"You will connect on the next step: ollama.com opens, you press Connect, and no key is typed. Free to start.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):n.jsxs("div",{className:"ui-field",children:[n.jsx("span",{className:"ui-field-label",children:"Model"}),k?n.jsxs("div",{className:"ui-row",children:[n.jsxs("select",{"aria-label":"Model",value:A?"__custom__":z,onChange:se=>{se.target.value==="__custom__"?(P(!0),U("")):(P(!1),U(se.target.value))},children:[k.models.map(se=>n.jsxs("option",{value:se.id,children:[se.name===se.id?se.id:`${se.name} — ${se.id}`,se.isDefault?" (provider default)":"",se.thinks?" · thinks":""]},se.id)),n.jsx("option",{value:"__custom__",children:"Custom model…"})]}),n.jsx(T,{size:"sm",disabled:C||!Ie,onClick:()=>void Ue(),children:C?"Loading…":"Reload"})]}):n.jsxs("div",{className:"ui-row",children:[n.jsx(T,{disabled:C||!Ie,onClick:()=>void Ue(),children:C?"Loading models…":"Load models"}),de?n.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):n.jsxs("span",{className:"muted",children:["Optional now: ",Rm[h]," is used until you pick one."]})]}),A||de&&!k?n.jsx("input",{"aria-label":"Custom model",required:de,maxLength:150,value:z,onChange:se=>U(se.target.value),placeholder:de?"qwen3:8b":Rm[h]}):null,R?n.jsx("span",{className:"ui-field-hint critical",role:"alert",children:R}):null,k!=null&&k.truncated?n.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:()=>r(),children:"Cancel"}),n.jsx(T,{type:"submit",variant:"accent",disabled:be,children:"Save account"})]})]}),be&&!X&&n.jsxs("p",{className:"muted",children:["Enter an account name",M?" and a key":de?", an endpoint and a model":""," to enable Save account."]})]})}function s9({account:e,busy:t,run:s,anthropicOAuthEnabled:r,onDone:i}){const[a,l]=d.useState(e.defaultModel),o=e.configured;return n.jsxs(re,{gap:"lg",children:[n.jsxs(V,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!o?n.jsx(nR,{account:e,enabled:!!r,busy:t,run:s}):null,e.kind==="codex"&&!o?n.jsx(eR,{account:e,busy:t,run:s}):null,e.auth==="device-key"&&!o?n.jsx(tR,{account:e,busy:t,run:s}):null,o?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-page-lede",children:"Pick the model this account offers by default. An agent can still choose another when you assign it."}),n.jsx(le,{valign:"end",children:n.jsx(Oj,{accountId:e.enabled?e.id:void 0,label:"Default model",value:a,onChange:l,disabled:t},`${e.id}:${e.revision}`)}),n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:i,children:"Skip for now"}),n.jsx(T,{variant:"accent",disabled:t||!a.trim(),onClick:()=>{if(a===e.defaultModel){i();return}s(()=>E.saveProviderAccount({...Wj(e),defaultModel:a}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):n.jsx(le,{children:n.jsx(T,{onClick:i,children:"Finish later"})})]})}const n0=new Set(["co.uk","org.uk","me.uk","ltd.uk","plc.uk","net.uk","sch.uk","ac.uk","gov.uk","nhs.uk","police.uk","mod.uk","gov.ie","co.at","or.at","ac.at","gv.at","com.pl","net.pl","org.pl","info.pl","biz.pl","edu.pl","gov.pl","waw.pl","com.es","org.es","nom.es","gob.es","edu.es","com.pt","org.pt","gov.pt","edu.pt","com.gr","org.gr","net.gr","edu.gr","gov.gr","com.cy","org.cy","net.cy","gov.cy","ac.cy","com.mt","org.mt","net.mt","edu.mt","gov.mt","co.hu","org.hu","info.hu","com.ro","org.ro","info.ro","nom.ro","co.rs","org.rs","edu.rs","gov.rs","in.rs","com.ua","org.ua","net.ua","gov.ua","edu.ua","in.ua","kiev.ua","com.ru","org.ru","net.ru","msk.ru","spb.ru","co.no","priv.no","com.hr","from.hr","iz.hr","name.hr","co.it","gov.it","edu.it","asso.fr","com.fr","gouv.fr","nom.fr","prd.fr","tm.fr","co.je","net.je","org.je","co.gg","net.gg","org.gg","co.im","net.im","org.im","gc.ca","on.ca","qc.ca","bc.ca","ab.ca","com.mx","org.mx","net.mx","edu.mx","gob.mx","ny.us","ca.us","tx.us","fl.us","wa.us","k12.ca.us","lib.ca.us","com.br","net.br","org.br","gov.br","edu.br","art.br","blog.br","eco.br","emp.br","ind.br","inf.br","tv.br","app.br","dev.br","com.ar","org.ar","net.ar","gob.ar","edu.ar","int.ar","tur.ar","com.co","org.co","net.co","edu.co","gov.co","nom.co","com.pe","org.pe","net.pe","gob.pe","edu.pe","nom.pe","com.ve","org.ve","net.ve","gob.ve","co.ve","com.uy","org.uy","net.uy","gub.uy","edu.uy","com.ec","org.ec","net.ec","gob.ec","edu.ec","fin.ec","com.bo","org.bo","net.bo","gob.bo","edu.bo","com.py","org.py","net.py","gov.py","edu.py","gob.cl","gov.cl","co.cl","com.do","org.do","net.do","gob.do","edu.do","com.gt","org.gt","net.gt","gob.gt","edu.gt","co.cr","or.cr","fi.cr","go.cr","ac.cr","com.pa","org.pa","net.pa","gob.pa","com.sv","org.sv","gob.sv","edu.sv","com.ni","org.ni","gob.ni","com.hn","org.hn","net.hn","gob.hn","com.cu","org.cu","net.cu","gob.cu","com.jm","org.jm","net.jm","gov.jm","com.tt","org.tt","net.tt","gov.tt","co.tt","com.pr","org.pr","net.pr","gov.pr","com.au","net.au","org.au","edu.au","gov.au","asn.au","id.au","co.nz","net.nz","org.nz","ac.nz","govt.nz","school.nz","geek.nz","gen.nz","kiwi.nz","maori.nz","co.jp","ne.jp","or.jp","ac.jp","ad.jp","ed.jp","go.jp","gr.jp","lg.jp","com.cn","net.cn","org.cn","gov.cn","edu.cn","ac.cn","com.hk","net.hk","org.hk","edu.hk","gov.hk","idv.hk","com.tw","net.tw","org.tw","edu.tw","gov.tw","idv.tw","co.kr","or.kr","ne.kr","go.kr","ac.kr","re.kr","pe.kr","co.in","net.in","org.in","firm.in","gen.in","ind.in","ac.in","edu.in","gov.in","res.in","nic.in","com.sg","net.sg","org.sg","edu.sg","gov.sg","per.sg","com.my","net.my","org.my","edu.my","gov.my","name.my","co.id","or.id","ac.id","go.id","web.id","my.id","biz.id","net.id","sch.id","co.th","in.th","ac.th","go.th","or.th","net.th","com.vn","net.vn","org.vn","edu.vn","gov.vn","com.ph","net.ph","org.ph","edu.ph","gov.ph","com.pk","net.pk","org.pk","edu.pk","gov.pk","com.bd","org.bd","net.bd","gov.bd","edu.bd","com.lk","org.lk","gov.lk","edu.lk","com.np","org.np","gov.np","edu.np","com.kh","org.kh","gov.kh","com.mm","org.mm","gov.mm","com.fj","org.fj","gov.fj","ac.fj","com.pg","org.pg","gov.pg","ac.pg","com.kz","org.kz","gov.kz","edu.kz","com.tr","net.tr","org.tr","gov.tr","edu.tr","gen.tr","biz.tr","info.tr","av.tr","bel.tr","k12.tr","co.il","org.il","net.il","ac.il","gov.il","muni.il","com.sa","net.sa","org.sa","gov.sa","edu.sa","med.sa","co.ae","net.ae","org.ae","gov.ae","ac.ae","com.qa","org.qa","net.qa","gov.qa","edu.qa","com.kw","org.kw","net.kw","gov.kw","edu.kw","com.bh","org.bh","net.bh","gov.bh","edu.bh","com.om","org.om","net.om","gov.om","co.om","com.jo","org.jo","net.jo","gov.jo","edu.jo","com.lb","org.lb","net.lb","gov.lb","edu.lb","com.eg","org.eg","net.eg","gov.eg","edu.eg","eun.eg","co.ir","ac.ir","gov.ir","org.ir","net.ir","co.za","org.za","net.za","gov.za","ac.za","web.za","edu.za","nom.za","com.ng","org.ng","net.ng","gov.ng","edu.ng","name.ng","co.ke","or.ke","ne.ke","go.ke","ac.ke","sc.ke","co.tz","or.tz","ne.tz","go.tz","ac.tz","co.ug","or.ug","ne.ug","go.ug","ac.ug","com.gh","org.gh","gov.gh","edu.gh","co.ma","net.ma","org.ma","gov.ma","ac.ma","press.ma","com.tn","org.tn","gov.tn","ens.tn","fin.tn","com.dz","org.dz","net.dz","gov.dz","edu.dz","com.et","org.et","gov.et","edu.et","co.zw","org.zw","gov.zw","ac.zw","co.zm","org.zm","gov.zm","ac.zm","co.bw","org.bw","ac.bw","com.na","org.na","co.na","co.mz","org.mz","gov.mz","com.cm","co.cm","net.cm","gov.cm","com.sn","org.sn","edu.sn","gouv.sn","com.ci","co.ci","or.ci","go.ci","ac.ci","com.tg","gouv.tg","co.rw","gov.rw","ac.rw","*.ck","*.er","*.fk","*.jm","*.kh","*.mm","*.np","*.pg","*.bd","github.io","githubusercontent.com","gitlab.io","bitbucket.io","pages.dev","workers.dev","trycloudflare.com","vercel.app","vercel.dev","now.sh","netlify.app","netlify.com","herokuapp.com","herokussl.com","cloudfront.net","amazonaws.com","s3.amazonaws.com","elasticbeanstalk.com","awsapprunner.com","amplifyapp.com","azurewebsites.net","azurestaticapps.net","cloudapp.net","azureedge.net","azurefd.net","blob.core.windows.net","trafficmanager.net","appspot.com","firebaseapp.com","web.app","run.app","cloudfunctions.net","blogspot.com","fly.dev","onrender.com","up.railway.app","deno.dev","deno.net","glitch.me","repl.co","replit.dev","replit.app","ngrok.io","ngrok.app","ngrok-free.app","ngrok.dev","ngrok-free.dev","surge.sh","readthedocs.io","myshopify.com","wixsite.com","webflow.io","framer.app","framer.website","ondigitalocean.app","digitaloceanspaces.com","supabase.co","fastly.net","global.ssl.fastly.net","edgecompute.app","duckdns.org","dyndns.org","ddns.net","no-ip.org","hopto.org","zapto.org","eu.org","us.org","neocities.org","codeberg.page","sourceforge.io","pythonanywhere.com","streamlit.app","hf.space"]);function r9(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||n0.has(t))return!0;const s=t.slice(t.indexOf(".")+1);return n0.has(`*.${s}`)}function i9(e){return typeof e=="string"&&e.includes("*")}function a9(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,s,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${s.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const a=i.hostname;return a===""||a.startsWith("[")||/^[\d.]+$/.test(a)||a.startsWith(".")||a.includes("..")?{ok:!1,reason:"invalid"}:r9(a)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:a,port:i.port}}}const s0=["every-time","first-time","pre-approved"];function sR(e){const t=s0.indexOf(e);return s0.slice(0,t<0?1:t+1)}function ha(e){return e.endsWith(".account")}const l9="Stored, not usable until it has a binding.";function o9(e){return e==="browser.field"?"the origin of the site that holds the field, e.g. https://en.wikipedia.org or *.wikimedia.org":e==="browser.form.data"?"the origin, then the field name — e.g. https://localhost:8443 card-number":e==="browser.native.type"?"the app’s bundle id, e.g. com.bank.app":e==="http.header"?"the host, then the header name — e.g. localhost:9200 Authorization":e==="http.url"?"the plugin, then the host — e.g. calendar calendar.google.com":e==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":ha(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const rR={"browser.form.data":{hint:"an origin, then the field name",build:(e,t)=>({origin:e,field:t})},"http.header":{hint:"a host, then the header name",build:(e,t)=>({host:e,header:t})},"http.url":{hint:"a plugin, then the host",build:(e,t)=>({plugin:e,host:t})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}},c9="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",u9=e=>`That is a public suffix; ${e} would match every site.`,r0="Give the site as an origin, like https://en.wikipedia.org.";function i0(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(i9(e)){const s=a9(t);if(s.ok)return{ok:!0,target:s.value.pattern};if(s.reason==="placement")return{ok:!1,error:c9};if(s.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:u9(r)}}return{ok:!1,error:r0}}try{const s=new URL(t);if(s.origin==="null"||s.protocol!=="https:"&&s.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:s.origin}}catch{return{ok:!1,error:r0}}}function d9(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const s=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&s?[r,s]:null}function h9(e,t){const s=t.trim();if(s==="")return{ok:!1,error:"Give the exact place this value may go."};if(s.startsWith("{"))try{const a=JSON.parse(s);return a!==null&&typeof a=="object"&&!Array.isArray(a)?{ok:!0,target:a}:{ok:!1,error:'A target in JSON is an object, like {"host":"localhost","header":"Authorization"}.'}}catch{return{ok:!1,error:"That opens like JSON but does not parse."}}if(e==="browser.field")return i0(s);if(e==="browser.native.type"||ha(e))return{ok:!0,target:s};const r=rR[e];if(r===void 0)return{ok:!0,target:s};const i=d9(s);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const a=i0(i[0]);return a.ok?{ok:!0,target:r.build(a.target,i[1])}:a}return{ok:!0,target:r.build(i[0],i[1])}}function f9(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function iR(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const s=t,r=rR[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),a=i.map(l=>s[l]);if(i.every(l=>typeof s[l]=="string"))return a.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const Pl="accounts.provider";function aR(e,t){if(typeof e!="object"||e===null)return[];const s=e[t];return Array.isArray(s)?s.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,a=r.count;return typeof i!="string"||typeof a!="number"||!(a>0)?[]:[{place:i,count:a}]}):[]}function lR(e){const t=e.map(({place:s,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?s.replace(/s$/,""):s}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function m9(e){const t=aR(e,"found");return t.length?`The value already sits in ${lR(t)}.`:""}function p9(e){const t=aR(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${lR(t)}.`:""}const g9=/^(PROVIDER_ACCOUNT_|CODEX_ACCOUNT_|ANTHROPIC_ACCOUNT_|OLLAMA_DEVICE_)/,x9=/^MCP_(TOKEN|ENV|CONNECTION)_/,oR="GMAIL_APP_PASSWORD";function Br(e){const t=e.usedBy??[],s=e.bindings.map(r=>r.kind);if(t.some(r=>r.kind==="mailbox")||s.includes("email.account")||e.name===oR)return"mail";if(t.some(r=>r.kind==="model-account")||s.includes(Pl)||g9.test(e.name))return"models";if(t.some(r=>r.kind==="connection")||s.includes("mcp.env")||x9.test(e.name))return"connections";for(const r of e.bindings){if(r.kind==="http.url"&&Hj(r.target)&&typeof r.target.plugin=="string")return`plugin:${r.target.plugin}`;if(ha(r.kind))return`plugin:${r.kind.slice(0,-8)}`}return"mine"}function v9(e){if(e==="mine")return{title:"Your secrets",aside:"Agents fill these where you allow, without seeing them."};if(e==="mail")return{title:"Mail",aside:"Mailbox passwords. A new one is set on the Email page, which tests it first."};if(e==="models")return{title:"Model accounts",aside:"Managed in Model accounts."};if(e==="connections")return{title:"Connections",aside:"Managed in Connections."};const t=e.slice(7);return t==="calendar"?{title:"Calendar links",aside:"Private links, fetched only by the calendar plugin."}:{title:t.charAt(0).toUpperCase()+t.slice(1),aside:`Kept for the ${t} plugin.`}}function j9(e,t){const s=r=>r==="mine"?0:r==="mail"?1:r==="models"?3:r==="connections"?4:2;return s(e)-s(t)||e.localeCompare(t)}function cR(e){return e==="models"||e==="connections"}function Hj(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function a0(e){const t=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/\/.*$/,"").replace(/^www\./,"");return t.startsWith("*.")?`any ${t.slice(2)} site`:t}const Kj=e=>(e.usedBy??[]).flatMap(t=>t.kind==="mailbox"?[t]:[]),tf=e=>(e.usedBy??[]).find(t=>t.kind==="model-account"),Vj=e=>(e.usedBy??[]).find(t=>t.kind==="connection");function ko(e,t=new Map){var r,i;const s=Br(e);if(s==="mail"){const a=Kj(e)[0];return a?`${a.provider==="Email"?"Mailbox":a.provider} ${a.auth==="xoauth2"?"sign-in":"app password"}`:"Old mailbox password"}if(s==="models"){const a=tf(e),l=(a==null?void 0:a.id)??((r=e.bindings.find(c=>c.kind===Pl&&typeof c.target=="string"))==null?void 0:r.target),o=typeof l=="string"?t.get(l):void 0;return(o==null?void 0:o.label)??(a==null?void 0:a.label)??"Old model account key"}if(s==="connections")return((i=Vj(e))==null?void 0:i.name)??"Old connection sign-in";if(s.startsWith("plugin:")){const a=/^[^:]{1,40}:\s+(.+)$/.exec(e.name);return a?a[1]:e.name}return e.name}function w9(e,t){var r,i,a;if(Br(e)!=="models")return null;const s=((r=tf(e))==null?void 0:r.id)??((i=e.bindings.find(l=>l.kind===Pl&&typeof l.target=="string"))==null?void 0:i.target);return typeof s=="string"?((a=t.get(s))==null?void 0:a.provider)??null:null}function uR(e,t){const s=Hj(t)?t:{},r=i=>typeof s[i]=="string"?s[i]:"";return e==="browser.field"&&typeof t=="string"?`Filled on ${a0(t)}`:e==="browser.form.data"&&r("origin")?`Filled into “${r("field")}” on ${a0(r("origin"))}`:e==="browser.native.type"&&typeof t=="string"?`Typed into the app ${t}`:(e==="http.header"||e==="http.url")&&r("host")?`Sent only to ${r("host")}`:e==="developer.env"&&r("variable")?`Given to ${r("workspace")} as ${r("variable")}`:e==="mcp.env"&&r("variable")?`Given to a program as ${r("variable")}`:e==="email.account"?"Used by a mailbox":e===Pl?"Used by a model account":ha(e)?`Used by a ${e.slice(0,-8)} account`:`Goes to ${iR(e,t)}`}function y9(e,t){return ha(e)||e===Pl?"Signed in":uR(e,t).replace(/^Sent only to/,"Sent to")}const b9={"api-key":"API key for this model account",chatgpt:"ChatGPT sign-in for this model account","anthropic-oauth":"Claude sign-in for this model account","device-key":"Ollama device key for this model account"};function k9(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Gj(e){const t=Br(e);if(t==="mail"){const a=Kj(e).map(l=>l.address);return a.length?`Used by the ${a.length===1?"mailbox":"mailboxes"} ${k9(a)}`:e.name===oR?"From the old .env setup":"No mailbox uses it"}if(t==="models"){const a=tf(e);return a?b9[a.auth]??"Key for this model account":"No model account uses it"}if(t==="connections"){const a=Vj(e);if(a!=null&&a.variable)return`Given to the program as ${a.variable}`;const l=e.bindings.find(c=>c.kind==="http.header"),o=l&&Hj(l.target)&&typeof l.target.host=="string"?l.target.host:null;return o?`Sign-in token · sent only to ${o}`:a?"Sign-in for this connection":"No connection uses it"}if(e.bindings.length===0)return"";const s=e.bindings.map(a=>uR(a.kind,a.target));let r=s.length<=2?s.join(" · "):`${s[0]} and ${s.length-1} more places`;const i=new Set(e.bindings.map(a=>a.rule==="first-time"&&a.firstApprovedAt!==null?"pre-approved":a.rule));return i.size===1&&i.has("every-time")&&(r+=" · asks you every time"),i.size===1&&i.has("first-time")&&(r+=" · asks you the first time"),e.totp&&(r+=" · a fresh code each time"),r}function N9(e,t=Date.now()){return e.lastUse?`Last used ${Oe(e.lastUse.at,t)}`:"Never used"}function tx(e){return gi("email","settings",{account:e,set:"password"})}function dR(e){var s,r;const t=Br(e);if(t==="models"){const i=(s=tf(e))==null?void 0:s.id;return{label:"Managed in Model accounts",href:i?J1(i):De("accounts")}}if(t==="connections"){const i=(r=Vj(e))==null?void 0:r.id;return{label:"Managed in Connections",href:i?Z1(i):De("connections")}}return null}function hR(e){const t=/is not bound to (.+?)\.?$/.exec(e);if(!t)return null;const s=t[1];return/[0-9a-f]{8}-[0-9a-f]{4}-/i.test(s)?null:s}function fR(e,t=Date.now()){if(e.unused)return null;const s=Br(e),r=Kj(e)[0],i=dR(e),a=()=>r?{label:"Set password",href:tx(r.id)}:i?{label:s==="models"?"Fix in Model accounts":"Fix in Connections",href:i.href}:{label:"Set a value",action:"replace"},l=e.lastUse,o=l?Oe(l.at,t):"",c=(l==null?void 0:l.detail)??"";if(e.hasValue===!1||(l==null?void 0:l.outcome)==="refused"&&/has no value stored/.test(c))return{text:"No value stored.",fix:a()};if(r!=null&&r.loginFailedAt)return{text:`${r.provider==="Email"?"The mail server":r.provider} turned it down at sign-in ${Oe(r.loginFailedAt,t)}.`,fix:{label:"Set password",href:tx(r.id)}};if((l==null?void 0:l.outcome)==="refused"){if(/vault is locked/.test(c))return{text:`Held back ${o}: the vault was locked.`,fix:null};if(/TOTP secret/.test(c))return{text:`Held back ${o}: a one-time code goes only into a field on a website.`,fix:null};if(/is not bound to/.test(c)){const u=s==="mine"?hR(c):null;return{text:u?`Held back ${o}: it was asked for at ${u}, where it may not go.`:`Held back ${o}: it was asked for somewhere it may not go.`,fix:s==="mine"?{label:"Change where it may go",action:"places"}:null}}return{text:`Held back ${o}: ${pR(c||null)}.`,fix:null}}if((l==null?void 0:l.outcome)==="failed"){const u=r?a():i?null:{label:"Replace value",action:"replace"};return{text:`Didn’t go through ${o}${c?`: ${c.replace(/\.$/,"")}`:""}.`,fix:u}}return(l==null?void 0:l.outcome)==="pending"?{text:`Waiting for your approval since ${o}.`,fix:{label:"Review",href:Lh}}:s==="mine"&&e.bindings.length===0?{text:"Can’t be used anywhere until you choose where it may go.",fix:{label:"Choose where it may go",action:"places"}}:null}function mR(e){if(!e.unused)return"";const t=Br(e);return t==="mail"?"Not used by anything — no mailbox uses it any more.":t==="models"?"Not used by anything — no model account uses it any more.":t==="connections"?"Not used by anything — no connection uses it any more.":"Not used by anything — what it was for is gone."}function nx(e){return e.usageUnknown&&!e.unused?"Couldn’t check what uses it just now.":""}function _a(e){return!!e.unused&&!cR(Br(e))}function S9(e){if(e.unused||e.bindings.length===0)return"Nothing uses it, so nothing stops working.";const t=Gj(e).split(" · ")[0]??"";return t.startsWith("Filled on ")?`Agents can no longer fill it on ${t.slice(10)}.`:t.startsWith("Sent only to ")?`Agents can no longer send it to ${t.slice(13)}.`:`Whatever uses it stops working: ${t.charAt(0).toLowerCase()}${t.slice(1)}.`}const C9={"every-time":"Every time","first-time":"The first time, then not again","pre-approved":"Never — allowed ahead of time"};function E9(e){const t={"browser.field":"A field on a website","browser.form.data":"A form field, by its name","browser.native.type":"An app on this computer","http.header":"A request to a host","http.url":"A plugin’s web address","developer.env":"A workspace variable","mcp.env":"A program’s variable",[Pl]:"A model account"};return t[e]?t[e]:ha(e)?`A ${e.slice(0,-8)} account`:e}const A9={"every-time":"Every time","first-time":"The first time","pre-approved":"Never"};function pR(e){if(!e)return"buddi didn’t hand it over";if(/has no value stored/.test(e))return"no value was stored";if(/vault is locked/.test(e))return"the vault was locked";if(/TOTP secret/.test(e))return"a one-time code goes only into a field on a website";const t=/is not bound to/.test(e)?hR(e):void 0;return t!==void 0?t?`asked for at ${t}, where it may not go`:"asked for somewhere it may not go":e.replace(/\.$/,"")}function T9(e){return e==="browser.field"?"www.pnc.com":e==="browser.form.data"?"www.pnc.com card-number":e==="browser.native.type"?"com.bank.app":e==="http.header"?"api.github.com Authorization":e==="http.url"?"calendar calendar.google.com":e==="developer.env"?"my-app ADMIN_PASSWORD":ha(e)?"acct-1":'{"host":"localhost","header":"Authorization"}'}function Gd(e){return sR(e).includes("first-time")?"first-time":e}function R9(e){const t=y9(e.kind,e.target);return e.outcome==="refused"?{text:`Held back — ${pR(e.detail)}`,tone:"warning"}:e.outcome==="failed"?{text:`Didn’t go through — ${(e.detail??t).replace(/\.$/,"")}`,tone:"warning"}:e.outcome==="pending"?{text:`Asked for your approval · ${t}`}:{text:t}}async function na(e,t,s,r){s(!0),r(null);try{return(await E.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{s(!1)}}const gR="Passwords, keys and links your agents use without ever seeing them. Each goes only where you allow.";function $9(e,t){if(t==="mail")return"mail";if(t==="models")return"chip";if(t==="connections")return"plug";if(t==="plugin:calendar")return"calendar";const s=e.bindings.map(r=>r.kind);return s.some(r=>r.startsWith("browser."))?"globe":s.includes("developer.env")?"terminal":"key"}function I9({embedded:e,timezone:t,secret:s,adding:r,navigate:i}={}){const a=ce(()=>E.secrets(),[]),l=ce(()=>E.providerAccounts(),[]),o=d.useMemo(()=>{var g;return new Map((((g=l.data)==null?void 0:g.accounts)??[]).map(x=>[x.id,{label:x.label,provider:XT(x)}]))},[l.data]),[c,u]=d.useState(s?{what:"replace",name:s}:r?{what:"add"}:null);d.useEffect(()=>{s&&u({what:"replace",name:s})},[s]),d.useEffect(()=>{r&&u({what:"add"})},[r]);const h=()=>{u(null),(s||r)&&i&&i(De("secrets"))},f=a.data,m=d.useMemo(()=>{const g=new Map;for(const x of(f==null?void 0:f.secrets)??[]){const b=Br(x);g.set(b,[...g.get(b)??[],x])}return[...g.entries()].sort(([x],[b])=>j9(x,b))},[f]),p=c&&c.what!=="add"?(f==null?void 0:f.secrets.find(g=>g.name===c.name))??null:null;return n.jsxs(An,{embedded:e,title:"Keys and secrets",lede:gR,actions:e?void 0:n.jsx(T,{variant:"accent",size:"sm",onClick:()=>u({what:"add"}),children:"Add a secret"}),children:[n.jsxs(re,{gap:"lg",children:[!f&&!a.error?n.jsx(xe,{children:"Opening the vault…"}):null,a.error?n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:a.error}),n.jsx(le,{children:n.jsx(T,{onClick:a.reload,children:"Retry"})})]}):null,f&&f.secrets.length===0?n.jsx(qe,{children:n.jsx(jn,{icon:"lock",title:"Nothing stored yet.",children:"Add a site password or an API token, and say where an agent may use it. Mailbox passwords and calendar links show up here as you add them."})}):null,f&&f.secrets.length>0?n.jsx(qe,{flush:!0,children:m.map(([g,x])=>{const b=v9(g);return n.jsxs("section",{className:"secrets-group","aria-label":b.title,children:[n.jsxs("header",{className:"secrets-group-head",children:[n.jsx("h3",{className:"secrets-group-title",children:b.title}),n.jsx("span",{className:"secrets-group-aside",children:b.aside})]}),n.jsx(dt,{children:x.map(j=>n.jsx(M9,{secret:j,group:g,accounts:o,onOpen:v=>u({what:v,name:j.name})},j.name))})]},g)})}):null,f&&f.ownKeys.length>0?n.jsx(St,{summary:`buddi’s own keys · ${f.ownKeys.length}`,children:n.jsxs("p",{className:"secrets-note",children:["The keys buddi itself runs on, read from its environment:"," ",f.ownKeys.map((g,x)=>n.jsxs("span",{children:[x>0?", ":"",n.jsx("code",{className:"mono",children:g})]},g)),". They aren’t changed here, and buddi hides them in whatever it sends out, like your own."]})}):null]}),(c==null?void 0:c.what)==="add"&&f?n.jsx(L9,{destinations:f.destinations,onClose:h,onChanged:a.reload}):null,p&&(c==null?void 0:c.what)==="sheet"?n.jsx(D9,{secret:p,accounts:o,timezone:t,onClose:h,onOpen:g=>u({what:g,name:p.name})}):null,p&&(c==null?void 0:c.what)==="replace"?n.jsx(_9,{secret:p,title:ko(p,o),onClose:h,onChanged:a.reload}):null,p&&(c==null?void 0:c.what)==="rename"?n.jsx(F9,{secret:p,onClose:h,onChanged:a.reload}):null,p&&(c==null?void 0:c.what)==="places"&&f?n.jsx(z9,{secret:p,title:ko(p,o),destinations:f.destinations,onClose:h,onChanged:a.reload}):null,p&&(c==null?void 0:c.what)==="delete"?n.jsx(U9,{secret:p,title:ko(p,o),onClose:h,onChanged:a.reload}):null]})}const Yd=e=>t=>{t.stopPropagation(),e==null||e()};function xR({fix:e,onOpen:t}){return"href"in e?n.jsx(Tt,{size:"sm",href:e.href,onClick:Yd(),children:e.label}):n.jsx(T,{size:"sm",onClick:Yd(()=>t(e.action)),children:e.label})}function P9(e,t,s){if(t==="mine")return[{label:"Replace value…",onSelect:()=>s("replace")},{label:"Rename…",onSelect:()=>s("rename")},{label:"Change where it may go…",hint:"Places, and when it asks",onSelect:()=>s("places")},{label:"Usage history",onSelect:()=>s("sheet")},"separator",{label:"Delete…",tone:"critical",onSelect:()=>s("delete")}];if(t==="mail"){const r=(e.usedBy??[]).find(i=>i.kind==="mailbox");return[r&&!e.unused?{label:"Set a new password",hint:"On the Email page, which tests it first",onSelect:()=>{window.location.hash=tx(r.id)}}:null,{label:"Usage history",onSelect:()=>s("sheet")},_a(e)?"separator":null,_a(e)?{label:"Remove…",tone:"critical",onSelect:()=>s("delete")}:null]}return[{label:t==="plugin:calendar"?"Replace link…":"Replace value…",onSelect:()=>s("replace")},{label:"Usage history",onSelect:()=>s("sheet")},_a(e)?"separator":null,_a(e)?{label:"Remove…",tone:"critical",onSelect:()=>s("delete")}:null]}function M9({secret:e,group:t,accounts:s,onOpen:r}){const i=ko(e,s),a=w9(e,s),l=[Gj(e),N9(e)].filter(Boolean).join(" · "),o=fR(e),c=mR(e),u=nx(e),h=cR(t)?dR(e):null;return n.jsx(it,{onClick:()=>r("sheet"),label:`${i}: details`,lead:n.jsx(_r,{icon:$9(e,t)}),title:n.jsxs(n.Fragment,{children:[i,a?n.jsx("span",{className:"secrets-tag",children:a}):null]}),sub:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"secrets-line",children:l}),o?n.jsx("span",{className:"secrets-status","data-tone":"warning",children:o.text}):null,c?n.jsx("span",{className:"secrets-status",children:c}):null,u?n.jsx("span",{className:"secrets-status",children:u}):null]}),side:n.jsxs("span",{className:"secrets-side",children:[o!=null&&o.fix?n.jsx(xR,{fix:o.fix,onOpen:r}):null,c&&_a(e)?n.jsx(T,{size:"sm",variant:"ghost",onClick:Yd(()=>r("delete")),children:"Remove…"}):null,h?n.jsxs("a",{className:"secrets-managed",href:h.href,onClick:Yd(),children:[h.label,n.jsx(ue,{name:"chevron-right",size:12})]}):n.jsx(Cl,{label:`More for ${i}`,items:P9(e,t,r),sheet:{title:i,sub:l}})]})})}function D9({secret:e,accounts:t,timezone:s,onClose:r,onOpen:i}){const a=Br(e),l=ko(e,t),o=fR(e),c=mR(e),u=[...new Set(e.bindings.map(m=>m.rule))],h=e.lastUse,f=(e.usedBy??[]).map(m=>({label:m.kind==="mailbox"?"Mailbox":m.kind==="model-account"?"Model account":"Connection",value:n.jsx("code",{className:"mono secrets-mono",children:m.id})}));return n.jsx(ht,{title:l,onClose:r,foot:a==="mine"?n.jsxs(le,{children:[n.jsx(T,{variant:"danger-ghost",onClick:()=>i("delete"),children:"Delete…"}),n.jsx(_t,{}),n.jsx(T,{onClick:()=>i("rename"),children:"Rename…"}),n.jsx(T,{variant:"accent",onClick:()=>i("replace"),children:"Replace value…"})]}):void 0,children:n.jsxs(re,{gap:"lg",children:[n.jsx(Wt,{items:[{label:"Where it may go",value:Gj(e)||"Nowhere yet"},...u.length===1&&a==="mine"?[{label:"Asks you",value:C9[u[0]]}]:[],{label:"Last used",value:h?`${Oe(h.at)}${h.agentId?` by ${h.agentId}`:""}`:"Never"}]}),o?n.jsx(V,{tone:"warning",action:o.fix?n.jsx(xR,{fix:o.fix,onOpen:i}):void 0,children:o.text}):null,c?_a(e)?n.jsxs(V,{action:n.jsx(T,{size:"sm",onClick:()=>i("delete"),children:"Remove…"}),children:[c," Nothing removes it but you."]}):n.jsx(V,{children:c}):null,nx(e)?n.jsx(V,{children:nx(e)}):null,n.jsxs(re,{gap:"sm",children:[n.jsx("h3",{className:"secrets-sheet-head",children:"Usage history"}),n.jsx(O9,{name:e.name,timezone:s})]}),n.jsx(St,{summary:"Details",children:n.jsxs(re,{gap:"sm",children:[n.jsx(Wt,{items:[{label:"Stored as",value:n.jsx("code",{className:"mono secrets-mono",children:e.name})},...e.bindings.map((m,p)=>({key:`b${p}`,label:p===0?"Bindings":"",value:n.jsxs("code",{className:"mono secrets-mono",children:[m.kind," ",iR(m.kind,m.target)," · ",m.rule]})})),...e.totp?[{label:"One-time code",value:"buddi fills the current code, never the seed"}]:[],...f]}),n.jsx("p",{className:"secrets-note",children:"What buddi keeps for it, never the value. “Held back” means buddi declined to hand the value over — not bound to that place, no value stored, or the vault locked — so it never left."})]})})]})})}function O9({name:e,timezone:t}){const s=ce(()=>E.secretUses(e,50),[e]);if(s.error)return n.jsx(ae,{message:s.error});if(!s.data)return n.jsx(xe,{children:"Reading the history…"});const r=s.data.uses;return r.length===0?n.jsx("p",{className:"secrets-note",children:"Nothing has used it yet."}):n.jsx(dt,{children:r.map((i,a)=>{const l=R9(i);return n.jsx(it,{title:n.jsx("span",{className:"secrets-history","data-tone":l.tone,children:l.text}),sub:`${et(i.at,t??"UTC")} · ${i.agent??(i.plugin?`the ${i.plugin} plugin`:"you")}`},a)})})}function vR({title:e,result:t,scrubbed:s,busy:r,failure:i,onScrub:a}){const l=m9(t);return n.jsxs(re,{gap:"sm",children:[n.jsxs(V,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),n.jsx("p",{className:"secrets-note",children:l||"Nothing of the value sits where buddi already holds text."}),n.jsx(ae,{message:i}),l?n.jsx(le,{children:n.jsx(T,{variant:"accent",disabled:r||s!==null,onClick:a,children:s===null?"Scrub the history":p9(s)||"Nothing of it was left to replace."})}):null]})}function jR({destinations:e,bindings:t,disabled:s,onChange:r}){const i=(a,l)=>{r(t.map((o,c)=>c===a?{...o,...l}:o))};return n.jsxs(re,{gap:"sm",children:[t.map((a,l)=>{const o=e.find(h=>h.kind===a.kind),c=(o==null?void 0:o.maxRule)??a.rule,u=o?e:[...e,{kind:a.kind,plugin:"",maxRule:a.rule}];return n.jsxs("div",{className:"secrets-place",children:[n.jsx(ie,{label:"Kind of place",children:n.jsx("select",{value:a.kind,disabled:s,onChange:h=>{var p;const f=h.target.value,m=(p=e.find(g=>g.kind===f))==null?void 0:p.maxRule;i(l,{kind:f,rule:m?Gd(m):a.rule})},children:u.map(h=>n.jsx("option",{value:h.kind,children:E9(h.kind)},h.kind))})}),n.jsx(ie,{label:"The place",children:n.jsx("input",{type:"text",spellCheck:!1,disabled:s,value:a.target,placeholder:T9(a.kind),onChange:h=>i(l,{target:h.target.value})})}),n.jsx(ie,{label:"Asks you",children:n.jsx("select",{value:a.rule,disabled:s,onChange:h=>i(l,{rule:h.target.value}),children:sR(c).map(h=>n.jsx("option",{value:h,children:A9[h]},h))})}),n.jsx(T,{size:"sm",variant:"ghost",disabled:s,onClick:()=>r(t.filter((h,f)=>f!==l)),children:"Remove"}),n.jsxs("p",{className:"ui-field-hint secrets-place-hint",children:["The place: ",o9(a.kind),"."]})]},l)}),t.length===0?n.jsx("p",{className:"ui-field-hint",children:l9}):null,e.length?n.jsx(le,{children:n.jsx(T,{size:"sm",disabled:s,onClick:()=>r([...t,{kind:e[0].kind,target:"",rule:Gd(e[0].maxRule)}]),children:"Add a place"})}):n.jsx("p",{className:"ui-field-hint",children:"Nothing installed here takes a secret yet, so there is nowhere to send one."})]})}function wR(e){const t=e.map(r=>h9(r.kind,r.target)),s=t.findIndex(r=>!r.ok);return s!==-1?{ok:!1,error:`Place ${s+1}: ${t[s].error}`}:{ok:!0,bindings:e.map((r,i)=>({kind:r.kind,target:t[i].target,rule:r.rule}))}}function L9({destinations:e,onClose:t,onChanged:s}){const[r,i]=d.useState(""),[a,l]=d.useState(""),[o,c]=d.useState(!1),[u,h]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:Gd(e[0].maxRule)}]:[]),[f,m]=d.useState(!1),[p,g]=d.useState(null),[x,b]=d.useState(null),[j,v]=d.useState(null),w=async()=>{const N=wR(u);if(!N.ok){g(N.error);return}const k=a;l("");const S=await na("secrets.put",{name:r.trim(),value:k,totp:o,bindings:N.bindings},m,g);S!==null&&(b({name:r.trim(),result:S}),s())},y=async()=>{const N=await na("secrets.scrub_history",{name:(x==null?void 0:x.name)??""},m,g);N!==null&&(v(N),s())};return x?n.jsx(ht,{title:"Add a secret",onClose:t,foot:n.jsx(le,{align:"end",children:n.jsx(T,{onClick:t,children:"Done"})}),children:n.jsx(vR,{title:x.name,result:x.result,scrubbed:j,busy:f,failure:p,onScrub:()=>void y()})}):n.jsx(ht,{title:"Add a secret",size:"wide",onClose:t,foot:n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:t,children:"Cancel"}),n.jsx(T,{type:"submit",form:"secrets-add",variant:"accent",disabled:f,children:"Save secret"})]}),children:n.jsxs("form",{id:"secrets-add",className:"ui-stack","data-gap":"lg",onSubmit:N=>{N.preventDefault(),w()},children:[n.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[n.jsx(ie,{label:"Name",hint:"What agents ask for it by. Saving a name that exists replaces that secret’s value.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:N=>i(N.target.value),placeholder:"PNC password"})}),n.jsx(ie,{label:"Value",hint:"Kept in the vault and never shown again, not even here.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:a,onChange:N=>l(N.target.value)})}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:N=>c(N.target.checked)}),n.jsx("span",{children:"It’s a one-time-code seed — buddi fills the current code, never the seed"})]})]}),n.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[n.jsx("h3",{className:"secrets-sheet-head",children:"Where it may go"}),n.jsx("p",{className:"secrets-note",children:"Agents can use it only in these places. Anywhere else, buddi holds it back and the row says so."}),n.jsx(jR,{destinations:e,bindings:u,disabled:f,onChange:h})]}),p?n.jsx(V,{tone:"critical",role:"alert",children:p}):null]})})}function _9({secret:e,title:t,onClose:s,onChanged:r}){const[i,a]=d.useState(""),[l,o]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[m,p]=d.useState(null),g=async()=>{const b=i;a("");const j=await na("secrets.put",{name:e.name,value:b,totp:e.totp,bindings:e.bindings.map(({kind:v,target:w,rule:y})=>({kind:v,target:w,rule:y}))},o,u);j!==null&&(f(j),r())},x=async()=>{const b=await na("secrets.scrub_history",{name:e.name},o,u);b!==null&&(p(b),r())};return h?n.jsx(un,{title:`Replaced the value of “${t}”`,onClose:s,foot:n.jsx(T,{variant:"accent",onClick:s,children:"Done"}),children:n.jsx(vR,{title:t,result:h,scrubbed:m,busy:l,failure:c,onScrub:()=>void x()})}):n.jsx(un,{title:`Replace the value of “${t}”`,onClose:s,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(T,{type:"submit",form:"secrets-replace",variant:"accent",disabled:l||i==="",children:"Save value"})]}),children:n.jsxs("form",{id:"secrets-replace",className:"ui-stack","data-gap":"sm",onSubmit:b=>{b.preventDefault(),i!==""&&g()},children:[n.jsx(ie,{label:"New value",hint:"Kept in the vault and never shown again. Where it may go stays the same.",children:n.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,disabled:l,value:i,onChange:b=>a(b.target.value)})}),n.jsx(ae,{message:c})]})})}function F9({secret:e,onClose:t,onChanged:s}){const[r,i]=d.useState(e.name),[a,l]=d.useState(!1),[o,c]=d.useState(null),u=r.trim()!==""&&r.trim()!==e.name,h=async()=>{await na("secrets.rename",{name:e.name,to:r.trim()},l,c)!==null&&(s(),t())};return n.jsx(un,{title:`Rename “${e.name}”`,onClose:t,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{type:"submit",form:"secrets-rename",variant:"accent",disabled:a||!u,children:"Rename"})]}),children:n.jsxs("form",{id:"secrets-rename",className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),u&&h()},children:[n.jsx(ie,{label:"Name",hint:"What agents ask for it by. One that uses the old name needs the new one.",children:n.jsx("input",{required:!0,autoFocus:!0,maxLength:200,disabled:a,value:r,onChange:f=>i(f.target.value)})}),n.jsx(ae,{message:o})]})})}function z9({secret:e,title:t,destinations:s,onClose:r,onChanged:i}){const[a,l]=d.useState(()=>e.bindings.length?e.bindings.map(m=>({kind:m.kind,target:f9(m.target),rule:m.rule})):s.length?[{kind:s[0].kind,target:"",rule:Gd(s[0].maxRule)}]:[]),[o,c]=d.useState(!1),[u,h]=d.useState(null),f=async()=>{const m=wR(a);if(!m.ok){h(m.error);return}await na("secrets.rebind",{name:e.name,bindings:m.bindings},c,h)!==null&&(i(),r())};return n.jsx(ht,{title:`Where “${t}” may go`,size:"wide",onClose:r,foot:n.jsxs(le,{align:"end",children:[n.jsx(T,{onClick:r,children:"Cancel"}),n.jsx(T,{type:"submit",form:"secrets-places",variant:"accent",disabled:o,children:"Save"})]}),children:n.jsxs("form",{id:"secrets-places",className:"ui-stack","data-gap":"sm",onSubmit:m=>{m.preventDefault(),f()},children:[n.jsx("p",{className:"secrets-note",children:"Agents can use it only in these places. Anywhere else, buddi holds it back and the row says so."}),n.jsx(jR,{destinations:s,bindings:a,disabled:o,onChange:l}),u?n.jsx(V,{tone:"critical",role:"alert",children:u}):null]})})}function U9({secret:e,title:t,onClose:s,onChanged:r}){const[i,a]=d.useState(!1),[l,o]=d.useState(null),c=!!e.unused,u=async()=>{await na("secrets.delete",{name:e.name},a,o)!==null&&(r(),s())};return n.jsxs(un,{title:`${c?"Remove":"Delete"} “${t}”?`,onClose:s,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:i,onClick:()=>void u(),children:c?"Remove":"Delete"})]}),children:[n.jsxs("p",{className:"secrets-dialog-text",children:[S9(e)," The value is gone for good; its usage history stays, under its name."]}),n.jsx(ae,{message:l})]})}function B9({timezone:e,embedded:t}){var p;const{data:s,error:r,reload:i}=ce(()=>E.sentinels(),[],3e4),[a,l]=d.useState(null),[o,c]=d.useState(null),u=(s==null?void 0:s.installed)??[],h=((s==null?void 0:s.runs)??[]).filter(g=>g.lastError),f=u.filter(g=>!g.enabled),m=(g,x)=>{l(g),c(null),E.setSentinelEnabled(g,x).catch(b=>c(b instanceof me?b.message:String(b))).finally(()=>{l(null),i()})};return n.jsxs(An,{embedded:t,title:"Watchers",children:[n.jsx(ae,{message:r??o}),n.jsx(V,{children:"Watchers are small checks that run on their own, with no model involved. An urgent finding wakes an agent, which verifies it before it tells you. The rest waits for the weekly recap."}),h.length>0?n.jsx(V,{tone:"warning",children:h.length===1?"One watcher failed on its last run.":`${h.length} watchers failed on their last run.`}):null,f.length>0?n.jsxs(V,{tone:"warning",children:[f.length===1?"One watcher is off.":`${f.length} watchers are off.`," A watcher that is off does not run, and what it already found stays as it was."]}):null,n.jsx(oe,{title:"Installed",aside:n.jsx("a",{href:`${vt}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:s?u.length===0?n.jsx(jn,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):n.jsx(dt,{children:u.map(g=>{const x=s.runs.find(b=>b.sentinelId===g.id);return n.jsx(it,{lead:n.jsx(ve,{tone:g.enabled?x!=null&&x.lastError?"critical":x?"good":void 0:"muted",children:g.enabled?x!=null&&x.lastError?"failed":x?"ok":"never ran":"off"}),title:g.description,sub:`${g.id}, every ${W9(g.every)}${x!=null&&x.lastError?`. ${x.lastError}`:""}`,side:n.jsxs(n.Fragment,{children:[n.jsx("span",{title:x?et(x.lastRunAt,e):void 0,children:x?Oe(x.lastRunAt):"never ran"}),n.jsx(T,{size:"sm",disabled:a===g.id,onClick:()=>m(g.id,!g.enabled),children:g.enabled?"Turn off":"Turn on"})]})},g.id)})}):n.jsx(xe,{children:"Loading…"})}),n.jsx(fH,{mutes:((p=s==null?void 0:s.alerts)==null?void 0:p.mutes)??[],onChanged:i})]})}function W9(e){if(e%86400===0){const s=e/86400;return s===1?"day":`${s} days`}if(e%3600===0){const s=e/3600;return s===1?"hour":`${s} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}const l0=4,H9={time:"profile",date:"profile",zone:null};function K9({data:e,phone:t}){const s=d.useRef(null),r=GA(),[i,a]=d.useState(.4),l=t?390:1280,o=t?780:800;d.useEffect(()=>{const u=s.current;if(!u)return;const h=()=>a(u.clientWidth/l||.4);if(h(),typeof ResizeObserver>"u")return;const f=new ResizeObserver(h);return f.observe(u),()=>f.disconnect()},[l]);const c=(e==null?void 0:e.owner)??null;return n.jsx("div",{ref:s,className:"lke-preview","data-phone":t?"true":void 0,style:{aspectRatio:`${l} / ${o}`},role:"img","aria-label":"Preview of the lock screen",children:n.jsxs("div",{className:"lk","data-preview":"true","data-bg":Ij(e==null?void 0:e.background,e==null?void 0:e.image),"data-phone":t?"true":void 0,"data-view":"glance",style:{width:l,height:o,transform:`scale(${i})`},"aria-hidden":"true",children:[n.jsx(sT,{data:e??null,now:r,phone:t}),n.jsx("footer",{className:"lk-unlock",children:t?n.jsxs("span",{className:"lk-chip lk-enter",children:[n.jsx(ue,{name:"lock",size:14}),n.jsx("span",{children:"Enter PIN"})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"lk-who",children:[n.jsx("span",{className:"lk-face",children:(c??"You").slice(0,1).toUpperCase()}),c?n.jsx("span",{className:"lk-owner",children:c}):null]}),n.jsxs("span",{className:"lk-pin",children:[n.jsx(ue,{name:"lock",size:15}),n.jsx("span",{className:"lke-pin-hint",children:"Enter your PIN"})]})]})})]})})}function V9({info:e,placement:t,index:s,count:r,onSize:i,onSettings:a,onMove:l,onRemove:o}){var u;const c=t.label??e.title;return n.jsxs("li",{className:"lke-row","data-key":t.key,children:[n.jsxs("span",{className:"lke-row-text",children:[n.jsx("span",{className:"lke-row-title",children:c}),n.jsx("span",{className:"lke-row-sub",children:e.builtIn?"Built in":`${e.plugin} plugin`})]}),n.jsxs("span",{className:"lke-row-tools",children:[e.sizes.length>1?n.jsx(rn,{label:`Size of ${c}`,options:["small","medium"].filter(h=>e.sizes.includes(h)).map(h=>({value:h,label:h==="small"?"Small":"Medium"})),value:t.size,onChange:i}):null,n.jsxs("span",{className:"lke-row-acts",children:[(((u=e.settings)==null?void 0:u.length)??0)>0?n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Settings for ${c}`,title:"Settings",onClick:a,children:n.jsx(ue,{name:"settings",size:14})}):null,n.jsxs("span",{className:"lke-move",children:[n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Move ${c} earlier`,title:"Move earlier",disabled:s===0,onClick:()=>l(-1),children:n.jsx(ue,{name:"chevron-left"})}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Move ${c} later`,title:"Move later",disabled:s===r-1,onClick:()=>l(1),children:n.jsx(ue,{name:"chevron-right"})})]}),n.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":`Take ${c} off the lock screen`,title:"Take off the lock screen",onClick:o,children:n.jsx(ue,{name:"close",size:12})})]})]})]})}function o0(e){return e?"place"in e?`place:${e.place}`:`town:${e.timezone}:${e.label}`:""}function G9({clock:e,onClock:t,version:s}){var G,B,K;const r=e??H9,i=ce(()=>E.lockScreen(),[s]),a=ce(()=>E.widgets("lock"),[]),l=ce(()=>E.owner(),[]),[o,c]=d.useState(void 0),[u,h]=d.useState(!1),[f,m]=d.useState(null),[p,g]=d.useState(null),[x,b]=d.useState(null),[j,v]=d.useState(null);d.useEffect(()=>{a.data&&c(a.data)},[a.data]);const w=((G=i.data)==null?void 0:G.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone,y=(o==null?void 0:o.lock)??[],N=new Map(((o==null?void 0:o.available)??[]).map(F=>[F.id,F])),k=y.length>=l0,S=F=>{if(!o)return Promise.resolve(!1);const Q=o;return m(null),c({...o,lock:F,arranged:{...o.arranged,lock:!0}}),E.saveWidgets("lock",F).then(X=>(c(X),i.reload(),!0),X=>(c(Q),m(`Couldn't save the lock screen's widgets: ${X instanceof Error?X.message:String(X)}`),!1))},C=(F,Q)=>{const X=y.slice(),[Z]=X.splice(F,1);X.splice(F+Q,0,Z),S(X)},$=(F,Q)=>{const X=N.get(F);!X||k||S([...y,{key:ZA(),widget:F,size:X.sizes.includes("small")?"small":X.sizes[0],settings:Q}])},R=F=>{if(F==="find"){b({query:"",found:[],busy:!1});return}if(b(null),F==="")return t({...r,zone:null});if(F.startsWith("place:"))return t({...r,zone:{place:F.slice(6)}});const Q=r.zone&&!("place"in r.zone)?r.zone:j;Q&&t({...r,zone:Q})},I=()=>{if(!x||x.query.trim().length<2)return;const F=x.query.trim();b({query:x.query,found:[],busy:!0}),E.findPlace(F).then(({found:Q})=>{var _e;const X=Q.filter(Ie=>Ie.timezone);if(X.length===0){b({query:F,found:[],busy:!1,missed:`Nothing with a timezone found for “${F}”.`});return}const Z=X[0],de={label:((_e=Z.name.split(",")[0])==null?void 0:_e.trim())||Z.name,timezone:Z.timezone};v(de),b(null),t({...r,zone:de})}).catch(()=>b({query:F,found:[],busy:!1,missed:"The place finder didn’t answer. Try again in a moment."}))},z=new Date,U=F=>jc({dateFormat:F},()=>dr(z,w,{weekday:!0})),A=(((B=l.data)==null?void 0:B.places)??[]).filter(F=>F.timezone&&F.timezone!==w),P=r.zone&&!("place"in r.zone)?r.zone:j,D=((o==null?void 0:o.home)??[]).filter(F=>N.has(F.widget)&&!N.get(F.widget).sensitive),O=((o==null?void 0:o.available)??[]).filter(F=>!F.sensitive),M=((o==null?void 0:o.available)??[]).filter(F=>F.sensitive).map(F=>F.title),W=p?y.find(F=>F.key===p):void 0,_=W?N.get(W.widget):void 0;return n.jsxs(oe,{title:"What it shows",aside:"Every change is kept at once.",panel:!0,children:[n.jsxs("div",{className:"lke",children:[n.jsxs("div",{className:"lke-look",children:[n.jsx(K9,{data:i.data,phone:u}),n.jsxs("div",{className:"lke-look-foot",children:[n.jsx(rn,{label:"Preview on",options:[{value:"desk",label:"Desk"},{value:"phone",label:"Phone"}],value:u?"phone":"desk",onChange:F=>h(F==="phone")}),n.jsxs("span",{className:"lke-look-note",children:["As it shows now",(K=i.data)!=null&&K.focus?", with your focus on":"","."]})]})]}),n.jsxs("div",{className:"lke-controls",children:[n.jsx(ae,{message:f}),n.jsxs("div",{className:"lke-group",role:"group","aria-label":"Clock",children:[n.jsx("p",{className:"lke-group-title",children:"Clock"}),n.jsxs("div",{className:"wg-field",role:"group","aria-label":"Time",children:[n.jsx("span",{className:"wg-field-label",children:"Time"}),n.jsx(rn,{label:"Time",options:[{value:"profile",label:QC()},{value:"12h",label:"12-hour"},{value:"24h",label:"24-hour"}],value:r.time,onChange:F=>t({...r,time:F})})]}),n.jsx(ie,{label:"Date",children:n.jsxs("select",{value:r.date,onChange:F=>t({...r,date:F.target.value}),children:[n.jsxs("option",{value:"profile",children:["Profile · ",U(null)]}),n.jsx("option",{value:"short",children:U("short")}),n.jsx("option",{value:"long",children:U("long")}),n.jsx("option",{value:"iso",children:U("iso")}),n.jsx("option",{value:"off",children:"No date"})]})}),n.jsx(ie,{label:"A second clock",hint:"A place in another zone, under the time.",children:n.jsxs("select",{value:x?"find":o0(r.zone),onChange:F=>R(F.target.value),children:[n.jsx("option",{value:"",children:"None"}),A.map(F=>n.jsxs("option",{value:`place:${F.id}`,children:[F.label," — ",F.name.split(",")[0]]},F.id)),r.zone&&"place"in r.zone&&!A.some(F=>F.id===r.zone.place)?n.jsx("option",{value:o0(r.zone),children:"A place no longer in another zone"}):null,P?n.jsx("option",{value:`town:${P.timezone}:${P.label}`,children:P.label}):null,n.jsx("option",{value:"find",children:"Another town…"})]})}),x?n.jsxs("div",{className:"wg-field-stack",children:[n.jsxs("div",{className:"wg-find",children:[n.jsx("input",{autoFocus:!0,value:x.query,placeholder:"Find a town: Tokyo","aria-label":"Find a town for the second clock",onChange:F=>b({...x,query:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),I()),F.key==="Escape"&&b(null)}}),n.jsx(T,{size:"sm",disabled:x.busy||x.query.trim().length<2,onClick:I,children:x.busy?"Finding…":"Find"})]}),x.missed?n.jsx("span",{className:"ui-field-hint",children:x.missed}):null]}):null]}),n.jsxs("div",{className:"lke-group",role:"group","aria-label":"Widgets",children:[n.jsxs("div",{className:"lke-group-head",children:[n.jsxs("p",{className:"lke-group-title",children:["Widgets ",n.jsxs("span",{className:"lke-count",children:[y.length," of ",l0]})]}),k||!o?n.jsxs(T,{size:"sm",disabled:!0,children:[n.jsx(ue,{name:"plus",size:12})," Add a widget"]}):n.jsx(Cl,{label:"Add a widget",trigger:n.jsxs("button",{type:"button",className:"ui-btn","data-size":"sm",children:[n.jsx(ue,{name:"plus",size:12})," Add a widget"]}),items:[D.length>0?{heading:"As on Home"}:null,...D.map(F=>({label:F.label??N.get(F.widget).title,hint:"same settings",onSelect:()=>$(F.widget,F.settings)})),D.length>0?"separator":null,{heading:"Every widget"},...O.map(F=>({label:F.title,onSelect:()=>$(F.id,{})}))]})]}),o?y.length===0?n.jsx("p",{className:"lke-empty",children:"No widgets: just the clock and the counts."}):n.jsx("ul",{className:"lke-list",children:y.map((F,Q)=>{const X=N.get(F.widget);return X?n.jsx(V9,{info:X,placement:F,index:Q,count:y.length,onSize:Z=>void S(y.map(de=>de.key===F.key?{...de,size:Z}:de)),onSettings:()=>g(F.key),onMove:Z=>C(Q,Z),onRemove:()=>void S(y.filter(Z=>Z.key!==F.key))},F.key):null})}):n.jsx("p",{className:"lke-empty","aria-busy":"true",children:"Reading the lock screen’s widgets…"}),n.jsxs("p",{className:"ui-field-hint",children:[k?"Four is the most it holds; take one off to add another. ":"","Each keeps its own settings, apart from Home’s.",M.length>0?` A sensitive widget — ${M.join(", ")} — never shows here.`:" A sensitive widget never shows here."," ","One with nothing to show right now stays off until it has."]})]}),n.jsxs("p",{className:"lke-note",children:[n.jsx(ue,{name:"moon",size:13}),n.jsx("span",{children:"Your focus shows at the top only while one is on. Approvals and notifications show as counts when there are some, never what they say."})]})]})]}),W&&_?n.jsx(QA,{info:_,placement:W,surface:"lock",onClose:()=>g(null),onSave:F=>S(y.map(Q=>Q.key===W.key?{...Q,settings:F}:Q)).then(Q=>(Q&&g(null),Q)),onRemove:()=>{g(null),S(y.filter(F=>F.key!==W.key))}}):null]})}const Y9=[{id:"earth",label:"Earth"},{id:"field",label:"Buddi"},{id:"dawn",label:"Dawn"},{id:"sea",label:"Sea"},{id:"moss",label:"Moss"},{id:"dusk",label:"Dusk"}],q9=[{value:"1",label:"1 min"},{value:"5",label:"5 min"},{value:"15",label:"15 min"},{value:"60",label:"1 hour"},{value:"never",label:"Never"}],Q9=e=>e.delayMinutes===null?"never":String(e.delayMinutes);function sx(e){if(e instanceof me){const t=e.detail??{};return e.status===429||t.waitUntil?"Too many wrong tries. Wait a moment, then try again.":e.status===403&&typeof t.triesLeft=="number"?`${e.message} ${t.triesLeft} ${t.triesLeft===1?"try":"tries"} left.`:e.message}return"Something went wrong. Try again."}function X9({kind:e,onClose:t,onDone:s}){const[r,i]=d.useState(""),[a,l]=d.useState(""),[o,c]=d.useState(""),[u,h]=d.useState(null),[f,m]=d.useState(!1),p=e==="remove",g=e!=="set",x=!f&&(!g||r.length>=4)&&(p||a.length>=4&&o.length>=4),b=y=>y.replace(/\D/g,"").slice(0,8),j=e==="set"?"Set a PIN":e==="change"?"Change your PIN":"Remove the PIN?",v=y=>{if(y==null||y.preventDefault(),!x)return;if(!p&&a!==o){h("The two PINs aren’t the same.");return}m(!0),h(null),(p?E.removePin(r):E.setPin(a,g?r:void 0)).then(s).catch(k=>{m(!1),h(sx(k))})},w=(y,N,k,S)=>n.jsx(ie,{label:y,children:n.jsx("input",{type:"password",inputMode:"numeric",autoComplete:y==="Current PIN"?"current-password":"new-password",maxLength:8,autoFocus:S,value:N,onChange:C=>{h(null),k(b(C.target.value))}})});return n.jsx(un,{title:j,onClose:t,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{variant:p?"danger":"accent",disabled:!x,onClick:()=>v(),children:p?"Remove PIN":e==="set"?"Set PIN":"Change PIN"})]}),children:n.jsxs("form",{className:"lk-form",onSubmit:v,children:[n.jsx("p",{className:"lk-honest",children:p?"The dashboard stops locking, on every device. You can set a PIN again any time.":"Four to eight digits. You type it to open the dashboard after it locks, on any device signed in to it."}),g?w("Current PIN",r,i,!0):null,p?null:w(e==="set"?"PIN":"New PIN",a,l,!g),p?null:w("The same again",o,c,!1),u?n.jsx(V,{tone:"critical",children:u}):null,n.jsx("button",{type:"submit",hidden:!0,"aria-hidden":"true",tabIndex:-1})]})})}function J9(e){const t=Zh(),s=ce(()=>E.lockState(),[]),[r,i]=d.useState(null),[a,l]=d.useState(null),[o,c]=d.useState(!1),u=d.useRef(null),h=s.data??t.state,f=b=>{t.update(b),s.reload()},m=b=>{l(null),b.then(f).catch(j=>l(sx(j)))},p=b=>{b&&(c(!0),l(null),E.uploadLockBackground(b).then(f).catch(j=>l(sx(j))).finally(()=>{c(!1),u.current&&(u.current.value="")}))};if(!h)return n.jsx(oe,{title:"Lock screen",panel:!0,children:n.jsx(ae,{message:s.error?"Couldn’t read the lock screen’s settings.":null})});const g=h.pin,x=(b,j)=>n.jsxs("button",{type:"button",className:"lk-swatch","data-bg":b,"aria-pressed":h.background===b,"aria-label":j,title:j,onClick:()=>m(E.setLockSettings({background:b})),children:[b==="image"&&h.image?n.jsx("img",{src:h.image,alt:""}):b==="earth"?n.jsx("img",{src:Ug.thumb,alt:""}):n.jsx("span",{className:"lk-swatch-field"}),n.jsx("span",{className:"lk-swatch-label",children:j})]},b);return n.jsxs(n.Fragment,{children:[n.jsxs(oe,{title:"Lock screen",aside:"Kept for every device signed in to this dashboard.",actions:g?n.jsxs(T,{size:"sm",onClick:()=>t.lockNow(),children:[n.jsx(ue,{name:"lock",size:13})," Lock now"]}):void 0,panel:!0,children:[n.jsxs(re,{divided:!0,gap:"lg",children:[n.jsx("p",{className:"lk-honest ui-section",children:"A privacy screen over this dashboard, on every device signed in to it: it locks when nobody has used it for a while, or when you lock it, and opens with your PIN. A new browser opens locked too. It isn’t a second sign-in — anyone who can run buddi on this computer can open it without the PIN. Telegram and buddi in your coding tools carry on as before."}),n.jsx(ae,{message:a}),n.jsxs("div",{className:"lk-pref ui-section",children:[n.jsxs("div",{className:"lk-pref-text",children:[n.jsx("div",{className:"lk-pref-label",children:"PIN"}),n.jsx("div",{className:"ui-field-hint",children:g?"Set. Kept hashed on this buddi; five wrong tries, then a wait that grows.":"Four to eight digits. Until you set one, nothing locks."})]}),g?n.jsxs(le,{children:[n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>i("remove"),children:"Remove…"}),n.jsx(T,{size:"sm",onClick:()=>i("change"),children:"Change…"})]}):n.jsx(T,{size:"sm",variant:"accent",onClick:()=>i("set"),children:"Set a PIN"})]}),n.jsxs("div",{className:"lk-pref ui-section","data-off":g?void 0:"true","aria-disabled":g?void 0:"true",children:[n.jsxs("div",{className:"lk-pref-text",children:[n.jsx("div",{className:"lk-pref-label",children:"Lock after"}),n.jsx("div",{className:"ui-field-hint",children:g?n.jsxs(n.Fragment,{children:["Nobody using it for this long. Lock it yourself from your menu",n.jsxs("span",{className:"lk-shortcut",children:[", or with ",n.jsx("kbd",{className:"lk-kbd",children:t.shortcut})]}),"."]}):"Set a PIN first."})]}),n.jsx(rn,{label:"Lock after",options:q9,value:g?Q9(h):"",onChange:b=>{g&&m(E.setLockSettings({delayMinutes:b==="never"?null:Number(b)}))}})]}),n.jsxs("div",{className:"lk-pref ui-section","data-stack":"true",children:[n.jsxs("div",{className:"lk-pref-text",children:[n.jsx("div",{className:"lk-pref-label",children:"Background"}),n.jsx("div",{className:"ui-field-hint",children:"Behind the time and your widgets, on every device. A picture is kept as a JPEG of at most 2560 pixels, without its location or other details."})]}),n.jsxs("div",{className:"lk-swatches",role:"group","aria-label":"Background",children:[Y9.map(b=>x(b.id,b.label)),h.image?x("image","Your picture"):null,n.jsxs("label",{className:"lk-swatch","data-kind":"add","aria-busy":o?"true":void 0,children:[n.jsx("input",{ref:u,type:"file",accept:"image/jpeg,image/png",className:"lk-sr",disabled:o,onChange:b=>{var j;return p((j=b.target.files)==null?void 0:j[0])}}),n.jsx("span",{className:"lk-swatch-field","data-kind":"add",children:n.jsx(ue,{name:"plus",size:16})}),n.jsx("span",{className:"lk-swatch-label",children:o?"Adding…":h.image?"Replace":"Your picture"})]})]}),n.jsxs("p",{className:"lk-credit",children:["Earth: photo by ",n.jsx("a",{href:wm.authorUrl,target:"_blank",rel:"noreferrer",children:wm.author})," on ",n.jsx("a",{href:wm.photoUrl,target:"_blank",rel:"noreferrer",children:"Unsplash"})]}),h.image?n.jsx(le,{align:"end",children:n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>m(E.removeLockBackground()),children:"Remove picture"})}):null]})]}),r?n.jsx(X9,{kind:r,onClose:()=>i(null),onDone:b=>{i(null),f(b)}}):null]}),n.jsx(G9,{clock:h.clock,onClock:b=>m(E.setLockSettings({clock:b})),version:`${h.background}:${h.image??""}:${JSON.stringify(h.clock??null)}`})]})}const Im=60;function yR(e){return e instanceof me?e.message:"Something went wrong. Try again."}function Z9(e,t,s=Date.now()){const r=`made ${dr(new Date(e.createdAt),t,{compact:!0})} ${e.createdVia==="cli"?"in the terminal":"here"}`;return`buddi_…${e.hint} · ${r} · ${e.lastUsedAt?`last used ${Oe(e.lastUsedAt,s)}`:"never used"}`}function e7({onClose:e,onMade:t}){const[s,r]=d.useState(""),[i,a]=d.useState(!1),[l,o]=d.useState(null),[c,u]=d.useState(null),[h,f]=d.useState(!1),m=!i&&s.trim()!==""&&s.trim().length<=Im,p=g=>{g==null||g.preventDefault(),m&&(a(!0),o(null),E.createApiToken(s.trim()).then(x=>{u({token:x.token,name:x.apiToken.name}),t()}).catch(x=>o(yR(x))).finally(()=>a(!1)))};if(c){const g=()=>{var x;(x=navigator.clipboard)==null||x.writeText(c.token).then(()=>{f(!0),window.setTimeout(()=>f(!1),1600)}).catch(()=>{})};return n.jsx(un,{title:`Token for ${c.name}`,onClose:e,foot:n.jsx(T,{variant:"accent",onClick:e,children:"Done"}),children:n.jsxs("div",{className:"at-form",children:[n.jsxs("div",{className:"at-secret",children:[n.jsx("code",{className:"at-secret-text","aria-label":"The token",children:c.token}),n.jsx(T,{size:"sm",onClick:g,children:h?"Copied":"Copy"})]}),n.jsx(V,{tone:"warning",title:"Copy it now",children:"buddi keeps only a fingerprint of it, so it can’t show it again. Lost it? Revoke it and make another."}),n.jsx("p",{className:"at-text",children:"Send it as a header on every request:"}),n.jsx("code",{className:"at-try",children:`curl -H "Authorization: Bearer buddi_…" ${location.origin}/api/overview`})]})})}return n.jsx(un,{title:"Make a token",onClose:e,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:e,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!m,onClick:()=>p(),children:"Make token"})]}),children:n.jsxs("form",{className:"at-form",onSubmit:p,children:[n.jsx("p",{className:"at-text",children:"It acts as you on buddi’s HTTP API. Anything a gated tool does still waits for your approval here or on Telegram."}),n.jsx(ie,{label:"What will use it",hint:`So you can tell tokens apart later. Up to ${Im} characters.`,children:n.jsx("input",{autoFocus:!0,value:s,maxLength:Im,placeholder:"Home Assistant",onChange:g=>{o(null),r(g.target.value)}})}),l?n.jsx(V,{tone:"critical",children:l}):null,n.jsx("button",{type:"submit",hidden:!0,"aria-hidden":"true",tabIndex:-1})]})})}function t7({token:e,onClose:t,onRevoked:s}){const[r,i]=d.useState(!1),[a,l]=d.useState(null),o=()=>{i(!0),l(null),E.revokeApiToken(e.id).then(()=>{s(),t()}).catch(c=>{i(!1),l(yR(c))})};return n.jsxs(un,{title:`Revoke “${e.name}”?`,onClose:t,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:r,onClick:o,children:"Revoke"})]}),children:[n.jsx("p",{className:"at-text",children:"A request carrying it is refused from now on. Whatever uses it stops working until you give it a new token."}),a?n.jsx(V,{tone:"critical",children:a}):null]})}function n7({timezone:e}){var o;const t=ce(()=>E.apiTokens(),[]),[s,r]=d.useState(!1),[i,a]=d.useState(null),l=((o=t.data)==null?void 0:o.tokens)??[];return n.jsxs(re,{gap:"lg",children:[n.jsx("p",{className:"ui-page-lede",children:"Let a script or another program use buddi without the dashboard. A token acts as you, minus the decisions only you make here."}),n.jsx(ae,{message:t.error?"Couldn’t read the API tokens.":null}),n.jsx(oe,{title:"Tokens",aside:"Kept as a fingerprint · shown once",actions:n.jsx(T,{variant:"accent",size:"sm",onClick:()=>r(!0),children:"Make a token"}),panel:!0,flush:!0,children:t.data&&l.length===0?n.jsxs(xe,{title:"No tokens yet.",children:["Make one here, or in a terminal with ",n.jsx("code",{className:"mono",children:"buddi api-token create <name>"}),"."]}):n.jsx(dt,{children:l.map(c=>n.jsx(it,{lead:n.jsx(_r,{icon:"key"}),title:c.name,sub:Z9(c,e),side:n.jsx(T,{size:"sm",variant:"ghost",onClick:()=>a(c),children:"Revoke…"})},c.id))})}),n.jsxs(oe,{title:"What a token can’t do",panel:!0,children:[n.jsxs("ul",{className:"at-cant",children:[n.jsx("li",{children:"Approve anything, or make a change where your click is the approval. It can reject."}),n.jsx("li",{children:"Change what an agent may do without asking: its tools, who it hands work to, a connection given out, an “Always”."}),n.jsx("li",{children:"Install or run code buddi hasn’t run before: plugins, upgrades, program connections."}),n.jsx("li",{children:"Change how buddi is reached or unlocked — PIN, Tailscale, Telegram pairing, other tokens — or restore a backup."}),n.jsx("li",{children:"Read or store a secret: owner secrets, model account keys, the backup passphrase."})]}),n.jsxs("p",{className:"at-foot",children:["In a terminal: ",n.jsx("code",{className:"mono",children:"buddi api-token create"}),", ",n.jsx("code",{className:"mono",children:"list"}),", ",n.jsx("code",{className:"mono",children:"revoke"}),". Every route, and which a token may call: docs/api.md."]})]}),s?n.jsx(e7,{onClose:()=>r(!1),onMade:()=>t.reload()}):null,i?n.jsx(t7,{token:i,onClose:()=>a(null),onRevoked:()=>t.reload()}):null]})}function s7({embedded:e}){const{data:t,error:s,reload:r}=ce(()=>E.owner(),[]);return n.jsxs(An,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[n.jsx(ae,{message:s}),t?n.jsxs(re,{gap:"lg",children:[n.jsx(a7,{initial:t,onSaved:r}),n.jsx(u7,{initial:t})]}):null]})}const bR=new Date(Date.UTC(2026,9,1,14,5));function r7(){return[["",`Auto (${jc({timeFormat:null},()=>Ht(bR,"UTC"))} here)`],["12h","12-hour · 2:05 PM"],["24h","24-hour · 14:05"]]}function i7(){return[["",`Auto (${jc({dateFormat:null},()=>dr(bR,"UTC",{weekday:!0}))} here)`],["short","Thu, Oct 1"],["long","Thursday, 1 October"],["iso","2026-10-01"]]}function a7({initial:e,onSaved:t}){const[s,r]=d.useState(e.preferredName??""),[i,a]=d.useState(e.timezone??""),[l,o]=d.useState(e.timeFormat??""),[c,u]=d.useState(e.dateFormat??""),[h,f]=d.useState(e.language??""),[m,p]=d.useState(e.about??""),[g,x]=d.useState(!1),[b,j]=d.useState(!1),[v,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),a(e.timezone??""),o(e.timeFormat??""),u(e.dateFormat??""),f(e.language??""),p(e.about??"")},[e]);const y=s.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||l!==(e.timeFormat??"")||c!==(e.dateFormat??"")||h.trim()!==(e.language??"")||m.trim()!==(e.about??""),N=async()=>{x(!0),w(null);try{const C=await E.setOwner({preferredName:s.trim()===""?null:s.trim(),timezone:i===""?null:i,timeFormat:l===""?null:l,dateFormat:c===""?null:c,language:h.trim()===""?null:h.trim(),about:m.trim()===""?null:m.trim()});Sv({timeFormat:C.timeFormat??null,dateFormat:C.dateFormat??null}),window.dispatchEvent(new Event(Vp)),j(!0),t()}catch(C){w(C instanceof me?C.message:String(C))}finally{x(!1)}},k=e.zones.length>0?e.zones:[e.detectedTimezone],S=C=>$=>{j(!1),C($)};return n.jsx(oe,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:n.jsxs(n.Fragment,{children:[b&&!y?n.jsx("span",{className:"muted",children:"Saved"}):null,n.jsx(T,{variant:"accent",disabled:!y||g,onClick:()=>void N(),children:g?"Saving…":"Save"})]}),children:n.jsxs(re,{divided:!0,gap:"lg",children:[n.jsx(oe,{title:"Name, time and language",children:n.jsxs(Os,{children:[n.jsx(ie,{label:"What the agents call you",children:n.jsx("input",{value:s,maxLength:80,placeholder:e.displayName??"Your name",onChange:C=>S(r)(C.target.value)})}),n.jsx(ie,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:n.jsxs("select",{value:i,onChange:C=>S(a)(C.target.value),children:[n.jsx("option",{value:"",children:"Not set (use the host's)"}),k.map(C=>n.jsx("option",{value:C,children:C},C))]})}),n.jsx(ie,{label:"Time",children:n.jsx("select",{value:l,onChange:C=>S(o)(C.target.value),children:r7().map(([C,$])=>n.jsx("option",{value:C,children:$},C))})}),n.jsx(ie,{label:"Dates",hint:"Auto follows this browser's language. Agents write them your way too.",children:n.jsx("select",{value:c,onChange:C=>S(u)(C.target.value),children:i7().map(([C,$])=>n.jsx("option",{value:C,children:$},C))})}),n.jsx(ie,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:n.jsx("input",{value:h,maxLength:40,placeholder:"English, français…",onChange:C=>S(f)(C.target.value)})})]})}),n.jsxs(oe,{title:"About you",children:[n.jsx(ie,{label:"In your own words",hint:"Who you are, how you like answers, anything every agent should keep in mind. A few lines is plenty.",children:n.jsx("textarea",{rows:4,maxLength:1e3,value:m,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:C=>S(p)(C.target.value)})}),v?n.jsx(V,{tone:"critical",children:v}):null]})]})})}const l7=["Home","Work"];function o7(e){const t=e.trim().toLowerCase();return t==="home"?"home":t==="work"?"briefcase":"pin"}function c0({label:e,empty:t}){return n.jsx("span",{className:"place-glyph","data-empty":t?"true":void 0,"aria-hidden":"true",children:n.jsx(ue,{name:o7(e),size:18})})}function c7(e){var s;const t=((s=e.name.split(",").pop())==null?void 0:s.trim())??"";return e.address?t&&!e.address.toLowerCase().includes(t.toLowerCase())?`${e.address} · ${t}`:e.address:e.name}function u7({initial:e}){var c;const[t,s]=d.useState(e.places??[]);d.useEffect(()=>s(e.places??[]),[e]);const[r,i]=d.useState(null),a=e.timezone??e.detectedTimezone,l=l7.filter(u=>!t.some(h=>h.label.toLowerCase()===u.toLowerCase())),o=d.useMemo(()=>new Date,[t]);return n.jsxs(oe,{title:"Places",aside:"the front desk, and plugins you allow",actions:n.jsx(T,{size:"sm",onClick:()=>i({label:""}),children:"Add a place"}),panel:!0,flush:!0,children:[n.jsxs(dt,{children:[t.map(u=>n.jsx(it,{label:`${u.label}: edit`,onClick:()=>i({place:u,label:u.label}),lead:n.jsx(c0,{label:u.label}),title:u.label,sub:c7(u),side:u.timezone&&u.timezone!==a?n.jsxs(ve,{children:[Ht(o,u.timezone)," there"]}):void 0},u.id)),l.map(u=>n.jsx(it,{label:`${u}: add`,onClick:()=>i({label:u}),lead:n.jsx(c0,{label:u,empty:!0}),title:n.jsx("span",{className:"muted",children:u}),sub:"Not set",side:n.jsx(T,{size:"sm",onClick:h=>{h.stopPropagation(),i({label:u})},children:"Add"})},u))]}),n.jsx("p",{className:"place-note",children:"Only the town is looked up, on Open-Meteo, to find where it is and its timezone. The address stays on this computer."}),r?n.jsx(d7,{editing:r,zones:e.zones.length>0?e.zones:[e.detectedTimezone],onClose:()=>i(null),onSaved:u=>{s(u),i(null)}},((c=r.place)==null?void 0:c.id)??`new:${r.label}`):null]})}function d7({editing:e,zones:t,onClose:s,onSaved:r}){const i=e.place,[a,l]=d.useState(e.label),[o,c]=d.useState((i==null?void 0:i.address)??""),[u,h]=d.useState(i?[{name:i.name,latitude:i.latitude,longitude:i.longitude,...i.timezone?{timezone:i.timezone}:{}}]:null),[f,m]=d.useState(0),[p,g]=d.useState((i==null?void 0:i.timezone)??""),[x,b]=d.useState(null),[j,v]=d.useState(null),[w,y]=d.useState((i==null?void 0:i.address)??""),N=u==null?void 0:u[f],k=()=>{o.trim().length<2||(b("find"),v(null),E.findPlace(o.trim()).then(I=>{var z;h(I.found),y(o.trim()),m(0),g(((z=I.found[0])==null?void 0:z.timezone)??""),I.found.length===0&&v("Nothing found by that name. Try the town, with its country.")}).catch(I=>v(I instanceof me?I.message:String(I))).finally(()=>b(null)))},S=()=>{N&&(b("save"),v(null),E.savePlace({...i?{id:i.id}:{},label:a.trim(),address:o.trim()===""?null:o.trim(),name:N.name,latitude:N.latitude,longitude:N.longitude,timezone:p===""?null:p}).then(I=>r(I.places)).catch(I=>v(I instanceof me?I.message:String(I))).finally(()=>b(null)))},C=()=>{i&&(b("remove"),v(null),E.removePlace(i.id).then(I=>r(I.places)).catch(I=>v(I instanceof me?I.message:String(I))).finally(()=>b(null)))},$=i?i.label:e.label?`Add ${e.label}`:"Add a place",R=p!==""&&!t.includes(p)?[p,...t]:t;return n.jsx(ht,{title:$,onClose:s,foot:n.jsxs(le,{children:[i?n.jsx(T,{variant:"danger-ghost",disabled:x!==null,onClick:C,children:x==="remove"?"Removing…":"Remove"}):null,n.jsx(_t,{}),n.jsx(T,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!N||a.trim()===""||x!==null,onClick:S,children:x==="save"?"Saving…":"Save"})]}),children:n.jsxs(re,{gap:"lg",children:[n.jsx(ie,{label:"Name",hint:"What you call it: Home, Work, Mum's.",children:n.jsx("input",{value:a,maxLength:40,autoFocus:!e.label,onChange:I=>l(I.target.value)})}),n.jsx(ie,{label:"Address",hint:"A street address, or just the town.",action:n.jsx(T,{disabled:o.trim().length<2||x!==null,onClick:k,children:x==="find"?"Finding…":"Find"}),children:n.jsx("input",{value:o,maxLength:200,autoFocus:!!e.label&&!i,placeholder:"12 Elm Street, Portland, Maine",onChange:I=>c(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),k())}})}),u&&u.length>0?n.jsx("div",{className:"place-found",role:"radiogroup","aria-label":"Which place",children:u.map((I,z)=>n.jsxs("button",{type:"button",role:"radio","aria-checked":z===f,className:"place-option","data-on":z===f?"true":void 0,onClick:()=>{m(z),g(I.timezone??"")},children:[n.jsx("span",{className:"place-radio","aria-hidden":"true"}),n.jsxs("span",{className:"place-option-text",children:[n.jsx("span",{className:"place-option-name",children:I.name}),n.jsxs("span",{className:"place-option-sub",children:[I.latitude.toFixed(2),", ",I.longitude.toFixed(2),I.timezone?` · ${I.timezone}`:""]})]})]},`${I.latitude},${I.longitude}`))}):n.jsx("p",{className:"place-note-inline",children:"Find it to pin it on the map; nothing is saved until you say Save."}),i&&u&&o.trim()!==w?n.jsx("p",{className:"place-note-inline",children:"The address changed. Find it again to move the pin, or save to keep it where it is."}):null,n.jsx(ie,{label:"Its timezone",hint:N?"From where it is. Change it if that is wrong.":"Filled in once the place is found.",children:n.jsxs("select",{value:p,disabled:!N,onChange:I=>g(I.target.value),children:[n.jsx("option",{value:"",children:"Not known"}),R.map(I=>n.jsx("option",{value:I,children:I},I))]})}),n.jsx(ae,{message:j})]})})}const h7=2e6;function u0(e,t){const s=e.replace(/\r\n/g,`
|
|
115
|
+
`).replace(/\n+$/,"").split(`
|
|
116
|
+
`),r=t.replace(/\r\n/g,`
|
|
117
|
+
`).replace(/\n+$/,"").split(`
|
|
118
|
+
`);if(e.trim()===t.trim())return"(no change)";if(s.length*r.length>h7)return[...s.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
|
|
119
|
+
`);const i=Array.from({length:s.length+1},()=>new Uint32Array(r.length+1));for(let c=s.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=s[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const a=[];let l=0,o=0;for(;l<s.length&&o<r.length;)s[l]===r[o]?(a.push(` ${s[l]}`),l++,o++):i[l+1][o]>=i[l][o+1]?a.push(`-${s[l++]}`):a.push(`+${r[o++]}`);for(;l<s.length;)a.push(`-${s[l++]}`);for(;o<r.length;)a.push(`+${r[o++]}`);return a.join(`
|
|
120
|
+
`)}const kR={skill:"skill",policy:"rule",change:"change to itself"};function f7(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,s])=>!/Id$/.test(t)&&s!==null&&s!==void 0&&s!=="").map(([t,s])=>`${t} ${typeof s=="object"?JSON.stringify(s):String(s)}`).join(" · ")}function rx(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function m7(e,t){const s=e.change;if(!s||s.part!=="tools")return[];if(t===e.editable)return s.added;const r=new Set(rx(s.current??""));return rx(t).filter(i=>!r.has(i))}function p7(e){const t=a=>a.kind==="policy"&&a.ruleKind?`${String(a.payload.plugin??"")}\0${a.ruleKind}`:null,s=new Map;for(const a of e){const l=t(a);l&&s.set(l,(s.get(l)??0)+1)}const r=new Map,i=[];for(const a of e){const l=t(a);if(!l||(s.get(l)??0)<2){i.push(a);continue}let o=r.get(l);o||(o={key:l,label:a.ruleKindLabel||a.ruleKind||"Rules",plugin:String(a.payload.plugin??""),cards:[]},r.set(l,o),i.push(o)),o.cards.push(a)}return i}function g7(e){return"cards"in e}function d0(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function x7({embedded:e,plugin:t}){const{data:s,error:r,reload:i}=ce(()=>E.proposals(),[],3e4),[a,l]=d.useState(null),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState({}),p=async(v,w,y=!1)=>{l(null),c(null),h(v),m(({[v]:N,...k})=>k);try{c(await w()),i()}catch(N){const k=N instanceof Error?N.message:String(N);y?m(S=>({...S,[v]:k})):l(k)}finally{h(null)}},g=gA(),x=((s==null?void 0:s.open)??[]).filter(v=>d0(v,t)),b=((s==null?void 0:s.closed)??[]).filter(v=>d0(v,t)),j=v=>n.jsx(b7,{proposal:v,busy:u===v.id,refusal:f[v.id]??null,onKeep:w=>void p(v.id,async()=>{const y=await E.keepProposal(v.id,w);return`${v.title}: ${y.note}`},!0),onDiscard:w=>void p(v.id,async()=>(await E.discardProposal(v.id,w),`Discarded: ${v.title}. ${v.agent} will be told once and will not propose it again for 90 days.`))},v.id);return n.jsxs(An,{embedded:e,title:"Proposals",lede:"What your agents learned and would like to keep: a procedure, a rule, a change to their own instructions. Keep what is right, correct what is nearly right, discard the rest. A few rules apply themselves, where their plugin allows it (one you always keep, one that only quiets mail sent to many); its own page lists them, with Undo.",children:[n.jsx(ae,{message:r??a}),t?n.jsxs(V,{role:"status",children:["Showing the rules ",t," proposes. ",n.jsx("a",{href:De("proposals"),children:"Show every proposal"})]}):null,o?n.jsx(V,{tone:"good",role:"status",children:o}):null,t?null:n.jsx(xA,{offers:g.offers,reload:g.reload}),!s||x.length===0?n.jsx(oe,{title:"Waiting",panel:!0,children:s?t?n.jsx(jn,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):n.jsx(jn,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):n.jsx(xe,{children:"Loading…"})}):n.jsx(oe,{title:"Waiting",aside:`${x.length} to decide`,children:p7(x).map(v=>g7(v)?n.jsx(v7,{group:v,busy:u===v.key,onKeepAll:()=>void p(v.key,async()=>{const w=await E.keepAllProposals(v.cards.map(y=>y.id));return`${v.label}: ${w.note}`}),card:w=>j(w)},v.key):j(v))}),b.length>0?n.jsx(oe,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:n.jsx(dt,{children:b.map(v=>{var w;return n.jsx(it,{title:v.title,sub:`${v.agent}: ${j7(v)}`,side:v.kind==="skill"&&v.state==="kept"&&((w=v.skill)!=null&&w.live)?n.jsxs(le,{align:"end",children:[n.jsx("span",{className:"muted",children:Oe(v.decidedAt??v.createdAt)}),n.jsx(T,{size:"sm",variant:"ghost",disabled:u===v.id,onClick:()=>void p(v.id,async()=>{const y=v.skill;return await E.removeSkill(v.agent,y.name),`Removed ${y.name} from ${v.agent}. Its versions are kept, and ${v.agent} will not propose it again for 90 days.`}),children:"Remove this skill"})]}):Oe(v.decidedAt??v.createdAt)},v.id)})})}):null,!t&&(s!=null&&s.digest)?n.jsx(y7,{schedule:s.digest.schedule,onSaved:i}):null]})}function v7({group:e,busy:t,onKeepAll:s,card:r}){const i=e.cards.length,a=e.cards.some(l=>l.untrusted);return n.jsx(ws,{tone:a?"warning":"accent",title:`${e.label} (${i})`,meta:n.jsxs(n.Fragment,{children:[n.jsx(ve,{children:kR.policy}),n.jsx(ve,{mono:!0,children:e.plugin})]}),foot:n.jsx(le,{align:"end",children:n.jsxs(T,{variant:"accent",size:"sm",disabled:t,onClick:s,children:["Keep all (",i,")"]})}),children:n.jsxs(re,{gap:"sm",children:[n.jsxs("p",{children:[i," rules of the same kind from ",e.plugin,", each learned from your own decisions. Keep all keeps every one of them as if you had kept each, in one go."]}),n.jsx(St,{summary:`Show each of the ${i}`,children:n.jsx(re,{gap:"sm",children:e.cards.map(l=>r(l))})})]})})}function j7(e){switch(e.state){case"kept":return e.decidedBy==="auto"?e.note??"Kept by itself.":e.kind==="skill"&&e.skill?e.skill.live?`Kept as ${e.skill.name}, version ${e.skill.version}; it loads on the agent's next run.`:`Kept; ${e.skill.name} has a newer version now (${e.skill.version}).`:e.note??"Kept.";case"discarded":return e.reason?`Discarded: ${e.reason}`:"Discarded.";case"expired":return`Expired: ${e.reason??"not decided in 30 days"}.`;default:return"Waiting."}}const w7=Array.from({length:24},(e,t)=>t),h0=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function y7({schedule:e,onSaved:t}){const[s,r]=d.useState(e.day),[i,a]=d.useState(e.hour),[l,o]=d.useState(!1),[c,u]=d.useState(null),h=s!==e.day||i!==e.hour,f=async()=>{o(!0),u(null);try{await E.setDigestSchedule(s,i),u({tone:"good",text:`The digest now runs on ${h0[s]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(m){u({tone:"critical",text:m instanceof Error?m.message:String(m)})}finally{o(!1)}};return n.jsx(oe,{title:"Weekly digest",panel:!0,foot:n.jsx(T,{variant:"accent",disabled:l||!h,onClick:()=>void f(),children:"Save"}),children:n.jsxs(re,{children:[n.jsxs("p",{className:"muted",children:["Once a week, one message on Telegram and a card on Home: what your agents learned, what waits here, and what the rules you kept stopped them doing. No message when nothing was learned and nothing waits.",e.next?` Next: ${Oe(e.next)}.`:""]}),n.jsxs(le,{children:[n.jsx(ie,{label:"Day",children:n.jsx("select",{value:s,disabled:l,onChange:m=>r(Number(m.target.value)),children:h0.map((m,p)=>n.jsx("option",{value:p,children:m},m))})}),n.jsx(ie,{label:`Hour (${e.timezone})`,children:n.jsx("select",{value:i,disabled:l,onChange:m=>a(Number(m.target.value)),children:w7.map(m=>n.jsxs("option",{value:m,children:[String(m).padStart(2,"0"),":00"]},m))})})]}),c?n.jsx(V,{tone:c.tone,role:"status",children:c.text}):null]})})}function f0(e,t){return e==="tools"?rx(t).join(`
|
|
121
|
+
`):t}function b7({proposal:e,busy:t,refusal:s,onKeep:r,onDiscard:i}){const[a,l]=d.useState(e.editable??""),[o,c]=d.useState(""),u=e.editable!==null&&a!==e.editable,h=e.payload,f=e.echoes??[],m=e.kind==="change"?e.change??null:null,p=m7(e,a);return n.jsx(ws,{tone:e.untrusted?"warning":"accent",title:e.title,meta:n.jsxs(n.Fragment,{children:[n.jsx(ve,{children:kR[e.kind]}),n.jsx(ve,{mono:!0,children:e.agent}),e.untrusted?n.jsx(ve,{tone:"warning",children:"untrusted text in view"}):null,p.length>0?n.jsx(ve,{tone:"warning",children:"widens its tools"}):null]}),foot:n.jsxs(le,{align:"end",children:[s?n.jsx("span",{className:"proposal-refusal",role:"alert",children:s}):null,n.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:o,maxLength:300,disabled:t,onChange:g=>c(g.target.value)}),n.jsx(T,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(o.trim()||void 0),children:"Discard"}),n.jsx(T,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&a.trim()==="",onClick:()=>r(u?a:void 0),children:u?"Keep my version":"Keep"})]}),children:n.jsxs(re,{gap:"sm",children:[e.why?n.jsx("p",{children:e.why}):null,n.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Oe(e.createdAt),e.conversationId?n.jsxs(n.Fragment,{children:[" in ",n.jsx("a",{href:il(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?n.jsxs(V,{tone:"warning",title:e.kind==="policy"?"Learned from mail you received.":"Made with untrusted text in view.",children:[e.kind==="policy"?"The plugin counted this rule from your own triage decisions; no instruction in that mail can change what it does.":"Something written by someone other than you was in the agent's context when it proposed this. Read it for instructions that came from there rather than from you.",n.jsx("ul",{className:"proposal-sources",children:e.sources.map(g=>n.jsx("li",{className:"mono",children:g},g))}),f.length>0?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),n.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(g=>n.jsx("li",{children:n.jsx("mark",{className:"wb-diff-mark",children:g})},g))})]}):null]}):null,e.kind==="skill"?n.jsxs(n.Fragment,{children:[typeof h.when=="string"?n.jsxs("p",{className:"ui-card-meta",children:["When: ",h.when]}):null,e.skill?n.jsxs(re,{gap:"sm",children:[n.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",n.jsxs("a",{href:At(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),n.jsx(Id,{text:u0(e.skill.steps,a),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,n.jsx(ie,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:g=>l(g.target.value)})})]}):null,e.kind==="change"?n.jsxs(n.Fragment,{children:[p.length>0?n.jsxs(V,{tone:"warning",title:`Adds: ${p.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,m!=null&&m.refusal&&!u?n.jsx(V,{tone:"warning",title:"Keeping this as proposed will be refused.",children:m.refusal}):null,m&&m.current!==null?n.jsx(Id,{text:u0(f0(m.part,m.current),f0(m.part,a)),marks:f,label:`${e.agent}'s ${m.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof h.before=="string"?n.jsx(St,{summary:`What its ${h.part==="tools"?"tool list":"instructions"} said when proposed`,children:n.jsx(Pt,{children:h.before})}):null,n.jsx(ie,{label:h.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:n.jsx("textarea",{rows:8,value:a,disabled:t,onChange:g=>l(g.target.value)})})]}):null,e.kind==="policy"?n.jsx(Wt,{items:[{label:"Plugin",value:n.jsx("span",{className:"mono",children:String(h.plugin??"")})},{label:"Matches",value:n.jsx("span",{className:"mono",children:f7(h.matcher??{})})},{label:"Does",value:String(h.action??"")},{label:"Learned from",value:(()=>{const g=Array.isArray(h.verdicts)?h.verdicts.length:0;return`${g} ${g===1?"decision":"decisions"}`})()}]}):null]})})}function k7(e){const t=[{label:"Home",path:e.home}];if(e.path===e.home||!e.path.startsWith(`${e.home}/`))return t;let s=e.home;for(const r of e.path.slice(e.home.length+1).split("/"))s=`${s}/${r}`,t.push({label:r,path:s});return t}function N7({start:e,onPick:t,onClose:s}){const[r,i]=d.useState(null),[a,l]=d.useState(null),[o,c]=d.useState(""),u=(p,g=!1)=>{l(null),E.pluginFolders(p).then(x=>{i(x),c("")}).catch(x=>{g&&p!==void 0?u(void 0):l(x instanceof me?x.message:String(x))})};d.useEffect(()=>{u(e,!0)},[]);const h=o.trim().toLowerCase(),f=((r==null?void 0:r.folders)??[]).filter(p=>h===""||p.name.toLowerCase().includes(h)),m=r?k7(r):[];return n.jsxs(ht,{title:"Choose the folder",onClose:s,foot:n.jsxs(le,{children:[n.jsx("span",{className:"plugins-foot-note mono",children:(r==null?void 0:r.path)??""}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",onClick:s,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:!r,onClick:()=>r&&t(r.path),children:"Use this folder"})]}),children:[n.jsx("p",{className:"plugins-note",children:"Folders on the computer buddi runs on, inside your home directory. The one you want holds the plugin's package.json and is already built."}),r?n.jsx(gg,{label:"Folder",items:m.map((p,g)=>g===m.length-1?{key:p.path,label:p.label,current:!0}:{key:p.path,label:p.label,onClick:()=>u(p.path)})}):null,n.jsx($E,{label:"Find a folder here",value:o,placeholder:"Find a folder here…",onChange:c}),n.jsx(ae,{message:a}),r?f.length===0?n.jsx(xe,{children:h===""?"No folders in here.":`No folder here is called anything like “${o.trim()}”.`}):n.jsx(qe,{flush:!0,children:n.jsx(dt,{children:f.map(p=>n.jsx(it,{onClick:()=>u(p.path),label:`Open ${p.name}`,lead:n.jsx(_r,{icon:"folder"}),title:p.name,side:p.plugin?n.jsx(ve,{tone:"accent",children:"package.json"}):void 0},p.path))})}):a?null:n.jsx(xe,{children:"Reading the folders…"}),r!=null&&r.truncated?n.jsx("p",{className:"plugins-note",children:"Only the first 500 folders are listed; find one by name above."}):null]})}const S7="New tools and pages for your team, written by someone else. Each one is read with you, fact by fact, before any of it runs.";function m0(){return n.jsxs("p",{className:"plugins-quiet connections-quiet",children:[n.jsx(ue,{name:"globe",size:14}),n.jsxs("span",{children:["A plugin is code buddi installs and runs; a connection is a service or program buddi talks to."," ",n.jsx("a",{href:De("connections"),children:"Connections"})]})]})}const C7=1500,E7={fetching:"Fetching the package.","installing-dependencies":"Installing its dependencies. Nothing of the plugin has run.",reading:"Reading what it says it is.",done:"Read. Nothing has been imported yet.",failed:"That did not work."},A7="Restart buddi to apply it. In a checkout, stop it and run: buddi serve",NR=[{value:"npm",label:"From npm"},{value:"file",label:"A file"},{value:"directory",label:"A directory I built"}],SR="buddi.plugins.install-mode";function T7(){try{const e=window.localStorage.getItem(SR);if(NR.some(t=>t.value===e))return e}catch{}return"npm"}function R7(e){try{window.localStorage.setItem(SR,e)}catch{}}const Cu=".tgz",Tr=(e,t,s)=>`${e} ${e===1?t:s}`;function CR(e){const t=[];return e.tools>0&&t.push(Tr(e.tools,"tool","tools")),e.sentinels>0&&t.push(`${e.sentinels} on a timer`),e.views>0&&t.push(Tr(e.views,"view","views")),e.agents>0&&t.push(`${Tr(e.agents,"agent","agents")} proposed`),t.length===0?"nothing on its own":t.join(", ")}function ix(e){return e.kind==="registry"?`npm · ${e.name}@${e.version}`:e.kind==="tarball"?`a file on this machine · ${e.path}`:`a directory on this machine · ${e.path}`}function ER(e){return e.kind==="registry"?"npm":e.kind==="tarball"?"a file":"a directory"}function Yj(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function AR(e){return e.author?e.author.name:e.source.kind==="registry"?e.publisher??"nobody npm will name":"you"}function nf({author:e}){return e.url?n.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.name}):n.jsx(n.Fragment,{children:e.name})}function ax({value:e}){return e===void 0||e===""?n.jsx("span",{className:"muted",children:"none — this came off a disk"}):n.jsx("span",{className:"plugins-hash",children:e})}function TR(e){return e.length===0?"none; nothing leaves this computer":n.jsx("span",{className:"mono",children:e.join(", ")})}function qj(e){return e.length===0?"Nothing beyond its own tables, its own folder and its own tools' approvals.":e.map(t=>`It ${t.words}.`).join(" ")}const wi=e=>e instanceof me?e.message:String(e);function $7(e){const[t,s]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){s(void 0),i(null);return}let a=!1;const l=()=>{E.pluginJob(e).then(c=>{a||(s(c),(c.phase==="done"||c.phase==="failed")&&(a=!0))}).catch(c=>{a||(i(wi(c)),a=!0)})};l();const o=window.setInterval(l,C7);return()=>{a=!0,window.clearInterval(o)}},[e]),{job:t,error:r}}function I7({plugin:e,pages:t,navigate:s,variant:r}){const i=t.filter(a=>a.plugin===e);return i.length===0?null:n.jsx(n.Fragment,{children:i.map(a=>{const l=lr(a.plugin,a.id);return n.jsx(Tt,{size:"sm",variant:r,href:l,"aria-label":`Open ${a.title}`,onClick:o=>{o.stopPropagation(),s&&(o.preventDefault(),s(l))},children:i.length===1?"Open":`Open ${a.title}`},a.id)})})}function RR({plugin:e}){var s;if(e.enabled===!1)return n.jsx(ve,{children:"disabled"});const t=(s=e.needs)==null?void 0:s[0];return t?n.jsxs(ve,{tone:"warning",children:["needs ",t.plugin]}):e.loadsAtRestart?n.jsx(ve,{tone:"accent",children:"loads at restart"}):e.loaded&&e.setup?n.jsx(ve,{tone:"warning",children:"needs setup"}):e.loaded?n.jsx(ve,{tone:"good",dot:!0,children:"loaded"}):n.jsx(ve,{tone:"critical",children:"did not load"})}function Qj({entry:e}){var t;return e.trust==="by-buddi"?n.jsx(ve,{tone:"accent",children:"by buddi"}):n.jsxs(ve,{tone:"good",children:["reviewed ",((t=e.reviewed)==null?void 0:t.version)??e.version]})}const lx=De("plugins"),Pm={installed:lx,browse:`${lx}?tab=browse`};function P7({railPages:e=[],settingsPages:t=[],navigate:s,hash:r=""}={}){const i=ce(()=>E.plugins(),[],2e4),[a,l]=d.useState(null),{job:o,error:c}=$7(a),[u,h]=d.useState(null),[f,m]=d.useState(()=>Cb(r));d.useEffect(()=>m(Cb(r)),[r]);const[p,g]=d.useState(null),[x,b]=d.useState(null),[j,v]=d.useState(null),[w,y]=d.useState(null),[N,k]=d.useState(!1),S=J=>{k(!0),E.market(J).then(y).catch(je=>y({plugins:[],unavailable:wi(je)})).finally(()=>k(!1))};d.useEffect(()=>{f==="browse"&&w===null&&!N&&S(!1)},[f]);const C=J=>{h(null),l(J)},$=J=>h(wi(J)),[R,I]=d.useState(!1),z=J=>{I(!0),g(null),J.then(je=>{C(je.job.id),m("installed")}).catch($).finally(()=>I(!1))},U=d.useRef(null);d.useEffect(()=>{const J=cF(r);if(!(J===null||U.current===J)){U.current=J,m("installed"),z(E.stagePlugin(J));try{window.history.replaceState(window.history.state,"",lx)}catch{}}},[r]);const A=J=>je=>{je.preventDefault(),m(J),g(null),s==null||s(Pm[J])};d.useEffect(()=>{((o==null?void 0:o.phase)==="done"||(o==null?void 0:o.phase)==="failed")&&i.reload()},[o==null?void 0:o.phase]);const P=i.data,D=(P==null?void 0:P.checkout)??!0,O=(P==null?void 0:P.installed)??[],M=J=>w==null?void 0:w.plugins.find(je=>je.installed!==void 0&&(je.installed.name??je.name)===J.name),W=J=>e.some(je=>je.plugin===J),_=(J,je)=>W(J)?n.jsx(I7,{plugin:J,pages:e,navigate:s,variant:je}):void 0,G=J=>{const je=e.find(Ge=>Ge.plugin===J);je&&s&&s(lr(je.plugin,je.id))},B=J=>{const je=t.find(Ge=>Ge.plugin===J);if(!(!je||!s))return()=>s(gi(je.plugin,je.id))},K=((w==null?void 0:w.plugins)??[]).filter(J=>J.update).length,F=(J,je)=>E.setPluginEnabled(J,je).then(Ge=>{dU(),v({name:J,notes:Ge.notes??[]}),i.reload()}),Q=(J,je,Ge)=>E.uninstallPlugin(J,je?{purge:!0,confirm:Ge}:{}).then(lt=>{g(null),v({name:J,notes:lt.notes??[]}),i.reload()}),X=J=>{h(null),F(J,!0).catch($)},Z=(J,je)=>{const Ge=w==null?void 0:w.plugins.find(ot=>{var q;return(((q=ot.installed)==null?void 0:q.name)??ot.name)===J&&ot.installed!==void 0}),lt=Ge&&je?`${Ge.npm}@${je}`:void 0;z(lt?E.updatePlugin(J,je,lt):E.updatePlugin(J,je))},de=J=>{h(null);const je=Ge=>{const lt=Ge.plugins.find(ot=>{var q;return ot.name===J||((q=ot.installed)==null?void 0:q.name)===J});if(!lt){h(`${J} is not listed on withbuddi.com. Add it from npm, a file or a directory above, then install this one.`);return}z(E.stagePlugin(`${lt.npm}@${lt.version}`))};if(w&&w.plugins.length>0)return je(w);I(!0),E.market(!1).then(Ge=>{y(Ge),je(Ge)}).catch($).finally(()=>I(!1))},_e=(J,je)=>je===void 0?void 0:je.place==="settings"?gi(J,je.id):lr(J,je.id),Ie=J=>{var Ge;if(J.enabled===!1)return;const je=(Ge=J.needs)==null?void 0:Ge[0];if(je)switch(je.state){case"missing":return{label:`Install ${je.plugin}`,run:()=>de(je.plugin)};case"disabled":return{label:`Enable ${je.plugin}`,run:()=>X(je.plugin)};case"range":return{label:`Update ${je.plugin}`,run:()=>Z(je.plugin)};case"setup":{const lt=_e(je.plugin,je.page),ot=lt&&s?()=>s(lt):B(je.plugin);return ot?{label:`Set up ${je.plugin}`,run:ot}:void 0}default:return{label:`See ${je.plugin}`,run:()=>g({kind:"installed",name:je.plugin})}}if(J.loaded&&J.setup){const lt=_e(J.name,J.setup.page),ot=lt&&s?()=>s(lt):B(J.name);return ot?{label:"Set it up",run:ot}:void 0}},Ue=n.jsxs(Tc,{label:"Plugins",children:[n.jsx(ll,{href:Pm.installed,active:f==="installed",count:K,onClick:A("installed"),children:"Installed"}),n.jsx(ll,{href:Pm.browse,active:f==="browse",onClick:A("browse"),children:"Browse"})]}),ee=(P==null?void 0:P.staged)??[],be=U7(ee,(o==null?void 0:o.phase)==="done"?o.stagedId:void 0),se=ee.find(J=>J.id===be),Te=ee.filter(J=>J.id!==be),pe=J=>{g(null),W7(J),l(null),i.reload()},Re=(p==null?void 0:p.kind)==="staged"?Te.find(J=>J.id===p.name):void 0,Se=(p==null?void 0:p.kind)==="installed"?O.find(J=>J.name===p.name):void 0,Fe=(p==null?void 0:p.kind)==="market"?w==null?void 0:w.plugins.find(J=>J.name===p.name):void 0,Ze=j&&!(Se&&Se.name===j.name)&&j.notes.length>0?j.notes:null,Ee=Re?n.jsx(F7,{staged:Re,onClose:()=>g(null),onInstalled:pe,onInstallFirst:de,onGone:()=>{g(null),i.reload()}},Re.id):Se?n.jsx(Q7,{plugin:Se,listing:M(Se),notes:(j==null?void 0:j.name)===Se.name?j.notes:null,canOpen:W(Se.name)&&Se.enabled!==!1,onOpen:()=>G(Se.name),onClose:()=>g(null),onDisable:()=>b({kind:"disable",name:Se.name}),onEnable:()=>X(Se.name),onRemove:()=>b({kind:"remove",name:Se.name}),onUpdate:J=>Z(Se.name,J),onSettings:Se.enabled===!1?void 0:B(Se.name),firstStep:Ie(Se),busy:R}):Fe?n.jsx(rG,{entry:Fe,canOpen:Fe.installed!==void 0&&W(Fe.installed.name??Fe.name),onOpen:()=>{var J;return G(((J=Fe.installed)==null?void 0:J.name)??Fe.name)},onClose:()=>g(null),onInstall:()=>z(E.stagePlugin(`${Fe.npm}@${Fe.version}`)),onUpdate:J=>{var je;return Z(((je=Fe.installed)==null?void 0:je.name)??Fe.name,J)},busy:R}):null,ze=x?O.find(J=>J.name===x.name):void 0,nt=x?n.jsx(X7,{kind:x.kind,name:x.name,canDisable:(ze==null?void 0:ze.enabled)!==!1,onCancel:()=>b(null),onDisableInstead:()=>b({kind:"disable",name:x.name}),onDisable:()=>F(x.name,!1).then(()=>b(null)),onRemove:(J,je)=>Q(x.name,J,je).then(()=>b(null))},`${x.kind}:${x.name}`):null;if(f==="browse")return n.jsxs(re,{gap:"lg",children:[n.jsx(m0,{}),Ue,n.jsx(ae,{message:u}),n.jsx(iG,{market:w,loading:N,busy:R,onRetry:()=>S(!0),onOpen:J=>g({kind:"market",name:J.name}),onInstall:J=>z(E.stagePlugin(`${J.npm}@${J.version}`)),onUpdate:(J,je)=>{var Ge;return Z(((Ge=J.installed)==null?void 0:Ge.name)??J.name,je)}}),Ee]});const Ye=(P==null?void 0:P.builtIn)??[];return n.jsxs(re,{gap:"lg",children:[n.jsx(m0,{}),Ue,n.jsx(ae,{message:i.error??u??c}),P!=null&&P.unavailable?n.jsx(V,{tone:"warning",children:P.unavailable}):null,Ze?n.jsx(V,{role:"status",children:Ze.join(" ")}):null,n.jsx(M7,{trust:(P==null?void 0:P.trust)??"",job:o,busy:o!==void 0&&o.phase!=="done"&&o.phase!=="failed",onStaged:C,onFailed:h}),se?n.jsx(L7,{staged:se,onInstalled:pe,onGone:()=>i.reload(),onInstallFirst:de},se.id):null,Te.length>0?n.jsx(qe,{flush:!0,title:"Waiting for you",tool:Tr(Te.length,"package","packages"),children:n.jsx("div",{className:"plugins-rows",children:n.jsx(dt,{children:Te.map(J=>n.jsx(_7,{staged:J,onReview:()=>{IR(J),g({kind:"staged",name:J.id})},onReject:()=>{h(null),E.rejectStaged(J.id).then(()=>i.reload()).catch($)}},J.id))})})}):null,P!=null&&P.restartNeeded?n.jsx(B7,{checkout:D,waiting:O.filter(J=>J.loadsAtRestart)}):null,n.jsx(K7,{list:O,firstStepFor:Ie}),n.jsx(qe,{flush:!0,title:"Installed",tool:P?Tr(O.length,"plugin","plugins"):void 0,children:P?O.length===0?n.jsx(xe,{children:"Nothing installed yet. Only what buddi ships with is here."}):n.jsx("div",{className:"plugins-rows",children:n.jsx(dt,{children:O.map(J=>n.jsx(G7,{plugin:J,listing:M(J),open:J.enabled===!1?void 0:_(J.name,"ghost"),canOpen:W(J.name)&&J.enabled!==!1,busy:R,onDetails:()=>g({kind:"installed",name:J.name}),onOpen:()=>G(J.name),onSettings:J.enabled===!1?void 0:B(J.name),onDisable:()=>b({kind:"disable",name:J.name}),onEnable:()=>X(J.name),onRemove:()=>b({kind:"remove",name:J.name}),onUpdate:je=>Z(J.name,je),firstStep:Ie(J)},J.name))})}):n.jsx(xe,{children:"Loading…"})}),Ye.length>0?n.jsx(J7,{plugins:Ye,openFor:_}):null,Ee,nt]})}function M7({trust:e,job:t,busy:s,onStaged:r,onFailed:i}){const[a,l]=d.useState(T7),[o,c]=d.useState(""),[u,h]=d.useState(!1),[f,m]=d.useState(null),[p,g]=d.useState(null),[x,b]=d.useState(!1),[j,v]=d.useState(!1),w=d.useRef(null),y=C=>i(wi(C)),N=C=>{l(C),R7(C),g(null)},k=()=>{h(!0),E.stagePlugin(o.trim()).then(C=>{r(C.job.id),c("")}).catch(y).finally(()=>h(!1))},S=C=>{if(C){if(!C.name.toLowerCase().endsWith(Cu)){m(null),g(`${C.name} is not a ${Cu}. A packed plugin is the file npm pack writes.`);return}g(null),m(C.name),h(!0),E.uploadPlugin(C).then($=>r($.job.id)).catch(y).finally(()=>h(!1))}};return n.jsxs(qe,{title:"Add a plugin",actions:n.jsx(rn,{label:"Where it comes from",options:NR,value:a,onChange:N}),children:[n.jsxs("div",{className:"plugins-add",children:[a==="file"?n.jsxs("div",{className:"plugins-drop",role:"group","aria-label":"A plugin file","data-state":x?"over":p?"refused":f?"chosen":void 0,onDragOver:C=>{C.preventDefault(),b(!0)},onDragLeave:()=>b(!1),onDrop:C=>{var $,R;C.preventDefault(),b(!1),S((R=($=C.dataTransfer)==null?void 0:$.files)==null?void 0:R[0])},children:[n.jsx(ue,{name:"drop",size:20}),n.jsx("span",{className:"plugins-drop-text",children:p??(f?`${f} — reading it.`:n.jsxs(n.Fragment,{children:["Drop a ",n.jsx("span",{className:"mono",children:Cu})," here: the file ",n.jsx("span",{className:"mono",children:"npm pack"})," ","writes. It is read the moment it lands."]}))}),n.jsx(T,{variant:"accent",disabled:s||u,onClick:()=>{var C;return(C=w.current)==null?void 0:C.click()},children:"Choose a file"}),n.jsx("input",{ref:w,type:"file",accept:Cu,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:C=>{var $;S(($=C.target.files)==null?void 0:$[0]),C.target.value=""}})]}):n.jsxs("div",{className:"plugins-add-row",children:[n.jsxs(le,{valign:"end",children:[n.jsx(ie,{grow:!0,label:a==="npm"?"Package":"The directory it is in",children:n.jsx("input",{type:"text",value:o,placeholder:a==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:C=>c(C.target.value)})}),a==="directory"?n.jsx(T,{onClick:()=>v(!0),children:"Browse…"}):null,n.jsx(T,{variant:"accent",disabled:s||u||o.trim()==="",onClick:k,children:"Read it first"})]}),n.jsx("span",{className:"ui-field-hint",children:a==="npm"?"A package name, or a name@version. Reading fetches it and hashes it; nothing of it runs.":"The folder with its package.json, already built. Nothing of it runs until you say yes."})]}),t?n.jsxs("p",{className:"plugins-status",role:"status","data-tone":t.phase==="failed"?"critical":void 0,children:[E7[t.phase]," ",t.error??""]}):null,n.jsx("div",{className:"plugins-trust",children:n.jsx(V,{tone:"warning",children:e})})]}),j?n.jsx(N7,{start:o.trim().startsWith("/")?o.trim():void 0,onClose:()=>v(!1),onPick:C=>{c(C),v(!1)}}):null]})}function D7({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],s=((i=e.uses)==null?void 0:i.dropped)??[];return n.jsxs("span",{className:"plugins-uses",children:[t.length===0?qj([]):t.map(a=>n.jsxs("span",{children:["It ",a.words,". ",a.added?n.jsxs(ve,{tone:"warning",children:["new in ",e.version]}):null]},a.use)),s.length>0?n.jsxs("span",{className:"muted",children:["No longer: ",s.map(a=>a.words).join("; "),"."]}):null]})}function $R(e,t,s){const[r,i]=d.useState(e.plan??null),[a,l]=d.useState(!1),[o,c]=d.useState(null);return{plan:r,busy:a,failed:o,approve:f=>{l(!0),c(null),E.approveStaged(e.id,{integrity:e.integrity??"",...f?{acknowledgeDrift:!0}:{}}).then(m=>{m.installed?t(e.name):m.plan&&i(m.plan)}).catch(m=>c(wi(m))).finally(()=>l(!1))},reject:()=>{l(!0),c(null),E.rejectStaged(e.id).then(()=>s()).catch(f=>c(wi(f))).finally(()=>l(!1))}}}function IR(e){e.openedAt||E.openedStaged(e.id).catch(()=>{})}function O7({staged:e,onInstallFirst:t}){return n.jsxs("span",{className:"plugins-requires",children:[(e.requires??[]).map(s=>n.jsxs("span",{className:"plugins-require",children:[n.jsxs("span",{title:s.range,children:[n.jsx("span",{className:"mono",children:s.plugin})," ",s.rangeWords??s.range]}),s.state==="ok"?n.jsx("span",{className:"plugins-require-ok",children:s.installed?`${s.installed} is here`:"here"}):s.state==="missing"?n.jsxs(n.Fragment,{children:[n.jsx(ve,{tone:"warning",children:"not installed"}),t?n.jsxs(T,{size:"sm",onClick:()=>t(s.plugin),children:["Install ",s.plugin," first"]}):null]}):n.jsx(ve,{tone:"warning",children:s.state==="disabled"?"disabled here":s.state==="range"?`${s.installed??"another version"} is here`:s.state==="failed"?"did not load here":"waiting here"})]},s.plugin)),(e.requires??[]).some(s=>s.state!=="ok")?n.jsx("span",{className:"muted",children:"It installs either way, and waits — tools and widgets off, nothing lost — until each is here and set up."}):null]})}function PR({staged:e,inSheet:t,onInstallFirst:s}){var i;const r=e.dependencies;return n.jsxs("div",{className:"plugins-staged","data-in":t?"sheet":void 0,children:[n.jsx("div",{className:"plugins-facts",children:n.jsx(Wt,{items:[...e.author?[{label:"By",value:n.jsx(nf,{author:e.author})}]:[],{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:ix(e.source)},{label:"Published by",value:Yj(e.source,e.publisher)},...e.previousSource&&e.previous?[{label:"Replaces",value:`${e.previous.version}, installed from ${ix(e.previousSource)}`}]:e.source.kind==="directory"&&((i=e.previous)==null?void 0:i.version)===e.version?[{label:"Reinstalls",value:`${e.version}, the same version, its files read again from the folder`}]:[],...e.source.kind==="directory"?[]:[{label:"Installs as",value:e.installsAs?n.jsx("span",{className:"mono",children:e.installsAs}):"the name its manifest gives, read when you approve — it declares no buddi.name"}],...e.coreAsDependency?[{label:"Core",value:"It asks npm for buddi's core; buddi provides its own."}]:[],{label:"Dependencies",value:r.count===0?"none":`${r.count}${r.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${r.withScripts.join(", ")}`}`},{label:"What it reaches",value:n.jsx(D7,{staged:e})},...(e.requires??[]).length>0?[{label:"Needs",value:n.jsx(O7,{staged:e,onInstallFirst:s})}]:[],{label:"Integrity",value:n.jsx(ax,{value:e.integrity})},...e.stagedHash?[{label:"Files on disk",value:n.jsx(ax,{value:e.stagedHash})}]:[]]})}),n.jsxs("div",{className:"plugins-claim",children:[n.jsx("div",{className:"plugins-claim-head",children:"What it says about itself"}),n.jsx("div",{className:"plugins-claim-note",children:"From its own buddi.md. Nothing has checked it yet."}),e.claims.missing?n.jsx("p",{className:"plugins-claim-text",children:"It ships no buddi.md, so it says nothing about itself at all."}):n.jsxs("p",{className:"plugins-claim-text",children:["“",e.claims.text,"”"]}),n.jsx("div",{className:"plugins-facts",children:n.jsx(Wt,{items:[{label:"Schema it owns",value:e.claims.schema?n.jsx("span",{className:"mono",children:e.claims.schema}):"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":n.jsx("span",{className:"mono",children:e.claims.hosts.join(", ")})}]})})]})]})}function MR({plan:e,busy:t,onReject:s,onInstallAnyway:r}){return n.jsxs(ws,{tone:"warning",title:"What it said, and what it does",meta:n.jsx(ve,{tone:"warning",children:"read this first"}),foot:n.jsxs(le,{children:[n.jsx("span",{className:"plugins-foot-note",children:"Install anyway says you read these."}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",disabled:t,onClick:s,children:"Not this one"}),n.jsx(T,{variant:"danger",disabled:t,onClick:r,children:"Install anyway"})]}),children:[n.jsx("p",{className:"plugins-note",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),n.jsx("ul",{className:"plugins-drift",children:e.drift.map(i=>n.jsx("li",{children:i},i))}),n.jsx(DR,{unlocks:e.agents??[]})]})}function L7({staged:e,onInstalled:t,onGone:s,onInstallFirst:r}){const{plan:i,busy:a,failed:l,approve:o,reject:c}=$R(e,t,s);d.useEffect(()=>IR(e),[e.id]);const u=(i==null?void 0:i.drift)??[];return n.jsxs(re,{gap:"sm",children:[n.jsxs(ws,{tone:"accent",title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"plugins-ver",children:e.version})]}),meta:n.jsx(ve,{children:"read, not installed"}),foot:n.jsxs(le,{children:[n.jsx("span",{className:"plugins-foot-note",children:"Nothing of it has run."}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",disabled:a,onClick:c,children:"Not this one"}),n.jsx(T,{variant:"accent",disabled:a||u.length>0,onClick:()=>o(!1),children:"Install"})]}),children:[n.jsx(ae,{message:l}),n.jsx(PR,{staged:e,onInstallFirst:r})]}),i&&u.length>0?n.jsx(MR,{plan:i,busy:a,onReject:c,onInstallAnyway:()=>o(!0)}):null]})}function _7({staged:e,onReview:t,onReject:s}){const r=Oe(e.createdAt);return n.jsx(it,{onClick:t,label:`${e.name}: review`,lead:n.jsx(_r,{svg:void 0}),title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"plugins-ver",children:e.version})]}),sub:`from ${ER(e.source)}${r?` · read ${r}`:""}`,side:n.jsxs("span",{className:"plugins-side",children:[n.jsxs("span",{className:"plugins-wait-extra",children:[n.jsx(ve,{children:"read, not installed"}),n.jsx(T,{size:"sm",variant:"ghost",onClick:cl(s),children:"Not this one"})]}),n.jsx(T,{size:"sm",onClick:cl(t),children:"Review"})]})})}function F7({staged:e,onClose:t,onInstalled:s,onGone:r,onInstallFirst:i}){const{plan:a,busy:l,failed:o,approve:c,reject:u}=$R(e,s,r),h=(a==null?void 0:a.drift)??[];return n.jsxs(ht,{title:n.jsx(Zj,{svg:void 0,name:e.name,version:e.version,by:e.author?n.jsx(nf,{author:e.author}):Yj(e.source,e.publisher),pills:n.jsxs(n.Fragment,{children:[" · ",n.jsx(ve,{children:"read, not installed"})]})}),onClose:t,foot:n.jsxs(le,{children:[n.jsx("span",{className:"plugins-foot-note",children:"Nothing of it has run."}),n.jsx(_t,{}),n.jsx(T,{variant:"ghost",disabled:l,onClick:u,children:"Not this one"}),n.jsx(T,{variant:"accent",disabled:l||h.length>0,onClick:()=>c(!1),children:"Install"})]}),children:[n.jsx(ae,{message:o}),n.jsx(PR,{staged:e,inSheet:!0,onInstallFirst:i}),a&&h.length>0?n.jsx(MR,{plan:a,busy:l,onReject:u,onInstallAnyway:()=>c(!0)}):null]})}const z7=10*60*1e3;function U7(e,t,s=Date.now()){if(t&&e.some(a=>a.id===t))return t;const r=[...e].sort((a,l)=>(l.createdAt??"").localeCompare(a.createdAt??""))[0];if(!(r!=null&&r.createdAt))return null;const i=s-Date.parse(r.createdAt);return Number.isFinite(i)&&i<z7?r.id:null}function B7({checkout:e,waiting:t}){const[s,r]=d.useState(!1),[i,a]=d.useState(null),l=qF(t),o=l?`${l} ${t.length===1?"is":"are"} installed.`:"A plugin was installed, disabled or enabled since buddi started, and this buddi has not caught up.";return n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:i}),n.jsxs(V,{tone:e?"warning":"accent",role:"status",action:e?void 0:n.jsx(T,{size:"sm",variant:"accent",disabled:s,onClick:()=>{r(!0),a(null),zh({kind:"plugins",...l?{line:`Loading ${l}…`}:{line:"Applying your plugin changes…"}},()=>E.serviceAction("restart")).catch(c=>a(wi(c))).finally(()=>r(!1))},children:"Restart to load it"}),children:[o," ",e?A7:`${l?t.length===1?"Its tools appear":"Their tools appear":"It takes effect"} once buddi restarts, which takes a few seconds. This page waits and comes back by itself.`]})]})}const Xj="buddi.plugins.justInstalled";function W7(e){try{window.sessionStorage.setItem(Xj,e)}catch{}}function H7(){try{return window.sessionStorage.getItem(Xj)}catch{return null}}function K7({list:e,firstStepFor:t}){var u;const[s,r]=d.useState(()=>H7()),i=s?e.find(h=>h.name===s):void 0,a=i!==void 0&&(i.loaded||i.needs!==void 0),l=a&&(i.needs!==void 0||i.setup!==void 0),o=()=>{try{window.sessionStorage.removeItem(Xj)}catch{}r(null)};if(d.useEffect(()=>{a&&!l&&o()},[a,l]),!i||!l)return null;const c=t(i);return n.jsx(V,{tone:"accent",role:"status",action:n.jsxs(n.Fragment,{children:[n.jsx(T,{size:"sm",variant:"ghost",onClick:o,children:"Later"}),c?n.jsx(T,{size:"sm",variant:"accent",onClick:()=>{o(),c.run()},children:c.label}):null]}),children:i.needs?`${i.name} is installed and waits. ${Jj(i)}.`:`${i.name} is loaded. First: ${((u=i.setup)==null?void 0:u.note)??"set it up on its settings page."}`})}const cl=e=>t=>{t.stopPropagation(),e()},V7=e=>e.unlocks.filter(t=>t.drift.state==="not-accepted").length;function Jj(e){var t;return e.needs&&e.needs.length>0?e.needs.map(s=>s.state==="setup"&&s.note?`${s.words}: ${s.note}`:s.words).join(" · "):((t=e.setup)==null?void 0:t.note)??"Not set up yet. Its settings say what it needs."}function G7({plugin:e,listing:t,open:s,canOpen:r,busy:i,onDetails:a,onOpen:l,onSettings:o,onDisable:c,onEnable:u,onRemove:h,onUpdate:f,firstStep:m}){const p=e.enabled===!1,g=V7(e),x=!p&&(e.needs!==void 0||e.loaded&&e.setup!==void 0);return n.jsx(it,{onClick:a,label:`${e.name}: details`,dimmed:p,lead:n.jsx(_r,{svg:t==null?void 0:t.iconSvg}),title:n.jsxs(n.Fragment,{children:[e.name," ",n.jsx("span",{className:"plugins-ver",children:e.version}),g>0?n.jsxs("span",{className:"plugins-ask",children:[Tr(g,"agent","agents")," to accept"]}):null]}),sub:x?n.jsx("span",{className:"plugins-sub","data-tone":"warning",children:Jj(e)}):`by ${AR(e)} · from ${ER(e.source)} · ${CR(e.contribution)}`,side:n.jsxs("span",{className:"plugins-side",children:[x&&m?n.jsx(T,{size:"sm",onClick:cl(m.run),children:m.label}):null,t!=null&&t.update?n.jsxs(T,{size:"sm",disabled:i,onClick:cl(()=>f(t.update)),children:["Update to ",t.update]}):null,x?null:s,!x&&!r&&o?n.jsx(T,{size:"sm",variant:"ghost",onClick:b=>{b.stopPropagation(),o()},children:"Settings"}):null,n.jsx(RR,{plugin:e}),n.jsx(Cl,{label:`More for ${e.name}`,items:[{label:"Details",onSelect:a},r?{label:"Open its page",onSelect:l}:null,o?{label:"Its settings",onSelect:o}:null,e.source.kind==="directory"&&!i?{label:"Reinstall from folder",hint:"reads its files again",onSelect:()=>f()}:null,p?{label:"Enable",hint:"all of it comes back",onSelect:u}:{label:"Disable…",hint:"keeps its data",onSelect:c},"separator",{label:"Remove…",tone:"critical",onSelect:h}]})]})})}const Y7={"not-accepted":["warning","not accepted"],"up-to-date":["good","up to date"],"owner-edited":["accent","yours, edited"],"proposal-changed":["warning","proposal changed"],"owner-edited-and-proposal-changed":["warning","edited, and changed"],gone:[void 0,"gone"]};function DR({plugin:e,unlocks:t}){return t.length===0?null:n.jsxs(oe,{title:"Agents it would unlock",children:[n.jsx("div",{className:"plugins-unlocks",children:n.jsx(dt,{children:t.map(s=>n.jsx(q7,{plugin:e,unlock:s},s.id))})}),n.jsxs("p",{className:"plugins-note",children:["Nothing here is created by installing. Accept creates the agent with the tools listed; change or remove it"," ",n.jsx("a",{href:Et,children:"on the Agents page"}),"."]})]})}function q7({plugin:e,unlock:t}){const s=jj(e,t.id),r=s.created?"up-to-date":t.drift.state,[i,a]=Y7[r];return n.jsxs("div",{className:"plugins-unlock",children:[n.jsx(it,{title:n.jsxs("span",{className:"plugins-handle",children:["@",t.handle]}),sub:s.created?"Accepted just now. It is on the Agents page.":t.drift.message,side:n.jsxs("span",{className:"plugins-side",children:[n.jsx(ve,{tone:i,children:a}),e&&r==="not-accepted"?n.jsx(T,{size:"sm",variant:"accent",disabled:s.busy,onClick:s.accept,children:"Accept"}):null]})}),n.jsx(ae,{message:s.failure}),s.created?n.jsx(mA,{agent:s.created}):null]})}function Zj({svg:e,name:t,version:s,by:r,pills:i}){return n.jsxs("span",{className:"plugins-sheet-title",children:[n.jsx(_r,{svg:e,size:"lg"}),n.jsxs("span",{className:"plugins-sheet-name",children:[n.jsxs("span",{children:[t," ",n.jsx("span",{className:"plugins-ver",children:s})]}),n.jsxs("span",{className:"plugins-sheet-by",children:["by ",r,i]})]})]})}function Q7({plugin:e,listing:t,notes:s,canOpen:r,busy:i,onOpen:a,onSettings:l,onClose:o,onDisable:c,onEnable:u,onRemove:h,onUpdate:f,firstStep:m}){var v,w;const p=e.enabled===!1,g=e.author!==void 0&&e.source.kind==="directory",x=(t==null?void 0:t.summary)??e.description,b=(e.network??((w=(v=t==null?void 0:t.claims)==null?void 0:v.manifest)==null?void 0:w.network)??[]).map(y=>y.host),j=e.uses??(t==null?void 0:t.usesWords);return n.jsxs(ht,{title:n.jsx(Zj,{svg:t==null?void 0:t.iconSvg,name:e.name,version:e.version,by:e.author?n.jsx(nf,{author:e.author}):AR(e),pills:n.jsxs(n.Fragment,{children:[t?n.jsxs(n.Fragment,{children:[" · ",n.jsx(Qj,{entry:t})]}):null," · ",n.jsx(RR,{plugin:e})]})}),onClose:o,foot:n.jsxs(le,{children:[n.jsx(T,{variant:"danger-ghost",onClick:h,children:"Remove…"}),n.jsx(_t,{}),l?n.jsx(T,{variant:"ghost",onClick:l,children:"Settings"}):null,r?n.jsx(T,{onClick:a,children:"Open"}):null,p?n.jsx(T,{onClick:u,children:"Enable"}):n.jsx(T,{variant:"ghost",onClick:c,children:"Disable…"}),t!=null&&t.update?n.jsxs(T,{variant:"accent",disabled:i,onClick:()=>f(t.update),children:["Update to ",t.update]}):n.jsx(T,{disabled:i,onClick:()=>f(),children:e.source.kind==="directory"?"Reinstall from folder":"Check for an update"})]}),children:[e.error?n.jsx(V,{tone:"critical",children:e.error}):null,s&&s.length>0?n.jsx(V,{role:"status",children:s.join(" ")}):null,p?n.jsx(V,{children:"Disabled: its tools, pages and watchers are off and its missions are paused. Its data is kept."}):null,!p&&e.needs&&e.needs.length>0?n.jsxs(V,{tone:"warning",action:m?n.jsx(T,{size:"sm",variant:"accent",onClick:m.run,children:m.label}):void 0,children:["Waiting: ",Jj(e),". Its tools and widgets stay off until then; its data is kept."]}):!p&&e.loaded&&e.setup?n.jsxs(V,{tone:"warning",action:m?n.jsx(T,{size:"sm",variant:"accent",onClick:m.run,children:m.label}):void 0,children:["Not set up yet. ",e.setup.note??"Its settings say what it needs."]}):null,x?n.jsx("p",{className:"plugins-summary-full",children:x}):null,n.jsx("div",{className:"plugins-facts",children:n.jsx(Wt,{items:[{label:"From",value:ix(e.source)},...g?[]:[{label:"Published by",value:Yj(e.source,e.publisher)}],{label:"Integrity",value:n.jsx(ax,{value:e.integrity})},{label:"Installed",value:Oe(e.installedAt)},...e.installedAs?[{label:"Installed as",value:e.installedAs}]:[],{label:"Contributes",value:CR(e.contribution)},...e.network||t?[{label:"Talks to hosts",value:TR(b)}]:[],...j?[{label:"Reaches in buddi",value:qj(j)}]:[]]})}),n.jsx(DR,{plugin:e.name,unlocks:e.unlocks})]})}function X7({kind:e,name:t,canDisable:s,onCancel:r,onDisableInstead:i,onDisable:a,onRemove:l}){const[o,c]=d.useState(!1),[u,h]=d.useState(""),[f,m]=d.useState(!1),[p,g]=d.useState(null),x=j=>{m(!0),g(null),j().catch(v=>g(wi(v))).finally(()=>m(!1))};if(e==="disable")return n.jsxs(un,{title:`Disable ${t}?`,onClose:r,foot:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",disabled:f,onClick:r,children:"Cancel"}),n.jsx(T,{variant:"accent",disabled:f,onClick:()=>x(a),children:"Disable"})]}),children:[n.jsx("p",{className:"plugins-dialog-text",children:"Its tools, pages and watchers stop now and its missions pause. Its data and the agents you accepted from it are kept; enable it to have it all back."}),n.jsx(ae,{message:p})]});const b=!o||u.trim()===t;return n.jsxs(un,{title:`Remove ${t}?`,onClose:r,foot:n.jsxs(n.Fragment,{children:[s?n.jsx(T,{variant:"ghost",size:"sm",disabled:f,onClick:i,children:"Disable instead"}):null,n.jsx(_t,{}),n.jsx(T,{variant:"ghost",disabled:f,onClick:r,children:"Cancel"}),n.jsx(T,{variant:"danger",disabled:f||!b,onClick:()=>x(()=>l(o,u.trim())),children:o?"Remove and drop its data":"Remove"})]}),children:[n.jsxs("p",{className:"plugins-dialog-text",children:["This takes ",t," off this machine and stops its code loading. Its tables and the agents you accepted from it stay."]}),n.jsxs("div",{className:"plugins-purge","data-on":o?"true":void 0,children:[n.jsxs("label",{className:"plugins-check",children:[n.jsx("input",{type:"checkbox",checked:o,onChange:j=>{c(j.target.checked),h("")}}),n.jsxs("span",{children:[n.jsx("span",{className:"plugins-check-title",children:"Also drop its data"}),n.jsx("span",{className:"plugins-check-hint",children:"Its tables are gone for good; there is no undo."})]})]}),o?n.jsx(ie,{label:n.jsxs(n.Fragment,{children:["Type ",n.jsx("span",{className:"mono",children:t})," to confirm"]}),children:n.jsx("input",{autoFocus:!0,value:u,onChange:j=>h(j.target.value)})}):null]}),n.jsx(ae,{message:p})]})}function J7({plugins:e,openFor:t}){return n.jsxs(St,{boxed:!0,summary:`Ships with buddi · ${Tr(e.length,"plugin","plugins")}`,children:[n.jsx("p",{className:"plugins-note",children:"Compiled into this buddi: nothing to approve, nothing to remove. An agent still reaches one only if its own tools line names it."}),n.jsx("div",{className:"plugins-builtins",children:e.map(s=>{const r=(s.network??[]).map(a=>a.host),i=[s.description,s.author?`By ${s.author.name}.`:null,r.length>0?`Talks to ${r.join(", ")}.`:null].filter(Boolean).join(" ");return n.jsxs("div",{className:"plugins-builtin",title:i||void 0,children:[n.jsx("span",{className:"mono",children:s.name}),n.jsxs("span",{className:"plugins-builtin-n",children:[t(s.name,"ghost"),Tr(s.contribution.tools,"tool","tools")]})]},s.name)})})]})}const Z7=[{value:"days",label:"Your days"},{value:"money",label:"Money"},{value:"voice",label:"Voice"},{value:"work",label:"Work"},{value:"home",label:"Home"},{value:"other",label:"Other"}];function eG(e,t){const s=t.trim().toLowerCase();return s===""?!0:[e.title,e.summary,e.npm].some(r=>r.toLowerCase().includes(s))}function tG({pricing:e}){return e.kind==="free"?n.jsx(n.Fragment,{children:"free"}):n.jsxs(n.Fragment,{children:[e.kind==="paid"?"paid":"a subscription",e.trialDays?` · ${e.trialDays} days to try`:"",e.note?` · ${e.note}`:"",e.vendor?n.jsxs(n.Fragment,{children:[" · ",n.jsx("a",{href:e.vendor,target:"_blank",rel:"noopener noreferrer",children:"its maker's page"})]}):null]})}function nG({entry:e,busy:t,onOpen:s,onInstall:r,onUpdate:i}){var a;return n.jsxs(ws,{onClick:s,label:`${e.title}: details`,children:[n.jsxs("div",{className:"plugins-card-head",children:[n.jsx(_r,{svg:e.iconSvg,size:"lg"}),n.jsxs("div",{className:"plugins-card-name",children:[n.jsx("h3",{className:"ui-card-title",children:e.title}),n.jsxs("div",{className:"plugins-card-by",children:["by ",((a=e.author)==null?void 0:a.name)??"someone who gave no name"]})]})]}),n.jsx("p",{className:"plugins-summary",children:e.summary}),n.jsxs("div",{className:"plugins-card-foot",children:[n.jsx(Qj,{entry:e}),e.installed?n.jsxs(ve,{children:["installed ",e.installed.version]}):null,n.jsx(_t,{}),e.update?n.jsxs(T,{size:"sm",disabled:t,onClick:cl(()=>i(e.update)),children:["Update to ",e.update]}):e.installed?null:n.jsx(T,{size:"sm",variant:"accent",disabled:t,onClick:cl(r),children:"Install"})]})]})}function sG(e){var o,c;const t=(o=e.claims)==null?void 0:o.manifest,s=t==null?void 0:t.tools;if(!s)return;const r=s.filter(u=>u.tier==="auto").length,i=s.length-r,a=((c=t==null?void 0:t.sentinels)==null?void 0:c.length)??0,l=[r>0?`${r} run without asking`:null,i>0?`${i} ask${i===1?"s":""} you first`:null,a>0?`${a} on a timer`:null].filter(Boolean);return l.length===0?"none":l.join(", ")}function rG({entry:e,canOpen:t,busy:s,onOpen:r,onClose:i,onInstall:a,onUpdate:l}){var m,p,g,x,b,j,v,w;const o=(m=e.screenshots)==null?void 0:m[0],c=(((g=(p=e.claims)==null?void 0:p.manifest)==null?void 0:g.network)??[]).map(y=>y.host),u=sG(e),h=((j=(b=(x=e.claims)==null?void 0:x.manifest)==null?void 0:b.agents)==null?void 0:j.length)??0,f=(w=(v=e.claims)==null?void 0:v.package)==null?void 0:w.dependencies;return n.jsxs(ht,{title:n.jsx(Zj,{svg:e.iconSvg,name:e.title,version:e.version,by:e.author?n.jsx(nf,{author:e.author}):"someone who gave no name",pills:n.jsxs(n.Fragment,{children:[" · ",n.jsx(Qj,{entry:e}),e.installed?n.jsxs(n.Fragment,{children:[" · ",n.jsxs(ve,{children:["installed ",e.installed.version]})]}):null]})}),onClose:i,foot:n.jsxs(le,{children:[n.jsx("span",{className:"plugins-foot-note",children:e.installed&&!e.update?"This is the version you have.":"Install reads it first. Nothing of it runs until you say yes."}),n.jsx(_t,{}),t?n.jsx(T,{onClick:r,children:"Open"}):null,e.update?n.jsxs(T,{variant:"accent",disabled:s,onClick:()=>l(e.update),children:["Update to ",e.update]}):e.installed?null:n.jsx(T,{variant:"accent",disabled:s,onClick:a,children:"Install"})]}),children:[o?n.jsx("img",{className:"plugins-shot",src:E.marketAssetUrl(o),alt:`${e.title}, as it looks in buddi`}):null,n.jsx("p",{className:"plugins-summary-full",children:e.summary}),n.jsx("div",{className:"plugins-facts",children:n.jsx(Wt,{items:[{label:"Package",value:n.jsx("span",{className:"mono",children:`${e.npm}@${e.version}`})},...u?[{label:"Tools",value:u}]:[],...h>0?[{label:"Proposes",value:`${Tr(h,"agent","agents")}, created only if you accept`}]:[],{label:"Talks to hosts",value:TR(c)},{label:"Reaches in buddi",value:qj(e.usesWords??[])},...f?[{label:"Dependencies",value:f.count===0?"none":`${f.count}${f.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${f.withScripts.join(", ")}`}`}]:[],{label:"Licence",value:n.jsxs(n.Fragment,{children:[e.license??"not stated"," · ",n.jsx(tG,{pricing:e.pricing})]})}]})})]})}function iG({market:e,loading:t,busy:s,onRetry:r,onOpen:i,onInstall:a,onUpdate:l}){const[o,c]=d.useState(""),[u,h]=d.useState("all"),f=(e==null?void 0:e.plugins)??[],m=[{value:"all",label:"All"},{value:"recommended",label:"Recommended"},...Z7.filter(x=>f.some(b=>b.category===x.value))],p=f.filter(x=>u==="recommended"&&(x.trust!=="by-buddi"||x.installed)||u!=="all"&&u!=="recommended"&&x.category!==u?!1:eG(x,o)),g=o.trim();return n.jsxs(re,{gap:"lg",children:[n.jsxs(le,{children:[n.jsx($E,{grow:!0,label:"Search plugins",value:o,placeholder:"Search plugins: weather, money, calendar…",onChange:c}),n.jsx(wz,{label:"Show",options:m,value:u,onChange:h})]}),n.jsxs("p",{className:"plugins-quiet",children:[n.jsx(ue,{name:"globe",size:14}),"Opening this tab fetched the list from withbuddi.com. Nothing else leaves."," ",n.jsx("button",{type:"button",className:"plugins-link",disabled:t,onClick:r,children:"Refresh"})]}),e===null||t&&e.unavailable?n.jsx(xe,{children:"Asking withbuddi.com…"}):e.unavailable?n.jsx(V,{tone:"warning",action:n.jsx(T,{size:"sm",disabled:t,onClick:r,children:"Try again"}),children:e.unavailable}):n.jsxs(n.Fragment,{children:[e.stale?n.jsxs(V,{tone:"warning",action:n.jsx(T,{size:"sm",disabled:t,onClick:r,children:"Try again"}),children:["withbuddi.com did not answer, so this is the list as it was",e.fetchedAt?` ${Oe(e.fetchedAt)}`:" last time","."]}):null,p.length>0?n.jsx("div",{className:"plugins-grid",children:p.map(x=>n.jsx(nG,{entry:x,busy:s,onOpen:()=>i(x),onInstall:()=>a(x),onUpdate:b=>l(x,b)},x.npm))}):n.jsx(xe,{warm:!0,title:"Nothing listed matches",children:g!==""?`No plugin on withbuddi.com mentions “${g}”.`:f.length===0?"withbuddi.com lists no plugins yet.":"Nothing on this shelf yet."})]})]})}var $c={},aG=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},OR={},rs={};let ew;const lG=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];rs.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};rs.getSymbolTotalCodewords=function(t){return lG[t]};rs.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};rs.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');ew=t};rs.isKanjiModeEnabled=function(){return typeof ew<"u"};rs.toSJIS=function(t){return ew(t)};var sf={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+s)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(sf);function LR(){this.buffer=[],this.length=0}LR.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let s=0;s<t;s++)this.putBit((e>>>t-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var oG=LR;function Ic(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Ic.prototype.set=function(e,t,s,r){const i=e*this.size+t;this.data[i]=s,r&&(this.reservedBit[i]=!0)};Ic.prototype.get=function(e,t){return this.data[e*this.size+t]};Ic.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s};Ic.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var cG=Ic,_R={};(function(e){const t=rs.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,a=t(r),l=a===145?26:Math.ceil((a-13)/(2*i-2))*2,o=[a-7];for(let c=1;c<i-1;c++)o[c]=o[c-1]-l;return o.push(6),o.reverse()},e.getPositions=function(r){const i=[],a=e.getRowColCoords(r),l=a.length;for(let o=0;o<l;o++)for(let c=0;c<l;c++)o===0&&c===0||o===0&&c===l-1||o===l-1&&c===0||i.push([a[o],a[c]]);return i}})(_R);var FR={};const uG=rs.getSymbolSize,p0=7;FR.getPositions=function(t){const s=uG(t);return[[0,0],[s-p0,0],[0,s-p0]]};var zR={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const a=i.size;let l=0,o=0,c=0,u=null,h=null;for(let f=0;f<a;f++){o=c=0,u=h=null;for(let m=0;m<a;m++){let p=i.get(f,m);p===u?o++:(o>=5&&(l+=t.N1+(o-5)),u=p,o=1),p=i.get(m,f),p===h?c++:(c>=5&&(l+=t.N1+(c-5)),h=p,c=1)}o>=5&&(l+=t.N1+(o-5)),c>=5&&(l+=t.N1+(c-5))}return l},e.getPenaltyN2=function(i){const a=i.size;let l=0;for(let o=0;o<a-1;o++)for(let c=0;c<a-1;c++){const u=i.get(o,c)+i.get(o,c+1)+i.get(o+1,c)+i.get(o+1,c+1);(u===4||u===0)&&l++}return l*t.N2},e.getPenaltyN3=function(i){const a=i.size;let l=0,o=0,c=0;for(let u=0;u<a;u++){o=c=0;for(let h=0;h<a;h++)o=o<<1&2047|i.get(u,h),h>=10&&(o===1488||o===93)&&l++,c=c<<1&2047|i.get(h,u),h>=10&&(c===1488||c===93)&&l++}return l*t.N3},e.getPenaltyN4=function(i){let a=0;const l=i.data.length;for(let c=0;c<l;c++)a+=i.data[c];return Math.abs(Math.ceil(a*100/l/5)-10)*t.N4};function s(r,i,a){switch(r){case e.Patterns.PATTERN000:return(i+a)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(i+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return i*a%2+i*a%3===0;case e.Patterns.PATTERN110:return(i*a%2+i*a%3)%2===0;case e.Patterns.PATTERN111:return(i*a%3+(i+a)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,a){const l=a.size;for(let o=0;o<l;o++)for(let c=0;c<l;c++)a.isReserved(c,o)||a.xor(c,o,s(i,c,o))},e.getBestMask=function(i,a){const l=Object.keys(e.Patterns).length;let o=0,c=1/0;for(let u=0;u<l;u++){a(u),e.applyMask(u,i);const h=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),h<c&&(c=h,o=u)}return o}})(zR);var rf={};const Zr=sf,Eu=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Au=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];rf.getBlocksCount=function(t,s){switch(s){case Zr.L:return Eu[(t-1)*4+0];case Zr.M:return Eu[(t-1)*4+1];case Zr.Q:return Eu[(t-1)*4+2];case Zr.H:return Eu[(t-1)*4+3];default:return}};rf.getTotalCodewordsCount=function(t,s){switch(s){case Zr.L:return Au[(t-1)*4+0];case Zr.M:return Au[(t-1)*4+1];case Zr.Q:return Au[(t-1)*4+2];case Zr.H:return Au[(t-1)*4+3];default:return}};var UR={},af={};const No=new Uint8Array(512),qd=new Uint8Array(256);(function(){let t=1;for(let s=0;s<255;s++)No[s]=t,qd[t]=s,t<<=1,t&256&&(t^=285);for(let s=255;s<512;s++)No[s]=No[s-255]})();af.log=function(t){if(t<1)throw new Error("log("+t+")");return qd[t]};af.exp=function(t){return No[t]};af.mul=function(t,s){return t===0||s===0?0:No[qd[t]+qd[s]]};(function(e){const t=af;e.mul=function(r,i){const a=new Uint8Array(r.length+i.length-1);for(let l=0;l<r.length;l++)for(let o=0;o<i.length;o++)a[l+o]^=t.mul(r[l],i[o]);return a},e.mod=function(r,i){let a=new Uint8Array(r);for(;a.length-i.length>=0;){const l=a[0];for(let c=0;c<i.length;c++)a[c]^=t.mul(i[c],l);let o=0;for(;o<a.length&&a[o]===0;)o++;a=a.slice(o)}return a},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let a=0;a<r;a++)i=e.mul(i,new Uint8Array([1,t.exp(a)]));return i}})(UR);const BR=UR;function tw(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}tw.prototype.initialize=function(t){this.degree=t,this.genPoly=BR.generateECPolynomial(this.degree)};tw.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const s=new Uint8Array(t.length+this.degree);s.set(t);const r=BR.mod(s,this.genPoly),i=this.degree-r.length;if(i>0){const a=new Uint8Array(this.degree);return a.set(r,i),a}return r};var dG=tw,WR={},Ai={},nw={};nw.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var fr={};const HR="[0-9]+",hG="[A-Z $%*+\\-./:]+";let dc="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";dc=dc.replace(/u/g,"\\u");const fG="(?:(?![A-Z0-9 $%*+\\-./:]|"+dc+`)(?:.|[\r
|
|
122
|
+
]))+`;fr.KANJI=new RegExp(dc,"g");fr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");fr.BYTE=new RegExp(fG,"g");fr.NUMERIC=new RegExp(HR,"g");fr.ALPHANUMERIC=new RegExp(hG,"g");const mG=new RegExp("^"+dc+"$"),pG=new RegExp("^"+HR+"$"),gG=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");fr.testKanji=function(t){return mG.test(t)};fr.testNumeric=function(t){return pG.test(t)};fr.testAlphanumeric=function(t){return gG.test(t)};(function(e){const t=nw,s=fr;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,l){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?a.ccBits[0]:l<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return s.testNumeric(a)?e.NUMERIC:s.testAlphanumeric(a)?e.ALPHANUMERIC:s.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(a,l){if(e.isValid(a))return a;try{return r(a)}catch{return l}}})(Ai);(function(e){const t=rs,s=rf,r=sf,i=Ai,a=nw,l=7973,o=t.getBCHDigit(l);function c(m,p,g){for(let x=1;x<=40;x++)if(p<=e.getCapacity(x,g,m))return x}function u(m,p){return i.getCharCountIndicator(m,p)+4}function h(m,p){let g=0;return m.forEach(function(x){const b=u(x.mode,p);g+=b+x.getBitsLength()}),g}function f(m,p){for(let g=1;g<=40;g++)if(h(m,g)<=e.getCapacity(g,p,i.MIXED))return g}e.from=function(p,g){return a.isValid(p)?parseInt(p,10):g},e.getCapacity=function(p,g,x){if(!a.isValid(p))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=i.BYTE);const b=t.getSymbolTotalCodewords(p),j=s.getTotalCodewordsCount(p,g),v=(b-j)*8;if(x===i.MIXED)return v;const w=v-u(x,p);switch(x){case i.NUMERIC:return Math.floor(w/10*3);case i.ALPHANUMERIC:return Math.floor(w/11*2);case i.KANJI:return Math.floor(w/13);case i.BYTE:default:return Math.floor(w/8)}},e.getBestVersionForData=function(p,g){let x;const b=r.from(g,r.M);if(Array.isArray(p)){if(p.length>1)return f(p,b);if(p.length===0)return 1;x=p[0]}else x=p;return c(x.mode,x.getLength(),b)},e.getEncodedBits=function(p){if(!a.isValid(p)||p<7)throw new Error("Invalid QR Code version");let g=p<<12;for(;t.getBCHDigit(g)-o>=0;)g^=l<<t.getBCHDigit(g)-o;return p<<12|g}})(WR);var KR={};const ox=rs,VR=1335,xG=21522,g0=ox.getBCHDigit(VR);KR.getEncodedBits=function(t,s){const r=t.bit<<3|s;let i=r<<10;for(;ox.getBCHDigit(i)-g0>=0;)i^=VR<<ox.getBCHDigit(i)-g0;return(r<<10|i)^xG};var GR={};const vG=Ai;function ul(e){this.mode=vG.NUMERIC,this.data=e.toString()}ul.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};ul.prototype.getLength=function(){return this.data.length};ul.prototype.getBitsLength=function(){return ul.getBitsLength(this.data.length)};ul.prototype.write=function(t){let s,r,i;for(s=0;s+3<=this.data.length;s+=3)r=this.data.substr(s,3),i=parseInt(r,10),t.put(i,10);const a=this.data.length-s;a>0&&(r=this.data.substr(s),i=parseInt(r,10),t.put(i,a*3+1))};var jG=ul;const wG=Ai,Mm=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function dl(e){this.mode=wG.ALPHANUMERIC,this.data=e}dl.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};dl.prototype.getLength=function(){return this.data.length};dl.prototype.getBitsLength=function(){return dl.getBitsLength(this.data.length)};dl.prototype.write=function(t){let s;for(s=0;s+2<=this.data.length;s+=2){let r=Mm.indexOf(this.data[s])*45;r+=Mm.indexOf(this.data[s+1]),t.put(r,11)}this.data.length%2&&t.put(Mm.indexOf(this.data[s]),6)};var yG=dl;const bG=Ai;function hl(e){this.mode=bG.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}hl.getBitsLength=function(t){return t*8};hl.prototype.getLength=function(){return this.data.length};hl.prototype.getBitsLength=function(){return hl.getBitsLength(this.data.length)};hl.prototype.write=function(e){for(let t=0,s=this.data.length;t<s;t++)e.put(this.data[t],8)};var kG=hl;const NG=Ai,SG=rs;function fl(e){this.mode=NG.KANJI,this.data=e}fl.getBitsLength=function(t){return t*13};fl.prototype.getLength=function(){return this.data.length};fl.prototype.getBitsLength=function(){return fl.getBitsLength(this.data.length)};fl.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let s=SG.toSJIS(this.data[t]);if(s>=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
123
|
+
Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),e.put(s,13)}};var CG=fl,YR={exports:{}};(function(e){var t={single_source_shortest_paths:function(s,r,i){var a={},l={};l[r]=0;var o=t.PriorityQueue.make();o.push(r,0);for(var c,u,h,f,m,p,g,x,b;!o.empty();){c=o.pop(),u=c.value,f=c.cost,m=s[u]||{};for(h in m)m.hasOwnProperty(h)&&(p=m[h],g=f+p,x=l[h],b=typeof l[h]>"u",(b||x>g)&&(l[h]=g,o.push(h,g),a[h]=u))}if(typeof i<"u"&&typeof l[i]>"u"){var j=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(j)}return a},extract_shortest_path_from_predecessor_list:function(s,r){for(var i=[],a=r;a;)i.push(a),s[a],a=s[a];return i.reverse(),i},find_path:function(s,r,i){var a=t.single_source_shortest_paths(s,r,i);return t.extract_shortest_path_from_predecessor_list(a,i)},PriorityQueue:{make:function(s){var r=t.PriorityQueue,i={},a;s=s||{};for(a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);return i.queue=[],i.sorter=s.sorter||r.default_sorter,i},default_sorter:function(s,r){return s.cost-r.cost},push:function(s,r){var i={value:s,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(YR);var EG=YR.exports;(function(e){const t=Ai,s=jG,r=yG,i=kG,a=CG,l=fr,o=rs,c=EG;function u(j){return unescape(encodeURIComponent(j)).length}function h(j,v,w){const y=[];let N;for(;(N=j.exec(w))!==null;)y.push({data:N[0],index:N.index,mode:v,length:N[0].length});return y}function f(j){const v=h(l.NUMERIC,t.NUMERIC,j),w=h(l.ALPHANUMERIC,t.ALPHANUMERIC,j);let y,N;return o.isKanjiModeEnabled()?(y=h(l.BYTE,t.BYTE,j),N=h(l.KANJI,t.KANJI,j)):(y=h(l.BYTE_KANJI,t.BYTE,j),N=[]),v.concat(w,y,N).sort(function(S,C){return S.index-C.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function m(j,v){switch(v){case t.NUMERIC:return s.getBitsLength(j);case t.ALPHANUMERIC:return r.getBitsLength(j);case t.KANJI:return a.getBitsLength(j);case t.BYTE:return i.getBitsLength(j)}}function p(j){return j.reduce(function(v,w){const y=v.length-1>=0?v[v.length-1]:null;return y&&y.mode===w.mode?(v[v.length-1].data+=w.data,v):(v.push(w),v)},[])}function g(j){const v=[];for(let w=0;w<j.length;w++){const y=j[w];switch(y.mode){case t.NUMERIC:v.push([y,{data:y.data,mode:t.ALPHANUMERIC,length:y.length},{data:y.data,mode:t.BYTE,length:y.length}]);break;case t.ALPHANUMERIC:v.push([y,{data:y.data,mode:t.BYTE,length:y.length}]);break;case t.KANJI:v.push([y,{data:y.data,mode:t.BYTE,length:u(y.data)}]);break;case t.BYTE:v.push([{data:y.data,mode:t.BYTE,length:u(y.data)}])}}return v}function x(j,v){const w={},y={start:{}};let N=["start"];for(let k=0;k<j.length;k++){const S=j[k],C=[];for(let $=0;$<S.length;$++){const R=S[$],I=""+k+$;C.push(I),w[I]={node:R,lastCount:0},y[I]={};for(let z=0;z<N.length;z++){const U=N[z];w[U]&&w[U].node.mode===R.mode?(y[U][I]=m(w[U].lastCount+R.length,R.mode)-m(w[U].lastCount,R.mode),w[U].lastCount+=R.length):(w[U]&&(w[U].lastCount=R.length),y[U][I]=m(R.length,R.mode)+4+t.getCharCountIndicator(R.mode,v))}}N=C}for(let k=0;k<N.length;k++)y[N[k]].end=0;return{map:y,table:w}}function b(j,v){let w;const y=t.getBestModeForData(j);if(w=t.from(v,y),w!==t.BYTE&&w.bit<y.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString(w)+`.
|
|
124
|
+
Suggested mode is: `+t.toString(y));switch(w===t.KANJI&&!o.isKanjiModeEnabled()&&(w=t.BYTE),w){case t.NUMERIC:return new s(j);case t.ALPHANUMERIC:return new r(j);case t.KANJI:return new a(j);case t.BYTE:return new i(j)}}e.fromArray=function(v){return v.reduce(function(w,y){return typeof y=="string"?w.push(b(y,null)):y.data&&w.push(b(y.data,y.mode)),w},[])},e.fromString=function(v,w){const y=f(v,o.isKanjiModeEnabled()),N=g(y),k=x(N,w),S=c.find_path(k.map,"start","end"),C=[];for(let $=1;$<S.length-1;$++)C.push(k.table[S[$]].node);return e.fromArray(p(C))},e.rawSplit=function(v){return e.fromArray(f(v,o.isKanjiModeEnabled()))}})(GR);const lf=rs,Dm=sf,AG=oG,TG=cG,RG=_R,$G=FR,cx=zR,ux=rf,IG=dG,Qd=WR,PG=KR,MG=Ai,Om=GR;function DG(e,t){const s=e.size,r=$G.getPositions(t);for(let i=0;i<r.length;i++){const a=r[i][0],l=r[i][1];for(let o=-1;o<=7;o++)if(!(a+o<=-1||s<=a+o))for(let c=-1;c<=7;c++)l+c<=-1||s<=l+c||(o>=0&&o<=6&&(c===0||c===6)||c>=0&&c<=6&&(o===0||o===6)||o>=2&&o<=4&&c>=2&&c<=4?e.set(a+o,l+c,!0,!0):e.set(a+o,l+c,!1,!0))}}function OG(e){const t=e.size;for(let s=8;s<t-8;s++){const r=s%2===0;e.set(s,6,r,!0),e.set(6,s,r,!0)}}function LG(e,t){const s=RG.getPositions(t);for(let r=0;r<s.length;r++){const i=s[r][0],a=s[r][1];for(let l=-2;l<=2;l++)for(let o=-2;o<=2;o++)l===-2||l===2||o===-2||o===2||l===0&&o===0?e.set(i+l,a+o,!0,!0):e.set(i+l,a+o,!1,!0)}}function _G(e,t){const s=e.size,r=Qd.getEncodedBits(t);let i,a,l;for(let o=0;o<18;o++)i=Math.floor(o/3),a=o%3+s-8-3,l=(r>>o&1)===1,e.set(i,a,l,!0),e.set(a,i,l,!0)}function Lm(e,t,s){const r=e.size,i=PG.getEncodedBits(t,s);let a,l;for(a=0;a<15;a++)l=(i>>a&1)===1,a<6?e.set(a,8,l,!0):a<8?e.set(a+1,8,l,!0):e.set(r-15+a,8,l,!0),a<8?e.set(8,r-a-1,l,!0):a<9?e.set(8,15-a-1+1,l,!0):e.set(8,15-a-1,l,!0);e.set(r-8,8,1,!0)}function FG(e,t){const s=e.size;let r=-1,i=s-1,a=7,l=0;for(let o=s-1;o>0;o-=2)for(o===6&&o--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,o-c)){let u=!1;l<t.length&&(u=(t[l]>>>a&1)===1),e.set(i,o-c,u),a--,a===-1&&(l++,a=7)}if(i+=r,i<0||s<=i){i-=r,r=-r;break}}}function zG(e,t,s){const r=new AG;s.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),MG.getCharCountIndicator(c.mode,e)),c.write(r)});const i=lf.getSymbolTotalCodewords(e),a=ux.getTotalCodewordsCount(e,t),l=(i-a)*8;for(r.getLengthInBits()+4<=l&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const o=(l-r.getLengthInBits())/8;for(let c=0;c<o;c++)r.put(c%2?17:236,8);return UG(r,e,t)}function UG(e,t,s){const r=lf.getSymbolTotalCodewords(t),i=ux.getTotalCodewordsCount(t,s),a=r-i,l=ux.getBlocksCount(t,s),o=r%l,c=l-o,u=Math.floor(r/l),h=Math.floor(a/l),f=h+1,m=u-h,p=new IG(m);let g=0;const x=new Array(l),b=new Array(l);let j=0;const v=new Uint8Array(e.buffer);for(let S=0;S<l;S++){const C=S<c?h:f;x[S]=v.slice(g,g+C),b[S]=p.encode(x[S]),g+=C,j=Math.max(j,C)}const w=new Uint8Array(r);let y=0,N,k;for(N=0;N<j;N++)for(k=0;k<l;k++)N<x[k].length&&(w[y++]=x[k][N]);for(N=0;N<m;N++)for(k=0;k<l;k++)w[y++]=b[k][N];return w}function BG(e,t,s,r){let i;if(Array.isArray(e))i=Om.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const h=Om.rawSplit(e);u=Qd.getBestVersionForData(h,s)}i=Om.fromString(e,u||40)}else throw new Error("Invalid data");const a=Qd.getBestVersionForData(i,s);if(!a)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=a;else if(t<a)throw new Error(`
|
|
125
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
126
|
+
Minimum version required to store current data is: `+a+`.
|
|
127
|
+
`);const l=zG(t,s,i),o=lf.getSymbolSize(t),c=new TG(o);return DG(c,t),OG(c),LG(c,t),Lm(c,s,0),t>=7&&_G(c,t),FG(c,l),isNaN(r)&&(r=cx.getBestMask(c,Lm.bind(null,c,s))),cx.applyMask(r,c),Lm(c,s,r),{modules:c,version:t,errorCorrectionLevel:s,maskPattern:r,segments:i}}OR.create=function(t,s){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Dm.M,i,a;return typeof s<"u"&&(r=Dm.from(s.errorCorrectionLevel,Dm.M),i=Qd.from(s.version),a=cx.from(s.maskPattern),s.toSJISFunc&&lf.setToSJISFunction(s.toSJISFunc)),BG(t,i,r,a)};var qR={},sw={};(function(e){function t(s){if(typeof s=="number"&&(s=s.toString()),typeof s!="string")throw new Error("Color should be defined as hex string");let r=s.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+s);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(a){return[a,a]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,a=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:a,scale:a?4:l,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const a=e.getScale(r,i);return Math.floor((r+i.margin*2)*a)},e.qrToImageData=function(r,i,a){const l=i.modules.size,o=i.modules.data,c=e.getScale(l,a),u=Math.floor((l+a.margin*2)*c),h=a.margin*c,f=[a.color.light,a.color.dark];for(let m=0;m<u;m++)for(let p=0;p<u;p++){let g=(m*u+p)*4,x=a.color.light;if(m>=h&&p>=h&&m<u-h&&p<u-h){const b=Math.floor((m-h)/c),j=Math.floor((p-h)/c);x=f[o[b*l+j]?1:0]}r[g++]=x.r,r[g++]=x.g,r[g++]=x.b,r[g]=x.a}}})(sw);(function(e){const t=sw;function s(i,a,l){i.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=l,a.width=l,a.style.height=l+"px",a.style.width=l+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,l,o){let c=o,u=l;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),l||(u=r()),c=t.getOptions(c);const h=t.getImageWidth(a.modules.size,c),f=u.getContext("2d"),m=f.createImageData(h,h);return t.qrToImageData(m.data,a,c),s(f,u,h),f.putImageData(m,0,0),u},e.renderToDataURL=function(a,l,o){let c=o;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),c||(c={});const u=e.render(a,l,c),h=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(h,f.quality)}})(qR);var QR={};const WG=sw;function x0(e,t){const s=e.a/255,r=t+'="'+e.hex+'"';return s<1?r+" "+t+'-opacity="'+s.toFixed(2).slice(1)+'"':r}function _m(e,t,s){let r=e+t;return typeof s<"u"&&(r+=" "+s),r}function HG(e,t,s){let r="",i=0,a=!1,l=0;for(let o=0;o<e.length;o++){const c=Math.floor(o%t),u=Math.floor(o/t);!c&&!a&&(a=!0),e[o]?(l++,o>0&&c>0&&e[o-1]||(r+=a?_m("M",c+s,.5+u+s):_m("m",i,0),i=0,a=!1),c+1<t&&e[o+1]||(r+=_m("h",l),l=0)):i++}return r}QR.render=function(t,s,r){const i=WG.getOptions(s),a=t.modules.size,l=t.modules.data,o=a+i.margin*2,c=i.color.light.a?"<path "+x0(i.color.light,"fill")+' d="M0 0h'+o+"v"+o+'H0z"/>':"",u="<path "+x0(i.color.dark,"stroke")+' d="'+HG(l,a,i.margin)+'"/>',h='viewBox="0 0 '+o+" "+o+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+h+' shape-rendering="crispEdges">'+c+u+`</svg>
|
|
128
|
+
`;return typeof r=="function"&&r(null,m),m};const KG=aG,dx=OR,XR=qR,VG=QR;function rw(e,t,s,r,i){const a=[].slice.call(arguments,1),l=a.length,o=typeof a[l-1]=="function";if(!o&&!KG())throw new Error("Callback required as last argument");if(o){if(l<2)throw new Error("Too few arguments provided");l===2?(i=s,s=t,t=r=void 0):l===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=s,s=t,t=void 0))}else{if(l<1)throw new Error("Too few arguments provided");return l===1?(s=t,t=r=void 0):l===2&&!t.getContext&&(r=s,s=t,t=void 0),new Promise(function(c,u){try{const h=dx.create(s,r);c(e(h,t,r))}catch(h){u(h)}})}try{const c=dx.create(s,r);i(null,e(c,t,r))}catch(c){i(c)}}$c.create=dx.create;$c.toCanvas=rw.bind(null,XR.render);$c.toDataURL=rw.bind(null,XR.renderToDataURL);$c.toString=rw.bind(null,function(e,t,s){return VG.render(e,s)});async function GG(e){const t=await $c.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const v0=10*6e4,YG=2e3;function iw(e,t){const[s,r]=d.useState(null),[i,a]=d.useState(null),[l,o]=d.useState(!1),[c,u]=d.useState(!1),h=d.useRef(e);h.current=e;const f=d.useRef(t);f.current=t;const m=d.useCallback(async()=>{const p=await E.telegramPairing();r(p),u(!1),o(!1),a(await GG(p.link).catch(()=>""))},[]);return d.useEffect(()=>{if(!s||l||c)return;let p=!1;const g=Math.min(Date.parse(s.expiresAt)||Date.now()+v0,Date.now()+v0),x=window.setInterval(()=>{if(Date.now()>=g){u(!0);return}h.current().then(b=>{var j;p||!b||(o(!0),(j=f.current)==null||j.call(f))}).catch(()=>{})},YG);return()=>{p=!0,window.clearInterval(x)}},[s,l,c]),{offer:s,square:i,paired:l,stale:c,ask:m}}function aw({offer:e,square:t,children:s}){return n.jsxs("div",{className:"meet-pair",children:[t?n.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,n.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),s]})}const JR=new Set(["approval","question"]),Zu={approval:{label:"Approvals",hint:"A run nobody is watching wants to do something gated."},question:{label:"Questions",hint:"A run asked you something and waits."},watcher:{label:"Watchers",hint:"A watcher or a source found something."},reminder:{label:"Reminders",hint:"A reminder an agent promised you came due."},failure:{label:"Failures",hint:"Background jobs died and will not be retried."},recap:{label:"Reports",hint:"Mission reports, the weekly recap, answers to actions you tapped."},plugin:{label:"Plugins",hint:"A plugin that may send you messages has something to say."},agent:{label:"Messages from your agents",hint:"An agent told you something itself."}},qG=new Set(["agent"]),QG={maxUrgency:"now",muted:[]};function XG(e,t){var i;const s=Zu[e.kind].label.toLowerCase();return e.kind!=="agent"||!e.agentId?s:`from ${((i=t.find(a=>a.id===e.agentId))==null?void 0:i.name)??e.agentId}`}function JG({timezone:e}){var j,v,w;const t=ce(()=>E.notificationSettings(),[]),s=ce(()=>E.agents(),[]),r=ce(()=>E.notifications(20),[],3e4),i=d.useRef(!1);d.useEffect(()=>{var y,N;i.current||!r.data||window.location.hash!==tE||(i.current=!0,(N=(y=document.getElementById("notifications-recent"))==null?void 0:y.scrollIntoView)==null||N.call(y,{block:"start"}))},[r.data]);const[a,l]=d.useState(null),[o,c]=d.useState(!1),[u,h]=d.useState(!1),[f,m]=d.useState(null),p=((j=t.data)==null?void 0:j.channels)??[],g=a??((v=t.data)==null?void 0:v.settings),x=y=>{g&&(h(!1),l({...g,...y}))},b=()=>{g&&(c(!0),h(!1),m(null),E.saveNotificationSettings(g).then(()=>{h(!0),l(null),t.reload()}).catch(y=>m(y instanceof me?y.message:String(y))).finally(()=>c(!1)))};return n.jsxs(re,{gap:"lg",children:[n.jsx(oe,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:n.jsx(T,{variant:"accent",disabled:o||!g,onClick:b,children:"Save"}),children:n.jsxs(re,{divided:!0,children:[n.jsx(ae,{message:t.error??f}),n.jsx(oe,{title:"Where buddi reaches you",children:g?p.length===0?n.jsxs("p",{className:"ui-card-meta",children:["No channel yet, so everything waits for you here. ",n.jsx("a",{href:De("telegram"),children:"Set up Telegram"})," and buddi can reach you on your phone."]}):n.jsxs(re,{gap:"sm",children:[p.map(y=>{var N;return n.jsx(iY,{channel:y,checked:(g.defaultChannel??((N=p[0])==null?void 0:N.kind))===y.kind,onPick:()=>x({defaultChannel:y.kind})},y.kind)}),p.some(y=>y.kind==="telegram")?null:n.jsxs("p",{className:"ui-card-meta",children:["Telegram is not set up. ",n.jsx("a",{href:De("telegram"),children:"Set up Telegram"})]})]}):n.jsx(xe,{children:"Loading…"})}),n.jsx(oe,{title:"By kind",children:g?n.jsxs(re,{gap:"sm",children:[aO.filter(y=>!qG.has(y)).map(y=>n.jsxs("div",{className:"pref-row nt-kind",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:Zu[y].label}),n.jsx("span",{className:"ui-field-hint",children:Zu[y].hint})]}),n.jsxs("select",{"aria-label":Zu[y].label,value:aY(g,y,p),onChange:N=>{const k={...g.perKind};N.target.value==="default"?delete k[y]:k[y]=N.target.value,x({perKind:k})},children:[n.jsx("option",{value:"default",children:"Default"}),p.map(N=>n.jsx("option",{value:N.kind,children:N.label},N.kind)),JR.has(y)?null:n.jsx("option",{value:"off",children:"Off"})]})]},y)),n.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),n.jsx(oe,{title:"Messages from your agents",children:g?n.jsx(ZG,{settings:g,agents:((w=s.data)==null?void 0:w.agents)??[],onChange:x}):null}),n.jsx(oe,{title:"Focus schedules",children:g?n.jsxs(re,{gap:"sm",children:[n.jsx(cY,{schedules:g.schedules,onChange:y=>x({schedules:y})}),n.jsxs("p",{className:"ui-field-hint",children:["Do not disturb holds everything but approvals and questions; Urgent only also lets watchers and failures through. What waited comes in one message when the focus ends. Switch a focus by hand from your initial at the foot of the rail, or /focus on Telegram. Times are on your clock (",e,")."]}),n.jsx("div",{className:"nt-times",children:n.jsx(ie,{label:"End of the day",children:n.jsx("input",{type:"time",value:g.endOfDay,onChange:y=>x({endOfDay:y.target.value})})})}),n.jsx("p",{className:"ui-field-hint",children:"At the end of the day, what could wait goes out as one message."})]}):null}),u?n.jsx(V,{tone:"good",role:"status",children:"Saved."}):null]})}),n.jsx(eY,{}),n.jsx("div",{id:"notifications-recent",className:"notifications-recent",children:n.jsxs(oe,{title:"The last twenty",panel:!0,flush:!0,children:[n.jsx(ae,{message:r.error}),r.data?r.data.notifications.length===0?n.jsx(xe,{children:"Nothing yet. What buddi tells you will be listed here."}):n.jsx(dt,{children:r.data.notifications.map(y=>{var N;return n.jsx(it,{title:Qo(y),sub:`${et(y.createdAt,e)} · ${XG(y,((N=s.data)==null?void 0:N.agents)??[])} · ${lY(y,p)}`,side:n.jsx(oY,{row:y})},y.id)})}):n.jsx(xe,{children:"Loading…"})]})})]})}function ZG({settings:e,agents:t,onChange:s}){const r=e.perKind.agent!=="off",i=e.agents??QG,a=o=>{const c={...e.perKind};o?delete c.agent:c.agent="off",s({perKind:c})},l=(o,c)=>s({agents:{...i,muted:c?[...new Set([...i.muted,o])]:i.muted.filter(u=>u!==o)}});return n.jsxs(re,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:o=>a(o.target.checked)}),n.jsx("span",{children:"Agents may message you"})]}),n.jsxs("div",{className:"pref-row nt-kind",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:"Highest urgency"}),n.jsx("span",{className:"ui-field-hint",children:"End of the day holds every message for the end-of-day message."})]}),n.jsxs("select",{"aria-label":"Highest urgency for agents",value:i.maxUrgency,disabled:!r,onChange:o=>s({agents:{...i,maxUrgency:o.target.value==="today"?"today":"now"}}),children:[n.jsx("option",{value:"now",children:"Now"}),n.jsx("option",{value:"today",children:"End of the day"})]})]}),t.length>0?n.jsx("div",{className:"ui-stack","data-gap":"sm",role:"group","aria-label":"Muted agents",children:t.map(o=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:i.muted.includes(o.id),disabled:!r,onChange:c=>l(o.id,c.target.checked),"aria-label":`Mute @${o.handle}`}),n.jsxs("span",{children:["Mute ",o.name," (@",o.handle,")"]})]},o.id))}):null,n.jsx("p",{className:"ui-field-hint",children:'An agent given the owner.notify tool can message you itself, signed "@agent: title" on Telegram; here the agent is named beside it. Each agent may send 6 urgent messages an hour and 20 a day. Off keeps them in the list below and never sends them.'})]})}function eY(){var u;const e=ce(()=>E.tipsSettings(),[]),[t,s]=d.useState(!1),[r,i]=d.useState(null),[a,l]=d.useState(null),o=a??((u=e.data)==null?void 0:u.enabled)??!0,c=h=>{s(!0),i(null),l(h),E.saveTipsSettings(h).then(f=>l(f.enabled)).catch(f=>{l(!h),i(f instanceof me?f.message:String(f))}).finally(()=>s(!1))};return n.jsx(oe,{title:"Tips",panel:!0,children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:e.error??r}),n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:o,disabled:t||!e.data,onChange:h=>c(h.target.checked)}),n.jsx("span",{children:"Tips on Home"})]}),n.jsx("p",{className:"ui-field-hint",children:"When something in buddi has gone unused, Home may say so in one sentence, at most once a day."})]})})}function tY({timezone:e}){return n.jsx(nY,{timezone:e,onChange:()=>{}})}function nY({timezone:e,onChange:t}){var C,$;const s=ce(()=>E.telegramBot(),[]),r=ce(()=>E.telegramDevices(),[]),[i,a]=d.useState(!1),[l,o]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState(null),[m,p]=d.useState(null),g=d.useRef(new Set),x=iw(()=>E.telegramDevices().then(R=>R.devices.some(I=>!g.current.has(I.id))),()=>{r.reload(),t()}),b=((C=s.data)==null?void 0:C.configured)??!1,j=!b||i,v=()=>{var I;if(l.trim()===""||c)return;u(!0),f(null);const R=i&&(((I=s.data)==null?void 0:I.running)??!1);E.saveTelegramToken(l.trim()).then(z=>{o(""),a(!1),f(z.restartNeeded?{ok:!1,text:z.note??"Saved. It will be ready the next time buddi starts."}:R?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),s.reload(),t()}).catch(z=>f({ok:!1,text:z instanceof me?z.message:String(z)})).finally(()=>u(!1))},w=()=>{var R;p(null),g.current=new Set((((R=r.data)==null?void 0:R.devices)??[]).map(I=>I.id)),x.ask().catch(I=>p(I instanceof me?I.message:String(I)))},{offer:y,square:N,paired:k,stale:S}=x;return n.jsx(oe,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{title:"The bot",foot:j?n.jsxs(n.Fragment,{children:[i?n.jsx(T,{variant:"ghost",onClick:()=>{a(!1),o("")},children:"Cancel"}):null,n.jsx(T,{variant:"accent",disabled:c||l.trim()==="",onClick:v,children:"Save token"})]}):void 0,children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:s.error}),!s.data&&!s.error?n.jsx(xe,{children:"Loading…"}):b&&!i?n.jsxs("div",{className:"nt-channel",children:[n.jsx("span",{className:"pref-label",children:($=s.data)!=null&&$.username?`Bot: @${s.data.username}`:"A bot token is saved."}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{a(!0),f(null)},children:"Replace token"})]}):null,j?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),n.jsx(ie,{label:"Bot token",grow:!0,children:n.jsx("input",{type:"password",value:l,autoComplete:"off",spellCheck:!1,onChange:R=>o(R.target.value),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),v())}})})]}):null,h?n.jsx(V,{tone:h.ok?"good":"warning",role:"status",children:h.text}):null]})}),n.jsxs(oe,{title:"Your devices",children:[n.jsx(ae,{message:r.error}),r.data?r.data.devices.length===0?n.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):n.jsx(dt,{children:r.data.devices.map(R=>n.jsx(it,{title:R.name??`Telegram user ${R.userId}`,sub:`Paired ${et(R.pairedAt,e)} · ${R.lastSeenAt?`last spoke ${Oe(R.lastSeenAt)}`:"has not spoken yet"}`,side:n.jsx(sY,{id:R.id,onGone:()=>{r.reload(),t()}})},R.id))}):r.error?null:n.jsx(xe,{children:"Loading…"})]}),n.jsx(oe,{title:"Pair a device",foot:b&&(!y||k)?n.jsx(T,{variant:y?void 0:"accent",onClick:w,children:"Pair a phone"}):b&&S?n.jsx(T,{variant:"accent",onClick:w,children:"New code"}):void 0,children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:m}),b?k?n.jsx(V,{tone:"good",role:"status",children:"Paired."}):y&&S?n.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):y?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),n.jsx(aw,{offer:y,square:N,children:n.jsx(rY,{text:y.link})}),n.jsxs("p",{className:"ui-field-hint",children:["The code works until ",et(y.expiresAt,e),"."]})]}):n.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):n.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function sY({id:e,onGone:t}){const[s,r]=d.useState(!1),[i,a]=d.useState(!1),[l,o]=d.useState(null);if(!s)return n.jsx(T,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{a(!0),o(null),E.unpairTelegramDevice(e).then(t).catch(u=>o(u instanceof me?u.message:String(u))).finally(()=>a(!1))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx("span",{className:"ui-field-hint",role:l?"alert":void 0,children:l??"It will no longer reach your agents."}),n.jsx(T,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),n.jsx(T,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function rY({text:e}){const[t,s]=d.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>s("Copied."),()=>s("Select the link to copy it."))};return n.jsxs("span",{className:"nt-channel",children:[n.jsx(T,{size:"sm",onClick:r,children:"Copy"}),t?n.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function iY({channel:e,checked:t,onPick:s}){const[r,i]=d.useState(!1),[a,l]=d.useState(null),o=()=>{i(!0),l(null),E.testChannel(e.kind).then(()=>l({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>l({ok:!1,text:c instanceof me?c.message:String(c)})).finally(()=>i(!1))};return n.jsxs("div",{className:"nt-channel",children:[n.jsxs("label",{children:[n.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:s}),n.jsxs("span",{className:"nt-channel-text",children:[n.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),n.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),a?n.jsx("span",{className:"nt-channel-sent","data-tone":a.ok?void 0:"critical",role:"status",children:a.text}):null]})]}),n.jsx(T,{size:"sm",disabled:r,onClick:o,children:"Send a test"})]})}function aY(e,t,s){const r=e.perKind[t];return r==="off"?JR.has(t)?"default":"off":r&&s.some(i=>i.kind===r)?r:"default"}function lY(e,t){var s;return e.channel&&e.channel!=="dashboard"?((s=t.find(r=>r.kind===e.channel))==null?void 0:s.label)??e.channel:"dashboard"}function oY({row:e}){return e.state==="failed"?n.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?n.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?n.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?n.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?n.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?n.jsx("span",{className:"nt-state",children:"Sent"}):n.jsx("span",{className:"nt-state",children:"Not seen"})}const j0={mon:"Mon",tue:"Tue",wed:"Wed",thu:"Thu",fri:"Fri",sat:"Sat",sun:"Sun"},w0={mode:"do-not-disturb",days:[...Jp],from:"22:00",to:"07:00"};function cY({schedules:e,onChange:t}){const s=(r,i)=>t(e.map((a,l)=>l===r?{...a,...i}:a));return n.jsxs(re,{gap:"sm",children:[e.length===0?n.jsx("p",{className:"ui-card-meta",children:"No schedule: a focus is on only when you switch one on."}):null,e.map((r,i)=>{const a=i+1;return n.jsxs("div",{className:"nt-schedule",role:"group","aria-label":`Schedule ${a}`,children:[n.jsxs("select",{"aria-label":`Schedule ${a} mode`,value:r.mode,onChange:l=>s(i,{mode:l.target.value}),children:[n.jsx("option",{value:"do-not-disturb",children:"Do not disturb"}),n.jsx("option",{value:"urgent-only",children:"Urgent only"})]}),n.jsx("span",{className:"nt-days",children:Jp.map(l=>{const o=r.days.includes(l);return n.jsx("button",{type:"button",className:"nt-day","aria-pressed":o,"aria-label":`Schedule ${a} ${j0[l]}`,onClick:()=>s(i,{days:o?r.days.filter(c=>c!==l):Jp.filter(c=>c===l||r.days.includes(c))}),children:j0[l]},l)})}),n.jsx(ie,{label:"From",children:n.jsx("input",{type:"time","aria-label":`Schedule ${a} from`,value:r.from,onChange:l=>s(i,{from:l.target.value})})}),n.jsx(ie,{label:"To",children:n.jsx("input",{type:"time","aria-label":`Schedule ${a} to`,value:r.to,onChange:l=>s(i,{to:l.target.value})})}),n.jsx(T,{size:"sm",variant:"ghost","aria-label":`Remove schedule ${a}`,onClick:()=>t(e.filter((l,o)=>o!==i)),children:"Remove"})]},i)}),n.jsx("div",{className:"nt-schedule-add",children:n.jsx(T,{size:"sm",onClick:()=>t([...e,{...w0,days:[...w0.days]}]),children:"Add a schedule"})})]})}const uY={you:"person",appearance:"sun",notifications:"bell",telegram:"send",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",connections:"globe",lock:"lock",api:"terminal",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function dY(e){const t=hF.map(r=>({id:r.id,route:De(r.id),label:r.label,icon:uY[r.id],group:r.group})),s=[...e].sort((r,i)=>r.title.localeCompare(i.title,void 0,{sensitivity:"base"})||r.plugin.localeCompare(i.plugin)||r.id.localeCompare(i.id)).map(r=>({id:X1(r.plugin,r.id),route:gi(r.plugin,r.id),label:r.title,icon:WA(r.icon),group:"plugins"}));return[...t,...s]}function ZR(e){return dF.map(t=>({id:t.id,label:t.label,entries:e.filter(s=>s.group===t.id)})).filter(t=>t.entries.length>0)}function e$(e,t,s){return t?`${e}, ${t} open`:s?`${e}, ${s}`:void 0}function hY({entries:e,active:t,counts:s={},dots:r={},navigate:i}){var u;const a=d.useRef(null),l=ZR(e),o=e.some(h=>h.id===t)?t:(u=e[0])==null?void 0:u.id,c=h=>{var g;const f=[...((g=a.current)==null?void 0:g.querySelectorAll("a.settings-nav-link"))??[]],m=f.indexOf(document.activeElement);if(m===-1)return;const p=x=>{var b;h.preventDefault(),(b=f[Math.max(0,Math.min(f.length-1,x))])==null||b.focus()};if(h.key==="ArrowDown")p(m+1);else if(h.key==="ArrowUp")p(m-1);else if(h.key==="Home")p(0);else if(h.key==="End")p(f.length-1);else if(h.key==="Enter"||h.key===" "){h.preventDefault();const x=f[m].getAttribute("href");x&&i(x)}};return n.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:a,onKeyDown:c,children:l.map(h=>n.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${h.id}`,children:[n.jsx("div",{className:"settings-nav-label",id:`settings-nav-${h.id}`,children:h.label}),h.entries.map(f=>{const m=f.id===t,p=s[f.id],g=r[f.id];return n.jsxs("a",{className:"settings-nav-link",href:f.route,"data-active":m?"true":void 0,"aria-current":m?"page":void 0,"aria-label":e$(f.label,p,g),tabIndex:f.id===o?0:-1,onClick:x=>{x.preventDefault(),i(f.route)},children:[n.jsx(ue,{name:f.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:f.label}),p?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:p>99?"99+":p}):g?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","data-testid":"settings-nav-dot","aria-hidden":"true"}):null]},f.id)})]},h.id))})}function fY({entries:e,active:t,counts:s={},dots:r={},navigate:i}){const a=ZR(e),l=e.find(o=>o.id===t)??e[0];return n.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:n.jsxs(bc,{modal:!1,children:[n.jsx(kc,{asChild:!0,children:n.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(l==null?void 0:l.label)??""}`,children:[l?n.jsx(ue,{name:l.icon,className:"settings-nav-icon"}):null,n.jsx("span",{className:"settings-nav-text",children:l==null?void 0:l.label}),n.jsx(ue,{name:"chevron-down",className:"settings-menu-chevron"})]})}),n.jsx(Nl,{children:n.jsx(Nc,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:n.jsx(w_,{value:t,onValueChange:o=>{const c=e.find(u=>u.id===o);c&&i(c.route)},children:a.map((o,c)=>n.jsxs(G1,{children:[c>0?n.jsx(Nr,{className:"ui-menu-sep"}):null,n.jsx(ta,{className:"ui-menu-label",children:o.label}),o.entries.map(u=>{const h=s[u.id],f=r[u.id];return n.jsxs(y_,{value:u.id,className:"ui-menu-item settings-menu-item","data-active":u.id===t?"true":void 0,"aria-label":e$(u.label,h,f),children:[n.jsxs("span",{className:"settings-menu-entry",children:[n.jsx(ue,{name:u.icon,className:"settings-nav-icon"}),n.jsx("span",{className:"settings-nav-text",children:u.label})]}),h?n.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):f?n.jsx("span",{className:"ui-badge settings-nav-dot","data-kind":"dot","aria-hidden":"true"}):null]},u.id)})]},o.id))})})})]})})}function mY({hash:e,timezone:t,navigate:s,agents:r,pluginPages:i}){var v,w,y;const a=fF(e),l=BE(i!==void 0),o=i??l,c=eF(e),u=c?o.find(c.plugin,c.page):void 0,h=Ps(nj),f=dY(o.settings),p={proposals:((w=(v=ce(()=>Promise.resolve().then(()=>E.proposals()),[],3e4).data)==null?void 0:v.open)==null?void 0:w.length)??0},g=ce(()=>E.version(),[]),x=ce(()=>Promise.resolve().then(()=>E.connectionSignals()),[],6e4),b={};g.data&&!g.data.checkout&&g.data.updateAvailable&&(b.system="a newer buddi is ready"),(((y=x.data)==null?void 0:y.signals)??[]).length>0&&(b.connections=aT);const j={entries:f,active:a,counts:p,dots:b,navigate:N=>s(N)};return n.jsxs("div",{className:"settings",children:[h?null:n.jsx(hY,{...j}),n.jsx("div",{className:"settings-body",children:n.jsxs("div",{className:"ui-page",children:[a==="secrets"?n.jsx(nc,{before:n.jsx(gg,{inline:!0,items:[{label:"Settings",href:en,onClick:()=>s(en)}]}),title:"Keys and secrets",lede:gR,actions:n.jsx(Tt,{variant:"accent",size:"sm",href:Sb,onClick:N=>{N.preventDefault(),s(Sb)},children:"Add a secret"})}):a==="plugins"||a==="connections"?n.jsx(nc,{before:n.jsx(gg,{inline:!0,items:[{label:"Settings",href:en,onClick:()=>s(en)}]}),title:a==="plugins"?"Plugins":"Connections",lede:a==="plugins"?S7:PT}):n.jsxs("header",{className:"ui-page-head",children:[n.jsx("h2",{className:"ui-page-title",children:"Settings"}),n.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),h?n.jsx(fY,{...j}):null,u?n.jsx(j8,{page:u,params:Q1(e),navigate:s,timezone:t,siblings:o.all.filter(N=>N.plugin===u.plugin)}):null,a==="you"?n.jsx(s7,{embedded:!0}):null,a==="appearance"?n.jsx(pY,{railPages:o.rail}):null,a==="notifications"?n.jsx(JG,{timezone:t}):null,a==="telegram"?n.jsx(tY,{timezone:t}):null,a==="memory"?n.jsx(jT,{embedded:!0,agents:r,timezone:t}):null,a==="proposals"?n.jsx(x7,{embedded:!0,plugin:oF(e)}):null,a==="accounts"?n.jsx(VV,{embedded:!0,account:tF(e)}):null,a==="computer"?n.jsx(O6,{embedded:!0,timezone:t}):null,a==="secrets"?n.jsx(I9,{embedded:!0,timezone:t,secret:sF(e),adding:rF(e),navigate:s}):null,a==="connections"?n.jsx(rK,{embedded:!0,timezone:t,connection:nF(e)}):null,a==="lock"?n.jsx(J9,{navigate:s}):null,a==="api"?n.jsx(n7,{timezone:t}):null,a==="watchers"?n.jsx(B9,{timezone:t,embedded:!0}):null,a==="backup"?n.jsx(FV,{}):null,a==="plugins"?n.jsx(P7,{railPages:o.rail,settingsPages:o.settings,navigate:s,hash:e}):null,a==="system"?n.jsx(vY,{timezone:t}):null]})})]})}function pY({railPages:e}){const[t,s]=fT();return n.jsx(oe,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:n.jsxs(re,{divided:!0,gap:"lg",children:[n.jsx(Fm,{label:"Theme",hint:"System follows your Mac.",children:n.jsx(rn,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:t.theme,onChange:r=>s({theme:r})})}),n.jsx(Fm,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:n.jsx(rn,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:t.ground,onChange:r=>s({ground:r})})}),n.jsx(Fm,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:n.jsx(rn,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:t.width,onChange:r=>s({width:r})})}),n.jsx(xY,{pages:e}),n.jsx(gY,{})]})})}function gY(){var a;const e=ce(()=>E.overview(),[]),[t,s]=d.useState(null),r=((a=e.data)==null?void 0:a.glances)??[];if(r.length===0)return null;const i=(l,o)=>{s(l),E.setGlanceHidden(l,!o).then(()=>e.reload()).finally(()=>s(null))};return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:"Home glances"}),n.jsx("span",{className:"ui-field-hint",children:"The lines beside the date on Home, at most three. Kept for every browser."})]}),n.jsx(re,{gap:"sm",children:r.map(l=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:!l.hidden,disabled:t===l.id,onChange:o=>i(l.id,o.target.checked)}),n.jsx("span",{children:l.title})]},l.id))})]})}function xY({pages:e}){const t=lT(),[s,r]=d.useState(null);if(e.length===0)return null;const i=(a,l)=>{r(null),XW(a,!l).catch(o=>r(o instanceof Error?o.message:String(o)))};return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:"In the rail"}),n.jsx("span",{className:"ui-field-hint",children:"The plugin pages beside Home and Chat. One you turn off still opens from Settings → Plugins. Kept for every browser."})]}),n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:s}),e.map(a=>n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:!t.has(uc(a)),onChange:l=>i(a,l.target.checked)}),n.jsx("span",{children:a.title})]},uc(a)))]})]})}function Fm({label:e,hint:t,children:s}){return n.jsxs("div",{className:"pref-row ui-section",children:[n.jsxs("div",{className:"pref-text",children:[n.jsx("span",{className:"pref-label",children:e}),n.jsx("span",{className:"ui-field-hint",children:t})]}),s]})}function vY({timezone:e}){const t=ce(()=>E.overview(),[],15e3),s=ce(()=>E.session(),[]),r=ce(()=>E.providerAccounts(),[]),i=t.data;return n.jsxs(re,{gap:"lg",children:[n.jsx(ae,{message:t.error}),n.jsx($Y,{}),i?n.jsx(oe,{title:"The queue",panel:!0,actions:n.jsx(T,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{E.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:n.jsxs("p",{className:"ui-card-meta",children:[i.paused?"Paused. Nothing is being claimed until you resume.":"Running. Jobs are claimed as they come due."," ",i.paused?n.jsx(ve,{tone:"warning",children:"paused"}):n.jsx(ve,{tone:"good",children:"running"})]})}):null,n.jsxs(oe,{title:"This host",panel:!0,children:[n.jsx(Wt,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?et(i.now,e):"…"},{label:"Bound to",value:s.data?`${s.data.host}:${s.data.port}`:"…"},{label:"Credential vault",value:r.data?bY(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?n.jsx(V,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),n.jsx(yY,{}),n.jsx(T8,{}),n.jsx(jY,{}),n.jsx(oe,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?n.jsx(xe,{children:"No sources are installed."}):n.jsx(Wt,{items:i.mail.map(a=>({key:a.sourceId,label:n.jsx("span",{className:"mono",children:a.sourceId}),value:a.lastError?n.jsx("span",{className:"critical",children:a.lastError}):n.jsxs("span",{children:["polled ",Oe(a.lastRunAt)]})}))}):n.jsx(xe,{children:"Loading…"})})]})}function jY(){var p;const e=ce(()=>E.tailscale(),[]),[t,s]=d.useState(null),[r,i]=d.useState(!1),[a,l]=d.useState(null),[o,c]=d.useState(!1),u=e.data,h=t??((u==null?void 0:u.login)||((p=u==null?void 0:u.self)==null?void 0:p.login)||""),f=(u==null?void 0:u.proxied)===!0,m=g=>{i(!0),l(null),c(!1),E.setTailscale({enabled:g,login:h.trim()}).then(()=>{c(!0)}).catch(x=>l(x instanceof me?x.message:String(x))).finally(()=>{i(!1),e.reload()})};return n.jsx(oe,{title:"Sign in through Tailscale",panel:!0,foot:n.jsx(T,{variant:"accent",disabled:r||!u||f,onClick:()=>m((u==null?void 0:u.enabled)??!1),children:"Save"}),children:n.jsx(re,{divided:!0,children:n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:e.error??a}),n.jsx("p",{className:"ui-card-meta",children:u?u.available&&u.self?`Tailscale is running on this machine as ${u.self.login}.`:u.available?"Tailscale is running on this machine.":"Tailscale is not running here.":"…"}),f?n.jsxs(n.Fragment,{children:[n.jsx(V,{tone:"warning",children:"Change this from the computer buddi runs on."}),n.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${h}`:"Off"})]}):null,n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:g=>m(g.target.checked)}),n.jsx("span",{children:"Let this Tailscale login sign in"})]}),n.jsx(ie,{label:"Tailscale login",children:n.jsx("input",{type:"text",value:h,placeholder:"you@example.com",disabled:r||!u||f,onChange:g=>s(g.target.value)})}),n.jsx("p",{className:"ui-card-meta",children:"Anyone signed in to Tailscale as this login, on any device in your tailnet, is signed in to buddi. The proxy must run on this machine:"}),n.jsxs("div",{className:"tailscale-command",children:[n.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),n.jsx(T,{size:"sm",disabled:r||!u,onClick:()=>{wY((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),n.jsx("p",{className:"ui-card-meta",children:"This gives your tailnet the trust this machine already has: buddi cannot tell the Tailscale proxy from another program running here, and any program that can reach the dashboard on this machine can already read buddi’s files."}),o?n.jsx(V,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function wY(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function yY(){var u;const e=ce(()=>E.service(),[],1e4),[t,s]=d.useState(null),[r,i]=d.useState(!1),[a,l]=d.useState(null),o=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!o)return null;const c=h=>{i(!0),l(null),zh({kind:h},()=>E.serviceAction(h)).then(()=>{s(null)}).catch(f=>{l(f.message),e.reload()}).finally(()=>{i(!1)})};return n.jsx(oe,{title:"Service",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsx(Wt,{items:[{label:"Database",value:n.jsx(y0,{state:o.database,pid:o.databasePid})},{label:"Gateway",value:n.jsx(y0,{state:o.gateway,pid:o.gatewayPid})},{label:"Supervisor",value:n.jsxs("span",{className:"mono",children:["pid ",o.supervisorPid]})}]})}),n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:a}),t?n.jsx(V,{tone:"warning",role:"alert",children:t==="stop"?"Stopping the gateway closes this dashboard. The database keeps running; run buddi in a terminal to bring the dashboard back.":"Restarting the gateway takes a few seconds. This page waits for it and comes back by itself."}):n.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),n.jsx(le,{align:"end",children:t?n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",disabled:r,onClick:()=>{s(null),l(null)},children:"Cancel"}),n.jsx(T,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:()=>{s("stop")},children:"Stop gateway"}),n.jsx(T,{variant:"accent",onClick:()=>{s("restart")},children:"Restart gateway"})]})})]})})]})})}function y0({state:e,pid:t}){return n.jsxs("span",{children:[n.jsx(ve,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?n.jsx("span",{className:"ui-card-meta",children:"no process"}):n.jsxs("span",{className:"mono",children:["pid ",t]})]})}function bY(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const kY=2e3,Xd={starting:"Getting started.",backup:"Taking a backup first, so there is a way back.",stopping:"Stopping the gateway. The database stays up.",installing:"Installing the new version.",verifying:"Checking that the new version can start its database.","rolling-back":"The new version could not start its database. Putting the previous one back.",restarting:"Restarting buddi on the new version.",migrating:"Bringing the database up to date.",done:"Done.",failed:"That did not work."},NY=new Set(["done","failed","rolled-back"]),SY="The check asks the npm registry for the newest version and sends nothing else.",CY="This takes a backup, installs the new version and restarts buddi. This page waits for it and comes back by itself.",EY="A checkout upgrades with git pull, then buddi upgrade in a terminal.",AY=15*6e4;function TY(e){const t=e.step==="starting"?"while starting":`at ${e.step??"an unknown step"}`;return`The upgrade to ${e.to} failed ${t}: ${e.error??"no reason given"}. The backup taken first is ${e.backup??"not available"}. Run buddi doctor in a terminal; it prints the way back.`}function b0(e,t=Date.now()){const s=e[e.length-1];if((s==null?void 0:s.outcome)!=="failed")return null;const r=Date.parse(s.finishedAt??s.startedAt);return Number.isFinite(r)&&t-r<AY?s:null}function RY(e,t){const[s,r]=d.useState(void 0),[i,a]=d.useState(null),l=d.useRef(t);return l.current=t,d.useEffect(()=>{if(!e){r(void 0);return}let o=!1,c=!1;const u=()=>{o||c||E.upgradeJob(e).then(f=>{var m;o||(r(f),a(null),lE({step:Xd[f.phase]??f.detail??f.phase}),(NY.has(f.phase)||f.finishedAt)&&(o=!0,f.phase==="failed"&&(al(),(m=l.current)==null||m.call(l,f))))}).catch(f=>{o||(f instanceof me&&f.status!==0&&f.status<500?(o=!0,al(),a(f.message)):c=!0)})};u();const h=window.setInterval(u,kY);return()=>{o=!0,window.clearInterval(h)}},[e]),{job:s,error:i}}function $Y(){const e=ce(()=>E.version(),[]),[t,s]=d.useState(null),[r,i]=d.useState(!1),[a,l]=d.useState(!1),[o,c]=d.useState(null),[u,h]=d.useState(null),f=d.useCallback(j=>{s(null),h(j)},[]),m=RY(t,f),p=e.data,g=()=>{l(!0),c(null),E.checkVersion().catch(j=>c(j instanceof me?j.message:String(j))).finally(()=>{l(!1),e.reload()})},x=j=>{l(!0),c(null),E.setVersionCheck(j).catch(v=>c(v instanceof me?v.message:String(v))).finally(()=>{l(!1),e.reload()})},b=()=>{l(!0),c(null),h(null),zh({kind:"upgrade",line:p!=null&&p.latest?`Upgrading to ${p.latest}…`:"Upgrading…",step:Xd.starting,patienceMs:aE},()=>E.startUpgrade(p==null?void 0:p.latest)).then(j=>{var v;i(!1),s(((v=j==null?void 0:j.job)==null?void 0:v.id)??null)}).catch(j=>c(j instanceof me?j.message:String(j))).finally(()=>l(!1))};return p!=null&&p.checkout?n.jsx(oe,{title:"Version",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsx(Wt,{items:[{label:"Running",value:n.jsx("span",{className:"mono",children:p.current})}]})}),n.jsx(oe,{children:n.jsx("p",{className:"ui-card-meta",children:EY})})]})}):n.jsx(oe,{title:"Version",panel:!0,children:n.jsxs(re,{divided:!0,children:[n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(ae,{message:e.error??o}),n.jsx(Wt,{items:[{label:"Running",value:p?n.jsx("span",{className:"mono",children:p.current}):"…"},{label:"Newest",value:p?p.updateAvailable&&p.latest?n.jsxs("span",{children:["A newer buddi is available: ",n.jsx("span",{className:"mono",children:p.latest})]}):p.checkedAt?n.jsxs("span",{children:["This is the latest, as of ",Oe(p.checkedAt),"."]}):n.jsx("span",{children:"Not checked yet."}):"…"}]}),p!=null&&p.error?n.jsxs(V,{tone:"warning",children:["The last check did not get an answer: ",p.error]}):null,n.jsx(le,{align:"end",children:n.jsx(T,{disabled:a,onClick:g,children:"Check now"})})]})}),n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsxs("label",{className:"backup-check",children:[n.jsx("input",{type:"checkbox",checked:(p==null?void 0:p.checkEnabled)??!1,disabled:a||!p,onChange:j=>x(j.target.checked)}),n.jsx("span",{children:"Check once a day"})]}),n.jsx("p",{className:"ui-card-meta",children:SY})]})}),p!=null&&p.updateAvailable&&p.latest&&p.latestNotes?n.jsx(oe,{title:`What changes in ${p.latest}`,children:n.jsx(Lr,{text:p.latestNotes})}):null,n.jsx(oe,{children:n.jsxs(re,{gap:"sm",children:[n.jsx(IY,{...m,job:m.job??u??void 0}),!m.job&&!u&&!m.error&&p&&b0(p.history)?n.jsx(V,{tone:"critical",role:"alert",children:TY(b0(p.history))}):null,r?n.jsx(V,{tone:"warning",role:"alert",children:CY}):null,n.jsx(le,{align:"end",children:r?n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",disabled:a,onClick:()=>i(!1),children:"Cancel"}),n.jsxs(T,{variant:"accent",disabled:a,onClick:b,children:["Upgrade to ",p==null?void 0:p.latest]})]}):n.jsx(T,{variant:"accent",disabled:a||t!==null||!(p!=null&&p.updateAvailable),onClick:()=>i(!0),children:p!=null&&p.updateAvailable&&p.latest?`Upgrade to ${p.latest}`:"Upgrade"})})]})}),p&&p.history.length>0?n.jsx(oe,{title:"Upgrades so far",children:n.jsx(Wt,{items:p.history.slice().reverse().map(j=>({key:j.startedAt,label:n.jsxs("span",{className:"mono",children:[j.from," → ",j.to]}),value:n.jsx(PY,{attempt:j})}))})}):null]})})}function IY({job:e,error:t}){return t?n.jsx(ae,{message:t}):e?e.phase==="failed"?n.jsxs(V,{tone:"critical",role:"alert",children:[Xd.failed," ",e.error??""," buddi is still running on the version it had."]}):n.jsx(V,{tone:e.phase==="done"?"good":void 0,role:"status",children:Xd[e.phase]??e.detail??e.phase}):null}function PY({attempt:e}){return n.jsxs("span",{children:[n.jsx(ve,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Oe(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?n.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",n.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Jd=["hello","brain","takeOn","reach","assistant","handover"],t$={hello:"you",brain:"model",takeOn:"take-on",reach:"reach",assistant:"agent",handover:"hello"};function n$(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function MY(e){var a,l,o;const t=n$(e.accounts),s=e.assistant?(((a=e.accounts)==null?void 0:a.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(s==null?void 0:s.accountId)??((o=(l=e.onboarding)==null?void 0:l.details)==null?void 0:o.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(s==null?void 0:s.model)??i.defaultModel}}function s$(e){var a,l,o,c,u;const t=MY(e),s=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0,r=((a=e.onboarding)==null?void 0:a.details)??{},i=((l=e.onboarding)==null?void 0:l.stepsDone)??[];return{...(o=e.owner)!=null&&o.preferredName?{name:e.owner.preferredName}:{},...(c=e.owner)!=null&&c.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...Array.isArray(r.takeOn)?{takeOn:r.takeOn}:s?{takeOn:[]}:{},...r.reach?{reach:r.reach}:i.includes("reach")||s?{reach:{}}:{},...i.includes("browser")||((u=r.reach)==null?void 0:u.browser)===!0?{browser:e.browser??"other"}:{},...s?{assistant:s}:{}}}function r$(e,t){return t==="hello"?typeof e.name=="string"&&e.name!==""&&typeof e.clock=="string"&&e.clock!=="":t==="brain"?e.brain!==void 0:t==="takeOn"?e.takeOn!==void 0:t==="reach"?e.reach!==void 0:t==="assistant"?e.assistant!==void 0:!1}function ed(e){return Jd.find(t=>!r$(e,t))??"handover"}function DY(e){const t=Jd.indexOf(e);return t>0?Jd[t-1]:null}function k0(e,t,s){return s===t?"now":r$(e,s)?"done":"todo"}function OY(e,t){return{...e}}const hx="buddi.firstRun.restore";function fx(e){try{e===null?window.sessionStorage.removeItem(hx):window.sessionStorage.setItem(hx,e)}catch{}}function i$(){try{return window.sessionStorage.getItem(hx)}catch{return null}}function LY(e){const t=s$(e),s=ed(t);return{answers:t,open:s,stay:s!=="handover"}}function _Y(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function FY(e){const t=e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,20).replace(/-+$/,"");return t===""?"assistant":t}const zY=6e4,UY=5*6e4,a$=1500,BY=2e3,WY="(max-width: 720px)";function Ml(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,s=0;const r=l=>{const o=l.ownerDocument.activeElement;if(o===null||o===l.ownerDocument.body||o===l.ownerDocument.documentElement)return!0;const c=l.closest('[role="dialog"]');return c!==null&&o.tagName==="BUTTON"&&o.closest('[role="dialog"]')===c},i=()=>{const l=e.current;l&&r(l)&&l.focus()},a=()=>{i(),s=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(a):a(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(s),window.removeEventListener("focus",i)}},[]),e}const lw=d.createContext({busy:0,report:()=>{}});function HY({children:e}){const[t,s]=d.useState(0),r=d.useCallback(a=>s(l=>Math.max(0,l+(a?1:-1))),[]),i=d.useMemo(()=>({busy:t,report:r}),[t,r]);return n.jsx(lw.Provider,{value:i,children:e})}function ct({children:e}){const{busy:t}=d.useContext(lw);return n.jsxs("div",{className:"wiz-say",children:[n.jsx(Ec,{state:t>0?"working":"idle",size:"sm",className:"wiz-say-face"}),n.jsx("div",{className:"wiz-bubble",children:e})]})}function tt({children:e}){return n.jsx(n.Fragment,{children:e})}function Us({line:e}){const{report:t}=d.useContext(lw);return d.useEffect(()=>(t(!0),()=>t(!1)),[t]),n.jsxs("div",{className:"wiz-busy",role:"status","aria-live":"polite",children:[n.jsxs("span",{className:"wiz-pulse","aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),e]})}const ow=d.createContext(null);function qt({children:e,actions:t}){const s=d.useContext(ow),r=t==null?null:s?vl.createPortal(t,s):n.jsx("div",{className:"wiz-dock-inline",children:t});return n.jsxs(n.Fragment,{children:[e?n.jsx("div",{className:"wiz-ask",children:e}):null,r]})}function Jn({onClick:e,disabled:t}){return n.jsxs(T,{variant:"ghost",size:"lg",onClick:e,disabled:t,children:[n.jsx(ue,{name:"chevron-left"}),L.back]})}function Dl({children:e,onClick:t,disabled:s}){return n.jsxs(T,{variant:"accent",size:"lg",onClick:t,disabled:s,children:[e,n.jsx(ue,{name:"arrow"})]})}function KY({navigate:e,timezone:t}){var zn,Bs,Y,$e,Je,bt,gt;const s=Ps(WY),[r,i]=d.useState(void 0);d.useEffect(()=>{E.session().then(we=>i(we.platform)).catch(()=>{})},[]);const[a,l]=d.useState({}),[o,c]=d.useState(null),[u,h]=d.useState(void 0),[f,m]=d.useState(void 0),[p,g]=d.useState([]),[x,b]=d.useState(null),[j,v]=d.useState(null),[w,y]=d.useState(!1),[N,k]=d.useState(null),[S,C]=d.useState(null),[$,R]=d.useState(null),[I,z]=d.useState(null),[U,A]=d.useState(()=>i$()?"running":"idle"),[P,D]=d.useState({}),[O,M]=d.useState([]),[W,_]=d.useState(0),G=d.useRef(void 0),[B,K]=d.useState(null),F=d.useCallback(()=>{Promise.resolve().then(()=>E.takeOnProgress()).then(we=>{we&&Array.isArray(we.plugins)&&K(we)}).catch(()=>{})},[]);d.useEffect(()=>{if(!(B!=null&&B.running))return;const we=window.setInterval(F,BY);return()=>window.clearInterval(we)},[B==null?void 0:B.running,F]);const Q=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),X=d.useRef(e);X.current=e;const Z=d.useCallback(async(we=!0,We=!1)=>{var Un,Rn,Ws,Ll,Ti,$n,Ri,mr,Wr;const[Le,Xt,ys,wn,bs,ks]=await Promise.all([E.onboarding().catch(()=>{}),E.owner().catch(()=>{}),E.providerAccounts().catch(()=>{}),Be.agents().catch(()=>{}),E.browser().catch(()=>{}),E.providers().catch(()=>{})]);h(ys);const ye=(Rn=(Un=ks==null?void 0:ks.providers.find(Ft=>Ft.kind==="anthropic"))==null?void 0:Un.defaultModel)==null?void 0:Rn.trim();m(ye||void 0),g((Xt==null?void 0:Xt.zones)??[]),k(((Ws=Le==null?void 0:Le.details)==null?void 0:Ws.conversationId)??null);const Ce=(wn==null?void 0:wn.agents.find(Ft=>Ft.id===wn.defaultAgentId))??(wn==null?void 0:wn.agents[0]);Ce&&b(Ce),C(Le&&!Le.needs.agent&&Ce?{id:Ce.id,name:Ce.name,avatar:((Ll=Ce.avatar)==null?void 0:Ll.kind)==="emoji"?Ce.avatar.value:"",description:Ce.description,...Ce.picture?{picture:Ce.picture}:{}}:null),Array.isArray((Ti=Le==null?void 0:Le.details)==null?void 0:Ti.takeOn)&&F();const Ke={onboarding:Le,owner:Xt,accounts:ys,browser:($n=bs==null?void 0:bs.browser)==null?void 0:$n.engine,...Ce?{assistant:{id:Ce.id,name:Ce.name,avatar:((Ri=Ce.avatar)==null?void 0:Ri.kind)==="emoji"?Ce.avatar.value:""}}:{}};if(We){const Ft=LY(Ke);if(l(Ft.answers),c(Ft.open),!Ft.stay){const Hs=(mr=Le==null?void 0:Le.details)==null?void 0:mr.conversationId;X.current(Hs&&Ce?at(Ce.id,Hs):sn,!0)}return}if(we&&(Le==null?void 0:Le.state)==="done"){const Ft=(Wr=Le.details)==null?void 0:Wr.conversationId;X.current(Ft&&Ce?at(Ce.id,Ft):sn,!0);return}if(!we)return;const fe=s$(Ke);l(fe),c(Ft=>Ft??ed(fe))},[]);d.useEffect(()=>{Z()},[Z]);const de=(we,We={})=>{Promise.resolve().then(()=>E.onboardingStep(t$[we],We)).catch(()=>{})},_e=we=>ed(we)==="brain"&&P.brain?{...we,brain:P.brain}:we,Ie=(we,We)=>{const Le=_e(We);Le.brain&&(G.current=Le.brain),v(null),M([]),l(Le),we==="brain"&&Le.brain?de(we,{accountId:Le.brain.accountId}):we==="reach"?de(we,Le.reach?{reach:Le.reach}:{}):we!=="takeOn"&&de(we),c(ed(Le))},Ue=(we,We)=>{v(null),l(We),We.brain&&(G.current=We.brain),we==="brain"&&We.brain&&de(we,{accountId:We.brain.accountId})},ee=we=>{v(null),l(We=>OY(We)),c(we)},be=()=>{if(!o)return;const we=DY(o==="handover"?"handover":o);we&&ee(we)},se=()=>{const we=a.brain??G.current,We=((B==null?void 0:B.plugins)??[]).filter(Le=>Le.state==="ready").map(Le=>Le.title);v(null),D({}),M([]),l({}),c("hello"),_(Le=>Le+1),(async()=>{var ye;const[Le,Xt,ys]=await Promise.all([Promise.resolve().then(()=>E.providerAccounts()).catch(()=>{}),Promise.resolve().then(()=>E.telegram()).catch(()=>{}),Promise.resolve().then(()=>E.browser()).catch(()=>{})]),wn=n$(Le),bs=we&&wn.some(Ce=>Ce.id===we.accountId)?we:void 0;Le&&h(Le),D(bs?{brain:bs}:{});const ks=[...new Set(wn.map(Ce=>Ce.label)),...Xt!=null&&Xt.paired?[L.startOver.telegram]:[],...((ye=ys==null?void 0:ys.browser)==null?void 0:ye.engine)==="chromium"?[L.startOver.browser]:[],...We];M(ks.length>0?[L.startOver.said(ks.join(", "))]:[])})()},Te=()=>{y(!0),E.skipOnboarding().then(()=>e(sn)).catch(we=>v(we instanceof me?we.message:String(we))).finally(()=>y(!1))},pe=ce(()=>E.version().catch(()=>({current:""})),[]),Re=d.useRef(null);d.useEffect(()=>{Re.current&&(Re.current.scrollTop=0)},[o]);const Se=U==="running",Fe=Object.keys(a).length===0,Ze={answers:a,accounts:u,claudeModel:f,zones:p,browserZone:Q,assistantAgent:x,met:N,onMet:k,existing:S,progress:B,onProgress:F,navigate:e,onSettled:we=>o&&Ie(o,we),onKept:we=>o&&Ue(o,we),onBack:be,onTrouble:v,onReload:()=>void Z(!1),onPickAnotherBrain:()=>ee("brain"),onSpoken:z},Ee=(a.takeOn??[]).map(we=>{var We;return((We=Ya.find(Le=>Le.id===we))==null?void 0:We.title)??we}),ze=(B==null?void 0:B.plugins)??[],nt=ze.filter(we=>we.state==="ready").length,Ye=ze.length===0?null:B!=null&&B.running?L.takeOn.installing(nt,ze.length):nt===ze.length?L.takeOn.installed:null,J=[(zn=a.reach)!=null&&zn.phone?L.reach.done.phone:null,(Bs=a.reach)!=null&&Bs.mailbox?L.reach.done.mailbox:null,(Y=a.reach)!=null&&Y.app||($e=a.reach)!=null&&$e.browser?L.reach.done.app:null].filter(we=>we!==null),je={hello:{answer:L.hello.answer(a.name??""),sub:a.clock??null},brain:{answer:L.brain.answer(((Je=a.brain)==null?void 0:Je.label)??"")},takeOn:{answer:L.takeOn.answer(Ee),sub:Ye},reach:{answer:L.reach.answer(J)},assistant:{answer:((bt=a.assistant)==null?void 0:bt.name)??""}},Ge=Jd.filter(we=>we!=="handover"),lt=o===null||o==="handover"?Ge.length:Ge.indexOf(o),ot=Math.min(lt,Ge.length-1),q=I?null:n.jsxs("div",{className:"wiz-map-out",children:[n.jsx("button",{type:"button",className:"wiz-link",disabled:w,onClick:Te,children:L.later}),o==="hello"&&Fe&&U==="idle"?n.jsx("button",{type:"button",className:"wiz-link",onClick:()=>A("form"),children:L.restore.offer}):!Se&&o!==null&&!(o==="hello"&&Fe)?n.jsx("button",{type:"button",className:"wiz-link",disabled:w,onClick:se,children:L.startOver.link}):null]}),ft=r===void 0||r==="darwin"?L.tagline:L.taglineElsewhere,yt=o&&o!=="handover"?n.jsx("span",{className:"wiz-count",children:L.count(lt+1)}):n.jsx("span",{className:"wiz-count"});return n.jsx(ow.Provider,{value:$,children:n.jsx(HY,{children:n.jsxs(PE,{className:"wiz-ground",children:[n.jsx("div",{className:"wiz",ref:Re,"data-phone":s?"true":void 0,"data-testid":"meet",children:n.jsxs("div",{className:"wiz-frame",children:[s?n.jsxs("div",{className:"wiz-strip",children:[n.jsx(sc,{size:"sm"}),n.jsx("span",{className:"wiz-dots","aria-label":o&&o!=="handover"?L.count(lt+1):void 0,children:Ge.map(we=>n.jsx("i",{"data-state":k0(a,o,we)},we))}),n.jsx("span",{className:"wiz-strip-name",children:o&&o!=="handover"?L.strip(lt+1,L.chapters[lt]??""):L.handover.starterLabel})]}):n.jsxs("nav",{className:"wiz-map","aria-label":"Chapters",children:[n.jsxs("div",{className:"wiz-head",children:[n.jsx(sc,{size:"lg"}),n.jsxs("div",{children:[n.jsx("div",{className:"wiz-head-name",children:"buddi"}),n.jsx("div",{className:"wiz-head-line",children:ft}),(gt=pe.data)!=null&>.current?n.jsxs("div",{className:"wiz-head-version mono",children:["buddi ",pe.data.current]}):null]})]}),Ge.map((we,We)=>{const Le=Se?we==="hello"?"now":"todo":k0(a,o,we),Xt=je[we];return n.jsxs("div",{className:"wiz-ch","data-state":Le,"aria-current":Le==="now"?"step":void 0,children:[n.jsx("span",{className:"wiz-num","data-state":Le,children:Le==="done"?n.jsx(ue,{name:"check",size:12}):We+1}),n.jsxs("span",{className:"wiz-ch-label",children:[Le==="done"?Xt.answer:L.chapters[We],Le==="done"&&Xt.sub?n.jsx("span",{className:"wiz-ch-sub",children:Xt.sub}):null]}),Le==="done"&&!Se?n.jsx("button",{type:"button",className:"wiz-link",onClick:()=>ee(we),children:L.change}):null]},we)}),n.jsx("div",{className:"wiz-map-spacer"}),n.jsx("div",{className:"wiz-map-note",children:L.mapNotes[ot]}),q]}),n.jsx("div",{className:"wiz-stage",role:"main",children:n.jsxs("div",{className:"wiz-column","data-width":o==="hello"?"narrow":o==="brain"?"mid":"wide",children:[n.jsxs(yz,{dock:n.jsxs(n.Fragment,{children:[yt,n.jsx("div",{className:"wiz-dock-actions",ref:R})]}),children:[Se?n.jsx(wq,{onDone:we=>{A("idle"),M([...we?[L.restore.welcome(we)]:[],L.restore.keys]),Z(!0,!0)},onFailed:we=>{A("idle"),v(we)}}):o==="hello"?n.jsx(VY,{...Ze}):o==="brain"?n.jsx(YY,{...Ze}):o==="takeOn"?n.jsx(uq,{...Ze}):o==="reach"?n.jsx(dq,{...Ze}):o==="assistant"?n.jsx(gq,{...Ze}):o==="handover"?n.jsx(xq,{...Ze}):n.jsx(Us,{}),O.length>0||j?n.jsxs(tt,{children:[O.map(we=>n.jsx(ct,{children:we},we)),j?n.jsx(ct,{children:j}):null]}):null]},`${W}-${o??""}-${Se?"r":""}`),s?n.jsx("div",{className:"wiz-phone-out",children:q}):null]})})]})}),U==="form"?n.jsx(jq,{onCancel:()=>A("idle"),onStarted:()=>A("running"),onTrouble:v}):null]})})})}function Ol({children:e}){return n.jsx("h1",{className:"wiz-title",children:e})}function N0(e){try{return Ht(new Date,e)}catch{return""}}function VY({answers:e,zones:t,browserZone:s,onSettled:r,onTrouble:i}){const a=Ml(),[l,o]=d.useState(e.name??""),[c,u]=d.useState(e.clock??s),[h,f]=d.useState(!1),[m,p]=d.useState(!1),g=()=>{const x=l.trim();x===""||m||(p(!0),E.setOwner({preferredName:x,timezone:c}).then(()=>r({...e,name:x,clock:c})).catch(b=>i(b instanceof me?b.message:String(b))).finally(()=>p(!1)))};return n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.hello.title}),n.jsx(tt,{children:L.hello.opening.map(x=>n.jsx(ct,{children:x},x))}),n.jsxs(qt,{actions:n.jsx(Dl,{onClick:g,disabled:m||l.trim()==="",children:L.hello.submit}),children:[n.jsxs("div",{className:"wiz-pair",children:[n.jsx(ie,{label:L.name.label,children:n.jsx("input",{ref:a,placeholder:L.name.placeholder,maxLength:80,value:l,onChange:x=>o(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),g())}})}),h?n.jsx(ie,{label:L.clock.label,hint:L.clock.hint(N0(c)),children:n.jsx("select",{value:c,onChange:x=>u(x.target.value),children:(t.includes(c)?t:[c,...t]).map(x=>n.jsx("option",{value:x,children:x},x))})}):n.jsx(ie,{label:L.clock.label,hint:L.clock.hint(N0(c)),action:n.jsx(T,{size:"lg",onClick:()=>f(!0),children:L.clock.change}),children:n.jsx("input",{value:c,readOnly:!0})})]}),n.jsx("div",{className:"wiz-foot",children:L.hello.foot})]})]})}const GY={free:{icon:"cloud",tone:"good"},claude:{icon:"bulb",tone:"mail"},chatgpt:{icon:"chat",tone:"coding"},key:{icon:"key",tone:"accent"},local:{icon:"monitor",tone:"plain",wide:!0}};function YY(e){const{accounts:t,answers:s,onSettled:r,onKept:i,onReload:a,onBack:l}=e,[o,c]=d.useState(null),[u,h]=d.useState("key"),[f,m]=d.useState(null),[p,g]=d.useState(!1),[x,b]=d.useState(null),[j,v]=d.useState(null),[w,y]=d.useState(null),N=(t==null?void 0:t.anthropicOAuthEnabled)===!0,k=(t==null?void 0:t.codexEnabled)===!0,S=t==null?void 0:t.gemini,[C,$]=d.useState(null);d.useEffect(()=>{let W=!1;const _=()=>{Promise.resolve().then(()=>E.ollama()).then(B=>{!W&&B&&b(B)}).catch(()=>{}),Promise.resolve().then(()=>E.mlxh()).then(B=>{!W&&B&&v(B)}).catch(()=>{W||v({running:!1,baseUrl:"",manager:!1,models:[]})})};_();const G=window.setInterval(_,4e3);return()=>{W=!0,window.clearInterval(G)}},[]);const R=async W=>{if(s.assistant??e.existing)try{await E.bindBrain({accountId:W.accountId,model:W.model})}catch(_){return _ instanceof me?_.message:String(_)}return a(),i({...s,brain:W}),C==null||C.close(),$(null),c(null),y(null),null},I=async(W,_,G)=>{g(!0),m(null);try{const B=await E.saveProviderAccount(W);let K=await E.testProviderAccount(B.id),F=W.defaultModel,Q=!1;if(K.state!=="connected"&&G&&G!==F&&qT(K)){const Z=(await E.providerAccounts()).accounts.find(de=>de.id===B.id);Z&&(await E.saveProviderAccount({id:Z.id,revision:Z.revision,label:Z.label,kind:Z.kind,auth:Z.auth,baseUrl:Z.baseUrl,defaultModel:G,enabled:Z.enabled}),K=await E.testProviderAccount(B.id),K.state==="connected"&&(F=G,Q=!0))}if(K.state!=="connected"){try{const Z=(await E.providerAccounts()).accounts.find(de=>de.id===B.id);Z&&await E.removeProviderAccount(B.id,Z.revision)}catch{}return m(K.message),K}const X=await R({accountId:B.id,label:_,model:F,...Q?{freeTier:Q}:{}});return X&&m(X),K}catch(B){return m(B instanceof me?B.message:String(B)),null}finally{g(!1)}},z=async W=>{g(!0),m(null);try{const _=await E.saveProviderAccount(W);let G;try{G=await E.testProviderAccount(_.id)}finally{try{const B=(await E.providerAccounts()).accounts.find(K=>K.id===_.id);B&&await E.removeProviderAccount(_.id,B.revision)}catch{}}return G.state!=="connected"&&m(G.message),G}catch(_){return m(_ instanceof me?_.message:String(_)),null}finally{g(!1)}},U=(W,_,G)=>{if(W.length<=1){I(_(W[0]??""),G);return}y({models:W,make:_,label:G})},A=W=>{if(W===o)return;C==null||C.close(),$((W==="free"||W==="chatgpt")&&typeof window.open=="function"?window.open("","_blank"):null),m(null),y(null),h("key"),c(W)},P=()=>{C==null||C.close(),$(null),y(null),m(null),c(null)},D=o$(x,j),O=["free",...N?["claude"]:[],...k?["chatgpt"]:[],"key","local"];let M=null;return w?M=n.jsxs(n.Fragment,{children:[n.jsx(tt,{children:n.jsx(ct,{children:L.brain.model.ask})}),p?n.jsx(Us,{line:L.brain.checking.service}):f?n.jsx(tt,{children:n.jsx(ct,{children:f})}):null,n.jsx(qY,{busy:p,models:w.models,onBack:P,onUse:W=>void I(w.make(W),w.label)})]}):o==="key"?M=n.jsxs(n.Fragment,{children:[n.jsx(rn,{label:L.brain.keyKinds.label,value:u,onChange:W=>{m(null),h(W)},options:[{value:"key",label:L.brain.keyKinds.key},...S?[{value:"gemini",label:L.brain.keyKinds.gemini}]:[],{value:"service",label:L.brain.keyKinds.service}]}),u==="gemini"&&S?n.jsx(XY,{busy:p,problem:f,preset:S,onBack:P,onUse:I},"gemini"):u==="service"?n.jsx(ZY,{busy:p,problem:f,address:(x==null?void 0:x.cloudBaseUrl)??"",onBack:P,onOffer:U,onTrial:z,onUse:I},"service"):n.jsx(QY,{busy:p,problem:f,onBack:P,onUse:I},"key")]}):o==="local"?M=n.jsx(JY,{busy:p,problem:f,probe:x,mlxh:j,onBack:P,onOffer:U,onUse:I}):o==="free"?M=n.jsx(tq,{...e,busy:p,consent:C,onBack:P,onConnected:R}):o==="chatgpt"?M=n.jsx(rq,{...e,busy:p,consent:C,onBack:P,onConnected:R}):o==="claude"&&(M=n.jsx(aq,{...e,busy:p,problem:f,onBack:P,onConnected:R})),n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.brain.title}),n.jsx(tt,{children:n.jsx(ct,{children:L.brain.ask})}),n.jsx("div",{className:"wiz-grid",role:"group","aria-label":L.brain.ask,children:O.map(W=>{const _=GY[W],G=L.brain.cards[W];return n.jsxs("button",{type:"button",className:"wiz-opt","aria-pressed":o===W,"data-wide":_.wide?"true":void 0,onClick:()=>A(W),children:[n.jsx("span",{className:"wiz-glyph","data-tone":_.tone,"aria-hidden":"true",children:n.jsx(ue,{name:_.icon})}),n.jsxs("span",{children:[n.jsx("span",{className:"wiz-opt-title",children:G.title}),n.jsx("span",{className:"wiz-opt-line",children:W==="local"?D:G.line}),"pill"in G?n.jsx(ve,{tone:"good",children:G.pill}):null]})]},W)})}),M,M===null&&s.brain?n.jsxs(tt,{children:[n.jsx(ct,{children:s.brain.freeTier?L.brain.worksOnFlash(s.brain.model):L.brain.works(s.brain.model)}),n.jsx(nq,{...e})]}):null,M===null?n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:l}),n.jsx(Dl,{onClick:()=>s.brain&&r(s),disabled:!s.brain,children:L.brain.submit})]})}):null]})}function qY({busy:e,models:t,onBack:s,onUse:r}){const[i,a]=d.useState(t[0]??"");return n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:s,disabled:e}),n.jsx(T,{variant:"accent",size:"lg",disabled:e||i==="",onClick:()=>r(i),children:L.brain.model.submit})]}),children:n.jsx(ie,{label:L.brain.model.label,grow:!0,children:n.jsx("select",{value:i,onChange:l=>a(l.target.value),children:t.map(l=>n.jsx("option",{value:l,children:l},l))})})})}function l$({models:e,picked:t,disabled:s,onPick:r}){return n.jsx(ie,{label:L.brain.model.label,grow:!0,children:n.jsx("select",{value:t,disabled:s,onChange:i=>r(i.target.value),children:e.map(i=>n.jsx("option",{value:i,children:i},i))})})}function QY({busy:e,problem:t,onBack:s,onUse:r}){const i=Ml(),[a,l]=d.useState(""),[o,c]=d.useState(null),[u,h]=d.useState(!1),[f,m]=d.useState([]),[p,g]=d.useState(""),[x,b]=d.useState(!1),j=e||u,v=!x&&t!==null&&f.length>0,w=o??_Y(a),y=()=>{const N=a.trim();N===""||j||(h(!0),b(!1),(async()=>{var $;let k=w==="anthropic"?"claude-sonnet-5":"gpt-5",S=f;if(v&&p!=="")k=p;else try{const R=await E.probeModels({kind:w,auth:"api-key",secret:N});k=(($=R.models.find(I=>I.isDefault))==null?void 0:$.id)??k,S=R.models.map(I=>I.id)}catch{S=[]}h(!1);const C=await r({label:w==="anthropic"?L.brain.key.anthropic:L.brain.key.openai,kind:w,auth:"api-key",baseUrl:"",defaultModel:k,enabled:!0,secret:N},w==="anthropic"?L.brain.key.anthropic:L.brain.key.openai);if(!(!C||C.state==="connected")){if(Tv(C)){b(!0),m([]);return}m(S.includes(k)||S.length===0?S:[k,...S]),g(k)}})())};return n.jsxs(n.Fragment,{children:[j?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.key})}):x?n.jsx(tt,{children:n.jsx(ct,{children:L.brain.key.refused})}):t?n.jsx(tt,{children:n.jsx(ct,{children:t})}):null,n.jsxs(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:s,disabled:j}),n.jsx(T,{variant:"accent",size:"lg",disabled:j||a.trim()==="",onClick:y,children:v?L.brain.model.retry:L.brain.key.submit})]}),children:[n.jsx(ie,{label:L.brain.key.field,grow:!0,children:n.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:L.brain.key.placeholder,value:a,onChange:N=>{l(N.target.value),m([])},onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),y())}})}),v?n.jsx(l$,{models:f,picked:p,disabled:j,onPick:g}):null,n.jsxs("button",{type:"button",className:"wiz-link",onClick:()=>c(w==="anthropic"?"openai":"anthropic"),children:[w==="anthropic"?L.brain.key.anthropic:L.brain.key.openai," · ",L.brain.key.which]})]})]})}function XY({busy:e,problem:t,preset:s,onBack:r,onUse:i}){const a=Ml(),[l,o]=d.useState(""),[c,u]=d.useState(!1),[h,f]=d.useState([]),[m,p]=d.useState(""),g=e||c,x=t!==null&&h.length>0,b=()=>{const j=l.trim();j===""||g||(u(!0),(async()=>{let v=KT,w;if(x&&m!=="")v=m;else try{const N=(await E.probeModels({kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,secret:j})).models.map(k=>k.id);v=VT(N)??v,w=YT(v)?GT(N):void 0,f(KV(N)),p(w??v)}catch{}u(!1),await i({label:L.brain.gemini.label,kind:"openai-compatible",auth:"api-key",baseUrl:s.baseUrl,defaultModel:v,enabled:!0,secret:j},L.brain.gemini.label,w)})())};return n.jsxs(n.Fragment,{children:[g?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.gemini})}):t?n.jsx(tt,{children:n.jsx(ct,{children:t})}):null,n.jsxs(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:r,disabled:g}),n.jsx(T,{variant:"accent",size:"lg",disabled:g||l.trim()==="",onClick:b,children:L.brain.gemini.submit})]}),children:[n.jsx(ie,{label:L.brain.gemini.field,grow:!0,children:n.jsx("input",{ref:a,type:"password",autoComplete:"off",spellCheck:!1,placeholder:L.brain.gemini.placeholder,value:l,onChange:j=>o(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b())}})}),x?n.jsx(ie,{label:L.brain.model.label,grow:!0,children:n.jsx("select",{value:m,disabled:g,onChange:j=>p(j.target.value),children:h.map(j=>n.jsx("option",{value:j,children:j},j))})}):null,n.jsx("a",{className:"wiz-link",href:s.keyUrl,target:"_blank",rel:"noreferrer",children:L.brain.gemini.get})]})]})}function o$(e,t){return e===null||t===null?L.brain.local.looking:!e.running&&!t.running?L.brain.local.missing:L.brain.local.found({...e.running?{ollama:e.models.length}:{},...t.running?{mlxh:t.models.length}:{}})}function JY({busy:e,problem:t,probe:s,mlxh:r,onBack:i,onOffer:a,onUse:l}){const o=(s==null?void 0:s.models)??[],c=qg(r),u=()=>{!(r!=null&&r.running)||!c||l({label:L.brain.mlxh.label,kind:"openai-compatible",auth:"none",baseUrl:r.baseUrl,defaultModel:c,enabled:!0},L.brain.mlxh.label)},h=s!==null&&r!==null&&!s.running&&!r.running,f=()=>{s&&a(o,m=>({label:L.brain.ollama.label,kind:"openai-compatible",auth:"none",baseUrl:s.baseUrl,defaultModel:m,enabled:!0}),L.brain.ollama.label)};return n.jsxs(n.Fragment,{children:[e?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.ollama})}):t?n.jsx(tt,{children:n.jsx(ct,{children:t})}):null,n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:i,disabled:e}),s!=null&&s.running?n.jsx(T,{variant:r!=null&&r.running?void 0:"accent",size:"lg",disabled:e||o.length===0,onClick:f,children:L.brain.ollama.connect}):null,r!=null&&r.running?n.jsx(T,{variant:"accent",size:"lg",disabled:e||!c,onClick:u,children:L.brain.mlxh.connect}):null,h&&s?n.jsx(Tt,{variant:"accent",size:"lg",href:s.downloadUrl,target:"_blank",rel:"noreferrer",children:L.brain.ollama.download}):null]}),children:n.jsxs("span",{className:"wiz-foot",children:[o$(s,r),r!=null&&r.running&&!c?` ${L.brain.mlxh.noBrain}`:"",h&&(r!=null&&r.baseUrl)?` ${NT(r.baseUrl)}`:""]})})]})}function ZY({busy:e,problem:t,address:s,onBack:r,onOffer:i,onTrial:a,onUse:l}){const o=Ml(),[c,u]=d.useState(s),[h,f]=d.useState(""),[m,p]=d.useState(!1),[g,x]=d.useState([]),[b,j]=d.useState(""),[v,w]=d.useState(!1),y=e||m,N=!v&&t!==null&&g.length>0,k=()=>{c.trim()===""||y||(p(!0),w(!1),(async()=>{var P;const S=h.trim()?"api-key":"none",C=D=>({label:L.brain.service.label,kind:"openai-compatible",auth:S,baseUrl:c.trim(),defaultModel:D,enabled:!0,...h.trim()?{secret:h.trim()}:{}}),$=(D,O,M)=>{if(!(!D||D.state==="connected")){if(Tv(D)){w(!0),x([]);return}x(O),j(M)}};if(S==="api-key"&&N&&b!==""){p(!1),$(await l(C(b),L.brain.service.label),g,b);return}let R=[],I;try{const D=await E.probeModels({kind:"openai-compatible",auth:S,baseUrl:c.trim(),...h.trim()?{secret:h.trim()}:{}});R=D.models.map(O=>O.id),I=(P=D.models.find(O=>O.isDefault))==null?void 0:P.id}catch{}p(!1);const z=I?[I]:R;if(S==="none"){i(z,C,L.brain.service.label);return}const U=z[0]??"";if(z.length<=1){$(await l(C(U),L.brain.service.label),R,U);return}const A=await a(C(U));(A==null?void 0:A.state)==="connected"?i(z,C,L.brain.service.label):$(A,R,U)})())};return n.jsxs(n.Fragment,{children:[y?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.service})}):v?n.jsx(tt,{children:n.jsx(ct,{children:L.brain.key.refused})}):t?n.jsx(tt,{children:n.jsx(ct,{children:t})}):null,n.jsxs(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:r,disabled:y}),n.jsx(T,{variant:"accent",size:"lg",disabled:y||c.trim()==="",onClick:k,children:N?L.brain.model.retry:L.brain.service.submit})]}),children:[n.jsx(ie,{label:L.brain.service.address,grow:!0,children:n.jsx("input",{ref:o,value:c,placeholder:L.brain.service.addressPlaceholder,onChange:S=>{u(S.target.value),x([])}})}),n.jsx(ie,{label:L.brain.service.key,children:n.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:h,onChange:S=>{f(S.target.value),x([])}})}),N?n.jsx(l$,{models:g,picked:b,disabled:y,onPick:j}):null]})]})}const eq=2e3;function tq({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,l]=d.useState(!0),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState(0),p=d.useRef(-1),g=d.useRef(null),x=L.brain.cloud.label;d.useEffect(()=>{if(p.current===f)return;p.current=f,l(!0),c(null);const j=f===0?t:g.current;(async()=>{try{const v=((i==null?void 0:i.accounts)??[]).find(k=>k.auth==="device-key"),w=v?{id:v.id}:await E.saveProviderAccount({label:x,kind:"openai-compatible",auth:"device-key",baseUrl:"",defaultModel:Hu,enabled:!0}),y=(await E.providerAccounts()).accounts.find(k=>k.id===w.id),N=await E.ollamaConnect(y.id,y.revision);h({id:y.id,attemptId:N.attemptId,url:N.verificationUrl}),j&&(j.location.href=N.verificationUrl)}catch(v){j==null||j.close(),c(v instanceof me?v.message:String(v))}finally{l(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let j=!1,v=!1;const w=async()=>{if(!(j||v)){v=!0;try{const N=await E.ollamaPoll(u.id,u.attemptId);if(j||N.state==="waiting")return;if(j=!0,h(null),N.state==="failed"){c(N.message);return}l(!0),c(await b(u.id)),l(!1)}catch{}finally{v=!1}}},y=window.setInterval(()=>void w(),eq);return()=>{j=!0,window.clearInterval(y)}},[u]);const b=async j=>{try{const v=(await E.accountModels(j).catch(()=>({models:[]}))).models.map(k=>k.id),w=v.length===0||v.includes(Hu)?Hu:v[0],y=(await E.providerAccounts()).accounts.find(k=>k.id===j);y&&y.defaultModel!==w&&await E.saveProviderAccount({id:y.id,revision:y.revision,label:y.label,kind:y.kind,auth:y.auth,baseUrl:y.baseUrl,defaultModel:w,enabled:y.enabled});const N=await E.testProviderAccount(j);return N.state!=="connected"?N.message:await r({accountId:j,label:x,model:w})}catch(v){return v instanceof me?v.message:String(v)}};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.cloud})}):o?n.jsx(tt,{children:n.jsx(ct,{children:o})}):u?n.jsx(tt,{children:n.jsx(ct,{children:L.brain.cloud.waiting})}):null,n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:s,disabled:a||e}),u?n.jsx(Tt,{variant:"accent",size:"lg",href:u.url,target:"_blank",rel:"noreferrer",children:L.brain.cloud.open}):o?n.jsx(T,{variant:"accent",size:"lg",disabled:a||e,onClick:()=>{g.current=typeof window.open=="function"?window.open("","_blank"):null,m(j=>j+1)},children:L.brain.cloud.again}):null]})})]})}function nq({answers:e,accounts:t,onKept:s,onTrouble:r}){var p;const i=e.brain,a=i?((t==null?void 0:t.accounts)??[]).find(g=>g.id===i.accountId):void 0,[l,o]=d.useState([]),[c,u]=d.useState(!1),h=Dj(a),f=(a==null?void 0:a.auth)==="device-key"||(a==null?void 0:a.kind)==="codex"||h||!!a&&QT(a,(p=t==null?void 0:t.gemini)==null?void 0:p.baseUrl);if(d.useEffect(()=>{if(!f||!a)return;let g=!1;return E.accountModels(a.id).then(x=>{const b=h?x.models.filter(j=>!kT({id:j.id,...j.image?{kind:"image"}:{}})):x.models;g||o(b.map(j=>j.id))}).catch(()=>{}),()=>{g=!0}},[f,a==null?void 0:a.id]),!f||!a||!i||l.length<2)return null;const m=g=>{g===i.model||c||(u(!0),r(null),(async()=>{try{await E.saveProviderAccount({id:a.id,revision:a.revision,label:a.label,kind:a.kind,auth:a.auth,baseUrl:a.baseUrl,defaultModel:g,enabled:a.enabled}),e.assistant&&await E.bindBrain({accountId:a.id,model:g}),s({...e,brain:{accountId:i.accountId,label:i.label,model:g}})}catch(x){r(x instanceof me?x.message:String(x))}finally{u(!1)}})())};return n.jsx(ct,{children:n.jsx(ie,{label:L.brain.model.change,children:n.jsx("select",{value:i.model,disabled:c,onChange:g=>m(g.target.value),children:(l.includes(i.model)?l:[i.model,...l]).map(g=>n.jsx("option",{value:g,children:g},g))})})})}const S0="gpt-5.5",sq=2e3;function rq({busy:e,consent:t,onBack:s,onConnected:r,accounts:i}){const[a,l]=d.useState(!0),[o,c]=d.useState(null),[u,h]=d.useState(null),[f,m]=d.useState(0),p=d.useRef(-1),g=d.useRef(null),x=d.useRef(null),b=L.brain.chatgpt.label;d.useEffect(()=>()=>{const w=x.current;x.current=null,w&&E.codexAccountAction(w.id,"cancel-login",w.revision).catch(()=>{})},[]),d.useEffect(()=>{if(p.current===f)return;p.current=f,l(!0),c(null);const w=f===0?t:g.current;(async()=>{try{const y=((i==null?void 0:i.accounts)??[]).find(C=>C.kind==="codex"),N=y?{id:y.id}:await E.saveProviderAccount({label:b,kind:"codex",auth:"chatgpt",baseUrl:"",defaultModel:S0,enabled:!0}),k=(await E.providerAccounts()).accounts.find(C=>C.id===N.id),S=await E.codexAccountAction(k.id,"login",k.revision);if(!(S!=null&&S.verificationUrl)||!S.userCode)throw new Error((S==null?void 0:S.message)??L.brain.chatgpt.failed);x.current={id:k.id,revision:k.revision},h({id:k.id,revision:k.revision,url:S.verificationUrl,code:S.userCode}),w&&(w.location.href=S.verificationUrl)}catch(y){w==null||w.close(),c(y instanceof me||y instanceof Error?y.message:String(y))}finally{l(!1)}})()},[f]),d.useEffect(()=>{if(!u)return;let w=!1,y=!1;const N=async()=>{if(!(w||y)){y=!0;try{const S=(await E.providerAccounts()).accounts.find($=>$.id===u.id);if(w)return;const C=S==null?void 0:S.login;if(!C||C.state==="pending")return;if(w=!0,x.current=null,h(null),C.state!=="connected"){c(C.message??L.brain.chatgpt.failed);return}l(!0),c(await j(u.id)),l(!1)}catch{}finally{y=!1}}},k=window.setInterval(()=>void N(),sq);return()=>{w=!0,window.clearInterval(k)}},[u]);const j=async w=>{var y,N;try{const k=(await E.accountModels(w).catch(()=>({models:[]}))).models,S=((y=k.find($=>$.isDefault))==null?void 0:y.id)??((N=k[0])==null?void 0:N.id)??S0,C=(await E.providerAccounts()).accounts.find($=>$.id===w);return C&&C.defaultModel!==S&&await E.saveProviderAccount({id:C.id,revision:C.revision,label:C.label,kind:C.kind,auth:C.auth,baseUrl:C.baseUrl,defaultModel:S,enabled:C.enabled}),await r({accountId:w,label:b,model:S})}catch(k){return k instanceof me?k.message:String(k)}},v=()=>{const w=x.current;x.current=null,w&&E.codexAccountAction(w.id,"cancel-login",w.revision).catch(()=>{}),s()};return n.jsxs(n.Fragment,{children:[a||e?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.chatgpt})}):o?n.jsx(tt,{children:n.jsx(ct,{children:o})}):u?n.jsx(tt,{children:n.jsxs(ct,{children:[L.brain.chatgpt.codeBefore,n.jsx("strong",{children:u.code}),L.brain.chatgpt.codeAfter]})}):null,n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:v,disabled:a||e}),u?n.jsx(Tt,{variant:"accent",size:"lg",href:u.url,target:"_blank",rel:"noreferrer",children:L.brain.chatgpt.open}):o?n.jsx(T,{variant:"accent",size:"lg",disabled:a||e,onClick:()=>{g.current=typeof window.open=="function"?window.open("","_blank"):null,m(w=>w+1)},children:L.brain.chatgpt.again}):null]}),children:u?n.jsx(Lj,{code:u.code,label:L.brain.chatgpt.code}):null})]})}const iq="claude-sonnet-5";function aq({busy:e,problem:t,onBack:s,onConnected:r,accounts:i,claudeModel:a}){const[l,o]=d.useState(!1),[c,u]=d.useState(null),[h,f]=d.useState(null),[m,p]=d.useState(""),g=d.useRef(null);d.useEffect(()=>()=>{const w=g.current;g.current=null,w&&E.anthropicAccountAction(w.id,"cancel-login",w.revision).catch(()=>{})},[]);const x=()=>{const w=g.current;g.current=null,w&&E.anthropicAccountAction(w.id,"cancel-login",w.revision).catch(()=>{}),s()},b=a??iq,j=()=>{o(!0),u(null);const w=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const y=((i==null?void 0:i.accounts)??[]).find($=>$.auth==="anthropic-oauth"),N=y?{id:y.id}:await E.saveProviderAccount({label:L.brain.claude.label,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:b,enabled:!0}),S=(await E.providerAccounts()).accounts.find($=>$.id===N.id),C=await E.anthropicAccountAction(S.id,"login",S.revision);g.current={id:S.id,revision:S.revision+1},f({id:S.id,revision:S.revision+1,url:C.verificationUrl??"",attemptId:C.attemptId??""}),w&&C.verificationUrl?w.location.href=C.verificationUrl:w==null||w.close()}catch(y){w==null||w.close(),u(y instanceof me?y.message:String(y))}finally{o(!1)}})()},v=()=>{!h||m.trim()===""||(g.current=null,o(!0),(async()=>{try{await E.anthropicAccountAction(h.id,"complete-login",h.revision,{attemptId:h.attemptId,code:m.trim()});const w=await E.testProviderAccount(h.id);if(w.state!=="connected"){u(w.message);return}u(await r({accountId:h.id,label:L.brain.claude.label,model:b}))}catch(w){u(w instanceof me?w.message:String(w))}finally{o(!1)}})())};return n.jsxs(n.Fragment,{children:[l||e?n.jsx(tt,{children:n.jsx(Us,{line:L.brain.checking.claude})}):t??c?n.jsx(tt,{children:n.jsx(ct,{children:t??c})}):null,h?n.jsxs(n.Fragment,{children:[n.jsx(tt,{children:n.jsx(ct,{children:L.brain.claude.waiting})}),n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:x,disabled:l}),n.jsx(Tt,{size:"lg",href:h.url,target:"_blank",rel:"noreferrer",children:L.brain.claude.open}),n.jsx(T,{variant:"accent",size:"lg",disabled:l||m.trim()==="",onClick:v,children:L.brain.claude.finish})]}),children:n.jsx(ie,{label:L.brain.claude.paste,grow:!0,children:n.jsx(lq,{value:m,onChange:p})})})]}):n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:x,disabled:e||l}),n.jsx(T,{variant:"accent",size:"lg",disabled:e||l,onClick:j,children:L.brain.claude.start})]})})]})}function lq({value:e,onChange:t}){const s=Ml();return n.jsx("input",{ref:s,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}const oq={days:"calendar",mail:"mail",money:"money",voice:"bulb",code:"monitor",pictures:"files"};function cq(e){const t=(e==null?void 0:e.plugins)??[];if(t.length===0)return null;const s=t.map(i=>i.title),r=t.filter(i=>i.state==="failed");if(e!=null&&e.running){const i=t.filter(a=>a.state==="ready"||a.state==="failed").length;return{line:L.takeOn.fetching(s,Math.min(i+1,t.length),t.length),done:!1}}return r.length>0?{line:r.map(i=>L.takeOn.failed(i.title,i.reason??"")).join(" "),done:!0}:{line:L.takeOn.ready(s),done:!0}}function uq({answers:e,progress:t,onProgress:s,onSettled:r,onBack:i,onTrouble:a}){const[l,o]=d.useState(()=>e.takeOn??[...S4]),[c,u]=d.useState(!1),h=Ya.filter(g=>l.includes(g.id)),f=g=>o(x=>x.includes(g)?x.filter(b=>b!==g):[...x,g]),m=g=>{c||(u(!0),Promise.resolve().then(()=>E.takeOn(g)).then(()=>{s(),r({...e,takeOn:g})}).catch(x=>a(x instanceof me?x.message:String(x))).finally(()=>u(!1)))},p=cq(t);return n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.takeOn.title}),n.jsx(tt,{children:n.jsx(ct,{children:L.takeOn.ask})}),n.jsxs(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:i,disabled:c}),n.jsx(T,{variant:"ghost",size:"lg",disabled:c,onClick:()=>m([]),children:L.takeOn.none}),n.jsx(Dl,{onClick:()=>m(Ya.filter(g=>l.includes(g.id)).map(g=>g.id)),disabled:c||l.length===0,children:L.takeOn.submit})]}),children:[n.jsx("div",{className:"wiz-grid","data-cols":"3",role:"group","aria-label":L.takeOn.title,children:Ya.map(g=>{const x=l.includes(g.id);return n.jsxs("button",{type:"button",className:"wiz-opt","data-tile":"true","aria-pressed":x,onClick:()=>f(g.id),children:[n.jsxs("span",{className:"wiz-tile-top",children:[n.jsx("span",{className:"wiz-glyph","aria-hidden":"true",children:n.jsx(ue,{name:oq[g.id]})}),n.jsx("span",{className:"wiz-tick","aria-hidden":"true",children:x?n.jsx(ue,{name:"check",size:12}):null})]}),n.jsxs("span",{children:[n.jsx("span",{className:"wiz-opt-title",children:g.title}),n.jsx("span",{className:"wiz-opt-plugins",children:g.plugins})]}),n.jsx("span",{className:"wiz-opt-line",children:g.line})]},g.id)})}),h.length>0?n.jsxs("div",{className:"wiz-stack",children:[p?n.jsxs("div",{className:"wiz-busy","data-boxed":"true",role:"status",children:[n.jsxs("span",{className:"wiz-pulse","data-done":p.done?"true":void 0,"aria-hidden":"true",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),n.jsx("span",{children:p.line}),l.includes("mail")?n.jsx("span",{className:"wiz-busy-side",children:L.takeOn.builtIn}):null]}):null,n.jsx("div",{className:"wiz-foot",children:h.map(g=>g.note).join(" ")})]}):n.jsx("div",{className:"wiz-foot",children:L.takeOn.nothing})]})]})}function dq({answers:e,navigate:t,onSettled:s,onBack:r}){var g,x,b;const[i,a]=d.useState(((g=e.reach)==null?void 0:g.phone)===!0),[l,o]=d.useState(((x=e.reach)==null?void 0:x.mailbox)===!0),[c,u]=d.useState(((b=e.reach)==null?void 0:b.app)===!0),[h,f]=d.useState(e.browser),m=(e.takeOn??[]).includes("mail"),p=()=>{const j={phone:i,mailbox:l,app:c,browser:h==="chrome"||h==="chromium"||h==="installed"};h!==void 0&&Promise.resolve().then(()=>E.onboardingStep("browser")).catch(()=>{}),s({...e,reach:j,...h!==void 0?{browser:h}:{}})};return n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.reach.title}),n.jsx(tt,{children:n.jsx(ct,{children:L.reach.ask})}),n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:r}),n.jsx(Dl,{onClick:p,children:L.reach.submit})]}),children:n.jsxs("div",{className:"wiz-rows",children:[n.jsx(hq,{paired:i,onPaired:()=>a(!0)}),n.jsx(mq,{wanted:m,added:l,onAdded:o,navigate:t,timezone:e.clock??"UTC"}),n.jsx(pq,{app:c,onApp:()=>u(!0),browser:h,onBrowser:f}),i?n.jsx(V,{tone:"good",role:"status",children:L.reach.phone.hello}):null]})})]})}function hq({paired:e,onPaired:t}){const[s,r]=d.useState(null),[i,a]=d.useState(!1),l=d.useRef(t);l.current=t,d.useEffect(()=>{let c=!1;return Promise.resolve().then(()=>E.telegram()).then(u=>{c||!u||(r(u),u.paired&&l.current())}).catch(()=>{c||r({configured:!1,running:!1,paired:!1})}),()=>{c=!0}},[]);const o=(s==null?void 0:s.configured)===!0&&s.running===!0&&!e;return n.jsxs("div",{className:"wiz-row",children:[n.jsx("span",{className:"wiz-glyph","aria-hidden":"true",children:n.jsx(ue,{name:"chat"})}),n.jsxs("span",{className:"wiz-row-text",children:[n.jsx("span",{className:"wiz-opt-title",children:L.reach.phone.title}),n.jsx("span",{className:"wiz-opt-line",children:L.reach.phone.line})]}),e?n.jsx("span",{className:"wiz-row-side",children:n.jsx(ve,{tone:"good",dot:!0,children:L.reach.phone.paired})}):o?n.jsx(fq,{onPaired:t}):n.jsx("span",{className:"wiz-row-side",children:n.jsx(T,{size:"lg",disabled:s===null,onClick:()=>a(!0),children:L.reach.phone.setUp})}),i?n.jsx(ht,{title:L.telegram.sheet,onClose:()=>a(!1),children:n.jsx(yq,{onPaired:t,onDismiss:()=>a(!1)})}):null]})}function fq({onPaired:e}){const{offer:t,square:s,paired:r,stale:i,ask:a}=iw(()=>E.telegram().then(o=>o.paired),e),l=d.useRef(!1);return d.useEffect(()=>{l.current||(l.current=!0,a().catch(()=>{}))},[a]),r?n.jsx("span",{className:"wiz-row-side",children:n.jsx(ve,{tone:"good",dot:!0,children:L.reach.phone.paired})}):i||!t?n.jsx("span",{className:"wiz-row-side",children:n.jsx(T,{size:"lg",onClick:()=>void a().catch(()=>{}),children:L.telegram.newCode})}):n.jsx("span",{className:"wiz-qr-slot",children:n.jsx(aw,{offer:t,square:s})})}function mq({wanted:e,added:t,onAdded:s,navigate:r,timezone:i}){const[a,l]=d.useState(void 0),[o,c]=d.useState(!1),[u,h]=d.useState(null),f=d.useCallback(()=>{Promise.resolve().then(()=>E.pageQuery("email","accounts")).then(m=>{var g,x,b;const p=((b=(x=(g=m==null?void 0:m.data)==null?void 0:g.accounts)==null?void 0:x[0])==null?void 0:b.address)??null;h(p),s(p!==null)}).catch(()=>{})},[]);return d.useEffect(()=>{let m=!1;return Promise.resolve().then(()=>E.pages()).then(p=>{if(m)return;const g=((p==null?void 0:p.pages)??[]).filter(b=>b.plugin==="email"),x=g.find(b=>b.id==="settings")??null;l(x?{page:x,siblings:g}:null)}).catch(()=>{m||l(null)}),f(),()=>{m=!0}},[f]),n.jsxs("div",{className:"wiz-row",children:[n.jsx("span",{className:"wiz-glyph","data-tone":"mail","aria-hidden":"true",children:n.jsx(ue,{name:"mail"})}),n.jsxs("span",{className:"wiz-row-text",children:[n.jsx("span",{className:"wiz-opt-title",children:e?L.reach.mailbox.forTriage:L.reach.mailbox.title}),n.jsx("span",{className:"wiz-opt-line",children:a===null?L.reach.mailbox.unavailable:L.reach.mailbox.line})]}),n.jsx("span",{className:"wiz-row-side",children:t||u?n.jsx(ve,{tone:"good",dot:!0,mono:u!==null,children:u??L.reach.mailbox.added}):a?n.jsx(T,{size:"lg",onClick:()=>c(!0),children:L.reach.mailbox.add}):null}),o&&a?n.jsx(ht,{title:L.reach.mailbox.sheet,size:"wide",onClose:()=>{c(!1),f()},children:n.jsx(Aj,{page:a.page,siblings:a.siblings,navigate:r,timezone:i,embedded:!0})}):null]})}function pq({app:e,onApp:t,browser:s,onBrowser:r}){const i=Jh(),a=typeof navigator>"u"?null:VA(navigator.userAgent),[l,o]=d.useState(null),[c,u]=d.useState("idle"),[h,f]=d.useState(null),[m,p]=d.useState(null),[g,x]=d.useState(void 0),b=d.useRef(!1),j=d.useRef(!0);d.useEffect(()=>(j.current=!0,Promise.resolve().then(()=>E.browser()).then(C=>{var R;if(!j.current)return;const $=C==null?void 0:C.browser;$?((R=$.install)==null?void 0:R.state)==="running"?(o("none"),b.current=!0,u("installing"),y()):o($.engine):o("other")}).catch(()=>{j.current&&o("other")}),()=>{j.current=!1}),[]);const v=(C,$)=>{j.current&&(b.current=!1,u("failed"),f(C),p($??null))},w=async C=>{u("launching");let $;try{$=await E.browserCheck()}catch(R){return v(R instanceof me?R.message:String(R))}if(j.current){if($.ok){u("idle"),o(C),r(b.current?"installed":C);return}v($.message,$.command)}},y=async()=>{var R,I;let C;try{C=await E.browser()}catch(z){return v(z instanceof me?z.message:String(z))}if(!j.current)return;const $=C.browser;if(!$)return v(L.browser.failed(""));if(((R=$.install)==null?void 0:R.state)==="running"){u("installing"),x($.install.progress),window.setTimeout(()=>void y(),1e3);return}return $.engine!=="none"?w($.engine):v(((I=$.install)==null?void 0:I.line)??"")},N=()=>{if(p(null),l==="chrome"||l==="chromium"){w(l);return}b.current=!0,u("installing"),x(void 0),Promise.resolve().then(()=>E.browserInstall()).then(()=>{j.current&&window.setTimeout(()=>void y(),1e3)}).catch(C=>v(C instanceof me?C.message:String(C)))},k=s==="chrome"||s==="chromium"||s==="installed",S=c==="installing"||c==="launching";return n.jsxs("div",{className:"wiz-row","data-wrap":c!=="idle"?"true":void 0,children:[n.jsx("span",{className:"wiz-glyph","data-tone":"good","aria-hidden":"true",children:n.jsx(ue,{name:"globe"})}),n.jsxs("span",{className:"wiz-row-text",children:[n.jsx("span",{className:"wiz-opt-title",children:L.reach.app.title}),n.jsx("span",{className:"wiz-opt-line",children:L.reach.app.line})]}),n.jsxs("span",{className:"wiz-row-side",children:[e?n.jsx(ve,{tone:"good",dot:!0,children:L.reach.app.installed}):i?n.jsx(T,{size:"lg",onClick:()=>{i.prompt().then(()=>i.userChoice).then(C=>{(!C||C.outcome==="accepted")&&t()}).catch(()=>{})},children:L.reach.app.install}):null,k?n.jsx(ve,{tone:"good",dot:!0,children:L.reach.app.ready(s==="chrome"?"chrome":"chromium")}):l===null||l==="other"?null:n.jsx(T,{size:"lg",disabled:S,onClick:N,children:S?L.browser.installing:c==="failed"?L.browser.retry:l==="chrome"?L.reach.app.chrome:l==="chromium"?L.reach.app.chromium:L.reach.app.fetch})]}),!e&&!i&&a?n.jsx("span",{className:"wiz-row-note",children:a}):null,c==="installing"?n.jsxs("div",{className:"wiz-row-more",children:[n.jsx("span",{className:"wiz-opt-line",children:L.browser.needs}),n.jsx(aA,{progress:g})]}):c==="launching"?n.jsx("div",{className:"wiz-row-more",children:n.jsx(Us,{line:L.browser.launching})}):c==="failed"?n.jsxs("div",{className:"wiz-row-more",children:[n.jsx("span",{className:"wiz-opt-line",children:L.browser.failed(h??"")}),m?n.jsx(vq,{command:m}):null]}):null]})}function gq({answers:e,existing:t,onSettled:s,onTrouble:r,onReload:i,onBack:a}){const[l,o]=d.useState(()=>(t==null?void 0:t.name)??v4),[c,u]=d.useState(()=>t!=null&&t.picture||t!=null&&t.avatar?null:"buddi"),[h,f]=d.useState(t?null:L.assistant.purposeValue),[m,p]=d.useState(t?"":L.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let w=!1;return E.firstAgentPersona().then(y=>{w||(f(y.persona),p(y.persona))},y=>{w||r(y instanceof me?y.message:String(y))}),()=>{w=!0}},[t==null?void 0:t.id]);const[g,x]=d.useState(!1),b=Ya.filter(w=>(e.takeOn??[]).includes(w.id)&&"mate"in w).map(w=>w.mate),j=Db.find(w=>w.id===c),v=()=>{if(l.trim()===""||g)return;x(!0);const w=!t||h!==null&&m.trim()!==""&&m.trim()!==h.trim()?{instructions:m.trim()}:{},y=t?E.updateFirstAgent({name:l.trim(),...w}):E.createFirstAgent({name:l.trim(),handle:FY(l),description:"",...w,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let N;try{N=await y}catch(S){r(S instanceof me?S.message:String(S)),x(!1);return}let k=null;try{j&&await E.uploadAgentPicture(N.id,await OT(j.role))}catch(S){k=S instanceof me?S.message:String(S)}x(!1),i(),s({...e,assistant:{id:N.id,name:l.trim(),avatar:j?"":(t==null?void 0:t.avatar)??""}}),k&&r(k)})()};return n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.assistant.title}),n.jsx(tt,{children:n.jsxs(ct,{children:[L.assistant.ask,b.length>0?L.assistant.team(b):""]})}),n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(Jn,{onClick:a,disabled:g}),n.jsx(Dl,{onClick:v,disabled:g||l.trim()===""||h===null,children:L.assistant.submit})]}),children:n.jsxs("div",{className:"wiz-meet",children:[n.jsxs("div",{className:"wiz-face",children:[n.jsx("span",{className:"wiz-face-tile","data-agent":(j==null?void 0:j.id)??"buddi","aria-hidden":"true",children:j?n.jsx("img",{src:ca(j.role),alt:""}):t!=null&&t.picture?n.jsx("img",{src:t.picture,alt:""}):n.jsx("span",{className:"wiz-face-emoji",children:(t==null?void 0:t.avatar)??""})}),n.jsx("div",{className:"wiz-swatches",role:"group","aria-label":L.assistant.colour,children:Db.map(w=>n.jsx("button",{type:"button",className:"wiz-swatch","data-agent":w.id,"aria-label":L.assistant.swatch(w.label),"aria-pressed":c===w.id,onClick:()=>u(w.id)},w.id))}),n.jsx("span",{className:"wiz-face-cap",children:L.assistant.colour})]}),n.jsxs("div",{className:"wiz-stack",children:[n.jsx(ie,{label:L.assistant.name,children:n.jsx("input",{value:l,maxLength:60,onChange:w=>o(w.target.value)})}),n.jsx(ie,{label:L.assistant.purpose,hint:L.assistant.purposeHint,children:n.jsx("textarea",{className:"wiz-persona",value:m,maxLength:8e3,rows:7,onChange:w=>p(w.target.value)})})]})]})})]})}function xq({answers:e,assistantAgent:t,met:s,onMet:r,navigate:i,onPickAnotherBrain:a,onSpoken:l,progress:o,onProgress:c}){var P;const u=e.assistant,[h,f]=d.useState(s),[m,p]=d.useState([]),[g,x]=d.useState(!1),[b,j]=d.useState(!1),[v,w]=d.useState(!0),[y,N]=d.useState(!1),k=d.useRef(!1),S=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{c()},[]),d.useEffect(()=>{if(!u||k.current)return;if(k.current=!0,s){f(s);return}let D=!1;return(async()=>{try{const O=await Be.startConversation(u.id);if(D)return;f(O.conversationId),r(O.conversationId),await E.onboardingStep(t$.handover,{conversationId:O.conversationId}).catch(()=>{}),await Be.send(u.id,{conversationId:O.conversationId,text:b4,opening:!0})}catch{D||(w(!1),x(!0))}})(),()=>{D=!0}},[u==null?void 0:u.id,s]),d.useEffect(()=>{if(!h)return;let D=!1;const O=Date.now(),M=()=>{Be.conversation(h).then(_=>{if(D)return;p(_.messages);const G=Date.now()-O;if(_.messages.some(C0)){w(!1),x(!1),j(!1);return}const B=_.runs??[],K=B.some(Q=>Q.finishedAt===null),F=B.length>0&&!K;j(K&&G>=zY),(F||G>=UY)&&(w(!1),x(!0))}).catch(()=>{})};M();const W=window.setInterval(M,a$);return()=>{D=!0,window.clearInterval(W)}},[h]);const C=u&&h?at(u.id,h):null,$=m.some(C0);d.useEffect(()=>{$&&C&&l(C)},[$,C,l]);const R=e.takeOn??[],I=Ya.filter(D=>R.includes(D.id)&&"mate"in D).map(D=>D.mate),z=L.handover.starters({days:R.includes("days"),mail:R.includes("mail"),mailbox:((P=e.reach)==null?void 0:P.mailbox)===!0},I),U=(o==null?void 0:o.waiting)??[],A=D=>{!u||!h||y||(N(!0),Promise.resolve().then(()=>Be.send(u.id,{conversationId:h,text:D})).then(()=>i(at(u.id,h),!0)).catch(()=>N(!1)))};return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"wiz-hello",children:n.jsx(fj,{messages:m,live:[],now:Date.now(),onOpen:()=>{},working:v,agents:S,agentName:(u==null?void 0:u.name)??"",...u?{agentId:u.id}:{},emptyHint:L.handover.waiting,plain:!0,workingLine:L.handover.looking((u==null?void 0:u.name)??"")})}),b&&!g?n.jsx(tt,{children:n.jsx(ct,{children:L.handover.slow})}):null,g?n.jsxs(n.Fragment,{children:[n.jsx(tt,{children:n.jsx(ct,{children:L.handover.silent})}),n.jsx(qt,{actions:n.jsx(Dl,{onClick:a,children:L.handover.again})})]}):null,$?n.jsx("div",{className:"wiz-starters",role:"group","aria-label":L.handover.starterLabel,children:z.map(D=>n.jsx("button",{type:"button",className:"wiz-starter",disabled:y,onClick:()=>A(D),children:D},D))}):null,$&&U.length>0?n.jsx(V,{tone:"warm",title:L.handover.waitingTitle(U.length),action:n.jsx(T,{variant:"accent",onClick:()=>i(sn,!0),children:L.handover.home}),children:L.handover.waitingBody(U)}):null,$&&C?n.jsx(qt,{actions:n.jsx(Tt,{variant:"accent",size:"lg",href:C,onClick:D=>{D.preventDefault(),i(C,!0)},children:L.done.open})}):null]})}function vq({command:e}){const[t,s]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){s("failed");return}navigator.clipboard.writeText(e).then(()=>s("done"),()=>s("failed"))};return n.jsxs(re,{gap:"sm",children:[n.jsx(Pt,{label:"The command to run",children:e}),n.jsxs(le,{align:"end",children:[t==="failed"?n.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,n.jsx(T,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function C0(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function jq({onCancel:e,onStarted:t,onTrouble:s}){const[r,i]=d.useState(null),[a,l]=d.useState(""),[o,c]=d.useState(!1),u=()=>{!r||o||(c(!0),s(null),E.firstRunRestore(r,a.trim()).then(h=>{fx(h.job.id),t()}).catch(h=>s(h instanceof me?h.message:String(h))).finally(()=>c(!1)))};return n.jsx(ht,{title:L.restore.sheet,onClose:e,children:n.jsxs("div",{className:"wiz-restore",children:[n.jsx("p",{className:"wiz-foot",children:L.restore.lede}),n.jsx(ie,{label:L.restore.file,children:n.jsx("input",{type:"file",onChange:h=>{var f;return i(((f=h.target.files)==null?void 0:f[0])??null)}})}),n.jsx(ie,{label:L.restore.passphrase,hint:L.restore.passphraseHint,children:n.jsx("input",{type:"password",autoComplete:"off",value:a,onChange:h=>l(h.target.value)})}),n.jsxs(le,{align:"end",children:[n.jsx(T,{variant:"ghost",onClick:e,children:L.restore.cancel}),n.jsx(T,{variant:"accent",disabled:o||!r,onClick:u,children:L.restore.submit})]})]})})}function wq({onDone:e,onFailed:t}){const[s,r]=d.useState([]),i=d.useRef({onDone:e,onFailed:t});i.current={onDone:e,onFailed:t},d.useEffect(()=>{const l=i$();if(!l)return;let o=!1;const c=()=>{E.backupJob(l).then(h=>{o||(r(f=>f.includes(h.phase)?f:[...f,h.phase]),h.phase==="done"?(o=!0,fx(null),E.owner().then(f=>i.current.onDone(f.preferredName??void 0),()=>i.current.onDone(void 0))):(h.phase==="rolled-back"||h.phase==="failed")&&(o=!0,fx(null),i.current.onFailed(h.error??L.restore.phases[h.phase])))}).catch(()=>{})};c();const u=window.setInterval(c,a$);return()=>{o=!0,window.clearInterval(u)}},[]);const a=s.filter(l=>l in L.restore.phases);return n.jsxs(n.Fragment,{children:[n.jsx(Ol,{children:L.restore.title}),n.jsxs(tt,{children:[n.jsx(ct,{children:L.restore.started}),a.map(l=>n.jsx(ct,{children:L.restore.phases[l]},l))]}),n.jsx(Us,{})]})}function yq(e){return n.jsx(ow.Provider,{value:null,children:n.jsx("div",{className:"wiz-sheet-body",children:n.jsx(bq,{...e})})})}function bq({onPaired:e,onDismiss:t}){const s=Ml(),[r,i]=d.useState(""),[a,l]=d.useState(!1),[o,c]=d.useState(null),{offer:u,square:h,paired:f,stale:m,ask:p}=iw(()=>E.telegram().then(b=>b.paired),e),g=()=>{r.trim()===""||a||(l(!0),c(null),(async()=>{try{const b=await E.saveTelegramToken(r.trim());if(i(""),b.restartNeeded){c(b.note??L.telegram.restart);return}await p()}catch(b){c(b instanceof me?b.message:String(b))}finally{l(!1)}})())},x=()=>{c(null),p().catch(b=>c(b instanceof me?b.message:String(b)))};return f?n.jsxs(n.Fragment,{children:[n.jsx(tt,{children:n.jsx(ct,{children:L.telegram.paired})}),n.jsx(qt,{actions:n.jsx(T,{variant:"accent",onClick:t,children:L.telegram.close})})]}):u?n.jsxs(n.Fragment,{children:[n.jsx(tt,{children:n.jsx(ct,{children:m?L.telegram.expired:L.telegram.scan})}),n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:L.telegram.notNow}),m?n.jsx(T,{variant:"accent",onClick:x,children:L.telegram.newCode}):null]}),children:m?null:n.jsx(aw,{offer:u,square:h})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(tt,{children:[n.jsx(ct,{children:L.telegram.how}),o?n.jsx(ct,{children:o}):null]}),n.jsx(qt,{actions:n.jsxs(n.Fragment,{children:[n.jsx(T,{variant:"ghost",onClick:t,children:L.telegram.notNow}),n.jsx(T,{variant:"accent",disabled:a||r.trim()==="",onClick:g,children:L.telegram.submit})]}),children:n.jsx(ie,{label:L.telegram.field,grow:!0,children:n.jsx("input",{ref:s,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),g())}})})})]})}const zm={recovery:0,lost:1,paused:2},kq="Lost buddi. Retrying…",Nq="The queue is paused. Nothing is being claimed until you resume it.";function Sq(e){const t=[];return e.recovery&&t.push({id:"recovery",priority:zm.recovery,tone:"warning",text:IV,action:{label:"Finish the checklist",href:mF}}),e.lost&&t.push({id:"lost",priority:zm.lost,tone:"critical",text:kq}),e.paused&&t.push({id:"paused",priority:zm.paused,tone:"warning",text:Nq,action:{label:"Resume",onClick:()=>{E.setPaused(!1).catch(()=>{})}}}),t}function Cq({banners:e,onNavigate:t}){if(e.length===0)return null;const s=[...e].sort((l,o)=>l.priority-o.priority),r=s[0],i=s.slice(1),a=r.action;return n.jsxs("div",{className:"shell-banner",role:"status","data-tone":r.tone,"data-banner":r.id,children:[n.jsx("span",{className:"shell-banner-dot","aria-hidden":"true"}),n.jsx("span",{className:"shell-banner-text",children:r.text}),i.length>0?n.jsxs("span",{className:"shell-banner-more",title:i.map(l=>l.text).join(`
|
|
129
|
+
`),children:["+",i.length," more"]}):null,a!=null&&a.href?n.jsx(Tt,{size:"sm",href:a.href,onClick:l=>{l.preventDefault(),t(a.href)},children:a.label}):a?n.jsx(T,{size:"sm",onClick:a.onClick,children:a.label}):null]})}const c$=1e4,Eq=3e4,u$=6e3,cw=/^(localhost|127(?:\.\d{1,3}){3}|\[?::1\]?)$|\.localhost$/i;function Aq(e){return cw.test(e)?n.jsxs(n.Fragment,{children:["Is buddi running on this Mac? ",n.jsx("code",{children:"buddi status"})," says."]}):n.jsx(n.Fragment,{children:"Is Tailscale on, and the Mac it runs on awake?"})}async function d$(e){let t;const s=new Promise((r,i)=>{t=setTimeout(()=>i(new me(0,Td)),e)});try{return{up:!0,version:await Promise.race([E.version(),s])}}catch(r){return Rd(r)?{up:!1}:{up:!0}}finally{clearTimeout(t)}}function h$(e){var t;return e.up&&Yv((t=e.version)==null?void 0:t.web)?(window.location.reload(),!1):e.up}function Tq({host:e,onRetry:t,retrying:s}){return n.jsxs("main",{className:"unreachable",role:"alert",children:[n.jsx("span",{className:"ui-blob","data-size":"lg","aria-hidden":"true",children:n.jsx("img",{src:ca("core"),alt:""})}),n.jsxs("h1",{children:["buddi isn't answering at ",e,"."]}),n.jsx("p",{children:Aq(e.replace(/:\d+$/,""))}),n.jsx("div",{className:"unreachable-actions",children:n.jsx(T,{variant:"accent",onClick:t,disabled:s,children:s?"Retrying…":"Retry"})})]})}function Rq({children:e}){const[t,s]=d.useState("checking"),[r,i]=d.useState(!1),a=d.useRef(!1),l=d.useCallback(async()=>{if(a.current)return;a.current=!0,i(!0);const o=await d$(u$);a.current=!1,i(!1),s(c=>c==="checking"?o.up?"up":"down":h$(o)?"up":"down")},[]);return d.useEffect(()=>{l()},[l]),d.useEffect(()=>{if(t!=="down")return;const o=window.setInterval(()=>void l(),c$);return()=>window.clearInterval(o)},[t,l]),t==="checking"?null:t==="down"?n.jsx(Tq,{host:window.location.host,onRetry:()=>void l(),retrying:r}):n.jsx(n.Fragment,{children:e})}function $q(e=Eq){const[t,s]=d.useState(!1);return d.useEffect(()=>{let r;const i=()=>{clearTimeout(r);const l=Jo();if(l===null)return s(!1);const o=l+e-Date.now();o<=0?s(!0):r=setTimeout(i,o)};i();const a=Av(i);return()=>{a(),clearTimeout(r)}},[e]),t}function Iq(){const e=$q();return d.useEffect(()=>{if(!e)return;const t=window.setInterval(()=>{d$(u$).then(h$)},c$);return()=>window.clearInterval(t)},[e]),e}const Pq={local:"Local",tailnet:"Tailnet",reconnecting:"Reconnecting…"},E0=(e,t,s=`${t}s`)=>e===1?t:s;function Mq(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function Dq(e){return e.includes("/")?e.split("/").pop().replace(/_/g," "):e}function Oq(e,t){return t?"reconnecting":cw.test(e)?"local":"tailnet"}function f$(e,t,s=Mq()){const r=[],i=Pq[e.link];if(r.push({key:"link",route:De("system"),dot:e.link==="reconnecting"?"warning":"good",text:i,label:`Connection: ${i}`}),e.focus){const u=`${Wi[e.focus.mode]} ${cc(e.focus,e.timezone,t)}`;r.push({key:"focus",route:De("notifications"),icon:"moon",text:u,label:`Focus: ${u}`})}const a=[];if(e.working>0&&a.push({key:"working",dot:"working",text:`${e.working} ${E0(e.working,"agent")} working`}),a.push(e.paused?{key:"queue",tone:"warning",text:"Queue paused"}:{key:"queue",text:"Queue running"}),e.failed>0&&a.push({key:"failed",tone:"critical",text:`${e.failed} failed`}),r.push({key:"work",route:e.failed>0?`${vt}/jobs?state=failed`:`${vt}/jobs`,parts:a,label:`Work: ${a.map(u=>u.text).join(", ")}`}),e.approvals>0){const u=`${E0(e.approvals,"approval")} waiting`;r.push({key:"approvals",route:Lh,count:e.approvals,text:u,label:`${e.approvals} ${u}`})}if(e.version){const u=e.version.updateAvailable&&e.version.latest?e.version.latest:null;r.push({key:"version",route:De("system"),end:!0,mono:`buddi ${e.version.current}`,update:u!==null,label:`buddi ${e.version.current}${u?`, a newer buddi is ready: ${u}`:""}`})}const l=e.timezone||s,o=Ht(t,l),c=l!==s;return r.push({key:"time",route:De("you"),end:!0,time:o,...c?{zone:Dq(l)}:{},label:`Your time: ${o}${c?`, ${l}`:""}`}),r}function Lq(e){var t;return e.link==="reconnecting"||e.failed>0?"critical":e.paused?"warning":e.approvals>0||(((t=e.version)==null?void 0:t.updateAvailable)??!1)?"attention":"good"}function m$(){const[e,t]=d.useState(()=>new Date);return d.useEffect(()=>{let s;const r=()=>{s=setTimeout(()=>{t(new Date),r()},6e4-Date.now()%6e4)};return r(),()=>clearTimeout(s)},[]),e}function _q(){const[e,t]=d.useState(()=>Jo()!==null);return d.useEffect(()=>Av(()=>t(Jo()!==null)),[]),e}function p$({item:e}){var t;return n.jsxs(n.Fragment,{children:[e.dot?n.jsx("span",{className:"shell-status-dot","data-tone":e.dot,"aria-hidden":"true"}):null,e.icon?n.jsx(ue,{name:e.icon,size:12}):null,e.count?n.jsx("span",{className:"ui-badge","aria-hidden":"true",children:e.count>99?"99+":e.count}):null,(t=e.parts)==null?void 0:t.map((s,r)=>n.jsxs(d.Fragment,{children:[r>0?n.jsx("span",{className:"shell-status-sep","aria-hidden":"true",children:"·"}):null,s.dot?n.jsx("span",{className:"shell-status-dot","data-tone":s.dot,"aria-hidden":"true"}):null,n.jsx("span",{"data-tone":s.tone,children:s.text})]},s.key)),e.text?n.jsx("span",{children:e.text}):null,e.mono?n.jsx("span",{className:"shell-status-mono",children:e.mono}):null,e.update?n.jsx("span",{className:"ui-badge","data-kind":"dot","data-testid":"status-update-dot","aria-hidden":"true"}):null,e.time?n.jsx("span",{className:"shell-status-time",children:e.time}):null,e.zone?n.jsx("span",{className:"shell-status-zone",children:e.zone}):null]})}function Fq({status:e,onNavigate:t}){const s=m$(),r=Zh(),i=f$(e,s),a=l=>n.jsx("a",{className:"shell-status-item","data-item":l.key,href:l.route,"aria-label":l.label,title:l.label,onClick:o=>{o.preventDefault(),t(l.route)},children:n.jsx(p$,{item:l})},l.key);return n.jsxs("footer",{className:"shell-status","aria-label":"Status",children:[i.filter(l=>!l.end).map(a),n.jsx("span",{className:"shell-status-spacer"}),i.filter(l=>l.end).map(a),r.pin?n.jsx("button",{type:"button",className:"shell-status-item shell-status-lock","data-item":"lock","aria-label":`Lock now (${r.shortcut})`,title:`Lock now (${r.shortcut})`,onClick:()=>r.lockNow(),children:n.jsx(ue,{name:"lock",size:13})}):null]})}function zq({status:e,onNavigate:t}){const s=m$(),r=Zh(),i=Lq(e);return n.jsx("div",{className:"rail-status",children:n.jsxs(bc,{modal:!1,children:[n.jsx(kc,{asChild:!0,children:n.jsx("button",{type:"button",className:"rail-status-btn","aria-label":"Status",children:n.jsx("span",{className:"rail-status-dot","data-tone":i,"data-testid":"rail-status-dot","aria-hidden":"true"})})}),n.jsx(Nl,{children:n.jsxs(Nc,{className:"ui-menu rail-status-menu",side:"right",align:"end",sideOffset:10,children:[n.jsx(ta,{className:"ui-menu-label",children:"Status"}),f$(e,s).map(a=>n.jsx(us,{asChild:!0,onSelect:()=>t(a.route),children:n.jsx("a",{className:"ui-menu-item rail-status-item","data-item":a.key,href:a.route,"aria-label":a.label,children:n.jsx("span",{className:"rail-status-line",children:n.jsx(p$,{item:a})})})},a.key)),r.pin?n.jsxs(n.Fragment,{children:[n.jsx(Nr,{className:"ui-menu-sep"}),n.jsx(us,{className:"ui-menu-item rail-status-item","data-item":"lock",onSelect:()=>r.lockNow(),children:n.jsxs("span",{className:"rail-status-line",children:[n.jsx(ue,{name:"lock",size:12}),n.jsx("span",{children:"Lock now"})]})})]}):null]})})]})})}const Uq=1e4;function g$(){return d.useSyncExternalStore(HF,Ib,Ib)}function Bq(e){switch(e.kind){case"plugins":return{title:"Restarting buddi",line:e.line??"Loading your plugins…"};case"upgrade":return{title:"Upgrading buddi",line:e.line??"Upgrading…"};case"restore":return{title:"Restoring buddi",line:e.line??"Putting your backup in place…"};case"recovery":return{title:"Restarting buddi",line:e.line??"Turning schedules, watchers and the phone back on…"};case"stop":return{title:"buddi is stopped",line:"This page comes back by itself once buddi is started again."};default:return{title:"Restarting buddi",line:e.line??"Back in a few seconds…"}}}function A0(e){const t=Math.max(0,Math.floor(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Wq({command:e}){const[t,s]=d.useState(!1);return d.useEffect(()=>{if(!t)return;const r=window.setTimeout(()=>s(!1),1600);return()=>window.clearTimeout(r)},[t]),n.jsxs("div",{className:"rs-cmd",children:[n.jsx("code",{className:"rs-cmd-text",children:e}),n.jsx(T,{size:"sm",onClick:()=>{var r;(r=navigator.clipboard)==null||r.writeText(e).then(()=>s(!0),()=>{})},children:t?"Copied":"Copy"})]})}function Hq({state:e,elapsedMs:t,hostname:s=window.location.hostname,onReload:r=()=>Ga.reload()}){const i=Bq(e),a=e.kind==="stop",l=!a&&t>=(e.patienceMs??FF),o=cw.test(s),c=d.useRef(null);d.useEffect(()=>{var h;return(h=c.current)==null?void 0:h.focus()},[]);const u=a?o?"This starts it again, in Terminal on this computer:":"On the computer buddi runs on, this starts it again:":o?"This says what it’s doing, in Terminal on this computer:":"On the computer buddi runs on, this says what it’s doing. Is that computer awake, and Tailscale on?";return n.jsx("div",{className:"ui-fieldbg rs-field","data-quiet":"true",children:n.jsx("div",{ref:c,className:"rs",role:"dialog","aria-modal":"true","aria-labelledby":"rs-title",tabIndex:-1,"data-state":a?"stopped":l?"long":"waiting",children:n.jsxs("div",{className:"rs-body",children:[n.jsx("span",{className:"ui-mascot rs-blob","data-size":"lg","aria-hidden":"true",children:n.jsx(Ec,{role:"core",state:a||l?"idle":"working",className:"ui-mascot-blob"})}),n.jsx("h1",{id:"rs-title",className:"rs-title",children:i.title}),n.jsx("p",{className:"rs-line",role:"status",children:l?"Still waiting — buddi may need a hand.":i.line}),!l&&e.step?n.jsx("p",{className:"rs-step",children:e.step}):null,a||l?null:n.jsx("div",{className:"rs-track","aria-hidden":"true",children:n.jsx("span",{})}),a||l?n.jsxs("div",{className:"rs-help",children:[n.jsx("p",{className:"rs-help-line",children:u}),n.jsx(Wq,{command:a?"buddi service start":"buddi status"})]}):null,n.jsxs("div",{className:"rs-foot",children:[n.jsx("span",{className:"rs-meta",children:a?"Checking every few seconds.":l?`${A0(t)} · still checking every few seconds`:t>=Uq?`${A0(t)} · this page reloads when buddi is back`:"This page reloads when buddi is back."}),a||l?n.jsx(T,{size:"sm",variant:l?"accent":void 0,onClick:r,children:"Reload"}):null]})]})})})}function Kq(e){const[t,s]=d.useState(()=>Ga.now());return d.useEffect(()=>{if(!e)return;s(Ga.now());const r=window.setInterval(()=>s(Ga.now()),1e3);return()=>window.clearInterval(r)},[e]),e?Math.max(0,t-e.startedAt):0}function Vq({children:e}){const t=g$(),s=Kq(t),r=d.useRef(null);return d.useEffect(()=>{VF();let i=Jo()!==null;const a=Av(()=>{const o=Jo()!==null;i&&!o&&Pb(),i=o}),l=()=>void Pb();return window.addEventListener(ec,l),()=>{a(),window.removeEventListener(ec,l)}},[]),d.useEffect(()=>{const i=r.current;i&&(i.toggleAttribute("inert",t!==null),t?i.setAttribute("aria-hidden","true"):i.removeAttribute("aria-hidden"))},[t]),n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:r,className:"rs-host",children:e}),t?n.jsx(Hq,{state:t,elapsedMs:s}):null]})}const Gq="(max-width: 1080px)",Yq="(max-width: 720px)";function qq(){const[e,t]=d.useState(()=>window.location.hash||sn);d.useEffect(()=>{const r=()=>t(window.location.hash||sn);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const s=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,s]}function Qq(){const[e,t]=fT();d.useEffect(()=>{hT(e)},[e]);const s=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,s]}const T0=new Map;function Xq(){var ys,wn,bs,ks;const[e,t]=qq(),[s,r]=d.useState("UTC"),[i,a]=d.useState({approvals:0,failed:0,paused:!1,running:0}),[l,o]=Qq(),c=Ps(nj),[u,h]=d.useState(!1),[f,m]=d.useState([]),[p,g]=d.useState(null),[x,b]=d.useState(null),[j,v]=d.useState([]),[w,y]=d.useState(!1),[N,k]=d.useState(null),[S,C]=d.useState(null),[$,R]=d.useState(0),[I,z]=d.useState(null),U=e4(),A=f.find(ye=>ye.id===p)??null,P=A!==null&&KB(e),[D,O]=d.useState(!1),M=d.useCallback(()=>O(!0),[]);d.useEffect(()=>{P||O(!1)},[P]),eH(t,Gu(e)===null,P?M:void 0);const W=Ps(Gq),_=UT(),G=BE(),B=lT(),K=ce(()=>Promise.resolve().then(()=>E.version()),[],AF),F=K.data;LF(K.reload);const Q=F&&!F.checkout&&F.updateAvailable?F:null,X=Yv(F==null?void 0:F.web);_F(F==null?void 0:F.web);const Z=((ys=ce(()=>Promise.resolve().then(()=>E.connectionSignals()),[],6e4).data)==null?void 0:ys.signals)??[],[de,_e]=d.useState(null),Ie=d.useMemo(()=>new Set(de?[de]:[]),[de]),[Ue,ee]=d.useState(new Map);d.useEffect(()=>{const ye=()=>{E.conversations().then(Ke=>{const fe=new Map;for(const Un of Ke.conversations){const Rn=Un.lastMessageAt??Un.createdAt,Ws=fe.get(Un.agentId);(!Ws||Rn>Ws)&&fe.set(Un.agentId,Rn)}ee(fe)}).catch(()=>{})};ye();const Ce=window.setInterval(ye,3e4);return()=>window.clearInterval(Ce)},[e]);const[be,se]=d.useState(!1);d.useEffect(()=>{if(be)return;let ye=!1;return E.onboarding().then(Ce=>{ye||(se(!0),Ce.state==="pending"&&Ce.needs.model&&!Gu(window.location.hash)&&t(Y_,!0))}).catch(()=>{ye||se(!0)}),()=>{ye=!0}},[be,t]),d.useEffect(()=>{const ye=pF(e);ye&&t(ye,!0)},[e,t]),d.useEffect(()=>{let ye=!1;const Ce=()=>{Be.agents().then(fe=>{ye||(m(fe.agents),bF(fe.defaultAgentId??null),g(fe.defaultAgentId??null),b(Un=>{var Rn;return Un??fe.defaultAgentId??((Rn=fe.agents[0])==null?void 0:Rn.id)??null}))}).catch(()=>{})};Ce();const Ke=window.setInterval(Ce,15e3);return window.addEventListener("focus",Ce),window.addEventListener(Xo,Ce),()=>{ye=!0,window.clearInterval(Ke),window.removeEventListener("focus",Ce),window.removeEventListener(Xo,Ce)}},[e]),d.useEffect(()=>{let ye=!1;const Ce=()=>{Be.groups().then(fe=>{ye||v(fe.groups)}).catch(()=>{})};Ce();const Ke=window.setInterval(Ce,3e4);return()=>{ye=!0,window.clearInterval(Ke)}},[e]);const Te=oE(f,p),pe=Q_(e),Re=q1(e),Se=Re?j.find(ye=>ye.id===Re.groupId)??null:null,Fe=Re?null:(pe==null?void 0:pe.agentId)??x;d.useEffect(()=>{pe&&b(pe.agentId)},[pe==null?void 0:pe.agentId]);const Ze=d.useRef(null);pe&&(Ze.current=e);const Ee=ye=>{b(ye),t(at(ye))},ze=ye=>t(Oi(ye)),nt=d.useCallback((ye,Ce,Ke=!0)=>t(Re?Oi(Re.groupId,Ce):at(ye,Ce),Ke),[t,Re==null?void 0:Re.groupId]),[Ye,J]=d.useState(!1),[,je]=d.useState(0);d.useEffect(()=>{const ye=()=>{je(Ce=>Ce+1),E.session().then(Ce=>r(Ce.timezone)).catch(()=>{})};return window.addEventListener(Vp,ye),()=>window.removeEventListener(Vp,ye)},[]),d.useEffect(()=>{E.session().then(ye=>{Sv({timeFormat:ye.timeFormat??null,dateFormat:ye.dateFormat??null}),r(ye.timezone),J(!0)}).catch(()=>{})},[]);const Ge=e5(Ye);i5(Ye,Ge.refresh,()=>J(!1)),d.useEffect(()=>{const ye=()=>{E.overview().then(Ke=>a({approvals:Ke.approvals.pending,failed:Ke.jobs.failed??0,paused:Ke.paused,running:Ke.running??0})).catch(()=>{})};ye();const Ce=window.setInterval(ye,2e4);return window.addEventListener(Bi,ye),()=>{window.clearInterval(Ce),window.removeEventListener(Bi,ye)}},[]);const lt=ce(()=>Promise.resolve().then(()=>E.focus()),[],6e4),ot=d.useRef(lt.reload);ot.current=lt.reload,d.useEffect(()=>{const ye=()=>ot.current();return window.addEventListener(Bi,ye),()=>window.removeEventListener(Bi,ye)},[]);const q=_q(),ft=Iq(),yt=g$()!==null,zn=Ps(Yq);d.useEffect(()=>{if(!Ye)return;if(e===gF){y(!0),t(ci,!0);return}const ye=xF(e),Ce=new Date().toDateString();!ye||T0.get(ye)===Ce||(T0.set(ye,Ce),E.tipsSeenPage(ye).catch(()=>{}))},[e,Ye,t]);const Bs={link:Oq(window.location.hostname,q&&!yt),focus:((wn=lt.data)==null?void 0:wn.focus)??null,working:i.running,paused:i.paused,failed:i.failed,approvals:i.approvals,version:F?{current:F.current,latest:F.latest,updateAvailable:!F.checkout&&F.updateAvailable}:void 0,timezone:s},Y=Sq({recovery:((bs=_.data)==null?void 0:bs.active)===!0,lost:ft&&!yt,paused:i.paused}),$e=Gu(e),Je=nE(e),bt=Je===ci,gt=N?j.find(ye=>ye.id===N.groupId)??null:null,we=ye=>v(Ce=>Ce.map(Ke=>Ke.id===ye.id?ye:Ke)),We=()=>k(null),Le=w?n.jsx(a5,{agents:f,onClose:()=>y(!1),onCreated:ye=>{v(Ce=>[...Ce,ye]),y(!1),t(Oi(ye.id))}}):gt&&(N==null?void 0:N.kind)==="members"?n.jsx($B,{group:gt,agents:f,onClose:We,onSaved:we}):gt&&(N==null?void 0:N.kind)==="rename"?n.jsx(IB,{group:gt,onClose:We,onSaved:ye=>{we(ye),We()}}):gt&&(N==null?void 0:N.kind)==="clear"?n.jsx(MB,{group:gt,onClose:We,onCleared:()=>{We(),R(ye=>ye+1),t(Oi(gt.id),!0)}}):gt&&(N==null?void 0:N.kind)==="delete"?n.jsx(DB,{group:gt,agents:f,onClose:We,onDeleted:ye=>{const Ce=j.findIndex(Ke=>Ke.id===gt.id);We(),v(Ke=>Ke.filter(fe=>fe.id!==gt.id)),C({group:gt,index:Ce,until:ye}),t(Ze.current??ci)}}):null,Xt=()=>{const ye=S;ye&&(C(null),Be.restoreGroup(ye.group.id).then(Ce=>{v(Ke=>{if(Ke.some(Un=>Un.id===Ce.id))return Ke;const fe=[...Ke];return fe.splice(Math.min(Math.max(ye.index,0),fe.length),0,Ce),fe}),t(Oi(Ce.id))}).catch(()=>z(ye.group.name)))};return $e?n.jsx(hb,{delayDuration:400,children:n.jsxs(Zy,{swipeDirection:"right",children:[n.jsx(KY,{navigate:t,timezone:s}),n.jsx(eb,{className:"ui-toasts"})]})}):n.jsx(T4,{picture:(ks=f.find(ye=>ye.id===p))==null?void 0:ks.picture,children:n.jsx(hb,{delayDuration:400,children:n.jsxs(Zy,{swipeDirection:"right",children:[Le,n.jsxs("div",{className:"wb-shell",children:[n.jsx(Cq,{banners:Y,onNavigate:t}),n.jsxs("div",{className:"wb",children:[n.jsx(BW,{attention:i.approvals+i.failed,place:Je,onNavigate:t,theme:l,onTheme:o,plugins:JW(G.rail,B),updateAvailable:Q!==null,settingsDot:Z.length>0?aT:void 0,stale:X,timezone:s,version:F&&!F.checkout?{current:F.current,latest:F.latest,updateAvailable:F.updateAvailable}:F?{current:F.current,updateAvailable:!1}:void 0,status:zn?n.jsx(zq,{status:Bs,onNavigate:t}):void 0}),bt&&!W?n.jsx(fE,{agents:Te,currentId:Fe,attention:U,onSelect:Ee,lastActivity:Ue,working:Ie,groups:j,currentGroupId:(Se==null?void 0:Se.id)??null,onSelectGroup:ze,onNewGroup:()=>y(!0)}):null,bt?n.jsx(OB,{timezone:s,agents:Te,agentId:Se?Se.coordinator:Fe,defaultAgentId:p,group:Se,...Se?{onGroupAction:ye=>k({kind:ye,groupId:Se.id})}:{},requestedConversationId:(Re==null?void 0:Re.conversationId)??(pe==null?void 0:pe.conversationId),requestedTab:pe==null?void 0:pe.tab,onConversationOpened:nt,onSelectAgent:Ee,onWorking:_e,attention:U,agentsInHeader:W,narrow:c,canvasOpen:u,onOpenCanvas:()=>h(!0),onCloseCanvas:()=>h(!1)},`room-${$}`):n.jsx("main",{"data-ground":Jq(Je,e)?"plain":void 0,"data-layout":Je===en?"split":void 0,children:n.jsx(Zq,{hash:e,place:Je,timezone:s,navigate:t,agents:f,defaultAgentId:p,attention:U,pluginPages:G,update:Q,connectionSignals:Z})})]}),zn?null:n.jsx(Fq,{status:Bs,onNavigate:t})]}),P&&A?n.jsx(VB,{agent:A,agents:f,open:D,onOpenChange:O,navigate:t}):null,n.jsxs(JB,{placement:XB(P,D),children:[n.jsx(t5,{queue:Ge.queue,agents:f,navigate:t,onDismiss:Ge.dismiss}),S?n.jsx(Bd,{title:`Deleted ${S.group.name}`,body:"Its history goes for good in a few seconds.",duration:o5,onUndo:Xt,onGone:()=>C(null)},S.group.id):null,I?n.jsx(Bd,{title:`${I} is gone for good`,body:"Undo came too late to bring it back.",duration:6e3,onGone:()=>z(null)},`late-${I}`):null,n.jsx(eb,{className:"ui-toasts"})]})]})})})}function Jq(e,t){return Wv(t)!==null}function Zq({place:e,pluginPages:t,...s}){const r={...s,pluginPages:t},i=Wv(s.hash);if(i){const a=t.find(i.plugin,i.page);if(a)return n.jsx(Aj,{page:a,item:i.item??null,params:Q1(s.hash),navigate:s.navigate,timezone:s.timezone,siblings:t.all.filter(l=>l.plugin===i.plugin)});if(t.all.length===0)return n.jsx(n.Fragment,{})}switch(e){case Et:return n.jsx(GK,{...s});case vt:return n.jsx(jH,{...s});case en:return n.jsx(mY,{...r});case Or:return n.jsx(y8,{...s});default:return n.jsx(dV,{...s})}}function eQ(){"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=`./sw.js?v=${encodeURIComponent(Gv)}`;navigator.serviceWorker.register(e,{scope:"./"}).catch(()=>{})})}function tQ({search:e=location.search}){const[t,s]=d.useState(null),r=d.useRef(!1);return d.useEffect(()=>{if(r.current)return;r.current=!0;const i=new URLSearchParams(e);try{history.replaceState(null,"",location.pathname)}catch{}const a=i.get("state")??"",l=i.get("code")??void 0,o=i.get("error")??void 0;E.connectionCallback({state:a,...l?{code:l}:{},...o?{error:o}:{}}).then(c=>{s({ok:!0,name:c.name,cli:c.cli===!0});try{const u=new BroadcastChannel(IT);u.postMessage({id:c.id}),u.close()}catch{}window.setTimeout(()=>{try{window.close()}catch{}},1500)}).catch(c=>s({ok:!1,message:c instanceof Error?c.message:String(c)}))},[e]),n.jsx("main",{className:"ui-page connections-callback",children:n.jsxs(re,{gap:"lg",children:[n.jsx("h2",{className:"ui-page-title",children:"Connections"}),t===null?n.jsx(V,{tone:"accent",role:"status",children:"Finishing the sign-in…"}):null,t!=null&&t.ok?n.jsxs(V,{tone:"good",role:"status",title:`Signed in to ${t.name}`,children:["buddi keeps the sign-in in its vault. You can close this tab; ",t.cli?"the terminal carries on.":"the other one carries on."]}):null,t&&!t.ok?n.jsx(V,{tone:"critical",role:"alert",title:"Nothing was connected",children:t.message}):null,t?n.jsx(Tt,{href:"/#/settings/connections",children:"Back to Connections"}):null]})})}const R0=document.getElementById("root");R0&&WS(R0).render(n.jsx(d.StrictMode,{children:location.pathname==="/connections/callback"?n.jsx(tQ,{}):n.jsx(Vq,{children:n.jsx(Rq,{children:n.jsx(UW,{children:n.jsx(Xq,{})})})})}));eQ();export{sQ as c,P$ as g};
|