@withbuddi/buddi 0.1.0-pre.19 → 0.1.0-pre.21
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 +1 -1
- package/node_modules/@buddi/cli/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/cli/dist/args.d.ts +6 -0
- package/node_modules/@buddi/cli/dist/args.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/args.js +15 -0
- 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 +18 -1
- package/node_modules/@buddi/cli/dist/commands.js.map +1 -1
- package/node_modules/@buddi/cli/dist/main.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/main.js +19 -2
- package/node_modules/@buddi/cli/dist/main.js.map +1 -1
- package/node_modules/@buddi/cli/dist/status.d.ts +10 -0
- package/node_modules/@buddi/cli/dist/status.d.ts.map +1 -1
- package/node_modules/@buddi/cli/dist/status.js +4 -0
- package/node_modules/@buddi/cli/dist/status.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 -1
- package/node_modules/@buddi/core/dist/agents/catalog.js.map +1 -1
- package/node_modules/@buddi/core/dist/host/build.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/host/build.js +33 -16
- package/node_modules/@buddi/core/dist/host/build.js.map +1 -1
- package/node_modules/@buddi/core/dist/host/types.d.ts +17 -0
- package/node_modules/@buddi/core/dist/host/types.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js +1 -0
- package/node_modules/@buddi/core/dist/pages/__fixtures__/demo.js.map +1 -1
- package/node_modules/@buddi/core/dist/pages.d.ts +74 -0
- package/node_modules/@buddi/core/dist/pages.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/pages.js +27 -1
- package/node_modules/@buddi/core/dist/pages.js.map +1 -1
- package/node_modules/@buddi/core/dist/plugin/index.d.ts +2 -2
- package/node_modules/@buddi/core/dist/plugin/index.d.ts.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/provider-accounts.d.ts +15 -1
- package/node_modules/@buddi/core/dist/provider-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/provider-accounts.js +22 -1
- package/node_modules/@buddi/core/dist/provider-accounts.js.map +1 -1
- package/node_modules/@buddi/core/dist/provider.d.ts +6 -0
- package/node_modules/@buddi/core/dist/provider.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/provider.js.map +1 -1
- package/node_modules/@buddi/core/dist/surfaces.d.ts +11 -0
- package/node_modules/@buddi/core/dist/surfaces.d.ts.map +1 -1
- package/node_modules/@buddi/core/dist/surfaces.js +4 -0
- package/node_modules/@buddi/core/dist/surfaces.js.map +1 -1
- package/node_modules/@buddi/core/migrations/046_ollama_device_key.sql +7 -0
- package/node_modules/@buddi/core/migrations/047_reported_context_windows.sql +5 -0
- package/node_modules/@buddi/core/migrations/048_surface_chat_voice.sql +13 -0
- package/node_modules/@buddi/core/migrations/049_surface_chat_voice_form.sql +8 -0
- package/node_modules/@buddi/gateway/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/gateway/dist/agents-cli.d.ts +2 -0
- package/node_modules/@buddi/gateway/dist/agents-cli.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/agents-cli.js +5 -3
- package/node_modules/@buddi/gateway/dist/agents-cli.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/session.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/session.js +2 -2
- package/node_modules/@buddi/gateway/dist/chat/session.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/usage.d.ts +16 -0
- package/node_modules/@buddi/gateway/dist/chat/usage.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/chat/usage.js +53 -11
- package/node_modules/@buddi/gateway/dist/chat/usage.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts +24 -11
- package/node_modules/@buddi/gateway/dist/codex-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/codex-accounts.js +151 -215
- package/node_modules/@buddi/gateway/dist/codex-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/index.d.ts +2 -0
- package/node_modules/@buddi/gateway/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/index.js +2 -0
- package/node_modules/@buddi/gateway/dist/index.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/ollama-accounts.d.ts +87 -0
- package/node_modules/@buddi/gateway/dist/ollama-accounts.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/ollama-accounts.js +179 -0
- package/node_modules/@buddi/gateway/dist/ollama-accounts.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts +51 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/provider-accounts.js +184 -25
- package/node_modules/@buddi/gateway/dist/provider-accounts.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/speech-cli.d.ts +43 -0
- package/node_modules/@buddi/gateway/dist/speech-cli.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/speech-cli.js +105 -0
- package/node_modules/@buddi/gateway/dist/speech-cli.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/surfaces/context-budget.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/surfaces/context-budget.js +10 -3
- package/node_modules/@buddi/gateway/dist/surfaces/context-budget.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/api.d.ts +10 -0
- package/node_modules/@buddi/gateway/dist/telegram/api.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/api.js +12 -0
- package/node_modules/@buddi/gateway/dist/telegram/api.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts +2 -1
- package/node_modules/@buddi/gateway/dist/telegram/browser-view.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/browser-view.js +4 -2
- package/node_modules/@buddi/gateway/dist/telegram/browser-view.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/main.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/main.js +10 -2
- package/node_modules/@buddi/gateway/dist/telegram/main.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts +25 -0
- package/node_modules/@buddi/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/surface.js +212 -10
- package/node_modules/@buddi/gateway/dist/telegram/surface.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts +112 -0
- package/node_modules/@buddi/gateway/dist/telegram/voice.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/telegram/voice.js +220 -0
- package/node_modules/@buddi/gateway/dist/telegram/voice.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/chat.d.ts +31 -8
- package/node_modules/@buddi/gateway/dist/web/chat.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/chat.js +3 -2
- package/node_modules/@buddi/gateway/dist/web/chat.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts +13 -2
- package/node_modules/@buddi/gateway/dist/web/onboarding.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/onboarding.js +24 -3
- package/node_modules/@buddi/gateway/dist/web/onboarding.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.d.ts +15 -12
- package/node_modules/@buddi/gateway/dist/web/read.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/read.js +9 -10
- package/node_modules/@buddi/gateway/dist/web/read.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/server.js +29 -13
- package/node_modules/@buddi/gateway/dist/web/server.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/speech.d.ts +47 -0
- package/node_modules/@buddi/gateway/dist/web/speech.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/speech.js +83 -0
- package/node_modules/@buddi/gateway/dist/web/speech.js.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/stream.d.ts +0 -24
- package/node_modules/@buddi/gateway/dist/web/stream.d.ts.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/stream.js +26 -2
- package/node_modules/@buddi/gateway/dist/web/stream.js.map +1 -1
- package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts +15 -0
- package/node_modules/@buddi/gateway/dist/web/usage-view.d.ts.map +1 -0
- package/node_modules/@buddi/gateway/dist/web/usage-view.js +20 -0
- package/node_modules/@buddi/gateway/dist/web/usage-view.js.map +1 -0
- 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 +18 -0
- package/node_modules/@buddi/runtime/dist/anthropic.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/anthropic.js +65 -13
- package/node_modules/@buddi/runtime/dist/anthropic.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts +55 -0
- package/node_modules/@buddi/runtime/dist/codex-direct.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/codex-direct.js +342 -0
- package/node_modules/@buddi/runtime/dist/codex-direct.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts +66 -0
- package/node_modules/@buddi/runtime/dist/codex-oauth.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/codex-oauth.js +210 -0
- package/node_modules/@buddi/runtime/dist/codex-oauth.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/codex-profile.d.ts +19 -0
- package/node_modules/@buddi/runtime/dist/codex-profile.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/codex-profile.js +99 -0
- package/node_modules/@buddi/runtime/dist/codex-profile.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/context-window.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/context-window.js +17 -4
- package/node_modules/@buddi/runtime/dist/context-window.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/delegate.d.ts +24 -0
- package/node_modules/@buddi/runtime/dist/delegate.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/delegate.js +87 -11
- package/node_modules/@buddi/runtime/dist/delegate.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.d.ts +4 -4
- package/node_modules/@buddi/runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/index.js +5 -5
- package/node_modules/@buddi/runtime/dist/index.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/loop.d.ts +7 -0
- package/node_modules/@buddi/runtime/dist/loop.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/loop.js +54 -8
- package/node_modules/@buddi/runtime/dist/loop.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/ollama-signing.d.ts +52 -0
- package/node_modules/@buddi/runtime/dist/ollama-signing.d.ts.map +1 -0
- package/node_modules/@buddi/runtime/dist/ollama-signing.js +154 -0
- package/node_modules/@buddi/runtime/dist/ollama-signing.js.map +1 -0
- package/node_modules/@buddi/runtime/dist/openai.d.ts +16 -4
- package/node_modules/@buddi/runtime/dist/openai.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/openai.js +44 -11
- package/node_modules/@buddi/runtime/dist/openai.js.map +1 -1
- package/node_modules/@buddi/runtime/dist/provider-models.d.ts +2 -0
- package/node_modules/@buddi/runtime/dist/provider-models.d.ts.map +1 -1
- package/node_modules/@buddi/runtime/dist/provider-models.js +13 -4
- package/node_modules/@buddi/runtime/dist/provider-models.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-browser/dist/computer.d.ts +53 -1
- package/node_modules/@buddi/tool-browser/dist/computer.d.ts.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/computer.js +154 -5
- package/node_modules/@buddi/tool-browser/dist/computer.js.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/controller.d.ts +20 -3
- package/node_modules/@buddi/tool-browser/dist/controller.d.ts.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/controller.js +170 -5
- package/node_modules/@buddi/tool-browser/dist/controller.js.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/index.d.ts.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/index.js +9 -1
- package/node_modules/@buddi/tool-browser/dist/index.js.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/service.d.ts +14 -1
- package/node_modules/@buddi/tool-browser/dist/service.d.ts.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/service.js +28 -5
- package/node_modules/@buddi/tool-browser/dist/service.js.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/types.d.ts +11 -0
- package/node_modules/@buddi/tool-browser/dist/types.d.ts.map +1 -1
- package/node_modules/@buddi/tool-browser/dist/types.js +16 -3
- package/node_modules/@buddi/tool-browser/dist/types.js.map +1 -1
- package/node_modules/@buddi/tool-browser/package.json +1 -1
- package/node_modules/@buddi/tool-email/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-host/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-memory/dist/.tsbuildinfo +1 -1
- package/node_modules/@buddi/tool-web/dist/.tsbuildinfo +1 -1
- package/node_modules/imapflow/CHANGELOG.md +29 -0
- package/node_modules/imapflow/dist/cjs/commands/append.js +12 -12
- package/node_modules/imapflow/dist/cjs/commands/authenticate.d.ts +3 -8
- package/node_modules/imapflow/dist/cjs/commands/close.js +2 -1
- package/node_modules/imapflow/dist/cjs/commands/copy.js +4 -4
- package/node_modules/imapflow/dist/cjs/commands/create.js +2 -3
- package/node_modules/imapflow/dist/cjs/commands/delete.js +4 -4
- package/node_modules/imapflow/dist/cjs/commands/expunge.js +8 -5
- package/node_modules/imapflow/dist/cjs/commands/fetch.js +12 -10
- package/node_modules/imapflow/dist/cjs/commands/idle.js +6 -2
- package/node_modules/imapflow/dist/cjs/commands/list.js +22 -18
- package/node_modules/imapflow/dist/cjs/commands/move.js +11 -6
- package/node_modules/imapflow/dist/cjs/commands/namespace.js +1 -1
- package/node_modules/imapflow/dist/cjs/commands/quota.js +10 -9
- package/node_modules/imapflow/dist/cjs/commands/rename.js +4 -4
- package/node_modules/imapflow/dist/cjs/commands/search.js +7 -8
- package/node_modules/imapflow/dist/cjs/commands/select.js +12 -9
- package/node_modules/imapflow/dist/cjs/commands/status.js +11 -11
- package/node_modules/imapflow/dist/cjs/commands/store.js +5 -5
- package/node_modules/imapflow/dist/cjs/commands/subscribe.js +2 -17
- package/node_modules/imapflow/dist/cjs/commands/subscription.d.ts +10 -0
- package/node_modules/imapflow/dist/cjs/commands/subscription.js +29 -0
- package/node_modules/imapflow/dist/cjs/commands/unsubscribe.js +2 -17
- package/node_modules/imapflow/dist/cjs/download.d.ts +22 -0
- package/node_modules/imapflow/dist/cjs/download.js +588 -0
- package/node_modules/imapflow/dist/cjs/errors.d.ts +50 -1
- package/node_modules/imapflow/dist/cjs/errors.js +53 -1
- package/node_modules/imapflow/dist/cjs/handler/imap-compiler.js +1 -1
- package/node_modules/imapflow/dist/cjs/handler/imap-stream.d.ts +13 -2
- package/node_modules/imapflow/dist/cjs/handler/imap-stream.js +51 -30
- package/node_modules/imapflow/dist/cjs/handler/parser-instance.js +2 -2
- package/node_modules/imapflow/dist/cjs/handler/token-parser.js +15 -9
- package/node_modules/imapflow/dist/cjs/imap-flow.d.ts +30 -84
- package/node_modules/imapflow/dist/cjs/imap-flow.js +282 -734
- package/node_modules/imapflow/dist/cjs/jp-decoder.js +1 -1
- package/node_modules/imapflow/dist/cjs/package-info.d.ts +1 -1
- package/node_modules/imapflow/dist/cjs/package-info.js +3 -3
- package/node_modules/imapflow/dist/cjs/search-compiler.js +5 -12
- package/node_modules/imapflow/dist/cjs/tools.d.ts +52 -11
- package/node_modules/imapflow/dist/cjs/tools.js +86 -23
- package/node_modules/imapflow/dist/cjs/types.d.ts +30 -16
- package/node_modules/imapflow/dist/esm/commands/append.js +13 -13
- package/node_modules/imapflow/dist/esm/commands/authenticate.d.ts +3 -8
- package/node_modules/imapflow/dist/esm/commands/close.js +2 -1
- package/node_modules/imapflow/dist/esm/commands/copy.js +5 -5
- package/node_modules/imapflow/dist/esm/commands/create.js +3 -4
- package/node_modules/imapflow/dist/esm/commands/delete.js +5 -5
- package/node_modules/imapflow/dist/esm/commands/expunge.js +9 -6
- package/node_modules/imapflow/dist/esm/commands/fetch.js +13 -11
- package/node_modules/imapflow/dist/esm/commands/idle.js +7 -3
- package/node_modules/imapflow/dist/esm/commands/list.js +22 -18
- package/node_modules/imapflow/dist/esm/commands/move.js +12 -7
- package/node_modules/imapflow/dist/esm/commands/namespace.js +2 -2
- package/node_modules/imapflow/dist/esm/commands/quota.js +11 -10
- package/node_modules/imapflow/dist/esm/commands/rename.js +5 -5
- package/node_modules/imapflow/dist/esm/commands/search.js +8 -9
- package/node_modules/imapflow/dist/esm/commands/select.js +13 -10
- package/node_modules/imapflow/dist/esm/commands/status.js +12 -12
- package/node_modules/imapflow/dist/esm/commands/store.js +6 -6
- package/node_modules/imapflow/dist/esm/commands/subscribe.js +2 -17
- package/node_modules/imapflow/dist/esm/commands/subscription.d.ts +10 -0
- package/node_modules/imapflow/dist/esm/commands/subscription.js +26 -0
- package/node_modules/imapflow/dist/esm/commands/unsubscribe.js +2 -17
- package/node_modules/imapflow/dist/esm/download.d.ts +22 -0
- package/node_modules/imapflow/dist/esm/download.js +581 -0
- package/node_modules/imapflow/dist/esm/errors.d.ts +50 -1
- package/node_modules/imapflow/dist/esm/errors.js +52 -0
- package/node_modules/imapflow/dist/esm/handler/imap-compiler.js +1 -1
- package/node_modules/imapflow/dist/esm/handler/imap-stream.d.ts +13 -2
- package/node_modules/imapflow/dist/esm/handler/imap-stream.js +51 -30
- package/node_modules/imapflow/dist/esm/handler/parser-instance.js +2 -2
- package/node_modules/imapflow/dist/esm/handler/token-parser.js +15 -9
- package/node_modules/imapflow/dist/esm/imap-flow.d.ts +30 -84
- package/node_modules/imapflow/dist/esm/imap-flow.js +282 -735
- package/node_modules/imapflow/dist/esm/jp-decoder.js +1 -1
- package/node_modules/imapflow/dist/esm/package-info.d.ts +1 -1
- package/node_modules/imapflow/dist/esm/package-info.js +3 -3
- package/node_modules/imapflow/dist/esm/search-compiler.js +5 -12
- package/node_modules/imapflow/dist/esm/tools.d.ts +52 -11
- package/node_modules/imapflow/dist/esm/tools.js +79 -21
- package/node_modules/imapflow/dist/esm/types.d.ts +30 -16
- package/node_modules/imapflow/package.json +4 -4
- package/package.json +2 -2
- package/packages/cli/dist/.tsbuildinfo +1 -1
- package/packages/cli/dist/args.d.ts +6 -0
- package/packages/cli/dist/args.d.ts.map +1 -1
- package/packages/cli/dist/args.js +15 -0
- 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 +18 -1
- package/packages/cli/dist/commands.js.map +1 -1
- package/packages/cli/dist/main.d.ts.map +1 -1
- package/packages/cli/dist/main.js +19 -2
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/status.d.ts +10 -0
- package/packages/cli/dist/status.d.ts.map +1 -1
- package/packages/cli/dist/status.js +4 -0
- package/packages/cli/dist/status.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 -1
- package/packages/core/dist/agents/catalog.js.map +1 -1
- package/packages/core/dist/host/build.d.ts.map +1 -1
- package/packages/core/dist/host/build.js +33 -16
- package/packages/core/dist/host/build.js.map +1 -1
- package/packages/core/dist/host/types.d.ts +17 -0
- package/packages/core/dist/host/types.d.ts.map +1 -1
- package/packages/core/dist/pages/__fixtures__/demo.d.ts.map +1 -1
- package/packages/core/dist/pages/__fixtures__/demo.js +1 -0
- package/packages/core/dist/pages/__fixtures__/demo.js.map +1 -1
- package/packages/core/dist/pages.d.ts +74 -0
- package/packages/core/dist/pages.d.ts.map +1 -1
- package/packages/core/dist/pages.js +27 -1
- package/packages/core/dist/pages.js.map +1 -1
- package/packages/core/dist/plugin/index.d.ts +2 -2
- package/packages/core/dist/plugin/index.d.ts.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/provider-accounts.d.ts +15 -1
- package/packages/core/dist/provider-accounts.d.ts.map +1 -1
- package/packages/core/dist/provider-accounts.js +22 -1
- package/packages/core/dist/provider-accounts.js.map +1 -1
- package/packages/core/dist/provider.d.ts +6 -0
- package/packages/core/dist/provider.d.ts.map +1 -1
- package/packages/core/dist/provider.js.map +1 -1
- package/packages/core/dist/surfaces.d.ts +11 -0
- package/packages/core/dist/surfaces.d.ts.map +1 -1
- package/packages/core/dist/surfaces.js +4 -0
- package/packages/core/dist/surfaces.js.map +1 -1
- package/packages/core/migrations/046_ollama_device_key.sql +7 -0
- package/packages/core/migrations/047_reported_context_windows.sql +5 -0
- package/packages/core/migrations/048_surface_chat_voice.sql +13 -0
- package/packages/core/migrations/049_surface_chat_voice_form.sql +8 -0
- package/packages/gateway/dist/.tsbuildinfo +1 -1
- package/packages/gateway/dist/agents-cli.d.ts +2 -0
- package/packages/gateway/dist/agents-cli.d.ts.map +1 -1
- package/packages/gateway/dist/agents-cli.js +5 -3
- package/packages/gateway/dist/agents-cli.js.map +1 -1
- package/packages/gateway/dist/chat/session.d.ts.map +1 -1
- package/packages/gateway/dist/chat/session.js +2 -2
- package/packages/gateway/dist/chat/session.js.map +1 -1
- package/packages/gateway/dist/chat/usage.d.ts +16 -0
- package/packages/gateway/dist/chat/usage.d.ts.map +1 -1
- package/packages/gateway/dist/chat/usage.js +53 -11
- package/packages/gateway/dist/chat/usage.js.map +1 -1
- package/packages/gateway/dist/codex-accounts.d.ts +24 -11
- package/packages/gateway/dist/codex-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/codex-accounts.js +151 -215
- package/packages/gateway/dist/codex-accounts.js.map +1 -1
- package/packages/gateway/dist/index.d.ts +2 -0
- package/packages/gateway/dist/index.d.ts.map +1 -1
- package/packages/gateway/dist/index.js +2 -0
- package/packages/gateway/dist/index.js.map +1 -1
- package/packages/gateway/dist/ollama-accounts.d.ts +87 -0
- package/packages/gateway/dist/ollama-accounts.d.ts.map +1 -0
- package/packages/gateway/dist/ollama-accounts.js +179 -0
- package/packages/gateway/dist/ollama-accounts.js.map +1 -0
- package/packages/gateway/dist/provider-accounts.d.ts +51 -1
- package/packages/gateway/dist/provider-accounts.d.ts.map +1 -1
- package/packages/gateway/dist/provider-accounts.js +184 -25
- package/packages/gateway/dist/provider-accounts.js.map +1 -1
- package/packages/gateway/dist/speech-cli.d.ts +43 -0
- package/packages/gateway/dist/speech-cli.d.ts.map +1 -0
- package/packages/gateway/dist/speech-cli.js +105 -0
- package/packages/gateway/dist/speech-cli.js.map +1 -0
- package/packages/gateway/dist/surfaces/context-budget.d.ts.map +1 -1
- package/packages/gateway/dist/surfaces/context-budget.js +10 -3
- package/packages/gateway/dist/surfaces/context-budget.js.map +1 -1
- package/packages/gateway/dist/telegram/api.d.ts +10 -0
- package/packages/gateway/dist/telegram/api.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/api.js +12 -0
- package/packages/gateway/dist/telegram/api.js.map +1 -1
- package/packages/gateway/dist/telegram/browser-view.d.ts +2 -1
- package/packages/gateway/dist/telegram/browser-view.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/browser-view.js +4 -2
- package/packages/gateway/dist/telegram/browser-view.js.map +1 -1
- package/packages/gateway/dist/telegram/main.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/main.js +10 -2
- package/packages/gateway/dist/telegram/main.js.map +1 -1
- package/packages/gateway/dist/telegram/surface.d.ts +25 -0
- package/packages/gateway/dist/telegram/surface.d.ts.map +1 -1
- package/packages/gateway/dist/telegram/surface.js +212 -10
- package/packages/gateway/dist/telegram/surface.js.map +1 -1
- package/packages/gateway/dist/telegram/voice.d.ts +112 -0
- package/packages/gateway/dist/telegram/voice.d.ts.map +1 -0
- package/packages/gateway/dist/telegram/voice.js +220 -0
- package/packages/gateway/dist/telegram/voice.js.map +1 -0
- package/packages/gateway/dist/web/chat.d.ts +31 -8
- package/packages/gateway/dist/web/chat.d.ts.map +1 -1
- package/packages/gateway/dist/web/chat.js +3 -2
- package/packages/gateway/dist/web/chat.js.map +1 -1
- package/packages/gateway/dist/web/onboarding.d.ts +13 -2
- package/packages/gateway/dist/web/onboarding.d.ts.map +1 -1
- package/packages/gateway/dist/web/onboarding.js +24 -3
- package/packages/gateway/dist/web/onboarding.js.map +1 -1
- package/packages/gateway/dist/web/read.d.ts +15 -12
- package/packages/gateway/dist/web/read.d.ts.map +1 -1
- package/packages/gateway/dist/web/read.js +9 -10
- package/packages/gateway/dist/web/read.js.map +1 -1
- package/packages/gateway/dist/web/server.d.ts.map +1 -1
- package/packages/gateway/dist/web/server.js +29 -13
- package/packages/gateway/dist/web/server.js.map +1 -1
- package/packages/gateway/dist/web/speech.d.ts +47 -0
- package/packages/gateway/dist/web/speech.d.ts.map +1 -0
- package/packages/gateway/dist/web/speech.js +83 -0
- package/packages/gateway/dist/web/speech.js.map +1 -0
- package/packages/gateway/dist/web/stream.d.ts +0 -24
- package/packages/gateway/dist/web/stream.d.ts.map +1 -1
- package/packages/gateway/dist/web/stream.js +26 -2
- package/packages/gateway/dist/web/stream.js.map +1 -1
- package/packages/gateway/dist/web/usage-view.d.ts +15 -0
- package/packages/gateway/dist/web/usage-view.d.ts.map +1 -0
- package/packages/gateway/dist/web/usage-view.js +20 -0
- package/packages/gateway/dist/web/usage-view.js.map +1 -0
- package/packages/install/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/.tsbuildinfo +1 -1
- package/packages/runtime/dist/anthropic.d.ts +18 -0
- package/packages/runtime/dist/anthropic.d.ts.map +1 -1
- package/packages/runtime/dist/anthropic.js +65 -13
- package/packages/runtime/dist/anthropic.js.map +1 -1
- package/packages/runtime/dist/codex-direct.d.ts +55 -0
- package/packages/runtime/dist/codex-direct.d.ts.map +1 -0
- package/packages/runtime/dist/codex-direct.js +342 -0
- package/packages/runtime/dist/codex-direct.js.map +1 -0
- package/packages/runtime/dist/codex-oauth.d.ts +66 -0
- package/packages/runtime/dist/codex-oauth.d.ts.map +1 -0
- package/packages/runtime/dist/codex-oauth.js +210 -0
- package/packages/runtime/dist/codex-oauth.js.map +1 -0
- package/packages/runtime/dist/codex-profile.d.ts +19 -0
- package/packages/runtime/dist/codex-profile.d.ts.map +1 -0
- package/packages/runtime/dist/codex-profile.js +99 -0
- package/packages/runtime/dist/codex-profile.js.map +1 -0
- package/packages/runtime/dist/context-window.d.ts.map +1 -1
- package/packages/runtime/dist/context-window.js +17 -4
- package/packages/runtime/dist/context-window.js.map +1 -1
- package/packages/runtime/dist/delegate.d.ts +24 -0
- package/packages/runtime/dist/delegate.d.ts.map +1 -1
- package/packages/runtime/dist/delegate.js +87 -11
- package/packages/runtime/dist/delegate.js.map +1 -1
- package/packages/runtime/dist/index.d.ts +4 -4
- package/packages/runtime/dist/index.d.ts.map +1 -1
- package/packages/runtime/dist/index.js +5 -5
- package/packages/runtime/dist/index.js.map +1 -1
- package/packages/runtime/dist/loop.d.ts +7 -0
- package/packages/runtime/dist/loop.d.ts.map +1 -1
- package/packages/runtime/dist/loop.js +54 -8
- package/packages/runtime/dist/loop.js.map +1 -1
- package/packages/runtime/dist/ollama-signing.d.ts +52 -0
- package/packages/runtime/dist/ollama-signing.d.ts.map +1 -0
- package/packages/runtime/dist/ollama-signing.js +154 -0
- package/packages/runtime/dist/ollama-signing.js.map +1 -0
- package/packages/runtime/dist/openai.d.ts +16 -4
- package/packages/runtime/dist/openai.d.ts.map +1 -1
- package/packages/runtime/dist/openai.js +44 -11
- package/packages/runtime/dist/openai.js.map +1 -1
- package/packages/runtime/dist/provider-models.d.ts +2 -0
- package/packages/runtime/dist/provider-models.d.ts.map +1 -1
- package/packages/runtime/dist/provider-models.js +13 -4
- package/packages/runtime/dist/provider-models.js.map +1 -1
- package/packages/tools/artifacts/dist/.tsbuildinfo +1 -1
- package/packages/tools/browser/dist/.tsbuildinfo +1 -1
- package/packages/tools/browser/dist/computer.d.ts +53 -1
- package/packages/tools/browser/dist/computer.d.ts.map +1 -1
- package/packages/tools/browser/dist/computer.js +154 -5
- package/packages/tools/browser/dist/computer.js.map +1 -1
- package/packages/tools/browser/dist/controller.d.ts +20 -3
- package/packages/tools/browser/dist/controller.d.ts.map +1 -1
- package/packages/tools/browser/dist/controller.js +170 -5
- package/packages/tools/browser/dist/controller.js.map +1 -1
- package/packages/tools/browser/dist/index.d.ts.map +1 -1
- package/packages/tools/browser/dist/index.js +9 -1
- package/packages/tools/browser/dist/index.js.map +1 -1
- package/packages/tools/browser/dist/service.d.ts +14 -1
- package/packages/tools/browser/dist/service.d.ts.map +1 -1
- package/packages/tools/browser/dist/service.js +28 -5
- package/packages/tools/browser/dist/service.js.map +1 -1
- package/packages/tools/browser/dist/types.d.ts +11 -0
- package/packages/tools/browser/dist/types.d.ts.map +1 -1
- package/packages/tools/browser/dist/types.js +16 -3
- package/packages/tools/browser/dist/types.js.map +1 -1
- package/packages/tools/browser/package.json +1 -1
- package/packages/tools/email/dist/.tsbuildinfo +1 -1
- package/packages/tools/host/dist/.tsbuildinfo +1 -1
- package/packages/tools/memory/dist/.tsbuildinfo +1 -1
- package/packages/tools/web/dist/.tsbuildinfo +1 -1
- package/packages/web/dist/assets/index-D5cRFcgm.css +1 -0
- package/packages/web/dist/assets/index-GCFB1vBV.js +125 -0
- package/packages/web/dist/index.html +2 -2
- package/node_modules/@buddi/runtime/dist/codex-app-server.d.ts +0 -20
- package/node_modules/@buddi/runtime/dist/codex-app-server.d.ts.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-app-server.js +0 -172
- package/node_modules/@buddi/runtime/dist/codex-app-server.js.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-policy.d.ts +0 -6
- package/node_modules/@buddi/runtime/dist/codex-policy.d.ts.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-policy.js +0 -79
- package/node_modules/@buddi/runtime/dist/codex-policy.js.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-rpc.d.ts +0 -34
- package/node_modules/@buddi/runtime/dist/codex-rpc.d.ts.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-rpc.js +0 -152
- package/node_modules/@buddi/runtime/dist/codex-rpc.js.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-session.d.ts +0 -30
- package/node_modules/@buddi/runtime/dist/codex-session.d.ts.map +0 -1
- package/node_modules/@buddi/runtime/dist/codex-session.js +0 -169
- package/node_modules/@buddi/runtime/dist/codex-session.js.map +0 -1
- package/packages/runtime/dist/codex-app-server.d.ts +0 -20
- package/packages/runtime/dist/codex-app-server.d.ts.map +0 -1
- package/packages/runtime/dist/codex-app-server.js +0 -172
- package/packages/runtime/dist/codex-app-server.js.map +0 -1
- package/packages/runtime/dist/codex-policy.d.ts +0 -6
- package/packages/runtime/dist/codex-policy.d.ts.map +0 -1
- package/packages/runtime/dist/codex-policy.js +0 -79
- package/packages/runtime/dist/codex-policy.js.map +0 -1
- package/packages/runtime/dist/codex-rpc.d.ts +0 -34
- package/packages/runtime/dist/codex-rpc.d.ts.map +0 -1
- package/packages/runtime/dist/codex-rpc.js +0 -152
- package/packages/runtime/dist/codex-rpc.js.map +0 -1
- package/packages/runtime/dist/codex-session.d.ts +0 -30
- package/packages/runtime/dist/codex-session.d.ts.map +0 -1
- package/packages/runtime/dist/codex-session.js +0 -169
- package/packages/runtime/dist/codex-session.js.map +0 -1
- package/packages/web/dist/assets/index-B727JQsO.css +0 -1
- package/packages/web/dist/assets/index-OA0xgibo.js +0 -123
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
var xg=e=>{throw TypeError(e)};var vg=(e,t,n)=>t.has(e)||xg("Cannot "+n);var Mt=(e,t,n)=>(vg(e,t,"read from private field"),n?n.call(e):t.get(e)),jg=(e,t,n)=>t.has(e)?xg("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ru=(e,t,n,r)=>(vg(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function E1(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{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 o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function A1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mj={exports:{}},_c={},gj={exports:{}},Ne={};/**
|
|
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 pl=Symbol.for("react.element"),T1=Symbol.for("react.portal"),R1=Symbol.for("react.fragment"),P1=Symbol.for("react.strict_mode"),I1=Symbol.for("react.profiler"),M1=Symbol.for("react.provider"),$1=Symbol.for("react.context"),_1=Symbol.for("react.forward_ref"),O1=Symbol.for("react.suspense"),D1=Symbol.for("react.memo"),L1=Symbol.for("react.lazy"),yg=Symbol.iterator;function F1(e){return e===null||typeof e!="object"?null:(e=yg&&e[yg]||e["@@iterator"],typeof e=="function"?e:null)}var xj={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vj=Object.assign,jj={};function Yi(e,t,n){this.props=e,this.context=t,this.refs=jj,this.updater=n||xj}Yi.prototype.isReactComponent={};Yi.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")};Yi.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function yj(){}yj.prototype=Yi.prototype;function zh(e,t,n){this.props=e,this.context=t,this.refs=jj,this.updater=n||xj}var Uh=zh.prototype=new yj;Uh.constructor=zh;vj(Uh,Yi.prototype);Uh.isPureReactComponent=!0;var wg=Array.isArray,wj=Object.prototype.hasOwnProperty,Bh={current:null},bj={key:!0,ref:!0,__self:!0,__source:!0};function kj(e,t,n){var r,i={},o=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(o=""+t.key),t)wj.call(t,r)&&!bj.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var c=Array(a),u=0;u<a;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:pl,type:e,key:o,ref:l,props:i,_owner:Bh.current}}function z1(e,t){return{$$typeof:pl,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Wh(e){return typeof e=="object"&&e!==null&&e.$$typeof===pl}function U1(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var bg=/\/+/g;function Pu(e,t){return typeof e=="object"&&e!==null&&e.key!=null?U1(""+e.key):t.toString(36)}function ka(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(o){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case pl:case T1:l=!0}}if(l)return l=e,i=i(l),e=r===""?"."+Pu(l,0):r,wg(i)?(n="",e!=null&&(n=e.replace(bg,"$&/")+"/"),ka(i,t,n,"",function(u){return u})):i!=null&&(Wh(i)&&(i=z1(i,n+(!i.key||l&&l.key===i.key?"":(""+i.key).replace(bg,"$&/")+"/")+e)),t.push(i)),1;if(l=0,r=r===""?".":r+":",wg(e))for(var a=0;a<e.length;a++){o=e[a];var c=r+Pu(o,a);l+=ka(o,t,n,c,i)}else if(c=F1(e),typeof c=="function")for(e=c.call(e),a=0;!(o=e.next()).done;)o=o.value,c=r+Pu(o,a++),l+=ka(o,t,n,c,i);else if(o==="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 Ol(e,t,n){if(e==null)return e;var r=[],i=0;return ka(e,r,"","",function(o){return t.call(n,o,i++)}),r}function B1(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Gt={current:null},Sa={transition:null},W1={ReactCurrentDispatcher:Gt,ReactCurrentBatchConfig:Sa,ReactCurrentOwner:Bh};function Sj(){throw Error("act(...) is not supported in production builds of React.")}Ne.Children={map:Ol,forEach:function(e,t,n){Ol(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Ol(e,function(){t++}),t},toArray:function(e){return Ol(e,function(t){return t})||[]},only:function(e){if(!Wh(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ne.Component=Yi;Ne.Fragment=R1;Ne.Profiler=I1;Ne.PureComponent=zh;Ne.StrictMode=P1;Ne.Suspense=O1;Ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W1;Ne.act=Sj;Ne.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=vj({},e.props),i=e.key,o=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,l=Bh.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)wj.call(t,c)&&!bj.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var u=0;u<c;u++)a[u]=arguments[u+2];r.children=a}return{$$typeof:pl,type:e.type,key:i,ref:o,props:r,_owner:l}};Ne.createContext=function(e){return e={$$typeof:$1,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:M1,_context:e},e.Consumer=e};Ne.createElement=kj;Ne.createFactory=function(e){var t=kj.bind(null,e);return t.type=e,t};Ne.createRef=function(){return{current:null}};Ne.forwardRef=function(e){return{$$typeof:_1,render:e}};Ne.isValidElement=Wh;Ne.lazy=function(e){return{$$typeof:L1,_payload:{_status:-1,_result:e},_init:B1}};Ne.memo=function(e,t){return{$$typeof:D1,type:e,compare:t===void 0?null:t}};Ne.startTransition=function(e){var t=Sa.transition;Sa.transition={};try{e()}finally{Sa.transition=t}};Ne.unstable_act=Sj;Ne.useCallback=function(e,t){return Gt.current.useCallback(e,t)};Ne.useContext=function(e){return Gt.current.useContext(e)};Ne.useDebugValue=function(){};Ne.useDeferredValue=function(e){return Gt.current.useDeferredValue(e)};Ne.useEffect=function(e,t){return Gt.current.useEffect(e,t)};Ne.useId=function(){return Gt.current.useId()};Ne.useImperativeHandle=function(e,t,n){return Gt.current.useImperativeHandle(e,t,n)};Ne.useInsertionEffect=function(e,t){return Gt.current.useInsertionEffect(e,t)};Ne.useLayoutEffect=function(e,t){return Gt.current.useLayoutEffect(e,t)};Ne.useMemo=function(e,t){return Gt.current.useMemo(e,t)};Ne.useReducer=function(e,t,n){return Gt.current.useReducer(e,t,n)};Ne.useRef=function(e){return Gt.current.useRef(e)};Ne.useState=function(e){return Gt.current.useState(e)};Ne.useSyncExternalStore=function(e,t,n){return Gt.current.useSyncExternalStore(e,t,n)};Ne.useTransition=function(){return Gt.current.useTransition()};Ne.version="18.3.1";gj.exports=Ne;var d=gj.exports;const H1=A1(d),qi=E1({__proto__:null,default:H1},[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 V1=d,K1=Symbol.for("react.element"),G1=Symbol.for("react.fragment"),Y1=Object.prototype.hasOwnProperty,q1=V1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Q1={key:!0,ref:!0,__self:!0,__source:!0};function Nj(e,t,n){var r,i={},o=null,l=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)Y1.call(t,r)&&!Q1.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:K1,type:e,key:o,ref:l,props:i,_owner:q1.current}}_c.Fragment=G1;_c.jsx=Nj;_c.jsxs=Nj;mj.exports=_c;var s=mj.exports,Cj={exports:{}},xn={},Ej={exports:{}},Aj={};/**
|
|
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 U=_-1>>>1,X=M[U];if(0<i(X,W))M[U]=W,M[_]=X,_=U;else break e}}function n(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 U=0,X=M.length,Z=X>>>1;U<Z;){var ue=2*(U+1)-1,je=M[ue],Ce=ue+1,Pe=M[Ce];if(0>i(je,_))Ce<X&&0>i(Pe,je)?(M[U]=Pe,M[Ce]=_,U=Ce):(M[U]=je,M[ue]=_,U=ue);else if(Ce<X&&0>i(Pe,_))M[U]=Pe,M[Ce]=_,U=Ce;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 o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,a=l.now();e.unstable_now=function(){return l.now()-a}}var c=[],u=[],p=1,f=null,h=3,x=!1,j=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(M){for(var W=n(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=n(u)}}function g(M){if(w=!1,y(M),!j)if(n(c)!==null)j=!0,q(k);else{var W=n(u);W!==null&&K(g,W.startTime-M)}}function k(M,W){j=!1,w&&(w=!1,v(C),C=-1),x=!0;var _=h;try{for(y(W),f=n(c);f!==null&&(!(f.expirationTime>W)||M&&!O());){var U=f.callback;if(typeof U=="function"){f.callback=null,h=f.priorityLevel;var X=U(f.expirationTime<=W);W=e.unstable_now(),typeof X=="function"?f.callback=X:f===n(c)&&r(c),y(W)}else r(c);f=n(c)}if(f!==null)var Z=!0;else{var ue=n(u);ue!==null&&K(g,ue.startTime-W),Z=!1}return Z}finally{f=null,h=_,x=!1}}var S=!1,N=null,C=-1,P=5,E=-1;function O(){return!(e.unstable_now()-E<P)}function L(){if(N!==null){var M=e.unstable_now();E=M;var W=!0;try{W=N(!0,M)}finally{W?D():(S=!1,N=null)}}else S=!1}var D;if(typeof m=="function")D=function(){m(L)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,z=T.port2;T.port1.onmessage=L,D=function(){z.postMessage(null)}}else D=function(){b(L,0)};function q(M){N=M,S||(S=!0,D())}function K(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(){j||x||(j=!0,q(k))},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"):P=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(h){case 1:case 2:case 3:var W=3;break;default:W=h}var _=h;h=W;try{return M()}finally{h=_}},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 _=h;h=M;try{return W()}finally{h=_}},e.unstable_scheduleCallback=function(M,W,_){var U=e.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?U+_:U):_=U,M){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=_+X,M={id:p++,callback:W,priorityLevel:M,startTime:_,expirationTime:X,sortIndex:-1},_>U?(M.sortIndex=_,t(u,M),n(c)===null&&M===n(u)&&(w?(v(C),C=-1):w=!0,K(g,_-U))):(M.sortIndex=X,t(c,M),j||x||(j=!0,q(k))),M},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(M){var W=h;return function(){var _=h;h=W;try{return M.apply(this,arguments)}finally{h=_}}}})(Aj);Ej.exports=Aj;var J1=Ej.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 X1=d,gn=J1;function Q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);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 Tj=new Set,Uo={};function Br(e,t){Ri(e,t),Ri(e+"Capture",t)}function Ri(e,t){for(Uo[e]=t,e=0;e<t.length;e++)Tj.add(t[e])}var bs=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kd=Object.prototype.hasOwnProperty,Z1=/^[: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]*$/,kg={},Sg={};function eN(e){return Kd.call(Sg,e)?!0:Kd.call(kg,e)?!1:Z1.test(e)?Sg[e]=!0:(kg[e]=!0,!1)}function tN(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function nN(e,t,n,r){if(t===null||typeof t>"u"||tN(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 Yt(e,t,n,r,i,o,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=l}var Rt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Rt[e]=new Yt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Rt[t]=new Yt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Rt[e]=new Yt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Rt[e]=new Yt(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){Rt[e]=new Yt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Rt[e]=new Yt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Rt[e]=new Yt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Rt[e]=new Yt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Rt[e]=new Yt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Hh=/[\-:]([a-z])/g;function Vh(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(Hh,Vh);Rt[t]=new Yt(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(Hh,Vh);Rt[t]=new Yt(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(Hh,Vh);Rt[t]=new Yt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Rt[e]=new Yt(e,1,!1,e.toLowerCase(),null,!1,!1)});Rt.xlinkHref=new Yt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Rt[e]=new Yt(e,1,!1,e.toLowerCase(),null,!0,!0)});function Kh(e,t,n,r){var i=Rt.hasOwnProperty(t)?Rt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(nN(t,n,i,r)&&(n=null),r||i===null?eN(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ps=X1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Dl=Symbol.for("react.element"),li=Symbol.for("react.portal"),ai=Symbol.for("react.fragment"),Gh=Symbol.for("react.strict_mode"),Gd=Symbol.for("react.profiler"),Rj=Symbol.for("react.provider"),Pj=Symbol.for("react.context"),Yh=Symbol.for("react.forward_ref"),Yd=Symbol.for("react.suspense"),qd=Symbol.for("react.suspense_list"),qh=Symbol.for("react.memo"),zs=Symbol.for("react.lazy"),Ij=Symbol.for("react.offscreen"),Ng=Symbol.iterator;function fo(e){return e===null||typeof e!="object"?null:(e=Ng&&e[Ng]||e["@@iterator"],typeof e=="function"?e:null)}var Qe=Object.assign,Iu;function No(e){if(Iu===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Iu=t&&t[1]||""}return`
|
|
34
|
-
`+Iu+e}var Mu=!1;function $u(e,t){if(!e||Mu)return"";Mu=!0;var n=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
|
-
`),o=r.stack.split(`
|
|
36
|
-
`),l=i.length-1,a=o.length-1;1<=l&&0<=a&&i[l]!==o[a];)a--;for(;1<=l&&0<=a;l--,a--)if(i[l]!==o[a]){if(l!==1||a!==1)do if(l--,a--,0>a||i[l]!==o[a]){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<=a);break}}}finally{Mu=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?No(e):""}function sN(e){switch(e.tag){case 5:return No(e.type);case 16:return No("Lazy");case 13:return No("Suspense");case 19:return No("SuspenseList");case 0:case 2:case 15:return e=$u(e.type,!1),e;case 11:return e=$u(e.type.render,!1),e;case 1:return e=$u(e.type,!0),e;default:return""}}function Qd(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 ai:return"Fragment";case li:return"Portal";case Gd:return"Profiler";case Gh:return"StrictMode";case Yd:return"Suspense";case qd:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Pj:return(e.displayName||"Context")+".Consumer";case Rj:return(e._context.displayName||"Context")+".Provider";case Yh:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case qh:return t=e.displayName||null,t!==null?t:Qd(e.type)||"Memo";case zs:t=e._payload,e=e._init;try{return Qd(e(t))}catch{}}return null}function rN(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 Qd(t);case 8:return t===Gh?"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 rr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Mj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function iN(e){var t=Mj(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(l){r=""+l,o.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ll(e){e._valueTracker||(e._valueTracker=iN(e))}function $j(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Mj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(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 Jd(e,t){var n=t.checked;return Qe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Cg(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=rr(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function _j(e,t){t=t.checked,t!=null&&Kh(e,"checked",t,!1)}function Xd(e,t){_j(e,t);var n=rr(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Zd(e,t.type,n):t.hasOwnProperty("defaultValue")&&Zd(e,t.type,rr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Eg(e,t,n){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,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Zd(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Co=Array.isArray;function yi(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+rr(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function ef(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Q(91));return Qe({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Ag(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Q(92));if(Co(n)){if(1<n.length)throw Error(Q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:rr(n)}}function Oj(e,t){var n=rr(t.value),r=rr(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Tg(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Dj(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 tf(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Dj(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Fl,Lj=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Fl=Fl||document.createElement("div"),Fl.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Fl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Bo(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var To={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},oN=["Webkit","ms","Moz","O"];Object.keys(To).forEach(function(e){oN.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),To[t]=To[e]})});function Fj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||To.hasOwnProperty(e)&&To[e]?(""+t).trim():t+"px"}function zj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Fj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var lN=Qe({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 nf(e,t){if(t){if(lN[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Q(62))}}function sf(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 rf=null;function Qh(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var of=null,wi=null,bi=null;function Rg(e){if(e=xl(e)){if(typeof of!="function")throw Error(Q(280));var t=e.stateNode;t&&(t=zc(t),of(e.stateNode,e.type,t))}}function Uj(e){wi?bi?bi.push(e):bi=[e]:wi=e}function Bj(){if(wi){var e=wi,t=bi;if(bi=wi=null,Rg(e),t)for(e=0;e<t.length;e++)Rg(t[e])}}function Wj(e,t){return e(t)}function Hj(){}var _u=!1;function Vj(e,t,n){if(_u)return e(t,n);_u=!0;try{return Wj(e,t,n)}finally{_u=!1,(wi!==null||bi!==null)&&(Hj(),Bj())}}function Wo(e,t){var n=e.stateNode;if(n===null)return null;var r=zc(n);if(r===null)return null;n=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(n&&typeof n!="function")throw Error(Q(231,t,typeof n));return n}var lf=!1;if(bs)try{var ho={};Object.defineProperty(ho,"passive",{get:function(){lf=!0}}),window.addEventListener("test",ho,ho),window.removeEventListener("test",ho,ho)}catch{lf=!1}function aN(e,t,n,r,i,o,l,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Ro=!1,Ya=null,qa=!1,af=null,cN={onError:function(e){Ro=!0,Ya=e}};function uN(e,t,n,r,i,o,l,a,c){Ro=!1,Ya=null,aN.apply(cN,arguments)}function dN(e,t,n,r,i,o,l,a,c){if(uN.apply(this,arguments),Ro){if(Ro){var u=Ya;Ro=!1,Ya=null}else throw Error(Q(198));qa||(qa=!0,af=u)}}function Wr(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Kj(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 Pg(e){if(Wr(e)!==e)throw Error(Q(188))}function fN(e){var t=e.alternate;if(!t){if(t=Wr(e),t===null)throw Error(Q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return Pg(i),e;if(o===r)return Pg(i),t;o=o.sibling}throw Error(Q(188))}if(n.return!==r.return)n=i,r=o;else{for(var l=!1,a=i.child;a;){if(a===n){l=!0,n=i,r=o;break}if(a===r){l=!0,r=i,n=o;break}a=a.sibling}if(!l){for(a=o.child;a;){if(a===n){l=!0,n=o,r=i;break}if(a===r){l=!0,r=o,n=i;break}a=a.sibling}if(!l)throw Error(Q(189))}}if(n.alternate!==r)throw Error(Q(190))}if(n.tag!==3)throw Error(Q(188));return n.stateNode.current===n?e:t}function Gj(e){return e=fN(e),e!==null?Yj(e):null}function Yj(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Yj(e);if(t!==null)return t;e=e.sibling}return null}var qj=gn.unstable_scheduleCallback,Ig=gn.unstable_cancelCallback,hN=gn.unstable_shouldYield,pN=gn.unstable_requestPaint,nt=gn.unstable_now,mN=gn.unstable_getCurrentPriorityLevel,Jh=gn.unstable_ImmediatePriority,Qj=gn.unstable_UserBlockingPriority,Qa=gn.unstable_NormalPriority,gN=gn.unstable_LowPriority,Jj=gn.unstable_IdlePriority,Oc=null,es=null;function xN(e){if(es&&typeof es.onCommitFiberRoot=="function")try{es.onCommitFiberRoot(Oc,e,void 0,(e.current.flags&128)===128)}catch{}}var Dn=Math.clz32?Math.clz32:yN,vN=Math.log,jN=Math.LN2;function yN(e){return e>>>=0,e===0?32:31-(vN(e)/jN|0)|0}var zl=64,Ul=4194304;function Eo(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 Ja(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,l=n&268435455;if(l!==0){var a=l&~i;a!==0?r=Eo(a):(o&=l,o!==0&&(r=Eo(o)))}else l=n&~i,l!==0?r=Eo(l):o!==0&&(r=Eo(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Dn(t),i=1<<n,r|=e[n],t&=~i;return r}function wN(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 bN(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var l=31-Dn(o),a=1<<l,c=i[l];c===-1?(!(a&n)||a&r)&&(i[l]=wN(a,t)):c<=t&&(e.expiredLanes|=a),o&=~a}}function cf(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Xj(){var e=zl;return zl<<=1,!(zl&4194240)&&(zl=64),e}function Ou(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ml(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Dn(t),e[t]=n}function kN(e,t){var n=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<n;){var i=31-Dn(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function Xh(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Dn(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var $e=0;function Zj(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var ey,Zh,ty,ny,sy,uf=!1,Bl=[],Gs=null,Ys=null,qs=null,Ho=new Map,Vo=new Map,Bs=[],SN="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 Mg(e,t){switch(e){case"focusin":case"focusout":Gs=null;break;case"dragenter":case"dragleave":Ys=null;break;case"mouseover":case"mouseout":qs=null;break;case"pointerover":case"pointerout":Ho.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vo.delete(t.pointerId)}}function po(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=xl(t),t!==null&&Zh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function NN(e,t,n,r,i){switch(t){case"focusin":return Gs=po(Gs,e,t,n,r,i),!0;case"dragenter":return Ys=po(Ys,e,t,n,r,i),!0;case"mouseover":return qs=po(qs,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Ho.set(o,po(Ho.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,Vo.set(o,po(Vo.get(o)||null,e,t,n,r,i)),!0}return!1}function ry(e){var t=Sr(e.target);if(t!==null){var n=Wr(t);if(n!==null){if(t=n.tag,t===13){if(t=Kj(n),t!==null){e.blockedOn=t,sy(e.priority,function(){ty(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Na(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=df(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rf=r,n.target.dispatchEvent(r),rf=null}else return t=xl(n),t!==null&&Zh(t),e.blockedOn=n,!1;t.shift()}return!0}function $g(e,t,n){Na(e)&&n.delete(t)}function CN(){uf=!1,Gs!==null&&Na(Gs)&&(Gs=null),Ys!==null&&Na(Ys)&&(Ys=null),qs!==null&&Na(qs)&&(qs=null),Ho.forEach($g),Vo.forEach($g)}function mo(e,t){e.blockedOn===t&&(e.blockedOn=null,uf||(uf=!0,gn.unstable_scheduleCallback(gn.unstable_NormalPriority,CN)))}function Ko(e){function t(i){return mo(i,e)}if(0<Bl.length){mo(Bl[0],e);for(var n=1;n<Bl.length;n++){var r=Bl[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Gs!==null&&mo(Gs,e),Ys!==null&&mo(Ys,e),qs!==null&&mo(qs,e),Ho.forEach(t),Vo.forEach(t),n=0;n<Bs.length;n++)r=Bs[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Bs.length&&(n=Bs[0],n.blockedOn===null);)ry(n),n.blockedOn===null&&Bs.shift()}var ki=Ps.ReactCurrentBatchConfig,Xa=!0;function EN(e,t,n,r){var i=$e,o=ki.transition;ki.transition=null;try{$e=1,ep(e,t,n,r)}finally{$e=i,ki.transition=o}}function AN(e,t,n,r){var i=$e,o=ki.transition;ki.transition=null;try{$e=4,ep(e,t,n,r)}finally{$e=i,ki.transition=o}}function ep(e,t,n,r){if(Xa){var i=df(e,t,n,r);if(i===null)Ku(e,t,r,Za,n),Mg(e,r);else if(NN(i,e,t,n,r))r.stopPropagation();else if(Mg(e,r),t&4&&-1<SN.indexOf(e)){for(;i!==null;){var o=xl(i);if(o!==null&&ey(o),o=df(e,t,n,r),o===null&&Ku(e,t,r,Za,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else Ku(e,t,r,null,n)}}var Za=null;function df(e,t,n,r){if(Za=null,e=Qh(r),e=Sr(e),e!==null)if(t=Wr(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Kj(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Za=e,null}function iy(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(mN()){case Jh:return 1;case Qj:return 4;case Qa:case gN:return 16;case Jj:return 536870912;default:return 16}default:return 16}}var Hs=null,tp=null,Ca=null;function oy(){if(Ca)return Ca;var e,t=tp,n=t.length,r,i="value"in Hs?Hs.value:Hs.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var l=n-e;for(r=1;r<=l&&t[n-r]===i[o-r];r++);return Ca=i.slice(e,1<r?1-r:void 0)}function Ea(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 Wl(){return!0}function _g(){return!1}function vn(e){function t(n,r,i,o,l){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=l,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Wl:_g,this.isPropagationStopped=_g,this}return Qe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Wl)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Wl)},persist:function(){},isPersistent:Wl}),t}var Qi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},np=vn(Qi),gl=Qe({},Qi,{view:0,detail:0}),TN=vn(gl),Du,Lu,go,Dc=Qe({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sp,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!==go&&(go&&e.type==="mousemove"?(Du=e.screenX-go.screenX,Lu=e.screenY-go.screenY):Lu=Du=0,go=e),Du)},movementY:function(e){return"movementY"in e?e.movementY:Lu}}),Og=vn(Dc),RN=Qe({},Dc,{dataTransfer:0}),PN=vn(RN),IN=Qe({},gl,{relatedTarget:0}),Fu=vn(IN),MN=Qe({},Qi,{animationName:0,elapsedTime:0,pseudoElement:0}),$N=vn(MN),_N=Qe({},Qi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ON=vn(_N),DN=Qe({},Qi,{data:0}),Dg=vn(DN),LN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},FN={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"},zN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function UN(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=zN[e])?!!t[e]:!1}function sp(){return UN}var BN=Qe({},gl,{key:function(e){if(e.key){var t=LN[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ea(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?FN[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sp,charCode:function(e){return e.type==="keypress"?Ea(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ea(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),WN=vn(BN),HN=Qe({},Dc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lg=vn(HN),VN=Qe({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sp}),KN=vn(VN),GN=Qe({},Qi,{propertyName:0,elapsedTime:0,pseudoElement:0}),YN=vn(GN),qN=Qe({},Dc,{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}),QN=vn(qN),JN=[9,13,27,32],rp=bs&&"CompositionEvent"in window,Po=null;bs&&"documentMode"in document&&(Po=document.documentMode);var XN=bs&&"TextEvent"in window&&!Po,ly=bs&&(!rp||Po&&8<Po&&11>=Po),Fg=" ",zg=!1;function ay(e,t){switch(e){case"keyup":return JN.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cy(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ci=!1;function ZN(e,t){switch(e){case"compositionend":return cy(t);case"keypress":return t.which!==32?null:(zg=!0,Fg);case"textInput":return e=t.data,e===Fg&&zg?null:e;default:return null}}function eC(e,t){if(ci)return e==="compositionend"||!rp&&ay(e,t)?(e=oy(),Ca=tp=Hs=null,ci=!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 ly&&t.locale!=="ko"?null:t.data;default:return null}}var tC={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 Ug(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!tC[e.type]:t==="textarea"}function uy(e,t,n,r){Uj(r),t=ec(t,"onChange"),0<t.length&&(n=new np("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Io=null,Go=null;function nC(e){wy(e,0)}function Lc(e){var t=fi(e);if($j(t))return e}function sC(e,t){if(e==="change")return t}var dy=!1;if(bs){var zu;if(bs){var Uu="oninput"in document;if(!Uu){var Bg=document.createElement("div");Bg.setAttribute("oninput","return;"),Uu=typeof Bg.oninput=="function"}zu=Uu}else zu=!1;dy=zu&&(!document.documentMode||9<document.documentMode)}function Wg(){Io&&(Io.detachEvent("onpropertychange",fy),Go=Io=null)}function fy(e){if(e.propertyName==="value"&&Lc(Go)){var t=[];uy(t,Go,e,Qh(e)),Vj(nC,t)}}function rC(e,t,n){e==="focusin"?(Wg(),Io=t,Go=n,Io.attachEvent("onpropertychange",fy)):e==="focusout"&&Wg()}function iC(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Lc(Go)}function oC(e,t){if(e==="click")return Lc(t)}function lC(e,t){if(e==="input"||e==="change")return Lc(t)}function aC(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Fn=typeof Object.is=="function"?Object.is:aC;function Yo(e,t){if(Fn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Kd.call(t,i)||!Fn(e[i],t[i]))return!1}return!0}function Hg(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Vg(e,t){var n=Hg(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Hg(n)}}function hy(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hy(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function py(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function ip(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 cC(e){var t=py(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hy(n.ownerDocument.documentElement,n)){if(r!==null&&ip(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=Vg(n,o);var l=Vg(n,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(),o>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var uC=bs&&"documentMode"in document&&11>=document.documentMode,ui=null,ff=null,Mo=null,hf=!1;function Kg(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hf||ui==null||ui!==Ga(r)||(r=ui,"selectionStart"in r&&ip(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}),Mo&&Yo(Mo,r)||(Mo=r,r=ec(ff,"onSelect"),0<r.length&&(t=new np("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ui)))}function Hl(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var di={animationend:Hl("Animation","AnimationEnd"),animationiteration:Hl("Animation","AnimationIteration"),animationstart:Hl("Animation","AnimationStart"),transitionend:Hl("Transition","TransitionEnd")},Bu={},my={};bs&&(my=document.createElement("div").style,"AnimationEvent"in window||(delete di.animationend.animation,delete di.animationiteration.animation,delete di.animationstart.animation),"TransitionEvent"in window||delete di.transitionend.transition);function Fc(e){if(Bu[e])return Bu[e];if(!di[e])return e;var t=di[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in my)return Bu[e]=t[n];return e}var gy=Fc("animationend"),xy=Fc("animationiteration"),vy=Fc("animationstart"),jy=Fc("transitionend"),yy=new Map,Gg="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 dr(e,t){yy.set(e,t),Br(t,[e])}for(var Wu=0;Wu<Gg.length;Wu++){var Hu=Gg[Wu],dC=Hu.toLowerCase(),fC=Hu[0].toUpperCase()+Hu.slice(1);dr(dC,"on"+fC)}dr(gy,"onAnimationEnd");dr(xy,"onAnimationIteration");dr(vy,"onAnimationStart");dr("dblclick","onDoubleClick");dr("focusin","onFocus");dr("focusout","onBlur");dr(jy,"onTransitionEnd");Ri("onMouseEnter",["mouseout","mouseover"]);Ri("onMouseLeave",["mouseout","mouseover"]);Ri("onPointerEnter",["pointerout","pointerover"]);Ri("onPointerLeave",["pointerout","pointerover"]);Br("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Br("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Br("onBeforeInput",["compositionend","keypress","textInput","paste"]);Br("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Br("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Br("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(" "),hC=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ao));function Yg(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,dN(r,t,void 0,e),e.currentTarget=null}function wy(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var l=r.length-1;0<=l;l--){var a=r[l],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==o&&i.isPropagationStopped())break e;Yg(i,a,u),o=c}else for(l=0;l<r.length;l++){if(a=r[l],c=a.instance,u=a.currentTarget,a=a.listener,c!==o&&i.isPropagationStopped())break e;Yg(i,a,u),o=c}}}if(qa)throw e=af,qa=!1,af=null,e}function Be(e,t){var n=t[vf];n===void 0&&(n=t[vf]=new Set);var r=e+"__bubble";n.has(r)||(by(t,e,2,!1),n.add(r))}function Vu(e,t,n){var r=0;t&&(r|=4),by(n,e,r,t)}var Vl="_reactListening"+Math.random().toString(36).slice(2);function qo(e){if(!e[Vl]){e[Vl]=!0,Tj.forEach(function(n){n!=="selectionchange"&&(hC.has(n)||Vu(n,!1,e),Vu(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vl]||(t[Vl]=!0,Vu("selectionchange",!1,t))}}function by(e,t,n,r){switch(iy(t)){case 1:var i=EN;break;case 4:i=AN;break;default:i=ep}n=i.bind(null,t,n,e),i=void 0,!lf||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Ku(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.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(;a!==null;){if(l=Sr(a),l===null)return;if(c=l.tag,c===5||c===6){r=o=l;continue e}a=a.parentNode}}r=r.return}Vj(function(){var u=o,p=Qh(n),f=[];e:{var h=yy.get(e);if(h!==void 0){var x=np,j=e;switch(e){case"keypress":if(Ea(n)===0)break e;case"keydown":case"keyup":x=WN;break;case"focusin":j="focus",x=Fu;break;case"focusout":j="blur",x=Fu;break;case"beforeblur":case"afterblur":x=Fu;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":x=Og;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":x=PN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":x=KN;break;case gy:case xy:case vy:x=$N;break;case jy:x=YN;break;case"scroll":x=TN;break;case"wheel":x=QN;break;case"copy":case"cut":case"paste":x=ON;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":x=Lg}var w=(t&4)!==0,b=!w&&e==="scroll",v=w?h!==null?h+"Capture":null:h;w=[];for(var m=u,y;m!==null;){y=m;var g=y.stateNode;if(y.tag===5&&g!==null&&(y=g,v!==null&&(g=Wo(m,v),g!=null&&w.push(Qo(m,g,y)))),b)break;m=m.return}0<w.length&&(h=new x(h,j,null,n,p),f.push({event:h,listeners:w}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",x=e==="mouseout"||e==="pointerout",h&&n!==rf&&(j=n.relatedTarget||n.fromElement)&&(Sr(j)||j[ks]))break e;if((x||h)&&(h=p.window===p?p:(h=p.ownerDocument)?h.defaultView||h.parentWindow:window,x?(j=n.relatedTarget||n.toElement,x=u,j=j?Sr(j):null,j!==null&&(b=Wr(j),j!==b||j.tag!==5&&j.tag!==6)&&(j=null)):(x=null,j=u),x!==j)){if(w=Og,g="onMouseLeave",v="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(w=Lg,g="onPointerLeave",v="onPointerEnter",m="pointer"),b=x==null?h:fi(x),y=j==null?h:fi(j),h=new w(g,m+"leave",x,n,p),h.target=b,h.relatedTarget=y,g=null,Sr(p)===u&&(w=new w(v,m+"enter",j,n,p),w.target=y,w.relatedTarget=b,g=w),b=g,x&&j)t:{for(w=x,v=j,m=0,y=w;y;y=ei(y))m++;for(y=0,g=v;g;g=ei(g))y++;for(;0<m-y;)w=ei(w),m--;for(;0<y-m;)v=ei(v),y--;for(;m--;){if(w===v||v!==null&&w===v.alternate)break t;w=ei(w),v=ei(v)}w=null}else w=null;x!==null&&qg(f,h,x,w,!1),j!==null&&b!==null&&qg(f,b,j,w,!0)}}e:{if(h=u?fi(u):window,x=h.nodeName&&h.nodeName.toLowerCase(),x==="select"||x==="input"&&h.type==="file")var k=sC;else if(Ug(h))if(dy)k=lC;else{k=iC;var S=rC}else(x=h.nodeName)&&x.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(k=oC);if(k&&(k=k(e,u))){uy(f,k,n,p);break e}S&&S(e,h,u),e==="focusout"&&(S=h._wrapperState)&&S.controlled&&h.type==="number"&&Zd(h,"number",h.value)}switch(S=u?fi(u):window,e){case"focusin":(Ug(S)||S.contentEditable==="true")&&(ui=S,ff=u,Mo=null);break;case"focusout":Mo=ff=ui=null;break;case"mousedown":hf=!0;break;case"contextmenu":case"mouseup":case"dragend":hf=!1,Kg(f,n,p);break;case"selectionchange":if(uC)break;case"keydown":case"keyup":Kg(f,n,p)}var N;if(rp)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 ci?ay(e,n)&&(C="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(ly&&n.locale!=="ko"&&(ci||C!=="onCompositionStart"?C==="onCompositionEnd"&&ci&&(N=oy()):(Hs=p,tp="value"in Hs?Hs.value:Hs.textContent,ci=!0)),S=ec(u,C),0<S.length&&(C=new Dg(C,e,null,n,p),f.push({event:C,listeners:S}),N?C.data=N:(N=cy(n),N!==null&&(C.data=N)))),(N=XN?ZN(e,n):eC(e,n))&&(u=ec(u,"onBeforeInput"),0<u.length&&(p=new Dg("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=N))}wy(f,t)})}function Qo(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ec(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=Wo(e,n),o!=null&&r.unshift(Qo(e,o,i)),o=Wo(e,t),o!=null&&r.push(Qo(e,o,i))),e=e.return}return r}function ei(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function qg(e,t,n,r,i){for(var o=t._reactName,l=[];n!==null&&n!==r;){var a=n,c=a.alternate,u=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&u!==null&&(a=u,i?(c=Wo(n,o),c!=null&&l.unshift(Qo(n,c,a))):i||(c=Wo(n,o),c!=null&&l.push(Qo(n,c,a)))),n=n.return}l.length!==0&&e.push({event:t,listeners:l})}var pC=/\r\n?/g,mC=/\u0000|\uFFFD/g;function Qg(e){return(typeof e=="string"?e:""+e).replace(pC,`
|
|
38
|
-
`).replace(mC,"")}function Kl(e,t,n){if(t=Qg(t),Qg(e)!==t&&n)throw Error(Q(425))}function tc(){}var pf=null,mf=null;function gf(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 xf=typeof setTimeout=="function"?setTimeout:void 0,gC=typeof clearTimeout=="function"?clearTimeout:void 0,Jg=typeof Promise=="function"?Promise:void 0,xC=typeof queueMicrotask=="function"?queueMicrotask:typeof Jg<"u"?function(e){return Jg.resolve(null).then(e).catch(vC)}:xf;function vC(e){setTimeout(function(){throw e})}function Gu(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Ko(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Ko(t)}function Qs(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 Xg(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Ji=Math.random().toString(36).slice(2),Qn="__reactFiber$"+Ji,Jo="__reactProps$"+Ji,ks="__reactContainer$"+Ji,vf="__reactEvents$"+Ji,jC="__reactListeners$"+Ji,yC="__reactHandles$"+Ji;function Sr(e){var t=e[Qn];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ks]||n[Qn]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Xg(e);e!==null;){if(n=e[Qn])return n;e=Xg(e)}return t}e=n,n=e.parentNode}return null}function xl(e){return e=e[Qn]||e[ks],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function fi(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Q(33))}function zc(e){return e[Jo]||null}var jf=[],hi=-1;function fr(e){return{current:e}}function We(e){0>hi||(e.current=jf[hi],jf[hi]=null,hi--)}function Ue(e,t){hi++,jf[hi]=e.current,e.current=t}var ir={},zt=fr(ir),en=fr(!1),Pr=ir;function Pi(e,t){var n=e.type.contextTypes;if(!n)return ir;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function tn(e){return e=e.childContextTypes,e!=null}function nc(){We(en),We(zt)}function Zg(e,t,n){if(zt.current!==ir)throw Error(Q(168));Ue(zt,t),Ue(en,n)}function ky(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Q(108,rN(e)||"Unknown",i));return Qe({},n,r)}function sc(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||ir,Pr=zt.current,Ue(zt,e),Ue(en,en.current),!0}function ex(e,t,n){var r=e.stateNode;if(!r)throw Error(Q(169));n?(e=ky(e,t,Pr),r.__reactInternalMemoizedMergedChildContext=e,We(en),We(zt),Ue(zt,e)):We(en),Ue(en,n)}var ms=null,Uc=!1,Yu=!1;function Sy(e){ms===null?ms=[e]:ms.push(e)}function wC(e){Uc=!0,Sy(e)}function hr(){if(!Yu&&ms!==null){Yu=!0;var e=0,t=$e;try{var n=ms;for($e=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}ms=null,Uc=!1}catch(i){throw ms!==null&&(ms=ms.slice(e+1)),qj(Jh,hr),i}finally{$e=t,Yu=!1}}return null}var pi=[],mi=0,rc=null,ic=0,wn=[],bn=0,Ir=null,gs=1,xs="";function br(e,t){pi[mi++]=ic,pi[mi++]=rc,rc=e,ic=t}function Ny(e,t,n){wn[bn++]=gs,wn[bn++]=xs,wn[bn++]=Ir,Ir=e;var r=gs;e=xs;var i=32-Dn(r)-1;r&=~(1<<i),n+=1;var o=32-Dn(t)+i;if(30<o){var l=i-i%5;o=(r&(1<<l)-1).toString(32),r>>=l,i-=l,gs=1<<32-Dn(t)+i|n<<i|r,xs=o+e}else gs=1<<o|n<<i|r,xs=e}function op(e){e.return!==null&&(br(e,1),Ny(e,1,0))}function lp(e){for(;e===rc;)rc=pi[--mi],pi[mi]=null,ic=pi[--mi],pi[mi]=null;for(;e===Ir;)Ir=wn[--bn],wn[bn]=null,xs=wn[--bn],wn[bn]=null,gs=wn[--bn],wn[bn]=null}var mn=null,hn=null,Ke=!1,_n=null;function Cy(e,t){var n=Sn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function tx(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,mn=e,hn=Qs(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,mn=e,hn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ir!==null?{id:gs,overflow:xs}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Sn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,mn=e,hn=null,!0):!1;default:return!1}}function yf(e){return(e.mode&1)!==0&&(e.flags&128)===0}function wf(e){if(Ke){var t=hn;if(t){var n=t;if(!tx(e,t)){if(yf(e))throw Error(Q(418));t=Qs(n.nextSibling);var r=mn;t&&tx(e,t)?Cy(r,n):(e.flags=e.flags&-4097|2,Ke=!1,mn=e)}}else{if(yf(e))throw Error(Q(418));e.flags=e.flags&-4097|2,Ke=!1,mn=e}}}function nx(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;mn=e}function Gl(e){if(e!==mn)return!1;if(!Ke)return nx(e),Ke=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!gf(e.type,e.memoizedProps)),t&&(t=hn)){if(yf(e))throw Ey(),Error(Q(418));for(;t;)Cy(e,t),t=Qs(t.nextSibling)}if(nx(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){hn=Qs(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}hn=null}}else hn=mn?Qs(e.stateNode.nextSibling):null;return!0}function Ey(){for(var e=hn;e;)e=Qs(e.nextSibling)}function Ii(){hn=mn=null,Ke=!1}function ap(e){_n===null?_n=[e]:_n.push(e)}var bC=Ps.ReactCurrentBatchConfig;function xo(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Q(309));var r=n.stateNode}if(!r)throw Error(Q(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(l){var a=i.refs;l===null?delete a[o]:a[o]=l},t._stringRef=o,t)}if(typeof e!="string")throw Error(Q(284));if(!n._owner)throw Error(Q(290,e))}return e}function Yl(e,t){throw e=Object.prototype.toString.call(t),Error(Q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function sx(e){var t=e._init;return t(e._payload)}function Ay(e){function t(v,m){if(e){var y=v.deletions;y===null?(v.deletions=[m],v.flags|=16):y.push(m)}}function n(v,m){if(!e)return null;for(;m!==null;)t(v,m),m=m.sibling;return null}function r(v,m){for(v=new Map;m!==null;)m.key!==null?v.set(m.key,m):v.set(m.index,m),m=m.sibling;return v}function i(v,m){return v=er(v,m),v.index=0,v.sibling=null,v}function o(v,m,y){return v.index=y,e?(y=v.alternate,y!==null?(y=y.index,y<m?(v.flags|=2,m):y):(v.flags|=2,m)):(v.flags|=1048576,m)}function l(v){return e&&v.alternate===null&&(v.flags|=2),v}function a(v,m,y,g){return m===null||m.tag!==6?(m=td(y,v.mode,g),m.return=v,m):(m=i(m,y),m.return=v,m)}function c(v,m,y,g){var k=y.type;return k===ai?p(v,m,y.props.children,g,y.key):m!==null&&(m.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===zs&&sx(k)===m.type)?(g=i(m,y.props),g.ref=xo(v,m,y),g.return=v,g):(g=$a(y.type,y.key,y.props,null,v.mode,g),g.ref=xo(v,m,y),g.return=v,g)}function u(v,m,y,g){return m===null||m.tag!==4||m.stateNode.containerInfo!==y.containerInfo||m.stateNode.implementation!==y.implementation?(m=nd(y,v.mode,g),m.return=v,m):(m=i(m,y.children||[]),m.return=v,m)}function p(v,m,y,g,k){return m===null||m.tag!==7?(m=Ar(y,v.mode,g,k),m.return=v,m):(m=i(m,y),m.return=v,m)}function f(v,m,y){if(typeof m=="string"&&m!==""||typeof m=="number")return m=td(""+m,v.mode,y),m.return=v,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Dl:return y=$a(m.type,m.key,m.props,null,v.mode,y),y.ref=xo(v,null,m),y.return=v,y;case li:return m=nd(m,v.mode,y),m.return=v,m;case zs:var g=m._init;return f(v,g(m._payload),y)}if(Co(m)||fo(m))return m=Ar(m,v.mode,y,null),m.return=v,m;Yl(v,m)}return null}function h(v,m,y,g){var k=m!==null?m.key:null;if(typeof y=="string"&&y!==""||typeof y=="number")return k!==null?null:a(v,m,""+y,g);if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Dl:return y.key===k?c(v,m,y,g):null;case li:return y.key===k?u(v,m,y,g):null;case zs:return k=y._init,h(v,m,k(y._payload),g)}if(Co(y)||fo(y))return k!==null?null:p(v,m,y,g,null);Yl(v,y)}return null}function x(v,m,y,g,k){if(typeof g=="string"&&g!==""||typeof g=="number")return v=v.get(y)||null,a(m,v,""+g,k);if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Dl:return v=v.get(g.key===null?y:g.key)||null,c(m,v,g,k);case li:return v=v.get(g.key===null?y:g.key)||null,u(m,v,g,k);case zs:var S=g._init;return x(v,m,y,S(g._payload),k)}if(Co(g)||fo(g))return v=v.get(y)||null,p(m,v,g,k,null);Yl(m,g)}return null}function j(v,m,y,g){for(var k=null,S=null,N=m,C=m=0,P=null;N!==null&&C<y.length;C++){N.index>C?(P=N,N=null):P=N.sibling;var E=h(v,N,y[C],g);if(E===null){N===null&&(N=P);break}e&&N&&E.alternate===null&&t(v,N),m=o(E,m,C),S===null?k=E:S.sibling=E,S=E,N=P}if(C===y.length)return n(v,N),Ke&&br(v,C),k;if(N===null){for(;C<y.length;C++)N=f(v,y[C],g),N!==null&&(m=o(N,m,C),S===null?k=N:S.sibling=N,S=N);return Ke&&br(v,C),k}for(N=r(v,N);C<y.length;C++)P=x(N,v,C,y[C],g),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?C:P.key),m=o(P,m,C),S===null?k=P:S.sibling=P,S=P);return e&&N.forEach(function(O){return t(v,O)}),Ke&&br(v,C),k}function w(v,m,y,g){var k=fo(y);if(typeof k!="function")throw Error(Q(150));if(y=k.call(y),y==null)throw Error(Q(151));for(var S=k=null,N=m,C=m=0,P=null,E=y.next();N!==null&&!E.done;C++,E=y.next()){N.index>C?(P=N,N=null):P=N.sibling;var O=h(v,N,E.value,g);if(O===null){N===null&&(N=P);break}e&&N&&O.alternate===null&&t(v,N),m=o(O,m,C),S===null?k=O:S.sibling=O,S=O,N=P}if(E.done)return n(v,N),Ke&&br(v,C),k;if(N===null){for(;!E.done;C++,E=y.next())E=f(v,E.value,g),E!==null&&(m=o(E,m,C),S===null?k=E:S.sibling=E,S=E);return Ke&&br(v,C),k}for(N=r(v,N);!E.done;C++,E=y.next())E=x(N,v,C,E.value,g),E!==null&&(e&&E.alternate!==null&&N.delete(E.key===null?C:E.key),m=o(E,m,C),S===null?k=E:S.sibling=E,S=E);return e&&N.forEach(function(L){return t(v,L)}),Ke&&br(v,C),k}function b(v,m,y,g){if(typeof y=="object"&&y!==null&&y.type===ai&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Dl:e:{for(var k=y.key,S=m;S!==null;){if(S.key===k){if(k=y.type,k===ai){if(S.tag===7){n(v,S.sibling),m=i(S,y.props.children),m.return=v,v=m;break e}}else if(S.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===zs&&sx(k)===S.type){n(v,S.sibling),m=i(S,y.props),m.ref=xo(v,S,y),m.return=v,v=m;break e}n(v,S);break}else t(v,S);S=S.sibling}y.type===ai?(m=Ar(y.props.children,v.mode,g,y.key),m.return=v,v=m):(g=$a(y.type,y.key,y.props,null,v.mode,g),g.ref=xo(v,m,y),g.return=v,v=g)}return l(v);case li:e:{for(S=y.key;m!==null;){if(m.key===S)if(m.tag===4&&m.stateNode.containerInfo===y.containerInfo&&m.stateNode.implementation===y.implementation){n(v,m.sibling),m=i(m,y.children||[]),m.return=v,v=m;break e}else{n(v,m);break}else t(v,m);m=m.sibling}m=nd(y,v.mode,g),m.return=v,v=m}return l(v);case zs:return S=y._init,b(v,m,S(y._payload),g)}if(Co(y))return j(v,m,y,g);if(fo(y))return w(v,m,y,g);Yl(v,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,m!==null&&m.tag===6?(n(v,m.sibling),m=i(m,y),m.return=v,v=m):(n(v,m),m=td(y,v.mode,g),m.return=v,v=m),l(v)):n(v,m)}return b}var Mi=Ay(!0),Ty=Ay(!1),oc=fr(null),lc=null,gi=null,cp=null;function up(){cp=gi=lc=null}function dp(e){var t=oc.current;We(oc),e._currentValue=t}function bf(e,t,n){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===n)break;e=e.return}}function Si(e,t){lc=e,cp=gi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Xt=!0),e.firstContext=null)}function Cn(e){var t=e._currentValue;if(cp!==e)if(e={context:e,memoizedValue:t,next:null},gi===null){if(lc===null)throw Error(Q(308));gi=e,lc.dependencies={lanes:0,firstContext:e}}else gi=gi.next=e;return t}var Nr=null;function fp(e){Nr===null?Nr=[e]:Nr.push(e)}function Ry(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,fp(t)):(n.next=i.next,i.next=n),t.interleaved=n,Ss(e,r)}function Ss(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Us=!1;function hp(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Py(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 vs(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Js(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Te&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Ss(e,n)}return i=r.interleaved,i===null?(t.next=t,fp(r)):(t.next=i.next,i.next=t),r.interleaved=t,Ss(e,n)}function Aa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xh(e,n)}}function rx(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=l:o=o.next=l,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ac(e,t,n,r){var i=e.updateQueue;Us=!1;var o=i.firstBaseUpdate,l=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var c=a,u=c.next;c.next=null,l===null?o=u:l.next=u,l=c;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==l&&(a===null?p.firstBaseUpdate=u:a.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=i.baseState;l=0,p=u=c=null,a=o;do{var h=a.lane,x=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:x,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var j=e,w=a;switch(h=t,x=n,w.tag){case 1:if(j=w.payload,typeof j=="function"){f=j.call(x,f,h);break e}f=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=w.payload,h=typeof j=="function"?j.call(x,f,h):j,h==null)break e;f=Qe({},f,h);break e;case 2:Us=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[a]:h.push(a))}else x={eventTime:x,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(u=p=x,c=f):p=p.next=x,l|=h;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;h=a,a=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(p===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=p,t=i.shared.interleaved,t!==null){i=t;do l|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);$r|=l,e.lanes=l,e.memoizedState=f}}function ix(e,t,n){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=n,typeof i!="function")throw Error(Q(191,i));i.call(r)}}}var vl={},ts=fr(vl),Xo=fr(vl),Zo=fr(vl);function Cr(e){if(e===vl)throw Error(Q(174));return e}function pp(e,t){switch(Ue(Zo,t),Ue(Xo,e),Ue(ts,vl),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:tf(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=tf(t,e)}We(ts),Ue(ts,t)}function $i(){We(ts),We(Xo),We(Zo)}function Iy(e){Cr(Zo.current);var t=Cr(ts.current),n=tf(t,e.type);t!==n&&(Ue(Xo,e),Ue(ts,n))}function mp(e){Xo.current===e&&(We(ts),We(Xo))}var Ge=fr(0);function cc(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.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 qu=[];function gp(){for(var e=0;e<qu.length;e++)qu[e]._workInProgressVersionPrimary=null;qu.length=0}var Ta=Ps.ReactCurrentDispatcher,Qu=Ps.ReactCurrentBatchConfig,Mr=0,Ye=null,ut=null,mt=null,uc=!1,$o=!1,el=0,kC=0;function $t(){throw Error(Q(321))}function xp(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Fn(e[n],t[n]))return!1;return!0}function vp(e,t,n,r,i,o){if(Mr=o,Ye=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ta.current=e===null||e.memoizedState===null?EC:AC,e=n(r,i),$o){o=0;do{if($o=!1,el=0,25<=o)throw Error(Q(301));o+=1,mt=ut=null,t.updateQueue=null,Ta.current=TC,e=n(r,i)}while($o)}if(Ta.current=dc,t=ut!==null&&ut.next!==null,Mr=0,mt=ut=Ye=null,uc=!1,t)throw Error(Q(300));return e}function jp(){var e=el!==0;return el=0,e}function qn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mt===null?Ye.memoizedState=mt=e:mt=mt.next=e,mt}function En(){if(ut===null){var e=Ye.alternate;e=e!==null?e.memoizedState:null}else e=ut.next;var t=mt===null?Ye.memoizedState:mt.next;if(t!==null)mt=t,ut=e;else{if(e===null)throw Error(Q(310));ut=e,e={memoizedState:ut.memoizedState,baseState:ut.baseState,baseQueue:ut.baseQueue,queue:ut.queue,next:null},mt===null?Ye.memoizedState=mt=e:mt=mt.next=e}return mt}function tl(e,t){return typeof t=="function"?t(e):t}function Ju(e){var t=En(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=ut,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var l=i.next;i.next=o.next,o.next=l}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var a=l=null,c=null,u=o;do{var p=u.lane;if((Mr&p)===p)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:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(a=c=f,l=r):c=c.next=f,Ye.lanes|=p,$r|=p}u=u.next}while(u!==null&&u!==o);c===null?l=r:c.next=a,Fn(r,t.memoizedState)||(Xt=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Ye.lanes|=o,$r|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Xu(e){var t=En(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var l=i=i.next;do o=e(o,l.action),l=l.next;while(l!==i);Fn(o,t.memoizedState)||(Xt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function My(){}function $y(e,t){var n=Ye,r=En(),i=t(),o=!Fn(r.memoizedState,i);if(o&&(r.memoizedState=i,Xt=!0),r=r.queue,yp(Dy.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||mt!==null&&mt.memoizedState.tag&1){if(n.flags|=2048,nl(9,Oy.bind(null,n,r,i,t),void 0,null),vt===null)throw Error(Q(349));Mr&30||_y(n,t,i)}return i}function _y(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ye.updateQueue,t===null?(t={lastEffect:null,stores:null},Ye.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Oy(e,t,n,r){t.value=n,t.getSnapshot=r,Ly(t)&&Fy(e)}function Dy(e,t,n){return n(function(){Ly(t)&&Fy(e)})}function Ly(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Fn(e,n)}catch{return!0}}function Fy(e){var t=Ss(e,1);t!==null&&Ln(t,e,1,-1)}function ox(e){var t=qn();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:e},t.queue=e,e=e.dispatch=CC.bind(null,Ye,e),[t.memoizedState,e]}function nl(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Ye.updateQueue,t===null?(t={lastEffect:null,stores:null},Ye.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function zy(){return En().memoizedState}function Ra(e,t,n,r){var i=qn();Ye.flags|=e,i.memoizedState=nl(1|t,n,void 0,r===void 0?null:r)}function Bc(e,t,n,r){var i=En();r=r===void 0?null:r;var o=void 0;if(ut!==null){var l=ut.memoizedState;if(o=l.destroy,r!==null&&xp(r,l.deps)){i.memoizedState=nl(t,n,o,r);return}}Ye.flags|=e,i.memoizedState=nl(1|t,n,o,r)}function lx(e,t){return Ra(8390656,8,e,t)}function yp(e,t){return Bc(2048,8,e,t)}function Uy(e,t){return Bc(4,2,e,t)}function By(e,t){return Bc(4,4,e,t)}function Wy(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 Hy(e,t,n){return n=n!=null?n.concat([e]):null,Bc(4,4,Wy.bind(null,t,e),n)}function wp(){}function Vy(e,t){var n=En();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xp(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ky(e,t){var n=En();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xp(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Gy(e,t,n){return Mr&21?(Fn(n,t)||(n=Xj(),Ye.lanes|=n,$r|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Xt=!0),e.memoizedState=n)}function SC(e,t){var n=$e;$e=n!==0&&4>n?n:4,e(!0);var r=Qu.transition;Qu.transition={};try{e(!1),t()}finally{$e=n,Qu.transition=r}}function Yy(){return En().memoizedState}function NC(e,t,n){var r=Zs(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},qy(e))Qy(t,n);else if(n=Ry(e,t,n,r),n!==null){var i=Ht();Ln(n,e,r,i),Jy(n,t,r)}}function CC(e,t,n){var r=Zs(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(qy(e))Qy(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var l=t.lastRenderedState,a=o(l,n);if(i.hasEagerState=!0,i.eagerState=a,Fn(a,l)){var c=t.interleaved;c===null?(i.next=i,fp(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=Ry(e,t,i,r),n!==null&&(i=Ht(),Ln(n,e,r,i),Jy(n,t,r))}}function qy(e){var t=e.alternate;return e===Ye||t!==null&&t===Ye}function Qy(e,t){$o=uc=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Jy(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xh(e,n)}}var dc={readContext:Cn,useCallback:$t,useContext:$t,useEffect:$t,useImperativeHandle:$t,useInsertionEffect:$t,useLayoutEffect:$t,useMemo:$t,useReducer:$t,useRef:$t,useState:$t,useDebugValue:$t,useDeferredValue:$t,useTransition:$t,useMutableSource:$t,useSyncExternalStore:$t,useId:$t,unstable_isNewReconciler:!1},EC={readContext:Cn,useCallback:function(e,t){return qn().memoizedState=[e,t===void 0?null:t],e},useContext:Cn,useEffect:lx,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ra(4194308,4,Wy.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ra(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ra(4,2,e,t)},useMemo:function(e,t){var n=qn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=qn();return t=n!==void 0?n(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=NC.bind(null,Ye,e),[r.memoizedState,e]},useRef:function(e){var t=qn();return e={current:e},t.memoizedState=e},useState:ox,useDebugValue:wp,useDeferredValue:function(e){return qn().memoizedState=e},useTransition:function(){var e=ox(!1),t=e[0];return e=SC.bind(null,e[1]),qn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Ye,i=qn();if(Ke){if(n===void 0)throw Error(Q(407));n=n()}else{if(n=t(),vt===null)throw Error(Q(349));Mr&30||_y(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,lx(Dy.bind(null,r,o,e),[e]),r.flags|=2048,nl(9,Oy.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=qn(),t=vt.identifierPrefix;if(Ke){var n=xs,r=gs;n=(r&~(1<<32-Dn(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=el++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=kC++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},AC={readContext:Cn,useCallback:Vy,useContext:Cn,useEffect:yp,useImperativeHandle:Hy,useInsertionEffect:Uy,useLayoutEffect:By,useMemo:Ky,useReducer:Ju,useRef:zy,useState:function(){return Ju(tl)},useDebugValue:wp,useDeferredValue:function(e){var t=En();return Gy(t,ut.memoizedState,e)},useTransition:function(){var e=Ju(tl)[0],t=En().memoizedState;return[e,t]},useMutableSource:My,useSyncExternalStore:$y,useId:Yy,unstable_isNewReconciler:!1},TC={readContext:Cn,useCallback:Vy,useContext:Cn,useEffect:yp,useImperativeHandle:Hy,useInsertionEffect:Uy,useLayoutEffect:By,useMemo:Ky,useReducer:Xu,useRef:zy,useState:function(){return Xu(tl)},useDebugValue:wp,useDeferredValue:function(e){var t=En();return ut===null?t.memoizedState=e:Gy(t,ut.memoizedState,e)},useTransition:function(){var e=Xu(tl)[0],t=En().memoizedState;return[e,t]},useMutableSource:My,useSyncExternalStore:$y,useId:Yy,unstable_isNewReconciler:!1};function Mn(e,t){if(e&&e.defaultProps){t=Qe({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function kf(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Qe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Wc={isMounted:function(e){return(e=e._reactInternals)?Wr(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ht(),i=Zs(e),o=vs(r,i);o.payload=t,n!=null&&(o.callback=n),t=Js(e,o,i),t!==null&&(Ln(t,e,i,r),Aa(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ht(),i=Zs(e),o=vs(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Js(e,o,i),t!==null&&(Ln(t,e,i,r),Aa(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ht(),r=Zs(e),i=vs(n,r);i.tag=2,t!=null&&(i.callback=t),t=Js(e,i,r),t!==null&&(Ln(t,e,r,n),Aa(t,e,r))}};function ax(e,t,n,r,i,o,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,l):t.prototype&&t.prototype.isPureReactComponent?!Yo(n,r)||!Yo(i,o):!0}function Xy(e,t,n){var r=!1,i=ir,o=t.contextType;return typeof o=="object"&&o!==null?o=Cn(o):(i=tn(t)?Pr:zt.current,r=t.contextTypes,o=(r=r!=null)?Pi(e,i):ir),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Wc,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function cx(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Wc.enqueueReplaceState(t,t.state,null)}function Sf(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},hp(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=Cn(o):(o=tn(t)?Pr:zt.current,i.context=Pi(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(kf(e,t,o,n),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&&Wc.enqueueReplaceState(i,i.state,null),ac(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function _i(e,t){try{var n="",r=t;do n+=sN(r),r=r.return;while(r);var i=n}catch(o){i=`
|
|
39
|
-
Error generating stack: `+o.message+`
|
|
40
|
-
`+o.stack}return{value:e,source:t,stack:i,digest:null}}function Zu(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Nf(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var RC=typeof WeakMap=="function"?WeakMap:Map;function Zy(e,t,n){n=vs(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){hc||(hc=!0,_f=r),Nf(e,t)},n}function ew(e,t,n){n=vs(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Nf(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Nf(e,t),typeof r!="function"&&(Xs===null?Xs=new Set([this]):Xs.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),n}function ux(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new RC;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(n)||(i.add(n),e=HC.bind(null,e,t,n),t.then(e,e))}function dx(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 fx(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=vs(-1,1),t.tag=2,Js(n,t,1))),n.lanes|=1),e)}var PC=Ps.ReactCurrentOwner,Xt=!1;function Ut(e,t,n,r){t.child=e===null?Ty(t,null,n,r):Mi(t,e.child,n,r)}function hx(e,t,n,r,i){n=n.render;var o=t.ref;return Si(t,i),r=vp(e,t,n,r,o,i),n=jp(),e!==null&&!Xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ns(e,t,i)):(Ke&&n&&op(t),t.flags|=1,Ut(e,t,r,i),t.child)}function px(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Tp(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,tw(e,t,o,r,i)):(e=$a(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var l=o.memoizedProps;if(n=n.compare,n=n!==null?n:Yo,n(l,r)&&e.ref===t.ref)return Ns(e,t,i)}return t.flags|=1,e=er(o,r),e.ref=t.ref,e.return=t,t.child=e}function tw(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(Yo(o,r)&&e.ref===t.ref)if(Xt=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(Xt=!0);else return t.lanes=e.lanes,Ns(e,t,i)}return Cf(e,t,n,r,i)}function nw(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ue(vi,dn),dn|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ue(vi,dn),dn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,Ue(vi,dn),dn|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,Ue(vi,dn),dn|=r;return Ut(e,t,i,n),t.child}function sw(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Cf(e,t,n,r,i){var o=tn(n)?Pr:zt.current;return o=Pi(t,o),Si(t,i),n=vp(e,t,n,r,o,i),r=jp(),e!==null&&!Xt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Ns(e,t,i)):(Ke&&r&&op(t),t.flags|=1,Ut(e,t,n,i),t.child)}function mx(e,t,n,r,i){if(tn(n)){var o=!0;sc(t)}else o=!1;if(Si(t,i),t.stateNode===null)Pa(e,t),Xy(t,n,r),Sf(t,n,r,i),r=!0;else if(e===null){var l=t.stateNode,a=t.memoizedProps;l.props=a;var c=l.context,u=n.contextType;typeof u=="object"&&u!==null?u=Cn(u):(u=tn(n)?Pr:zt.current,u=Pi(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof l.getSnapshotBeforeUpdate=="function";f||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==r||c!==u)&&cx(t,l,r,u),Us=!1;var h=t.memoizedState;l.state=h,ac(t,r,l,i),c=t.memoizedState,a!==r||h!==c||en.current||Us?(typeof p=="function"&&(kf(t,n,p,r),c=t.memoizedState),(a=Us||ax(t,n,a,r,h,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=a):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,Py(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Mn(t.type,a),l.props=u,f=t.pendingProps,h=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=Cn(c):(c=tn(n)?Pr:zt.current,c=Pi(t,c));var x=n.getDerivedStateFromProps;(p=typeof x=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(a!==f||h!==c)&&cx(t,l,r,c),Us=!1,h=t.memoizedState,l.state=h,ac(t,r,l,i);var j=t.memoizedState;a!==f||h!==j||en.current||Us?(typeof x=="function"&&(kf(t,n,x,r),j=t.memoizedState),(u=Us||ax(t,n,u,r,h,j,c)||!1)?(p||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,j,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,j,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=j),l.props=r,l.state=j,l.context=c,r=u):(typeof l.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Ef(e,t,n,r,o,i)}function Ef(e,t,n,r,i,o){sw(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return i&&ex(t,n,!1),Ns(e,t,o);r=t.stateNode,PC.current=t;var a=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=Mi(t,e.child,null,o),t.child=Mi(t,null,a,o)):Ut(e,t,a,o),t.memoizedState=r.state,i&&ex(t,n,!0),t.child}function rw(e){var t=e.stateNode;t.pendingContext?Zg(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Zg(e,t.context,!1),pp(e,t.containerInfo)}function gx(e,t,n,r,i){return Ii(),ap(i),t.flags|=256,Ut(e,t,n,r),t.child}var Af={dehydrated:null,treeContext:null,retryLane:0};function Tf(e){return{baseLanes:e,cachePool:null,transitions:null}}function iw(e,t,n){var r=t.pendingProps,i=Ge.current,o=!1,l=(t.flags&128)!==0,a;if((a=l)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ue(Ge,i&1),e===null)return wf(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,o?(r=t.mode,o=t.child,l={mode:"hidden",children:l},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=l):o=Kc(l,r,0,null),e=Ar(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Tf(n),t.memoizedState=Af,e):bp(t,l));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return IC(e,t,l,r,a,i,n);if(o){o=r.fallback,l=t.mode,i=e.child,a=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=er(i,c),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?o=er(a,o):(o=Ar(o,l,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,l=e.child.memoizedState,l=l===null?Tf(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=e.childLanes&~n,t.memoizedState=Af,r}return o=e.child,e=o.sibling,r=er(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function bp(e,t){return t=Kc({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function ql(e,t,n,r){return r!==null&&ap(r),Mi(t,e.child,null,n),e=bp(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function IC(e,t,n,r,i,o,l){if(n)return t.flags&256?(t.flags&=-257,r=Zu(Error(Q(422))),ql(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=Kc({mode:"visible",children:r.children},i,0,null),o=Ar(o,i,l,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Mi(t,e.child,null,l),t.child.memoizedState=Tf(l),t.memoizedState=Af,o);if(!(t.mode&1))return ql(e,t,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,o=Error(Q(419)),r=Zu(o,r,void 0),ql(e,t,l,r)}if(a=(l&e.childLanes)!==0,Xt||a){if(r=vt,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!==o.retryLane&&(o.retryLane=i,Ss(e,i),Ln(r,e,i,-1))}return Ap(),r=Zu(Error(Q(421))),ql(e,t,l,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=VC.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,hn=Qs(i.nextSibling),mn=t,Ke=!0,_n=null,e!==null&&(wn[bn++]=gs,wn[bn++]=xs,wn[bn++]=Ir,gs=e.id,xs=e.overflow,Ir=t),t=bp(t,r.children),t.flags|=4096,t)}function xx(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),bf(e.return,t,n)}function ed(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function ow(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(Ut(e,t,r.children,n),r=Ge.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&&xx(e,n,t);else if(e.tag===19)xx(e,n,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(Ue(Ge,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&cc(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ed(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&cc(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ed(t,!0,n,null,o);break;case"together":ed(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Pa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ns(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$r|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Q(153));if(t.child!==null){for(e=t.child,n=er(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=er(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function MC(e,t,n){switch(t.tag){case 3:rw(t),Ii();break;case 5:Iy(t);break;case 1:tn(t.type)&&sc(t);break;case 4:pp(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ue(oc,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ue(Ge,Ge.current&1),t.flags|=128,null):n&t.child.childLanes?iw(e,t,n):(Ue(Ge,Ge.current&1),e=Ns(e,t,n),e!==null?e.sibling:null);Ue(Ge,Ge.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return ow(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ue(Ge,Ge.current),r)break;return null;case 22:case 23:return t.lanes=0,nw(e,t,n)}return Ns(e,t,n)}var lw,Rf,aw,cw;lw=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Rf=function(){};aw=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Cr(ts.current);var o=null;switch(n){case"input":i=Jd(e,i),r=Jd(e,r),o=[];break;case"select":i=Qe({},i,{value:void 0}),r=Qe({},r,{value:void 0}),o=[];break;case"textarea":i=ef(e,i),r=ef(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=tc)}nf(n,r);var l;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var a=i[u];for(l in a)a.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Uo.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(a=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==a&&(c!=null||a!=null))if(u==="style")if(a){for(l in a)!a.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in c)c.hasOwnProperty(l)&&a[l]!==c[l]&&(n||(n={}),n[l]=c[l])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Uo.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Be("scroll",e),o||a===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};cw=function(e,t,n,r){n!==r&&(t.flags|=4)};function vo(e,t){if(!Ke)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function _t(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=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;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function $C(e,t,n){var r=t.pendingProps;switch(lp(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _t(t),null;case 1:return tn(t.type)&&nc(),_t(t),null;case 3:return r=t.stateNode,$i(),We(en),We(zt),gp(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Gl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,_n!==null&&(Lf(_n),_n=null))),Rf(e,t),_t(t),null;case 5:mp(t);var i=Cr(Zo.current);if(n=t.type,e!==null&&t.stateNode!=null)aw(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Q(166));return _t(t),null}if(e=Cr(ts.current),Gl(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Qn]=t,r[Jo]=o,e=(t.mode&1)!==0,n){case"dialog":Be("cancel",r),Be("close",r);break;case"iframe":case"object":case"embed":Be("load",r);break;case"video":case"audio":for(i=0;i<Ao.length;i++)Be(Ao[i],r);break;case"source":Be("error",r);break;case"img":case"image":case"link":Be("error",r),Be("load",r);break;case"details":Be("toggle",r);break;case"input":Cg(r,o),Be("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Be("invalid",r);break;case"textarea":Ag(r,o),Be("invalid",r)}nf(n,o),i=null;for(var l in o)if(o.hasOwnProperty(l)){var a=o[l];l==="children"?typeof a=="string"?r.textContent!==a&&(o.suppressHydrationWarning!==!0&&Kl(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(o.suppressHydrationWarning!==!0&&Kl(r.textContent,a,e),i=["children",""+a]):Uo.hasOwnProperty(l)&&a!=null&&l==="onScroll"&&Be("scroll",r)}switch(n){case"input":Ll(r),Eg(r,o,!0);break;case"textarea":Ll(r),Tg(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=tc)}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=Dj(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Qn]=t,e[Jo]=r,lw(e,t,!1,!1),t.stateNode=e;e:{switch(l=sf(n,r),n){case"dialog":Be("cancel",e),Be("close",e),i=r;break;case"iframe":case"object":case"embed":Be("load",e),i=r;break;case"video":case"audio":for(i=0;i<Ao.length;i++)Be(Ao[i],e);i=r;break;case"source":Be("error",e),i=r;break;case"img":case"image":case"link":Be("error",e),Be("load",e),i=r;break;case"details":Be("toggle",e),i=r;break;case"input":Cg(e,r),i=Jd(e,r),Be("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Qe({},r,{value:void 0}),Be("invalid",e);break;case"textarea":Ag(e,r),i=ef(e,r),Be("invalid",e);break;default:i=r}nf(n,i),a=i;for(o in a)if(a.hasOwnProperty(o)){var c=a[o];o==="style"?zj(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Lj(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Bo(e,c):typeof c=="number"&&Bo(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Uo.hasOwnProperty(o)?c!=null&&o==="onScroll"&&Be("scroll",e):c!=null&&Kh(e,o,c,l))}switch(n){case"input":Ll(e),Eg(e,r,!1);break;case"textarea":Ll(e),Tg(e);break;case"option":r.value!=null&&e.setAttribute("value",""+rr(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?yi(e,!!r.multiple,o,!1):r.defaultValue!=null&&yi(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=tc)}switch(n){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 _t(t),null;case 6:if(e&&t.stateNode!=null)cw(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Q(166));if(n=Cr(Zo.current),Cr(ts.current),Gl(t)){if(r=t.stateNode,n=t.memoizedProps,r[Qn]=t,(o=r.nodeValue!==n)&&(e=mn,e!==null))switch(e.tag){case 3:Kl(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Kl(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Qn]=t,t.stateNode=r}return _t(t),null;case 13:if(We(Ge),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Ke&&hn!==null&&t.mode&1&&!(t.flags&128))Ey(),Ii(),t.flags|=98560,o=!1;else if(o=Gl(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Q(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Q(317));o[Qn]=t}else Ii(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_t(t),o=!1}else _n!==null&&(Lf(_n),_n=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ge.current&1?ht===0&&(ht=3):Ap())),t.updateQueue!==null&&(t.flags|=4),_t(t),null);case 4:return $i(),Rf(e,t),e===null&&qo(t.stateNode.containerInfo),_t(t),null;case 10:return dp(t.type._context),_t(t),null;case 17:return tn(t.type)&&nc(),_t(t),null;case 19:if(We(Ge),o=t.memoizedState,o===null)return _t(t),null;if(r=(t.flags&128)!==0,l=o.rendering,l===null)if(r)vo(o,!1);else{if(ht!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=cc(e),l!==null){for(t.flags|=128,vo(o,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,l=o.alternate,l===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=l.childLanes,o.lanes=l.lanes,o.child=l.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=l.memoizedProps,o.memoizedState=l.memoizedState,o.updateQueue=l.updateQueue,o.type=l.type,e=l.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ue(Ge,Ge.current&1|2),t.child}e=e.sibling}o.tail!==null&&nt()>Oi&&(t.flags|=128,r=!0,vo(o,!1),t.lanes=4194304)}else{if(!r)if(e=cc(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),vo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Ke)return _t(t),null}else 2*nt()-o.renderingStartTime>Oi&&n!==1073741824&&(t.flags|=128,r=!0,vo(o,!1),t.lanes=4194304);o.isBackwards?(l.sibling=t.child,t.child=l):(n=o.last,n!==null?n.sibling=l:t.child=l,o.last=l)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=nt(),t.sibling=null,n=Ge.current,Ue(Ge,r?n&1|2:n&1),t):(_t(t),null);case 22:case 23:return Ep(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?dn&1073741824&&(_t(t),t.subtreeFlags&6&&(t.flags|=8192)):_t(t),null;case 24:return null;case 25:return null}throw Error(Q(156,t.tag))}function _C(e,t){switch(lp(t),t.tag){case 1:return tn(t.type)&&nc(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $i(),We(en),We(zt),gp(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return mp(t),null;case 13:if(We(Ge),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Q(340));Ii()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return We(Ge),null;case 4:return $i(),null;case 10:return dp(t.type._context),null;case 22:case 23:return Ep(),null;case 24:return null;default:return null}}var Ql=!1,Dt=!1,OC=typeof WeakSet=="function"?WeakSet:Set,oe=null;function xi(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Xe(e,t,r)}else n.current=null}function Pf(e,t,n){try{n()}catch(r){Xe(e,t,r)}}var vx=!1;function DC(e,t){if(pf=Xa,e=py(),ip(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var l=0,a=-1,c=-1,u=0,p=0,f=e,h=null;t:for(;;){for(var x;f!==n||i!==0&&f.nodeType!==3||(a=l+i),f!==o||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(x=f.firstChild)!==null;)h=f,f=x;for(;;){if(f===e)break t;if(h===n&&++u===i&&(a=l),h===o&&++p===r&&(c=l),(x=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=x}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(mf={focusedElem:e,selectionRange:n},Xa=!1,oe=t;oe!==null;)if(t=oe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,oe=e;else for(;oe!==null;){t=oe;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var w=j.memoizedProps,b=j.memoizedState,v=t.stateNode,m=v.getSnapshotBeforeUpdate(t.elementType===t.type?w:Mn(t.type,w),b);v.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Q(163))}}catch(g){Xe(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,oe=e;break}oe=t.return}return j=vx,vx=!1,j}function _o(e,t,n){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 o=i.destroy;i.destroy=void 0,o!==void 0&&Pf(t,n,o)}i=i.next}while(i!==r)}}function Hc(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function If(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function uw(e){var t=e.alternate;t!==null&&(e.alternate=null,uw(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Qn],delete t[Jo],delete t[vf],delete t[jC],delete t[yC])),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 dw(e){return e.tag===5||e.tag===3||e.tag===4}function jx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||dw(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 Mf(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=tc));else if(r!==4&&(e=e.child,e!==null))for(Mf(e,t,n),e=e.sibling;e!==null;)Mf(e,t,n),e=e.sibling}function $f(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for($f(e,t,n),e=e.sibling;e!==null;)$f(e,t,n),e=e.sibling}var Ct=null,$n=!1;function Ls(e,t,n){for(n=n.child;n!==null;)fw(e,t,n),n=n.sibling}function fw(e,t,n){if(es&&typeof es.onCommitFiberUnmount=="function")try{es.onCommitFiberUnmount(Oc,n)}catch{}switch(n.tag){case 5:Dt||xi(n,t);case 6:var r=Ct,i=$n;Ct=null,Ls(e,t,n),Ct=r,$n=i,Ct!==null&&($n?(e=Ct,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ct.removeChild(n.stateNode));break;case 18:Ct!==null&&($n?(e=Ct,n=n.stateNode,e.nodeType===8?Gu(e.parentNode,n):e.nodeType===1&&Gu(e,n),Ko(e)):Gu(Ct,n.stateNode));break;case 4:r=Ct,i=$n,Ct=n.stateNode.containerInfo,$n=!0,Ls(e,t,n),Ct=r,$n=i;break;case 0:case 11:case 14:case 15:if(!Dt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&Pf(n,t,l),i=i.next}while(i!==r)}Ls(e,t,n);break;case 1:if(!Dt&&(xi(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Xe(n,t,a)}Ls(e,t,n);break;case 21:Ls(e,t,n);break;case 22:n.mode&1?(Dt=(r=Dt)||n.memoizedState!==null,Ls(e,t,n),Dt=r):Ls(e,t,n);break;default:Ls(e,t,n)}}function yx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new OC),t.forEach(function(r){var i=KC.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Pn(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,l=t,a=l;e:for(;a!==null;){switch(a.tag){case 5:Ct=a.stateNode,$n=!1;break e;case 3:Ct=a.stateNode.containerInfo,$n=!0;break e;case 4:Ct=a.stateNode.containerInfo,$n=!0;break e}a=a.return}if(Ct===null)throw Error(Q(160));fw(o,l,i),Ct=null,$n=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Xe(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)hw(t,e),t=t.sibling}function hw(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Pn(t,e),Gn(e),r&4){try{_o(3,e,e.return),Hc(3,e)}catch(w){Xe(e,e.return,w)}try{_o(5,e,e.return)}catch(w){Xe(e,e.return,w)}}break;case 1:Pn(t,e),Gn(e),r&512&&n!==null&&xi(n,n.return);break;case 5:if(Pn(t,e),Gn(e),r&512&&n!==null&&xi(n,n.return),e.flags&32){var i=e.stateNode;try{Bo(i,"")}catch(w){Xe(e,e.return,w)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,l=n!==null?n.memoizedProps:o,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&o.type==="radio"&&o.name!=null&&_j(i,o),sf(a,l);var u=sf(a,o);for(l=0;l<c.length;l+=2){var p=c[l],f=c[l+1];p==="style"?zj(i,f):p==="dangerouslySetInnerHTML"?Lj(i,f):p==="children"?Bo(i,f):Kh(i,p,f,u)}switch(a){case"input":Xd(i,o);break;case"textarea":Oj(i,o);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var x=o.value;x!=null?yi(i,!!o.multiple,x,!1):h!==!!o.multiple&&(o.defaultValue!=null?yi(i,!!o.multiple,o.defaultValue,!0):yi(i,!!o.multiple,o.multiple?[]:"",!1))}i[Jo]=o}catch(w){Xe(e,e.return,w)}}break;case 6:if(Pn(t,e),Gn(e),r&4){if(e.stateNode===null)throw Error(Q(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(w){Xe(e,e.return,w)}}break;case 3:if(Pn(t,e),Gn(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ko(t.containerInfo)}catch(w){Xe(e,e.return,w)}break;case 4:Pn(t,e),Gn(e);break;case 13:Pn(t,e),Gn(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(Np=nt())),r&4&&yx(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Dt=(u=Dt)||p,Pn(t,e),Dt=u):Pn(t,e),Gn(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(oe=e,p=e.child;p!==null;){for(f=oe=p;oe!==null;){switch(h=oe,x=h.child,h.tag){case 0:case 11:case 14:case 15:_o(4,h,h.return);break;case 1:xi(h,h.return);var j=h.stateNode;if(typeof j.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,j.props=t.memoizedProps,j.state=t.memoizedState,j.componentWillUnmount()}catch(w){Xe(r,n,w)}}break;case 5:xi(h,h.return);break;case 22:if(h.memoizedState!==null){bx(f);continue}}x!==null?(x.return=h,oe=x):bx(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{i=f.stateNode,u?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(a=f.stateNode,c=f.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=Fj("display",l))}catch(w){Xe(e,e.return,w)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(w){Xe(e,e.return,w)}}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;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Pn(t,e),Gn(e),r&4&&yx(e);break;case 21:break;default:Pn(t,e),Gn(e)}}function Gn(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(dw(n)){var r=n;break e}n=n.return}throw Error(Q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Bo(i,""),r.flags&=-33);var o=jx(e);$f(e,o,i);break;case 3:case 4:var l=r.stateNode.containerInfo,a=jx(e);Mf(e,a,l);break;default:throw Error(Q(161))}}catch(c){Xe(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function LC(e,t,n){oe=e,pw(e)}function pw(e,t,n){for(var r=(e.mode&1)!==0;oe!==null;){var i=oe,o=i.child;if(i.tag===22&&r){var l=i.memoizedState!==null||Ql;if(!l){var a=i.alternate,c=a!==null&&a.memoizedState!==null||Dt;a=Ql;var u=Dt;if(Ql=l,(Dt=c)&&!u)for(oe=i;oe!==null;)l=oe,c=l.child,l.tag===22&&l.memoizedState!==null?kx(i):c!==null?(c.return=l,oe=c):kx(i);for(;o!==null;)oe=o,pw(o),o=o.sibling;oe=i,Ql=a,Dt=u}wx(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,oe=o):wx(e)}}function wx(e){for(;oe!==null;){var t=oe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Dt||Hc(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Dt)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Mn(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&ix(t,o,r);break;case 3:var l=t.updateQueue;if(l!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}ix(t,l,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.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 p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&Ko(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Q(163))}Dt||t.flags&512&&If(t)}catch(h){Xe(t,t.return,h)}}if(t===e){oe=null;break}if(n=t.sibling,n!==null){n.return=t.return,oe=n;break}oe=t.return}}function bx(e){for(;oe!==null;){var t=oe;if(t===e){oe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,oe=n;break}oe=t.return}}function kx(e){for(;oe!==null;){var t=oe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Hc(4,t)}catch(c){Xe(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Xe(t,i,c)}}var o=t.return;try{If(t)}catch(c){Xe(t,o,c)}break;case 5:var l=t.return;try{If(t)}catch(c){Xe(t,l,c)}}}catch(c){Xe(t,t.return,c)}if(t===e){oe=null;break}var a=t.sibling;if(a!==null){a.return=t.return,oe=a;break}oe=t.return}}var FC=Math.ceil,fc=Ps.ReactCurrentDispatcher,kp=Ps.ReactCurrentOwner,Nn=Ps.ReactCurrentBatchConfig,Te=0,vt=null,lt=null,Et=0,dn=0,vi=fr(0),ht=0,sl=null,$r=0,Vc=0,Sp=0,Oo=null,Qt=null,Np=0,Oi=1/0,hs=null,hc=!1,_f=null,Xs=null,Jl=!1,Vs=null,pc=0,Do=0,Of=null,Ia=-1,Ma=0;function Ht(){return Te&6?nt():Ia!==-1?Ia:Ia=nt()}function Zs(e){return e.mode&1?Te&2&&Et!==0?Et&-Et:bC.transition!==null?(Ma===0&&(Ma=Xj()),Ma):(e=$e,e!==0||(e=window.event,e=e===void 0?16:iy(e.type)),e):1}function Ln(e,t,n,r){if(50<Do)throw Do=0,Of=null,Error(Q(185));ml(e,n,r),(!(Te&2)||e!==vt)&&(e===vt&&(!(Te&2)&&(Vc|=n),ht===4&&Ws(e,Et)),nn(e,r),n===1&&Te===0&&!(t.mode&1)&&(Oi=nt()+500,Uc&&hr()))}function nn(e,t){var n=e.callbackNode;bN(e,t);var r=Ja(e,e===vt?Et:0);if(r===0)n!==null&&Ig(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Ig(n),t===1)e.tag===0?wC(Sx.bind(null,e)):Sy(Sx.bind(null,e)),xC(function(){!(Te&6)&&hr()}),n=null;else{switch(Zj(r)){case 1:n=Jh;break;case 4:n=Qj;break;case 16:n=Qa;break;case 536870912:n=Jj;break;default:n=Qa}n=bw(n,mw.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function mw(e,t){if(Ia=-1,Ma=0,Te&6)throw Error(Q(327));var n=e.callbackNode;if(Ni()&&e.callbackNode!==n)return null;var r=Ja(e,e===vt?Et:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=mc(e,r);else{t=r;var i=Te;Te|=2;var o=xw();(vt!==e||Et!==t)&&(hs=null,Oi=nt()+500,Er(e,t));do try{BC();break}catch(a){gw(e,a)}while(!0);up(),fc.current=o,Te=i,lt!==null?t=0:(vt=null,Et=0,t=ht)}if(t!==0){if(t===2&&(i=cf(e),i!==0&&(r=i,t=Df(e,i))),t===1)throw n=sl,Er(e,0),Ws(e,r),nn(e,nt()),n;if(t===6)Ws(e,r);else{if(i=e.current.alternate,!(r&30)&&!zC(i)&&(t=mc(e,r),t===2&&(o=cf(e),o!==0&&(r=o,t=Df(e,o))),t===1))throw n=sl,Er(e,0),Ws(e,r),nn(e,nt()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Q(345));case 2:kr(e,Qt,hs);break;case 3:if(Ws(e,r),(r&130023424)===r&&(t=Np+500-nt(),10<t)){if(Ja(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Ht(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=xf(kr.bind(null,e,Qt,hs),t);break}kr(e,Qt,hs);break;case 4:if(Ws(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var l=31-Dn(r);o=1<<l,l=t[l],l>i&&(i=l),r&=~o}if(r=i,r=nt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*FC(r/1960))-r,10<r){e.timeoutHandle=xf(kr.bind(null,e,Qt,hs),r);break}kr(e,Qt,hs);break;case 5:kr(e,Qt,hs);break;default:throw Error(Q(329))}}}return nn(e,nt()),e.callbackNode===n?mw.bind(null,e):null}function Df(e,t){var n=Oo;return e.current.memoizedState.isDehydrated&&(Er(e,t).flags|=256),e=mc(e,t),e!==2&&(t=Qt,Qt=n,t!==null&&Lf(t)),e}function Lf(e){Qt===null?Qt=e:Qt.push.apply(Qt,e)}function zC(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!Fn(o(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;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 Ws(e,t){for(t&=~Sp,t&=~Vc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Dn(t),r=1<<n;e[n]=-1,t&=~r}}function Sx(e){if(Te&6)throw Error(Q(327));Ni();var t=Ja(e,0);if(!(t&1))return nn(e,nt()),null;var n=mc(e,t);if(e.tag!==0&&n===2){var r=cf(e);r!==0&&(t=r,n=Df(e,r))}if(n===1)throw n=sl,Er(e,0),Ws(e,t),nn(e,nt()),n;if(n===6)throw Error(Q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,kr(e,Qt,hs),nn(e,nt()),null}function Cp(e,t){var n=Te;Te|=1;try{return e(t)}finally{Te=n,Te===0&&(Oi=nt()+500,Uc&&hr())}}function _r(e){Vs!==null&&Vs.tag===0&&!(Te&6)&&Ni();var t=Te;Te|=1;var n=Nn.transition,r=$e;try{if(Nn.transition=null,$e=1,e)return e()}finally{$e=r,Nn.transition=n,Te=t,!(Te&6)&&hr()}}function Ep(){dn=vi.current,We(vi)}function Er(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,gC(n)),lt!==null)for(n=lt.return;n!==null;){var r=n;switch(lp(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&nc();break;case 3:$i(),We(en),We(zt),gp();break;case 5:mp(r);break;case 4:$i();break;case 13:We(Ge);break;case 19:We(Ge);break;case 10:dp(r.type._context);break;case 22:case 23:Ep()}n=n.return}if(vt=e,lt=e=er(e.current,null),Et=dn=t,ht=0,sl=null,Sp=Vc=$r=0,Qt=Oo=null,Nr!==null){for(t=0;t<Nr.length;t++)if(n=Nr[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var l=o.next;o.next=i,r.next=l}n.pending=r}Nr=null}return e}function gw(e,t){do{var n=lt;try{if(up(),Ta.current=dc,uc){for(var r=Ye.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}uc=!1}if(Mr=0,mt=ut=Ye=null,$o=!1,el=0,kp.current=null,n===null||n.return===null){ht=1,sl=t,lt=null;break}e:{var o=e,l=n.return,a=n,c=t;if(t=Et,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=a,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var h=p.alternate;h?(p.updateQueue=h.updateQueue,p.memoizedState=h.memoizedState,p.lanes=h.lanes):(p.updateQueue=null,p.memoizedState=null)}var x=dx(l);if(x!==null){x.flags&=-257,fx(x,l,a,o,t),x.mode&1&&ux(o,u,t),t=x,c=u;var j=t.updateQueue;if(j===null){var w=new Set;w.add(c),t.updateQueue=w}else j.add(c);break e}else{if(!(t&1)){ux(o,u,t),Ap();break e}c=Error(Q(426))}}else if(Ke&&a.mode&1){var b=dx(l);if(b!==null){!(b.flags&65536)&&(b.flags|=256),fx(b,l,a,o,t),ap(_i(c,a));break e}}o=c=_i(c,a),ht!==4&&(ht=2),Oo===null?Oo=[o]:Oo.push(o),o=l;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Zy(o,c,t);rx(o,v);break e;case 1:a=c;var m=o.type,y=o.stateNode;if(!(o.flags&128)&&(typeof m.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&(Xs===null||!Xs.has(y)))){o.flags|=65536,t&=-t,o.lanes|=t;var g=ew(o,a,t);rx(o,g);break e}}o=o.return}while(o!==null)}jw(n)}catch(k){t=k,lt===n&&n!==null&&(lt=n=n.return);continue}break}while(!0)}function xw(){var e=fc.current;return fc.current=dc,e===null?dc:e}function Ap(){(ht===0||ht===3||ht===2)&&(ht=4),vt===null||!($r&268435455)&&!(Vc&268435455)||Ws(vt,Et)}function mc(e,t){var n=Te;Te|=2;var r=xw();(vt!==e||Et!==t)&&(hs=null,Er(e,t));do try{UC();break}catch(i){gw(e,i)}while(!0);if(up(),Te=n,fc.current=r,lt!==null)throw Error(Q(261));return vt=null,Et=0,ht}function UC(){for(;lt!==null;)vw(lt)}function BC(){for(;lt!==null&&!hN();)vw(lt)}function vw(e){var t=ww(e.alternate,e,dn);e.memoizedProps=e.pendingProps,t===null?jw(e):lt=t,kp.current=null}function jw(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=_C(n,t),n!==null){n.flags&=32767,lt=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ht=6,lt=null;return}}else if(n=$C(n,t,dn),n!==null){lt=n;return}if(t=t.sibling,t!==null){lt=t;return}lt=t=e}while(t!==null);ht===0&&(ht=5)}function kr(e,t,n){var r=$e,i=Nn.transition;try{Nn.transition=null,$e=1,WC(e,t,n,r)}finally{Nn.transition=i,$e=r}return null}function WC(e,t,n,r){do Ni();while(Vs!==null);if(Te&6)throw Error(Q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Q(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(kN(e,o),e===vt&&(lt=vt=null,Et=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Jl||(Jl=!0,bw(Qa,function(){return Ni(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Nn.transition,Nn.transition=null;var l=$e;$e=1;var a=Te;Te|=4,kp.current=null,DC(e,n),hw(n,e),cC(mf),Xa=!!pf,mf=pf=null,e.current=n,LC(n),pN(),Te=a,$e=l,Nn.transition=o}else e.current=n;if(Jl&&(Jl=!1,Vs=e,pc=i),o=e.pendingLanes,o===0&&(Xs=null),xN(n.stateNode),nn(e,nt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(hc)throw hc=!1,e=_f,_f=null,e;return pc&1&&e.tag!==0&&Ni(),o=e.pendingLanes,o&1?e===Of?Do++:(Do=0,Of=e):Do=0,hr(),null}function Ni(){if(Vs!==null){var e=Zj(pc),t=Nn.transition,n=$e;try{if(Nn.transition=null,$e=16>e?16:e,Vs===null)var r=!1;else{if(e=Vs,Vs=null,pc=0,Te&6)throw Error(Q(331));var i=Te;for(Te|=4,oe=e.current;oe!==null;){var o=oe,l=o.child;if(oe.flags&16){var a=o.deletions;if(a!==null){for(var c=0;c<a.length;c++){var u=a[c];for(oe=u;oe!==null;){var p=oe;switch(p.tag){case 0:case 11:case 15:_o(8,p,o)}var f=p.child;if(f!==null)f.return=p,oe=f;else for(;oe!==null;){p=oe;var h=p.sibling,x=p.return;if(uw(p),p===u){oe=null;break}if(h!==null){h.return=x,oe=h;break}oe=x}}}var j=o.alternate;if(j!==null){var w=j.child;if(w!==null){j.child=null;do{var b=w.sibling;w.sibling=null,w=b}while(w!==null)}}oe=o}}if(o.subtreeFlags&2064&&l!==null)l.return=o,oe=l;else e:for(;oe!==null;){if(o=oe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:_o(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,oe=v;break e}oe=o.return}}var m=e.current;for(oe=m;oe!==null;){l=oe;var y=l.child;if(l.subtreeFlags&2064&&y!==null)y.return=l,oe=y;else e:for(l=m;oe!==null;){if(a=oe,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Hc(9,a)}}catch(k){Xe(a,a.return,k)}if(a===l){oe=null;break e}var g=a.sibling;if(g!==null){g.return=a.return,oe=g;break e}oe=a.return}}if(Te=i,hr(),es&&typeof es.onPostCommitFiberRoot=="function")try{es.onPostCommitFiberRoot(Oc,e)}catch{}r=!0}return r}finally{$e=n,Nn.transition=t}}return!1}function Nx(e,t,n){t=_i(n,t),t=Zy(e,t,1),e=Js(e,t,1),t=Ht(),e!==null&&(ml(e,1,t),nn(e,t))}function Xe(e,t,n){if(e.tag===3)Nx(e,e,n);else for(;t!==null;){if(t.tag===3){Nx(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Xs===null||!Xs.has(r))){e=_i(n,e),e=ew(t,e,1),t=Js(t,e,1),e=Ht(),t!==null&&(ml(t,1,e),nn(t,e));break}}t=t.return}}function HC(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Ht(),e.pingedLanes|=e.suspendedLanes&n,vt===e&&(Et&n)===n&&(ht===4||ht===3&&(Et&130023424)===Et&&500>nt()-Np?Er(e,0):Sp|=n),nn(e,t)}function yw(e,t){t===0&&(e.mode&1?(t=Ul,Ul<<=1,!(Ul&130023424)&&(Ul=4194304)):t=1);var n=Ht();e=Ss(e,t),e!==null&&(ml(e,t,n),nn(e,n))}function VC(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),yw(e,n)}function KC(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Q(314))}r!==null&&r.delete(t),yw(e,n)}var ww;ww=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||en.current)Xt=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Xt=!1,MC(e,t,n);Xt=!!(e.flags&131072)}else Xt=!1,Ke&&t.flags&1048576&&Ny(t,ic,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Pa(e,t),e=t.pendingProps;var i=Pi(t,zt.current);Si(t,n),i=vp(null,t,r,e,i,n);var o=jp();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,tn(r)?(o=!0,sc(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,hp(t),i.updater=Wc,t.stateNode=i,i._reactInternals=t,Sf(t,r,e,n),t=Ef(null,t,r,!0,o,n)):(t.tag=0,Ke&&o&&op(t),Ut(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Pa(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=YC(r),e=Mn(r,e),i){case 0:t=Cf(null,t,r,e,n);break e;case 1:t=mx(null,t,r,e,n);break e;case 11:t=hx(null,t,r,e,n);break e;case 14:t=px(null,t,r,Mn(r.type,e),n);break e}throw Error(Q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),Cf(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),mx(e,t,r,i,n);case 3:e:{if(rw(t),e===null)throw Error(Q(387));r=t.pendingProps,o=t.memoizedState,i=o.element,Py(e,t),ac(t,r,null,n);var l=t.memoizedState;if(r=l.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=_i(Error(Q(423)),t),t=gx(e,t,r,n,i);break e}else if(r!==i){i=_i(Error(Q(424)),t),t=gx(e,t,r,n,i);break e}else for(hn=Qs(t.stateNode.containerInfo.firstChild),mn=t,Ke=!0,_n=null,n=Ty(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ii(),r===i){t=Ns(e,t,n);break e}Ut(e,t,r,n)}t=t.child}return t;case 5:return Iy(t),e===null&&wf(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,l=i.children,gf(r,i)?l=null:o!==null&&gf(r,o)&&(t.flags|=32),sw(e,t),Ut(e,t,l,n),t.child;case 6:return e===null&&wf(t),null;case 13:return iw(e,t,n);case 4:return pp(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Mi(t,null,r,n):Ut(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),hx(e,t,r,i,n);case 7:return Ut(e,t,t.pendingProps,n),t.child;case 8:return Ut(e,t,t.pendingProps.children,n),t.child;case 12:return Ut(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,l=i.value,Ue(oc,r._currentValue),r._currentValue=l,o!==null)if(Fn(o.value,l)){if(o.children===i.children&&!en.current){t=Ns(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var a=o.dependencies;if(a!==null){l=o.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=vs(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),bf(o.return,n,t),a.lanes|=n;break}c=c.next}}else if(o.tag===10)l=o.type===t.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Q(341));l.lanes|=n,a=l.alternate,a!==null&&(a.lanes|=n),bf(l,n,t),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===t){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}Ut(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Si(t,n),i=Cn(i),r=r(i),t.flags|=1,Ut(e,t,r,n),t.child;case 14:return r=t.type,i=Mn(r,t.pendingProps),i=Mn(r.type,i),px(e,t,r,i,n);case 15:return tw(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Mn(r,i),Pa(e,t),t.tag=1,tn(r)?(e=!0,sc(t)):e=!1,Si(t,n),Xy(t,r,i),Sf(t,r,i,n),Ef(null,t,r,!0,e,n);case 19:return ow(e,t,n);case 22:return nw(e,t,n)}throw Error(Q(156,t.tag))};function bw(e,t){return qj(e,t)}function GC(e,t,n,r){this.tag=e,this.key=n,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 Sn(e,t,n,r){return new GC(e,t,n,r)}function Tp(e){return e=e.prototype,!(!e||!e.isReactComponent)}function YC(e){if(typeof e=="function")return Tp(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Yh)return 11;if(e===qh)return 14}return 2}function er(e,t){var n=e.alternate;return n===null?(n=Sn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function $a(e,t,n,r,i,o){var l=2;if(r=e,typeof e=="function")Tp(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case ai:return Ar(n.children,i,o,t);case Gh:l=8,i|=8;break;case Gd:return e=Sn(12,n,t,i|2),e.elementType=Gd,e.lanes=o,e;case Yd:return e=Sn(13,n,t,i),e.elementType=Yd,e.lanes=o,e;case qd:return e=Sn(19,n,t,i),e.elementType=qd,e.lanes=o,e;case Ij:return Kc(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Rj:l=10;break e;case Pj:l=9;break e;case Yh:l=11;break e;case qh:l=14;break e;case zs:l=16,r=null;break e}throw Error(Q(130,e==null?e:typeof e,""))}return t=Sn(l,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Ar(e,t,n,r){return e=Sn(7,e,r,t),e.lanes=n,e}function Kc(e,t,n,r){return e=Sn(22,e,r,t),e.elementType=Ij,e.lanes=n,e.stateNode={isHidden:!1},e}function td(e,t,n){return e=Sn(6,e,null,t),e.lanes=n,e}function nd(e,t,n){return t=Sn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function qC(e,t,n,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=Ou(0),this.expirationTimes=Ou(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ou(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Rp(e,t,n,r,i,o,l,a,c){return e=new qC(e,t,n,a,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Sn(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hp(o),e}function QC(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:li,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function kw(e){if(!e)return ir;e=e._reactInternals;e:{if(Wr(e)!==e||e.tag!==1)throw Error(Q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(tn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Q(171))}if(e.tag===1){var n=e.type;if(tn(n))return ky(e,n,t)}return t}function Sw(e,t,n,r,i,o,l,a,c){return e=Rp(n,r,!0,e,i,o,l,a,c),e.context=kw(null),n=e.current,r=Ht(),i=Zs(n),o=vs(r,i),o.callback=t??null,Js(n,o,i),e.current.lanes=i,ml(e,i,r),nn(e,r),e}function Gc(e,t,n,r){var i=t.current,o=Ht(),l=Zs(i);return n=kw(n),t.context===null?t.context=n:t.pendingContext=n,t=vs(o,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Js(i,t,l),e!==null&&(Ln(e,i,l,o),Aa(e,i,l)),l}function gc(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 Cx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Pp(e,t){Cx(e,t),(e=e.alternate)&&Cx(e,t)}function JC(){return null}var Nw=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ip(e){this._internalRoot=e}Yc.prototype.render=Ip.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Q(409));Gc(e,t,null,null)};Yc.prototype.unmount=Ip.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_r(function(){Gc(null,e,null,null)}),t[ks]=null}};function Yc(e){this._internalRoot=e}Yc.prototype.unstable_scheduleHydration=function(e){if(e){var t=ny();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Bs.length&&t!==0&&t<Bs[n].priority;n++);Bs.splice(n,0,e),n===0&&ry(e)}};function Mp(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function qc(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Ex(){}function XC(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var u=gc(l);o.call(u)}}var l=Sw(t,r,e,0,null,!1,!1,"",Ex);return e._reactRootContainer=l,e[ks]=l.current,qo(e.nodeType===8?e.parentNode:e),_r(),l}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var u=gc(c);a.call(u)}}var c=Rp(e,0,!1,null,null,!1,!1,"",Ex);return e._reactRootContainer=c,e[ks]=c.current,qo(e.nodeType===8?e.parentNode:e),_r(function(){Gc(t,c,n,r)}),c}function Qc(e,t,n,r,i){var o=n._reactRootContainer;if(o){var l=o;if(typeof i=="function"){var a=i;i=function(){var c=gc(l);a.call(c)}}Gc(t,l,e,i)}else l=XC(n,t,e,i,r);return gc(l)}ey=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Eo(t.pendingLanes);n!==0&&(Xh(t,n|1),nn(t,nt()),!(Te&6)&&(Oi=nt()+500,hr()))}break;case 13:_r(function(){var r=Ss(e,1);if(r!==null){var i=Ht();Ln(r,e,1,i)}}),Pp(e,1)}};Zh=function(e){if(e.tag===13){var t=Ss(e,134217728);if(t!==null){var n=Ht();Ln(t,e,134217728,n)}Pp(e,134217728)}};ty=function(e){if(e.tag===13){var t=Zs(e),n=Ss(e,t);if(n!==null){var r=Ht();Ln(n,e,t,r)}Pp(e,t)}};ny=function(){return $e};sy=function(e,t){var n=$e;try{return $e=e,t()}finally{$e=n}};of=function(e,t,n){switch(t){case"input":if(Xd(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=zc(r);if(!i)throw Error(Q(90));$j(r),Xd(r,i)}}}break;case"textarea":Oj(e,n);break;case"select":t=n.value,t!=null&&yi(e,!!n.multiple,t,!1)}};Wj=Cp;Hj=_r;var ZC={usingClientEntryPoint:!1,Events:[xl,fi,zc,Uj,Bj,Cp]},jo={findFiberByHostInstance:Sr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},eE={bundleType:jo.bundleType,version:jo.version,rendererPackageName:jo.rendererPackageName,rendererConfig:jo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ps.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Gj(e),e===null?null:e.stateNode},findFiberByHostInstance:jo.findFiberByHostInstance||JC,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 Xl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xl.isDisabled&&Xl.supportsFiber)try{Oc=Xl.inject(eE),es=Xl}catch{}}xn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ZC;xn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Mp(t))throw Error(Q(200));return QC(e,t,null,n)};xn.createRoot=function(e,t){if(!Mp(e))throw Error(Q(299));var n=!1,r="",i=Nw;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Rp(e,1,!1,null,null,n,!1,r,i),e[ks]=t.current,qo(e.nodeType===8?e.parentNode:e),new Ip(t)};xn.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(Q(188)):(e=Object.keys(e).join(","),Error(Q(268,e)));return e=Gj(t),e=e===null?null:e.stateNode,e};xn.flushSync=function(e){return _r(e)};xn.hydrate=function(e,t,n){if(!qc(t))throw Error(Q(200));return Qc(null,e,t,!0,n)};xn.hydrateRoot=function(e,t,n){if(!Mp(e))throw Error(Q(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",l=Nw;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),t=Sw(t,null,e,1,n??null,i,!1,o,l),e[ks]=t.current,qo(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Yc(t)};xn.render=function(e,t,n){if(!qc(t))throw Error(Q(200));return Qc(null,e,t,!1,n)};xn.unmountComponentAtNode=function(e){if(!qc(e))throw Error(Q(40));return e._reactRootContainer?(_r(function(){Qc(null,null,e,!1,function(){e._reactRootContainer=null,e[ks]=null})}),!0):!1};xn.unstable_batchedUpdates=Cp;xn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!qc(n))throw Error(Q(200));if(e==null||e._reactInternals===void 0)throw Error(Q(38));return Qc(e,t,n,!1,r)};xn.version="18.3.1-next-f1338f8080-20240426";function Cw(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Cw)}catch(e){console.error(e)}}Cw(),Cj.exports=xn;var Di=Cj.exports,Ew,Ax=Di;Ew=Ax.createRoot,Ax.hydrateRoot;var tE=Object.defineProperty,Xi=(e,t)=>tE(e,"name",{value:t,configurable:!0}),Aw=!!(typeof window<"u"&&window.document&&window.document.createElement);function we(e,t,{checkForDefaultPrevented:n=!0}={}){return Xi(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}Xi(we,"composeEventHandlers");function nE(e){var t;if(!Aw)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}Xi(nE,"getOwnerWindow");function Ff(e){if(!Aw)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}Xi(Ff,"getOwnerDocument");function Tw(e,t=!1){const{activeElement:n}=Ff(e);if(!(n!=null&&n.nodeName))return null;if(Rw(n)&&n.contentDocument)return Tw(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=Ff(n).getElementById(r);if(i)return i}}return n}Xi(Tw,"getActiveElement");function Rw(e){return e.tagName==="IFRAME"}Xi(Rw,"isFrame");var sE=Object.defineProperty,$p=(e,t)=>sE(e,"name",{value:t,configurable:!0});function zf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}$p(zf,"setRef");function Pw(...e){return t=>{let n=!1;const r=e.map(i=>{const o=zf(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():zf(e[i],null)}}}}$p(Pw,"composeRefs");function qe(...e){return d.useCallback(Pw(...e),e)}$p(qe,"useComposedRefs");var rE=Object.defineProperty,kn=(e,t)=>rE(e,"name",{value:t,configurable:!0});function iE(e,t){const n=d.createContext(t);n.displayName=e+"Context";const r=kn(o=>{const{children:l,...a}=o,c=d.useMemo(()=>a,Object.values(a));return s.jsx(n.Provider,{value:c,children:l})},"Provider");r.displayName=e+"Provider";function i(o,l={}){const{optional:a=!1}=l,c=d.useContext(n);if(c)return c;if(t!==void 0)return t;if(!a)throw new Error(`\`${o}\` must be used within \`${e}\``)}return kn(i,"useContext"),[r,i]}kn(iE,"createContext");function Bn(e,t=[]){let n=[];function r(o,l){const a=d.createContext(l);a.displayName=o+"Context";const c=n.length;n=[...n,l];const u=kn(f=>{var v;const{scope:h,children:x,...j}=f,w=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=d.useMemo(()=>j,Object.values(j));return s.jsx(w.Provider,{value:b,children:x})},"Provider");u.displayName=o+"Provider";function p(f,h,x={}){var v;const{optional:j=!1}=x,w=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,b=d.useContext(w);if(b)return b;if(l!==void 0)return l;if(!j)throw new Error(`\`${f}\` must be used within \`${o}\``)}return kn(p,"useContext"),[u,p]}kn(r,"createContext");const i=kn(()=>{const o=n.map(l=>d.createContext(l));return kn(function(a){const c=(a==null?void 0:a[e])||o;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])},"useScope")},"createScope");return i.scopeName=e,[r,Iw(i,...t)]}kn(Bn,"createContextScope");function Iw(...e){const t=e[0];if(e.length===1)return t;const n=kn(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return kn(function(o){const l=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(o)[`__scope${u}`];return{...a,...f}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}kn(Iw,"composeContextScopes");var oE=Object.defineProperty,Wn=(e,t)=>oE(e,"name",{value:t,configurable:!0});function or(e){const t=d.forwardRef((n,r)=>{let{children:i,...o}=n,l=null,a=!1;const c=[];Uf(i)&&typeof Zl=="function"&&(i=Zl(i._payload)),d.Children.forEach(i,h=>{var x;if(Dw(h)){a=!0;const j=h;let w="child"in j.props?j.props.child:j.props.children;Uf(w)&&typeof Zl=="function"&&(w=Zl(w._payload)),l=lE(j,w),c.push((x=l==null?void 0:l.props)==null?void 0:x.children)}else c.push(h)}),l?l=d.cloneElement(l,void 0,c):!a&&d.Children.count(i)===1&&d.isValidElement(i)&&(l=i);const u=l?Ow(l):void 0,p=qe(r,u);if(!l){if(i||i===0)throw new Error(a?uE(e):cE(e));return i}const f=_w(o,l.props??{});return l.type!==d.Fragment&&(f.ref=r?p:u),d.cloneElement(l,f)});return t.displayName=`${e}.Slot`,t}Wn(or,"createSlot");var Mw=Symbol.for("radix.slottable");function $w(e){const t=Wn(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Mw,t}Wn($w,"createSlottable");var lE=Wn((e,t)=>{if("child"in e.props){const n=e.props.child;return d.isValidElement(n)?d.cloneElement(n,void 0,e.props.children(n.props.children)):null}return d.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function _w(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{const c=o(...a);return i(...a),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}Wn(_w,"mergeProps");function Ow(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Wn(Ow,"getElementRef");function Dw(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Mw}Wn(Dw,"isSlottable");var aE=Symbol.for("react.lazy");function Uf(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===aE&&"_payload"in e&&Lw(e._payload)}Wn(Uf,"isLazyComponent");function Lw(e){return typeof e=="object"&&e!==null&&"then"in e}Wn(Lw,"isPromiseLike");var cE=Wn(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),uE=Wn(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Zl=qi[" use ".trim().toString()],dE=Object.defineProperty,gt=(e,t)=>dE(e,"name",{value:t,configurable:!0});function Jc(e){const t=e+"CollectionProvider",[n,r]=Bn(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=gt(w=>{const{scope:b,children:v}=w,m=d.useRef(null),y=d.useRef(new Map).current;return s.jsx(i,{scope:b,itemMap:y,collectionRef:m,children:v})},"CollectionProvider");l.displayName=t;const a=e+"CollectionSlot",c=or(a),u=d.forwardRef((w,b)=>{const{scope:v,children:m}=w,y=o(a,v),g=qe(b,y.collectionRef);return s.jsx(c,{ref:g,children:m})});u.displayName=a;const p=e+"CollectionItemSlot",f="data-radix-collection-item",h=or(p),x=d.forwardRef((w,b)=>{const{scope:v,children:m,...y}=w,g=d.useRef(null),k=qe(b,g),S=o(p,v);return d.useEffect(()=>(S.itemMap.set(g,{ref:g,...y}),()=>void S.itemMap.delete(g))),s.jsx(h,{[f]:"",ref:k,children:m})});x.displayName=p;function j(w){const b=o(e+"CollectionConsumer",w);return d.useCallback(()=>{const m=b.collectionRef.current;if(!m)return[];const y=Array.from(m.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((S,N)=>y.indexOf(S.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return gt(j,"useCollection"),[{Provider:l,Slot:u,ItemSlot:x},j,r]}gt(Jc,"createCollection");var Tx=new WeakMap,ot,fn,sd=(fn=class extends Map{constructor(n){super(n);jg(this,ot);Ru(this,ot,[...super.keys()]),Tx.set(this,!0)}set(n,r){return Tx.get(this)&&(this.has(n)?Mt(this,ot)[Mt(this,ot).indexOf(n)]=n:Mt(this,ot).push(n)),super.set(n,r),this}insert(n,r,i){const o=this.has(r),l=Mt(this,ot).length,a=_p(n);let c=a>=0?a:l+a;const u=c<0||c>=l?-1:c;if(u===this.size||o&&u===this.size-1||u===-1)return this.set(r,i),this;const p=this.size+(o?0:1);a<0&&c++;const f=[...Mt(this,ot)];let h,x=!1;for(let j=c;j<p;j++)if(c===j){let w=f[j];f[j]===r&&(w=f[j+1]),o&&this.delete(r),h=this.get(w),this.set(r,i)}else{!x&&f[j-1]===r&&(x=!0);const w=f[x?j:j-1],b=h;h=this.get(w),this.delete(w),this.set(w,b)}return this}with(n,r,i){const o=new fn(this);return o.insert(n,r,i),o}before(n){const r=Mt(this,ot).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const o=Mt(this,ot).indexOf(n);return o===-1?this:this.insert(o,r,i)}after(n){let r=Mt(this,ot).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const o=Mt(this,ot).indexOf(n);return o===-1?this:this.insert(o+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Ru(this,ot,[]),super.clear()}delete(n){const r=super.delete(n);return r&&Mt(this,ot).splice(Mt(this,ot).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=_a(Mt(this,ot),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=_a(Mt(this,ot),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Mt(this,ot).indexOf(n)}keyAt(n){return _a(Mt(this,ot),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.at(o)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let o=i+r;return o<0&&(o=0),o>=this.size&&(o=this.size-1),this.keyAt(o)}find(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return o;i++}}findIndex(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return i;i++}return-1}filter(n,r){const i=[];let o=0;for(const l of this)Reflect.apply(n,r,[l,o,this])&&i.push(l),o++;return new fn(i)}map(n,r){const i=[];let o=0;for(const l of this)i.push([l[0],Reflect.apply(n,r,[l,o,this])]),o++;return new fn(i)}reduce(...n){const[r,i]=n;let o=0,l=i??this.at(0);for(const a of this)o===0&&n.length===1?l=a:l=Reflect.apply(r,this,[l,a,o,this]),o++;return l}reduceRight(...n){const[r,i]=n;let o=i??this.at(-1);for(let l=this.size-1;l>=0;l--){const a=this.at(l);l===this.size-1&&n.length===1?o=a:o=Reflect.apply(r,this,[o,a,l,this])}return o}toSorted(n){const r=[...this.entries()].sort(n);return new fn(r)}toReversed(){const n=new fn;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),o=this.get(i);n.set(i,o)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new fn(r)}slice(n,r){const i=new fn;let o=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(o=r-1);for(let l=n;l<=o;l++){const a=this.keyAt(l),c=this.get(a);i.set(a,c)}return i}every(n,r){let i=0;for(const o of this){if(!Reflect.apply(n,r,[o,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const o of this){if(Reflect.apply(n,r,[o,i,this]))return!0;i++}return!1}},ot=new WeakMap,gt(fn,"OrderedDict"),fn);function _a(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const n=Fw(e,t);return n===-1?void 0:e[n]}gt(_a,"at");function Fw(e,t){const n=e.length,r=_p(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}gt(Fw,"toSafeIndex");function _p(e){return e!==e||e===0?0:Math.trunc(e)}gt(_p,"toSafeInteger");function fE(e){const t=e+"CollectionProvider",[n,r]=Bn(t),[i,o]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new sd,setItemMap:gt(()=>{},"setItemMap")}),l=gt(({state:y,...g})=>y?s.jsx(c,{...g,state:y}):s.jsx(a,{...g}),"CollectionProvider");l.displayName=t;const a=gt(y=>{const g=b();return s.jsx(c,{...y,state:g})},"CollectionInit");a.displayName=t+"Init";const c=gt(y=>{const{scope:g,children:k,state:S}=y,N=d.useRef(null),[C,P]=d.useState(null),E=qe(N,P),[O,L]=S;return d.useEffect(()=>{if(!C)return;const D=Bw(()=>{});return D.observe(C,{childList:!0,subtree:!0}),()=>{D.disconnect()}},[C]),s.jsx(i,{scope:g,itemMap:O,setItemMap:L,collectionRef:E,collectionRefObject:N,collectionElement:C,children:k})},"CollectionProviderImpl");c.displayName=t+"Impl";const u=e+"CollectionSlot",p=or(u),f=d.forwardRef((y,g)=>{const{scope:k,children:S}=y,N=o(u,k),C=qe(g,N.collectionRef);return s.jsx(p,{ref:C,children:S})});f.displayName=u;const h=e+"CollectionItemSlot",x="data-radix-collection-item",j=or(h),w=d.forwardRef((y,g)=>{const{scope:k,children:S,...N}=y,C=d.useRef(null),[P,E]=d.useState(null),O=qe(g,C,E),L=o(h,k),{setItemMap:D}=L,T=d.useRef(N);zw(T.current,N)||(T.current=N);const z=T.current;return d.useEffect(()=>{const q=z;return D(K=>P?K.has(P)?K.set(P,{...q,element:P}).toSorted(Bf):(K.set(P,{...q,element:P}),K.toSorted(Bf)):K),()=>{D(K=>!P||!K.has(P)?K:(K.delete(P),new sd(K)))}},[P,z,D]),s.jsx(j,{[x]:"",ref:O,children:S})});w.displayName=h;function b(){return d.useState(new sd)}gt(b,"useInitCollection");function v(y){const{itemMap:g}=o(e+"CollectionConsumer",y);return g}return gt(v,"useCollection"),[{Provider:l,Slot:f,ItemSlot:w},{createCollectionScope:r,useCollection:v,useInitCollection:b}]}gt(fE,"createCollection");function zw(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||e[i]!==t[i])return!1;return!0}gt(zw,"shallowEqual");function Uw(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}gt(Uw,"isElementPreceding");function Bf(e,t){return!e[1].element||!t[1].element?0:Uw(e[1].element,t[1].element)?-1:1}gt(Bf,"sortByDocumentPosition");function Bw(e){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){e();return}})}gt(Bw,"getChildListObserver");var hE=Object.defineProperty,pE=(e,t)=>hE(e,"name",{value:t,configurable:!0}),mE=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Je=mE.reduce((e,t)=>{const n=or(`Primitive.${t}`),r=d.forwardRef((i,o)=>{const{asChild:l,...a}=i,c=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(c,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Xc(e,t){e&&Di.flushSync(()=>e.dispatchEvent(t))}pE(Xc,"dispatchDiscreteCustomEvent");var gE=Object.defineProperty,xE=(e,t)=>gE(e,"name",{value:t,configurable:!0});function zn(e){const t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}xE(zn,"useCallbackRef");var vE=Object.defineProperty,dt=(e,t)=>vE(e,"name",{value:t,configurable:!0}),Wf="dismissableLayer.update",jE="dismissableLayer.pointerDownOutside",yE="dismissableLayer.focusOutside",Rx,Op=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Dp=d.forwardRef(dt(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:a,onInteractOutside:c,onDismiss:u,...p}=t,f=d.useContext(Op),[h,x]=d.useState(null),j=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=d.useState({}),b=qe(n,x),v=Array.from(f.layers),[m]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),y=m?v.indexOf(m):-1,g=h?v.indexOf(h):-1,k=f.layersWithOutsidePointerEventsDisabled.size>0,S=g>=y,N=d.useRef(!1),C=Hw(L=>{l==null||l(L),c==null||c(L),L.defaultPrevented||u==null||u()},{ownerDocument:j,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:N,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(L=>{if(!(L instanceof Node))return!1;const D=[...f.branches].some(T=>T.contains(L));return S&&!D},[f.branches,S])}),P=Vw(L=>{if(i&&N.current)return;const D=L.target;[...f.branches].some(z=>z.contains(D))||(a==null||a(L),c==null||c(L),L.defaultPrevented||u==null||u())},j),E=h?g===v.length-1:!1,O=zn(L=>{L.key==="Escape"&&(o==null||o(L),!L.defaultPrevented&&u&&(L.preventDefault(),u()))});return d.useEffect(()=>{if(E)return j.addEventListener("keydown",O,{capture:!0}),()=>j.removeEventListener("keydown",O,{capture:!0})},[j,E,O]),d.useEffect(()=>{if(h)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Rx=j.body.style.pointerEvents,j.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(h)),f.layers.add(h),Hf(),()=>{r&&(f.layersWithOutsidePointerEventsDisabled.delete(h),f.layersWithOutsidePointerEventsDisabled.size===0&&(j.body.style.pointerEvents=Rx))}},[h,j,r,f]),d.useEffect(()=>()=>{h&&(f.layers.delete(h),f.layersWithOutsidePointerEventsDisabled.delete(h),Hf())},[h,f]),d.useEffect(()=>{const L=dt(()=>w({}),"handleUpdate");return document.addEventListener(Wf,L),()=>document.removeEventListener(Wf,L)},[]),s.jsx(Je.div,{...p,ref:b,style:{pointerEvents:k?S?"auto":"none":void 0,...t.style},onFocusCapture:we(t.onFocusCapture,P.onFocusCapture),onBlurCapture:we(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:we(t.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),wE=d.forwardRef(dt(function(t,n){const r=d.useContext(Op),i=d.useRef(null),o=qe(n,i);return d.useEffect(()=>{const l=i.current;if(l)return r.branches.add(l),()=>{r.branches.delete(l)}},[r.branches]),s.jsx(Je.div,{...t,ref:o})},"DismissableLayerBranch"));function Ww(){const e=d.useContext(Op),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}dt(Ww,"useDismissableLayerSurface");var bE=dt(()=>!0,"IS_TRUE");function Hw(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:o,shouldHandlePointerDownOutside:l=bE}=t,a=zn(e),c=d.useRef(!1),u=d.useRef(!1),p=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function h(){u.current=!1,i.current=!1,p.current.clear()}dt(h,"resetOutsideInteraction");function x(){return Array.from(p.current.values()).some(Boolean)}dt(x,"isOutsideInteractionIntercepted");function j(y){if(!u.current)return;const g=y.target;g instanceof Node&&[...o].some(S=>S.contains(g))||p.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{u.current&&f.current()},0)}dt(j,"handleInteractionCapture");function w(y){u.current&&p.current.set(y.type,!1)}dt(w,"handleInteractionBubble");const b=dt(y=>{if(y.target&&!c.current){let g=function(){n.removeEventListener("click",f.current);const S=x();h(),S||Lp(jE,a,k,{discrete:!0})};if(dt(g,"handleAndDispatchPointerDownOutsideEvent"),!l(y.target)){n.removeEventListener("click",f.current),h(),c.current=!1;return}const k={originalEvent:y};u.current=!0,i.current=r&&y.button===0,p.current.clear(),!r||y.button!==0?g():(n.removeEventListener("click",f.current),f.current=g,n.addEventListener("click",f.current,{once:!0}))}else n.removeEventListener("click",f.current),h();c.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of v)n.addEventListener(y,j,!0),n.addEventListener(y,w);const m=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(m),n.removeEventListener("pointerdown",b),n.removeEventListener("click",f.current);for(const y of v)n.removeEventListener(y,j,!0),n.removeEventListener(y,w)}},[n,a,r,i,o,l]),{onPointerDownCapture:dt(()=>c.current=!0,"onPointerDownCapture")}}dt(Hw,"usePointerDownOutside");function Vw(e,t=globalThis==null?void 0:globalThis.document){const n=zn(e),r=d.useRef(!1);return d.useEffect(()=>{const i=dt(o=>{o.target&&!r.current&&Lp(yE,n,{originalEvent:o},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:dt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:dt(()=>r.current=!1,"onBlurCapture")}}dt(Vw,"useFocusOutside");function Hf(){const e=new CustomEvent(Wf);document.dispatchEvent(e)}dt(Hf,"dispatchUpdate");function Lp(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Xc(i,o):i.dispatchEvent(o)}dt(Lp,"handleAndDispatchCustomEvent");var kE=wE,sn=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},SE=Object.defineProperty,NE=(e,t)=>SE(e,"name",{value:t,configurable:!0}),Fp=d.forwardRef(NE(function(t,n){var c;const{container:r,...i}=t,[o,l]=d.useState(!1);sn(()=>l(!0),[]);const a=r||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?Di.createPortal(s.jsx(Je.div,{...i,ref:n}),a):null},"Portal")),CE=Object.defineProperty,Cs=(e,t)=>CE(e,"name",{value:t,configurable:!0});function Kw(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}Cs(Kw,"useStateMachine");var pr=Cs(e=>{const{present:t,children:n}=e,r=Gw(t),i=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),o=Yw(r.ref,qw(i));return typeof n=="function"||r.isPresent?d.cloneElement(i,{ref:o}):null},"Presence");function Gw(e){const[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),o=d.useRef("none"),l=d.useRef(void 0),a=e?"mounted":"unmounted",[c,u]=Kw(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(o.current=l.current??oi(r.current),l.current=void 0):o.current="none"},[c]),sn(()=>{const p=r.current,f=i.current;if(f!==e){const x=o.current,j=oi(p);e?(l.current=j,u("MOUNT")):j==="none"||(p==null?void 0:p.display)==="none"?u("UNMOUNT"):u(f&&x!==j?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,u]),sn(()=>{if(t){let p;const f=t.ownerDocument.defaultView??window,h=Cs(j=>{const b=oi(r.current).includes(CSS.escape(j.animationName));if(j.target===t&&b&&(u("ANIMATION_END"),!i.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",p=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),x=Cs(j=>{j.target===t&&(o.current=oi(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(p),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(p=>{if(p){const f=getComputedStyle(p);r.current=f,l.current=oi(f)}else r.current=null;n(p)},[])}}Cs(Gw,"usePresence");function Vf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Cs(Vf,"setRef");function Yw(...e){const t=d.useRef(e);return t.current=e,d.useCallback(n=>{const r=t.current;let i=!1;const o=r.map(l=>{const a=Vf(l,n);return!i&&typeof a=="function"&&(i=!0),a});if(i)return()=>{for(let l=0;l<o.length;l++){const a=o[l];typeof a=="function"?a():Vf(r[l],null)}}},[])}Cs(Yw,"useStableComposedRefs");function oi(e){return(e==null?void 0:e.animationName)||"none"}Cs(oi,"getAnimationName");function qw(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Cs(qw,"getElementRef");var EE=Object.defineProperty,AE=(e,t)=>EE(e,"name",{value:t,configurable:!0}),Px=qi[" useEffectEvent ".trim().toString()],Ix=qi[" useInsertionEffect ".trim().toString()];function Qw(e){if(typeof Px=="function")return Px(e);const t=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Ix=="function"?Ix(()=>{t.current=e}):sn(()=>{t.current=e}),d.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}AE(Qw,"useEffectEvent");var TE=Object.defineProperty,jl=(e,t)=>TE(e,"name",{value:t,configurable:!0}),RE=qi[" useInsertionEffect ".trim().toString()]||sn;function Zi({prop:e,defaultProp:t,onChange:n=jl(()=>{},"onChange"),caller:r}){const[i,o,l]=Jw({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:i,u=d.useCallback(p=>{var f;if(a){const h=Xw(p)?p(e):p;h!==e&&((f=l.current)==null||f.call(l,h))}else o(p)},[a,e,o,l]);return[c,u]}jl(Zi,"useControllableState");function Jw({defaultProp:e,onChange:t}){const[n,r]=d.useState(e),i=d.useRef(n),o=d.useRef(t);return RE(()=>{o.current=t},[t]),d.useEffect(()=>{var l;i.current!==n&&((l=o.current)==null||l.call(o,n),i.current=n)},[n,i]),[n,r,o]}jl(Jw,"useUncontrolledState");function Xw(e){return typeof e=="function"}jl(Xw,"isFunction");var Mx=Symbol("RADIX:SYNC_STATE");function PE(e,t,n,r){const{prop:i,defaultProp:o,onChange:l,caller:a}=t,c=i!==void 0,u=Qw(l),p=[{...n,state:o}];r&&p.push(r);const[f,h]=d.useReducer((b,v)=>{if(v.type===Mx)return{...b,state:v.state};const m=e(b,v);return c&&!Object.is(m.state,b.state)&&u(m.state),m},...p),x=f.state,j=d.useRef(x);d.useEffect(()=>{j.current!==x&&(j.current=x,c||u(x))},[x,j,c]);const w=d.useMemo(()=>i!==void 0?{...f,state:i}:f,[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&h({type:Mx,state:i})},[i,f.state,c]),[w,h]}jl(PE,"useControllableStateReducer");var IE=Object.defineProperty,ME=(e,t)=>IE(e,"name",{value:t,configurable:!0}),$E=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"}),Zw=d.forwardRef(ME(function(t,n){return s.jsx(Je.span,{...t,ref:n,style:{...$E,...t.style}})},"VisuallyHidden")),_E=Zw,OE=Object.defineProperty,Ot=(e,t)=>OE(e,"name",{value:t,configurable:!0}),eb="ToastProvider",[tb,DE,LE]=Jc("Toast"),[nb,t6]=Bn("Toast",[LE]),[FE,sb]=nb(eb),zE=Ot(e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:o=50,announcerContainer:l,children:a}=e,[c,u]=d.useState(null),[p,f]=d.useState(0),h=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${eb}\`. Expected non-empty \`string\`.`),s.jsx(tb.Provider,{scope:t,children:s.jsx(FE,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:o,toastCount:p,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>f(x=>x+1),[]),onToastRemove:d.useCallback(()=>f(x=>x-1),[]),isClosePausedRef:h,announcerContainer:l,children:a})})},"ToastProvider"),UE="ToastViewport",BE=["F8"],WE="toast.viewportPause",HE="toast.viewportResume",VE=d.forwardRef(Ot(function(t,n){const{__scopeToast:r,hotkey:i=BE,label:o="Notifications ({hotkey})",...l}=t,a=sb(UE,r),c=DE(r),u=d.useRef(null),p=d.useRef(null),f=d.useRef(null),h=d.useRef(null),x=qe(n,h,a.onViewportChange),j=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),w=a.toastCount>0;d.useEffect(()=>{const v=Ot(m=>{var g;i.length!==0&&i.every(k=>m[k]||m.code===k)&&((g=h.current)==null||g.focus())},"handleKeyDown");return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[i]),d.useEffect(()=>{const v=u.current,m=h.current;if(w&&v&&m){const y=Ot(()=>{if(!a.isClosePausedRef.current){const N=new CustomEvent(WE);m.dispatchEvent(N),a.isClosePausedRef.current=!0}},"handlePause"),g=Ot(()=>{if(a.isClosePausedRef.current){const N=new CustomEvent(HE);m.dispatchEvent(N),a.isClosePausedRef.current=!1}},"handleResume"),k=Ot(N=>{!v.contains(N.relatedTarget)&&g()},"handleFocusOutResume"),S=Ot(()=>{v.contains(document.activeElement)||g()},"handlePointerLeaveResume");return v.addEventListener("focusin",y),v.addEventListener("focusout",k),v.addEventListener("pointermove",y),v.addEventListener("pointerleave",S),window.addEventListener("blur",y),window.addEventListener("focus",g),()=>{v.removeEventListener("focusin",y),v.removeEventListener("focusout",k),v.removeEventListener("pointermove",y),v.removeEventListener("pointerleave",S),window.removeEventListener("blur",y),window.removeEventListener("focus",g)}}},[w,a.isClosePausedRef]);const b=d.useCallback(({tabbingDirection:v})=>{const y=c().map(g=>{const k=g.ref.current,S=[k,...ob(k)];return v==="forwards"?S:S.reverse()});return(v==="forwards"?y.reverse():y).flat()},[c]);return d.useEffect(()=>{const v=h.current;if(v){const m=Ot(y=>{var S,N,C;const g=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!g){const P=document.activeElement,E=y.shiftKey;if(y.target===v&&E){(S=p.current)==null||S.focus();return}const D=b({tabbingDirection:E?"backwards":"forwards"}),T=D.findIndex(z=>z===P);Oa(D.slice(T+1))?y.preventDefault():E?(N=p.current)==null||N.focus():(C=f.current)==null||C.focus()}},"handleKeyDown");return v.addEventListener("keydown",m),()=>v.removeEventListener("keydown",m)}},[c,b]),s.jsxs(kE,{ref:u,role:"region","aria-label":o.replace("{hotkey}",j),tabIndex:-1,style:{pointerEvents:w?void 0:"none"},children:[w&&s.jsx($x,{ref:p,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"forwards"});Oa(v)}}),s.jsx(tb.Slot,{scope:r,children:s.jsx(Je.ol,{tabIndex:-1,...l,ref:x})}),w&&s.jsx($x,{ref:f,onFocusFromOutsideViewport:()=>{const v=b({tabbingDirection:"backwards"});Oa(v)}})]})},"ToastViewport")),KE="ToastFocusProxy",$x=d.forwardRef(Ot(function(t,n){const{__scopeToast:r,onFocusFromOutsideViewport:i,...o}=t,l=sb(KE,r);return s.jsx(Zw,{tabIndex:0,...o,ref:n,style:{position:"fixed"},onFocus:a=>{var p;const c=a.relatedTarget;!((p=l.viewport)!=null&&p.contains(c))&&i()}})},"ToastFocusProxy")),GE="Toast",[n6,s6]=nb(GE,{onClose(){}});function rb(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),ib(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",o=r.dataset.radixToastAnnounceExclude==="";if(!i)if(o){const l=r.dataset.radixToastAnnounceAlt;l&&t.push(l)}else t.push(...rb(r))}}),t}Ot(rb,"getAnnounceTextContent");function YE(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Xc(i,o):i.dispatchEvent(o)}Ot(YE,"handleAndDispatchCustomEvent");function qE(e=()=>{}){const t=zn(e);sn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}Ot(qE,"useNextFrame");function ib(e){return e.nodeType===e.ELEMENT_NODE}Ot(ib,"isHTMLElement");function ob(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Ot(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(;n.nextNode();)t.push(n.currentNode);return t}Ot(ob,"getTabbableCandidates");function Oa(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}Ot(Oa,"focusFirst");var _x=zE,Ox=VE,QE=Object.defineProperty,JE=(e,t)=>QE(e,"name",{value:t,configurable:!0}),XE=qi[" useId ".trim().toString()]||(()=>{}),ZE=0;function js(e){const[t,n]=d.useState(XE());return sn(()=>{e||n(r=>r??String(ZE++))},[e]),e||(t?`radix-${t}`:"")}JE(js,"useId");const eA=["top","right","bottom","left"],lr=Math.min,ys=Math.max,xc=Math.round,ea=Math.floor,ws=e=>({x:e,y:e}),tA={left:"right",right:"left",bottom:"top",top:"bottom"};function lb(e,t,n){return ys(e,lr(t,n))}function Es(e,t){return typeof e=="function"?e(t):e}function ar(e){return e.split("-")[0]}function eo(e){return e.split("-")[1]}function zp(e){return e==="x"?"y":"x"}function Up(e){return e==="y"?"height":"width"}function Xn(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Bp(e){return zp(Xn(e))}function nA(e,t,n){n===void 0&&(n=!1);const r=eo(e),i=Bp(e),o=Up(i);let l=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(l=vc(l)),[l,vc(l)]}function sA(e){const t=vc(e);return[Kf(e),t,Kf(t)]}function Kf(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Dx=["left","right"],Lx=["right","left"],rA=["top","bottom"],iA=["bottom","top"];function oA(e,t,n){switch(e){case"top":case"bottom":return n?t?Lx:Dx:t?Dx:Lx;case"left":case"right":return t?rA:iA;default:return[]}}function lA(e,t,n,r){const i=eo(e);let o=oA(ar(e),n==="start",r);return i&&(o=o.map(l=>l+"-"+i),t&&(o=o.concat(o.map(Kf)))),o}function vc(e){const t=ar(e);return tA[t]+e.slice(t.length)}function aA(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function ab(e){return typeof e!="number"?aA(e):{top:e,right:e,bottom:e,left:e}}function jc(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Fx(e,t,n){let{reference:r,floating:i}=e;const o=Xn(t),l=Bp(t),a=Up(l),c=ar(t),u=o==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let x;switch(c){case"top":x={x:p,y:r.y-i.height};break;case"bottom":x={x:p,y:r.y+r.height};break;case"right":x={x:r.x+r.width,y:f};break;case"left":x={x:r.x-i.width,y:f};break;default:x={x:r.x,y:r.y}}const j=eo(t);return j&&(x[l]+=h*(j==="end"?1:-1)*(n&&u?-1:1)),x}async function cA(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:l,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:h=!1,padding:x=0}=Es(t,e),j=ab(x),b=a[h?f==="floating"?"reference":"floating":f],v=jc(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:p,strategy:c})),m=f==="floating"?{x:r,y:i,width:l.floating.width,height:l.floating.height}:l.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),g=await(o.isElement==null?void 0:o.isElement(y))&&await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1},k=jc(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:m,offsetParent:y,strategy:c}):m);return{top:(v.top-k.top+j.top)/g.y,bottom:(k.bottom-v.bottom+j.bottom)/g.y,left:(v.left-k.left+j.left)/g.x,right:(k.right-v.right+j.right)/g.x}}const uA=50,dA=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:l}=n,a=l.detectOverflow?l:{...l,detectOverflow:cA},c=await(l.isRTL==null?void 0:l.isRTL(t));let u=await l.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=Fx(u,r,c),h=r,x=0;const j={};for(let w=0;w<o.length;w++){const b=o[w];if(!b)continue;const{name:v,fn:m}=b,{x:y,y:g,data:k,reset:S}=await m({x:p,y:f,initialPlacement:r,placement:h,strategy:i,middlewareData:j,rects:u,platform:a,elements:{reference:e,floating:t}});p=y??p,f=g??f,j[v]={...j[v],...k},S&&x<uA&&(x++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:i}):S.rects),{x:p,y:f}=Fx(u,h,c)),w=-1)}return{x:p,y:f,placement:h,strategy:i,middlewareData:j}},fA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:l,elements:a,middlewareData:c}=t,{element:u,padding:p=0}=Es(e,t)||{};if(u==null)return{};const f=ab(p),h={x:n,y:r},x=Bp(i),j=Up(x),w=await l.getDimensions(u),b=x==="y",v=b?"top":"left",m=b?"bottom":"right",y=b?"clientHeight":"clientWidth",g=o.reference[j]+o.reference[x]-h[x]-o.floating[j],k=h[x]-o.reference[x],S=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let N=S?S[y]:0;(!N||!await(l.isElement==null?void 0:l.isElement(S)))&&(N=a.floating[y]||o.floating[j]);const C=g/2-k/2,P=N/2-w[j]/2-1,E=lr(f[v],P),O=lr(f[m],P),L=N-w[j]-O,D=N/2-w[j]/2+C,T=lb(E,D,L),z=!c.arrow&&eo(i)!=null&&D!==T&&o.reference[j]/2-(D<E?E:O)-w[j]/2<0,q=z?D<E?D-E:D-L:0;return{[x]:h[x]+q,data:{[x]:T,centerOffset:D-T-q,...z&&{alignmentOffset:q}},reset:z}}}),hA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:l,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:w=!0,...b}=Es(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const v=ar(i),m=Xn(a),y=ar(a)===a,g=await(c.isRTL==null?void 0:c.isRTL(u.floating)),k=h||(y||!w?[vc(a)]:sA(a)),S=j!=="none";!h&&S&&k.push(...lA(a,w,j,g));const N=[a,...k],C=await c.detectOverflow(t,b),P=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&P.push(C[v]),f){const T=nA(i,l,g);P.push(C[T[0]],C[T[1]])}if(E=[...E,{placement:i,overflows:P}],!P.every(T=>T<=0)){var O,L;const T=(((O=o.flip)==null?void 0:O.index)||0)+1,z=N[T];if(z&&(!(f==="alignment"?m!==Xn(z):!1)||E.every(M=>Xn(M.placement)===m?M.overflows[0]>0:!0)))return{data:{index:T,overflows:E},reset:{placement:z}};let q=(L=E.filter(K=>K.overflows[0]<=0).sort((K,M)=>K.overflows[1]-M.overflows[1])[0])==null?void 0:L.placement;if(!q)switch(x){case"bestFit":{var D;const K=(D=E.filter(M=>{if(S){const W=Xn(M.placement);return W===m||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:D[0];K&&(q=K);break}case"initialPlacement":q=a;break}if(i!==q)return{reset:{placement:q}}}return{}}}};function zx(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ux(e){return eA.some(t=>e[t]>=0)}const pA=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...o}=Es(e,t);switch(i){case"referenceHidden":{const l=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=zx(l,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ux(a)}}}case"escaped":{const l=await r.detectOverflow(t,{...o,altBoundary:!0}),a=zx(l,n.floating);return{data:{escapedOffsets:a,escaped:Ux(a)}}}default:return{}}}}},cb=new Set(["left","top"]);async function mA(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),l=ar(n),a=eo(n),c=Xn(n)==="y",u=cb.has(l)?-1:1,p=o&&c?-1:1,f=Es(t,e);let{mainAxis:h,crossAxis:x,alignmentAxis:j}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof j=="number"&&(x=a==="end"?j*-1:j),c?{x:x*p,y:h*u}:{x:h*u,y:x*p}}const gA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:l,middlewareData:a}=t,c=await mA(t,e);return l===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:l}}}}},xA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:l=!0,crossAxis:a=!1,limiter:c={fn:m=>{let{x:y,y:g}=m;return{x:y,y:g}}},...u}=Es(e,t),p={x:n,y:r},f=await o.detectOverflow(t,u),h=Xn(i),x=zp(h);let j=p[x],w=p[h];const b=(m,y)=>lb(y+f[m==="y"?"top":"left"],y,y-f[m==="y"?"bottom":"right"]);l&&(j=b(x,j)),a&&(w=b(h,w));const v=c.fn({...t,[x]:j,[h]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[x]:l,[h]:a}}}}}},vA=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:o,placement:l,rects:a,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:f=!0}=Es(e,t),h={x:i,y:o},x=Xn(l),j=zp(x);let w=h[j],b=h[x];const v=Es(u,t),m=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(n=v.mainAxis)!=null?n:0,crossAxis:(r=v.crossAxis)!=null?r:0};if(p){const k=j==="y"?"height":"width",S=a.reference[j]-a.floating[k]+m.mainAxis,N=a.reference[j]+a.reference[k]-m.mainAxis;w<S?w=S:w>N&&(w=N)}if(f){var y,g;const k=j==="y"?"width":"height",S=cb.has(ar(l)),N=a.reference[x]-a.floating[k]+(S&&((y=c.offset)==null?void 0:y[x])||0)+(S?0:m.crossAxis),C=a.reference[x]+a.reference[k]+(S?0:((g=c.offset)==null?void 0:g[x])||0)-(S?m.crossAxis:0);b<N?b=N:b>C&&(b=C)}return{[j]:w,[x]:b}}}},jA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:l=()=>{},...a}=Es(e,t),c=await i.detectOverflow(t,a),u=ar(n),p=eo(n),f=Xn(n)==="y",{width:h,height:x}=r.floating;let j,w;u==="top"||u==="bottom"?(j=u,w=p===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(w=u,j=p==="end"?"top":"bottom");const b=x-c.top-c.bottom,v=h-c.left-c.right,m=lr(x-c[j],b),y=lr(h-c[w],v),g=t.middlewareData.shift,k=!g;let S=m,N=y;g!=null&&g.enabled.x&&(N=v),g!=null&&g.enabled.y&&(S=b),k&&!p&&(f?N=h-2*ys(c.left,c.right):S=x-2*ys(c.top,c.bottom)),await l({...t,availableWidth:N,availableHeight:S});const C=await i.getDimensions(o.floating);return h!==C.width||x!==C.height?{reset:{rects:!0}}:{}}}};function Zc(){return typeof window<"u"}function to(e){return ub(e)?(e.nodeName||"").toLowerCase():"#document"}function rn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Is(e){var t;return(t=(ub(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ub(e){return Zc()?e instanceof Node||e instanceof rn(e).Node:!1}function rs(e){return Zc()?e instanceof Element||e instanceof rn(e).Element:!1}function mr(e){return Zc()?e instanceof HTMLElement||e instanceof rn(e).HTMLElement:!1}function Bx(e){return!Zc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof rn(e).ShadowRoot}function eu(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=is(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function yA(e){return/^(table|td|th)$/.test(to(e))}function tu(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const wA=/transform|translate|scale|rotate|perspective|filter/,bA=/paint|layout|strict|content/,wr=e=>!!e&&e!=="none";let rd;function Wp(e){const t=rs(e)?is(e):e;return wr(t.transform)||wr(t.translate)||wr(t.scale)||wr(t.rotate)||wr(t.perspective)||!Hp()&&(wr(t.backdropFilter)||wr(t.filter))||wA.test(t.willChange||"")||bA.test(t.contain||"")}function kA(e){let t=Or(e);for(;mr(t)&&!rl(t);){if(Wp(t))return t;if(tu(t))return null;t=Or(t)}return null}function Hp(){return rd==null&&(rd=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),rd}function rl(e){return/^(html|body|#document)$/.test(to(e))}function is(e){return rn(e).getComputedStyle(e)}function nu(e){return rs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Or(e){if(to(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Bx(e)&&e.host||Is(e);return Bx(t)?t.host:t}function db(e){const t=Or(e);return rl(t)?(e.ownerDocument||e).body:mr(t)&&eu(t)?t:db(t)}function il(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=db(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),l=rn(i);if(o){const a=Gf(l);return t.concat(l,l.visualViewport||[],eu(i)?i:[],a&&n?il(a):[])}else return t.concat(i,il(i,[],n))}function Gf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fb(e){const t=is(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=mr(e),o=i?e.offsetWidth:n,l=i?e.offsetHeight:r,a=xc(n)!==o||xc(r)!==l;return a&&(n=o,r=l),{width:n,height:r,$:a}}function Vp(e){return rs(e)?e:e.contextElement}function Ci(e){const t=Vp(e);if(!mr(t))return ws(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=fb(t);let l=(o?xc(n.width):n.width)/r,a=(o?xc(n.height):n.height)/i;return(!l||!Number.isFinite(l))&&(l=1),(!a||!Number.isFinite(a))&&(a=1),{x:l,y:a}}const SA=ws(0);function hb(e){const t=rn(e);return!Hp()||!t.visualViewport?SA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function NA(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===rn(e)}function Dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=Vp(e);let l=ws(1);t&&(r?rs(r)&&(l=Ci(r)):l=Ci(e));const a=NA(o,n,r)?hb(o):ws(0);let c=(i.left+a.x)/l.x,u=(i.top+a.y)/l.y,p=i.width/l.x,f=i.height/l.y;if(o&&r){const h=rn(o),x=rs(r)?rn(r):r;let j=h,w=Gf(j);for(;w&&x!==j;){const b=Ci(w),v=w.getBoundingClientRect(),m=is(w),y=v.left+(w.clientLeft+parseFloat(m.paddingLeft))*b.x,g=v.top+(w.clientTop+parseFloat(m.paddingTop))*b.y;c*=b.x,u*=b.y,p*=b.x,f*=b.y,c+=y,u+=g,j=rn(w),w=Gf(j)}}return jc({width:p,height:f,x:c,y:u})}function su(e,t){const n=nu(e).scrollLeft;return t?t.left+n:Dr(Is(e)).left+n}function pb(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-su(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function CA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",l=Is(r),a=t?tu(t.floating):!1;if(r===l||a&&o)return n;let c={scrollLeft:0,scrollTop:0},u=ws(1);const p=ws(0),f=mr(r);if((f||!o)&&((to(r)!=="body"||eu(l))&&(c=nu(r)),f)){const x=Dr(r);u=Ci(r),p.x=x.x+r.clientLeft,p.y=x.y+r.clientTop}const h=l&&!f&&!o?pb(l,c):ws(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+h.x,y:n.y*u.y-c.scrollTop*u.y+p.y+h.y}}function EA(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function AA(e){const t=nu(e),n=e.ownerDocument.body,r=ys(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ys(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-t.scrollLeft+su(e);const l=-t.scrollTop;return is(n).direction==="rtl"&&(o+=ys(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:o,y:l}}const TA=25;function RA(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=rn(e),o=Is(e),l=i.visualViewport;let a=o.clientWidth,c=o.clientHeight,u=0,p=0;if(l){const h=!Hp()||t==="fixed";r?h||(u=-l.offsetLeft,p=-l.offsetTop):(a=l.width,c=l.height,h&&(u=l.offsetLeft,p=l.offsetTop))}if(su(o)<=0){const h=o.ownerDocument,x=h.body,j=getComputedStyle(x),w=h.compatMode==="CSS1Compat"&&parseFloat(j.marginLeft)+parseFloat(j.marginRight)||0,b=Math.abs(o.clientWidth-x.clientWidth-w),v=getComputedStyle(o).scrollbarGutter==="stable both-edges"?b/2:b;v<=TA&&(a-=v)}return{width:a,height:c,x:u,y:p}}function PA(e,t){const n=Dr(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Ci(e),l=e.clientWidth*o.x,a=e.clientHeight*o.y,c=i*o.x,u=r*o.y;return{width:l,height:a,x:c,y:u}}function Wx(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=RA(e,n,t);else if(t==="document")r=AA(Is(e));else if(rs(t))r=PA(t,n);else{const i=hb(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return jc(r)}function IA(e,t){const n=t.get(e);if(n)return n;let r=il(e,[],!1).filter(a=>rs(a)&&to(a)!=="body"),i=null;const o=is(e).position==="fixed";let l=o?Or(e):e;for(;rs(l)&&!rl(l);){const a=is(l),c=Wp(l),u=i?i.position:o?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&a.position==="static")?r=r.filter(f=>f!==l):i=a,l=Or(l)}return t.set(e,r),r}function MA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const l=[...n==="clippingAncestors"?tu(t)?[]:IA(t,this._c):[].concat(n),r],a=Wx(t,l[0],i);let c=a.top,u=a.right,p=a.bottom,f=a.left;for(let h=1;h<l.length;h++){const x=Wx(t,l[h],i);c=ys(x.top,c),u=lr(x.right,u),p=lr(x.bottom,p),f=ys(x.left,f)}return{width:u-f,height:p-c,x:f,y:c}}function $A(e){const{width:t,height:n}=fb(e);return{width:t,height:n}}function _A(e,t,n){const r=mr(t),i=Is(t),o=n==="fixed",l=Dr(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const c=ws(0);if((r||!o)&&((to(t)!=="body"||eu(i))&&(a=nu(t)),r)){const h=Dr(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}!r&&i&&(c.x=su(i));const u=i&&!r&&!o?pb(i,a):ws(0),p=l.left+a.scrollLeft-c.x-u.x,f=l.top+a.scrollTop-c.y-u.y;return{x:p,y:f,width:l.width,height:l.height}}function id(e){return is(e).position==="static"}function Hx(e,t){if(!mr(e)||is(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Is(e)===n&&(n=n.ownerDocument.body),n}function mb(e,t){const n=rn(e);if(tu(e))return n;if(!mr(e)){let i=Or(e);for(;i&&!rl(i);){if(rs(i)&&!id(i))return i;i=Or(i)}return n}let r=Hx(e,t);for(;r&&yA(r)&&id(r);)r=Hx(r,t);return r&&rl(r)&&id(r)&&!Wp(r)?n:r||kA(e)||n}const OA=async function(e){const t=this.getOffsetParent||mb,n=this.getDimensions,r=await n(e.floating);return{reference:_A(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DA(e){return is(e).direction==="rtl"}const LA={convertOffsetParentRelativeRectToViewportRelativeRect:CA,getDocumentElement:Is,getClippingRect:MA,getOffsetParent:mb,getElementRects:OA,getClientRects:EA,getDimensions:$A,getScale:Ci,isElement:rs,isRTL:DA};function gb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function FA(e,t,n){let r=null,i;const o=Is(e);function l(){var p;clearTimeout(i),(p=r)==null||p.disconnect(),r=null}function a(p,f){p===void 0&&(p=!1),f===void 0&&(f=1),l();const h=e.getBoundingClientRect(),{left:x,top:j,width:w,height:b}=h;if(p||t(),!w||!b)return;const v=ea(j),m=ea(o.clientWidth-(x+w)),y=ea(o.clientHeight-(j+b)),g=ea(x),S={rootMargin:-v+"px "+-m+"px "+-y+"px "+-g+"px",threshold:ys(0,lr(1,f))||1};let N=!0;function C(P){const E=P[0].intersectionRatio;if(!gb(h,e.getBoundingClientRect()))return a();if(E!==f){if(!N)return a();E?a(!1,E):i=setTimeout(()=>{a(!1,1e-7)},1e3)}N=!1}try{r=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{r=new IntersectionObserver(C,S)}r.observe(e)}const c=rn(e),u=()=>a(n);return c.addEventListener("resize",u),a(!0),()=>{c.removeEventListener("resize",u),l()}}function zA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Vp(e),p=i||o?[...u?il(u):[],...t?il(t):[]]:[];p.forEach(v=>{i&&v.addEventListener("scroll",n),o&&v.addEventListener("resize",n)});const f=u&&a?FA(u,n,o):null;let h=-1,x=null;l&&(x=new ResizeObserver(v=>{let[m]=v;m&&m.target===u&&x&&t&&(x.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=x)==null||y.observe(t)})),n()}),u&&!c&&x.observe(u),t&&x.observe(t));let j,w=c?Dr(e):null;c&&b();function b(){const v=Dr(e);w&&!gb(w,v)&&n(),w=v,j=requestAnimationFrame(b)}return n(),()=>{var v;p.forEach(m=>{i&&m.removeEventListener("scroll",n),o&&m.removeEventListener("resize",n)}),f==null||f(),(v=x)==null||v.disconnect(),x=null,c&&cancelAnimationFrame(j)}}const UA=gA,BA=xA,WA=hA,HA=jA,VA=pA,Vx=fA,KA=vA,GA=(e,t,n)=>{const r=new Map,i=n??{},o={...LA,...i.platform,_c:r};return dA(e,t,{...i,platform:o})};var YA=typeof document<"u",qA=function(){},Da=YA?d.useLayoutEffect:qA;function yc(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 n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!yc(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!yc(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function xb(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Kx(e,t){const n=xb(e);return Math.round(t*n)/n}function od(e){const t=d.useRef(e);return Da(()=>{t.current=e}),t}function QA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[p,f]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,x]=d.useState(r);yc(h,r)||x(r);const[j,w]=d.useState(null),[b,v]=d.useState(null),m=d.useCallback(M=>{M!==S.current&&(S.current=M,w(M))},[]),y=d.useCallback(M=>{M!==N.current&&(N.current=M,v(M))},[]),g=o||j,k=l||b,S=d.useRef(null),N=d.useRef(null),C=d.useRef(p),P=c!=null,E=od(c),O=od(i),L=od(u),D=d.useCallback(()=>{if(!S.current||!N.current)return;const M={placement:t,strategy:n,middleware:h};O.current&&(M.platform=O.current),GA(S.current,N.current,M).then(W=>{const _={...W,isPositioned:L.current!==!1};T.current&&!yc(C.current,_)&&(C.current=_,Di.flushSync(()=>{f(_)}))})},[h,t,n,O,L]);Da(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const T=d.useRef(!1);Da(()=>(T.current=!0,()=>{T.current=!1}),[]),Da(()=>{if(g&&(S.current=g),k&&(N.current=k),g&&k){if(E.current)return E.current(g,k,D);D()}},[g,k,D,E,P]);const z=d.useMemo(()=>({reference:S,floating:N,setReference:m,setFloating:y}),[m,y]),q=d.useMemo(()=>({reference:g,floating:k}),[g,k]),K=d.useMemo(()=>{const M={position:n,left:0,top:0};if(!q.floating)return M;const W=Kx(q.floating,p.x),_=Kx(q.floating,p.y);return a?{...M,transform:"translate("+W+"px, "+_+"px)",...xb(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:_}},[n,a,q.floating,p.x,p.y]);return d.useMemo(()=>({...p,update:D,refs:z,elements:q,floatingStyles:K}),[p,D,z,q,K])}const JA=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Vx({element:r.current,padding:i}).fn(n):{}:r?Vx({element:r,padding:i}).fn(n):{}}}},XA=(e,t)=>{const n=UA(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZA=(e,t)=>{const n=BA(e);return{name:n.name,fn:n.fn,options:[e,t]}},eT=(e,t)=>({fn:KA(e).fn,options:[e,t]}),tT=(e,t)=>{const n=WA(e);return{name:n.name,fn:n.fn,options:[e,t]}},nT=(e,t)=>{const n=HA(e);return{name:n.name,fn:n.fn,options:[e,t]}},sT=(e,t)=>{const n=VA(e);return{name:n.name,fn:n.fn,options:[e,t]}},rT=(e,t)=>{const n=JA(e);return{name:n.name,fn:n.fn,options:[e,t]}};var iT=Object.defineProperty,oT=(e,t)=>iT(e,"name",{value:t,configurable:!0});function vb(e){const[t,n]=d.useState(void 0);return sn(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let l,a;if("borderBoxSize"in o){const c=o.borderBoxSize,u=Array.isArray(c)?c[0]:c;l=u.inlineSize,a=u.blockSize}else l=e.offsetWidth,a=e.offsetHeight;n({width:l,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}oT(vb,"useSize");var lT=Object.defineProperty,tr=(e,t)=>lT(e,"name",{value:t,configurable:!0}),jb="Popper",[yb,ru]=Bn(jb),[aT,wb]=yb(jb),cT=tr(e=>{const{__scopePopper:t,children:n}=e,[r,i]=d.useState(null),[o,l]=d.useState(void 0);return s.jsx(aT,{scope:t,anchor:r,onAnchorChange:i,placementState:o,setPlacementState:l,children:n})},"Popper"),uT="PopperAnchor",dT=d.forwardRef(tr(function(t,n){const{__scopePopper:r,virtualRef:i,...o}=t,l=wb(uT,r),a=d.useRef(null),c=l.onAnchorChange,u=d.useCallback(w=>{a.current=w,w&&c(w)},[c]),p=qe(n,u),f=d.useRef(null);d.useEffect(()=>{if(!i)return;const w=f.current;f.current=i.current,w!==f.current&&c(f.current)});const h=l.placementState&&iu(l.placementState),x=h==null?void 0:h[0],j=h==null?void 0:h[1];return i?null:s.jsx(Je.div,{"data-radix-popper-side":x,"data-radix-popper-align":j,...o,ref:p})},"PopperAnchor")),bb="PopperContent",[fT,r6]=yb(bb),hT=d.forwardRef(tr(function(t,n){var he,ge,ye,kt,ct,_e,$;const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:l="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:p=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:x=!1,updatePositionStrategy:j="optimized",onPlaced:w,...b}=t,v=wb(bb,r),[m,y]=d.useState(null),g=qe(n,y),[k,S]=d.useState(null),N=vb(k),C=(N==null?void 0:N.width)??0,P=(N==null?void 0:N.height)??0,E=i+(l!=="center"?"-"+l:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},L=Array.isArray(p)?p:[p],D=L.length>0,T={padding:O,boundary:L.filter(kb),altBoundary:D},{refs:z,floatingStyles:q,placement:K,isPositioned:M,middlewareData:W}=QA({strategy:"fixed",placement:E,whileElementsMounted:tr((...de)=>zA(...de,{animationFrame:j==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[XA({mainAxis:o+P,alignmentAxis:a}),u&&ZA({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?eT():void 0,...T}),u&&tT({...T}),nT({...T,apply:tr(({elements:de,rects:xe,availableWidth:be,availableHeight:it})=>{const{width:St,height:cn}=xe.reference,Tn=de.floating.style;Tn.setProperty("--radix-popper-available-width",`${be}px`),Tn.setProperty("--radix-popper-available-height",`${it}px`),Tn.setProperty("--radix-popper-anchor-width",`${St}px`),Tn.setProperty("--radix-popper-anchor-height",`${cn}px`)},"apply")}),k&&rT({element:k,padding:c}),pT({arrowWidth:C,arrowHeight:P}),x&&sT({strategy:"referenceHidden",...T,boundary:D?T.boundary:void 0})]}),_=v.setPlacementState;sn(()=>(_(K),()=>{_(void 0)}),[K,_]);const[U,X]=iu(K),Z=zn(w);sn(()=>{M&&(Z==null||Z())},[M,Z]);const ue=(he=W.arrow)==null?void 0:he.x,je=(ge=W.arrow)==null?void 0:ge.y,Ce=((ye=W.arrow)==null?void 0:ye.centerOffset)!==0,[Pe,Ve]=d.useState();return sn(()=>{m&&Ve(window.getComputedStyle(m).zIndex)},[m]),s.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:M?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Pe,"--radix-popper-transform-origin":[(kt=W.transformOrigin)==null?void 0:kt.x,(ct=W.transformOrigin)==null?void 0:ct.y].join(" "),...((_e=W.hide)==null?void 0:_e.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(fT,{scope:r,placedSide:U,placedAlign:X,onArrowChange:S,arrowX:ue,arrowY:je,shouldHideArrow:Ce,children:s.jsx(Je.div,{"data-side":U,"data-align":X,...b,ref:g,style:{...b.style,animation:M?($=b.style)==null?void 0:$.animation:"none"}})})})},"PopperContent"));function kb(e){return e!==null}tr(kb,"isNotNull");var pT=tr(e=>({name:"transformOrigin",options:e,fn(t){var b,v,m;const{placement:n,rects:r,middlewareData:i}=t,l=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=l?0:e.arrowWidth,c=l?0:e.arrowHeight,[u,p]=iu(n),f={start:"0%",center:"50%",end:"100%"}[p],h=(((v=i.arrow)==null?void 0:v.x)??0)+a/2,x=(((m=i.arrow)==null?void 0:m.y)??0)+c/2;let j="",w="";return u==="bottom"?(j=l?f:`${h}px`,w=`${-c}px`):u==="top"?(j=l?f:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(j=`${-c}px`,w=l?f:`${x}px`):u==="left"&&(j=`${r.floating.width+c}px`,w=l?f:`${x}px`),{data:{x:j,y:w}}}}),"transformOrigin");function iu(e){const[t,n="center"]=e.split("-");return[t,n]}tr(iu,"getSideAndAlignFromPlacement");var Sb=cT,Nb=dT,Cb=hT,mT=Object.defineProperty,xt=(e,t)=>mT(e,"name",{value:t,configurable:!0}),[Kp,i6]=Bn("Tooltip",[ru]),Gp=ru(),gT="TooltipProvider",xT=700,Yf="tooltip.open",[vT,Yp]=Kp(gT),jT=xt(e=>{const{__scopeTooltip:t,delayDuration:n=xT,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,l=d.useRef(!0),a=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),s.jsx(vT,{scope:t,isOpenDelayedRef:l,delayDuration:n,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:a,onPointerInTransitChange:d.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:o})},"TooltipProvider"),qf="Tooltip",[yT,yl]=Kp(qf),wT=xt(e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:l,delayDuration:a}=e,c=Yp(qf,e.__scopeTooltip),u=Gp(t),[p,f]=d.useState(null),[h,x]=d.useState(void 0),j=js(),w=d.useRef(0),b=l??c.disableHoverableContent,v=a??c.delayDuration,m=d.useRef(!1),[y,g]=Zi({prop:r,defaultProp:i??!1,onChange:xt(E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Yf))):c.onClose(),o==null||o(E)},"onChange"),caller:qf}),k=d.useMemo(()=>y?m.current?"delayed-open":"instant-open":"closed",[y]),S=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,m.current=!1,g(!0)},[g]),N=d.useCallback(()=>{window.clearTimeout(w.current),w.current=0,g(!1)},[g]),C=d.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{m.current=!0,g(!0),w.current=0},v)},[v,g]);d.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]);const P=h??j;return s.jsx(Sb,{...u,children:s.jsx(yT,{scope:t,contentId:P,setContentId:x,open:y,stateAttribute:k,trigger:p,onTriggerChange:f,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayedRef.current?C():S()},[c.isOpenDelayedRef,C,S]),onTriggerLeave:d.useCallback(()=>{b?N():(window.clearTimeout(w.current),w.current=0)},[N,b]),onOpen:S,onClose:N,disableHoverableContent:b,children:n})})},"Tooltip"),Gx="TooltipTrigger",bT=d.forwardRef(xt(function(t,n){const{__scopeTooltip:r,...i}=t,o=yl(Gx,r),l=Yp(Gx,r),a=Gp(r),c=d.useRef(null),u=qe(n,c,o.onTriggerChange),p=d.useRef(!1),f=d.useRef(!1),h=d.useCallback(()=>p.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(Nb,{asChild:!0,...a,children:s.jsx(Je.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:u,onPointerMove:we(t.onPointerMove,x=>{x.pointerType!=="touch"&&!f.current&&!l.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:we(t.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:we(t.onPointerDown,()=>{o.open&&o.onClose(),p.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:we(t.onFocus,()=>{p.current||o.onOpen()}),onBlur:we(t.onBlur,o.onClose),onClick:we(t.onClick,o.onClose)})})},"TooltipTrigger")),Eb="TooltipPortal",[kT,ST]=Kp(Eb,{forceMount:void 0}),NT=xt(e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,o=yl(Eb,t);return s.jsx(kT,{scope:t,forceMount:n,children:s.jsx(pr,{present:n||o.open,children:s.jsx(Fp,{asChild:!0,container:i,children:r})})})},"TooltipPortal"),ol="TooltipContent",CT=d.forwardRef(xt(function(t,n){const r=ST(ol,t.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...l}=t,a=yl(ol,t.__scopeTooltip);return s.jsx(pr,{present:i||a.open,children:a.disableHoverableContent?s.jsx(Ab,{side:o,...l,ref:n}):s.jsx(ET,{side:o,...l,ref:n})})},"TooltipContent")),ET=d.forwardRef(xt(function(t,n){const r=yl(ol,t.__scopeTooltip),i=Yp(ol,t.__scopeTooltip),o=d.useRef(null),l=qe(n,o),[a,c]=d.useState(null),{trigger:u,onClose:p}=r,f=o.current,{onPointerInTransitChange:h}=i,x=d.useCallback(()=>{c(null),h(!1)},[h]),j=d.useCallback((w,b)=>{const v=w.currentTarget,m={x:w.clientX,y:w.clientY},y=Tb(m,v.getBoundingClientRect()),g=Rb(m,y),k=Pb(b.getBoundingClientRect()),S=Mb([...g,...k]);c(S),h(!0)},[h]);return d.useEffect(()=>()=>x(),[x]),d.useEffect(()=>{if(u&&f){const w=xt(v=>j(v,f),"handleTriggerLeave"),b=xt(v=>j(v,u),"handleContentLeave");return u.addEventListener("pointerleave",w),f.addEventListener("pointerleave",b),()=>{u.removeEventListener("pointerleave",w),f.removeEventListener("pointerleave",b)}}},[u,f,j,x]),d.useEffect(()=>{if(a){const w=xt(b=>{const v=b.target,m={x:b.clientX,y:b.clientY},y=(u==null?void 0:u.contains(v))||(f==null?void 0:f.contains(v)),g=!Ib(m,a);y?x():g&&(x(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,f,a,p,x]),s.jsx(Ab,{...t,ref:l})},"TooltipContentHoverable")),AT=$w("TooltipContent"),Ab=d.forwardRef(xt(function(t,n){const{__scopeTooltip:r,children:i,"aria-label":o,id:l,onEscapeKeyDown:a,onPointerDownOutside:c,...u}=t,p=yl(ol,r),f=Gp(r),{onClose:h}=p;d.useEffect(()=>(document.addEventListener(Yf,h),()=>document.removeEventListener(Yf,h)),[h]),d.useEffect(()=>{if(p.trigger){const j=xt(w=>{w.target instanceof Node&&w.target.contains(p.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[p.trigger,h]);const{setContentId:x}=p;return sn(()=>(x(l),()=>{x(void 0)}),[l,x]),s.jsx(Dp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:j=>j.preventDefault(),onDismiss:h,children:s.jsxs(Cb,{"data-state":p.stateAttribute,role:o?void 0:"tooltip",id:o?void 0:p.contentId,...f,...u,ref:n,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:[s.jsx(AT,{children:i}),o?s.jsx(_E,{id:p.contentId,role:"tooltip",children:o}):null]})})},"TooltipContentImpl"));function Tb(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}xt(Tb,"getExitSideFromRect");function Rb(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}xt(Rb,"getPaddedExitPoints");function Pb(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}xt(Pb,"getPointsFromRect");function Ib(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],c=t[l],u=a.x,p=a.y,f=c.x,h=c.y;p>r!=h>r&&n<(f-u)*(r-p)/(h-p)+u&&(i=!i)}return i}xt(Ib,"isPointInPolygon");function Mb(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),$b(t)}xt(Mb,"getHull");function $b(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 o=t[t.length-1],l=t[t.length-2];if((o.x-l.x)*(i.y-l.y)>=(o.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const o=n[n.length-1],l=n[n.length-2];if((o.x-l.x)*(i.y-l.y)>=(o.y-l.y)*(i.x-l.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}xt($b,"getHullPresorted");var Yx=jT,wc=wT,bc=bT,kc=NT,Sc=CT;const qx="buddi_csrf",no="x-buddi-csrf",ll="buddi:agents-changed",TT="This page's sign-in no longer matches its cookies. Reload the page and try again.";class ce extends Error{constructor(t,n,r){super(n),this.status=t,this.detail=r,this.name="ApiError"}}function Hr(){var r;const e=Number(location.port)||(location.protocol==="https:"?443:80),t=document.cookie.match(new RegExp(`(?:^|; )${qx}_${e}=([^;]*)`));if(t!=null&&t[1])return decodeURIComponent(t[1]);const n=[...document.cookie.matchAll(new RegExp(`(?:^|; )${qx}(?:_\\d+)?=([^;]*)`,"g"))];return n.length===1&&((r=n[0])!=null&&r[1])?decodeURIComponent(n[0][1]):""}async function Vr(e,t={}){const n=await fetch(e,{...t,credentials:"same-origin",redirect:"error",headers:{Accept:"application/json",...t.headers??{}}});if(n.status===401)throw new ce(401,"This session has expired. Run `buddi dashboard` for a fresh link.");const r=await n.text(),i=r===""?null:RT(r);if(!n.ok){const o=i&&typeof i=="object"&&"error"in i?String(i.error):void 0,l=(t.method??"GET").toUpperCase(),a=o??(n.status===403&&l!=="GET"&&l!=="HEAD"?TT:`request failed (${n.status})`);throw new ce(n.status,a,i)}return i}function RT(e){try{return JSON.parse(e)}catch{return null}}function le(e,t={}){const n=new URLSearchParams;for(const[i,o]of Object.entries(t))o!==void 0&&o!==""&&n.set(i,String(o));const r=n.toString();return Vr(`/api${e}${r?`?${r}`:""}`)}function _b(e,t){return Vr(`/api${e}`,{method:"POST",headers:{[no]:Hr()},body:t})}function Lo(e){return Vr(`/api${e}`,{method:"DELETE",headers:{[no]:Hr()}})}function ne(e,t={}){return Vr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/json",[no]:Hr()},body:JSON.stringify(t??{})})}function Ob(e,t,n,r={}){const i=t.name.replace(/[^\w.-]+/g,"_").slice(-120)||n;return Vr(`/api${e}`,{method:"POST",headers:{"Content-Type":"application/octet-stream",[no]:Hr(),"X-Filename":i,...r},body:t})}function Qx(e,t,n){return Ob(e,t,"backup.tar.gz",{...n.passphrase?{"X-Backup-Passphrase":n.passphrase}:{},...n.confirm?{"X-Backup-Confirm":n.confirm}:{}})}function PT(e,t={}){return Vr(`/api${e}`,{method:"PATCH",headers:{"Content-Type":"application/json",[no]:Hr()},body:JSON.stringify(t??{})})}function yo(e,t={}){return Vr(`/api${e}`,{method:"PUT",headers:{"Content-Type":"application/json",[no]:Hr()},body:JSON.stringify(t??{})})}function IT(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 MT=["approval","question","watcher","reminder","failure","recap","plugin"],Fe={agents:()=>le("/chat/agents"),views:()=>le("/chat/views"),conversations:(e,t)=>le(`/chat/${encodeURIComponent(e)}/conversations`,{limit:t}),startConversation:e=>ne(`/chat/${encodeURIComponent(e)}/conversations`),conversation:e=>le(`/chat/conversations/${encodeURIComponent(e)}`),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),_b("/chat/attachments",t)},discardAttachment:e=>Lo(`/artifacts/${encodeURIComponent(e)}`),groups:()=>le("/groups"),group:e=>le(`/groups/${encodeURIComponent(e)}`),createGroup:e=>ne("/groups",e),updateGroup:(e,t)=>PT(`/groups/${encodeURIComponent(e)}`,t),archiveGroup:e=>Lo(`/groups/${encodeURIComponent(e)}`),groupConversations:e=>le(`/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`},A={providers:()=>le("/providers"),providerAccounts:()=>le("/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,n)=>ne(`/provider-accounts/${encodeURIComponent(e)}/${t}`,{revision:n}),anthropicAccountAction:(e,t,n,r)=>ne(`/provider-accounts/${encodeURIComponent(e)}/anthropic/${t}`,{revision:n,...r}),assignProviderAccount:(e,t,n)=>ne(`/agents/${encodeURIComponent(e)}/account`,{accountId:t,model:n}),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=>le("/host/browser-profiles",{app:e}),installedApps:()=>le("/host/apps"),browser:e=>le(`/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)=>le(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/link`),previewCheck:(e,t)=>le(`/preview/${encodeURIComponent(e)}/${encodeURIComponent(t)}/check`),extension:()=>le("/extension"),pairExtension:e=>ne("/extension/pair",{code:e}),forgetExtension:()=>Lo("/extension/pair"),session:()=>le("/session"),overview:()=>le("/overview"),events:e=>le("/events",e),eventKinds:()=>le("/events/kinds"),conversations:()=>le("/conversations"),conversation:e=>le(`/conversations/${encodeURIComponent(e)}`),missions:()=>le("/missions"),jobs:(e={})=>le("/jobs",e),approvals:()=>le("/approvals"),approval:e=>le(`/approvals/${encodeURIComponent(e)}`).then(t=>t.action),offers:()=>le("/offers"),dismissOffer:e=>ne(`/offers/${encodeURIComponent(e)}/dismiss`,{}),dismissOffers:e=>ne("/offers/dismiss-all",{ids:e}),agentOffers:()=>le("/agent-offers"),dismissAgentOffer:(e,t)=>ne(`/agent-offers/${encodeURIComponent(e)}/${encodeURIComponent(t)}/dismiss`,{}),proposals:()=>le("/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}),discardProposal:(e,t)=>ne(`/proposals/${encodeURIComponent(e)}/discard`,t?{reason:t}:{}),reminders:()=>le("/reminders"),sentinels:()=>le("/sentinels"),setSentinelEnabled:(e,t)=>ne(`/sentinels/${encodeURIComponent(e)}/enabled`,{enabled:t}),snoozeAlert:(e,t)=>ne(`/alerts/${encodeURIComponent(e)}/snooze`,{snoozed:t}),agents:()=>le("/agents"),library:e=>le("/artifacts",e),libraryEntry:(e,t=0)=>le(`/artifacts/${encodeURIComponent(e)}`,t?{contexts:t}:{}),onboarding:()=>le("/onboarding"),onboardingStep:(e,t={})=>ne("/onboarding/step",{step:e,...t}),completeOnboarding:()=>ne("/onboarding/complete"),skipOnboarding:()=>ne("/onboarding/skip"),createFirstAgent:e=>ne("/onboarding/agent",e),ollama:()=>le("/onboarding/ollama"),firstAgentPersona:()=>le("/onboarding/agent"),updateFirstAgent:e=>ne("/onboarding/agent/update",e),bindBrain:e=>ne("/onboarding/brain",e),pages:()=>le("/pages"),pageQuery:(e,t,n={})=>le(`/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n),pageFileUrl:(e,t,n={})=>{const r=new URLSearchParams(Object.entries(n).filter(([,i])=>i!=="")).toString();return`/api/pages/${encodeURIComponent(e)}/${encodeURIComponent(t)}${r?`?${r}`:""}`},pageAct:(e,t)=>ne(`/pages/${encodeURIComponent(e)}/act`,t),telegram:()=>le("/telegram"),saveTelegramToken:e=>ne("/telegram/token",{token:e}),telegramPairing:()=>ne("/telegram/pairing"),telegramBot:()=>le("/telegram/bot"),telegramDevices:()=>le("/telegram/devices"),unpairTelegramDevice:e=>Lo(`/telegram/devices/${encodeURIComponent(e)}`),notifications:(e=20)=>le("/notifications",{limit:e}),notificationSeen:e=>ne(`/notifications/${encodeURIComponent(e)}/seen`),notificationSettings:()=>le("/notifications/settings"),saveNotificationSettings:e=>yo("/notifications/settings",e),testChannel:e=>ne("/notifications/test",{channel:e}),presence:e=>ne("/presence",{state:e}),owner:()=>le("/owner"),setOwner:e=>ne("/owner",e),memory:e=>le(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=>le(`/agents/${encodeURIComponent(e)}/profile`),agentSkills:e=>le(`/agents/${encodeURIComponent(e)}/skills`),removeSkill:(e,t)=>ne(`/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}/remove`,{}),host:(e,t)=>le("/host",{agentId:e,conversationId:t}),secrets:()=>le("/secrets"),secretUses:(e,t)=>le("/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,n,r)=>ne(`/approvals/${encodeURIComponent(e)}/${t}`,n||r?{...n?{permissionScope:n}:{},...r?{ownerChoices:r}:{}}:void 0),setPaused:e=>ne("/pause",{paused:e}),service:()=>le("/service"),serviceAction:e=>ne(`/service/${e}`),version:()=>le("/version"),checkVersion:()=>ne("/version/check"),setVersionCheck:e=>yo("/version/check",{enabled:e}),tailscale:()=>le("/tailscale"),setTailscale:e=>yo("/tailscale",e),startUpgrade:e=>ne("/upgrade",e===void 0?{}:{version:e}),upgradeJob:e=>le(`/upgrade/jobs/${encodeURIComponent(e)}`),backups:()=>le("/backups"),startBackup:e=>ne("/backups",{encrypt:e}),verifyArchive:e=>ne("/backups/verify",{name:e}),restoreArchive:e=>ne("/backups/restore",e),restoreUpload:(e,t)=>Qx("/backups/restore",e,t),backupJob:e=>le(`/backups/jobs/${encodeURIComponent(e)}`),backupSchedule:()=>le("/backups/schedule"),setBackupSchedule:e=>yo("/backups/schedule",e),backupPassphrase:()=>le("/backups/passphrase"),setBackupPassphrase:e=>yo("/backups/passphrase",{passphrase:e}),plugins:()=>le("/plugins"),stagePlugin:e=>ne("/plugins/stage",{spec:e}),uploadPlugin:e=>Ob("/plugins/upload",e,"plugin.tgz"),pluginJob:e=>le(`/plugins/jobs/${encodeURIComponent(e)}`),approveStaged:(e,t)=>ne(`/plugins/staged/${encodeURIComponent(e)}/approve`,t),rejectStaged:e=>ne(`/plugins/staged/${encodeURIComponent(e)}/reject`),updatePlugin:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/update`,t?{version:t}:{}),uninstallPlugin:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/uninstall`,t),acceptPluginAgent:(e,t)=>ne(`/plugins/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/accept`),recovery:()=>le("/recovery"),leaveRecovery:e=>ne("/recovery/leave",e),firstRunRestore:(e,t)=>Qx("/onboarding/restore",e,{passphrase:t}),setMissionEnabled:(e,t)=>ne(`/missions/${encodeURIComponent(e)}/enabled`,{enabled:t}),setMisfirePolicy:(e,t,n)=>ne(`/missions/${encodeURIComponent(e)}/schedule`,{misfirePolicy:t,...n===void 0?{}:{deadlineMinutes:n}}),retryJob:e=>ne(`/jobs/${encodeURIComponent(e)}/retry`),cancelJob:e=>ne(`/jobs/${encodeURIComponent(e)}/cancel`),setDefaultAgent:e=>ne("/agents/default",{agentId:e}),agentTools:e=>le(`/agents/${encodeURIComponent(e)}/tools`),agentFile:e=>le(`/agents/${encodeURIComponent(e)}/file`),uploadAgentPicture:(e,t)=>{const n=new FormData;return n.append("file",t,t.name),_b(`/agents/${encodeURIComponent(e)}/avatar`,n)},removeAgentPicture:e=>Lo(`/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"})};var $T=Object.defineProperty,_T=(e,t)=>$T(e,"name",{value:t,configurable:!0}),OT=d.createContext(void 0);function ou(e){const t=d.useContext(OT);return e||t||"ltr"}_T(ou,"useDirection");var DT=Object.defineProperty,qp=(e,t)=>DT(e,"name",{value:t,configurable:!0}),ta=0,Yn=null;function LT(e){return lu(),e.children}qp(LT,"FocusGuards");function lu(){d.useEffect(()=>{Yn||(Yn={start:Qf(),end:Qf()});const{start:e,end:t}=Yn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ta++,()=>{ta===1&&(Yn==null||Yn.start.remove(),Yn==null||Yn.end.remove(),Yn=null),ta=Math.max(0,ta-1)}},[])}qp(lu,"useFocusGuards");function Qf(){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}qp(Qf,"createFocusGuard");var FT=Object.defineProperty,Bt=(e,t)=>FT(e,"name",{value:t,configurable:!0}),ld="focusScope.autoFocusOnMount",ad="focusScope.autoFocusOnUnmount",Jx={bubbles:!1,cancelable:!0},Db=d.forwardRef(Bt(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:l,...a}=t,[c,u]=d.useState(null),p=zn(o),f=zn(l),h=d.useRef(null),x=qe(n,u),j=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let b=function(g){if(j.paused||!c)return;const k=g.target;c.contains(k)?h.current=k:ps(h.current,{select:!0})},v=function(g){if(j.paused||!c)return;const k=g.relatedTarget;k!==null&&(c.contains(k)||ps(h.current,{select:!0}))},m=function(g){if(document.activeElement===document.body)for(const S of g)S.removedNodes.length>0&&ps(c)};Bt(b,"handleFocusIn"),Bt(v,"handleFocusOut"),Bt(m,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const y=new MutationObserver(m);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),y.disconnect()}}},[i,c,j.paused]),d.useEffect(()=>{if(c){Xx.add(j);const b=document.activeElement;if(!c.contains(b)){const m=new CustomEvent(ld,Jx);c.addEventListener(ld,p),c.dispatchEvent(m),m.defaultPrevented||(Lb(Wb(Qp(c)),{select:!0}),document.activeElement===b&&ps(c))}return()=>{c.removeEventListener(ld,p),setTimeout(()=>{const m=new CustomEvent(ad,Jx);c.addEventListener(ad,f),c.dispatchEvent(m),m.defaultPrevented||ps(b??document.body,{select:!0}),c.removeEventListener(ad,f),Xx.remove(j)},0)}}},[c,p,f,j]);const w=d.useCallback(b=>{if(!r&&!i||j.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,m=document.activeElement;if(v&&m){const y=b.currentTarget,[g,k]=Fb(y);g&&k?!b.shiftKey&&m===k?(b.preventDefault(),r&&ps(g,{select:!0})):b.shiftKey&&m===g&&(b.preventDefault(),r&&ps(k,{select:!0})):m===y&&b.preventDefault()}},[r,i,j.paused]);return s.jsx(Je.div,{tabIndex:-1,...a,ref:x,onKeyDown:w})},"FocusScope"));function Lb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ps(r,{select:t}),document.activeElement!==n)return}Bt(Lb,"focusFirst");function Fb(e){const t=Qp(e),n=Jf(t,e),r=Jf(t.reverse(),e);return[n,r]}Bt(Fb,"getTabbableEdges");function Qp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Bt(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(;n.nextNode();)t.push(n.currentNode);return t}Bt(Qp,"getTabbableCandidates");function Jf(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):zb(r,{upTo:t})))return r}Bt(Jf,"findVisible");function zb(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}Bt(zb,"isHidden");function Ub(e){return e instanceof HTMLInputElement&&"select"in e}Bt(Ub,"isSelectableInput");function ps(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ub(e)&&t&&e.select()}}Bt(ps,"focus");var Xx=Bb();function Bb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Xf(e,t),e.unshift(t)},remove(t){var n;e=Xf(e,t),(n=e[0])==null||n.resume()}}}Bt(Bb,"createFocusScopesStack");function Xf(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Bt(Xf,"arrayRemove");function Wb(e){return e.filter(t=>t.tagName!=="A")}Bt(Wb,"removeLinks");var zT=Object.defineProperty,Jp=(e,t)=>zT(e,"name",{value:t,configurable:!0}),cd=!1;function Hb(){const[e,t]=d.useState(cd);return d.useEffect(()=>{cd||(cd=!0,t(!0))},[]),e}Jp(Hb,"useIsHydrated");var Vb=qi[" useSyncExternalStore ".trim().toString()];function Kb(){return()=>{}}Jp(Kb,"subscribe");function Gb(){return Vb(Kb,()=>!0,()=>!1)}Jp(Gb,"useIsHydratedModern");var UT=typeof Vb=="function"?Gb:Hb,BT=Object.defineProperty,Kr=(e,t)=>BT(e,"name",{value:t,configurable:!0}),ud="rovingFocusGroup.onEntryFocus",WT={bubbles:!1,cancelable:!0},au="RovingFocusGroup",[Zf,Yb,HT]=Jc(au),[VT,cu]=Bn(au,[HT]),[KT,GT]=VT(au),YT=d.forwardRef(Kr(function(t,n){return s.jsx(Zf.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Zf.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(qT,{...t,ref:n})})})},"RovingFocusGroup")),qT=d.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,orientation:i,loop:o=!1,dir:l,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:p,preventScrollOnEntryFocus:f=!1,...h}=t,x=d.useRef(null),j=qe(n,x),w=ou(l),[b,v]=Zi({prop:a,defaultProp:c??null,onChange:u,caller:au}),[m,y]=d.useState(!1),g=zn(p),k=Yb(r),S=d.useRef(!1),[N,C]=d.useState(0);return d.useEffect(()=>{const P=x.current;if(P)return P.addEventListener(ud,g),()=>P.removeEventListener(ud,g)},[g]),s.jsx(KT,{scope:r,orientation:i,dir:w,loop:o,currentTabStopId:b,onItemFocus:d.useCallback(P=>v(P),[v]),onItemShiftTab:d.useCallback(()=>y(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(P=>P+1),[]),onFocusableItemRemove:d.useCallback(()=>C(P=>P-1),[]),children:s.jsx(Je.div,{tabIndex:m||N===0?-1:0,"data-orientation":i,...h,ref:j,style:{outline:"none",...t.style},onMouseDown:we(t.onMouseDown,()=>{S.current=!0}),onFocus:we(t.onFocus,P=>{const E=!S.current;if(P.target===P.currentTarget&&E&&!m){const O=new CustomEvent(ud,WT);if(P.currentTarget.dispatchEvent(O),!O.defaultPrevented){const L=k().filter(K=>K.focusable),D=L.find(K=>K.active),T=L.find(K=>K.id===b),q=[D,T,...L].filter(Boolean).map(K=>K.ref.current);Xp(q,f)}}S.current=!1}),onBlur:we(t.onBlur,()=>y(!1))})})},"RovingFocusGroupImpl")),QT="RovingFocusGroupItem",JT=d.forwardRef(Kr(function(t,n){const{__scopeRovingFocusGroup:r,focusable:i=!0,active:o=!1,tabStopId:l,children:a,...c}=t,u=js(),p=l||u,f=GT(QT,r),h=f.currentTabStopId===p,x=Yb(r),{onFocusableItemAdd:j,onFocusableItemRemove:w,currentTabStopId:b}=f,v=UT();return sn(()=>{if(!(!v||!i))return j(),()=>w()},[v,i,j,w]),d.useEffect(()=>{if(!(v||!i))return j(),()=>w()},[v,i,j,w]),s.jsx(Zf.ItemSlot,{scope:r,id:p,focusable:i,active:o,children:s.jsx(Je.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...c,ref:n,onMouseDown:we(t.onMouseDown,m=>{i?f.onItemFocus(p):m.preventDefault()}),onFocus:we(t.onFocus,()=>f.onItemFocus(p)),onKeyDown:we(t.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){f.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const y=Qb(m,f.orientation,f.dir);if(y!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let k=x().filter(S=>S.focusable).map(S=>S.ref.current);if(y==="last")k.reverse();else if(y==="prev"||y==="next"){y==="prev"&&k.reverse();const S=k.indexOf(m.currentTarget);k=f.loop?Jb(k,S+1):k.slice(S+1)}setTimeout(()=>Xp(k))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:b!=null}):a})})},"RovingFocusGroupItem")),XT={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qb(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Kr(qb,"getDirectionAwareKey");function Qb(e,t,n){const r=qb(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return XT[r]}Kr(Qb,"getFocusIntent");function Xp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Kr(Xp,"focusFirst");function Jb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Kr(Jb,"wrapArray");var Xb=YT,Zb=JT,ZT=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ti=new WeakMap,na=new WeakMap,sa={},dd=0,e0=function(e){return e&&(e.host||e0(e.parentNode))},eR=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=e0(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},tR=function(e,t,n,r){var i=eR(t,Array.isArray(e)?e:[e]);sa[n]||(sa[n]=new WeakMap);var o=sa[n],l=[],a=new Set,c=new Set(i),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};i.forEach(u);var p=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))p(h);else try{var x=h.getAttribute(r),j=x!==null&&x!=="false",w=(ti.get(h)||0)+1,b=(o.get(h)||0)+1;ti.set(h,w),o.set(h,b),l.push(h),w===1&&j&&na.set(h,!0),b===1&&h.setAttribute(n,"true"),j||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return p(t),a.clear(),dd++,function(){l.forEach(function(f){var h=ti.get(f)-1,x=o.get(f)-1;ti.set(f,h),o.set(f,x),h||(na.has(f)||f.removeAttribute(r),na.delete(f)),x||f.removeAttribute(n)}),dd--,dd||(ti=new WeakMap,ti=new WeakMap,na=new WeakMap,sa={})}},t0=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=ZT(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),tR(r,i,n,"aria-hidden")):function(){return null}},Jn=function(){return Jn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Jn.apply(this,arguments)};function n0(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[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])&&(n[r[i]]=e[r[i]]);return n}function nR(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var La="right-scroll-bar-position",Fa="width-before-scroll-bar",sR="with-scroll-bars-hidden",rR="--removed-body-scroll-bar-size";function fd(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function iR(e,t){var n=d.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var oR=typeof window<"u"?d.useLayoutEffect:d.useEffect,Zx=new WeakMap;function lR(e,t){var n=iR(null,function(r){return e.forEach(function(i){return fd(i,r)})});return oR(function(){var r=Zx.get(n);if(r){var i=new Set(r),o=new Set(e),l=n.current;i.forEach(function(a){o.has(a)||fd(a,null)}),o.forEach(function(a){i.has(a)||fd(a,l)})}Zx.set(n,e)},[e]),n}function aR(e){return e}function cR(e,t){t===void 0&&(t=aR);var n=[],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 n.length?n[n.length-1]:e},useMedium:function(o){var l=t(o,r);return n.push(l),function(){n=n.filter(function(a){return a!==l})}},assignSyncMedium:function(o){for(r=!0;n.length;){var l=n;n=[],l.forEach(o)}n={push:function(a){return o(a)},filter:function(){return n}}},assignMedium:function(o){r=!0;var l=[];if(n.length){var a=n;n=[],a.forEach(o),l=n}var c=function(){var p=l;l=[],p.forEach(o)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(p){l.push(p),u()},filter:function(p){return l=l.filter(p),n}}}};return i}function uR(e){e===void 0&&(e={});var t=cR(null);return t.options=Jn({async:!0,ssr:!1},e),t}var s0=function(e){var t=e.sideCar,n=n0(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,Jn({},n))};s0.isSideCarExport=!0;function dR(e,t){return e.useMedium(t),s0}var r0=uR(),hd=function(){},uu=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:hd,onWheelCapture:hd,onTouchMoveCapture:hd}),i=r[0],o=r[1],l=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,p=e.enabled,f=e.shards,h=e.sideCar,x=e.noRelative,j=e.noIsolation,w=e.inert,b=e.allowPinchZoom,v=e.as,m=v===void 0?"div":v,y=e.gapMode,g=n0(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,S=lR([n,t]),N=Jn(Jn({},g),i);return d.createElement(d.Fragment,null,p&&d.createElement(k,{sideCar:r0,removeScrollBar:u,shards:f,noRelative:x,noIsolation:j,inert:w,setCallbacks:o,allowPinchZoom:!!b,lockRef:n,gapMode:y}),l?d.cloneElement(d.Children.only(a),Jn(Jn({},N),{ref:S})):d.createElement(m,Jn({},N,{className:c,ref:S}),a))});uu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};uu.classNames={fullWidth:Fa,zeroRight:La};var fR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hR(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fR();return t&&e.setAttribute("nonce",t),e}function pR(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mR(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gR=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hR())&&(pR(t,n),mR(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xR=function(){var e=gR();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},i0=function(){var e=xR(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},vR={left:0,top:0,right:0,gap:0},pd=function(e){return parseInt(e||"",10)||0},jR=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[pd(n),pd(r),pd(i)]},yR=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vR;var t=jR(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},wR=i0(),Ei="data-scroll-locked",bR=function(e,t,n,r){var i=e.left,o=e.top,l=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
41
|
-
.`.concat(sR,` {
|
|
42
|
-
overflow: hidden `).concat(r,`;
|
|
43
|
-
padding-right: `).concat(a,"px ").concat(r,`;
|
|
44
|
-
}
|
|
45
|
-
body[`).concat(Ei,`] {
|
|
46
|
-
overflow: hidden `).concat(r,`;
|
|
47
|
-
overscroll-behavior: contain;
|
|
48
|
-
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
49
|
-
padding-left: `.concat(i,`px;
|
|
50
|
-
padding-top: `).concat(o,`px;
|
|
51
|
-
padding-right: `).concat(l,`px;
|
|
52
|
-
margin-left:0;
|
|
53
|
-
margin-top:0;
|
|
54
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
55
|
-
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.`).concat(La,` {
|
|
59
|
-
right: `).concat(a,"px ").concat(r,`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.`).concat(Fa,` {
|
|
63
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.`).concat(La," .").concat(La,` {
|
|
67
|
-
right: 0 `).concat(r,`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.`).concat(Fa," .").concat(Fa,` {
|
|
71
|
-
margin-right: 0 `).concat(r,`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
body[`).concat(Ei,`] {
|
|
75
|
-
`).concat(rR,": ").concat(a,`px;
|
|
76
|
-
}
|
|
77
|
-
`)},ev=function(){var e=parseInt(document.body.getAttribute(Ei)||"0",10);return isFinite(e)?e:0},kR=function(){d.useEffect(function(){return document.body.setAttribute(Ei,(ev()+1).toString()),function(){var e=ev()-1;e<=0?document.body.removeAttribute(Ei):document.body.setAttribute(Ei,e.toString())}},[])},SR=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;kR();var o=d.useMemo(function(){return yR(i)},[i]);return d.createElement(wR,{styles:bR(o,!t,i,n?"":"!important")})},eh=!1;if(typeof window<"u")try{var ra=Object.defineProperty({},"passive",{get:function(){return eh=!0,!0}});window.addEventListener("test",ra,ra),window.removeEventListener("test",ra,ra)}catch{eh=!1}var ni=eh?{passive:!1}:!1,NR=function(e){return e.tagName==="TEXTAREA"},o0=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!NR(e)&&n[t]==="visible")},CR=function(e){return o0(e,"overflowY")},ER=function(e){return o0(e,"overflowX")},tv=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=l0(e,r);if(i){var o=a0(e,r),l=o[1],a=o[2];if(l>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},AR=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},TR=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},l0=function(e,t){return e==="v"?CR(t):ER(t)},a0=function(e,t){return e==="v"?AR(t):TR(t)},RR=function(e,t){return e==="h"&&t==="rtl"?-1:1},PR=function(e,t,n,r,i){var o=RR(e,window.getComputedStyle(t).direction),l=o*r,a=n.target,c=t.contains(a),u=!1,p=l>0,f=0,h=0;do{if(!a)break;var x=a0(e,a),j=x[0],w=x[1],b=x[2],v=w-b-o*j;(j||v)&&l0(e,a)&&(f+=v,h+=j);var m=a.parentNode;a=m&&m.nodeType===Node.DOCUMENT_FRAGMENT_NODE?m.host:m}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(p&&Math.abs(f)<1||!p&&Math.abs(h)<1)&&(u=!0),u},ia=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nv=function(e){return[e.deltaX,e.deltaY]},sv=function(e){return e&&"current"in e?e.current:e},IR=function(e,t){return e[0]===t[0]&&e[1]===t[1]},MR=function(e){return`
|
|
78
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
79
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
80
|
-
`)},$R=0,si=[];function _R(e){var t=d.useRef([]),n=d.useRef([0,0]),r=d.useRef(),i=d.useState($R++)[0],o=d.useState(i0)[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 w=nR([e.lockRef.current],(e.shards||[]).map(sv),!0).filter(Boolean);return w.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=d.useCallback(function(w,b){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var v=ia(w),m=n.current,y="deltaX"in w?w.deltaX:m[0]-v[0],g="deltaY"in w?w.deltaY:m[1]-v[1],k,S=w.target,N=Math.abs(y)>Math.abs(g)?"h":"v";if("touches"in w&&N==="h"&&S.type==="range")return!1;var C=window.getSelection(),P=C&&C.anchorNode,E=P?P===S||P.contains(S):!1;if(E)return!1;var O=tv(N,S);if(!O)return!0;if(O?k=N:(k=N==="v"?"h":"v",O=tv(N,S)),!O)return!1;if(!r.current&&"changedTouches"in w&&(y||g)&&(r.current=k),!k)return!0;var L=r.current||k;return PR(L,b,w,L==="h"?y:g)},[]),c=d.useCallback(function(w){var b=w;if(!(!si.length||si[si.length-1]!==o)){var v="deltaY"in b?nv(b):ia(b),m=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&IR(k.delta,v)})[0];if(m&&m.should){b.cancelable&&b.preventDefault();return}if(!m){var y=(l.current.shards||[]).map(sv).filter(Boolean).filter(function(k){return k.contains(b.target)}),g=y.length>0?a(b,y[0]):!l.current.noIsolation;g&&b.cancelable&&b.preventDefault()}}},[]),u=d.useCallback(function(w,b,v,m){var y={name:w,delta:b,target:v,should:m,shadowParent:OR(v)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(g){return g!==y})},1)},[]),p=d.useCallback(function(w){n.current=ia(w),r.current=void 0},[]),f=d.useCallback(function(w){u(w.type,nv(w),w.target,a(w,e.lockRef.current))},[]),h=d.useCallback(function(w){u(w.type,ia(w),w.target,a(w,e.lockRef.current))},[]);d.useEffect(function(){return si.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,ni),document.addEventListener("touchmove",c,ni),document.addEventListener("touchstart",p,ni),function(){si=si.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,ni),document.removeEventListener("touchmove",c,ni),document.removeEventListener("touchstart",p,ni)}},[]);var x=e.removeScrollBar,j=e.inert;return d.createElement(d.Fragment,null,j?d.createElement(o,{styles:MR(i)}):null,x?d.createElement(SR,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function OR(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const DR=dR(r0,_R);var Zp=d.forwardRef(function(e,t){return d.createElement(uu,Jn({},e,{ref:t,sideCar:DR}))});Zp.classNames=uu.classNames;var LR=Object.defineProperty,Ie=(e,t)=>LR(e,"name",{value:t,configurable:!0}),FR=["Enter"," "],zR=["ArrowDown","PageUp","Home"],c0=["ArrowUp","PageDown","End"],UR=[...zR,...c0],du="Menu",[th,BR,WR]=Jc(du),[Gr,u0]=Bn(du,[WR,ru,cu]),em=ru(),d0=cu(),[HR,wl]=Gr(du),[VR,tm]=Gr(du),KR=Ie(e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:l=!0}=e,a=em(t),[c,u]=d.useState(null),p=d.useRef(!1),f=zn(o),h=ou(i);return d.useEffect(()=>{const x=Ie(()=>{p.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},"handleKeyDown"),j=Ie(()=>p.current=!1,"handlePointer");return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),d.useEffect(()=>{if(!n)return;const x=Ie(()=>f(!1),"handleBlur");return window.addEventListener("blur",x),()=>window.removeEventListener("blur",x)},[n,f]),s.jsx(Sb,{...a,children:s.jsx(HR,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:s.jsx(VR,{scope:t,onClose:d.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:h,modal:l,children:r})})})},"Menu"),GR=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,...i}=t,o=em(r);return s.jsx(Nb,{...o,...i,ref:n})},"MenuAnchor")),f0="MenuPortal",[YR,qR]=Gr(f0,{forceMount:void 0}),QR=Ie(e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=wl(f0,t);return s.jsx(YR,{scope:t,forceMount:n,children:s.jsx(pr,{present:n||o.open,children:s.jsx(Fp,{asChild:!0,container:i,children:r})})})},"MenuPortal"),nr="MenuContent",[JR,h0]=Gr(nr),XR=d.forwardRef(Ie(function(t,n){const r=qR(nr,t.__scopeMenu),{forceMount:i=r.forceMount,...o}=t,l=wl(nr,t.__scopeMenu),a=tm(nr,t.__scopeMenu);return s.jsx(th.Provider,{scope:t.__scopeMenu,children:s.jsx(pr,{present:i||l.open,children:s.jsx(th.Slot,{scope:t.__scopeMenu,children:a.modal?s.jsx(ZR,{...o,ref:n}):s.jsx(eP,{...o,ref:n})})})})},"MenuContent")),ZR=d.forwardRef(Ie(function(t,n){const r=wl(nr,t.__scopeMenu),i=d.useRef(null),o=qe(n,i);return d.useEffect(()=>{const l=i.current;if(l)return t0(l)},[]),s.jsx(p0,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:we(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentModal")),eP=d.forwardRef(Ie(function(t,n){const r=wl(nr,t.__scopeMenu);return s.jsx(p0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})},"MenuRootContentNonModal")),tP=or("MenuContent.ScrollLock"),p0=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,loop:i=!1,trapFocus:o,onOpenAutoFocus:l,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:p,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:x,onDismiss:j,disableOutsideScroll:w,...b}=t,v=wl(nr,r),m=tm(nr,r),y=em(r),g=d0(r),k=BR(r),[S,N]=d.useState(null),C=d.useRef(null),P=qe(n,C,v.onContentChange),E=d.useRef(0),O=d.useRef(""),L=d.useRef(0),D=d.useRef(null),T=d.useRef("right"),z=d.useRef(0),q=w?Zp:d.Fragment,K=w?{as:tP,allowPinchZoom:!0}:void 0,M=Ie(_=>{var Ve,he;const U=O.current+_,X=k().filter(ge=>!ge.disabled),Z=document.activeElement,ue=(Ve=X.find(ge=>ge.ref.current===Z))==null?void 0:Ve.textValue,je=X.map(ge=>ge.textValue),Ce=b0(je,U,ue),Pe=(he=X.find(ge=>ge.textValue===Ce))==null?void 0:he.ref.current;Ie(function ge(ye){O.current=ye,window.clearTimeout(E.current),ye!==""&&(E.current=window.setTimeout(()=>ge(""),1e3))},"updateSearch")(U),Pe&&setTimeout(()=>Pe.focus())},"handleTypeaheadSearch");d.useEffect(()=>()=>window.clearTimeout(E.current),[]),lu();const W=d.useCallback(_=>{var X,Z;return T.current===((X=D.current)==null?void 0:X.side)&&S0(_,(Z=D.current)==null?void 0:Z.area)},[]);return s.jsx(JR,{scope:r,searchRef:O,onItemEnter:d.useCallback(_=>{W(_)&&_.preventDefault()},[W]),onItemLeave:d.useCallback(_=>{var U;W(_)||((U=C.current)==null||U.focus(),N(null))},[W]),onTriggerLeave:d.useCallback(_=>{W(_)&&_.preventDefault()},[W]),pointerGraceTimerRef:L,onPointerGraceIntentChange:d.useCallback(_=>{D.current=_},[]),children:s.jsx(q,{...K,children:s.jsx(Db,{asChild:!0,trapped:o,onMountAutoFocus:we(l,_=>{var U;_.preventDefault(),(U=C.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:s.jsx(Dp,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:p,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:x,onDismiss:j,children:s.jsx(Xb,{asChild:!0,...g,dir:m.dir,orientation:"vertical",loop:i,currentTabStopId:S,onCurrentTabStopIdChange:N,onEntryFocus:we(u,_=>{m.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Cb,{role:"menu","aria-orientation":"vertical","data-state":x0(v.open),"data-radix-menu-content":"",dir:m.dir,...y,...b,ref:P,style:{outline:"none",...b.style},onKeyDown:we(b.onKeyDown,_=>{const X=_.target.closest("[data-radix-menu-content]")===_.currentTarget,Z=_.ctrlKey||_.altKey||_.metaKey,ue=_.key.length===1;X&&(_.key==="Tab"&&_.preventDefault(),!Z&&ue&&M(_.key));const je=C.current;if(_.target!==je||!UR.includes(_.key))return;_.preventDefault();const Pe=k().filter(Ve=>!Ve.disabled).map(Ve=>Ve.ref.current);c0.includes(_.key)&&Pe.reverse(),y0(Pe)}),onBlur:we(t.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(E.current),O.current="")}),onPointerMove:we(t.onPointerMove,Nc(_=>{const U=_.target,X=z.current!==_.clientX;if(_.currentTarget.contains(U)&&X){const Z=_.clientX>z.current?"right":"left";T.current=Z,z.current=_.clientX}}))})})})})})})},"MenuContentImpl")),m0=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Je.div,{role:"group",...i,ref:n})},"MenuGroup")),nP=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Je.div,{...i,ref:n})},"MenuLabel")),nh="MenuItem",rv="menu.itemSelect",g0=d.forwardRef(Ie(function(t,n){const{disabled:r=!1,onSelect:i,...o}=t,l=d.useRef(null),a=tm(nh,t.__scopeMenu),c=h0(nh,t.__scopeMenu),u=qe(n,l),p=d.useRef(!1),f=Ie(()=>{const h=l.current;if(!r&&h){const x=new CustomEvent(rv,{bubbles:!0,cancelable:!0});h.addEventListener(rv,j=>i==null?void 0:i(j),{once:!0}),Xc(h,x),x.defaultPrevented?p.current=!1:a.onClose()}},"handleSelect");return s.jsx(sP,{...o,ref:u,disabled:r,onClick:we(t.onClick,f),onPointerDown:h=>{var x;(x=t.onPointerDown)==null||x.call(t,h),p.current=!0},onPointerUp:we(t.onPointerUp,h=>{var x;p.current||(x=h.currentTarget)==null||x.click()}),onKeyDown:we(t.onKeyDown,h=>{r||h.target!==h.currentTarget||c.searchRef.current!==""&&h.key===" "||FR.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})},"MenuItem")),sP=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,disabled:i=!1,textValue:o,...l}=t,a=h0(nh,r),c=d0(r),u=d.useRef(null),p=qe(n,u),[f,h]=d.useState(!1),[x,j]=d.useState("");return d.useEffect(()=>{const w=u.current;w&&j((w.textContent??"").trim())},[l.children]),s.jsx(th.ItemSlot,{scope:r,disabled:i,textValue:o??x,children:s.jsx(Zb,{asChild:!0,...c,focusable:!i,children:s.jsx(Je.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...l,ref:p,onPointerMove:we(t.onPointerMove,Nc(w=>{i?a.onItemLeave(w):(a.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:we(t.onPointerLeave,Nc(w=>a.onItemLeave(w))),onFocus:we(t.onFocus,()=>h(!0)),onBlur:we(t.onBlur,()=>h(!1))})})})},"MenuItemImpl")),rP="MenuRadioGroup",[iP,oP]=Gr(rP,{value:void 0,onValueChange:Ie(()=>{},"onValueChange")}),lP=d.forwardRef(Ie(function(t,n){const{value:r,onValueChange:i,...o}=t,l=zn(i);return s.jsx(iP,{scope:t.__scopeMenu,value:r,onValueChange:l,children:s.jsx(m0,{...o,ref:n})})},"MenuRadioGroup")),aP="MenuRadioItem",cP=d.forwardRef(Ie(function(t,n){const{value:r,...i}=t,o=oP(aP,t.__scopeMenu),l=r===o.value;return s.jsx(dP,{scope:t.__scopeMenu,checked:l,children:s.jsx(g0,{role:"menuitemradio","aria-checked":l,...i,ref:n,"data-state":j0(l),onSelect:we(i.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,r)},{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),uP="MenuItemIndicator",[dP,o6]=Gr(uP,{checked:!1}),fP=d.forwardRef(Ie(function(t,n){const{__scopeMenu:r,...i}=t;return s.jsx(Je.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})},"MenuSeparator")),hP="MenuSub",[l6,a6]=Gr(hP);function x0(e){return e?"open":"closed"}Ie(x0,"getOpenState");function v0(e){return e==="indeterminate"}Ie(v0,"isIndeterminate");function j0(e){return v0(e)?"indeterminate":e?"checked":"unchecked"}Ie(j0,"getCheckedState");function y0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Ie(y0,"focusFirst");function w0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Ie(w0,"wrapArray");function b0(e,t,n){const i=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let l=w0(e,Math.max(o,0));i.length===1&&(l=l.filter(u=>u!==n));const c=l.find(u=>u.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}Ie(b0,"getNextMatch");function k0(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,l=t.length-1;o<t.length;l=o++){const a=t[o],c=t[l],u=a.x,p=a.y,f=c.x,h=c.y;p>r!=h>r&&n<(f-u)*(r-p)/(h-p)+u&&(i=!i)}return i}Ie(k0,"isPointInPolygon");function S0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return k0(n,t)}Ie(S0,"isPointerInGraceArea");function Nc(e){return t=>t.pointerType==="mouse"?e(t):void 0}Ie(Nc,"whenMouse");var pP=KR,mP=GR,gP=QR,xP=XR,vP=m0,jP=nP,yP=g0,wP=lP,bP=cP,kP=fP,SP=Object.defineProperty,os=(e,t)=>SP(e,"name",{value:t,configurable:!0}),nm="DropdownMenu",[NP,c6]=Bn(nm,[u0]),ls=u0(),[CP,N0]=NP(nm),EP=os(e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:l,modal:a=!0}=e,c=ls(t),u=d.useRef(null),[p,f]=Zi({prop:i,defaultProp:o??!1,onChange:l,caller:nm});return s.jsx(CP,{scope:t,triggerId:js(),triggerRef:u,contentId:js(),open:p,onOpenChange:f,onOpenToggle:d.useCallback(()=>f(h=>!h),[f]),modal:a,children:s.jsx(pP,{...c,open:p,onOpenChange:f,dir:r,modal:a,children:n})})},"DropdownMenu"),AP="DropdownMenuTrigger",TP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,disabled:i=!1,...o}=t,l=N0(AP,r),a=ls(r),c=qe(n,l.triggerRef);return s.jsx(mP,{asChild:!0,...a,children:s.jsx(Je.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,...o,ref:c,onPointerDown:we(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(l.onOpenToggle(),l.open||u.preventDefault())}),onKeyDown:we(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&l.onOpenToggle(),u.key==="ArrowDown"&&l.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})},"DropdownMenuTrigger")),RP=os(e=>{const{__scopeDropdownMenu:t,...n}=e,r=ls(t);return s.jsx(gP,{...r,...n})},"DropdownMenuPortal"),PP="DropdownMenuContent",IP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=N0(PP,r),l=ls(r),a=d.useRef(!1);return s.jsx(xP,{id:o.contentId,"aria-labelledby":o.triggerId,...l,...i,ref:n,onCloseAutoFocus:we(t.onCloseAutoFocus,c=>{var u;a.current||(u=o.triggerRef.current)==null||u.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:we(t.onInteractOutside,c=>{const u=c.detail.originalEvent,p=u.button===0&&u.ctrlKey===!0,f=u.button===2||p;(!o.modal||f)&&(a.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")),MP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(vP,{...o,...i,ref:n})},"DropdownMenuGroup")),$P=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(jP,{...o,...i,ref:n})},"DropdownMenuLabel")),_P=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(yP,{...o,...i,ref:n})},"DropdownMenuItem")),OP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(wP,{...o,...i,ref:n})},"DropdownMenuRadioGroup")),DP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(bP,{...o,...i,ref:n})},"DropdownMenuRadioItem")),LP=d.forwardRef(os(function(t,n){const{__scopeDropdownMenu:r,...i}=t,o=ls(r);return s.jsx(kP,{...o,...i,ref:n})},"DropdownMenuSeparator")),sm=EP,rm=TP,im=RP,om=IP,FP=MP,lm=$P,sh=_P,zP=OP,UP=DP,za=LP,BP=Object.defineProperty,so=(e,t)=>BP(e,"name",{value:t,configurable:!0}),am="Tabs",[WP,u6]=Bn(am,[cu]),C0=cu(),[HP,cm]=WP(am),VP=d.forwardRef(so(function(t,n){const{__scopeTabs:r,value:i,onValueChange:o,defaultValue:l,orientation:a="horizontal",dir:c,activationMode:u="automatic",...p}=t,f=ou(c),[h,x]=Zi({prop:i,onChange:o,defaultProp:l??"",caller:am});return s.jsx(HP,{scope:r,baseId:js(),value:h,onValueChange:x,orientation:a,dir:f,activationMode:u,children:s.jsx(Je.div,{dir:f,"data-orientation":a,...p,ref:n})})},"Tabs")),KP="TabsList",GP=d.forwardRef(so(function(t,n){const{__scopeTabs:r,loop:i=!0,...o}=t,l=cm(KP,r),a=C0(r);return s.jsx(Xb,{asChild:!0,...a,orientation:l.orientation,dir:l.dir,loop:i,children:s.jsx(Je.div,{role:"tablist","aria-orientation":l.orientation,...o,ref:n})})},"TabsList")),YP="TabsTrigger",qP=d.forwardRef(so(function(t,n){const{__scopeTabs:r,value:i,disabled:o=!1,...l}=t,a=cm(YP,r),c=C0(r),u=um(a.baseId,i),p=dm(a.baseId,i),f=i===a.value;return s.jsx(Zb,{asChild:!0,...c,focusable:!o,active:f,children:s.jsx(Je.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":p,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...l,ref:n,onMouseDown:we(t.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(i):h.preventDefault()}),onKeyDown:we(t.onKeyDown,h=>{o||h.target!==h.currentTarget||[" ","Enter"].includes(h.key)&&a.onValueChange(i)}),onFocus:we(t.onFocus,()=>{const h=a.activationMode!=="manual";!f&&!o&&h&&a.onValueChange(i)})})})},"TabsTrigger")),QP="TabsContent",JP=d.forwardRef(so(function(t,n){const{__scopeTabs:r,value:i,forceMount:o,children:l,...a}=t,c=cm(QP,r),u=um(c.baseId,i),p=dm(c.baseId,i),f=i===c.value,h=d.useRef(f);return d.useEffect(()=>{const x=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(x)},[]),s.jsx(pr,{present:o||f,children:({present:x})=>s.jsx(Je.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!x,id:p,tabIndex:0,...a,ref:n,style:{...t.style,animationDuration:h.current?"0s":void 0},children:x&&l})})},"TabsContent"));function um(e,t){return`${e}-trigger-${t}`}so(um,"makeTriggerId");function dm(e,t){return`${e}-content-${t}`}so(dm,"makeContentId");var XP=VP,ZP=GP,e2=qP,t2=JP;function Re(e,t){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat("en-GB",{timeZone:t,year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(n)}function Se(e,t=Date.now()){if(!e)return"";const n=new Date(e).getTime();if(Number.isNaN(n))return"";const r=Math.round((n-t)/1e3),i=Math.abs(r),[o,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(o,l)}function n2(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 Lt(e){return new Intl.NumberFormat("en-US").format(e)}function on(e){try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}function al(e,t=8){return e.length<=t?e:e.slice(0,t)}function As(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Li(e){return e.replace(/<<<[^<>]*>>>/g,"")}function jt(e,t,n){if(e==null)return"—";switch(t){case"currency":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?s2(r,n):String(e)}case"percent":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?`${ov(r)}%`:String(e)}case"number":{const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?Number.isInteger(r)?Lt(r):ov(r):String(e)}case"date":return r2(String(e));default:return typeof e=="string"?e:typeof e=="number"?Lt(e):typeof e=="boolean"?e?"yes":"no":JSON.stringify(e)??String(e)}}function s2(e,t){if(!(Math.abs(e)<1e3&&!Number.isInteger(e)))return n2(e,t);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t??"USD",maximumFractionDigits:2}).format(e)}catch{return e.toFixed(2)}}function r2(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short",year:"numeric"}).format(n)}function iv(e){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);if(!t)return e;const n=new Date(`${t[0]}T00:00:00Z`);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat("en-GB",{timeZone:"UTC",day:"numeric",month:"short"}).format(n)}function ov(e){return String(Math.round(e*100)/100)}function i2(e,t,n=4){if(!Number.isFinite(e)||!Number.isFinite(t))return[];if(e===t)return[e];const r=(t-e)/Math.max(1,n),i=10**Math.floor(Math.log10(r)),o=[1,2,2.5,5,10].map(a=>a*i).find(a=>a>=r)??i*10,l=[];for(let a=Math.ceil(e/o)*o;a<=t+o/1e3;a+=o)l.push(Math.round(a*1e6)/1e6);return l.filter(a=>a>=e&&a<=t)}function o2({props:e}){if(e.bars.length===0)return s.jsx("p",{className:"wb-empty",children:"No categories came back."});const t=e.bars.map(o=>o.value),n=Math.max(0,...t),r=Math.min(0,...t),i=n-r||1;return s.jsx("div",{className:"wb-bars",children:e.bars.map(o=>{const l=Math.abs(o.value)/i;return s.jsxs("div",{className:"wb-bar-row",children:[s.jsx("div",{className:"wb-bar-cat",title:o.category,children:o.category}),s.jsx("div",{className:"wb-bar-track",children:s.jsx("div",{className:"wb-bar-fill",style:{width:`${Math.max(1,l*100)}%`,background:o.value<0?"var(--chart-bar-negative)":"var(--chart-bar)"}})}),s.jsx("div",{className:"wb-bar-val",children:jt(o.value,e.unit,e.currency)})]},o.category)})})}const l2=/^(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 )/,a2=/^(… |\.\.\. |\(no change\)$|\)/;function c2(e){return e.replace(/\n$/,"").split(`
|
|
81
|
-
`).map(n=>({kind:u2(n),text:n}))}function u2(e){return e.startsWith("@@")?"hunk":l2.test(e)||a2.test(e)?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"context"}function d2({text:e,marks:t}){const n=e.toLowerCase(),r=[];for(const l of t){const a=l.trim().toLowerCase();if(a!=="")for(let c=n.indexOf(a);c!==-1;c=n.indexOf(a,c+a.length))r.push([c,c+a.length])}if(r.length===0)return s.jsx(s.Fragment,{children:e===""?" ":e});r.sort((l,a)=>l[0]-a[0]);const i=[];let o=0;for(const[l,a]of r)l<o||(l>o&&i.push(s.jsx("span",{children:e.slice(o,l)},`t${o}`)),i.push(s.jsx("mark",{className:"wb-diff-mark",children:e.slice(l,a)},`m${l}`)),o=a);return o<e.length&&i.push(s.jsx("span",{children:e.slice(o)},`t${o}`)),s.jsx(s.Fragment,{children:i})}function Cc({text:e,limit:t,more:n,label:r="Diff",marks:i}){const o=c2(e),l=t===void 0?o:o.slice(0,t),a=o.length-l.length;return s.jsxs("div",{className:"wb-diff-wrap",children:[s.jsx("pre",{className:"wb-diff","aria-label":r,"data-testid":"diff",children:l.map((c,u)=>s.jsx("span",{className:"wb-diff-line","data-kind":c.kind,children:i&&i.length>0?s.jsx(d2,{text:c.text,marks:i}):c.text===""?" ":c.text},u))}),a>0?s.jsxs("p",{className:"wb-diff-more",children:[a," more line",a===1?"":"s",n?s.jsxs(s.Fragment,{children:[" · ",s.jsx("button",{type:"button",className:"wb-diff-open",onClick:n.onClick,children:n.label})]}):null]}):null]})}function f2({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title mono",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:jt(t.value,t.unit,null)})]},t.label))}):null,e.diff?s.jsx(Cc,{text:e.diff,label:e.title?`Diff of ${e.title}`:"Diff"}):s.jsx("p",{className:"wb-empty",children:"This change came back with no diff."})]})}const Vt="#/",Fi="#/chat",et="#/agents",Ze="#/activity",Jt="#/settings",Lr="#/files",h2="#/welcome";function lv(e){const t=/^#\/welcome(?:\?(.*))?$/.exec(e);if(!t)return null;try{return{step:new URLSearchParams(t[1]??"").get("step")}}catch{return{step:null}}}function oa(e,t={}){const n=new URLSearchParams;t.q&&n.set("q",t.q),t.origin&&n.set("origin",t.origin),t.family&&n.set("family",t.family);const r=n.toString();return`${Lr}${e?`/${encodeURIComponent(e)}`:""}${r?`?${r}`:""}`}function p2(e){const t=/^#\/files(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[2]??""),r={};return n.get("q")&&(r.q=n.get("q")),n.get("origin")&&(r.origin=n.get("origin")),n.get("family")&&(r.family=n.get("family")),{...t[1]?{artifactId:decodeURIComponent(t[1])}:{},filters:r}}catch{return null}}function ze(e,t,n){return`#/chat/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function m2(e){if(E0(e))return null;const t=/^#\/chat\/([^/?]+)(?:\/([^/?]+))?(?:\?(.*))?$/.exec(e);if(!t)return null;try{const n=new URLSearchParams(t[3]??"").get("tab");return{agentId:decodeURIComponent(t[1]),...t[2]?{conversationId:decodeURIComponent(t[2])}:{},...n?{tab:n}:{}}}catch{return null}}function Fo(e,t){return`#/chat/g/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:""}`}function E0(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 ft(e,t,n){return`${et}/${encodeURIComponent(e)}${t?`/${t}${n?`/${n}`:""}`:""}`}function g2(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 zi(e){return`${Ze}/conversations/${encodeURIComponent(e)}`}const x2="#/p";function cl(e,t,n){const r=`${x2}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;return n?`${r}/${encodeURIComponent(n)}`:r}function fm(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 v2="p.";function hm(e,t){return`${Jt}/${encodeURIComponent(A0(e,t))}`}function j2(e){const t=/^#\/settings\/p\.([^/?.]+)(?:\.([^/?.]+))?(?:\?.*)?$/.exec(e);if(!t)return null;const n=decodeURIComponent(t[1]);return{plugin:n,page:t[2]?decodeURIComponent(t[2]):n}}function A0(e,t){return`${v2}${e}${t===e?"":`.${t}`}`}function st(e){return e?`${Jt}/${e}`:Jt}function y2(e){return`${st("proposals")}${e?`?plugin=${encodeURIComponent(e)}`:""}`}function w2(e){const t=/^#\/settings\/proposals\?(.*)$/.exec(e);if(!t)return null;try{return new URLSearchParams(t[1]).get("plugin")||null}catch{return null}}const b2=[{route:Vt,label:"Home"},{route:Fi,label:"Chat"},{route:et,label:"Agents"},{route:Ze,label:"Activity"},{route:Lr,label:"Files"},{route:Jt,label:"Settings"}],k2=[{id:"you",label:"You"},{id:"access",label:"Models and access"},{id:"running",label:"Running"},{id:"plugins",label:"Plugins"}],S2=[{id:"you",label:"Profile",group:"you"},{id:"appearance",label:"Appearance",group:"you"},{id:"notifications",label:"Notifications",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:"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 N2(e){var t;return((t=/^#\/settings\/([a-z0-9.-]+)/.exec(e))==null?void 0:t[1])??"you"}const av=st("backup");function C2(e){const t=/^#\/conversations\/(.+)$/.exec(e);if(t)return zi(decodeURIComponent(t[1]));const n=/^#\/email(?:\/([^/?]+))?(?:\?.*)?$/.exec(e);if(n)try{return cl("email","mail",n[1]?decodeURIComponent(n[1]):null)}catch{return cl("email","mail")}return e==="#/settings/email"?hm("email","settings"):{"#/overview":Vt,"#/approvals":Vt,"#/events":`${Ze}/events`,"#/jobs":`${Ze}/jobs`,"#/conversations":Ze,"#/missions":`${et}?tab=missions`,"#/offers":`${et}?tab=offers`,"#/reminders":`${et}?tab=reminders`,"#/providers":st("accounts"),"#/browser":st("computer"),"#/sentinels":st("watchers"),"#/settings/sentinels":st("watchers")}[e]??null}function E2(e){if(e===""||e==="#"||e===Vt)return Vt;if(e.startsWith(Fi))return Fi;if(e.startsWith(et))return et;if(e.startsWith(Ze))return Ze;if(e.startsWith(Lr))return Lr;if(e.startsWith(Jt))return Jt;const t=fm(e);return t?cl(t.plugin,t.page):Vt}const pm="front-desk",mm=[{id:pm,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."}],T0=new Set(mm.map(e=>e.id)),cv=e=>T0.has(e);function uv(e,t){const n=t.filter(r=>!T0.has(r));return[...mm.filter(r=>e.has(r.id)).map(r=>r.id),...n.filter((r,i)=>n.indexOf(r)===i)]}function A2(e,t){return e.find(n=>(n.roles??[]).includes(t))}const dv=["coding","finance","mail","research","calendar","files","memory"],T2={developer:"coding",coding:"coding",finance:"finance",credit:"finance",mail:"mail",email:"mail",research:"research",calendar:"calendar",files:"files",memory:"memory",[pm]:"buddi"},R2=[["mail",["email"]],["finance",["finance"]],["coding",["developer"]],["research",["web","browser"]],["art",["image"]]];function P2(e){const t=new Set(e.map(n=>n.split(".")[0]??n));for(const[n,r]of R2)if(r.some(i=>t.has(i)))return n;return t.size>0&&[...t].every(n=>n==="memory")?"memory":null}let rh=null;function I2(e){rh=e}function bl(e){if(e.accent&&/^#[0-9a-fA-F]{6}$/.test(e.accent))return{key:"own",hex:e.accent.toLowerCase()};for(const n of e.roles??[]){const r=T2[n];if(r)return{key:r}}const t=P2(e.tools??[]);return t?{key:t}:rh!==null&&e.id===rh?{key:"buddi"}:{key:dv[M2(e.id)%dv.length]??"coding"}}function kl(e){return e.key==="own"?{"data-agent":"own",style:{"--agent-fill":e.hex}}:{"data-agent":e.key}}function M2(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t}const $2=["run.started","tool.called","tool.result","message.appended","awaiting-approval","run.finished","live","live.settle","live.snapshot","attention","ping"];function _2(e){const n=e.replace(/\r\n/g,`
|
|
82
|
-
`).split(`
|
|
83
|
-
|
|
84
|
-
`),r=n.pop()??"",i=[];for(const o of n){let l=null,a="message";const c=[];for(const u of o.split(`
|
|
85
|
-
`)){if(u===""||u.startsWith(":"))continue;const p=u.indexOf(":"),f=p===-1?u:u.slice(0,p),h=p===-1?"":u.slice(p+1).replace(/^ /,"");f==="id"?l=h:f==="event"?a=h:f==="data"&&c.push(h)}c.length===0&&a==="message"||i.push({id:l,name:$2.includes(a)?a:"ping",data:O2(c.join(`
|
|
86
|
-
`))})}return{events:i,rest:r}}function O2(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"?t:{value:t}}catch{return{value:e}}}function R0(e){const t=e.fetchImpl??globalThis.fetch.bind(globalThis),n=e.wait??(c=>new Promise(u=>setTimeout(u,c))),r=e.retryMs??1500;let i=e.lastEventId??null,o=!1,l=null;return(async()=>{var c,u,p,f;for(;!o;){(c=e.onStatus)==null||c.call(e,"connecting"),l=new AbortController;try{const h=await t(e.url,{credentials:"same-origin",signal:l.signal,headers:{Accept:"text/event-stream",...i===null?{}:{"Last-Event-ID":i}}});if(!h.ok||!h.body)throw new Error(`stream ${h.status}`);(u=e.onStatus)==null||u.call(e,"open");const x=h.body.getReader(),j=new TextDecoder;let w="";for(;;){const{done:b,value:v}=await x.read();if(b)break;w+=j.decode(v,{stream:!0});const{events:m,rest:y}=_2(w);w=y;for(const g of m)e.onEvent(g),g.id!==null&&(i=g.id);if(o)break}}catch{}if(o)break;(p=e.onStatus)==null||p.call(e,"closed"),await n(r)}(f=e.onStatus)==null||f.call(e,"closed")})(),{close:()=>{o=!0,l==null||l.abort()},lastEventId:()=>i}}const D2="/api/chat/attention/stream";function P0(e,t){const n=(o,l)=>o.name.localeCompare(l.name),r=o=>e.filter(l=>l.anchor===o).sort(n),i=e.filter(o=>o.anchor!=="top"&&o.anchor!=="bottom").sort((o,l)=>o.id===t?l.id===t?0:-1:l.id===t?1:n(o,l));return{top:r("top"),middle:i,bottom:r("bottom")}}function I0(e,t){const n=P0(e,t);return[...n.top,...n.middle,...n.bottom]}function fu(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 L2(e){return e?e.approvals>0?{count:e.approvals}:e.question?{count:null}:null:null}function F2(e){return new Map(((e==null?void 0:e.agents)??[]).map(t=>[t.agentId,t]))}function z2(){const[e,t]=d.useState(null);return d.useEffect(()=>{let n=!1;const r=()=>{le("/chat/attention").then(o=>{n||t(o)}).catch(()=>{})};r();const i=R0({url:D2,onEvent:()=>r()});return()=>{n=!0,i.close()}},[]),F2(e)}const gm="maker";function M0(e){return e.filter(t=>t.available&&!t.roles.includes(gm))}function $0(e){return M0(e).length>=2}function U2(e){var t;return((t=e.find(n=>n.roles.includes(gm)))==null?void 0:t.name)??"the agent maker"}const B2="{{default}}";function W2(e,t){return e.split(B2).join(t??"your assistant")}function H2(e,t){return((e==null?void 0:e.starters)??[]).slice(0,3).map(n=>W2(n,t))}function V2(e){var n,r;const t=(n=e==null?void 0:e.intro)==null?void 0:n.trim();return t&&t!==""?t:((r=e==null?void 0:e.description)==null?void 0:r.trim())??""}function K2(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 _0(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 n=(i=e.unavailableReason)==null?void 0:i.trim();return n&&n!==""?`${e.name??"This agent"} cannot run: ${n}`:`${e.name??"This agent"} cannot run: it has no model account yet.`}const G2="Settings → Model accounts",Y2="Install it in Settings → Plugins";function ih(e){return e!=null&&e.heldBack?{section:"plugins",label:Y2}:{section:"accounts",label:G2}}const q2={home:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3.5 9.2 10 3.6l6.5 5.6"}),s.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,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M7 8.3h6M7 11.3h3.6"})]})],agents:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"7.5",cy:"7",r:"2.8"}),s.jsx("path",{d:"M2.8 16.2a4.7 4.7 0 0 1 9.4 0"}),s.jsx("circle",{cx:"14",cy:"7.8",r:"2.2"}),s.jsx("path",{d:"M13.2 12.5a3.9 3.9 0 0 1 4.3 3.7"})]})],activity:[20,1.6,s.jsx("path",{d:"M2.8 10.5h3.4l2-5.2 3.4 9.8 2.2-4.6h3.4"})],settings:[24,1.9,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),20],files:[20,1.6,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M12.7 2.8v3.8h3.8"}),s.jsx("path",{d:"M4.4 6.2v9.4a1.6 1.6 0 0 0 1.6 1.6h6.6"})]})],mail:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"5",width:"14",height:"10.5",rx:"1.4"}),s.jsx("path",{d:"M3.4 6 10 11l6.6-5"})]})],money:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"5.2",width:"14.8",height:"9.6",rx:"1.6"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.2"}),s.jsx("path",{d:"M5.4 10h.5M14.1 10h.5"})]})],calendar:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4.4",width:"14",height:"12.2",rx:"1.6"}),s.jsx("path",{d:"M3 8.2h14M6.8 2.9v2.6M13.2 2.9v2.6"})]})],chart:[20,1.6,s.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,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5.4 13.6V9a4.6 4.6 0 0 1 9.2 0v4.6l1.2 1.7H4.2Z"}),s.jsx("path",{d:"M8.4 17.1a1.8 1.8 0 0 0 3.2 0"})]})],plug:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.4 2.8v3.4M12.6 2.8v3.4"}),s.jsx("path",{d:"M5 6.2h10v3.1a5 5 0 0 1-10 0Z"}),s.jsx("path",{d:"M10 14.3v3"})]})],key:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.6",cy:"10",r:"3.2"}),s.jsx("path",{d:"M9.8 10h7.2M14.4 10v2.6M16.6 10v1.8"})]})],globe:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"7.1"}),s.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"})]})],person:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"7",r:"3.2"}),s.jsx("path",{d:"M4 16.6a6 6 0 0 1 12 0"})]})],sun:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"10",r:"3.2"}),s.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,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("path",{d:"M7.6 3.2v13.6M10 7h2.6M10 9.8h2.6"})]})],bulb:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.2 13.2a5 5 0 1 1 5.6 0v1.6H7.2Z"}),s.jsx("path",{d:"M8 17.2h4"})]})],monitor:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"10",rx:"1.4"}),s.jsx("path",{d:"M7.4 16.8h5.2M10 13.6v3.2"})]})],eye:[20,1.6,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"10",cy:"10",r:"2.4"})]})],archive:[20,1.6,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.8",y:"3.6",width:"14.4",height:"3.6",rx:"1"}),s.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,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"5.4",y:"5.4",width:"9.2",height:"9.2",rx:"1.4"}),s.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"})]})],camera:[17,1.5,s.jsxs(s.Fragment,{children:[s.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"}),s.jsx("circle",{cx:"8.5",cy:"9.2",r:"2.4"})]})],clip:[17,1.5,s.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"})],send:[16,1.8,s.jsx("path",{d:"M8 13V3.5M3.8 7.7 8 3.5l4.2 4.2"})],thought:[13,1.4,s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4.2 9.6a3.6 3.6 0 1 1 4.6 0v1.2H4.2z"}),s.jsx("path",{d:"M5.2 12.2h2.6"})]})],chevron:[11,1.5,s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})],arrow:[13,1.5,s.jsx("path",{d:"M4.8 2.6 9 6.5l-4.2 3.9"})],out:[12,1.6,s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6",cy:"6",r:"4.4"}),s.jsx("path",{d:"M3.4 8.6 8.6 3.4"})]}),11],"chevron-left":[14,1.6,s.jsx("path",{d:"M9 2.5 4.5 7 9 11.5"})],"chevron-right":[14,1.6,s.jsx("path",{d:"M5 2.5 9.5 7 5 11.5"})],plus:[14,1.6,s.jsx("path",{d:"M7 2.5v9M2.5 7h9"})],"chevron-down":[14,1.4,s.jsx("path",{d:"M4 5.5 7 8.5l3-3"}),12],frame:[22,1.3,s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"2.6",y:"3.6",width:"16.8",height:"14.8",rx:"2"}),s.jsx("path",{d:"M2.6 14.2 7.4 9.6l3.4 3 3-2.6 3.6 3.2"}),s.jsx("circle",{cx:"7.4",cy:"7.6",r:"1.2"})]})],"shape-timeseries":[16,1.4,s.jsx("path",{d:"M2 11.5 5.4 7.2l2.6 2.2L14 3.5"})],"shape-table":[16,1.4,s.jsx("path",{d:"M2.2 3.5h11.6v9H2.2zM2.2 6.6h11.6M6.6 6.6v5.9"})],"shape-bars":[16,1.4,s.jsx("path",{d:"M3 13V8.2M7 13V3.6M11 13V6.4M2 13.6h12"})],"shape-keyvalue":[16,1.4,s.jsx("path",{d:"M2.6 4.6h4M9.4 4.6h4M2.6 8h4M9.4 8h4M2.6 11.4h4M9.4 11.4h4"})],"shape-document":[16,1.4,s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3M6 9h4M6 11.2h3"})],"shape-diff":[16,1.4,s.jsx("path",{d:"M8 2.6v5M5.5 5.1h5M5.5 11.6h5M3 14h10"})],"shape-terminal":[16,1.4,s.jsx("path",{d:"M2.2 3.4h11.6v9.2H2.2zM4.6 6.4l2 1.6-2 1.6M8 10h3"})],"shape-image":[16,1.4,s.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,s.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,s.jsx("path",{d:"M2.2 4h11.6v8H2.2zM2.2 4.4 8 8.8l5.8-4.4"})],"shape-structured":[16,1.4,s.jsx("path",{d:"M4 2.6h8v10.8H4zM6.2 5.6h3.6M6.2 8h3.6M6.2 10.4h2.2"})]};function De({name:e,size:t,className:n,...r}){const[i,o,l,a]=q2[e],c=t??a??i;return s.jsx("svg",{className:n,width:c,height:c,viewBox:`0 0 ${i} ${i}`,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round","data-icon":e,...r,children:l})}const O0="buddi.rosterCollapsed";function Q2(){try{return window.localStorage.getItem(O0)==="1"}catch{return!1}}function J2(e){try{window.localStorage.setItem(O0,e?"1":"0")}catch{}}function D0({agents:e,currentId:t,attention:n,onSelect:r,orientation:i="vertical",lastActivity:o,groups:l=[],currentGroupId:a=null,onSelectGroup:c,onNewGroup:u}){const p=[...e.top,...e.middle,...e.bottom],f=i==="vertical"?"right":"bottom",[h,x]=d.useState(Q2),j=w=>s.jsx(X2,{agent:w,active:w.id===t,attention:n.get(w.id),side:f,onSelect:r,lastAt:(o==null?void 0:o.get(w.id))??null},w.id);return s.jsxs("nav",{className:i==="vertical"?"wb-agent-rail":"wb-agent-strip","aria-label":"Agents","data-testid":"agent-rail","data-collapsed":i==="vertical"&&h?"true":void 0,children:[e.top.map(j),e.top.length>0&&e.middle.length>0?s.jsx("span",{className:"wb-agent-sep","data-testid":"agent-rail-sep","aria-hidden":"true"}):null,i==="vertical"&&!h&&e.middle.length>0?s.jsx("span",{className:"wb-roster-label",children:"Your team"}):null,s.jsxs("div",{className:"wb-agent-scroll",children:[e.middle.map(j),c&&$0(p)?s.jsxs("div",{className:"wb-groups","data-testid":"group-rail",children:[s.jsx("span",{className:"wb-agent-sep","aria-hidden":"true"}),s.jsxs("div",{className:"wb-groups-head",children:[s.jsx("span",{className:"wb-groups-label",children:"Groups"}),u?s.jsx("button",{type:"button",className:"ui-icon-btn","data-size":"sm","aria-label":"New group",title:"A team of agents in one conversation",onClick:u,children:s.jsx(De,{name:"plus"})}):null]}),l.map(w=>s.jsxs("button",{type:"button",className:"wb-face wb-group-face","data-active":w.id===a?"true":void 0,"aria-current":w.id===a?"true":void 0,"aria-label":`${w.name}, ${w.members.length} agents`,onClick:()=>c(w.id),children:[s.jsxs("span",{className:"wb-face-mark wb-group-stack","aria-hidden":"true",children:[w.members.slice(0,3).map(b=>{const v=p.find(m=>m.id===b);return s.jsx(xm,{className:"wb-group-chip",id:b,name:(v==null?void 0:v.name)??"?",face:v,initials:1},b)}),w.members.length>3?s.jsxs("span",{className:"wb-group-chip wb-group-more",children:["+",w.members.length-3]}):null]}),s.jsxs("span",{className:"wb-face-text",children:[s.jsx("span",{className:"wb-face-name",children:w.name}),s.jsx("span",{className:"wb-face-status",children:w.members.map(b=>{var v;return((v=p.find(m=>m.id===b))==null?void 0:v.name)??b}).join(", ")})]})]},w.id))]}):null]}),e.bottom.map(j),i==="vertical"?s.jsx("button",{type:"button",className:"ui-icon-btn wb-roster-toggle","data-size":"sm","aria-label":h?"Show agent names":"Hide agent names","aria-pressed":h,onClick:()=>x(w=>(J2(!w),!w)),children:s.jsx(De,{name:h?"chevron-right":"chevron-left"})}):null]})}function X2({agent:e,active:t,attention:n,side:r,onSelect:i,lastAt:o=null}){const l=fu(n),a=l?fv(l):e.available?o?`Last spoke ${Se(o)}`:e.description:e.unavailableReason??"Cannot run right now",c=L2(n),u=e.unavailableReason??"This agent cannot run on this machine right now.",p=[e.name,e.available?null:"unavailable",l,t?"current":null].filter(f=>f!==null&&f!=="").join(" — ");return s.jsxs(wc,{children:[s.jsx(bc,{asChild:!0,children:s.jsxs("button",{className:"wb-face",...kl(bl(e)),"data-active":t?"true":void 0,"data-unavailable":e.available?void 0:"true","data-testid":`agent-face-${e.id}`,"aria-label":p,"aria-current":t?"true":void 0,disabled:!e.available,onClick:()=>e.available&&i(e.id),children:[s.jsx(xm,{className:"wb-face-mark",id:e.id,name:e.name,face:e}),s.jsxs("span",{className:"wb-face-text","aria-hidden":"true",children:[s.jsxs("span",{className:"wb-face-name",children:[e.name,s.jsxs("span",{className:"wb-face-handle",children:["@",e.handle]})]}),s.jsx("span",{className:"wb-face-status","data-tone":l?"critical":void 0,children:a})]}),c?s.jsx("span",{className:"wb-face-badge","data-kind":c.count===null?"dot":"count","data-testid":`agent-badge-${e.id}`,"aria-hidden":"true",children:c.count===null?"":c.count}):null,e.available?null:s.jsx("span",{className:"wb-face-out","aria-hidden":"true",children:s.jsx(De,{name:"out"})})]})}),s.jsx(kc,{children:s.jsxs(Sc,{className:"ui-tip",side:r,sideOffset:8,children:[s.jsx("span",{className:"ui-tip-title",children:e.name}),s.jsx("span",{className:"ui-tip-hint",children:e.available?`@${e.handle} · ${e.model}`:u}),l?s.jsx("span",{className:"ui-tip-alert",children:fv(l)}):null]})})]})}function fv(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}.`}function Z2(e){let t=0;for(const n of e)t=(t*31+n.charCodeAt(0))%997;return t%6+1}function xm({className:e,id:t,name:n,face:r,tint:i,size:o,unavailable:l,initials:a=2}){const[c,u]=d.useState(null),p=r!=null&&r.picture&&r.picture!==c?r.picture:void 0,f=r==null?void 0:r.avatar,h=p?"image":f==null?void 0:f.kind,x=t?kl(bl({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 s.jsx("span",{className:e,"data-tint":x?void 0:i,"data-size":o,"data-kind":h,"data-unavailable":l?"true":void 0,...x,"aria-hidden":"true",children:p?s.jsx("img",{src:p,alt:"",onError:()=>u(p)}):(f==null?void 0:f.kind)==="image"?s.jsx("img",{src:f.url,alt:""}):(f==null?void 0:f.kind)==="emoji"?f.value:K2(n).slice(0,a)})}function as({id:e,name:t,size:n,unavailable:r,face:i}){return s.jsx(xm,{className:"ui-avatar",id:e,tint:Z2(e),name:t,size:n,unavailable:r,face:i})}function Zt({agents:e,id:t,size:n}){const r=e.find(i=>i.id===t);return s.jsx(as,{id:t,name:(r==null?void 0:r.name)??t,size:n,unavailable:r?!r.available:!1,face:r})}const L0=d.createContext(null);function eI({picture:e,children:t}){return s.jsx(L0.Provider,{value:e??null,children:t})}function F0({size:e}){const t=d.useContext(L0),[n,r]=d.useState(null);return!t||t===n?null:s.jsx("span",{className:"ui-mascot","data-size":e,"data-testid":"mascot","aria-hidden":"true",children:s.jsx("img",{src:t,alt:"",onError:()=>r(t)})})}const z0=d.createContext([]);function cr({text:e,className:t}){const n=oh(e.replace(/\r\n/g,`
|
|
87
|
-
`).split(`
|
|
88
|
-
`));return s.jsx("div",{className:t??"wb-md",children:n.map((r,i)=>s.jsx(lh,{block:r},i))})}const hv=/^(\s*)(```|~~~)\s*([\w+-]*)\s*$/,pv=/^(#{1,6})\s+(.*?)\s*#*\s*$/,mv=/^\s*([-*_])(\s*\1){2,}\s*$/,la=/^(\s*)([-*+])\s+(.*)$/,wo=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,aa=/^\s*>\s?(.*)$/,md=/^\s*\|.*\|\s*$/,gv=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;function oh(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.trim()===""){n+=1;continue}const i=hv.exec(r);if(i){const a=i[2],c=[];for(n+=1;n<e.length&&!new RegExp(`^\\s*${a}\\s*$`).test(e[n]);)c.push(e[n]),n+=1;n+=1,t.push({type:"code",lang:i[3]||null,text:c.join(`
|
|
89
|
-
`)});continue}const o=pv.exec(r);if(o){t.push({type:"h",level:o[1].length,text:o[2]}),n+=1;continue}if(mv.test(r)){t.push({type:"hr"}),n+=1;continue}if(aa.test(r)){const a=[];for(;n<e.length&&aa.test(e[n]);)a.push(aa.exec(e[n])[1]),n+=1;t.push({type:"quote",blocks:oh(a),raw:a.join(`
|
|
90
|
-
`)});continue}if(md.test(r)&&n+1<e.length&&gv.test(e[n+1])){const a=xd(r),c=xd(e[n+1]).map(p=>{const f=p.startsWith(":"),h=p.endsWith(":");return f&&h?"center":h?"right":f?"left":null});n+=2;const u=[];for(;n<e.length&&md.test(e[n]);)u.push(xd(e[n])),n+=1;t.push({type:"table",head:a,rows:u,align:c});continue}if(la.test(r)||wo.test(r)){const a=wo.exec(r)??la.exec(r),c=wo.test(r),u=a[1].length,p=c?Number(a[2]):1,f=[];for(;n<e.length;){const h=c?wo.exec(e[n]):la.exec(e[n]);if(!h||h[1].length!==u)break;const x=[h[3]];for(n+=1;n<e.length;){const j=e[n],w=j.trim()!==""&&gd(j)>u,b=j.trim()===""&&n+1<e.length&&e[n+1].trim()!==""&&gd(e[n+1])>u;if(!w&&!b)break;x.push(j.trim()===""?"":j.slice(Math.min(gd(j),u+2))),n+=1}f.push(oh(x))}t.push({type:"list",ordered:c,start:p,items:f});continue}const l=[];for(;n<e.length;){const a=e[n];if(a.trim()===""||hv.test(a)||pv.test(a)||mv.test(a)||aa.test(a)||la.test(a)||wo.test(a)||md.test(a)&&n+1<e.length&&gv.test(e[n+1]))break;l.push(a.trim()),n+=1}l.length>0&&t.push({type:"p",text:l.join(`
|
|
91
|
-
`)})}return t}function gd(e){return e.length-e.trimStart().length}function xd(e){const t=e.trim().replace(/^\|/,"").replace(/\|$/,""),n=[];let r="";for(let i=0;i<t.length;i+=1){const o=t[i];if(o==="\\"&&t[i+1]==="|"){r+="|",i+=1;continue}if(o==="|"){n.push(r.trim()),r="";continue}r+=o}return n.push(r.trim()),n}function lh({block:e}){switch(e.type){case"p":return s.jsx("p",{children:On(e.text)});case"h":{const t=Math.min(6,Math.max(1,e.level)),n=`h${Math.min(t+2,6)}`;return s.jsx(n,{className:"wb-md-h","data-level":t,children:On(e.text)})}case"code":return s.jsxs("div",{className:"wb-md-code-frame",children:[s.jsxs("div",{className:"wb-md-code-head",children:[s.jsx("span",{className:"wb-md-code-lang",children:e.lang??"text"}),s.jsx(xv,{text:e.text,what:"code",always:!0})]}),s.jsx("pre",{className:"wb-md-code","data-lang":e.lang??void 0,children:s.jsx("code",{children:e.text})})]});case"quote":return s.jsxs("div",{className:"wb-md-copyable",children:[s.jsx("blockquote",{children:e.blocks.map((t,n)=>s.jsx(lh,{block:t},n))}),s.jsx(xv,{text:e.raw,what:"quote"})]});case"hr":return s.jsx("hr",{});case"list":{const t=e.items.map((n,r)=>s.jsx("li",{children:n.map((i,o)=>i.type==="p"?s.jsx(d.Fragment,{children:On(i.text)},o):s.jsx(lh,{block:i},o))},r));return e.ordered?s.jsx("ol",{start:e.start,children:t}):s.jsx("ul",{children:t})}case"table":return s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table wb-md-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.head.map((t,n)=>s.jsx("th",{style:e.align[n]?{textAlign:e.align[n]}:void 0,children:On(t)},n))})}),s.jsx("tbody",{children:e.rows.map((t,n)=>s.jsx("tr",{children:t.map((r,i)=>s.jsx("td",{style:e.align[i]?{textAlign:e.align[i]}:void 0,children:On(r)},i))},n))})]})})}}function xv({text:e,what:t,always:n=!1}){const[r,i]=d.useState("idle"),o=()=>{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 s.jsx("button",{type:"button",className:"wb-md-copy","data-state":r,"data-always":n||void 0,"aria-label":`Copy ${t}`,title:`Copy ${t}`,onClick:o,children:r==="done"?"Copied":r==="failed"?"Select to copy":s.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:[s.jsx("rect",{x:"4.5",y:"4.5",width:"6.5",height:"6.5",rx:"1.2"}),s.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 tI({handle:e}){const n=d.useContext(z0).find(r=>r.handle.toLowerCase()===e.toLowerCase());return n?s.jsxs(wc,{children:[s.jsx(bc,{asChild:!0,children:s.jsxs("a",{className:"wb-mention-link",href:ze(n.id),children:["@",n.handle]})}),s.jsx(kc,{children:s.jsxs(Sc,{className:"wb-agent-card",sideOffset:6,children:[s.jsx(as,{id:n.id,name:n.name,face:n,unavailable:!n.available}),s.jsxs("span",{className:"wb-agent-card-text",children:[s.jsx("span",{className:"wb-agent-card-name",children:n.name}),s.jsx("span",{className:"wb-agent-card-desc",children:n.description}),s.jsxs("span",{className:"wb-agent-card-meta",children:[n.model,n.available?"":" · unavailable"]})]})]})})]}):s.jsxs(s.Fragment,{children:["@",e]})}const nI=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 On(e){const t=[];let n=e,r=0;for(;n!=="";){const i=nI.exec(n);if(!i){t.push(...vv(n,r));break}i.index>0&&t.push(...vv(n.slice(0,i.index),r)),r+=100,i[2]!==void 0?t.push(s.jsx("code",{children:i[2]},r)):i[3]!==void 0?t.push(s.jsx("strong",{children:On(i[3])},r)):i[4]!==void 0?t.push(s.jsx("strong",{children:On(i[4])},r)):i[5]!==void 0?t.push(s.jsx("s",{children:On(i[5])},r)):i[6]!==void 0?t.push(s.jsx("em",{children:On(i[6])},r)):i[7]!==void 0?t.push(s.jsx("em",{children:On(i[7])},r)):i[8]!==void 0&&i[9]!==void 0?t.push(s.jsx("a",{href:i[9],target:"_blank",rel:"noopener noreferrer",children:On(i[8])},r)):i[10]!==void 0?t.push(s.jsx("a",{href:i[10],target:"_blank",rel:"noopener noreferrer",children:i[10]},r)):i[11]!==void 0&&t.push(s.jsx(tI,{handle:i[11]},r)),n=n.slice(i.index+i[0].length)}return t}function vv(e,t){return e.split(`
|
|
92
|
-
`).flatMap((r,i)=>i===0?[r]:[s.jsx("br",{},`${t}-br-${i}`),r])}function sI({props:e}){return s.jsxs("div",{children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-block",children:e.metadata.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:jt(t.value,t.unit,null)})]},t.label))}):null,e.kind==="image"&&e.src?s.jsx("img",{src:e.src,alt:e.title??"Attached image",className:"wb-doc-image"}):e.kind==="pdf"&&e.src?s.jsx("object",{data:e.src,type:"application/pdf",className:"wb-doc-pdf",children:s.jsx("a",{href:e.src,children:"Open the PDF"})}):e.text?s.jsx("div",{className:"wb-doc",children:s.jsx(cr,{text:e.text})}):s.jsx("p",{className:"wb-empty",children:"This document came back with no body."})]})}function me(e,t){if(t===""||t==="$")return e;let n=e;for(const r of t.split(".")){const i=/^([^[\]]*)((?:\[\d+\])*)$/.exec(r);if(!i)return;const[,o="",l=""]=i;if(o!==""){if(n===null||typeof n!="object")return;n=n[o]}for(const a of l.match(/\d+/g)??[]){if(!Array.isArray(n))return;n=n[Number(a)]}if(n===void 0)return}return n}function ke(e,t){if(t)return"const"in t?t.const:me(e,t.path)}function sr(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 He(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):null}function Tr(e){return Array.isArray(e)?e:[]}function rI(e,t){const n=Tr(me(e,t.points)).map(i=>{const o=sr(me(i,t.y)),l=He(me(i,t.x));return o===null||l===null?null:{x:l,y:o}}).filter(i=>i!==null),r=(t.referenceLines??[]).map(i=>{const o=sr(ke(e,i.value));return o===null?null:{value:o,label:i.label,tone:i.tone??"neutral"}}).filter(i=>i!==null);return{points:n,unit:t.unit??"number",currency:He(ke(e,t.currency)),label:He(ke(e,t.label)),referenceLines:r,mark:t.mark??null,shadeBelow:sr(ke(e,t.shadeBelow)),events:iI(e,t)}}function iI(e,t){const n=t.events;if(!n)return[];const r=[],i=(o,l)=>{const a=He(me(o,n.label));if(a===null)return;const c=He(me(o,n.at))??l;c!==null&&r.push({at:c,label:a,amount:n.amount?sr(me(o,n.amount)):null})};if(n.parent){for(const o of Tr(me(e,t.points))){const l=He(me(o,t.x));for(const a of Tr(me(o,n.parent)))i(a,l)}return r}for(const o of Tr(me(e,n.path??t.points)))i(o,null);return r}function oI(e,t){const n=(t.columns??[]).map(a=>({key:a.key,label:a.label,type:a.type??"text"})),r=a=>(t.columns??[]).map(c=>{const u=me(a,c.key);let p=null;if(c.bar){const f=sr(ke(a,c.bar.max))??sr(ke(e,c.bar.max)),h=sr(u);if(f!==null&&f>0&&h!==null){const x=Math.max(0,Math.min(1,h/f));p={fraction:x,tone:aI(x*100,c.bar.thresholds)}}}return{value:u,type:c.type??"text",currency:He(ke(a,c.currency))??He(ke(e,c.currency)),bar:p}}),i=Tr(me(e,t.rows)),o=t.groupBy?lI(i,t.groupBy,r):[{label:null,rows:i.map(r)}],l=(t.summary??[]).map(a=>({label:a.label,value:ke(e,a.value),unit:a.unit??"text",currency:He(ke(e,a.currency)),tone:a.tone??"neutral"}));return{columns:n,groups:o,summary:l,empty:t.empty??"Nothing to show."}}function lI(e,t,n){const r=new Map;for(const i of e){const o=String(me(i,t.key)??""),l=r.get(o);l?l.push(i):r.set(o,[i])}return[...r.entries()].map(([i,o])=>{var l;return{label:((l=t.labels)==null?void 0:l[i])??i,rows:o.map(n)}})}function aI(e,t){var r;return!t||t.length===0?"neutral":((r=[...t].sort((i,o)=>o.atLeast-i.atLeast).find(i=>e>=i.atLeast))==null?void 0:r.tone)??"neutral"}function cI(e,t){return{bars:Tr(me(e,t.bars)).map(r=>{const i=sr(me(r,t.value)),o=He(me(r,t.category));return i===null||o===null?null:{category:o,value:i}}).filter(r=>r!==null),unit:t.unit??"number",currency:He(ke(e,t.currency))}}function uI(e,t){if(t.pairs)return{pairs:t.pairs.map(r=>({label:r.label,value:ke(e,r.value),unit:r.unit??"text",currency:He(ke(e,r.currency)),tone:r.tone??"neutral"}))};const n=me(e,t.from??"$");return n===null||typeof n!="object"||Array.isArray(n)?{pairs:[]}:{pairs:Object.entries(n).map(([r,i])=>({label:Wt(r),value:i,unit:"text",currency:null,tone:"neutral"}))}}function dI(e,t){const n=He(ke(e,t.kind)),r=n==="image"||n==="pdf"?n:"text",i=t.src?He(me(e,t.src)):null;return{kind:r,text:t.text?He(me(e,t.text)):null,src:i&&B0(i)?i:null,title:He(ke(e,t.title)),metadata:(t.metadata??[]).map(o=>({label:o.label,value:ke(e,o.value),unit:o.unit??"text"}))}}function fI(e,t){const n=t.diff?me(e,t.diff):void 0;return{diff:typeof n=="string"&&n.trim()!==""?n:null,title:He(ke(e,t.title)),metadata:(t.metadata??[]).map(r=>({label:r.label,value:ke(e,r.value),unit:r.unit??"text"}))}}function hI(e,t){const n=t.output?me(e,t.output):void 0,r=l=>{const a=l?me(e,l):void 0;return typeof a=="number"&&Number.isInteger(a)?a:null},i=r(t.omittedBytes),o=t.elapsedMs?me(e,t.elapsedMs):void 0;return{command:He(ke(e,t.command)),output:typeof n=="string"?n:null,exitCode:r(t.exitCode),elapsedMs:typeof o=="number"&&Number.isFinite(o)&&o>=0?o:null,omittedBytes:i!==null&&i>0?i:null,metadata:(t.metadata??[]).map(l=>({label:l.label,value:ke(e,l.value),unit:l.unit??"text"}))}}const pI=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function U0(e){const t=e!==null&&typeof e=="object"&&!Array.isArray(e)?e.artifactId??e.id:e;return typeof t=="string"&&pI.test(t)?t.toLowerCase():null}function mI(e,t){return{artifactId:t.src?U0(me(e,t.src)):null,title:He(ke(e,t.title)),caption:He(ke(e,t.caption)),...t.captionLabel?{captionLabel:He(ke(e,t.captionLabel))}:{}}}function jv(e){if(!B0(e))return null;let t;try{t=new URL(e,"file:///").pathname}catch{return null}const n=/^\/preview\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/([A-Za-z0-9][A-Za-z0-9_.-]*)\/?$/.exec(t);return n?{plugin:n[1],name:n[2]}:null}function gI(e,t){const n=t.src?He(me(e,t.src)):null,r=t.port?me(e,t.port):null,i=t.awaiting?He(me(e,t.awaiting)):null;return{target:n?jv(n):null,title:He(ke(e,t.title)),output:t.output?He(me(e,t.output)):null,port:typeof r=="number"&&Number.isInteger(r)&&r>0&&r<=65535?r:null,awaiting:i?jv(i):null,reloadsItself:t.reloadsItself?me(e,t.reloadsItself)===!0:!1,ports:t.ports?xI(me(e,t.ports)):[]}}function xI(e){const t=Tr(e).filter(n=>typeof n=="number"&&Number.isInteger(n)&&n>0&&n<=65535);return[...new Set(t)].sort((n,r)=>n-r)}function B0(e){return e.startsWith("/")&&!e.startsWith("//")}function Wt(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 W0(e,t){const n=e.map??{};switch(e.renderer){case"timeseries":return{renderer:"timeseries",props:rI(t,n)};case"table":return{renderer:"table",props:oI(t,n)};case"bars":return{renderer:"bars",props:cI(t,n)};case"keyvalue":return{renderer:"keyvalue",props:uI(t,n)};case"document":return{renderer:"document",props:dI(t,n)};case"diff":return{renderer:"diff",props:fI(t,n)};case"terminal":return{renderer:"terminal",props:hI(t,n)};case"image":return{renderer:"image",props:mI(t,n)};case"preview":return{renderer:"preview",props:gI(t,n)};default:return{renderer:"structured",props:{value:t}}}}var vI=Object.defineProperty,Hn=(e,t)=>vI(e,"name",{value:t,configurable:!0}),vm="Dialog",[H0,d6]=Bn(vm),[jI,Ms]=H0(vm),yI=Hn(e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,a=d.useRef(null),c=d.useRef(null),[u,p]=Zi({prop:r,defaultProp:i??!1,onChange:o,caller:vm}),[f,h]=d.useState(0),[x,j]=d.useState(0);return s.jsx(jI,{scope:t,triggerRef:a,contentRef:c,contentId:js(),titleId:js(),descriptionId:js(),titlePresent:f>0,descriptionPresent:x>0,setTitleCount:h,setDescriptionCount:j,open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(w=>!w),[p]),modal:l,children:n})},"Dialog"),V0="DialogPortal",[wI,K0]=H0(V0,{forceMount:void 0}),bI=Hn(e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=Ms(V0,t);return s.jsx(wI,{scope:t,forceMount:n,children:d.Children.map(r,l=>s.jsx(pr,{present:n||o.open,children:s.jsx(Fp,{asChild:!0,container:i,children:l})}))})},"DialogPortal"),ah="DialogOverlay",kI=d.forwardRef(Hn(function(t,n){const r=K0(ah,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,l=Ms(ah,t.__scopeDialog);return l.modal?s.jsx(pr,{present:i||l.open,children:s.jsx(NI,{...o,ref:n})}):null},"DialogOverlay")),SI=or("DialogOverlay.RemoveScroll"),NI=d.forwardRef(Hn(function(t,n){const{__scopeDialog:r,...i}=t,o=Ms(ah,r),l=Ww(),a=qe(n,l);return s.jsx(Zp,{as:SI,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Je.div,{"data-state":jm(o.open),...i,ref:a,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),ul="DialogContent",CI=d.forwardRef(Hn(function(t,n){const r=K0(ul,t.__scopeDialog),{forceMount:i=r.forceMount,...o}=t,l=Ms(ul,t.__scopeDialog);return s.jsx(pr,{present:i||l.open,children:l.modal?s.jsx(EI,{...o,ref:n}):s.jsx(AI,{...o,ref:n})})},"DialogContent")),EI=d.forwardRef(Hn(function(t,n){const r=Ms(ul,t.__scopeDialog),i=d.useRef(null),o=qe(n,r.contentRef,i);return d.useEffect(()=>{const l=i.current;if(l)return t0(l)},[]),s.jsx(G0,{...t,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:we(t.onCloseAutoFocus,l=>{var a;l.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:we(t.onPointerDownOutside,l=>{const a=l.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&l.preventDefault()}),onFocusOutside:we(t.onFocusOutside,l=>l.preventDefault())})},"DialogContentModal")),AI=d.forwardRef(Hn(function(t,n){const r=Ms(ul,t.__scopeDialog),i=d.useRef(!1),o=d.useRef(!1);return s.jsx(G0,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{var a,c;(a=t.onCloseAutoFocus)==null||a.call(t,l),l.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),l.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:l=>{var u,p;(u=t.onInteractOutside)==null||u.call(t,l),l.defaultPrevented||(i.current=!0,l.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=l.target;((p=r.triggerRef.current)==null?void 0:p.contains(a))&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&o.current&&l.preventDefault()}})},"DialogContentNonModal")),G0=d.forwardRef(Hn(function(t,n){const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:l,...a}=t,c=Ms(ul,r);return lu(),s.jsx(s.Fragment,{children:s.jsx(Db,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:l,children:s.jsx(Dp,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":jm(c.open),...a,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),TI="DialogTitle",RI=d.forwardRef(Hn(function(t,n){const{__scopeDialog:r,...i}=t,o=Ms(TI,r),{setTitleCount:l}=o;return sn(()=>(l(a=>a+1),()=>l(a=>a-1)),[l]),s.jsx(Je.h2,{id:o.titleId,...i,ref:n})},"DialogTitle")),PI="DialogClose",II=d.forwardRef(Hn(function(t,n){const{__scopeDialog:r,...i}=t,o=Ms(PI,r);return s.jsx(Je.button,{type:"button",...i,ref:n,onClick:we(t.onClick,()=>o.onOpenChange(!1))})},"DialogClose"));function jm(e){return e?"open":"closed"}Hn(jm,"getState");const MI=5;function se(e,t,n){const[r,i]=d.useState(void 0),[o,l]=d.useState(null),[a,c]=d.useState(!0),[u,p]=d.useState(0),[f,h]=d.useState(0),x=d.useRef(e);return x.current=e,d.useEffect(()=>{let j=!1;return c(!0),x.current().then(w=>{j||(i(w),l(null),h(0))}).catch(w=>{j||(l(w instanceof ce?w.message:String(w)),h(b=>b+1))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[...t,u]),d.useEffect(()=>{if(!n||f>=MI)return;const j=window.setTimeout(()=>p(w=>w+1),n*2**f);return()=>window.clearTimeout(j)},[n,f,u]),{data:r,error:o,loading:a,reload:()=>{h(0),p(j=>j+1)}}}function Yr(...e){return e.filter(Boolean).join(" ")}function R({variant:e,size:t,className:n,type:r="button",...i}){return s.jsx("button",{type:r,className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...i})}function Un({variant:e,size:t,className:n,...r}){return s.jsx("a",{className:Yr("ui-btn",n),"data-variant":e&&e!=="default"?e:void 0,"data-size":t,...r})}function J({children:e,align:t,valign:n,className:r}){return s.jsx("div",{className:Yr("ui-toolbar",r),"data-align":t,"data-valign":n,children:e})}function ro(){return s.jsx("span",{className:"ui-toolbar-spacer"})}function ee({label:e,hint:t,inline:n,grow:r,wide:i,children:o}){return s.jsxs("div",{className:"ui-field","data-inline":n?"true":void 0,"data-grow":r?"true":void 0,"data-wide":i?"true":void 0,children:[s.jsxs("label",{className:"ui-field-control",children:[s.jsx("span",{className:"ui-field-label",children:e}),o]}),t?s.jsx("span",{className:"ui-field-hint",children:t}):null]})}function Ts({children:e,dense:t}){return s.jsx("div",{className:"ui-formgrid","data-dense":t?"true":void 0,children:e})}function pe({tone:e,mono:t,dot:n,children:r,className:i,title:o}){return s.jsxs("span",{className:Yr("ui-pill",t&&"mono",i),"data-tone":e,title:o,children:[n?s.jsx("span",{className:"ui-pill-dot","aria-hidden":"true"}):null,r]})}function Ua({children:e}){return s.jsx("span",{className:"ui-tag",children:e})}function hu({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 s.jsx(pe,{tone:t,children:e})}function V({tone:e,title:t,children:n,role:r}){return s.jsxs("div",{className:"ui-notice","data-tone":e,role:r,children:[t?s.jsx("div",{className:"ui-notice-title",children:t}):null,n]})}function re({message:e}){return e?s.jsx(V,{tone:"critical",role:"alert",children:e}):null}function ie({mascot:e,warm:t,title:n,action:r,children:i}){return t||n?s.jsxs("div",{className:"ui-empty","data-warm":t?"true":void 0,children:[n?s.jsx("div",{className:"ui-empty-title",children:n}):null,s.jsx("div",{children:i}),r]}):e?s.jsxs("div",{className:"ui-empty","data-mascot":"true",children:[s.jsx(F0,{size:"sm"}),s.jsx("p",{children:i})]}):s.jsx("p",{className:"ui-empty",children:i})}function yt({icon:e,title:t,action:n,children:r}){return s.jsxs("div",{className:"ui-empty-state",children:[e?s.jsx("span",{className:"ui-empty-state-icon",children:typeof e=="string"?s.jsx(De,{name:e}):e}):null,s.jsx("div",{className:"ui-empty-state-title",children:t}),r?s.jsx("p",{className:"ui-empty-state-line",children:r}):null,n?s.jsx("div",{className:"ui-empty-state-action",children:n}):null]})}function $I({children:e}){return s.jsx("div",{className:"ui-page",children:e})}function ym({title:e,lede:t,actions:n,before:r}){return s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[r,s.jsx("span",{children:e})]}),n?s.jsx("div",{className:"ui-page-actions",children:n}):null]}),t?s.jsx("p",{className:"ui-page-lede",children:t}):null]})}function an({embedded:e,title:t,lede:n,actions:r,children:i}){return e?s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[r?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:r}):null,i]}):s.jsxs($I,{children:[s.jsx(ym,{title:t,lede:n,actions:r}),i]})}function Y({title:e,aside:t,actions:n,panel:r,flush:i,foot:o,children:l}){const a=e||t||n?s.jsxs("div",{className:"ui-section-head",children:[e?s.jsx("h3",{className:"ui-section-title",children:e}):s.jsx("span",{}),t||n?s.jsxs("div",{className:"ui-section-side",children:[t?s.jsx("span",{className:"ui-section-aside",children:t}):null,n?s.jsx("div",{className:"ui-section-actions",children:n}):null]}):null]}):null;return s.jsxs("section",{className:"ui-section","data-panel":r?"true":void 0,children:[a,r?s.jsxs("div",{className:"ui-panel","data-flush":i?"true":void 0,children:[l,o?s.jsx("div",{className:"ui-panel-foot",children:o}):null]}):s.jsxs(s.Fragment,{children:[l,o?s.jsx("div",{className:"ui-toolbar","data-align":"end",children:o}):null]})]})}function rt({title:e,tool:t,actions:n,flush:r,children:i}){return s.jsxs("section",{className:"ui-panel","data-flush":r?"true":void 0,children:[e||t||n?s.jsxs("header",{className:"ui-panel-head",children:[e?s.jsx("h3",{className:"ui-panel-title",children:e}):s.jsx("span",{}),t?s.jsx("span",{className:"ui-panel-tool",children:t}):null,n?s.jsx("div",{className:"ui-panel-actions",children:n}):null]}):null,i]})}function Fr({tone:e,title:t,meta:n,actions:r,children:i,foot:o,as:l="div"}){return s.jsxs(l,{className:"ui-card","data-tone":e,children:[t||n||r?s.jsxs("div",{className:"ui-card-head",children:[t?s.jsx("h3",{className:"ui-card-title",children:t}):null,n,r?s.jsx("div",{className:"ui-card-actions",children:r}):null]}):null,i,o?s.jsx("div",{className:"ui-card-foot",children:o}):null]})}function G({gap:e,divided:t,children:n}){return s.jsx("div",{className:"ui-stack","data-gap":e,"data-divided":t?"true":void 0,children:n})}function _I({children:e}){return s.jsx("div",{className:"ui-row",children:e})}function pu({inline:e,children:t}){return s.jsx("div",{className:"ui-stats","data-inline":e?"true":void 0,children:t})}function Zn({label:e,value:t,note:n,tone:r,size:i}){return s.jsxs("div",{className:"ui-stat",children:[s.jsx("div",{className:"ui-stat-k",children:e}),s.jsx("div",{className:"ui-stat-v","data-tone":r,"data-size":i,children:t}),n?s.jsx("div",{className:"ui-stat-n",children:n}):null]})}function At({items:e}){return s.jsx("dl",{className:"ui-kv",children:e.map((t,n)=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{children:t.value})]},t.key??n))})}function ln({children:e}){return s.jsx("div",{className:"ui-table-wrap",children:s.jsx("table",{className:"ui-table",children:e})})}function OI({value:e,label:t}){const n=Math.max(0,Math.min(100,Math.round(Number.isFinite(e)?e:0)));return s.jsx("div",{className:"ui-progress",role:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-valuetext":`${n}%`,children:s.jsx("div",{className:"ui-progress-fill",style:{inlineSize:`${n}%`}})})}function at({children:e,label:t}){return s.jsx("pre",{className:"ui-code","aria-label":t,children:e})}function wt({summary:e,boxed:t,open:n,className:r,onToggle:i,children:o}){return s.jsxs("details",{className:Yr("ui-details",r),"data-boxed":t?"true":void 0,open:n,onToggle:i?l=>i(l.currentTarget.open):void 0,children:[s.jsx("summary",{children:e}),o]})}function qt({title:e,onClose:t,size:n,children:r}){return s.jsx(yI,{open:!0,onOpenChange:i=>{i||t()},children:s.jsxs(bI,{children:[s.jsx(kI,{className:"ui-sheet-overlay"}),s.jsxs(CI,{className:"ui-sheet","data-size":n,"aria-describedby":void 0,children:[s.jsxs("div",{className:"ui-sheet-head",children:[s.jsx(RI,{className:"ui-sheet-title",children:e}),s.jsx(II,{asChild:!0,children:s.jsx(R,{size:"sm",children:"Close"})})]}),r]})]})})}function mu({level:e,label:t,children:n}){return s.jsx("nav",{className:"ui-tabs","data-level":e,"aria-label":t,children:n})}function gu({href:e,active:t,count:n,onClick:r,children:i}){return s.jsxs("a",{className:"ui-tab",href:e,"aria-current":t?"page":void 0,onClick:r,children:[i,n?s.jsx("span",{className:"ui-count",children:n}):null]})}function Ba({label:e,options:t,value:n,onChange:r}){return s.jsx("div",{className:"ui-segment",role:"radiogroup","aria-label":e,children:t.map(i=>s.jsx("button",{type:"button",role:"radio",className:"ui-tab","aria-checked":i.value===n,onClick:()=>r(i.value),children:i.label},i.value))})}function Ft({children:e}){return s.jsx("div",{className:"ui-list",children:e})}function Kt({href:e,onClick:t,lead:n,title:r,sub:i,side:o}){const l=s.jsxs(s.Fragment,{children:[n,s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:r}),i?s.jsx("span",{className:"ui-list-sub",children:i}):null]}),o?s.jsx("span",{className:"ui-list-side",children:o}):null]});return e?s.jsx("a",{className:"ui-list-row",href:e,onClick:t?a=>{a.preventDefault(),t()}:void 0,children:l}):s.jsx("div",{className:"ui-list-row",children:l})}function Y0({href:e,onClick:t,current:n,lead:r,title:i,meta:o,sub:l,snippet:a,side:c}){return s.jsxs("a",{className:"ui-pick",href:e,"aria-current":n?"true":void 0,onClick:t?u=>{u.preventDefault(),t()}:void 0,children:[r?s.jsx("span",{className:"ui-pick-lead",children:r}):null,s.jsxs("span",{className:"ui-pick-main",children:[s.jsxs("span",{className:"ui-pick-top",children:[s.jsx("span",{className:"ui-pick-title",children:i}),o?s.jsx("span",{className:"ui-pick-meta",children:o}):null]}),l||c?s.jsxs("span",{className:"ui-pick-line",children:[l?s.jsx("span",{className:"ui-pick-sub",children:l}):null,c?s.jsx("span",{className:"ui-pick-side",children:c}):null]}):null,a?s.jsx("span",{className:"ui-pick-snippet",children:a}):null]})]})}function q0({list:e,detail:t,empty:n,label:r,className:i}){return s.jsxs("div",{className:Yr("ui-split",i),"data-open":t?"true":void 0,children:[s.jsx("section",{className:"ui-split-list","aria-label":r,children:e}),s.jsx("section",{className:"ui-split-detail","data-empty":t?void 0:"true",children:t??s.jsx("p",{className:"ui-empty ui-split-empty",children:n})})]})}function ch({children:e,onRemove:t,label:n}){return s.jsxs("span",{className:"ui-chip",children:[e,s.jsx("button",{type:"button",className:"ui-chip-x","aria-label":`Remove ${n}`,onClick:t,children:"×"})]})}function Q0({main:e,filters:t,filtersOpen:n,onToggleFilters:r,active:i,chips:o,actions:l,onSubmit:a,label:c}){return s.jsxs("form",{className:"ui-panel ui-searchbar",role:"search","aria-label":c,onSubmit:u=>{u.preventDefault(),a()},children:[s.jsxs("div",{className:"ui-searchbar-row",children:[e?s.jsx("div",{className:"ui-searchbar-main",children:e}):null,t&&r?s.jsxs(R,{"aria-expanded":n===!0,"aria-pressed":n===!0,onClick:r,children:["Filters",i?s.jsx("span",{className:"ui-count",children:i}):null]}):null,!r&&t?s.jsx("div",{className:"ui-searchbar-inline",children:t}):null,l?s.jsx("div",{className:"ui-searchbar-actions",children:l}):null]}),t&&r&&n?s.jsx("div",{className:"ui-searchbar-filters",children:t}):null,o?s.jsx("div",{className:"ui-searchbar-chips",children:o}):null]})}function J0({size:e}){return s.jsx("span",{className:"ui-mark","data-size":e,"aria-hidden":"true",children:"b"})}function DI({quiet:e,still:t,className:n,children:r}){return s.jsx("div",{className:Yr("ui-fieldbg",n),"data-quiet":e?"true":void 0,"data-still":t?"true":void 0,children:r})}function LI(e){const t={};for(const n of e??[])t[n.key]=n.default;return t}function wm(e){const[t,n]=d.useState({}),r=e??[],i={...LI(r),...t};return r.length===0?{values:void 0,controls:null}:{values:i,controls:s.jsx("div",{className:"ui-choices",children:r.map(o=>s.jsx(ee,{label:o.label,inline:!0,children:s.jsx("select",{value:i[o.key],onChange:l=>n(a=>({...a,[o.key]:l.target.value})),children:o.options.map(l=>s.jsx("option",{value:l,children:l},l))})},o.key))})}}function FI({props:e,timezone:t="UTC",onDecided:n}){var m;const[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null);d.useEffect(()=>{let y=!1;return i(null),l(null),A.approval(e.approvalId).then(g=>{y||i(g)}).catch(g=>{y||l(g instanceof ce?g.message:String(g))}),()=>{y=!0}},[e.approvalId]);const{values:f,controls:h}=wm(r==null?void 0:r.choices),x=(y,g)=>{p(y),l(null),(f&&y==="approve"?A.decide(e.approvalId,y,g,f):A.decide(e.approvalId,y,g)).then(k=>{i(k.action),n==null||n(k.action)}).catch(k=>l(k instanceof ce?k.message:String(k))).finally(()=>p(null))};if(o&&!r)return s.jsx("p",{className:"wb-empty",children:o});if(!r)return s.jsx("p",{className:"wb-empty",children:"Loading the envelope…"});const j=r.state==="pending",w=(m=r.permissionScopes)==null?void 0:m.includes("always"),b=zI(r),v=(r.preview??"").split(`
|
|
93
|
-
`).length>12||(r.preview??"").length>900;return s.jsxs("div",{children:[s.jsxs("div",{className:"ui-stats","data-inline":"true",children:[s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"Tool"}),s.jsx("div",{className:"ui-stat-v mono",children:r.tool})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:"State"}),s.jsx("div",{className:"ui-stat-v","data-tone":UI(r.state),children:r.state})]}),s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:j?"Expires":"Decided"}),s.jsx("div",{className:"ui-stat-v","data-size":"sm",children:Re(j?r.expiresAt:r.decidedAt,t)})]})]}),s.jsx(re,{message:o}),j?h:null,j?s.jsxs("div",{className:"wb-row-wrap wb-block",children:[s.jsx("button",{className:"ui-btn","data-variant":"good",disabled:u!==null,onClick:()=>x("approve"),children:u==="approve"?"Approving…":w?"Allow once":"Approve"}),w?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","conversation"),children:"Auto: this conversation"}),s.jsx("button",{className:"ui-btn",disabled:u!==null,onClick:()=>x("approve","always"),children:"Always: this agent"})]}):null,s.jsx("button",{className:"ui-btn","data-variant":"danger",disabled:u!==null,onClick:()=>x("reject"),children:u==="reject"?"Rejecting…":"Reject"}),s.jsx("span",{className:"wb-hint",children:w?"Auto-mode and Always also approve future calls to this tool within that scope. Host permissions can be revoked under Host execution.":"This runs the action exactly as printed above."})]}):s.jsxs("p",{className:"muted",children:[r.state," ",r.decidedBy?`by ${r.decidedBy}`:""," ",r.decidedVia?`via ${r.decidedVia}`:""]}),s.jsx("h4",{className:"ui-stat-k wb-label",children:"Preview"}),s.jsxs("div",{className:"wb-doc wb-block","data-clamp":v&&!a?"true":void 0,children:[r.preview||"(this tool wrote no preview)",v&&!a?s.jsx("button",{type:"button",className:"wb-doc-more",onClick:()=>c(!0),children:"Show the whole preview"}):null]}),s.jsxs("details",{className:"ui-details wb-block",children:[s.jsx("summary",{children:"The envelope, field by field"}),s.jsx("dl",{className:"ui-kv",children:b.map(y=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:y.label}),s.jsx("dd",{className:y.mono?"mono":void 0,children:y.value})]},y.label))})]})]})}function zI(e){const t=[],n=e.envelope;if(n!==null&&typeof n=="object"&&!Array.isArray(n))for(const[i,o]of Object.entries(n))t.push({label:Wt(i),value:Wa(o)});else n!=null&&t.push({label:"Envelope",value:Wa(n)});const r=e.canonicalArgs;if(r!==null&&typeof r=="object"&&!Array.isArray(r))for(const[i,o]of Object.entries(r)){const l=`Argument · ${Wt(i)}`;t.some(a=>a.label===l)||t.push({label:l,value:Wa(o)})}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 Wa(e){return e==null?"—":Array.isArray(e)?e.map(t=>Wa(t)).join(", ")||"—":typeof e=="object"?JSON.stringify(e):jt(e,"text",null)}function UI(e){return e==="approved"||e==="executed"?"good":e==="rejected"||e==="expired"?"critical":"warning"}const BI=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function WI(e){return BI.has(e.toLowerCase())}function zr(e){return`/api/artifacts/${encodeURIComponent(e)}/preview`}function xu(e){return`/api/artifacts/${encodeURIComponent(e)}/download`}function An(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 bm(e,t){const n=e.toLowerCase(),r=(t??"").toLowerCase().split(".").pop()??"";return n.startsWith("image/")?"image":n==="application/pdf"?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n==="text/csv"||n==="text/tab-separated-values"||n.includes("spreadsheet")||n.includes("excel")||["csv","tsv","xls","xlsx","numbers"].includes(r)?"table":n.includes("zip")||n.includes("tar")||n.includes("compressed")||["zip","gz","tgz","rar","7z"].includes(r)?"archive":n==="application/json"||n.includes("javascript")||n.includes("xml")||["ts","tsx","js","py","rb","go","rs","swift","json","yaml","yml","toml","sh","sql","html","css"].includes(r)?"code":n.startsWith("text/")||["md","txt","rtf","doc","docx"].includes(r)?"text":"file"}const Rr={image:"Image",pdf:"PDF",table:"Spreadsheet",text:"Document",code:"Code",audio:"Audio",video:"Video",archive:"Archive",file:"File"};function Ha(e){return`artifact:${e}`}function HI(e){const t=bm(e.mime,e.filename);return{id:Ha(e.artifactId),tool:Rr[t],title:e.filename??"Untitled file",renderer:"artifact",props:{attachment:e},at:null,source:"artifact",substantial:!1}}function VI({props:e}){const t=U0(e.artifactId),[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1);if(d.useEffect(()=>{if(t===null)return;let p=!0;return r(null),o(null),a(!1),A.libraryEntry(t).then(f=>{p&&r({filename:f.entry.filename,sizeBytes:f.entry.sizeBytes})}).catch(()=>{}),()=>{p=!1}},[t]),t===null)return s.jsx("p",{className:"wb-empty",children:"This result names no file in the Files library."});const c=e.title??(n==null?void 0:n.filename)??"Image",u=[i?`${i.width} × ${i.height}`:null,n!=null&&n.sizeBytes?An(n.sizeBytes):null].filter(p=>p!==null);return s.jsxs("figure",{className:"wb-image",children:[s.jsx("div",{className:"wb-image-frame",children:l?s.jsx("p",{className:"wb-empty",children:"This file cannot be shown here. Download it to open it."}):s.jsx("a",{href:zr(t),className:"wb-image-link",title:"Open at full size",children:s.jsx("img",{src:zr(t),alt:e.caption??c,onLoad:p=>{const f=p.currentTarget;f.naturalWidth>0&&o({width:f.naturalWidth,height:f.naturalHeight})},onError:()=>a(!0)})})}),s.jsxs("figcaption",{className:"wb-image-caption",children:[s.jsxs(J,{children:[s.jsx("span",{className:"wb-image-name",children:c}),u.length>0?s.jsx("span",{className:"wb-image-facts",children:u.join(" · ")}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Un,{size:"sm",href:xu(t),download:(n==null?void 0:n.filename)??c,children:"Download"})]}),e.caption&&e.captionLabel?s.jsx(wt,{summary:e.captionLabel,className:"wb-image-note",children:s.jsx("p",{className:"wb-image-note-body",children:e.caption})}):e.caption?s.jsx("p",{className:"wb-image-note",children:e.caption}):null]})]})}function KI({props:e}){return e.pairs.length===0?s.jsx("p",{className:"wb-empty",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.pairs.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:"tnum",style:t.tone==="neutral"?void 0:{color:`var(--${t.tone})`},children:jt(t.value,t.unit,t.currency)})]},t.label))})}const GI=8;function X0({text:e,label:t="Output",className:n}){const r=d.useRef(null),i=d.useRef(!0);return d.useLayoutEffect(()=>{const o=r.current;o&&i.current&&(o.scrollTop=o.scrollHeight)},[e]),s.jsx("pre",{ref:r,className:n?`wb-terminal-body ${n}`:"wb-terminal-body","aria-label":t,tabIndex:0,onScroll:o=>{const l=o.currentTarget;i.current=l.scrollHeight-l.scrollTop-l.clientHeight<=GI},children:e})}function YI(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 n=Math.floor(t/60);return`${n} min ${Math.round(t-n*60)} s`}function qI({text:e}){const[t,n]=d.useState("");return s.jsxs(s.Fragment,{children:[t?s.jsx("span",{role:"status",className:"wb-hint",children:t}):null,s.jsx(R,{size:"sm",onClick:()=>{var r;if(n(""),!((r=navigator.clipboard)!=null&&r.writeText)){n("Copy unavailable; select the text to copy.");return}navigator.clipboard.writeText(e).then(()=>n("Copied"),()=>n("Copy failed; select the text to copy."))},children:"Copy"})]})}function QI({props:e}){const t=e.output??"";return s.jsxs("div",{className:"wb-terminal",children:[s.jsxs(J,{className:"wb-terminal-head",children:[e.command!==null?s.jsx("code",{className:"wb-terminal-command",title:e.command,children:e.command}):null,e.exitCode!==null?s.jsxs(pe,{tone:e.exitCode===0?"good":"critical",mono:!0,children:["exit ",e.exitCode]}):null,e.elapsedMs!==null?s.jsx("span",{className:"wb-terminal-fact",children:YI(e.elapsedMs)}):null,s.jsx("span",{className:"ui-toolbar-spacer"}),t!==""?s.jsx(qI,{text:t}):null]}),e.omittedBytes!==null?s.jsxs("p",{className:"wb-terminal-note",children:["First ",An(e.omittedBytes)," not shown."]}):null,t!==""?s.jsx(X0,{text:t}):s.jsx("p",{className:"wb-empty",children:"No output."}),e.metadata.length>0?s.jsx("dl",{className:"ui-kv wb-terminal-facts",children:e.metadata.map(n=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:n.label}),s.jsx("dd",{children:jt(n.value,n.unit,null)})]},n.label))}):null]})}function JI(){const e=window.location.hostname.replace(/^\[|\]$/g,"").toLowerCase();return e==="127.0.0.1"||e==="::1"||e==="localhost"}function yv(e){try{const t=new URL(e);return t.searchParams.delete("ticket"),t.toString()}catch{return e}}function XI(e){const t=new Set(e.ports??[]);return e.port!==null&&t.add(e.port),[...t].sort((n,r)=>n-r)}function ZI({props:e}){var k;const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=((k=e.target)==null?void 0:k.plugin)??null,p=XI(e),[f,h]=d.useState(null),x=f!==null&&p.includes(f)?f:e.port,j=e.target?x!==null&&x!==e.port?`${e.target.name}.${x}`:e.target.name:null,w=e.changes??0,b=d.useRef(w),[v,m]=d.useState(0);d.useEffect(()=>{w<=b.current||(b.current=w,e.reloadsItself||m(S=>S+1))},[w,e.reloadsItself]),d.useEffect(()=>{if(u===null||j===null)return;let S=!0;return n(null),i(null),l(null),m(0),A.previewLink(u,j).then(N=>{S&&(n(N.url),i(yv(N.url)))}).catch(N=>{S&&l(N instanceof Error?N.message:"That preview could not be opened.")}),()=>{S=!1}},[u,j]);const y=()=>{u===null||j===null||A.previewLink(u,j).then(S=>i(S.url)).catch(()=>{})};if(e.target===null)return s.jsxs("p",{className:"wb-empty",children:["This panel names no preview. A preview is ",s.jsx("code",{children:"/preview/<plugin>/<name>/"}),", and nothing else is framed here."]});const g=!(e.output===null||e.output==="");return s.jsxs("div",{className:"wb-preview","data-output":a||void 0,children:[s.jsxs("div",{className:"wb-row wb-preview-head",children:[e.title?s.jsx("h4",{className:"wb-doc-title",children:e.title}):null,p.length>1?s.jsx("select",{className:"wb-preview-port","aria-label":"Port",title:"The ports this process is listening on.",value:x??"",onChange:S=>h(Number(S.target.value)),children:p.map(S=>s.jsxs("option",{value:S,children:[":",S]},S))}):null,g?s.jsx("button",{type:"button",className:"ui-btn wb-preview-toggle","data-variant":"ghost","data-size":"sm","aria-pressed":a,onClick:()=>c(S=>!S),children:a?"Hide output":"Output"}):null,r?s.jsx("a",{className:"wb-preview-open",href:r,target:"_blank",rel:"noreferrer noopener",onPointerEnter:y,onFocus:y,title:"Through buddi: works from anywhere the dashboard does, including the tailnet.",children:"Open in a tab"}):null,x!==null&&JI()?s.jsxs("a",{className:"wb-preview-direct",href:`http://localhost:${x}/`,target:"_blank",rel:"noreferrer noopener",title:"The process itself, on this machine only.",children:["localhost:",x]}):null]}),s.jsxs("div",{className:"wb-preview-body",children:[t?s.jsx("iframe",{className:"wb-preview-frame",src:v===0?t:yv(t),title:e.title??"Preview",sandbox:"allow-scripts allow-forms allow-same-origin allow-modals allow-downloads"},v):s.jsx("p",{className:"wb-empty wb-preview-frame",children:o??"Opening the preview…"}),g&&a?s.jsx(X0,{text:e.output??"",className:"wb-preview-output"}):null]})]})}const eM=50,tM=9,nM=24,sM=.6,rM=48,iM=/(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,oM=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}|$)/,lM=/^id$|(^|[a-z0-9])Id$|_id$/;function ji(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function pn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Z0(...e){for(const t of e)if(pn(t))for(const n of["currency","currencyCode"]){const r=t[n];if(typeof r=="string"&&/^[A-Za-z]{3}$/.test(r))return r.toUpperCase()}return null}function ek(e,t,n){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))?n!==null&&iM.test(e)?"currency":"number":r.every(i=>typeof i=="string"&&oM.test(i))?"date":"text"}function aM(e,t){if(!lM.test(e))return!1;const n=t.filter(r=>!io(r));return n.length<2?!1:new Set(n.map(r=>String(r))).size===n.length}function io(e){return e==null||e===""?!0:Array.isArray(e)?e.length===0:pn(e)?Object.keys(e).length===0:!1}function wv(e,t){const n=e.filter(pn);if(n.length===0||n.length/e.length<.8)return null;const r=n.slice(0,eM),i=new Map,o=[];for(const p of r)for(const f of Object.keys(p))i.has(f)||o.push(f),i.set(f,(i.get(f)??0)+1);if(i.size===0||i.size>nM||[...i.values()].reduce((p,f)=>p+f,0)/(i.size*r.length)<sM)return null;const a=[...i.keys()].sort((p,f)=>{const h=(i.get(f)??0)-(i.get(p)??0);return h!==0?h:o.indexOf(p)-o.indexOf(f)}),c=[],u=[];for(const p of a){const f=r.map(w=>w[p]),h=f.filter(w=>!io(w));if(h.length===0||aM(p,f))continue;const x=Z0(r[0],t),j=ek(p,f,x);if(r.length>=4&&h.length===f.length&&f.every(w=>ji(w)&&w===f[0])){u.push({label:Wt(p),value:f[0],type:j,currency:x});continue}if(c.push({key:p,label:Wt(p),type:j,currency:j==="currency"?x:null}),c.length===tM)break}return c.length===0?null:{columns:c,rows:n,constants:u}}function cM(e,t,n){const r=Z0(n);return{label:Wt(e),value:t,type:ek(e,[t],r),currency:r}}function tk(e){return typeof e=="string"&&e.length>rM}function uM(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.":pn(e)&&Object.keys(e).length===0?"This tool returned an empty result.":null}function uh(e){if(typeof e=="string"&&e.trim()!=="")return e;if(pn(e))for(const t of["message","error","reason","detail","description"]){const n=e[t];if(typeof n=="string"&&n.trim()!=="")return n;if(pn(n)){const r=uh(n);if(r!=="The call failed with no reason given.")return r}}return"The call failed with no reason given."}function km(e,t={}){if(t.failed){let f=e;if(typeof e=="string")try{const h=JSON.parse(e.replace(/^tool-error:\s*/,""));pn(h)&&(f=h)}catch{}return{kind:"error",summary:uh(f),detail:bv(f)}}if(pn(e)){const f=e.error,h=e.ok;if(typeof f=="string"&&f.trim()!==""||h===!1)return{kind:"error",summary:uh(e),detail:bv(e)}}const n=uM(e);if(n)return{kind:"empty",note:n,stats:[]};if(Array.isArray(e)){const f=wv(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(ji)?{kind:"list",label:null,items:e,total:e.length,stats:[],notes:[],asides:[]}:{kind:"tree",value:e}}if(!pn(e))return{kind:"tree",value:e};const r=Object.entries(e);let i=null,o=null;for(const[f,h]of r){if(!Array.isArray(h))continue;const x=wv(h,e);if(x){(!i||x.rows.length>i.candidate.rows.length)&&(i={key:f,candidate:x});continue}h.length>0&&h.every(ji)&&(!o||h.length>o.items.length)&&(o={key:f,items:h})}const l=(i==null?void 0:i.key)??(o==null?void 0:o.key)??null,a=[],c=[],u=[];for(const[f,h]of r)if(f!==l){if(tk(h)){c.push(h);continue}if(ji(h)){if(h==="")continue;a.push(cM(f,h,e));continue}h!==void 0&&u.push({label:Wt(f),value:h})}if(i)return{kind:"table",label:Wt(i.key),columns:i.candidate.columns,rows:i.candidate.rows,total:i.candidate.rows.length,stats:[...a,...i.candidate.constants],notes:c,asides:u};if(o)return{kind:"list",label:Wt(o.key),items:o.items,total:o.items.length,stats:a,notes:c,asides:u};const p=r.filter(([,f])=>Array.isArray(f)&&f.length===0);return p.length>0&&p.length===r.filter(([,f])=>Array.isArray(f)).length?{kind:"empty",note:`No ${p.map(([h])=>Wt(h).toLowerCase()).join(", ")} to show.`,stats:a}:r.every(([,f])=>ji(f)||pn(f)||Array.isArray(f))?{kind:"record",pairs:a,notes:c,asides:u}:{kind:"tree",value:e}}function bv(e){if(!pn(e))return null;const t=Object.entries(e).filter(([n])=>n!=="message"&&n!=="error");return t.length===0?null:Object.fromEntries(t)}const Ec=25,dM=3,dh=8,nk=6;function fh(e,t=0){if(t>nk||io(e)||tk(e))return 0;if(ji(e))return 1;if(Array.isArray(e)){let n=0;for(const r of e)if(n+=fh(r,t+1),n>=dh)return n;return n}if(pn(e)){let n=0;for(const r of Object.values(e))if(n+=fh(r,t+1),n>=dh)return n;return n}return 0}function hh(e,t=0){if(t>nk)return!1;if(Array.isArray(e))return e.some(o=>hh(o,t+1));if(!pn(e))return!1;const n=e.artifactId??e.artifact_id;if(typeof n=="string"&&n.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(o=>hh(o,t+1))}function fM(e){if(hh(e))return!0;const t=km(e);switch(t.kind){case"table":return t.rows.length>0;case"list":return t.items.length>=dM;case"record":case"tree":return fh(e)>=dh;default:return!1}}function vd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Sm(e){const t=vd(e);if(!t)return null;const n=vd(t.output)??t;if(typeof n.state!="string"||typeof n.stdout!="string"||typeof n.stderr!="string"||!(n.exitCode===null||typeof n.exitCode=="number"&&Number.isFinite(n.exitCode)))return null;const r=n===t?null:vd(t.input),i=(r==null?void 0:r.command)??n.command;return{command:typeof i=="string"?i:null,input:r,result:n}}function hM({text:e,label:t}){const[n,r]=d.useState("");return s.jsxs("span",{className:"wb-command-copy",children:[s.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}),n&&s.jsx("span",{role:"status",className:"wb-hint",children:n})]})}function jd({title:e,text:t,error:n=!1}){return s.jsxs("section",{className:"wb-command-stream","data-error":n||void 0,children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("h4",{children:e}),s.jsx(hM,{text:t,label:`Copy ${e.toLowerCase()}`})]}),s.jsx("pre",{className:"wb-command-text","aria-label":e,tabIndex:0,children:t})]})}function pM({value:e,children:t}){const{result:n,command:r,input:i}=e,o=n.state==="completed"&&n.exitCode!==null&&n.exitCode!==0,l=typeof n.signal=="string"&&n.signal?n.signal:null,a=n.state==="completed"&&n.exitCode===0,c=Object.fromEntries(Object.entries(n).filter(([p,f])=>!["stdout","stderr","state","exitCode","artifacts","outputErrors","command"].includes(p)&&f!==null&&f!==void 0&&f!=="")),u=Array.isArray(n.outputErrors)?n.outputErrors.filter(p=>typeof p=="string"):[];return s.jsxs("div",{className:"wb-command-result",children:[s.jsxs("div",{className:"wb-command-bar",children:[s.jsx("span",{className:"ui-pill","data-tone":a?"good":"critical",children:o?"Failed":n.state==="completed"&&l?"Terminated":n.state}),n.exitCode!==null&&s.jsxs("span",{className:"mono",children:["Exit code ",n.exitCode]}),l&&s.jsxs("span",{className:"mono",children:["Signal ",l]}),s.jsx("span",{className:"wb-hint",children:"Recorded command result"})]}),r!==null&&s.jsx(jd,{title:"Command",text:r}),n.state==="output-limit"&&s.jsx("p",{className:"wb-fail",children:"Output limit reached. The command was stopped and the captured output may be incomplete."}),n.state==="timed-out"&&s.jsx("p",{className:"wb-fail",children:"The command exceeded its time limit. Output below may be partial."}),n.state==="cancelled"&&s.jsx("p",{className:"wb-note",children:"The command was cancelled. Completed changes were not undone."}),n.stdout?s.jsx(jd,{title:"Output",text:n.stdout}):s.jsx("p",{className:"wb-note",children:"No standard output."}),n.stderr?s.jsx(jd,{title:"Standard error",text:n.stderr,error:!0}):null,u.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"File export errors"}),u.map((p,f)=>s.jsx("p",{className:"wb-fail",children:p},f))]}),t,(Object.keys(c).length>0||i!==null)&&s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Execution details"}),s.jsx("pre",{children:on({...c,...i?{input:i}:{}})})]})]})}const ca=2,kv=64;function mM({props:e}){const[t,n]=d.useState(!1),r=Sm(e.value),i=gM((r==null?void 0:r.result)??e.value),o=d.useMemo(()=>km(e.value,{failed:e.failed??!1}),[e.value,e.failed]);return s.jsxs("div",{children:[!r&&s.jsx(Sv,{files:i}),t?s.jsx("pre",{className:"ui-code",children:on(e.value)}):r?s.jsx(pM,{value:r,children:i.length>0&&s.jsxs("section",{children:[s.jsx("h4",{children:"Generated files"}),s.jsx(Sv,{files:i})]})}):i.length?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"Tool details"}),s.jsx(Nv,{shape:o})]}):s.jsx(Nv,{shape:o}),s.jsx("div",{className:"wb-row-end wb-section",children:s.jsx("button",{className:"ui-btn","data-variant":"ghost","data-size":"sm",onClick:()=>n(l=>!l),"aria-pressed":t,children:t?"Readable":"Raw JSON"})})]})}function gM(e){const t=e&&typeof e=="object"&&"artifacts"in e?e.artifacts:null;return Array.isArray(t)?t.filter(n=>n&&typeof n.id=="string"&&/^[0-9a-f-]{36}$/i.test(n.id)&&typeof n.filename=="string"):[]}function Sv({files:e}){return e.length?s.jsx("div",{className:"wb-artifacts",children:e.map(t=>{var n;return s.jsxs("div",{children:[["image/png","image/jpeg","image/gif","image/webp"].includes(t.mime??"")?s.jsx(xM,{file:t}):null,s.jsx("a",{className:"ui-btn",href:`/api/artifacts/${encodeURIComponent(t.id)}/download`,download:!0,children:(n=t.mime)!=null&&n.startsWith("image/")?`Download ${t.filename}`:t.filename})]},t.id)})}):null}function xM({file:e}){const[t,n]=d.useState(!1);return t?s.jsx("p",{className:"wb-note",children:"Preview unavailable. You can still download the file."}):s.jsx("img",{className:"wb-artifact-image",src:`/api/artifacts/${e.id}/preview`,alt:e.filename,onError:()=>n(!0)})}function Nv({shape:e}){switch(e.kind){case"error":return s.jsxs("div",{children:[s.jsx("p",{className:"wb-fail",role:"status",children:e.summary}),e.detail===null?null:s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:"What came back with it"}),s.jsx("div",{className:"wb-tree",children:dl(e.detail,1)})]})]});case"empty":return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx("p",{className:"wb-note",children:e.note})]});case"table":{const t=kM(e.columns,e.rows);return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx(wd,{notes:e.notes}),t?s.jsx(SM,{label:e.label,plan:t,rows:e.rows,total:e.total}):s.jsx(jM,{label:e.label,columns:e.columns,rows:e.rows,total:e.total}),s.jsx(bd,{asides:e.asides})]})}case"list":return s.jsxs("div",{children:[s.jsx(yd,{stats:e.stats}),s.jsx(wd,{notes:e.notes}),e.label?s.jsx("h4",{className:"wb-sub",children:e.label}):null,s.jsx("ul",{className:"wb-list",children:e.items.slice(0,100).map((t,n)=>s.jsx("li",{children:jt(t,"text",null)},n))}),e.total>100?s.jsxs("p",{className:"wb-note",children:["Showing 100 of ",e.total,"."]}):null,s.jsx(bd,{asides:e.asides})]});case"record":return s.jsxs("div",{children:[s.jsx(wd,{notes:e.notes}),s.jsx(vM,{pairs:e.pairs}),s.jsx(bd,{asides:e.asides})]});default:return s.jsx("div",{className:"wb-tree",children:dl(e.value,0)})}}function yd({stats:e}){return e.length===0?null:s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.map(t=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:t.label}),s.jsx("div",{className:"ui-stat-v",children:Nm(t.value,t.type,t.currency)})]},t.label))})}const Cv=200;function wd({notes:e}){if(e.length===0)return null;const t=e.filter(r=>r.length<=Cv),n=e.filter(r=>r.length>Cv);return s.jsxs(s.Fragment,{children:[t.map(r=>s.jsx("p",{className:"wb-note",children:r},r)),n.length>0?s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:n.length===1?"A note that came with this result":`${n.length} notes that came with this result`}),n.map(r=>s.jsx("p",{className:"wb-note",children:r},r))]}):null]})}function vM({pairs:e}){return e.length===0?s.jsx("p",{className:"wb-note",children:"Nothing to show."}):s.jsx("dl",{className:"ui-kv",children:e.map(t=>s.jsxs("div",{className:"contents",children:[s.jsx("dt",{children:t.label}),s.jsx("dd",{className:t.type==="text"?void 0:"tnum",children:Nm(t.value,t.type,t.currency)})]},t.label))})}function bd({asides:e}){return e.length===0?null:s.jsx("div",{className:"wb-section",children:e.map(t=>s.jsxs("details",{className:"wb-aside",children:[s.jsx("summary",{children:t.label}),s.jsx("div",{className:"wb-tree",children:dl(t.value,1)})]},t.label))})}function jM({label:e,columns:t,rows:n,total:r}){const[i,o]=d.useState(!1),l=r<=Ec+5?r:Ec,a=i?n:n.slice(0,l);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.map(c=>s.jsx("th",{className:rk(c.type)?"num":void 0,children:c.label},c.key))})}),s.jsx("tbody",{children:a.map((c,u)=>s.jsx("tr",{children:t.map(p=>s.jsx(NM,{value:c[p.key],column:p},p.key))},u))})]})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}const yM=/^(title|name|headline|subject|label|heading)$/i,wM=/^(url|link|href|uri|permalink)$/i;function Ac(e){return typeof e=="string"&&/^https?:\/\/[^\s]+$/i.test(e.trim())}function bM(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function sk(e,t=48){try{const n=new URL(e),r=n.pathname==="/"?"":n.pathname,i=`${n.hostname.replace(/^www\./,"")}${r}${n.search}`;return i.length>t?`${i.slice(0,t-1)}…`:i}catch{return e.length>t?`${e.slice(0,t-1)}…`:e}}function ua(e,t){const n=e.map(r=>r[t]).filter(r=>typeof r=="string"&&r.trim()!=="");return n.length===0?0:n.reduce((r,i)=>r+i.length,0)/n.length}function kM(e,t){if(t.length===0)return null;const n=e.filter(p=>p.type==="text"),r=n.find(p=>wM.test(p.key)&&t.some(f=>Ac(f[p.key])))??n.find(p=>{const f=t.map(h=>h[p.key]).filter(h=>!io(h));return f.length>0&&f.filter(Ac).length/f.length>=.6});if(!r)return null;const i=n.filter(p=>p.key!==r.key),o=i.find(p=>yM.test(p.key))??i.find(p=>ua(t,p.key)>0);if(!o)return null;const a=[...i.filter(p=>p.key!==o.key)].sort((p,f)=>ua(t,f.key)-ua(t,p.key)),c=a[0]&&ua(t,a[0].key)>40?a[0]:null,u=e.filter(p=>p.key!==r.key&&p.key!==o.key&&p.key!==(c==null?void 0:c.key)).map(p=>p.key);return{url:r.key,title:o.key,description:(c==null?void 0:c.key)??null,meta:u}}function SM({label:e,plan:t,rows:n,total:r}){const[i,o]=d.useState(!1),l=r<=Ec+5?r:Ec,a=i?n:n.slice(0,l);return s.jsxs("div",{children:[e?s.jsx("h4",{className:"wb-sub",children:e}):null,s.jsx("ol",{className:"wb-records",children:a.map((c,u)=>{const p=c[t.url],f=Ac(p)?p.trim():null,h=typeof c[t.title]=="string"&&c[t.title].trim()!==""?c[t.title]:f?sk(f):"Untitled",x=t.description&&typeof c[t.description]=="string"?c[t.description]:null,j=f?bM(f):null,w=t.meta.map(b=>c[b]).filter(b=>!io(b)&&typeof b!="object").map(b=>String(b)).filter(b=>j===null||b.replace(/^www\./,"")!==j);return s.jsxs("li",{className:"wb-record",children:[f?s.jsx("a",{className:"wb-record-title",href:f,target:"_blank",rel:"noopener noreferrer",children:h}):s.jsx("span",{className:"wb-record-title",children:h}),s.jsxs("div",{className:"wb-record-meta",children:[j?s.jsx("span",{className:"wb-record-host",title:f??void 0,children:j}):null,w.map((b,v)=>s.jsx("span",{children:b.length>60?`${b.slice(0,59)}…`:b},v))]}),x?s.jsx("p",{className:"wb-record-desc",children:x.length>280?`${x.slice(0,279)}…`:x}):null]},u)})}),r>a.length?s.jsxs("p",{className:"wb-note wb-note-row",children:[s.jsxs("span",{children:["Showing ",a.length," of ",r]}),s.jsxs("button",{className:"ui-btn",onClick:()=>o(!0),children:["Show all ",r]})]}):null]})}function NM({value:e,column:t}){if(io(e))return s.jsx("td",{className:"wb-cell-soft",children:"—"});if(Ac(e)){const i=e.trim();return s.jsx("td",{className:"wb-cell-link",children:s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:i,children:sk(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 s.jsx("td",{className:"wb-cell-soft",title:on(e),children:i})}const n=Nm(e,t.type,t.currency),r=n.length>kv?`${n.slice(0,kv-1)}…`:n;return s.jsx("td",{className:rk(t.type)?"num":"wb-cell-text",...r===n?{}:{title:n},children:r})}function rk(e){return e==="number"||e==="currency"}function Nm(e,t,n){return e==null?"—":t==="boolean"?e?"yes":"no":jt(e,t==="text"?"text":t,n)}function dl(e,t){if(e===null)return s.jsx("span",{className:"wb-tree-null",children:"null"});if(e===void 0)return s.jsx("span",{className:"wb-tree-null",children:"—"});if(typeof e=="number")return s.jsx("span",{className:"wb-tree-num",children:e});if(typeof e=="boolean")return s.jsx("span",{className:"wb-tree-bool",children:e?"true":"false"});if(typeof e=="string")return s.jsx("span",{children:e===""?s.jsx("em",{className:"wb-tree-null",children:"empty"}):e});if(Array.isArray(e)){if(e.length===0)return s.jsx("span",{className:"wb-tree-null",children:"none"});const i=s.jsxs("div",{className:"wb-tree-branch",children:[e.slice(0,50).map((o,l)=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[l,". "]}),dl(o,t+1)]},l)),e.length>50?s.jsxs("div",{className:"wb-tree-key",children:["…and ",e.length-50," more"]}):null]});return t>=ca?s.jsx(Ev,{summary:`${e.length} items`,open:t===ca,children:i}):i}const n=Object.entries(e);if(n.length===0)return s.jsx("span",{className:"wb-tree-null",children:"empty"});const r=s.jsx("div",{className:t===0?void 0:"wb-tree-branch",children:n.map(([i,o])=>s.jsxs("div",{children:[s.jsxs("span",{className:"wb-tree-key",children:[Wt(i),": "]}),dl(o,t+1)]},i))});return t>=ca?s.jsx(Ev,{summary:`${n.length} fields`,open:t===ca,children:r}):r}function Ev({summary:e,open:t,children:n}){return s.jsxs("details",{open:t,children:[s.jsx("summary",{className:"wb-tree-key",children:e}),n]})}function CM({props:e}){const t=e.groups.every(n=>n.rows.length===0);return s.jsxs("div",{children:[e.summary.length>0?s.jsx("div",{className:"ui-stats","data-inline":"true",children:e.summary.map(n=>s.jsxs("div",{children:[s.jsx("div",{className:"ui-stat-k",children:n.label}),s.jsx("div",{className:"ui-stat-v","data-tone":n.tone,children:jt(n.value,n.unit,n.currency)})]},n.label))}):null,t?s.jsx("p",{className:"wb-empty",children:e.empty}):e.groups.map((n,r)=>s.jsxs("div",{className:r>0?"wb-section":void 0,children:[n.label?s.jsx("h4",{className:"ui-stat-k wb-label",children:n.label}):null,s.jsx("div",{className:"ui-table-wrap",children:s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.columns.map(i=>s.jsx("th",{className:ik(i.type)?"num":void 0,"data-type":i.type,children:i.label},i.key))})}),s.jsx("tbody",{children:n.rows.map((i,o)=>s.jsx("tr",{children:i.map((l,a)=>{var c;return s.jsx(EM,{cell:l},((c=e.columns[a])==null?void 0:c.key)??a)})},o))})]})})]},n.label??r))]})}function EM({cell:e}){const t=jt(e.value,e.type,e.currency);return e.bar?s.jsx("td",{className:"num",children:s.jsxs("div",{className:"wb-row wb-row-end",children:[s.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:s.jsx("div",{className:"ui-meter-fill","data-tone":e.bar.tone,style:{width:`${Math.round(e.bar.fraction*100)}%`}})}),s.jsx("span",{className:"tnum",children:t})]})}):s.jsx("td",{className:ik(e.type)?"num":void 0,"data-type":e.type,title:t.length>40?t:void 0,children:t})}function ik(e){return e==="number"||e==="currency"||e==="percent"}const ri=760,kd=400,tt={top:18,right:18,bottom:36,left:66},AM=5;function TM({props:e}){const{points:t,referenceLines:n,unit:r,currency:i}=e;if(t.length===0)return s.jsx("p",{className:"wb-empty",children:"This result carried no points to plot."});const o=[...t.map(g=>g.y),...n.map(g=>g.value)],l=Math.min(...o),a=Math.max(...o),c=a-l||Math.abs(a)||1,u=l-c*.08,p=a+c*.08,f=ri-tt.left-tt.right,h=kd-tt.top-tt.bottom,x=g=>tt.left+(t.length===1?f/2:g/(t.length-1)*f),j=g=>tt.top+h-(g-u)/(p-u)*h,w=i2(l,a,4),b=PM(t.map(g=>g.y),e.mark),v=e.shadeBelow===null?[]:IM(t.map(g=>g.y),e.shadeBelow),m=t.map((g,k)=>`${k===0?"M":"L"}${x(k)},${j(g.y)}`).join(" "),y=g=>jt(g,r,i);return s.jsxs("div",{children:[e.label?s.jsx("p",{className:"ui-panel-sub",children:e.label}):null,s.jsxs("div",{className:"wb-chart-layout",children:[s.jsx("div",{className:"wb-chart-plot",children:s.jsxs("svg",{className:"wb-chart",viewBox:`0 0 ${ri} ${kd}`,role:"img","aria-label":RM(e,y),preserveAspectRatio:"xMidYMid meet",children:[v.map(g=>s.jsx("rect",{className:"wb-chart-breach",x:x(g.from),width:Math.max(2,x(g.to)-x(g.from)),y:tt.top,height:h},`band-${g.from}`)),w.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-grid",x1:tt.left,x2:ri-tt.right,y1:j(g),y2:j(g)}),s.jsx("text",{x:tt.left-8,y:j(g)+4,textAnchor:"end",children:y(g)})]},`tick-${g}`)),n.map(g=>s.jsxs("g",{children:[s.jsx("line",{className:"wb-chart-floor",x1:tt.left,x2:ri-tt.right,y1:j(g.value),y2:j(g.value)}),s.jsxs("text",{x:ri-tt.right,y:j(g.value)-6,textAnchor:"end",children:[g.label," ",y(g.value)]})]},`rule-${g.label}`)),s.jsx("line",{className:"wb-chart-axis",x1:tt.left,x2:tt.left,y1:tt.top,y2:tt.top+h}),s.jsx("line",{className:"wb-chart-axis",x1:tt.left,x2:ri-tt.right,y1:tt.top+h,y2:tt.top+h}),s.jsx("path",{className:"wb-chart-series",d:m}),b!==null?s.jsxs("g",{children:[s.jsx("circle",{className:"wb-chart-min",cx:x(b),cy:j(t[b].y),r:4.5}),s.jsx("text",{x:x(b),y:j(t[b].y)+20,textAnchor:"middle",children:y(t[b].y)})]}):null,MM(t.length).map(g=>s.jsx("text",{x:x(g),y:kd-10,textAnchor:"middle",children:iv(t[g].x)},`x-${g}`))]})}),e.events.length>0?s.jsxs("aside",{className:"wb-chart-events",children:[s.jsx("h4",{className:"ui-stat-k wb-label",children:"What happens"}),s.jsx("ul",{className:"wb-chart-event-list",children:e.events.map((g,k)=>s.jsxs("li",{className:"wb-chart-event",children:[s.jsxs("span",{children:[s.jsx("span",{className:"wb-chart-event-day",children:iv(g.at)}),g.label]}),g.amount===null?null:s.jsx("span",{className:g.amount<0?"tnum critical":"tnum good",children:jt(g.amount,r,i)})]},`${g.at}-${g.label}-${k}`))})]}):null]})]})}function RM(e,t){const n=e.points.map(l=>l.y),r=e.points[0],i=e.points[e.points.length-1],o=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(...n))}, high ${t(Math.max(...n))}`,o].filter(Boolean).join("; ")}function PM(e,t){if(!t||e.length===0)return null;let n=0;for(let r=1;r<e.length;r+=1)(t==="min"?e[r]<e[n]:e[r]>e[n])&&(n=r);return n}function IM(e,t){const n=[];let r=null;return e.forEach((i,o)=>{i<t?r===null&&(r=o):r!==null&&(n.push({from:r,to:o}),r=null)}),r!==null&&n.push({from:r,to:e.length-1}),n}function MM(e,t=AM){if(e<=0)return[];if(e<=t)return[...Array(e).keys()];const n=e-1,r=new Set;for(let i=0;i<t;i+=1)r.add(Math.round(i/(t-1)*n));return[...r].sort((i,o)=>i-o)}const In=e=>e,ph={timeseries:In(TM),table:In(CM),bars:In(o2),keyvalue:In(KI),document:In(sI),diff:In(f2),terminal:In(QI),image:In(VI),preview:In(ZI),envelope:In(FI),structured:In(mM)},$M="structured";function _M(e){return(Tc(e)?ph[e]:void 0)??ph[$M]}function Tc(e){return Object.prototype.hasOwnProperty.call(ph,e)}function OM({renderer:e,props:t,timezone:n,onDecided:r}){const i=_M(e),l=Tc(e)?t:{value:t};return s.jsx(i,{props:l,timezone:n,onDecided:r})}function DM({profile:e,onChange:t}){return s.jsxs("div",{className:"wb-prof","data-testid":"agent-profile",children:[s.jsx("p",{className:"wb-prof-lead",children:e.description}),s.jsxs("div",{className:"wb-prof-tags",children:[e.isDefault?s.jsx(Sd,{children:"Opens by default"}):null,s.jsx(Sd,{children:e.source==="example"?"Shipped with buddi":"Yours"}),e.roles.map(n=>s.jsx(Sd,{title:`A surface command that asks for "${n}" lands on this agent.`,children:Wt(n)},n))]}),e.available?null:s.jsxs("p",{className:"wb-prof-blocked","data-testid":"agent-profile-unavailable",children:[s.jsx("strong",{children:"This agent cannot run here."})," ",e.unavailableReason]}),s.jsx(bo,{title:"How it works with you",note:"Live decisions stay in the conversation; this page explains the standing rules.",children:s.jsxs("ul",{className:"wb-prof-list",children:[s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Quick questions"}),s.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."})]}),s.jsx("span",{className:"wb-prof-auto",children:"Answers only"})]}),s.jsxs("li",{className:"wb-prof-row","data-gated":"true",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name",children:"Action approvals"}),s.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."})]}),s.jsxs("span",{className:"wb-prof-gate",children:[s.jsx(ok,{}),"Exact action"]})]})]})}),s.jsx(bo,{title:"What it can do",note:LM(e),tone:e.gatedCount>0?"warning":void 0,children:e.tools.length===0?s.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((n,r)=>+(r.gated>0)-+(n.gated>0)).map(n=>s.jsx(FM,{family:n},n.family))}),s.jsx(bo,{title:"What it runs on",children:s.jsxs("dl",{className:"wb-prof-kv",children:[s.jsx(ko,{label:"Provider",children:e.engine.provider}),s.jsx(ko,{label:"Model",children:s.jsx("span",{className:"mono",children:e.engine.model})}),s.jsxs(ko,{label:"Credential",children:[e.engine.credentialKind," from"," ",s.jsx("span",{className:"mono",children:e.engine.credentialEnv})]}),s.jsxs(ko,{label:"Turn budget",children:[e.engine.maxTurns," ",e.engine.maxTurns===1?"turn":"turns"," per message"]}),s.jsx(ko,{label:"Language",children:HM(e.engine.language)})]})}),e.skills.length>0?s.jsx(bo,{title:"What it has read",note:`${e.skills.length} ${e.skills.length===1?"skill":"skills"}, composed into every run`,children:s.jsx("ul",{className:"wb-prof-list",children:e.skills.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:n.name}),n.description?s.jsx("span",{className:"wb-prof-row-desc",children:n.description}):null]}),s.jsxs("span",{className:"wb-prof-row-side",title:n.file,children:[n.scope==="private"?"its own":"shared"," · ",n.provenance]})]},n.file))})}):null,e.delegates.length>0?s.jsx(bo,{title:"Who it can hand work to",note:"A colleague's tools are reached through the colleague, never held here",children:s.jsx("ul",{className:"wb-prof-list",children:e.delegates.map(n=>s.jsxs("li",{className:"wb-prof-row",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsxs("span",{className:"wb-prof-row-name mono",children:["@",n.handle]}),s.jsx("span",{className:"wb-prof-row-desc",children:n.description})]}),s.jsx("span",{className:"wb-prof-row-side",children:n.available?n.name:`${n.name} · cannot run`})]},n.id))})}):null,s.jsxs("footer",{className:"wb-prof-foot",children:[s.jsx("p",{className:"wb-prof-note",children:e.note}),s.jsx("p",{className:"wb-prof-file mono",title:e.file,children:e.file}),e.changeVia&&t?s.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 LM(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 n=e.gatedCount===1?"one of them stops and waits for you":`${e.gatedCount} of them stop and wait for you`;return`${t}, and ${n}.`}function FM({family:e}){const t=[...e.tools].sort((n,r)=>Number(r.gated)-Number(n.gated));return s.jsxs("section",{className:"wb-prof-family",children:[s.jsxs("h4",{className:"wb-prof-family-head",children:[s.jsx("span",{className:"wb-prof-family-name",children:Wt(e.family)}),s.jsxs("span",{className:"wb-prof-family-note",children:[e.tools.length," ",e.tools.length===1?"tool":"tools",e.gated>0?` · ${e.gated} needs you`:""]})]}),s.jsx("ul",{className:"wb-prof-list",children:t.map(n=>s.jsx(zM,{tool:n},n.name))})]})}function zM({tool:e}){return s.jsxs("li",{className:"wb-prof-row","data-gated":e.gated?"true":void 0,"data-testid":"agent-profile-tool",children:[s.jsxs("span",{className:"wb-prof-row-main",children:[s.jsx("span",{className:"wb-prof-row-name mono",children:WM(e.name)}),s.jsx("span",{className:"wb-prof-row-desc","data-clamp":"true",title:e.description,children:e.description})]}),e.gated?s.jsxs("span",{className:"wb-prof-gate",title:"The call is recorded and waits; nothing happens until you approve it.",children:[s.jsx(ok,{}),"Needs your approval"]}):s.jsx("span",{className:"wb-prof-auto",title:BM(e.tier),children:UM(e.tier)})]})}function UM(e){return e==="auto"?"Runs on its own":e==="gated"?"Needs your approval":"Not runnable here"}function BM(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 WM(e){const t=e.split(".");return(t[t.length-1]??e).replace(/_/g," ")}function HM(e){return e==="mirror"?"Mirrors whichever language you write in":e==="en"?"Always English":e==="fr"?"Always French":e}function bo({title:e,note:t,tone:n,children:r}){return s.jsxs("section",{className:"wb-prof-section",children:[s.jsx("h3",{className:"wb-prof-title",children:e}),t?s.jsx("p",{className:"wb-prof-note-lead","data-tone":n,children:t}):null,r]})}function ko({label:e,children:t}){return s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"wb-prof-k",children:e}),s.jsx("dd",{className:"wb-prof-v",children:t})]})}function Sd({children:e,title:t}){return s.jsx("span",{className:"wb-prof-tag",title:t,children:e})}function ok(){return s.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:[s.jsx("rect",{x:"2.8",y:"6",width:"8.4",height:"6.2",rx:"1.4"}),s.jsx("path",{d:"M4.8 6V4.4a2.2 2.2 0 0 1 4.4 0V6"})]})}const Nd=1e5,Cd=200,Ed=30;function lk({artifactId:e,filename:t,mime:n,family:r,available:i=!0}){const[o,l]=d.useState(!1);return i?r==="image"&&!o?s.jsx("figure",{className:"file-preview file-preview-image",children:s.jsx("img",{src:zr(e),alt:t??"Image",onError:()=>l(!0)})}):r==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:zr(e),type:"application/pdf","aria-label":t??"PDF",children:s.jsx(V,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):r==="text"||r==="code"||r==="table"?s.jsx(VM,{artifactId:e,filename:t,mime:n,family:r}):s.jsx(V,{children:"Preview not supported for this kind of file. Download it to open it."}):s.jsx(V,{children:"The file is no longer available; its record is kept."})}function VM({artifactId:e,filename:t,mime:n,family:r}){const[i,o]=d.useState("loading");if(d.useEffect(()=>{let a=!1;return o("loading"),fetch(zr(e),{credentials:"same-origin"}).then(async c=>{if(!c.ok)throw new Error(String(c.status));const u=await c.text();a||o({text:u.slice(0,Nd),truncated:c.headers.get("X-Preview-Truncated")==="1"||u.length>Nd})}).catch(()=>{a||o("failed")}),()=>{a=!0}},[e]),i==="loading")return s.jsx("div",{className:"file-preview",children:s.jsx(ie,{children:"Loading preview…"})});if(i==="failed")return s.jsx(V,{children:"The preview could not be loaded. Download the file to open it."});const l=r==="table"&&(/csv|tab-separated/.test(n)||/\.(csv|tsv)$/i.test(t??""));return s.jsxs("div",{className:"file-preview",children:[l?s.jsx(GM,{text:i.text,delimiter:/tab|\.tsv$/i.test(n+(t??""))?" ":","}):s.jsx("pre",{className:"file-preview-text",children:i.text}),i.truncated?s.jsxs("p",{className:"muted",children:["Showing the first ",Nd.toLocaleString()," characters. The download has the whole file."]}):null]})}function KM(e,t,n,r){const i=[];let o=[],l="",a=!1,c=!1,u=!1;const p=()=>{o.length<r?o.push(l):c=!0,l=""},f=()=>{p(),i.push(o),o=[]};let h=0;for(;h<e.length;h+=1){if(i.length>=n){u=e.slice(h).trim()!=="";break}const x=e[h];if(a){x==='"'?e[h+1]==='"'?(l+='"',h+=1):a=!1:l+=x;continue}if(x==='"'){a=!0;continue}if(x===t){p();continue}if(x!=="\r"){if(x===`
|
|
94
|
-
`){f();continue}l+=x}}return i.length<n&&(l!==""||o.length>0)&&f(),{rows:i,truncatedRows:u,truncatedCols:c}}function GM({text:e,delimiter:t}){const n=d.useMemo(()=>KM(e,t,Cd+1,Ed),[e,t]),[r,...i]=n.rows;if(!r)return s.jsx("p",{className:"muted",children:"The file is empty."});const o=Math.min(Ed,n.rows.reduce((a,c)=>Math.max(a,c.length),0)),l=Array.from({length:o},(a,c)=>c);return s.jsxs("div",{className:"ui-table-wrap file-preview-table",children:[s.jsxs("table",{className:"ui-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:l.map(a=>s.jsx("th",{children:r[a]??""},a))})}),s.jsx("tbody",{children:i.slice(0,Cd).map((a,c)=>s.jsx("tr",{children:l.map(u=>s.jsx("td",{children:a[u]??""},u))},c))})]}),n.truncatedRows||n.truncatedCols?s.jsxs("p",{className:"muted",children:["Showing the first ",Cd," rows",n.truncatedCols?` and ${Ed} columns`:"",". The download has the whole file."]}):null]})}function YM({attachment:e}){const t=bm(e.mime,e.filename),n=e.filename??"Untitled file";return s.jsxs("div",{className:"wb-artifact","data-family":t,"data-testid":"artifact-view",children:[s.jsx(lk,{artifactId:e.artifactId,filename:e.filename??null,mime:e.mime,family:t}),s.jsxs("dl",{className:"ui-kv",children:[s.jsx("dt",{children:"Type"}),s.jsxs("dd",{children:[Rr[t],s.jsx("span",{className:"wb-artifact-mime mono",children:e.mime})]}),e.sizeBytes?s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:An(e.sizeBytes)})]}):null,s.jsx("dt",{children:"Id"}),s.jsx("dd",{className:"mono",children:e.artifactId})]}),s.jsx("div",{className:"ui-toolbar","data-align":"end",children:s.jsx("a",{className:"ui-btn",href:xu(e.artifactId),download:n,children:"Download"})})]})}const Av=80,qM=["query","path","url","dir"],QM=["message","task"];function Cm(e,t){const n=JM(t);if(!n)return null;const r=ii(n.command);if(r!==null){const l=ii(n.name);return da(l===null?r:`${l}: ${r}`)}for(const l of qM){const a=ii(n[l]);if(a!==null)return da(a)}const i=ii(n.action);if(i!==null){const l=QM.map(a=>ii(n[a])).find(a=>a!==null)??null;return da(l===null?i:`${i} · ${l}`)}const o=Object.values(n).filter(l=>typeof l=="string");return o.length===1?da(ii(o[0])):null}function ii(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t===""?null:t}function da(e){return e===null?null:e.length>Av?`${e.slice(0,Av-1)}…`:e}function JM(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Rc="agent.delegate";function XM(e){if(e===null||typeof e!="object")return null;const t=e,n=t.conversationId;if(typeof n!="string"||n==="")return null;const r=t.agentId??t.agent;return{conversationId:n,agentId:typeof r=="string"?r:"",runId:typeof t.runId=="string"?t.runId:null}}function ZM(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 mh="canvas.show",Tv="canvas.clear",Rv=12;function Ai(e){return`${e.plugin}/${e.name}`}function e$(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const t=e.diff;return typeof t=="string"&&t.trim()!==""}function t$({messages:e,descriptors:t}){const n=new Map(t.filter(o=>o.renderer==="preview").map(o=>[o.tool,o]));if(n.size===0)return[];const r=new Map,i=[];for(const o of e)for(const l of o.blocks??[]){if(l.type==="tool_use"&&r.set(l.id,l.name),l.type!=="tool_result"||l.ok===!1)continue;const a=n.get(l.name||r.get(l.toolUseId)||"");if(!a)continue;const c=W0(a,ak(l.output)).props;c.target===null&&c.awaiting!==null&&i.push({...c.awaiting,at:o.at??null})}return i}function n$({messages:e,descriptors:t,awaiting:n,folded:r,served:i}){var u;const o=new Map(t.map(p=>[p.tool,p])),l=new Map;let a=[],c=0;for(const p of e)for(const f of p.blocks??[]){if(f.type==="tool_use"){if(l.set(f.id,{name:f.name,input:f.input,at:p.at??null}),f.name===mh){const g=r$(f.id,f.input,p.at??null);g&&a.push(g)}if(f.name===Tv&&(a=[]),f.name===Rc){const g=XM(f.input);g&&a.push({id:f.id,tool:Rc,title:"Delegation",renderer:"delegate",props:{...g,result:null},at:p.at??null,source:"delegate",substantial:!0})}continue}if(f.type!=="tool_result"||f.name===mh||f.name===Tv)continue;const h=l.get(f.toolUseId),x=p.at??(h==null?void 0:h.at)??null,j=f.name||(h==null?void 0:h.name)||"tool",w=a.find(g=>g.source==="delegate"&&g.id===f.toolUseId);if(w&&((u=f.delegation)==null?void 0:u.state)==="waiting"){w.props={...w.props,result:null,waiting:{approvalId:f.delegation.approvalId}},f.delegation.approvalId&&(w.tone="warning");continue}if(w){w.props={...w.props,result:{ok:f.ok,text:ZM(f.ok?f.output:f.error??f.output)}},f.ok||(w.tone="critical");continue}const b=f.approval?xh(f):(n==null?void 0:n.get(f.toolUseId))??xh(f);if(b){a.push({id:f.toolUseId,tool:j,title:"Approval",renderer:"envelope",props:{approvalId:b},at:x,tone:"warning",source:"approval",substantial:!0});continue}if(r!=null&&r.has(j))continue;const v=ak(f.output);if(f.ok===!1){a.push({id:f.toolUseId,tool:j,title:ns(j),renderer:"structured",props:{value:f.error??v??null,failed:!0},at:x,tone:"critical",source:"fallback",substantial:!1});continue}e$(v)&&(c+=1);const m=o.get(j);if(m){const g=W0(m,v),{renderer:k}=g;let{props:S}=g;if(k==="preview"){const N=S,C=N.target??(N.awaiting&&(i!=null&&i.has(Ai(N.awaiting)))?N.awaiting:null);if(C===null)continue;S={...N,target:C,awaiting:null};const P=Ai(C);a=a.filter(E=>!(E.source==="descriptor"&&E.renderer==="preview"&&E.props.target!==null&&Ai(E.props.target)===P))}a.push({id:f.toolUseId,tool:j,title:m.title??ns(j),renderer:k,props:S,at:x,source:"descriptor",substantial:gh(k,S)});continue}const y={value:Sm(v)?{input:h==null?void 0:h.input,output:v}:v};i$("structured",y)&&a.push({id:f.toolUseId,tool:j,title:ns(j),renderer:"structured",props:y,at:x,source:"fallback",substantial:gh("structured",y)})}for(const p of a)p.source==="descriptor"&&p.renderer==="preview"&&(p.props={...p.props,changes:c});return s$(a)}const Pv="forAgent";function ak(e){if(e===null||typeof e!="object"||Array.isArray(e)||!(Pv in e))return e;const{[Pv]:t,...n}=e;return n}function s$(e){if(e.length<=Rv)return e;const t=e.length-Rv;return[...e.slice(0,t).filter(r=>r.source==="approval"),...e.slice(t)]}function r$(e,t,n){if(t===null||typeof t!="object")return null;const{renderer:r,title:i,data:o}=t,l=typeof r=="string"&&Tc(r)?r:"structured";return{id:e,tool:mh,title:typeof i=="string"&&i.trim()!==""?i:"Shown",renderer:l,props:l==="structured"&&!Tc(String(r))?{value:o}:o,at:n,substantial:!0,source:"canvas"}}function i$(e,t){const n=t??{};return!!(n.failed===!0||gh(e,t)||km(n.value).kind==="error")}function gh(e,t){const n=t??{};switch(e){case"timeseries":return fa(n.points)>0;case"bars":return fa(n.bars)>0;case"keyvalue":return fa(n.pairs)>0;case"document":return!!n.text||!!n.src;case"diff":return!!n.diff;case"terminal":return!!n.output||!!n.command;case"image":return!!n.artifactId;case"preview":return!!n.target;case"envelope":return!0;case"table":return(Array.isArray(n.groups)?n.groups:[]).some(i=>fa(i.rows)>0);default:return Sm(n.value)?!0:n.failed===!0?!1:fM(n.value)}}function fa(e){return Array.isArray(e)?e.length:0}function xh(e){if(e.approval)return e.approval.state==="pending"?e.approval.id:null;for(const t of[e.error,e.output]){const n=uk(t,0);if(n)return n}return null}function o$(e,t,n={}){var a,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 o=r.find(u=>u.type==="tool_result"&&u.toolUseId===t),l=(a=n.redactInputOf)!=null&&a.has(i.name)?ck(i.input):i.input;return{id:t,tool:i.name,title:ns(i.name),renderer:"structured",props:{value:{input:l,...(o==null?void 0:o.type)==="tool_result"?{status:((c=o.approval)==null?void 0:c.state)??(o.ok?"completed":"failed"),output:o.output,...o.error?{error:o.error}:{}}:{status:"Awaiting result"}}},at:null,source:"fallback",substantial:!1}}const l$=new Set(["value","text","password","secret","code"]);function ck(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=l$.has(n)&&typeof r=="string"?"— withheld —":ck(r);return t}function uk(e,t){if(t>3||e===null||typeof e!="object")return null;const n=e,r=n.reason,i=n.actionId??n.approvalId;if(typeof i=="string"&&i!==""&&(r===void 0||r==="approval-required"))return i;for(const o of Object.values(n)){const l=uk(o,t+1);if(l)return l}return null}function ns(e){const t=e.split(".");return t.length===1?Wt(e):t.map(n=>Wt(n)).join(" · ")}function dk({name:e,mime:t,sizeBytes:n,thumbnail:r,state:i,error:o,onOpen:l,onRemove:a,size:c="md"}){const u=bm(t,e),p=[Rr[u],An(n)].filter(Boolean).join(" · "),f=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wb-file-visual","data-family":u,children:r?s.jsx("img",{src:r,alt:""}):s.jsx(Em,{family:u})}),s.jsxs("span",{className:"wb-file-text",children:[s.jsx("span",{className:"wb-file-name",title:e,children:e}),s.jsx("span",{className:"wb-file-meta",children:i==="uploading"?"Uploading…":i==="failed"?"Upload failed":p})]})]});return s.jsxs("span",{className:"wb-file","data-size":c,"data-state":i,"data-thumb":r?"true":void 0,title:i==="failed"?o:void 0,children:[l?s.jsx("button",{type:"button",className:"wb-file-open",onClick:l,"aria-label":`Open ${e}`,children:f}):s.jsx("span",{className:"wb-file-open",children:f}),a?s.jsx("button",{type:"button",className:"wb-file-x","aria-label":`Remove ${e}`,onClick:a,children:s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:s.jsx("path",{d:"M2.5 2.5l5 5M7.5 2.5l-5 5"})})}):null]})}function Em({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 s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"2"}),s.jsx("circle",{cx:"7.5",cy:"8.5",r:"1.4"}),s.jsx("path",{d:"M17 13l-3.6-3.6a1 1 0 0 0-1.4 0L6 15.5"})]});case"pdf":return s.jsxs("svg",{...t,children:[s.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"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 13.5h5M7.5 11h5"})]});case"table":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),s.jsx("path",{d:"M3 8.5h14M3 12.5h14M8 4v12M13 4v12"})]});case"text":return s.jsxs("svg",{...t,children:[s.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"}),s.jsx("path",{d:"M11.5 2.5V7H16"}),s.jsx("path",{d:"M7.5 10.5h5M7.5 13.5h3.5"})]});case"code":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M7 6l-4 4 4 4M13 6l4 4-4 4M11.5 4l-3 12"})});case"audio":return s.jsx("svg",{...t,children:s.jsx("path",{d:"M4 8v4M7.5 5.5v9M11 3.5v13M14.5 6.5v7M18 8.5v3"})});case"video":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"3",y:"5",width:"10",height:"10",rx:"1.5"}),s.jsx("path",{d:"M13 9l4-2.5v7L13 11"})]});case"archive":return s.jsxs("svg",{...t,children:[s.jsx("rect",{x:"4",y:"3",width:"12",height:"14",rx:"1.5"}),s.jsx("path",{d:"M10 3v3M10 8v2M10 12v2M8.5 14h3"})]});default:return s.jsxs("svg",{...t,children:[s.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"}),s.jsx("path",{d:"M11.5 2.5V7H16"})]})}}function a$(e){const t=c$(e);if(!t)return null;const n=Ad(t.diff);if(n!==null)return{kind:"diff",diff:n};const r=Ad(t.command),i=Ad(t.plain),o=Td(t.exitCode);return r!==null&&(i!==null||o!==null||Td(t.pid)!==null)?{kind:"command",command:r,output:i,exitCode:o,elapsedMs:Td(t.elapsedMs)}:null}function Ad(e){return typeof e=="string"&&e.trim()!==""?e:null}function Td(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function c$(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}const Iv="offer:",fk="owner:interjection";function u$(e){return e===fk}function d$(e){if(typeof e!="string"||!e.startsWith(Iv))return null;const t=e.slice(Iv.length).trim();return t===""?null:t}function hk({messages:e,live:t,now:n,onOpen:r,working:i=!1,partial:o=null,agents:l,speakers:a,coordinatorId:c,workingAs:u,onOpenFile:p,children:f,agentName:h,emptyHint:x,empty:j,plain:w=!1,workingLine:b,runs:v}){var S,N;const m=d.useRef(null);d.useEffect(()=>{var C;(C=m.current)==null||C.scrollIntoView({block:"end"})},[e.length,t.length,i,o==null?void 0:o.text.length,o==null?void 0:o.thinking.length,!!f]);const y=o&&!o.settled&&(o.text!==""||o.thinking!==""),g=e.filter(C=>(C.blocks??[]).some(y$)),k=v$(g,v??[]);return s.jsx(z0.Provider,{value:l??a??[],children:s.jsxs("div",{className:"wb-messages","data-testid":"messages",children:[g.length===0&&t.length===0?j??s.jsx("p",{className:"wb-chat-empty",children:x}):null,g.map((C,P)=>{const E=C.speaker??null,O=a?E==="owner"||E===null&&C.role==="user":C.role==="user",L=a&&E==="room",D=a&&E&&E!=="owner"&&E!=="room"?a.find(U=>U.id===E)??null:null,T=g[P-1],z=P===0||(a?((T==null?void 0:T.speaker)??null)!==E:T.role!==C.role);if(L)return s.jsx("div",{className:"wb-msg wb-msg-room","data-role":"room",children:(C.blocks??[]).filter(U=>U.type==="text").map((U,X)=>s.jsx("span",{children:U.text},X))},C.id);const q=(C.blocks??[]).filter(U=>U.type==="approval_result");if(q.length>0)return s.jsx("div",{className:"wb-msg","data-role":"assistant","data-testid":"approval-result",children:q.map((U,X)=>s.jsx(w$,{block:U},X))},C.id);const K=C.role==="user"&&u$(E),M=C.role==="user"?d$(E):null;if(M){const U=(C.blocks??[]).filter(X=>X.type==="text").map(X=>X.text).join(`
|
|
95
|
-
`);return s.jsx("div",{className:"wb-msg","data-role":"user","data-testid":"offer-turn",children:s.jsx("div",{className:"wb-bubble wb-bubble-offer",title:U,children:M})},C.id)}const W=a&&D&&C.role==="user"?x$(C):null;if(W){const U=g.slice(P+1).find(Z=>Z.role==="assistant"&&Z.speaker&&Z.speaker!==D.id),X=U!=null&&U.speaker?a.find(Z=>Z.id===U.speaker):void 0;return s.jsxs("details",{className:"wb-msg wb-msg-room wb-msg-ask","data-role":"room",children:[s.jsxs("summary",{children:[D.name," asked ",(X==null?void 0:X.name)??"a member",W.request?`: ${W.request.length>120?`${W.request.slice(0,119)}…`:W.request}`:""]}),W.request?s.jsx("p",{children:W.request}):null]},C.id)}const _=k.get(C.id)??null;return s.jsxs("div",{className:"wb-msg","data-role":O||K?"user":"assistant",children:[K?s.jsx("div",{className:"wb-msg-added","data-testid":"added-while-working",children:"added while working"}):null,z&&!O&&!K?s.jsxs("div",{className:"wb-msg-who",children:[D&&a?s.jsx(Zt,{agents:a,id:D.id,size:"sm"}):null,s.jsx("span",{children:D?D.name:h??"Assistant"}),D&&c===D.id?s.jsx("span",{className:"wb-msg-role",children:"coordinator"}):null]}):null,Mv(C).length>0?s.jsx("div",{className:"wb-msg-files",role:"list","aria-label":"Files sent with this message",children:Mv(C).map(U=>s.jsx("span",{role:"listitem",children:s.jsx(dk,{name:U.filename??"Untitled file",mime:U.mime,sizeBytes:U.sizeBytes,thumbnail:WI(U.mime)?zr(U.artifactId):null,...p?{onOpen:()=>p(U)}:{}})},U.artifactId))}):null,(C.blocks??[]).map((U,X)=>{const Z=p$(C.blocks??[],X,e);if(Z==="inside")return null;if(Z)return s.jsx(m$,{refusals:Z.refusals},X);if(U.type==="thinking")return w||U.text.trim()===""?null:s.jsx(vh,{text:U.text},X);if(U.type==="text")return U.text.trim()===""?null:O?s.jsx("div",{className:"wb-bubble",children:U.text},X):s.jsx("div",{className:"wb-bubble","data-rich":"true",children:s.jsx(cr,{text:U.text})},X);if(U.type==="attachment")return null;if(U.type==="tool_use"){if(w)return null;const ue=pk(e,U.id),je=ue?S$(ue):null;return s.jsx(jh,{label:je&&!(ue!=null&&ue.delegation)?`Approval · ${U.name}`:ns(U.name),tool:U.name,ok:(ue==null?void 0:ue.ok)??null,running:ue===null,...je?{status:je.status,waiting:je.waiting,approval:!0}:{},gist:Cm(U.name,U.input),body:ue?a$(ue.output):null,opens:!0,onOpen:()=>r(U.id)},X)}return null}),_?s.jsx("div",{className:"wb-msg-budget","data-testid":"budget-stop",children:j$(_)}):null]},C.id)}),y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"live-turn",children:[((S=g.at(-1))==null?void 0:S.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,o.thinking!==""&&!w?s.jsx(vh,{text:o.thinking,live:o.text==="",seconds:g$(o.thinkingStartedAt,o.textStartedAt??n)}):null,o.text!==""?s.jsxs("div",{className:"wb-bubble","data-live":"true","data-rich":"true",children:[s.jsx(cr,{text:o.text}),s.jsx("span",{className:"wb-caret","aria-hidden":"true"})]}):null]}):null,i&&t.length===0&&!y?s.jsxs("div",{className:"wb-msg","data-role":"assistant","data-testid":"working",children:[((N=g.at(-1))==null?void 0:N.role)!=="assistant"||u?s.jsx("div",{className:"wb-msg-who",children:u??h??"Assistant"}):null,s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[b??`${u??h??"The agent"} is working`,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})]}):null,t.map(C=>s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx(jh,{label:ns(C.name),tool:C.name,ok:null,running:!0,elapsed:Math.max(0,Math.round((n-C.startedAt)/1e3)),opens:!1,onOpen:()=>r(C.toolUseId)})},C.toolUseId)),f,s.jsx("div",{ref:m})]})})}function f$(e){var t,n;return((n=(t=/\(allowed: ([^)]*)\)/.exec(e))==null?void 0:t[1])==null?void 0:n.trim())||null}const h$="delegation refused:";function p$(e,t,n){const r=o=>{const l=e[o];if(!l||l.type!=="tool_use"||l.name!==Rc)return null;const a=pk(n,l.id);if(!a||a.ok!==!1)return null;const c=typeof a.error=="string"?a.error:String(a.error??"");if(!c.trimStart().startsWith(h$))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 o=t;;o+=1){const l=r(o);if(!l)break;i.push(l)}return i.length<2?null:{refusals:i}}function m$({refusals:e}){const[t,n]=d.useState(!1),r=e.map(a=>f$(a.message)).find(a=>a!==null)??null,i=e.map(a=>a.target),o=i.slice(0,3),l=`Delegation refused ${e.length} times: ${o.join(", ")}${i.length>o.length?", …":""}`+(r?` (allowed: ${r})`:"");return s.jsxs("div",{className:"wb-refusals","data-testid":"delegation-refusals","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":!1,"aria-expanded":t,onClick:()=>n(a=>!a),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:l}),s.jsx(De,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("div",{className:"wb-refusals-list",children:e.map((a,c)=>s.jsxs("div",{className:"wb-refusal",children:[s.jsxs("span",{className:"wb-tool","data-static":"true","data-ok":!1,children:[s.jsx("span",{className:"wb-tool-mark","data-ok":"false","aria-hidden":"true"}),s.jsxs("span",{className:"wb-tool-label",children:[ns(Rc)," · ",a.target]}),s.jsx("span",{className:"wb-tool-elapsed",children:"refused"})]}),s.jsx("p",{className:"wb-refusal-why",children:a.message})]},c))}):null]})}function g$(e,t){return e===null?null:Math.max(0,Math.round((t-e)/1e3))}function vh({text:e,live:t=!1,seconds:n=null}){const[r,i]=d.useState(!1),o=t?`Thinking${n!==null&&n>0?` · ${n}s`:""}`:n!==null&&n>0?`Thought for ${n}s`:"Thoughts";return s.jsxs("div",{className:"wb-thought","data-live":t||void 0,"data-open":r||void 0,children:[s.jsxs("button",{type:"button",className:"wb-thought-toggle","aria-expanded":r,onClick:()=>i(l=>!l),children:[t?s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}):s.jsx(De,{name:"thought"}),s.jsx("span",{children:o}),s.jsx(De,{name:"arrow",className:"wb-tool-arrow"})]}),r?s.jsx("div",{className:"wb-thought-text",children:s.jsx(cr,{text:e})}):null]})}function x$(e){var r;const t=((r=(e.blocks??[]).find(i=>i.type==="text"))==null?void 0:r.text)??"",n=/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 n?{handle:n[1],request:n[2].trim()}:null}function Mv(e){return(e.blocks??[]).filter(t=>t.type==="attachment")}function v$(e,t){const n=t.filter(l=>l.startedAt!==null&&l.finishedAt!==null),r=(l,a)=>a.at!==""&&a.at>=l.startedAt&&a.at<=l.finishedAt,i=(l,a)=>l!==a&&l.startedAt>=a.startedAt&&l.finishedAt<=a.finishedAt&&(l.startedAt>a.startedAt||l.finishedAt<a.finishedAt),o=new Map;for(const l of n){if(l.stopped!=="max_turns"&&l.stopped!=="max_tokens"||l.noticed!==!0||l.runId===null)continue;let a=null;for(const c of e)c.role!=="assistant"||!r(l,c)||(a=c);a===null||n.some(c=>i(c,l)&&r(c,a))||o.has(a.id)||o.set(a.id,l)}return o}function j$(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 y$(e){return e.type==="text"||e.type==="thinking"?e.text.trim()!=="":e.type==="tool_use"||e.type==="attachment"||e.type==="approval_result"}function w$({block:e}){const[t,n]=d.useState(!1),r=e.state==="succeeded";return s.jsxs("div",{className:"wb-approval","data-open":t||void 0,children:[s.jsxs("button",{type:"button",className:"wb-tool","data-ok":r,"aria-expanded":t,onClick:()=>n(i=>!i),children:[s.jsx("span",{className:"wb-tool-mark","data-ok":r?"true":"false","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e.name===""?"Approved action":ns(e.name)}),s.jsx("span",{className:"wb-tool-elapsed",children:e.state}),s.jsx(De,{name:"arrow",className:"wb-tool-arrow"})]}),t?s.jsx("pre",{className:"wb-approval-output mono",children:b$(e.output)}):null]})}function b$(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)??"null"}catch{return String(e)}}const k$=40;function S$(e){var n,r;if(((n=e.delegation)==null?void 0:n.state)==="waiting")return{status:e.delegation.approvalId?"waiting for your approval":"running",waiting:!0};if(xh(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 jh({label:e,tool:t,ok:n,running:r,elapsed:i,opens:o,onOpen:l,status:a,waiting:c=!1,approval:u=!1,gist:p=null,body:f=null}){const[h,x]=d.useState(!1),j=s.jsxs(s.Fragment,{children:[r?s.jsx("span",{className:"wb-pulse","aria-hidden":"true"}):s.jsx("span",{className:"wb-tool-mark","data-ok":c?"pending":n===!1?"false":"true","aria-hidden":"true"}),s.jsx("span",{className:"wb-tool-label",children:e}),p?s.jsx("span",{className:"wb-tool-gist mono","data-testid":"tool-gist",children:p}):null,i===void 0?null:s.jsxs("span",{className:"wb-tool-elapsed",children:[i,"s"]}),a||n===!1?s.jsx("span",{className:"wb-tool-elapsed",children:a??"failed"}):null]}),w={"data-ok":n===null?void 0:n,"data-running":r,"data-gist":p?!0:void 0,"data-approval":u||void 0};return f?s.jsxs("div",{className:"wb-toolcall","data-open":h||void 0,children:[s.jsxs("div",{className:"wb-tool","data-split":"true",...w,children:[s.jsxs("button",{type:"button",className:"wb-tool-toggle","aria-expanded":h,onClick:()=>x(b=>!b),children:[s.jsx(De,{name:"chevron",className:"wb-tool-chevron"}),j]}),o?s.jsxs(wc,{children:[s.jsx(bc,{asChild:!0,children:s.jsx("button",{type:"button",className:"wb-tool-open","aria-label":"Open on the canvas",onClick:l,children:s.jsx(De,{name:"arrow",className:"wb-tool-arrow"})})}),s.jsx(kc,{children:s.jsxs(Sc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):null]}),h?s.jsx(N$,{body:f,onOpen:o?l:null}):null]}):o?s.jsxs(wc,{children:[s.jsx(bc,{asChild:!0,children:s.jsxs("button",{className:"wb-tool",...w,onClick:l,children:[j,s.jsx(De,{name:"arrow",className:"wb-tool-arrow"})]})}),s.jsx(kc,{children:s.jsxs(Sc,{className:"ui-tip",sideOffset:6,children:[s.jsx("span",{className:"ui-tip-title",children:"Open on the canvas"}),s.jsx("span",{className:"ui-tip-hint mono",children:t})]})})]}):s.jsx("span",{className:"wb-tool","data-static":"true",...w,children:j})}function N$({body:e,onOpen:t}){const n=t?{label:"Open on the canvas",onClick:t}:void 0;if(e.kind==="diff")return s.jsx("div",{className:"wb-tool-body","data-kind":"diff","data-testid":"tool-body",children:s.jsx(Cc,{text:e.diff,limit:k$,...n?{more:n}:{}})});const r=[e.exitCode===null?null:`exit ${e.exitCode}`,e.elapsedMs===null?null:C$(e.elapsedMs)].filter(i=>i!==null);return s.jsxs("div",{className:"wb-tool-body","data-kind":"command","data-testid":"tool-body",children:[s.jsxs("div",{className:"wb-tool-command",children:[s.jsx("code",{className:"mono",children:e.command}),r.length>0?s.jsx("span",{className:"wb-tool-facts","data-failed":e.exitCode!==null&&e.exitCode!==0?!0:void 0,children:r.join(" · ")}):null]}),e.output?s.jsx("pre",{className:"wb-tool-output",children:e.output}):null]})}function C$(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function pk(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}const mk="approval-dock";function E$(){var t;const e=document.getElementById(mk);e&&((t=e.scrollIntoView)==null||t.call(e,{block:"nearest"}),e.focus())}const A$=["workspace","cwd","workdir","root"];function T$({approvals:e,timezone:t,now:n,version:r,onDecided:i,onSay:o,onOpenFull:l}){const[a,c]=d.useState([]),u=e.filter(h=>!a.includes(h.approvalId)),p=u[0];if(!p)return null;const f=h=>c(x=>x.includes(h)?x:[...x,h]);return s.jsx(R$,{item:p,count:u.length,timezone:t,now:n,version:r,onSettled:h=>{f(p.approvalId),h&&i(h)},onSay:o,onOpenFull:()=>l(p.toolUseId)},p.approvalId)}function R$({item:e,count:t,timezone:n,now:r,version:i,onSettled:o,onSay:l,onOpenFull:a}){var C;const[c,u]=d.useState(null),[p,f]=d.useState(null),[h,x]=d.useState(null),[j,w]=d.useState("");d.useEffect(()=>{let P=!1;return A.approval(e.approvalId).then(E=>{P||(u(E),E.state!=="pending"&&o(E))}).catch(E=>{P||f(E instanceof ce?E.message:String(E))}),()=>{P=!0}},[e.approvalId,i]);const b=c!==null&&c.state==="pending"&&Date.parse(c.expiresAt)<=r;d.useEffect(()=>{b&&c&&o({...c,state:"expired"})},[b]);const{values:v,controls:m}=wm(c==null?void 0:c.choices),y=(P,E)=>{const O=j.trim();x(P),f(null),(v&&P==="approve"?A.decide(e.approvalId,P,E,v):A.decide(e.approvalId,P,E)).then(L=>{o(L.action),O&&l(O)}).catch(L=>{f(L instanceof ce?L.message:String(L)),x(null)})},g=h!==null||c===null||c.state!=="pending",k=((C=c==null?void 0:c.permissionScopes)==null?void 0:C.includes("always"))??!1,S=c?Cm(c.tool,c.canonicalArgs)??I$(c.preview):null,N=c?P$(c):null;return s.jsxs("section",{id:mk,tabIndex:-1,className:"wb-question","data-kind":"approval","aria-label":"Approval needed","data-testid":"approval-dock",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your OK"}),t>1?s.jsxs("span",{className:"wb-dock-count","data-testid":"approval-dock-count",children:["1 of ",t]}):null,s.jsx("strong",{children:c?ns(c.tool):"Loading the request…"}),e.askedBy?s.jsx("span",{className:"wb-dock-asker","data-testid":"approval-dock-asker",children:e.askedBy}):null]}),S||N?s.jsxs("div",{className:"wb-dock-section wb-dock-subject",children:[S?s.jsx("code",{className:"wb-dock-gist",children:S}):null,N?s.jsxs("span",{className:"wb-dock-where",children:["in ",s.jsx("span",{className:"mono",children:N})]}):null]}):null,m?s.jsx("div",{className:"wb-dock-section",children:m}):null,s.jsx(re,{message:p}),s.jsx("div",{className:"wb-dock-section",children:s.jsx("input",{className:"wb-dock-instead",value:j,onChange:P=>w(P.target.value),onKeyDown:P=>{P.key==="Enter"&&P.preventDefault()},placeholder:"Tell the agent what to do instead (optional)","aria-label":"Tell the agent what to do instead (optional)",disabled:h!==null})}),s.jsxs("div",{className:"wb-dock-section wb-dock-actions",children:[s.jsxs("span",{className:"wb-dock-meta",children:[c?s.jsxs(s.Fragment,{children:["Expires ",Re(c.expiresAt,n)," · "]}):null,s.jsx("button",{type:"button",className:"wb-link",onClick:a,children:"See the full request on the Canvas"})]}),s.jsx(R,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("reject"),children:h==="reject"?"Rejecting…":"Reject"}),k?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",size:"sm",disabled:g,onClick:()=>y("approve","conversation"),children:"Auto: this conversation"}),s.jsx(R,{size:"sm",disabled:g,onClick:()=>y("approve","always"),children:"Always: this agent"})]}):null,s.jsx(R,{variant:"good",size:"sm",disabled:g,onClick:()=>y("approve"),children:h==="approve"?"Approving…":k?"Allow once":"Approve"})]})]})}function P$(e){for(const t of[e.canonicalArgs,e.envelope])if(!(t===null||typeof t!="object"||Array.isArray(t)))for(const n of A$){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}return null}function I$(e){const t=(e??"").split(`
|
|
96
|
-
`).map(n=>n.trim()).find(Boolean);return t?t.length>160?`${t.slice(0,157)}…`:t:null}const M$=2e3;function $$({conversationId:e,agentId:t,runId:n=null,result:r=null,waiting:i=null,agents:o=[]}){const l=r!==null,[a,c]=d.useState(l),u=!a||i!==null,{data:p,error:f}=se(()=>Fe.conversation(e),[e,a,(i==null?void 0:i.approvalId)??null],u?M$:void 0),h=(p==null?void 0:p.runs)??[],x=n===null?null:h.find(g=>g.runId===n)??null,j=l||i===null&&(n!==null?x!==null&&x.finishedAt!==null:h.length>0&&h.every(g=>g.finishedAt!==null));d.useEffect(()=>{j&&c(!0)},[j]);const w=r?r.ok?"done":"failed":i!=null&&i.approvalId?"waiting":j?"done":"working",b=o.find(g=>g.id===t)??null,v=(b==null?void 0:b.name)??(p==null?void 0:p.agentId)??t,m=(p==null?void 0:p.messages)??[],y=(r==null?void 0:r.text)??_$(m);return s.jsxs("div",{className:"wb-delegate","data-testid":"delegate-view","data-status":w,children:[s.jsxs("header",{className:"wb-delegate-head",children:[s.jsx(Zt,{agents:o,id:t}),s.jsxs("div",{className:"wb-delegate-who",children:[s.jsx("strong",{children:v}),s.jsx("span",{className:"wb-delegate-status","data-status":w,role:"status",children:w==="working"?s.jsxs(s.Fragment,{children:["Working",s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]}):w==="waiting"?"Waiting for your approval":w==="failed"?"Failed":"Done"})]})]}),f?s.jsx("p",{className:"muted",children:f}):null,s.jsx("div",{className:"wb-delegate-work",children:m.map((g,k)=>s.jsx("div",{className:"wb-delegate-turn",children:(g.blocks??[]).map((S,N)=>{if(S.type==="thinking")return S.text.trim()===""?null:s.jsx(vh,{text:S.text},N);if(S.type==="tool_use"){const C=D$(O$(m,S.id));return s.jsx(jh,{label:ns(S.name),tool:S.name,ok:C.ok,running:C.running,waiting:C.waiting,status:C.status,gist:Cm(S.name,S.input),opens:!1,onOpen:()=>{}},N)}return null})},g.id??k))}),y?s.jsx("div",{className:"wb-delegate-answer","data-testid":"delegate-answer",children:s.jsx(cr,{text:y})}):w==="working"||w==="waiting"?s.jsxs("p",{className:"muted",children:[v," has not answered yet."]}):null,s.jsxs("div",{className:"wb-delegate-actions",children:[w==="waiting"?s.jsx(R,{variant:"accent",onClick:()=>E$(),"data-testid":"delegate-to-approval",children:"Go to the approval"}):null,s.jsx("a",{className:"ui-btn",href:ze(t||(p==null?void 0:p.agentId)||"",e),children:"Open this conversation"})]})]})}function _$(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.role!=="assistant")continue;const r=(n.blocks??[]).filter(i=>i.type==="text").map(i=>i.text.trim()).filter(i=>i!=="").join(`
|
|
97
|
-
|
|
98
|
-
`);if(r!=="")return r}return null}function O$(e,t){for(const n of e)for(const r of n.blocks??[])if(r.type==="tool_result"&&r.toolUseId===t)return r;return null}function D$(e){var n;if(e===null)return{running:!0,ok:null,waiting:!1,status:void 0};const t=(n=e.approval)==null?void 0:n.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 $v=1024*1024;function L$({files:e,agentId:t,root:n,revision:r}){const[i,o]=d.useState({kind:"dir",path:""});return d.useEffect(()=>o({kind:"dir",path:""}),[e.plugin,t]),s.jsx("div",{className:"wb-files","data-testid":"files-view",children:i.kind==="dir"?s.jsx(F$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o}):s.jsx(z$,{files:e,agentId:t,root:n,path:i.path,revision:r,go:o})})}function gk({root:e,path:t,go:n}){const r=t===""?[]:t.split("/"),i=[{label:e,path:""},...r.map((o,l)=>({label:o,path:r.slice(0,l+1).join("/")}))];return s.jsx("nav",{className:"wb-files-crumbs","aria-label":"Where you are in the workspace",children:i.map((o,l)=>{const a=l===i.length-1;return s.jsxs("span",{className:"wb-files-crumb",children:[l>0?s.jsx("span",{className:"wb-files-sep","aria-hidden":"true",children:"/"}):null,a?s.jsx("span",{className:"wb-files-here mono","aria-current":"location",children:o.label}):s.jsx("button",{type:"button",className:"wb-files-step mono",onClick:()=>n({kind:"dir",path:o.path}),children:o.label})]},o.path)})})}function F$({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(!1),[h,x]=d.useState(null);d.useEffect(()=>{let b=!1;return u(null),A.pageQuery(e.plugin,e.list,{agent:t,...r?{path:r}:{}}).then(v=>{b||a(v.data)}).catch(v=>{b||u(v instanceof Error?v.message:String(v))}),()=>{b=!0}},[e.plugin,e.list,t,r,i]),d.useEffect(()=>x(null),[r]);const j=async()=>{f(!0),x(null);try{const b=await fetch(A.pageFileUrl(e.plugin,e.archive,{agent:t,...r?{path:r}:{}}),{credentials:"same-origin"});if(!b.ok){const g=await b.json().catch(()=>null);x((g==null?void 0:g.error)??"The archive could not be made.");return}const v=await b.blob(),m=URL.createObjectURL(v),y=document.createElement("a");y.href=m,y.download=`${r===""?n:r.split("/").at(-1)}.zip`,y.click(),window.setTimeout(()=>URL.revokeObjectURL(m),1e4)}catch{x("The archive could not be made.")}finally{f(!1)}},w=l&&l.path===r?l.entries:null;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(gk,{root:n,path:r,go:o}),s.jsx(ro,{}),s.jsx(R,{size:"sm",onClick:()=>void j(),disabled:p||w===null||w.length===0,children:p?"Packing…":"Download as archive"})]}),h?s.jsx(V,{tone:"warning",role:"alert",children:h}):null,c?s.jsx(V,{tone:"critical",role:"alert",children:c}):null,w===null?c?null:s.jsx(ie,{children:"Reading the folder…"}):w.length===0?s.jsx(ie,{children:r===""?s.jsxs(s.Fragment,{children:["Nothing in this workspace yet. To hand the agent a file, add it to the ",s.jsx("a",{href:Lr,children:"Files library"})," and mention it here."]}):"This folder is empty."}):s.jsx(Ft,{children:w.map(b=>s.jsx(Kt,{href:"#",onClick:()=>o({kind:b.kind,path:b.path}),lead:s.jsx(B$,{kind:b.kind}),title:s.jsxs("span",{className:"mono",children:[b.name,b.kind==="dir"?"/":""]}),side:b.kind==="file"?An(b.bytes):void 0},b.path))}),l&&l.path===r&&(l.skipped>0||l.truncated)?s.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 z$({files:e,agentId:t,root:n,path:r,revision:i,go:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(!1);d.useEffect(()=>{let v=!1;return u(null),A.pageQuery(e.plugin,e.stat,{agent:t,path:r}).then(m=>{v||a(m.data)}).catch(m=>{v||u(m instanceof Error?m.message:String(m))}),()=>{v=!0}},[e.plugin,e.stat,t,r,i]);const h=l&&l.path===r?l:null,x=h?`${h.bytes}-${Math.round(h.mtimeMs)}`:"",j=h?A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,v:x}):"",w=A.pageFileUrl(e.plugin,e.read,{agent:t,path:r,download:"1"}),b=(h==null?void 0:h.type)==="text"&&h.bytes<=$v;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(gk,{root:n,path:r,go:o}),s.jsx(ro,{}),b?s.jsx(R,{size:"sm","aria-pressed":p,onClick:()=>f(v=>!v),children:"Wrap"}):null,s.jsx(Un,{size:"sm",href:w,download:(h==null?void 0:h.name)??r.split("/").at(-1),children:"Download"})]}),c?s.jsx(V,{tone:"critical",role:"alert",children:c}):null,h===null?c?null:s.jsx(ie,{children:"Reading the file…"}):h.type==="image"?s.jsx("figure",{className:"wb-files-picture",children:s.jsx("img",{src:j,alt:h.name})}):h.type==="pdf"?s.jsx("div",{className:"file-preview file-preview-pdf",children:s.jsx("object",{data:j,type:"application/pdf","aria-label":h.name,children:s.jsx(V,{children:"Your browser cannot show this PDF here. Download it to open it."})})}):b?s.jsx(U$,{src:j,wrap:p}):s.jsxs(s.Fragment,{children:[s.jsx(V,{children:h.type==="text"?`This file is over ${An($v)}, too long to read here. Download it to open it.`:"This kind of file is not shown here. Download it to open it."}),s.jsx(At,{items:[{label:"Size",value:An(h.bytes)},{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})}]})]})]})}function U$({src:e,wrap:t}){const[n,r]=d.useState(null),[i,o]=d.useState(!1);return d.useEffect(()=>{let l=!1;return o(!1),fetch(e,{credentials:"same-origin"}).then(async a=>{if(!a.ok)throw new Error(String(a.status));const c=await a.text();l||r(c)}).catch(()=>{l||o(!0)}),()=>{l=!0}},[e]),i?s.jsx(V,{tone:"critical",children:"The file could not be read."}):n===null?s.jsx(ie,{children:"Reading the file…"}):n===""?s.jsx(ie,{children:"This file is empty."}):s.jsx("pre",{className:"wb-files-text","data-wrap":t?"true":void 0,"data-testid":"files-text",children:n})}function B$({kind:e}){return s.jsx("span",{className:"wb-files-icon","data-kind":e,"aria-hidden":"true",children:s.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"?s.jsx("path",{d:"M2 4.2h4.2l1.4 1.6H14v7H2z"}):s.jsx("path",{d:"M4 2.4h5l3 3v8.2H4zM9 2.4v3h3"})})})}const W$=3,H$=152,V$=104,K$=100,G$=2,_v=5;function Y$({renderables:e,activeId:t,onActivate:n,timezone:r,onDecided:i,onChangeAgent:o,face:l,descriptors:a,grantedTools:c,agentName:u,maxTabs:p,browserPanel:f,agents:h,onClose:x,loading:j=!1}){const[w,b]=q$(p);if(e.length===0)return s.jsxs("div",{className:"wb-canvas","data-testid":"canvas",children:[s.jsx("div",{className:"wb-canvas-tabs",ref:w,"aria-hidden":"true",children:s.jsx("span",{className:"wb-canvas-label",children:"Canvas"})}),s.jsx("div",{className:"wb-canvas-body wb-canvas-body-empty",children:j?null:s.jsxs("div",{className:"wb-empty",children:[l?s.jsx("span",{className:"wb-empty-face",children:l}):null,s.jsx("p",{className:"ui-empty wb-empty-line",children:e_(u,t_(a??[],c??[]))})]})})]});const v=e.some(g=>g.id===t)?t:e[e.length-1].id,{shown:m,hidden:y}=Q$(e,v,b);return s.jsx("div",{className:"wb-canvas","data-testid":"canvas",children:s.jsxs(XP,{value:v,onValueChange:n,className:"contents",children:[s.jsxs("div",{className:"wb-canvas-tabs",ref:w,children:[s.jsx("span",{className:"wb-canvas-label","aria-hidden":"true",children:"Canvas"}),s.jsx(ZP,{className:"wb-tabstrip","aria-label":"Canvas",children:m.map(g=>s.jsxs("div",{className:"wb-tab-item",children:[s.jsxs(e2,{value:g.id,className:"wb-tab","data-tone":g.tone,onKeyDown:k=>{k.key==="Delete"&&x&&Ov(g)&&(k.preventDefault(),x(g.id))},children:[g.tone==="warning"||g.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":g.tone,"aria-hidden":"true"}):null,s.jsx("span",{className:"wb-tab-text",children:g.title})]}),x&&Ov(g)?s.jsx("button",{className:"wb-tab-close","aria-label":`Close ${g.title} tab`,title:"Dismiss panel; keep conversation history",onClick:()=>x(g.id),children:"×"}):null]},g.id))}),s.jsx(J$,{items:y,onActivate:n,timezone:r})]}),e.map(g=>s.jsx(t2,{value:g.id,className:"wb-canvas-body","data-renderer":g.source==="descriptor"&&g.renderer==="preview"?"preview":void 0,"data-dense":s_.has(g.renderer)?"true":void 0,children:s.jsxs("section",{className:"ui-panel","data-flush":g.source==="descriptor"&&g.renderer==="preview"?"true":void 0,children:[g.source!=="browser"&&g.source!=="files"&&!(g.source==="descriptor"&&g.renderer==="preview")?s.jsxs("header",{className:"ui-panel-head",children:[s.jsx("h2",{className:"ui-panel-title",children:g.title}),s.jsx("span",{className:"ui-panel-tool mono",children:g.tool})]}):null,g.tone==="critical"?s.jsxs("p",{className:"muted",children:["Recorded tool failure",g.at?` · ${new Date(g.at).toLocaleString()}`:"",". This is history, not live session status."]}):null,g.source==="browser"?f:g.source==="profile"?s.jsx(DM,{...g.props,...o?{onChange:o}:{}}):g.source==="artifact"?s.jsx(YM,{...g.props}):g.source==="files"?s.jsx(L$,{...g.props}):g.source==="delegate"?s.jsx($$,{...g.props,agents:h??[]}):s.jsx(OM,{renderer:g.renderer,props:g.props,timezone:r,onDecided:i})]})},g.id))]})})}function Ov(e){return e.source==="approval"?!1:e.source==="browser"?e.pinned!==!0:e.source!=="files"}function q$(e){const[t,n]=d.useState(_v),r=d.useRef(null);return[d.useCallback(o=>{var a;if((a=r.current)==null||a.disconnect(),r.current=null,!o||e!==void 0||typeof ResizeObserver>"u")return;const l=()=>{const c=o.clientWidth;if(c===0)return;const u=Math.floor((c-K$-V$)/H$);n(Math.max(G$,Math.min(_v,u)))};l(),r.current=new ResizeObserver(l),r.current.observe(o)},[e]),e??t]}function Q$(e,t,n){const r=new Set(e.filter(o=>o.id===t||o.source==="approval"||o.pinned===!0).map(o=>o.id)),i=new Set(r);for(let o=e.length-1;o>=0&&i.size<n;o-=1)i.add(e[o].id);return{shown:e.filter(o=>i.has(o.id)),hidden:e.filter(o=>!i.has(o.id))}}function J$({items:e,onActivate:t,timezone:n}){if(e.length===0)return null;const r=e.some(i=>i.tone==="critical")?"critical":e.some(i=>i.tone==="warning")?"warning":null;return s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.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?s.jsx("span",{className:"wb-tab-dot","data-tone":r,"aria-hidden":"true"}):null,s.jsxs("span",{className:"wb-tab-text",children:[e.length," more"]}),s.jsx(De,{name:"chevron-down"})]})}),s.jsx(im,{children:s.jsxs(om,{className:"ui-menu","data-wide":"true",align:"end",sideOffset:6,children:[s.jsx(lm,{className:"ui-menu-label",children:"Earlier in this conversation"}),[...e].reverse().map(i=>s.jsxs(sh,{className:"ui-menu-item",onSelect:()=>t(i.id),children:[s.jsxs("span",{className:"ui-menu-item-text",children:[i.tone==="warning"||i.tone==="critical"?s.jsx("span",{className:"wb-tab-dot","data-tone":i.tone,"aria-hidden":"true"}):null,i.title]}),s.jsx("span",{className:"ui-menu-note mono",children:X$(i.at,n)??i.tool})]},i.id))]})})]})}function X$(e,t){if(!e)return null;const n=new Date(e);return Number.isNaN(n.getTime())?null:new Intl.DateTimeFormat("en-GB",{timeZone:t,hour:"2-digit",minute:"2-digit"}).format(n)}const Z$={timeseries:"charts",table:"tables",bars:"comparisons",keyvalue:"figures",document:"pages it read",diff:"diffs",terminal:"command output",image:"pictures",preview:"running apps",envelope:"drafts",structured:"results"};function e_(e,t){const n=e?`What ${e} shows you`:"What your agent shows you",r=[...new Set(t.map(i=>Z$[i.renderer]??"results"))].slice(0,3);return r.length>0?`${n} lands here: ${r.join(", ")}.`:`${n} lands here.`}function t_(e,t){const n=new Set(t),r=new Set,i=e.filter(c=>{if(!n.has(c.tool))return!1;const u=n_(c);return r.has(u)?!1:(r.add(u),!0)}),o=new Set,l=i.filter(c=>o.has(c.renderer)?!1:(o.add(c.renderer),!0)),a=i.filter(c=>!l.includes(c));return[...l,...a].slice(0,W$)}function n_(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 s_=new Set(["table","diff","files"]),r_=3.5*6e4,i_=2e3;function o_(e,t,n={}){const[r,i]=d.useState({served:new Set,live:new Set,scope:t}),o=d.useRef(r.served);if(r.scope!==t){const u={served:new Set,live:new Set,scope:t};o.current=u.served,i(u)}const l=n.check??A.previewCheck,a=n.everyMs??i_,c=e.map(u=>`${Ai(u)}@${u.at??""}`).join("|");return d.useEffect(()=>{const u=new Map;for(const x of e){const j=Ai(x);if(o.current.has(j))continue;const w=x.at===null?Number.NaN:Date.parse(x.at),b=Number.isNaN(w)?0:w+r_,v=u.get(j);(!v||b>v.until)&&u.set(j,{plugin:x.plugin,name:x.name,until:b})}if(u.size===0)return;let p=!1,f;const h=async()=>{const x=Date.now();for(const[j,w]of[...u]){const b=await l(w.plugin,w.name).catch(()=>null);if(p)return;const v=x<=w.until;b!=null&&b.ok?(u.delete(j),i(m=>{const y={served:new Set(m.served).add(j),live:v?new Set(m.live).add(j):m.live,scope:m.scope};return o.current=y.served,y})):v||u.delete(j)}!p&&u.size>0&&(f=setTimeout(()=>void h(),a))};return h(),()=>{p=!0,f!==void 0&&clearTimeout(f)}},[c,t,l,a]),r}const yh="workspace-files";function l_(e){let t=0;for(const n of e)for(const r of n.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:o,path:l}=i;typeof o=="string"&&o.trim()!==""&&typeof l=="string"&&l!==""&&(t+=1)}return t}function a_(e){const[t,n]=d.useState(null);return d.useEffect(()=>{if(n(null),!e)return;let r=!1;return(async()=>{var o;const i=await A.pages();for(const l of Array.isArray(i==null?void 0:i.files)?i.files:[]){const a=await A.pageQuery(l.plugin,l.workspace,{agent:e}).catch(()=>null),c=(o=a==null?void 0:a.data)==null?void 0:o.workspace;if(c&&typeof c.name=="string")return{files:l,agentId:e,root:c.name}}return null})().then(i=>{r||n(i)}).catch(()=>{}),()=>{r=!0}},[e]),t&&t.agentId===e?t:null}function c_(e,t){return{id:yh,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 wh(e){return`agent-properties:${e}`}function u_(e){return{id:wh(e.id),tool:`@${e.handle}`,title:"Properties",renderer:"profile",props:{profile:e},at:null,source:"profile",substantial:!1}}function d_(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 xk({progress:e}){return s.jsxs(G,{gap:"sm",children:[s.jsx("span",{role:"status",children:d_(e)}),s.jsx(OI,{value:(e==null?void 0:e.percent)??0,label:"Fetching the browser"})]})}function f_(e,t,n,r){const i=e.width||1,o=e.height||1,l=t.pageScaleFactor||1,a=(n-e.left)*(t.deviceWidth/i)/l,c=((r-e.top)*(t.deviceHeight/o)-t.offsetTop)/l,u=(p,f)=>Math.max(0,Math.min(Math.round(p),Math.round(f)));return{x:u(a,t.deviceWidth),y:u(c,t.deviceHeight)}}function Rd(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function Dv(e){return[...e].length===1&&e.codePointAt(0)>=32&&e.codePointAt(0)!==127}const h_=4e3;function p_(e){return e.replace(/\r\n?/g,`
|
|
99
|
-
`).replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g,"").slice(0,h_)}const m_=["left","middle","right"],g_=33;function x_(e,t){return e.deviceWidth===t.deviceWidth&&e.deviceHeight===t.deviceHeight&&e.pageScaleFactor===t.pageScaleFactor&&e.offsetTop===t.offsetTop}function v_(e){if(e.byteLength<3)return null;const t=new DataView(e);if(t.getUint8(0)!==1)return null;const n=t.getUint16(1);if(e.byteLength<3+n)return null;try{return{metadata:JSON.parse(new TextDecoder().decode(new Uint8Array(e,3,n))),jpeg:new Blob([new Uint8Array(e,3+n)],{type:"image/jpeg"})}}catch{return null}}function j_(e=window.location){return`${e.protocol==="https:"?"wss":"ws"}://${e.host}/api/browser/hand`}function y_({sessionId:e,csrf:t,onGiveBack:n,connect:r}){const[i,o]=d.useState("connecting"),[l,a]=d.useState(null),[c,u]=d.useState(!1),[p,f]=d.useState(null),[h,x]=d.useState(!1),[j,w]=d.useState(0),b=d.useRef(null),v=d.useRef(null),m=d.useRef(null),y=d.useRef({at:0});d.useEffect(()=>{const T=r??(K=>new WebSocket(K));let z=!0,q;try{q=T(j_())}catch{o("lost");return}return q.binaryType="arraybuffer",b.current=q,q.onopen=()=>q.send(JSON.stringify({type:"hello",csrf:t,sessionId:e})),q.onmessage=K=>{if(!z)return;if(typeof K.data!="string"){const W=v_(K.data);if(!W||(f(_=>_&&x_(_,W.metadata)?_:W.metadata),u(!0),typeof createImageBitmap!="function"))return;createImageBitmap(W.jpeg).then(_=>{var X,Z,ue;const U=v.current;if(!z||!U){(X=_.close)==null||X.call(_);return}(U.width!==_.width||U.height!==_.height)&&(U.width=_.width,U.height=_.height),(Z=U.getContext("2d"))==null||Z.drawImage(_,0,0),(ue=_.close)==null||ue.call(_)}).catch(()=>{});return}const M=JSON.parse(K.data);if(M.type==="driving"){o("driving"),a(null);return}(M.type==="refused"||M.type==="ended")&&(a(M.error??"The screen cannot be driven from here."),o("refused"))},q.onclose=()=>{z&&o(K=>K==="refused"?K:"lost")},q.onerror=()=>{z&&o(K=>K==="refused"?K:"lost")},()=>{z=!1,b.current=null;try{q.close()}catch{}}},[e,t,j,r]),d.useEffect(()=>()=>{clearTimeout(y.current.timer)},[]);const g=d.useCallback(T=>{const z=b.current;if(z)try{z.send(JSON.stringify({type:"input",input:T}))}catch{}},[]),k=T=>{var K;const z=v.current;if(!z||!p)return null;const q=(K=z.getBoundingClientRect)==null?void 0:K.call(z);return q?f_(q,p,T.clientX,T.clientY):null},S=T=>{const z=y.current,q=Date.now();clearTimeout(z.timer),z.timer=void 0;const K=z.at+g_-q;if(K<=0){z.at=q,z.pending=void 0,g(T);return}z.pending=T,z.timer=setTimeout(()=>{const M=y.current.pending;y.current.timer=void 0,y.current.pending=void 0,y.current.at=Date.now(),M&&g(M)},K)},N=()=>{const T=y.current;clearTimeout(T.timer),T.timer=void 0;const z=T.pending;T.pending=void 0,z&&(T.at=Date.now(),g(z))},C=T=>z=>{var M,W;const q=k(z);if(!q)return;T==="mousePressed"&&(z.preventDefault(),(W=(M=v.current)==null?void 0:M.focus)==null||W.call(M));const K={kind:"mouse",type:T,x:q.x,y:q.y,button:m_[z.button]??"left",clickCount:T==="mouseMoved"?0:Math.min(3,Math.max(1,z.detail||1)),modifiers:Rd(z)};if(T==="mouseMoved"){S(K);return}N(),g(K)},P=T=>{const z=k(T);z&&(N(),g({kind:"wheel",x:z.x,y:z.y,deltaX:Math.round(T.deltaX),deltaY:Math.round(T.deltaY)}))},E=T=>T.ctrlKey||T.metaKey||T.altKey,O=T=>{var q,K;if(T.key==="Escape"&&E(T)){x(!1),(K=(q=T.target).blur)==null||K.call(q);return}if(T.preventDefault(),(T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))return;const z=Rd(T);if(Dv(T.key)&&!E(T)){g({kind:"key",type:"char",key:T.key,code:T.code,text:T.key,modifiers:z});return}g({kind:"key",type:"keyDown",key:T.key,code:T.code,modifiers:z})},L=T=>{T.key==="Escape"&&E(T)||(T.preventDefault(),!((T.metaKey||T.ctrlKey)&&(T.key==="v"||T.key==="V"))&&(Dv(T.key)&&!E(T)||g({kind:"key",type:"keyUp",key:T.key,code:T.code,modifiers:Rd(T)})))},D=T=>{var q;T.preventDefault();const z=p_(((q=T.clipboardData)==null?void 0:q.getData("text/plain"))??"");z!==""&&g({kind:"text",text:z})};return s.jsxs("section",{className:"hand","data-testid":"remote-hand","data-phase":i,"aria-label":"Driving the host browser",children:[s.jsxs("div",{className:"hand-bar",children:[s.jsx("span",{className:"hand-said",role:"status",children:"You are driving. Nothing you type here is kept."}),s.jsxs(J,{align:"end",children:[s.jsx(R,{size:"sm",variant:h?"accent":"ghost","aria-pressed":h,onClick:()=>{var z,q,K,M;const T=!h;x(T),T?(q=(z=m.current)==null?void 0:z.focus)==null||q.call(z):(M=(K=m.current)==null?void 0:K.blur)==null||M.call(K)},children:"Keyboard"}),s.jsx(R,{size:"sm",variant:"accent",onClick:n,children:"Give it back"})]})]}),i==="lost"?s.jsxs(V,{tone:"warning",role:"status",children:["Connection lost. The picture below is the last frame that arrived.",s.jsx(J,{align:"end",children:s.jsx(R,{size:"sm",variant:"accent",onClick:()=>{o("connecting"),w(T=>T+1)},children:"Reconnect"})})]}):null,i==="refused"&&l?s.jsx(V,{tone:"warning",role:"status",children:l}):null,s.jsx("div",{className:"hand-screen",children:c?s.jsx("canvas",{ref:v,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:P,onKeyDown:O,onKeyUp:L,onPaste:D,onContextMenu:T=>T.preventDefault()}):s.jsx("p",{className:"muted hand-waiting",children:i==="lost"?"No picture arrived before the connection dropped.":"Waiting for the first frame…"})}),s.jsx("input",{ref:m,className:"hand-typing","aria-label":"Type into the host browser",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,value:"",onChange:()=>{},onKeyDown:O,onKeyUp:L,onPaste:D,onBlur:()=>x(!1)})]})}function w_(e){return e==="darwin"?"this Mac":"this computer"}let Pd=null;function Am(){const[e,t]=d.useState(void 0);return d.useEffect(()=>{let n=!0;return Pd??(Pd=A.session().then(r=>r.platform,()=>{Pd=null})),Pd.then(r=>{n&&t(r)}),()=>{n=!1}},[]),w_(e)}function b_({embedded:e,timezone:t}={}){var c;const{data:n,error:r,reload:i}=se(()=>A.browser(),[],3e3),o=se(()=>A.session(),[]),l=(c=o.data)!=null&&c.platform?o.data.platform==="darwin":!0,a=!!o.data||!!o.error;return s.jsxs(an,{embedded:e,title:"Computer & browser",children:[s.jsx(re,{message:r}),!n||!a?s.jsx(ie,{children:"Checking the host…"}):s.jsx(k_,{data:n,macOS:l,reload:i,timezone:t},JSON.stringify(n.settings??null))]})}function k_({data:e,macOS:t,reload:n,timezone:r}){var N,C,P;const[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1),p=e.settings&&!t&&e.settings.mode==="computer"?{...e.settings,mode:"playwright"}:e.settings,f=(p==null?void 0:p.mode)??(!t&&e.mode==="computer"?"playwright":e.mode),h=f==="computer",x=(N=e.sessions)!=null&&N.length?e.sessions:e.session?[e]:[],j=x.length>0||e.busy,w=async E=>{o(!0),a(null);try{await E()}catch(O){a(O instanceof Error?O.message:String(O))}finally{o(!1),n()}},b=E=>void w(()=>A.browserSettings(E)),v=e.permissions,m=f==="playwright"?e.browser:void 0,y=((C=m==null?void 0:m.install)==null?void 0:C.state)==="running",g=(m==null?void 0:m.engine)==="none",k=!!e.enabled&&!g&&!(m!=null&&m.problem)&&(!h||!(v!=null&&v.supported)||v.accessibility&&v.screenRecording),S=h?"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.":(m==null?void 0:m.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 s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:l}),s.jsx(Y,{title:"Status",panel:!0,actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",disabled:i,onClick:()=>void w(()=>A.computerPermissions(!1)),children:"Check again"}),h&&!k&&(v!=null&&v.supported)?s.jsx(R,{size:"sm",variant:"accent",disabled:i||j,onClick:()=>void w(()=>A.computerPermissions(!0)),children:"Request macOS permissions"}):null,g||y?s.jsx(R,{size:"sm",variant:"accent",disabled:i||y,onClick:()=>void w(()=>A.browserInstall()),children:y?"Installing…":"Install Chromium"}):null]}),children:s.jsxs(G,{children:[e.enabled?g?s.jsxs(V,{tone:"warning",title:"No browser installed for the agents yet",children:["Install Chromium here (about 150 MB), or run ",s.jsx("code",{children:"buddi browser install"})," on this machine."]}):m!=null&&m.problem?s.jsx(V,{tone:"warning",children:m.message}):k?s.jsx(V,{tone:"good",children:S}):s.jsx(V,{tone:"warning",children:"macOS has not granted everything yet. Grant the permissions below, then check again."}):s.jsx(V,{tone:"warning",children:"The host is not available. Start buddi serve on a machine with a desktop session."}),h?v!=null&&v.supported?s.jsxs("ul",{className:"perm-list",children:[s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:v.accessibility?"good":"warning",children:v.accessibility?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Accessibility"}),s.jsx("span",{className:"muted",children:"Lets agents click and type in the apps you allow."})]}),s.jsxs("li",{className:"perm-row",children:[s.jsx(pe,{tone:v.screenRecording?"good":"warning",children:v.screenRecording?"Granted":"Needed"}),s.jsx("span",{className:"perm-name",children:"Screen Recording"}),s.jsx("span",{className:"muted",children:"Lets agents see the window they are working in."})]})]}):v?s.jsx("p",{className:"muted",children:"Computer control requires macOS 14 or later."}):null:null,((P=m==null?void 0:m.install)==null?void 0:P.state)==="running"?s.jsx(xk,{progress:m.install.progress}):m!=null&&m.install?s.jsx("p",{className:"muted",role:"status",children:m.install.state==="done"?"Chromium is installed. Agents can open their browser now.":`The install did not finish: ${m.install.line??"no reason given"}`}):null,m!=null&&m.headless&&!g?s.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,h&&(v!=null&&v.message)?s.jsx("p",{className:"muted",children:v.message}):null,h&&(v!=null&&v.supported)&&!k?s.jsx("p",{className:"muted",children:"macOS may ask you to restart buddi after granting them."}):null]})}),s.jsx(Y,{title:"Who is driving",panel:!0,actions:x.length>0?s.jsx(R,{variant:"danger",size:"sm",disabled:i,onClick:()=>void w(()=>A.browserControl("stop")),children:h?"Stop computer control":"Stop all browsers"}):void 0,children:x.length===0?s.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."}):s.jsx("div",{className:"ui-list",children:x.map(E=>s.jsxs("a",{className:"ui-list-row",href:ze(E.session.agentId,E.session.conversationId),children:[s.jsx(as,{id:E.session.agentId,name:E.session.agentId,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:E.session.task}),s.jsxs("span",{className:"ui-list-sub",children:[E.session.agentId,", ",E.busy?"working":E.state,", ",E.session.steps," of ",E.session.maxSteps," steps"]})]}),s.jsx("span",{className:"ui-list-side",children:"Open the Canvas"})]},E.session.id))})}),p?s.jsxs(s.Fragment,{children:[s.jsx(Y,{title:"How agents get a screen",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsxs("div",{className:"mode-choice",role:"radiogroup","aria-label":"Control mode",children:[t?s.jsx(Id,{current:p.mode,value:"computer",disabled:i||j||!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({...p,mode:"computer"})}):null,s.jsx(Id,{current:p.mode,value:"playwright",disabled:i||j||!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({...p,mode:"playwright"})}),s.jsx(Id,{current:p.mode,value:"extension",disabled:i||j||!e.enabled,title:"Your browser",body:"Uses the Chrome you are signed in to, in background tabs, through the buddi extension.",onPick:()=>b({...p,mode:"extension"})})]}),t?null:s.jsx("p",{className:"muted",children:"Using your own apps is macOS-only."}),j?s.jsx("p",{className:"muted",children:"Finish or stop the current session before changing this."}):null,p.mode==="extension"?s.jsx(E_,{busy:i,timezone:r}):null]})}),t?s.jsx(Y,{title:"Apps agents may use",panel:!0,children:s.jsxs(G,{children:[p.mode!=="computer"?s.jsx("p",{className:"muted",children:"Only used by “Use my apps”. The list is kept for when you switch back."}):null,s.jsx(A_,{settings:p,disabled:i||j||!e.enabled,onChange:b,onAdd:()=>u(!0)}),s.jsx(wt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[s.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."}),s.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."}),s.jsx("p",{children:"This is an allow list, not a sandbox: an allowed app’s own network traffic is not inspected."})]})})]})}):null,c?s.jsx(M_,{chosen:p.allowedApps,onClose:()=>u(!1),onPick:E=>{u(!1),p.allowedApps.includes(E)||b({...p,allowedApps:[...p.allowedApps,E]})}}):null]}):null]})}const S_="kmbckpnnjfggeffkkbmkggojnolkdokb";async function N_(){var e;try{if(typeof chrome>"u"||!((e=chrome==null?void 0:chrome.runtime)!=null&&e.sendMessage))return null;const t=await chrome.runtime.sendMessage(S_,{type:"buddi.status"});return t!=null&&t.installed?t:null}catch{return null}}function C_(e){try{return new URL(e).origin===window.location.origin}catch{return!1}}function E_({busy:e,timezone:t}){const{data:n,error:r,reload:i}=se(()=>A.extension(),[],3e3),o=Am(),l=se(()=>N_(),[],3e3).data??null,[a,c]=d.useState(""),[u,p]=d.useState(!1),[f,h]=d.useState(null),x=(l==null?void 0:l.state)==="pairing"?l.code??"":"";d.useEffect(()=>{x&&c(x)},[x]);const j=async m=>{p(!0),h(null);try{await m()}catch(y){h(y instanceof Error?y.message:String(y))}finally{p(!1),i()}},w=e||u,b=t??Intl.DateTimeFormat().resolvedOptions().timeZone,v=s.jsxs("div",{className:"ui-prose muted",children:[s.jsx("p",{children:"Open chrome://extensions, turn on Developer mode, choose Load unpacked, and pick this folder."}),s.jsx(at,{label:"The unpacked extension",children:(n==null?void 0:n.path)??"…"})]});return s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:r??f}),s.jsxs(J,{children:[s.jsx(pe,{tone:n!=null&&n.connected?"good":"warning",children:n!=null&&n.connected?"Connected":"Not connected"}),s.jsxs("span",{className:"muted",children:[n!=null&&n.connected&&n.pairedAt?`Paired with Chrome on ${o} since ${Re(n.pairedAt,b)}`:n!=null&&n.pairedAt?"Paired, but Chrome is not running the extension right now.":"No browser is paired with this buddi yet.",n!=null&&n.extension?` · extension ${n.extension}`:""]})]}),s.jsxs(G,{children:[s.jsxs("p",{className:"muted",children:[l?`The browser you are reading this in has the extension, version ${l.version}.`:n!=null&&n.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&&!C_(l.gateway)?s.jsx(V,{tone:"warning",children:`The extension is pointed at ${l.gateway}; set it to ${window.location.origin} in the popup.`}):null]}),n!=null&&n.pending?s.jsxs(J,{valign:"end",children:[s.jsx(ee,{grow:!0,label:"Pair your browser",hint:"Type the six digits the buddi extension is showing.",children:s.jsx("input",{"aria-label":"Pairing code",inputMode:"numeric",placeholder:"482 913",value:a,onChange:m=>c(m.target.value)})}),s.jsx(ro,{}),s.jsx(R,{variant:"accent",disabled:w||a.replace(/[^0-9]/g,"").length!==6,onClick:()=>void j(async()=>{await A.pairExtension(a),c("")}),children:"Pair"})]}):null,n!=null&&n.connected?s.jsx(wt,{summary:"Pair a different browser",children:v}):v,s.jsx(J,{align:"end",children:s.jsx(R,{variant:"danger",disabled:w||!(n!=null&&n.pairedAt),onClick:()=>void j(()=>A.forgetExtension()),children:"Forget this browser"})})]})}function Id({current:e,value:t,title:n,body:r,disabled:i,onPick:o}){const l=e===t;return s.jsxs("button",{type:"button",role:"radio","aria-checked":l,className:"mode-option",disabled:i,onClick:()=>{l||o()},children:[s.jsx("span",{className:"mode-option-dot","aria-hidden":"true"}),s.jsxs("span",{className:"mode-option-text",children:[s.jsx("span",{className:"mode-option-title",children:n}),s.jsx("span",{className:"mode-option-body",children:r})]})]})}function A_({settings:e,disabled:t,onChange:n,onAdd:r}){const i=se(()=>A.installedApps(),[]),o=l=>{var a,c;return((c=(a=i.data)==null?void 0:a.apps.find(u=>u.id===l))==null?void 0:c.name)??l};return s.jsxs(s.Fragment,{children:[e.allowedApps.length===0?s.jsx(ie,{children:"No apps yet. Agents cannot touch anything until you add one."}):s.jsx("ul",{className:"ui-list","aria-label":"Allowed apps",children:e.allowedApps.map(l=>s.jsxs("li",{className:"ui-list-row",children:[s.jsx(as,{id:l,name:o(l),size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[o(l),l===e.browserApp?s.jsx(pe,{tone:"accent",className:"app-role",children:"browser"}):null]}),s.jsx("span",{className:"ui-list-sub mono",children:l})]}),s.jsxs(J,{children:[l!==e.browserApp&&I_(l)?s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,browserApp:l}),children:"Use as browser"}):null,l===e.browserApp?s.jsx("span",{className:"muted",children:"In use as the browser"}):s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:()=>n({...e,allowedApps:e.allowedApps.filter(a=>a!==l)}),children:"Remove"})]})]},l))}),s.jsxs(J,{children:[s.jsx(R,{variant:"accent",disabled:t,onClick:r,children:"Add an app"}),s.jsx("span",{className:"muted",children:"The app marked as browser is the one agents open websites in."})]}),e.mode==="computer"&&T_.includes(e.browserApp)?s.jsx(R_,{settings:e,disabled:t,onChange:n}):null]})}const T_=["com.google.Chrome","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser"];function R_({settings:e,disabled:t,onChange:n}){var l;const i=((l=se(()=>A.browserProfiles(e.browserApp),[e.browserApp]).data)==null?void 0:l.profiles)??[],o=e.browserProfile?i.some(a=>a.directory===e.browserProfile):!0;return s.jsx(ee,{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:s.jsxs("select",{value:e.browserProfile??"",disabled:t,onChange:a=>{const{browserProfile:c,...u}=e;n(a.target.value?{...u,browserProfile:a.target.value}:u)},children:[s.jsx("option",{value:"",children:"Whichever is in front"}),!o&&e.browserProfile?s.jsxs("option",{value:e.browserProfile,children:[e.browserProfile," (not found)"]}):null,i.map(a=>s.jsxs("option",{value:a.directory,children:[a.name,a.directory==="Default"?"":` (${a.directory})`]},a.directory))]})})}const P_=["com.google.Chrome","com.apple.Safari","org.chromium.Chromium","com.microsoft.edgemac","com.brave.Browser","org.mozilla.firefox","company.thebrowser.Browser"];function I_(e){return P_.includes(e)}function M_({chosen:e,onClose:t,onPick:n}){const r=se(()=>A.installedApps(),[]),[i,o]=d.useState(""),[l,a]=d.useState(""),c=d.useMemo(()=>{var f;const u=((f=r.data)==null?void 0:f.apps)??[],p=i.trim().toLowerCase();return u.filter(h=>!p||h.name.toLowerCase().includes(p)||h.id.toLowerCase().includes(p)).slice(0,60)},[r.data,i]);return s.jsxs(qt,{title:"Add an app",onClose:t,children:[s.jsx("input",{autoFocus:!0,"aria-label":"Search apps",placeholder:"Search installed apps",value:i,onChange:u=>o(u.target.value)}),s.jsx(re,{message:r.error}),r.data?c.length===0?s.jsx(ie,{children:"No app matches."}):s.jsx("ul",{className:"ui-list","aria-label":"Installed apps",children:c.map(u=>{const p=e.includes(u.id);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx(as,{id:u.id,name:u.name,size:"sm"}),s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title",children:u.name}),s.jsx("span",{className:"ui-list-sub mono",children:u.id})]}),s.jsx(R,{size:"sm",disabled:p,onClick:()=>n(u.id),children:p?"Allowed":"Allow"})]},u.id)})}):s.jsx(ie,{children:"Reading your Applications folder…"}),s.jsx(wt,{summary:"Add by bundle identifier instead",children:s.jsxs(J,{children:[s.jsx("input",{"aria-label":"Bundle identifier",placeholder:"com.apple.TextEdit",value:l,onChange:u=>a(u.target.value)}),s.jsx(R,{disabled:!l.trim(),onClick:()=>n(l.trim()),children:"Allow this identifier"})]})})]})}function $_({data:e,error:t,reload:n,compact:r=!1,refresh:i,screenshotSrc:o,onScreenshotError:l,onScreenshotLoad:a,controls:c=!0}){var P,E,O;const[u,p]=d.useState(!1),[f,h]=d.useState(null),[x,j]=d.useState(null),[w,b]=d.useState(null),v=async L=>{p(!0),h(null),b(null);try{const D=L!=="stop"&&(e!=null&&e.session)?await A.browserControl(L,e.session.id):await A.browserControl(L);L==="takeover"?D.hand&&D.session?j(D.session.id):b(D.handMessage??null):j(null)}catch(D){h(D instanceof Error?D.message:String(D))}finally{p(!1),n()}},m=x&&((P=e==null?void 0:e.session)==null?void 0:P.id)===x&&e.state==="paused"?x:null,y=!!(e!=null&&e.enabled)&&!u,g=(e==null?void 0:e.mode)==="computer",k=(e==null?void 0:e.mode)==="extension",S=g?"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.",N=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 s.jsxs("section",{className:"browser-panel","data-compact":r?"true":void 0,"aria-label":"Host browser",children:[s.jsxs("div",{className:"browser-heading",children:[s.jsxs("div",{children:[r?null:s.jsx("p",{className:"browser-eyebrow",children:"On your host machine"}),s.jsx("h2",{className:"browser-title",children:g?"Computer":k?"Your browser":"Browser"})]}),s.jsx(pe,{tone:C,children:s.jsx("span",{role:"status",children:N})})]}),r?s.jsx("a",{className:"browser-full-view",href:"#/browser",children:g?"Open computer view & settings ↗":"Open full browser view ↗"}):s.jsx("p",{className:"ui-page-lede",children:g?"Your apps, operated through macOS accessibility, screenshots and input. No browser debugging connection.":k?"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."}),s.jsx(re,{message:t??f}),c?s.jsxs(J,{children:[s.jsx(R,{variant:"danger",disabled:!y||(e==null?void 0:e.state)==="stopped",onClick:()=>void v("stop"),children:g?"Stop computer control":"Stop all browsers"}),s.jsx(R,{disabled:!y||!(e!=null&&e.session)||(e==null?void 0:e.state)==="paused",onClick:()=>void v("takeover"),children:"Take over"}),s.jsx(R,{disabled:!y||(e==null?void 0:e.busy)||!["stopped","paused"].includes((e==null?void 0:e.state)??""),onClick:()=>void v("resume"),children:"Resume access"}),s.jsx(R,{disabled:!y||!(e!=null&&e.session),onClick:()=>void v("release"),children:g?"Release control":"Close & release"})]}):null,c?r?s.jsx(wt,{summary:"About these controls",children:s.jsx("p",{className:"muted",children:S})}):s.jsx("p",{className:"muted",children:S}):null,w?s.jsx(V,{tone:"warning",role:"status",children:w}):null,e!=null&&e.message&&!m?s.jsx(V,{tone:"warning",role:"status",children:e.message}):null,e!=null&&e.session?s.jsxs("div",{className:"browser-task",children:[s.jsxs("div",{className:"ui-row",children:[s.jsx("strong",{children:e.session.agentId}),s.jsxs("span",{className:"muted",children:[e.session.steps," / ",e.session.maxSteps," steps"]})]}),r?null:s.jsx("p",{children:e.session.task}),s.jsxs("p",{className:"muted",children:["Last action: ",e.lastAction??"None"," · Access expires ",new Date(e.session.expiresAt).toLocaleTimeString()]})]}):s.jsx("p",{className:"browser-task muted",children:e!=null&&e.enabled?g?"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."}),m?s.jsx(y_,{sessionId:m,csrf:Hr(),onGiveBack:()=>void v("resume")}):null,s.jsxs("div",{className:"browser-window",hidden:!!m,children:[s.jsxs("div",{className:"browser-address",children:[s.jsx("span",{"aria-hidden":"true",children:"◉"}),s.jsx("span",{children:((E=e==null?void 0:e.page)==null?void 0:E.url)??(g?"Waiting for an application":"Waiting for a website")})]}),e!=null&&e.hasScreenshot&&e.page?s.jsxs("figure",{children:[s.jsx("img",{src:o??`/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}:{},...a?{onLoad:a}:{}},o??e.page.id),s.jsxs("figcaption",{children:["Last observation · ",new Date(e.page.capturedAt).toLocaleTimeString()," · ",e.page.title||"Untitled page"]})]}):s.jsxs("div",{className:"browser-empty",children:[s.jsx("strong",{children:g?"Your selected app will appear here":"Your browser activity will appear here"}),s.jsx("p",{children:g?"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."})]})]}),(((O=e==null?void 0:e.page)==null?void 0:O.tabs.length)??0)>1?s.jsx(wt,{summary:`${e.page.tabs.length} open tabs`,children:s.jsx("ul",{className:"ui-prose",children:e.page.tabs.map(L=>s.jsxs("li",{children:[L.title||L.id," — ",L.url]},L.id))})}):null,s.jsxs("p",{className:"muted",children:[g?"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."," ",m?"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 __=2e3,O_=5;function D_(e,t){if(!e.hasScreenshot||!e.page)return null;const n=e.session?`&sessionId=${encodeURIComponent(e.session.id)}`:"";return`/api/browser/screenshot?v=${encodeURIComponent(e.page.id)}${n}`}function L_({status:e,error:t,reload:n,steps:r,live:i,focusedStepId:o=null}){var y;const[l,a]=d.useState(0),[c,u]=d.useState(0),p=c>=O_;d.useEffect(()=>{if(!i||p)return;const g=window.setInterval(()=>{typeof document<"u"&&document.hidden||a(k=>k+1)},__);return()=>window.clearInterval(g)},[i,p]);const f=d.useRef(null);i&&(e!=null&&e.session)&&(f.current=e);const[h,x]=d.useState(null),j=d.useRef(null),w=((y=e==null?void 0:e.page)==null?void 0:y.id)??null;d.useEffect(()=>{const g=i&&e?D_(e):null;if(!g||typeof fetch!="function"||typeof(URL==null?void 0:URL.createObjectURL)!="function")return;let k=!1;return(async()=>{try{const S=await fetch(g);if(!S.ok||k)return;const N=await S.blob();if(k)return;const C=URL.createObjectURL(N);j.current&&URL.revokeObjectURL(j.current),j.current=C,x(C)}catch{}})(),()=>{k=!0}},[i,w]),d.useEffect(()=>()=>{j.current&&typeof(URL==null?void 0:URL.revokeObjectURL)=="function"&&URL.revokeObjectURL(j.current)},[]);const b=f.current,v=i?e:b?h?b:{...b,hasScreenshot:!1}:e,m=r.at(-1)??null;return s.jsxs("div",{className:"wb-browser","data-testid":"browser-view","data-live":i?"true":"false",children:[s.jsx($_,{data:v,error:t,reload:n,compact:!0,controls:i,...i?{refresh:l}:{},...!i&&h?{screenshotSrc:h}:{},onScreenshotError:()=>u(g=>g+1),onScreenshotLoad:()=>u(0)}),i?p?s.jsx("p",{className:"muted wb-browser-ended",role:"status",children:"The last observation could not be loaded. Showing what arrived before it."}):null:s.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."}),s.jsx(F_,{steps:r,newestId:(m==null?void 0:m.id)??null,focusedId:o??null,live:i})]})}function F_({steps:e,newestId:t,focusedId:n,live:r}){const i=d.useRef(null);return d.useEffect(()=>{var l;if(!n||!i.current)return;const o=i.current.querySelector(`[data-step="${CSS!=null&&CSS.escape?CSS.escape(n):n}"]`);(l=o==null?void 0:o.scrollIntoView)==null||l.call(o,{block:"nearest"})},[n]),e.length===0?s.jsx("p",{className:"muted wb-browser-empty",children:r?"No action taken on this screen yet.":"This conversation took no action on the screen."}):s.jsx("section",{className:"wb-browser-steps","aria-label":"Steps taken on this screen",children:s.jsx("ol",{className:"wb-browser-list",ref:i,children:e.map((o,l)=>{const a=o.awaiting?"awaiting":o.ok===null?"running":o.ok?"ok":"failed";return s.jsxs("li",{"data-step":o.id,className:"wb-browser-step","data-state":a,"data-newest":o.id===t?"true":void 0,"data-focused":o.id===n?"true":void 0,children:[s.jsx("span",{className:"wb-browser-index mono",children:l+1}),s.jsxs("span",{className:"wb-browser-what",children:[s.jsx("strong",{children:o.action}),o.target?s.jsx("span",{className:"muted wb-browser-target",children:o.target}):null,o.error?s.jsx("span",{className:"wb-browser-error",children:o.error}):null]}),s.jsx("span",{className:"wb-browser-outcome","data-state":a,children:a==="awaiting"?"Awaiting approval":a==="running"?"Working":a==="ok"?"Done":"Failed"})]},o.id)})})})}function z_({agentId:e,conversationId:t}){const{data:n,error:r,reload:i}=se(()=>A.host(e,t),[e,t],2e3),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=async x=>{c(!0),l(null);try{await x(),i()}catch(j){l(j instanceof Error?j.message:String(j))}finally{c(!1)}},p=(n==null?void 0:n.permissions)??[],f=(n==null?void 0:n.runs)??[],h=p.some(x=>!x.conversationId)?"Always allowed":p.length?"Conversation auto-mode":"Ask each time";return s.jsx(wt,{className:"host-controls",summary:`Host execution · ${r?"Status unavailable":h}${f.length?` · ${f.length} running`:""}`,children:s.jsxs(G,{gap:"sm",children:[s.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."}),s.jsx(re,{message:o??r}),p.map(x=>s.jsxs(J,{children:[s.jsxs("span",{children:[x.agentId,": ",x.conversationId?"conversation auto-mode":"always allowed"]}),s.jsx(R,{size:"sm",disabled:a,onClick:()=>void u(()=>A.revokeHost(x.id)),children:"Revoke permission"})]},x.id)),p.length?null:s.jsx("p",{className:"muted",children:"The next command will ask for approval. Choose its permission scope there."}),f.map(x=>s.jsxs(G,{gap:"sm",children:[s.jsxs("p",{children:[x.agentId," · ",s.jsx("span",{className:"mono",children:x.cwd})]}),s.jsx(at,{children:x.command}),s.jsx(at,{label:"Command output",children:x.stdout||x.stderr?`${x.stdout}
|
|
100
|
-
${x.stderr}`:"Waiting for output…"}),s.jsx(J,{children:s.jsx(R,{size:"sm",variant:"danger",disabled:a,onClick:()=>void u(()=>A.stopHost(x.agentId,x.conversationId)),children:"Stop command"})})]},x.actionId))]})})}const vk="browser.act",U_="browser.status",Va=new Set([vk,U_]);function B_(e,t,n){const r=e==null?void 0:e.session;return!r||!t||!n||r.agentId!==t||r.conversationId!==n?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 W_(e,t){return{...e,title:`${t==="computer"?"Computer":"Browser"} (ended)`,pinned:!1}}function H_(e){var r;const t=[],n=new Map;for(const i of e)for(const o of i.blocks??[]){if(o.type==="tool_use"&&o.name===vk){const a={id:o.id,action:V_(o.input)??"act",target:K_(o.input),ok:null,awaiting:!1,error:null,at:i.at??null};t.push(a),n.set(o.id,a);continue}if(o.type!=="tool_result")continue;const l=n.get(o.toolUseId);if(l){if(((r=o.approval)==null?void 0:r.state)==="pending"){l.awaiting=!0,l.ok=null,l.error=null;continue}l.awaiting=!1,l.ok=o.ok,l.error=o.ok?null:G_(o)}}return t}function Lv(e,t){var r;let n=!1;for(const i of e)for(const o of i.blocks??[])if(o.type==="tool_use"&&o.id===t&&(n=Va.has(o.name)),o.type==="tool_result"&&o.toolUseId===t&&((r=o.approval)==null?void 0:r.state)==="pending")return null;return n?t:null}function V_(e){if(e===null||typeof e!="object")return null;const t=e.action;return typeof t=="string"&&t!==""?t:null}function K_(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 n=t.target;if(n!==null&&typeof n=="object"){const r=n,i=r.name;if(typeof i=="string"&&i!=="")return i;const o=r.ref;if(typeof o=="string"&&o!=="")return o;if(typeof r.x=="number"&&typeof r.y=="number")return`${r.x}, ${r.y}`}return null}function G_(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 n of["message","error","reason"]){const r=t[n];if(typeof r=="string"&&r.trim()!=="")return r.trim()}}return null}function Y_({agentId:e,groupId:t,currentId:n,timezone:r,onSelect:i,onNew:o}){const[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(0);return d.useEffect(()=>{let h=!1;return a(null),u(null),(t?Fe.groupConversations(t):Fe.conversations(e,100)).then(x=>{h||a(x.conversations)}).catch(x=>{h||u(x instanceof Error?x.message:String(x))}),()=>{h=!0}},[e,t,p]),s.jsxs("section",{className:"wb-history","aria-label":"Past conversations",children:[s.jsxs("div",{className:"ui-toolbar",children:[s.jsx("strong",{children:"Past conversations"}),s.jsx("button",{className:"ui-btn",onClick:o,children:"New conversation"})]}),c?s.jsxs("p",{role:"alert",children:[c," ",s.jsx("button",{className:"ui-btn",onClick:()=>f(h=>h+1),children:"Retry"})]}):l===null?s.jsx("p",{className:"muted",children:"Loading conversations…"}):l.length===0?s.jsx("p",{className:"muted",children:"No conversations yet."}):s.jsx("ul",{children:l.map(h=>s.jsx("li",{children:s.jsxs("a",{href:t?Fo(t,h.id):ze(e,h.id),"aria-current":h.id===n?"page":void 0,onClick:x=>{x.button===0&&!x.metaKey&&!x.ctrlKey&&!x.shiftKey&&!x.altKey&&(x.preventDefault(),i(h.id))},children:[s.jsx("span",{children:h.preview||h.opening||"Untitled conversation"}),s.jsxs("small",{children:[Re(h.lastMessageAt??h.startedAt??h.createdAt??null,r)," · ",h.messageCount," messages",h.id===n?" · Current":""]})]})},h.id))}),s.jsx("a",{href:"#/conversations",children:"View all agents’ conversation records ↗"}),(l==null?void 0:l.length)===100?s.jsx("p",{className:"muted",children:"Showing the 100 most recent conversations."}):null]})}const jk="buddi.dismissedTabs";function q_(){try{const e=JSON.parse(sessionStorage.getItem(jk)??"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([,t])=>Array.isArray(t)&&t.every(n=>typeof n=="string")))}catch{return{}}}function Fv(e){try{sessionStorage.setItem(jk,JSON.stringify(Object.fromEntries(Object.entries(e).slice(-100))))}catch{}}const Q_="This browser cannot capture a tab. Chrome, Safari and Firefox can, on a secure address.",ha="The tab could not be captured. Try again, and pick the tab itself rather than the whole screen.",J_=e=>e instanceof Error&&(e.name==="NotAllowedError"||e.name==="AbortError");async function X_(e={}){var r;const t=e.media??(typeof navigator>"u"?void 0:navigator.mediaDevices);if(!t||typeof t.getDisplayMedia!="function")throw new Error(Q_);let n;try{n=await t.getDisplayMedia({video:{displaySurface:"browser"},audio:!1,selfBrowserSurface:"exclude",surfaceSwitching:"exclude",preferCurrentTab:!1})}catch(i){if(J_(i))return null;throw new Error(ha)}try{const i=e.document??document,o=i.createElement("video");o.muted=!0,o.playsInline=!0,o.srcObject=n,await new Promise((p,f)=>{o.onloadedmetadata=()=>p(),o.onerror=()=>f(new Error(ha))}),await o.play(),await new Promise(p=>{const f=o.requestVideoFrameCallback;typeof f=="function"?f.call(o,()=>p()):setTimeout(p,120)});const l=i.createElement("canvas");l.width=o.videoWidth,l.height=o.videoHeight;const a=l.getContext("2d");if(!a||l.width===0)throw new Error(ha);a.drawImage(o,0,0);const c=await new Promise(p=>l.toBlob(p,"image/png"));if(!c)throw new Error(ha);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{n.getTracks().forEach(i=>i.stop())}}const zv="Send files once the agent has answered.",Z_=d.forwardRef(function({disabled:t,running:n,onSend:r,onStop:i,agentName:o,draft:l,model:a,setupHref:c,thinking:u,onThinking:p,onOpenFile:f,mentions:h,history:x,threadKey:j},w){var Vn;const b=j?`buddi.draft.${j}`:null,v=F=>{if(!F)return"";try{return window.localStorage.getItem(F)??""}catch{return""}},[m,y]=d.useState(()=>v(b)),[g,k]=d.useState([]),[S,N]=d.useState(!1),[C,P]=d.useState(null),[E,O]=d.useState(!1),L=d.useRef(null),D=d.useRef(null),[T,z]=d.useState(null),[q,K]=d.useState(0),M=T&&h?h.filter(F=>F.handle.toLowerCase().startsWith(T.query.toLowerCase())||F.name.toLowerCase().startsWith(T.query.toLowerCase())).slice(0,6):[],W=(F,ae)=>{if(!h||h.length===0){z(null);return}const Ae=F.slice(0,ae),Pt=/(^|\s)@([\w-]*)$/.exec(Ae);if(!Pt){z(null);return}z({start:ae-Pt[2].length-1,query:Pt[2]}),K(0)},_=F=>{if(!T)return;const ae=D.current,Ae=ae?ae.selectionStart:m.length,Pt=`${m.slice(0,T.start)}@${F} ${m.slice(Ae)}`;y(Pt),X<0&&Ce(Pt),z(null),window.requestAnimationFrame(()=>{if(!ae)return;const pt=T.start+F.length+2;ae.focus(),ae.setSelectionRange(pt,pt),St()})},U=x??[],[X,Z]=d.useState(-1),ue=d.useRef(m),je=d.useRef(b);if(je.current!==b){je.current=b;const F=v(b);ue.current=F,F!==m&&(y(F),Z(-1),z(null))}const Ce=F=>{if(ue.current=F,!!b)try{F===""?window.localStorage.removeItem(b):window.localStorage.setItem(b,F)}catch{}},Pe=F=>{y(F),z(null);const ae=D.current;ae&&(ae.value=F,ae.setSelectionRange(F.length,F.length)),window.requestAnimationFrame(St)},Ve=F=>!F.value.slice(0,F.selectionStart??F.value.length).includes(`
|
|
101
|
-
`),he=()=>m===""||X>=0&&m===U[X],ge=()=>{X<0||(Z(-1),Pe(ue.current))},ye=g.some(F=>F.state==="uploading"),kt=g.length>0,ct=n&&kt,_e=!t&&!ye&&!ct&&m.trim()!=="",$=F=>{for(const ae of Array.from(F??[])){const Ae=`${ae.name}:${ae.size}:${Math.random().toString(36).slice(2,8)}`,Pt=ae.type.startsWith("image/")&&typeof URL.createObjectURL=="function"?URL.createObjectURL(ae):null;k(pt=>[...pt,{key:Ae,filename:ae.name||"Pasted image",mime:ae.type||"application/octet-stream",sizeBytes:ae.size,thumbnail:Pt,state:"uploading"}]),Fe.attach(ae).then(pt=>k(Os=>Os.map(ds=>ds.key===Ae?{...ds,state:"ready",uploaded:pt}:ds))).catch(pt=>k(Os=>Os.map(ds=>ds.key===Ae?{...ds,state:"failed",error:pt instanceof ce?pt.message:String(pt)}:ds)))}},de=F=>{F.thumbnail&&typeof URL.revokeObjectURL=="function"&&URL.revokeObjectURL(F.thumbnail)},xe=F=>{const ae=g.find(Ae=>Ae.key===F);ae&&(de(ae),ae.state==="ready"&&ae.uploaded&&Fe.discardAttachment(ae.uploaded.artifactId).catch(()=>{})),k(Ae=>Ae.filter(Pt=>Pt.key!==F))};d.useImperativeHandle(w,()=>({addFiles:F=>{var ae;$(F),(ae=D.current)==null||ae.focus()},focus:()=>{var F;return(F=D.current)==null?void 0:F.focus()}}));const be=d.useRef(g);be.current=g,d.useEffect(()=>()=>be.current.forEach(de),[]);const it=d.useRef(0);d.useEffect(()=>{if(!l||l.at===it.current)return;it.current=l.at,y(ae=>ae.trim()===""?l.text:ae),X<0&&m.trim()===""&&Ce(l.text);const F=D.current;F&&(F.focus(),window.requestAnimationFrame(()=>{F.style.height="auto",F.style.height=`${Math.min(F.scrollHeight,200)}px`,F.setSelectionRange(F.value.length,F.value.length)}))},[l]);const St=()=>{const F=D.current;F&&(F.style.height="auto",F.style.height=`${Math.min(F.scrollHeight,200)}px`)},cn=()=>{if(!_e)return;const F=g.filter(ae=>ae.state==="ready"&&ae.uploaded).map(ae=>ae.uploaded);r(m.trim(),F),g.forEach(de),Z(-1),Ce(""),y(""),k([]),window.requestAnimationFrame(St)},Tn=F=>{if(T&&M.length>0){if(F.key==="ArrowDown"){F.preventDefault(),K(ae=>(ae+1)%M.length);return}if(F.key==="ArrowUp"){F.preventDefault(),K(ae=>(ae-1+M.length)%M.length);return}if(F.key==="Enter"||F.key==="Tab"){F.preventDefault(),_(M[q].handle);return}if(F.key==="Escape"){F.preventDefault(),z(null);return}}if(F.key==="ArrowUp"&&!F.shiftKey&&!F.altKey&&!F.metaKey&&!F.ctrlKey){const ae=F.currentTarget;if(U.length>0&&X+1<U.length&&Ve(ae)&&he()){F.preventDefault(),X<0&&(ue.current=m),Z(X+1),Pe(U[X+1]);return}}if(F.key==="ArrowDown"&&!F.shiftKey&&!F.altKey&&!F.metaKey&&!F.ctrlKey&&X>=0&&m===U[X]){if(F.preventDefault(),X===0){ge();return}Z(X-1),Pe(U[X-1]);return}if(F.key==="Escape"&&X>=0){F.preventDefault(),ge();return}F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),cn())},xr=F=>{var Ae;const ae=Array.from(((Ae=F.clipboardData)==null?void 0:Ae.files)??[]);ae.length!==0&&(F.preventDefault(),$(ae))},_s=g.filter(F=>F.state==="failed"),Rn=_s.length;return s.jsx("div",{className:"wb-composer","data-testid":"composer",children:s.jsxs("div",{className:"wb-composer-box","data-focused":E,"data-disabled":t,children:[g.length>0?s.jsx("div",{className:"wb-composer-files",role:"list","aria-label":"Files to send",children:g.map(F=>s.jsx("span",{role:"listitem",children:s.jsx(dk,{name:F.filename,mime:F.mime,sizeBytes:F.sizeBytes,thumbnail:F.thumbnail,state:F.state,error:F.error,onRemove:()=>xe(F.key),...f&&F.state==="ready"&&F.uploaded?{onOpen:()=>f(eO(F.uploaded))}:{},size:"sm"})},F.key))}):null,s.jsxs("label",{className:"sr-only",htmlFor:"wb-composer-input",children:["Message ",o]}),s.jsx("textarea",{id:"wb-composer-input",ref:D,value:m,rows:2,placeholder:n?`${o} is working…`:`Message ${o}`,onChange:F=>{y(F.target.value),X<0&&Ce(F.target.value),W(F.target.value,F.target.selectionStart??F.target.value.length),St()},onFocus:()=>O(!0),onBlur:()=>O(!1),onKeyDown:Tn,onPaste:xr,disabled:t}),T&&M.length>0?s.jsx("div",{className:"wb-mentions",role:"listbox","aria-label":"Members",children:M.map((F,ae)=>s.jsxs("button",{type:"button",role:"option","aria-selected":ae===q,className:"wb-mention","data-active":ae===q||void 0,onMouseDown:Ae=>{Ae.preventDefault(),_(F.handle)},children:[s.jsxs("span",{className:"wb-mention-handle",children:["@",F.handle]}),s.jsx("span",{className:"wb-mention-name",children:F.name})]},F.handle))}):null,s.jsxs("div",{className:"wb-composer-row",children:[s.jsx("input",{ref:L,type:"file",multiple:!0,hidden:!0,"data-testid":"file-input",onChange:F=>{$(F.target.files),F.target.value=""}}),s.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 F;return(F=L.current)==null?void 0:F.click()},disabled:t,children:s.jsx(De,{name:"clip"})}),s.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:()=>{P(null),N(!0),X_().then(F=>{var ae;F&&($([F]),(ae=D.current)==null||ae.focus())}).catch(F=>P(F instanceof Error?F.message:String(F))).finally(()=>N(!1))},disabled:t||S,children:s.jsx(De,{name:"camera"})}),a?c?s.jsxs("a",{className:"wb-composer-model",href:c,title:"The model this agent runs on. Click to change it.",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):s.jsxs("span",{className:"wb-composer-model",title:"The model this agent runs on",children:[s.jsx("span",{className:"wb-composer-model-dot","aria-hidden":"true"}),a]}):null,p?s.jsxs("button",{type:"button",className:"wb-composer-think","aria-pressed":pa(u),disabled:t||n,title:n?`Wait for ${o} to finish — this run started with thinking ${pa(u)?"on":"off"}`:pa(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:()=>p(pa(u)?"off":"on"),children:[s.jsx("span",{className:"wb-composer-think-dot","aria-hidden":"true"}),"Thinking"]}):null,s.jsx("span",{className:"wb-hint","data-shown":m!==""&&!n||Rn>0||ct||C!==null,"data-tone":Rn>0||C!==null?"critical":void 0,children:Rn>0?Rn===1&&((Vn=_s[0])!=null&&Vn.error)?_s[0].error:`${Rn} files failed to upload and will not be sent`:C!==null?C:ct?zv:"Enter sends, Shift+Enter for a new line"}),n?s.jsx("button",{className:"ui-btn","data-variant":"stop",onClick:i,children:"Stop"}):null,s.jsx("button",{className:"wb-send","aria-label":"Send",title:ct?zv:ye?"Waiting for the upload to finish":n?`Send — ${o} picks it up between steps`:"Send",onClick:cn,disabled:!_e,children:s.jsx(De,{name:"send"})})]})]})})});function pa(e){return(e??"on")==="on"}function eO(e){return{type:"attachment",artifactId:e.artifactId,filename:e.filename,mime:e.mime,kind:e.kind,sizeBytes:e.sizeBytes}}function tO({question:e,disabled:t,onAnswer:n,onSkip:r}){const[i,o]=d.useState("");return d.useEffect(()=>{if(t)return;const l=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),r())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[t,r]),s.jsxs("section",{className:"wb-question","aria-label":"Question from agent","data-testid":"question-picker",children:[s.jsxs("div",{className:"wb-question-head",children:[s.jsx("span",{className:"wb-question-kicker",children:"Needs your input"}),s.jsx(R,{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"}),s.jsx("strong",{children:e.question})]}),e.options.length>0?s.jsx("div",{className:"wb-question-options",children:e.options.map((l,a)=>s.jsxs("button",{className:"wb-question-option","data-recommended":l.recommended||void 0,disabled:t,onClick:()=>n(l.label,l.id),children:[s.jsx("span",{className:"wb-question-number",children:a+1}),s.jsxs("span",{children:[s.jsxs("span",{className:"wb-question-label",children:[l.label,l.recommended?s.jsx("em",{children:"Recommended"}):null]}),l.hint?s.jsx("small",{children:l.hint}):null]})]},l.id))}):null,e.allowOther?s.jsxs("form",{className:"wb-question-other",onSubmit:l=>{l.preventDefault(),i.trim()&&n(i.trim())},children:[s.jsx("input",{value:i,onChange:l=>o(l.target.value),placeholder:e.options.length?"Something else…":"Type your answer…",disabled:t}),s.jsx("button",{className:"ui-btn","data-variant":"accent",disabled:t||!i.trim(),children:"Answer"})]}):null,s.jsx("p",{className:"wb-question-note",children:"This answers a question. It does not approve an action. Esc skips it."})]})}function nO(e,t){return e.messages<=0?!1:e.chars>e.maxChars?!0:e.lastActivityAt===null?!1:t-Date.parse(e.lastActivityAt)>e.idleTimeoutMs}function sO(e){const t=e/36e5;if(t>=1&&Number.isInteger(t))return`${t} hour${t===1?"":"s"}`;const n=Math.round(e/6e4);return`${n} minute${n===1?"":"s"}`}function rO(e){const{lifetime:t,startedAt:n,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 o=`A conversation ends after ${sO(t.idleTimeoutMs)} idle, or once its transcript grows past ${Math.round(t.maxChars/1e3)}k characters. What the agent remembers about you carries over.`,l=`${t.messages} message${t.messages===1?"":"s"}`;if(nO(t,r))return{text:`${l} · your next message starts a fresh one`,title:o,tone:"note"};const a=n?Se(n,r):"";return{text:a===""?l:`${l} · started ${a}`,title:n?`Started ${Re(n,i)}. ${o}`:o,tone:"quiet"}}const Ka=320,yk="buddi.chatWidth";function iO({timezone:e,agents:t,agentId:n,defaultAgentId:r=null,group:i=null,onEditGroup:o,onSelectAgent:l,attention:a,agentsInHeader:c,narrow:u,canvasOpen:p,onOpenCanvas:f,onCloseCanvas:h,newConversationSignal:x,requestedConversationId:j,requestedTab:w,onConversationOpened:b}){var dg,fg,hg,pg,mg,gg;const v=Am(),[m,y]=d.useState([]),[g,k]=d.useState(null),[S,N]=d.useState(null),[C,P]=d.useState(null),[E,O]=d.useState([]),[L,D]=d.useState([]),[T,z]=d.useState(null),[q,K]=d.useState(!1),[M,W]=d.useState(new Map),[_,U]=d.useState(null),[X,Z]=d.useState(q_),[ue,je]=d.useState([]),[Ce,Pe]=d.useState(!1),Ve=d.useRef(0),he=d.useRef(null),[ge,ye]=d.useState(!1),kt=d.useRef(x??0),ct=d.useRef(n),_e=d.useRef({agentId:n,conversationId:g});_e.current={agentId:n,conversationId:g};const $=X[g??""]??[],[de,xe]=d.useState(null),[be,it]=d.useState(null),[St,cn]=d.useState(null),[Tn,xr]=d.useState([]),[_s,Rn]=d.useState(!1),[Vn,F]=d.useState(()=>Date.now()),[ae,Ae]=d.useState(oO),Pt=d.useRef(null),[pt,Os]=d.useState(null),[ds,Vm]=d.useState(!1),[a1,Su]=d.useState(null),[c1,u1]=d.useState(null),[d1,Km]=d.useState(null);d.useEffect(()=>{if(!n)return;const I=uO(n);I&&Su({text:I,at:Date.now()})},[n]);const vr=i?`group:${i.id}`:n??null,yn=[...t.top,...t.middle,...t.bottom],fe=yn.find(I=>I.id===n)??null,qr=i?i.members.map(I=>yn.find(H=>H.id===I)).filter(I=>!!I):[],[Nu,Gm]=d.useState(null);d.useEffect(()=>{let I=!1;return Fe.views().then(H=>{I||y(H.views??[])}).catch(()=>{}),()=>{I=!0}},[]),d.useEffect(()=>{if(!n)return;const I=ct.current===n;if(ct.current=n,I&&j&&j===_e.current.conversationId)return;let H=!1;return k(null),N(null),P(null),O([]),xe(null),K(!1),U(null),je([]),Tl(null),ye(!1),Os(null),j?(j!=="new"?k(j):P(vr),()=>{H=!0}):((i?Fe.groupConversations(i.id):Fe.conversations(n)).then(te=>{if(H)return;const ve=[...te.conversations??[]].sort(lO)[0];ve?(k(ve.id),b==null||b(n,ve.id)):P(vr)}).catch(()=>{H||P(vr)}),()=>{H=!0})},[n,i==null?void 0:i.id,vr,j,b]);const Kn=d.useCallback(I=>Fe.conversation(I).then(H=>{if(_e.current.conversationId===I){if(H.agentId!==_e.current.agentId)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(H),O(te=>te.filter(ve=>!Md(H,ve)))}}).catch(H=>{_e.current.conversationId===I&&xe(Fs(H))}),[]);d.useEffect(()=>{if(!g)return;let I=!1;return W(new Map),D([]),Fe.conversation(g).then(H=>{if(!I){if(H.agentId!==n)throw new Error("This conversation belongs to another agent. Open it from that agent’s history.");N(H),O(te=>te.filter(ve=>!Md(H,ve)))}}).catch(H=>{I||xe(Fs(H))}),()=>{I=!0}},[g,n]),d.useEffect(()=>{if(!g)return;let I=!1;const H=window.setInterval(()=>{Fe.conversation(g).then(te=>{I||te.agentId!==_e.current.agentId||(N(te),O(ve=>ve.filter(Ee=>!Md(te,Ee))))}).catch(()=>{})},3e3);return()=>{I=!0,window.clearInterval(H)}},[g,n]),d.useEffect(()=>{if(!g)return;const I=R0({url:Fe.streamUrl(g),onEvent:H=>{switch(H.name){case"run.started":K(!0),z(null),Gm(Nt(H.data.agentId));break;case"live":{const te=Nt(H.data.runId)??"",ve=Number(H.data.turn??0),Ee=H.data.kind==="thinking"?"thinking":"text",Oe=Nt(H.data.text)??"",fs=Date.now();z(Ds=>{const Zr=Ds&&Ds.runId===te&&Ds.turn===ve?Ds:{runId:te,turn:ve,text:"",thinking:"",thinkingStartedAt:null,textStartedAt:null,settled:!1};return Ee==="thinking"?{...Zr,thinking:Zr.thinking+Oe,thinkingStartedAt:Zr.thinkingStartedAt??fs}:{...Zr,text:Zr.text+Oe,textStartedAt:Zr.textStartedAt??fs}});break}case"live.snapshot":{const te=Nt(H.data.runId)??"",ve=Number(H.data.turn??0),Ee=Nt(H.data.text)??"",Oe=Nt(H.data.thinking)??"",fs=Number(H.data.startedAt??Date.now());z({runId:te,turn:ve,text:Ee,thinking:Oe,thinkingStartedAt:Oe?fs:null,textStartedAt:Ee?fs:null,settled:!1});break}case"live.settle":{const te=Nt(H.data.runId)??"",ve=Number(H.data.turn??0);z(Ee=>Ee&&Ee.runId===te&&Ee.turn===ve?{...Ee,settled:!0}:Ee);break}case"tool.called":{const te=Nt(H.data.toolUseId)??Nt(H.data.id),ve=Nt(H.data.name)??Nt(H.data.tool)??"tool";te&&D(Ee=>[...Ee.filter(Oe=>Oe.toolUseId!==te),{toolUseId:te,name:ve,startedAt:Date.now()}]);break}case"tool.result":{const te=Nt(H.data.toolUseId)??Nt(H.data.id);te&&D(ve=>ve.filter(Ee=>Ee.toolUseId!==te)),Kn(g);break}case"message.appended":Kn(g).then(()=>{z(te=>te!=null&&te.settled?null:te)});break;case"awaiting-approval":{const te=Nt(H.data.approvalId)??Nt(H.data.actionId),ve=Nt(H.data.toolUseId);te&&ve&&W(Ee=>new Map(Ee).set(ve,te)),D(Ee=>Ee.filter(Oe=>Oe.toolUseId!==ve)),Kn(g);break}case"run.finished":{K(!1),D([]),z(null),Gm(null);const te=Nt(H.data.message);xe(te??null),Kn(g);break}}}});return()=>I.close()},[g,Kn]),d.useEffect(()=>{const I=window.setInterval(()=>F(Date.now()),L.length===0?6e4:1e3);return()=>window.clearInterval(I)},[L.length]);const Al=se(()=>n&&g?A.browser({agentId:n,conversationId:g}):Promise.resolve(void 0),[n,g],1500),Qr=Al.error?void 0:Al.data,lo=Qr!=null&&Qr.session&&Qr.session.agentId===n&&Qr.session.conversationId===g?Qr:void 0,jr=B_(lo,n,g),yr=(jr==null?void 0:jr.id)??null,[ao,f1]=d.useState(null),Ym=lo==null?void 0:lo.mode;d.useEffect(()=>{jr&&n&&g&&f1({agentId:n,conversationId:g,tab:W_(jr,Ym)})},[yr,Ym,n,g]);const h1=ao&&ao.agentId===n&&ao.conversationId===g&&!$.includes(ao.tab.id)?ao.tab:null,It=jr??h1,p1=d.useMemo(()=>H_((S==null?void 0:S.messages)??[]),[S]),[m1,Tl]=d.useState(null),g1=d.useMemo(()=>t$({messages:(S==null?void 0:S.messages)??[],descriptors:m}),[S,m]),Jr=o_(g1,g??null),Cu=a_(i?null:n),qm=d.useMemo(()=>l_((S==null?void 0:S.messages)??[]),[S]),un=d.useMemo(()=>{const H=n$({messages:(S==null?void 0:S.messages)??[],descriptors:m,awaiting:M,served:Jr.served,...It?{folded:Va}:{}}).filter(te=>te.source==="approval"||!$.includes(te.id));if(_&&!$.includes(_)&&!H.some(te=>te.id===_)){const te=o$((S==null?void 0:S.messages)??[],_,{redactInputOf:Va});te&&!Va.has(te.tool)&&H.push(te)}It&&H.push(It);for(const te of ue)H.push(HI(te));return Cu&&H.unshift(c_(Cu,qm)),pt?[...H,u_(pt)]:H},[S,m,M,pt,yr,It==null?void 0:It.title,_,X,g,ue,Jr.served,Cu,qm]),x1=d.useMemo(()=>{var H;const I=[];for(const te of(S==null?void 0:S.messages)??[]){if(te.role!=="user"||te.speaker&&te.speaker!=="owner")continue;const ve=(H=te.blocks.find(Ee=>Ee.type==="text"))==null?void 0:H.text.trim();ve&&I.unshift(ve)}return I},[S]),Eu=d.useMemo(()=>un.filter(I=>I.source==="approval"),[un]),Rl=Eu.at(-1)??null,Pl=d.useMemo(()=>[...Eu.map(I=>({approvalId:I.props.approvalId,toolUseId:I.id})),...((S==null?void 0:S.delegatedApprovals)??[]).map(I=>({approvalId:I.approvalId,toolUseId:I.toolUseId??"",askedBy:pO(I.chain,yn)}))],[Eu,S==null?void 0:S.delegatedApprovals]),co=d.useMemo(()=>{for(let I=un.length-1;I>=0;I-=1){const H=un[I];if(H!=null&&H.substantial)return H.id}return null},[un]),Il=d.useRef(null),Au=((dg=un.filter(I=>(I.source!=="browser"||I.pinned===!0)&&I.id!==yh).at(-1))==null?void 0:dg.id)??((fg=un.filter(I=>I.id!==yh).at(-1))==null?void 0:fg.id)??null;d.useEffect(()=>{if(co&&co!==Il.current){Il.current=co,U(co);return}_===null&&Au&&U(Au)},[co,_,Au]);const Qm=d.useRef(Jr.live);d.useEffect(()=>{const I=Qm.current;Qm.current=Jr.live;const H=[...Jr.live].filter(Ee=>!I.has(Ee));if(H.length===0||Rl||_!==null&&_!==Il.current)return;const ve=[...un].reverse().find(Ee=>Ee.source==="descriptor"&&Ee.renderer==="preview"&&Ee.props.target!==null&&H.includes(Ai(Ee.props.target)));ve&&U(ve.id)},[Jr.live,un,Rl,_]);const Jm=d.useRef(null);d.useEffect(()=>{yr!==Jm.current&&(Jm.current=yr,yr&&!Rl&&U(yr))},[yr,Rl]);const Xm=d.useRef(null),uo=w==="browser"?(It==null?void 0:It.id)??null:null;d.useEffect(()=>{!uo||Xm.current===uo||(Xm.current=uo,U(uo))},[uo]);const Tu=(It==null?void 0:It.id)??null;d.useEffect(()=>{!Tu||!_||Lv((S==null?void 0:S.messages)??[],_)!==null&&(Tl(_),U(Tu))},[Tu,_,S]);const Zm=I=>{je(H=>H.some(te=>te.artifactId===I.artifactId)?H:[...H,I]),U(Ha(I.artifactId)),u&&(f==null||f())},Ml=!i&&fe&&!fe.available?_0(fe):null,eg=ih(i?null:fe),tg=((S==null?void 0:S.offers)??[]).filter(I=>!Tn.includes(I.id)&&Date.parse(I.expiresAt)>Vn),v1=fe&&d1===fe.id?c1:(fe==null?void 0:fe.thinking)??null,j1=I=>{if(!fe)return;const H=fe.id;Km(H),u1(I),A.setAgentEngine(H,{thinking:I}).catch(te=>{Km(null),xe(te instanceof ce?te.message:String(te))})},ng=(I,H)=>{if(!n)return;const te=H.map(Oe=>Oe.artifactId),ve=q,Ee={id:`optimistic:${Date.now()}`,role:"user",at:new Date().toISOString(),blocks:[{type:"text",text:I},...H.map(Oe=>({type:"attachment",artifactId:Oe.artifactId,filename:Oe.filename,mime:Oe.mime,kind:Oe.kind,sizeBytes:Oe.sizeBytes}))],...ve?{speaker:fk}:{}};O(Oe=>ve?[...Oe,Ee]:[Ee]),xe(null),it(null),K(!0),(i?Fe.sendToGroup(i.id,{...g?{conversationId:g}:{},text:I,attachmentIds:te}):Fe.send(n,{...g?{conversationId:g}:{},text:I,attachmentIds:te})).then(async Oe=>{_e.current.agentId!==n||_e.current.conversationId!==g||(it(Oe.rolledOver===!0?"(New thread — the room had grown long. Where it stopped carries over as a summary.)":null),Oe.conversationId!==g?(N(null),k(Oe.conversationId)):await Kn(Oe.conversationId),Oe.queued===!0&&O(fs=>fs.filter(Ds=>Ds.id!==Ee.id)),b==null||b(n,Oe.conversationId))}).catch(Oe=>{O(fs=>fs.filter(Ds=>Ds.id!==Ee.id)),xe(Fs(Oe)),K(!1)})},y1=I=>{xe(null),cn(I),xr(H=>[...H,I]),A.takeOffer(I,g??void 0).then(H=>{H.runId&&(it(null),K(!0)),g&&Kn(g)}).catch(H=>{xr(te=>te.filter(ve=>ve!==I)),xe(Fs(H)),g&&Kn(g)}).finally(()=>cn(null))},w1=(I,H)=>sg({answer:I,...H?{optionId:H}:{}}),b1=()=>sg({answer:"",skipped:!0}),sg=I=>{const H=S==null?void 0:S.question;H&&(xe(null),Rn(!0),K(!0),Fe.answerQuestion(H.id,I).then(()=>{if(g)return Kn(g)}).catch(te=>{xe(Fs(te)),K(!1)}).finally(()=>Rn(!1)))},k1=()=>{if(n){if(pt){Os(null);return}Vm(!0),A.agentProfile(n).then(I=>{Os(I),U(wh(I.id)),u&&(f==null||f())}).catch(I=>xe(Fs(I))).finally(()=>Vm(!1))}},S1=I=>{Su({text:I.prompt,at:Date.now()}),l(I.agentId),u&&(h==null||h())},N1=()=>{g&&Fe.cancel(g).catch(I=>xe(Fs(I))).finally(()=>{K(!1),D([])})},$l=d.useCallback(()=>{if(k(null),N(null),O([]),K(!1),xe(null),it(null),D([]),W(new Map),U(null),je([]),Tl(null),Il.current=null,i){Fe.startGroupConversation(i.id).then(({conversationId:I})=>{k(I),n&&(b==null||b(n,I))}).catch(I=>xe(Fs(I)));return}P(vr),n&&(b==null||b(n,"new"))},[n,i,vr,b]);d.useEffect(()=>{x&&x!==kt.current&&(kt.current=x,$l())},[x,$l]);const rg=I=>{g&&Kn(g),A.overview().catch(()=>{}),I.state!=="pending"&&W(H=>new Map([...H].filter(([,te])=>te!==I.id)))},_l=d.useRef(!1);d.useEffect(()=>{const I=te=>{if(!_l.current)return;const ve=Math.max(Ka,Math.min(720,te.clientX-52));Ae(ve)},H=()=>{if(_l.current){_l.current=!1;try{ae!==null&&window.localStorage.setItem(yk,String(ae))}catch{}}};return window.addEventListener("pointermove",I),window.addEventListener("pointerup",H),()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",H)}},[ae]);const C1=((hg=yn.find(I=>I.id===r))==null?void 0:hg.name)??null,ig=i?[]:H2(fe,C1),og=!(S&&S.conversationId===g)&&!(!g&&C!==null&&C===vr),lg=og?s.jsx("div",{className:"wb-chat-loading","data-testid":"chat-loading","aria-busy":"true"}):!i&&fe?s.jsx(DI,{quiet:!0,still:!0,className:"wb-chat-field",children:s.jsxs("div",{className:"wb-chat-opening","data-testid":"chat-opening",children:[s.jsx(Zt,{agents:yn,id:fe.id,size:"xl"}),s.jsx("h2",{className:"wb-chat-hello",children:`Hi, I'm ${fe.name}.`}),s.jsx("p",{className:"wb-chat-intro",children:V2(fe)}),ig.length>0?s.jsx("div",{className:"wb-starters",role:"group","aria-label":`Things to ask ${fe.name}`,children:ig.map(I=>s.jsx("button",{type:"button",className:"wb-starter",onClick:()=>{var H;Su({text:I,at:Date.now()}),(H=he.current)==null||H.focus()},children:I},I))}):null]})}):null,ag=s.jsx(Y$,{renderables:un,activeId:_,onActivate:U,onClose:I=>{pt&&I===wh(pt.id)?Os(null):ue.some(H=>Ha(H.artifactId)===I)?je(H=>H.filter(te=>Ha(te.artifactId)!==I)):g&&Z(H=>{const te={...H,[g]:[...new Set([...H[g]??[],I])]};return Fv(te),te}),_===I&&U(null)},timezone:e,onDecided:rg,onChangeAgent:S1,agents:yn,browserPanel:It?s.jsx(L_,{status:lo,error:Al.error,reload:Al.reload,steps:p1,live:jr!==null,focusedStepId:m1},It.id):null,descriptors:m,grantedTools:i?qr.flatMap(I=>I.tools??[]):(fe==null?void 0:fe.tools)??[],...fe?{agentName:fe.name}:{},loading:og,...!i&&fe?{face:s.jsx(Zt,{agents:yn,id:fe.id,size:"xl"})}:{}}),cg=(mg=(pg=[...(S==null?void 0:S.messages)??[],...E].find(I=>I.role==="user"))==null?void 0:pg.blocks.find(I=>I.type==="text"))==null?void 0:mg.text.trim(),ug=cg?cg.split(`
|
|
102
|
-
`)[0]:"New conversation",Xr=rO({lifetime:(S==null?void 0:S.lifetime)??null,startedAt:(S==null?void 0:S.startedAt)??null,now:Vn,timezone:e});return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"wb-chat",ref:Pt,style:u||ae===null?void 0:{width:ae},"data-sized":!u&&ae!==null?"true":void 0,"data-testid":"chat-column","data-dropping":Ce||void 0,onDragEnter:I=>{ma(I)&&(I.preventDefault(),Ve.current+=1,Pe(!0))},onDragOver:I=>{ma(I)&&(I.preventDefault(),I.dataTransfer.dropEffect="copy")},onDragLeave:I=>{ma(I)&&(Ve.current=Math.max(0,Ve.current-1),Ve.current===0&&Pe(!1))},onDrop:I=>{var H;ma(I)&&(I.preventDefault(),Ve.current=0,Pe(!1),n&&((H=he.current)==null||H.addFiles(I.dataTransfer.files)))},children:[Ce?s.jsx("div",{className:"wb-drop","aria-hidden":"true",children:s.jsxs("div",{className:"wb-drop-card",children:[s.jsx(aO,{}),s.jsx("strong",{children:"Drop to attach"}),s.jsx("span",{children:fe?`It goes with your next message to ${fe.name}`:"Pick an agent first"})]})}):null,s.jsxs("header",{className:"wb-chat-head","data-testid":"chat-head",...!i&&fe?kl(bl(fe)):{},children:[s.jsxs("div",{className:"wb-head-row",children:[i?s.jsx("span",{className:"wb-head-face wb-head-group","aria-hidden":"true",children:qr.slice(0,3).map(I=>s.jsx(Zt,{agents:yn,id:I.id,size:"sm"},I.id))}):fe?s.jsx("a",{className:"wb-head-face",href:ft(fe.id),"aria-label":`${fe.name}'s page`,children:s.jsx(Zt,{agents:yn,id:fe.id})}):null,s.jsxs("div",{className:"wb-head-text",children:[i?s.jsx("span",{className:"wb-head-title",children:i.name}):s.jsx("span",{className:"wb-head-title",title:ug,children:ug}),s.jsx("span",{className:"wb-head-meta","data-tone":Xr.tone,title:i?`${qr.map(I=>I.name).join(", ")}. Coordinator: ${(fe==null?void 0:fe.name)??i.coordinator}.`:Xr.title,children:i?`${qr.map(I=>I.name).join(", ")} · ${Xr.text}`:fe?s.jsxs(s.Fragment,{children:[s.jsx("a",{className:"wb-head-name",href:ft(fe.id),title:`${fe.name}'s page`,children:fe.name})," ",s.jsxs("span",{className:"wb-head-handle",children:["@",fe.handle]}),` · ${Xr.tone==="quiet"&&Xr.text==="New conversation"?`on ${v}`:Xr.text}`]}):"No agent"})]}),s.jsx("button",{className:"ui-icon-btn wb-head-more","data-size":"sm","aria-label":"New chat",title:"New chat",disabled:!n,onClick:()=>{ye(!1),$l()},children:s.jsx(De,{name:"plus",size:16})}),s.jsx("button",{className:"ui-icon-btn wb-head-more","aria-label":"History",title:"Earlier conversations","aria-expanded":ge,"data-open":ge?"true":void 0,disabled:!n,onClick:()=>ye(I=>!I),children:s.jsx(dO,{})}),u?s.jsxs("button",{className:"ui-btn",onClick:f,disabled:un.length===0,children:["Canvas",un.length>0?` (${un.length})`:""]}):null,s.jsx(hO,{disabled:!n,items:i?[...qr.map(I=>({label:I.name,hint:I.id===i.coordinator?"Coordinator · open page":"Member · open page",href:ft(I.id)})),...o?[{label:"Members…",hint:"Name, coordinator, who is in the room",testId:"group-members",onSelect:o}]:[]]:[{label:pt?"Close properties":"Properties",hint:"What this agent can do, on the Canvas",testId:"agent-properties",disabled:ds,onSelect:k1},...fe?[{label:"Set up",hint:"Identity, model and access",href:ft(fe.id,"setup")},{label:"Open agent page",hint:"Profile, activity and setup",href:ft(fe.id)}]:[]]})]}),c?s.jsx(D0,{agents:t,currentId:n,attention:a,onSelect:l,orientation:"horizontal"}):null]}),ge&&n?s.jsx(Y_,{agentId:n,...i?{groupId:i.id}:{},currentId:g,timezone:e,onNew:()=>{ye(!1),$l()},onSelect:I=>{if(I===g){ye(!1);return}ye(!1),N(null),O([]),K(!1),U(null),xe(null),it(null),je([]),k(I),b==null||b(n,I,!1)}}):null,n&&g?s.jsx(z_,{agentId:n,conversationId:g},`${n}:${g}`):null,de?s.jsx("div",{className:"wb-chat-notice",children:s.jsx(re,{message:de})}):null,be?s.jsx("div",{className:"wb-chat-notice","data-testid":"chat-notice",children:be}):null,S!=null&&S.carriedOver?s.jsx("div",{className:"wb-carryover","data-testid":"chat-carryover",children:S.carriedOver}):null,s.jsx(hk,{messages:[...(S==null?void 0:S.messages)??[],...E],live:L,now:Vn,working:q,partial:T,agents:yn,...S!=null&&S.runs?{runs:S.runs}:{},...i?{speakers:yn,coordinatorId:i.coordinator}:{},...Nu?{workingAs:((gg=yn.find(I=>I.id===Nu))==null?void 0:gg.name)??Nu}:{},onOpenFile:Zm,onOpen:I=>{if(It){const H=Lv([...(S==null?void 0:S.messages)??[],...E],I);if(H){Tl(H),U(It.id),u&&(f==null||f());return}}g&&Z(H=>{const te={...H,[g]:(H[g]??[]).filter(ve=>ve!==I)};return Fv(te),te}),U(I),u&&(f==null||f())},...fe?{agentName:fe.name}:{},...lg?{empty:lg}:{},emptyHint:fe?`Nothing here yet. Ask ${fe.name} for something.`:"Loading agents…"}),tg.length>0?s.jsx("div",{className:"wb-offers","data-testid":"chat-offers",children:tg.map(I=>s.jsx("button",{className:"ui-btn",disabled:St!==null,title:I.prompt,onClick:()=>y1(I.id),children:I.label},I.id))}):null,Ml?s.jsx("div",{className:"wb-composer-blocked","data-testid":"composer-blocked",children:s.jsxs(V,{tone:"warning",role:"status",children:[Ml," ",s.jsx("a",{href:st(eg.section),children:eg.label})]})}):Pl.length>0?s.jsx(T$,{approvals:Pl,timezone:e,now:Vn,version:S,onDecided:rg,onSay:I=>ng(I,[]),onOpenFull:I=>{U(I),u&&(f==null||f())}}):null,Ml||Pl.length>0?null:S!=null&&S.question?s.jsx(tO,{question:S.question,disabled:_s||q,onAnswer:w1,onSkip:b1},S.question.id):null,Ml?null:s.jsx("div",{hidden:Pl.length>0||!!(S!=null&&S.question),"data-testid":"composer-slot",children:s.jsx(Z_,{ref:he,disabled:!n,running:q,onSend:ng,onStop:N1,agentName:i?i.name:(fe==null?void 0:fe.name)??"the agent",draft:a1,history:x1,threadKey:g??(i?`group:${i.id}`:n),model:i?null:(fe==null?void 0:fe.model)??null,setupHref:i?null:fe?ft(fe.id,"setup","brain"):null,thinking:v1,...!i&&fe?{onThinking:j1}:{},...i?{mentions:qr.map(I=>({handle:I.handle,name:I.name}))}:{},onOpenFile:Zm})})]}),u?p?s.jsxs("div",{className:"wb-sheet",role:"dialog","aria-label":"Canvas",children:[s.jsxs("div",{className:"wb-sheet-head",children:[s.jsx("strong",{children:"Canvas"}),s.jsx("button",{className:"ui-btn",onClick:h,children:"Close"})]}),ag]}):null:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"wb-grip","aria-label":"Resize the conversation column",onPointerDown:I=>{var H,te;_l.current=!0,(te=(H=I.currentTarget).setPointerCapture)==null||te.call(H,I.pointerId)},onKeyDown:I=>{const H=te=>{var ve;return te??((ve=Pt.current)==null?void 0:ve.offsetWidth)??Ka};I.key==="ArrowLeft"&&Ae(te=>Math.max(Ka,H(te)-16)),I.key==="ArrowRight"&&Ae(te=>Math.min(720,H(te)+16))}}),ag]})]})}function oO(){try{const e=window.localStorage.getItem(yk),t=Number(e);return e!==null&&Number.isFinite(t)&&t>=Ka?t:null}catch{return null}}function lO(e,t){return Date.parse(t.lastMessageAt??t.startedAt??t.createdAt??"")-Date.parse(e.lastMessageAt??e.startedAt??e.createdAt??"")}function Nt(e){return typeof e=="string"&&e!==""?e:null}function Fs(e){return e instanceof ce||e instanceof Error?e.message:String(e)}function Md(e,t){var r;const n=(r=t.blocks.find(i=>i.type==="text"))==null?void 0:r.text.trim();if(!n)return!0;for(let i=e.messages.length-1;i>=0;i-=1){const o=e.messages[i];if(o.role!=="user")continue;const l=o.blocks.find(a=>a.type==="text");if(l)return l.text.trim()===n}return!1}function ma(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!(t&&Array.from(t).includes("Files"))}function aO(){return s.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:[s.jsx("path",{d:"M14 4v13M8.5 11.5 14 17l5.5-5.5"}),s.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 bh="buddi.chatDraft";function cO(e,t){try{window.sessionStorage.setItem(bh,JSON.stringify({agentId:e,text:t}))}catch{}}function uO(e){try{const t=window.sessionStorage.getItem(bh);if(!t)return null;const n=JSON.parse(t);return n.agentId!==e||typeof n.text!="string"?null:(window.sessionStorage.removeItem(bh),n.text)}catch{return null}}function dO(){return s.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:[s.jsx("path",{d:"M2.6 8a5.4 5.4 0 1 0 1.6-3.8"}),s.jsx("path",{d:"M2.4 2.6v2.6h2.6M8 5.2V8l2 1.3"})]})}function fO(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",fill:"currentColor",children:[s.jsx("circle",{cx:"8",cy:"3.4",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"8",r:"1.35"}),s.jsx("circle",{cx:"8",cy:"12.6",r:"1.35"})]})}function hO({items:e,disabled:t}){const[n,r]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!n)return;const o=a=>{i.current&&!i.current.contains(a.target)&&r(!1)},l=a=>{a.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",o),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",l)}},[n]),s.jsxs("div",{className:"wb-head-menu",ref:i,children:[s.jsx("button",{className:"ui-icon-btn wb-head-more","data-testid":"chat-menu","aria-label":"More about this agent","aria-haspopup":"menu","aria-expanded":n,"data-open":n?"true":void 0,disabled:t,onClick:()=>r(o=>!o),children:s.jsx(fO,{})}),n?s.jsx("div",{className:"ui-menu wb-head-menu-list",role:"menu",children:e.map(o=>o.href?s.jsxs("a",{className:"ui-menu-item",role:"menuitem",href:o.href,onClick:()=>r(!1),children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label):s.jsxs("button",{className:"ui-menu-item",role:"menuitem","data-testid":o.testId,disabled:o.disabled,onClick:()=>{var l;r(!1),(l=o.onSelect)==null||l.call(o)},children:[s.jsx("span",{className:"ui-menu-item-text",children:o.label}),o.hint?s.jsx("span",{className:"ui-menu-item-hint",children:o.hint}):null]},o.label))}):null]})}function pO(e,t){const n=o=>{var l;return`@${((l=t.find(a=>a.id===o))==null?void 0:l.handle)??o}`},[r,...i]=e;return r===void 0?"":[n(r),...i.map(o=>`asked by ${n(o)}`)].join(", ")}const wk=3;function mO(e){if(e==="approval"||e==="question")return"accent";if(e==="watcher"||e==="reminder")return"warm";if(e==="failure")return"critical"}function gO(e){return e.state==="shown"&&e.seenAt===null}function xO(e){const[t,n]=d.useState([]),r=d.useRef(new Set),i=d.useRef(new Set),o=d.useCallback(()=>{e&&A.notifications(20).then(({notifications:a})=>{const c=a.filter(u=>gO(u)&&!r.current.has(u.id));n(u=>{const p=new Set(u.map(h=>h.id)),f=c.filter(h=>!p.has(h.id));return f.length===0?u:[...u,...f].sort((h,x)=>x.createdAt.localeCompare(h.createdAt))})}).catch(()=>{})},[e]);d.useEffect(()=>{for(const a of t.slice(0,wk))i.current.has(a.id)||(i.current.add(a.id),A.notificationSeen(a.id).catch(()=>{}))},[t]);const l=d.useCallback(a=>{r.current.add(a),n(c=>c.filter(u=>u.id!==a))},[]);return{queue:t,refresh:o,dismiss:l}}function vO({queue:e,agents:t,navigate:n,onDismiss:r}){if(e.length===0)return null;const i=e.slice(0,wk),o=e.length-i.length;return s.jsxs("section",{className:"nt-toasts","aria-label":"Notifications",children:[i.map(l=>s.jsxs("div",{className:"ui-toast nt-toast","data-tone":mO(l.kind),role:"status",children:[l.agentId?s.jsx(Zt,{agents:t,id:l.agentId,size:"sm"}):null,s.jsxs("div",{className:"nt-toast-main",children:[s.jsx("div",{className:"ui-toast-title",children:l.title}),l.text?s.jsx("div",{className:"ui-toast-body nt-toast-line",children:jO(l.text)}):null,l.link?s.jsx("a",{className:"nt-toast-link",href:l.link,onClick:a=>{a.preventDefault(),r(l.id),n(l.link)},children:"See"}):null]}),s.jsx("button",{type:"button",className:"nt-toast-x","aria-label":`Dismiss ${l.title}`,onClick:()=>r(l.id),children:"×"})]},l.id)),o>0?s.jsxs("p",{className:"nt-toasts-more",children:["and ",o," more"]}):null]})}function jO(e){var t;return((t=e.split(`
|
|
103
|
-
`).find(n=>n.trim()!==""))==null?void 0:t.trim())??""}const yO=3e4,wO=1e3;function bO(e,t,n){const r=d.useRef(t);r.current=t;const i=d.useRef(n);i.current=n,d.useEffect(()=>{if(!e)return;let o=!1,l=-1/0,a=null,c=null,u=!0;const p=()=>document.visibilityState!=="hidden",f=v=>{var m;l=Date.now(),A.presence(v).catch(y=>{var g;y instanceof ce&&y.status===401&&(o=!0,(g=i.current)==null||g.call(i))}),v==="active"&&((m=r.current)==null||m.call(r))},h=v=>{if(o||(a=v,c!==null))return;const m=l+wO-Date.now();if(m<=0){a=null,f(v);return}c=window.setTimeout(()=>{if(c=null,o||a===null)return;const y=a;a=null,f(y)},m)},x=()=>{u=!0,p()&&h("active")},j=()=>{u=!1,h("away")},w=()=>h(p()?"active":"away");p()&&h("active");const b=window.setInterval(()=>{p()&&u&&h("active")},yO);return window.addEventListener("focus",x),window.addEventListener("blur",j),document.addEventListener("visibilitychange",w),()=>{o=!0,window.clearInterval(b),c!==null&&window.clearTimeout(c),window.removeEventListener("focus",x),window.removeEventListener("blur",j),document.removeEventListener("visibilitychange",w)}},[e])}function Uv({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){return!t&&!$0(e)?s.jsx(qt,{title:"A new group",onClose:n,children:s.jsxs(V,{children:["A group needs two agents. Make another one with ",U2(e)," first."]})}):s.jsx(SO,{agents:kO(e,t),group:t??null,onClose:n,...r?{onCreated:r}:{},...i?{onSaved:i}:{},...o?{onArchived:o}:{}})}function kO(e,t){const n=M0(e),r=((t==null?void 0:t.members)??[]).filter(i=>!n.some(o=>o.id===i)).map(i=>e.find(o=>o.id===i)).filter(i=>i!==void 0);return[...n,...r]}function SO({agents:e,group:t,onClose:n,onCreated:r,onSaved:i,onArchived:o}){var C,P;const l=t!==null,[a,c]=d.useState((t==null?void 0:t.name)??""),[u,p]=d.useState((t==null?void 0:t.members)??[]),[f,h]=d.useState((t==null?void 0:t.coordinator)??((C=e.find(E=>E.roles.includes(pm)))==null?void 0:C.id)??((P=e[0])==null?void 0:P.id)??""),[x,j]=d.useState(!1),[w,b]=d.useState(!1),[v,m]=d.useState(null),y=[...new Set([f,...u])].filter(Boolean),g=a.trim()!==""&&f!==""&&y.length>=2,k=E=>p(O=>O.includes(E)?O.filter(L=>L!==E):[...O,E]),S=async()=>{j(!0),m(null);try{t?i==null||i(await Fe.updateGroup(t.id,{name:a.trim(),coordinator:f,members:y})):r==null||r(await Fe.createGroup({name:a.trim(),coordinator:f,members:y.filter(E=>E!==f)}))}catch(E){m(E instanceof ce?E.message:String(E))}finally{j(!1)}},N=async()=>{if(t){j(!0),m(null);try{await Fe.archiveGroup(t.id),o==null||o(t.id)}catch(E){m(E instanceof ce?E.message:String(E)),j(!1)}}};return s.jsx(qt,{title:l?`${t.name}: members`:"A new group",onClose:n,children:s.jsxs(G,{children:[s.jsx(ee,{label:"Name",hint:"What this team is for: Household finances, The move, Tax season.",children:s.jsx("input",{value:a,autoFocus:!0,maxLength:80,onChange:E=>c(E.target.value),placeholder:"Household finances"})}),s.jsx(ee,{label:"Coordinator",hint:"Reads your request, brings members in, and answers for the group. Concierge by default.",children:s.jsx("select",{value:f,onChange:E=>h(E.target.value),children:e.map(E=>s.jsx("option",{value:E.id,children:E.name},E.id))})}),s.jsx(ee,{label:"Members",hint:"Each keeps its own account, tools and approvals. Membership grants nothing.",children:s.jsx("div",{className:"group-pick",role:"group","aria-label":"Members",children:e.filter(E=>E.id!==f).map(E=>s.jsxs("label",{className:"group-pick-row","data-on":u.includes(E.id)||void 0,children:[s.jsx("input",{type:"checkbox",checked:u.includes(E.id),onChange:()=>k(E.id)}),s.jsx(Zt,{agents:e,id:E.id,size:"sm"}),s.jsxs("span",{className:"group-pick-text",children:[s.jsx("span",{className:"group-pick-name",children:E.name}),s.jsx("span",{className:"group-pick-desc",children:E.description})]})]},E.id))})}),s.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."}),l?s.jsx(V,{children:"Taking a member out leaves everything it already said in the transcript. It simply takes no new turns."}):null,v?s.jsx(V,{tone:"critical",children:v}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!g||x,onClick:()=>void S(),children:x?l?"Saving…":"Creating…":l?"Save":"Create group"})]}),l?s.jsx("div",{className:"group-archive",children:w?s.jsxs(G,{children:[s.jsxs(V,{tone:"warning",children:["Archive ",t.name,"? It leaves the rail and takes no new requests. Everything said in it stays readable."]}),s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:()=>b(!1),children:"Keep it"}),s.jsx(R,{variant:"danger",disabled:x,"data-testid":"group-archive-confirm",onClick:()=>void N(),children:"Archive group"})]})]}):s.jsx(R,{variant:"ghost",disabled:x,"data-testid":"group-archive",onClick:()=>b(!0),children:"Archive group"})}):null]})})}function Tm(e){const[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null);return{busy:t,note:r,failure:o,decide:async(c,u,p,f)=>{var x,j,w,b;n(c),l(null),i(null);let h;try{const v=f?await A.decide(c,u,p,f):await A.decide(c,u,p);h={decision:u,...(x=v.execution)!=null&&x.state?{state:v.execution.state}:{},...v.execution&&"result"in v.execution?{result:v.execution.result}:{}},i(u==="reject"?`Rejected ${v.action.tool}.`:((j=v.execution)==null?void 0:j.state)==="succeeded"?`Approved and done: ${v.action.tool}.`:`Approved ${v.action.tool}: ${((w=v.execution)==null?void 0:w.state)??"no execution"}${(b=v.execution)!=null&&b.message?` (${v.execution.message})`:""}`)}catch(v){l(v instanceof Error?v.message:String(v))}finally{n(null),e(h)}}}}function Rm({action:e,timezone:t,busy:n,onDecide:r,agentName:i}){var p,f;const[o,l]=d.useState(!1),{values:a,controls:c}=wm(e.choices),u=h=>a?r(e.id,"approve",h,a):r(e.id,"approve",h);return s.jsxs(Fr,{tone:"accent",title:e.tool,meta:s.jsxs(s.Fragment,{children:[s.jsxs(pe,{children:["v",e.toolVersion]}),s.jsxs("span",{className:"muted",children:["asked by ",i??e.agentId]})]}),children:[s.jsx(at,{children:e.preview}),s.jsxs("p",{className:"ui-card-meta",children:["Expires ",Re(e.expiresAt,t)," (",Se(e.expiresAt),"). Policy v",e.policyVersion,", args ",al(e.argsHash,12),e.jobId?`, job ${al(e.jobId)}`:"","."]}),c,s.jsxs(J,{children:[s.jsx(R,{variant:"good",disabled:n,onClick:()=>u(),children:(p=e.permissionScopes)!=null&&p.length?"Allow once":"Approve"}),(f=e.permissionScopes)!=null&&f.length?s.jsxs(s.Fragment,{children:[s.jsx(R,{disabled:n,onClick:()=>u("conversation"),children:"Auto: this conversation"}),s.jsx(R,{disabled:n,onClick:()=>u("always"),children:"Always: this agent"})]}):null,s.jsx(R,{variant:"danger",disabled:n,onClick:()=>r(e.id,"reject"),children:"Reject"}),s.jsx(R,{variant:"ghost",onClick:()=>l(h=>!h),"aria-expanded":o,children:o?"Hide envelope":"Show envelope"})]}),o?s.jsxs("div",{className:"ui-card-foot",children:[s.jsx(Y,{title:"Envelope: everything that decides what the world will see",children:s.jsx(at,{children:on(e.envelope)})}),s.jsx(Y,{title:"Canonical arguments",children:s.jsx(at,{children:on(e.canonicalArgs)})})]}):null]})}function bk(e,t,n){const[r,i]=d.useState(!1),[o,l]=d.useState(null),[a,c]=d.useState(null);return{accept:()=>{e&&(i(!0),c(null),A.acceptPluginAgent(e,t).then(p=>{l(p.agent)}).catch(p=>c(p instanceof ce?p.message:String(p))).finally(()=>i(!1)))},busy:r,created:o,failure:a}}function kk({agent:e}){return s.jsxs(V,{tone:"good",role:"status",children:["@",e.handle," is ready. ",s.jsxs("a",{href:ze(e.id),children:["Talk to @",e.handle]})]})}function Sk(e,t,n){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()===n.toLowerCase()}function NO(e,t){var i;const n=se(()=>A.approvals(),[e,t],15e3);return{action:((i=n.data)==null?void 0:i.pending.find(o=>Sk(o,e,t)))??null,reload:n.reload}}function CO({action:e,onDecided:t}){const{busy:n,failure:r,decide:i}=Tm(o=>t(o));return s.jsxs(G,{gap:"sm",children:[s.jsx(Rm,{action:e,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,busy:n===e.id,onDecide:(o,l,a,c)=>{i(o,l,a,c)}}),s.jsx(re,{message:r})]})}function Pm({plugin:e,agent:t,text:n,label:r,handle:i,onDismiss:o}){var f;const l=bk(e,t),a=NO(e,t),[c,u]=d.useState(null),p=l.created??c;if(p)return s.jsx(kk,{agent:p});if(a.action){const h=i??((f=/@(\S+)/.exec(r))==null?void 0:f[1])??t;return s.jsxs(G,{gap:"sm",children:[s.jsx("span",{children:n}),s.jsx(CO,{action:a.action,onDecided:x=>{(x==null?void 0:x.decision)==="approve"&&x.state==="succeeded"?u({id:t,handle:h,name:h}):a.reload()}})]})}return s.jsxs(G,{gap:"sm",children:[s.jsxs(J,{children:[s.jsx("span",{children:n}),s.jsx(ro,{}),o?s.jsx(R,{variant:"ghost",disabled:l.busy,onClick:o,children:"Not now"}):null,s.jsx(R,{variant:"accent",disabled:l.busy,onClick:l.accept,children:r})]}),s.jsx(re,{message:l.failure})]})}function Nk(){var t;const e=se(()=>A.agentOffers(),[],6e4);return{offers:((t=e.data)==null?void 0:t.offers)??[],reload:e.reload}}function Ck({offers:e,reload:t}){return e.length===0?null:s.jsx(Y,{title:"From your plugins",aside:`${e.length} to decide`,panel:!0,children:s.jsx(G,{gap:"sm",divided:!0,children:e.map(n=>s.jsx(Pm,{plugin:n.plugin,agent:n.agent,text:n.text,label:`Create @${n.handle}`,handle:n.handle,onDismiss:()=>{A.dismissAgentOffer(n.plugin,n.agent).then(t,t)}},`${n.plugin}/${n.agent}`))})})}const Im=d.createContext(null),Pc=d.createContext(!1);function bt(){const e=d.useContext(Im);if(!e)throw new Error("a plugin page component outside a plugin page");return e}function kh(e,t=new Set){if(Array.isArray(e))for(const n of e)kh(n,t);else if(e&&typeof e=="object"){const n=e.query;typeof n=="string"&&t.add(n);for(const r of Object.values(e))kh(r,t)}return t}function Ek(e,t){if(t.size===0)return!1;for(const n of kh(e))if(t.has(n))return!0;return!1}function Ak(){const[e,t]=d.useState(!1);return d.useEffect(()=>{if(!e)return;const n=()=>{document.visibilityState==="hidden"&&t(!1)};return document.addEventListener("visibilitychange",n),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}},[e]),[e,()=>t(n=>!n)]}function Tk({revealed:e,onToggle:t}){return s.jsx(R,{size:"sm",variant:"ghost","aria-pressed":e,onClick:t,children:e?"Hide":"Show"})}function Rk(){return s.jsx("p",{className:"muted",children:"Hidden until you show it."})}function Pk({children:e}){const[t,n]=Ak();return s.jsxs(G,{gap:"sm",children:[s.jsx(J,{align:"end",children:s.jsx(Tk,{revealed:t,onToggle:n})}),t?s.jsx(Pc.Provider,{value:!0,children:e}):s.jsx(Rk,{})]})}function Mm(e){return e===void 0||e==="neutral"?void 0:e}function Sh(e){return Mm(e)}function EO(e){const t=Mm(e);return t==="accent"?void 0:t}function ss(e,t){if(!t)return!0;const n=me(e,t.path),r=t.in!==void 0?t.in.includes(n):n===t.equals;return t.not===!0?!r:r}function $m(e,t,n){if("chat"in t){const o=ke(n,t.chat);return o==null?"":ze(String(o))}if("proposals"in t)return y2(e.plugin);const r=e.pages.find(o=>o.id===t.page);if((r==null?void 0:r.place)==="settings")return hm(e.plugin,t.page);const i=t.item===void 0?null:ke(n,t.item);return cl(e.plugin,t.page,i==null?null:String(i))}function AO(e,t){return e.replace(/\{count\}/g,String(t.count??0)).replace(/\{([^{}|]+)\|([^{}|]+)\}/g,(n,r,i)=>(t.count??0)===1?r:i).replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(n,r)=>{const i=me(t.row,r);return i==null?"":String(i)})}function Nh(e,t){if(e===void 0)return;if(typeof e=="string")return e;const n=ke(t,e);return n==="good"||n==="warning"||n==="critical"||n==="neutral"?n:void 0}function Ik(e,t,n){const r={};for(const[i,o]of Object.entries(e??{})){let l;"param"in o?l=n.params[o.param]:"route"in o?l=o.route==="plugin"?n.plugin:o.route==="page"?n.page:n.item:l=ke(t,o),!(l==null||l==="")&&(r[i]=String(l))}return r}function Ui(e,t){var r,i,o;const n={};for(const[l,a]of Object.entries(e??{}))if("row"in a)n[l]=me(t.row,a.row);else if("field"in a){if((r=t.omit)!=null&&r.has(a.field))continue;const c=(i=t.fields)==null?void 0:i[a.field],u=(o=t.shape)==null?void 0:o.find(p=>p.name===a.field);if(c===""&&(u==null?void 0:u.required)!==!0&&(u===void 0||u.type==="number"))continue;n[l]=c}else"selected"in a?n[l]=t.selected??[]:"param"in a?n[l]=t.scope.params[a.param]:n[l]=ke(t.data,a);return n}function cs(e,t){const n=bt(),r=e?Ik(e.params,t,n):{},i=JSON.stringify([(e==null?void 0:e.query)??null,r,n.version]),o=se(()=>e?A.pageQuery(n.plugin,e.query,r).then(l=>l.data):Promise.resolve(void 0),[i]);return{data:o.data,error:o.error,loading:o.loading}}function Sl(){const e=bt(),[t,n]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),f=(w,b)=>{if(w.done===void 0)return null;if(typeof w.done=="string")return w.done;const v=ke(b,w.done);return v==null?null:String(v)},h=(w,b,v)=>{const m=w??"refresh";if(typeof m=="object"){const y=$m(e,m.route,b);y===""?e.refresh():e.navigate(y);return}m==="close"&&(v==null||v()),e.refresh()},x=async(w,b,v)=>{n(w.tool),i(null),l(null);try{const m=await A.pageAct(e.plugin,{tool:w.tool,args:b});if(m.approvalId){c(m.approvalId),p({then:w.then,ref:w,...v?{onDone:v}:{}});return}c(null),p(null),l(f(w,m.result)),h(w.then,m.result,v)}catch(m){i(m instanceof Error?m.message:String(m)),e.refresh()}finally{n(null)}},j=w=>{if(!w){e.refresh();return}const b=u;if(c(null),p(null),b&&w.decision==="approve"&&w.state==="succeeded"){l(f(b.ref,w.result)),h(b.then,void 0,b.onDone);return}e.refresh()};return{running:t,busy:t!==null,error:r,done:o,approvalId:a,waiting:(u==null?void 0:u.ref.pending)??null,settle:j,run:x}}function Bi({action:e,args:t,disabled:n,running:r,count:i,row:o,onRun:l}){const[a,c]=d.useState(!1),u=f=>AO(f,{...i===void 0?{}:{count:i},row:o}),p=u(e.label);return a&&e.confirm?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-note",children:u(e.confirm)}),s.jsx(R,{variant:"ghost",onClick:()=>c(!1),children:"Cancel"}),s.jsxs(R,{variant:e.tone==="danger"?"danger":"accent",disabled:n,onClick:()=>{c(!1),l(e,t)},children:["Yes, ",p.toLowerCase()]})]}):s.jsx(R,{variant:e.tone==="danger"?"danger":e.tone==="accent"?"accent":void 0,disabled:n,onClick:()=>e.confirm?c(!0):l(e,t),children:r&&e.busy?e.busy:p})}function Ch({id:e,onDecided:t}){const n=bt(),r=se(()=>A.approval(e),[e,n.version]),{busy:i,note:o,failure:l,decide:a}=Tm(c=>{t?t(c):n.refresh()});return r.error?s.jsx(re,{message:r.error}):r.data?s.jsxs(G,{children:[s.jsx(Rm,{action:r.data,timezone:n.timezone,busy:i===e,onDecide:(c,u,p,f)=>{a(c,u,p,f)}}),o?s.jsx(V,{tone:"good",role:"status",children:o}):null,s.jsx(re,{message:l})]}):s.jsx(ie,{children:"Loading the approval…"})}function oo({act:e}){return e.error?s.jsx(re,{message:e.error}):e.approvalId?e.waiting?s.jsxs(G,{children:[s.jsx(V,{role:"status",children:e.waiting}),s.jsx(Ch,{id:e.approvalId,onDecided:e.settle})]}):s.jsx(Ch,{id:e.approvalId,onDecided:e.settle}):e.done?s.jsx(V,{tone:"good",role:"status",children:e.done}):null}function Ic(e,t){const n={};for(const r of e){const i=r.from===void 0?void 0:me(t,r.from);n[r.name]=i!==void 0?i:r.type==="checkbox"?!1:(r.type==="number","")}return n}function TO(e,t,n){const r=bt(),i=e.optionsFrom,o=i?{...Ik(i.query.params,n,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,o,r.version]),a=se(()=>i?A.pageQuery(r.plugin,i.query.query,o).then(c=>c.data):Promise.resolve(void 0),[l]);return i?{options:Wi(a.data,i.rows).map(c=>({value:String(me(c,i.value)??""),label:String(me(c,i.label)??"")})),loading:a.loading}:{options:e.options??[],loading:!1}}function RO({field:e,value:t,values:n,data:r,disabled:i,compact:o,onChange:l}){const a=TO(e,n,r),c={id:`f-${e.name}`,required:e.required,name:e.name,disabled:i,...o&&e.hint?{title:e.hint}:{}},u=o?void 0:e.hint;if(e.type==="select")return s.jsx(ee,{label:e.label,hint:u,children:s.jsxs("select",{...c,value:String(t??""),onChange:f=>l(f.target.value),children:[s.jsx("option",{value:"",children:a.loading?"Loading…":"—"}),a.options.map(f=>s.jsx("option",{value:f.value,children:f.label},f.value))]})});if(e.type==="textarea")return s.jsx(ee,{label:e.label,hint:u,wide:!0,children:s.jsx("textarea",{...c,value:String(t??""),onChange:f=>l(f.target.value),rows:6})});if(e.type==="checkbox")return s.jsx(ee,{label:e.label,hint:u,inline:!0,wide:!o,children:s.jsx("input",{...c,type:"checkbox",checked:t===!0,onChange:f=>l(f.target.checked)})});const p=e.type==="secret"?"password":e.type==="number"?"number":e.type;return s.jsx(ee,{label:e.label,hint:u,children:s.jsx("input",{...c,type:p,value:t==null?"":String(t),min:e.min,max:e.max,step:e.step,...o&&e.hint?{placeholder:e.hint}:{},onChange:f=>l(e.type==="number"?PO(f.target.value):f.target.value)})})}function PO(e){if(e.trim()==="")return"";const t=Number(e);return Number.isFinite(t)?t:e}function Mk(e,t){return{...typeof t=="object"&&t!==null?t:{},...e}}function $k(e,t,n){const r=Mk(t,n);return new Set(e.filter(i=>i.when!==void 0&&!ss(r,i.when)||i.disabledWhen!==void 0&&ss(r,i.disabledWhen)).map(i=>i.name))}function _m({fields:e,values:t,data:n,disabled:r,compact:i,onChange:o}){const l=Mk(t,n);return s.jsx(Ts,{dense:i,children:e.filter(a=>a.when===void 0||ss(l,a.when)).map(a=>s.jsx(RO,{field:a,compact:i,value:t[a.name],values:t,data:n,disabled:r===!0||a.disabledWhen!==void 0&&ss(l,a.disabledWhen),onChange:c=>o(a.name,c)},a.name))})}const fl=d.createContext(!1),_k=d.createContext(!1),Ok=d.createContext(!1);function $s({title:e,note:t,actions:n,children:r}){const i=d.useContext(fl);return s.jsx(Y,{title:e,aside:t,actions:n,panel:i,children:s.jsx(fl.Provider,{value:!1,children:s.jsx(_k.Provider,{value:i,children:r})})})}function Rs({component:e,data:t,choose:n,chosen:r}){const i=bt(),o=d.useContext(Pc);if(!ss(t,e.when))return null;if(e.kind!=="section"&&!o&&Ek(e,i.sensitive))return s.jsx(Pk,{children:s.jsx(Rs,{component:e,data:t,...n?{choose:n}:{},...r===void 0?{}:{chosen:r}})});switch(e.kind){case"section":return s.jsx(IO,{component:e,data:t});case"notice":return s.jsx(V,{tone:Mm(e.tone),title:e.title,children:typeof e.text=="string"?e.text:String(ke(t,e.text)??"")});case"link":return s.jsx(MO,{component:e,data:t});case"stats":return s.jsx($O,{component:e,data:t});case"list":return s.jsx(OO,{component:e,data:t,...n?{onChoose:n}:{},...r===void 0?{}:{chosen:r}});case"table":return s.jsx(DO,{component:e,data:t});case"detail":return s.jsx(zO,{component:e,data:t});case"form":return s.jsx(UO,{component:e,data:t});case"search":return s.jsx(HO,{component:e,data:t});case"list-detail":return s.jsx(VO,{component:e,data:t});case"repeat":return s.jsx(KO,{component:e,data:t});case"expand":return s.jsx(GO,{component:e,data:t});case"button":return s.jsx(YO,{component:e,data:t});case"approval":return s.jsx(QO,{component:e,data:t});case"artifact":return s.jsx(JO,{component:e,data:t});case"editor":return s.jsx(XO,{component:e,data:t});case"agent-offer":return s.jsx(qO,{component:e});default:return null}}function IO({component:e,data:t}){const n=bt(),r=d.useContext(Pc),[i,o]=Ak(),l=!r&&Ek(e.body,n.sensitive),a=l&&!i,c=d.useContext(fl);let u=e.body.length;const p=x=>x.kind==="button"||x.kind==="link"||x.kind==="form"&&x.drawer!==void 0&&!x.title;for(;c&&u>0&&p(e.body[u-1]);)u-=1;const f=e.body.slice(0,u),h=[...e.actions??[],...e.body.slice(u)];return s.jsx($s,{title:e.title,note:e.note,actions:h.length>0||l?s.jsxs(s.Fragment,{children:[h.map((x,j)=>s.jsx(Rs,{component:x,data:t},j)),l?s.jsx(Tk,{revealed:i,onToggle:o}):null]}):void 0,children:s.jsx(G,{gap:"lg",divided:c,children:a?s.jsx(Rk,{}):s.jsx(Pc.Provider,{value:r||l,children:f.map((x,j)=>s.jsx(Rs,{component:x,data:t},j))})})})}function MO({component:e,data:t}){const n=bt(),r=$m(n,e.to,t);return r===""?null:s.jsx(J,{children:s.jsx(Un,{href:r,onClick:i=>{i.preventDefault(),n.navigate(r)},children:e.label})})}function $O({component:e,data:t}){const n=cs(e.query,t);return s.jsxs($s,{title:e.title,note:e.note,children:[s.jsx(re,{message:n.error}),n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx(pu,{children:e.items.map((r,i)=>s.jsx(Zn,{label:r.label,value:jt(ke(n.data,r.value),r.unit??"text",null),tone:EO(r.tone)},i))})]})}function Dk(e,t,n,r){const i=(t.meta??[]).map(u=>String(ke(n,u)??"")).filter(u=>u!==""),o=String(ke(n,t.title)??""),l=t.to&&!r?$m(e,t.to,n):null,c=[...t.pill?[t.pill]:[],...t.pills??[]].map((u,p)=>{const f=ke(n,u.value);if(f==null||f==="")return null;const h=_O(u,f,n);return s.jsx(pe,{tone:Sh(h.tone),children:h.text},p)});return{text:o,href:l,pills:s.jsx(s.Fragment,{children:c}),meta:i.join(" · "),title:l?s.jsx("a",{href:l,onClick:u=>{u.preventDefault(),e.navigate(l)},children:o}):o,sub:t.sub?String(ke(n,t.sub)??""):null,side:s.jsxs(s.Fragment,{children:[c,i.length>0?s.jsxs("span",{className:"muted",children:[" ",i.join(" · ")]}):null]})}}function _O(e,t,n){const r=String(t),i=e.labels??{},o=e.tones??{};return{text:Object.prototype.hasOwnProperty.call(i,r)?i[r]:r,tone:Object.prototype.hasOwnProperty.call(o,r)?o[r]:Nh(e.tone,n)}}function Wi(e,t){const n=me(e,t);return Array.isArray(n)?n:[]}function Lk(e,t,n){const r=[],i=new Set;return e.forEach((o,l)=>{const a=t===void 0?void 0:me(o,t),c=a==null||a===""?null:String(a);if(c===null){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: row ${l} has no value at "${t??"(no key)"}" — not drawn`);return}if(i.has(c)){console.warn(`buddi: plugin ${n.plugin}, page ${n.page}, ${n.component}: two rows share the key "${c}" — the second is not drawn`);return}i.add(c),r.push({key:c,row:o})}),r}function OO({component:e,data:t,onChoose:n,chosen:r}){var k;const i=bt(),o=d.useContext(Ok),l=cs(e.query,t),a=Sl(),[c,u]=d.useState([]),p=o&&!e.select&&(e.actions??[]).length===0&&(e.bulk??[]).length===0,f=Wi(l.data,e.rows),h=e.collapsed?Wi(l.data,e.collapsed.rows):[],x={plugin:i.plugin,page:i.page,component:`list "${e.title??e.rows}"`},j=Lk([...f,...h],e.key??((k=e.select)==null?void 0:k.key),x),w=new Map(j.map(S=>[S.row,S.key])),b=new Set(j.map(S=>S.row)),v=new Set(j.filter(({row:S})=>{var N;return((N=e.select)==null?void 0:N.disabledWhen)===void 0||!ss(S,e.select.disabledWhen)}).map(({key:S})=>S)),m=c.filter(S=>v.has(S)),y=d.useMemo(()=>{const S=f.filter(C=>b.has(C));if(!e.groupBy)return[{label:null,rows:S}];const N=new Map;for(const C of S){const P=String(me(C,e.groupBy.key)??"");N.set(P,[...N.get(P)??[],C])}return[...N].map(([C,P])=>{var E,O;return{label:((O=(E=e.groupBy)==null?void 0:E.labels)==null?void 0:O[C])??C,rows:P}})},[f,e.groupBy,j.length]),g=S=>S.map(N=>{var L;const C=Dk(i,e.item,N,n),P=w.get(N);if(p&&(n||C.href))return s.jsx(Y0,{href:C.href??"#",current:r===P,onClick:()=>n?n(P):i.navigate(C.href),title:C.text,meta:C.meta,sub:C.sub,side:C.pills},P);const E=((L=e.select)==null?void 0:L.disabledWhen)!==void 0&&ss(N,e.select.disabledWhen),O=(e.actions??[]).filter(D=>ss(N,D.when));return s.jsx(Kt,{lead:e.select?s.jsx("input",{type:"checkbox","aria-label":`Select ${C.text}`,disabled:E,checked:c.includes(P),onClick:D=>D.stopPropagation(),onChange:D=>u(T=>D.target.checked?[...T,P]:T.filter(z=>z!==P))}):void 0,title:n?s.jsx("a",{href:"#","aria-current":r===P?"true":void 0,onClick:D=>{D.preventDefault(),n(P)},children:C.text}):C.title,sub:C.sub,side:s.jsxs(s.Fragment,{children:[C.side,O.map((D,T)=>s.jsx(Bi,{action:D,args:Ui(D.args,{data:l.data,row:N,scope:i}),disabled:a.busy,running:a.running===D.tool,row:N,onRun:(z,q)=>void a.run(z,q)},T))]})},P)});return s.jsxs($s,{title:e.title,note:e.note,children:[s.jsx(re,{message:l.error}),s.jsx(oo,{act:a}),y.every(S=>S.rows.length===0)?l.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsxs(Ft,{children:[e.select?s.jsx(Kt,{lead:s.jsx("input",{type:"checkbox","aria-label":"Select every row",checked:v.size>0&&m.length===v.size,disabled:v.size===0,onChange:S=>u(S.target.checked?[...v]:[])}),title:s.jsxs("span",{className:"muted",children:[v.size," to choose from"]})}):null,y.map((S,N)=>s.jsxs("div",{children:[S.label?s.jsx("div",{className:"ui-list-group",children:S.label}):null,g(S.rows)]},N))]}),e.collapsed&&h.some(S=>b.has(S))?s.jsx(wt,{summary:`${e.collapsed.label} (${h.filter(S=>b.has(S)).length})`,children:s.jsx(Ft,{children:g(h.filter(S=>b.has(S)))})}):null,e.bulk&&e.bulk.length>0?s.jsxs(J,{align:"end",children:[s.jsxs("span",{className:"ui-toolbar-note",children:[m.length," selected"]}),e.bulk.map((S,N)=>{const C=m.length>0||S.all!==!0?m:[...v];return s.jsx(Bi,{action:S,args:Ui(S.args,{data:l.data,selected:C,scope:i}),count:C.length,disabled:a.busy||C.length===0,running:a.running===S.tool,onRun:(P,E)=>{u([]),a.run(P,E)}},N)})]}):null]})}function DO({component:e,data:t}){const n=bt(),r=cs(e.query,t),i=Sl(),o=Wi(r.data,e.rows);return s.jsxs($s,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),s.jsx(oo,{act:i}),o.length===0?r.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[e.columns.map(l=>s.jsx("th",{children:l.label},l.key)),e.actions&&e.actions.length>0?s.jsx("th",{"aria-label":"Actions"}):null]})}),s.jsx("tbody",{children:o.map((l,a)=>s.jsxs("tr",{children:[e.columns.map(c=>{const u=c.pill?null:jt(me(l,c.key),c.type??"text",null);return s.jsx("td",{"data-fit":c.fit,title:LO(c,l,u),children:c.pill?s.jsx(FO,{column:c,row:l}):c.fit==="truncate"?s.jsx("span",{className:"ui-table-cut",children:u}):u},c.key)}),e.actions&&e.actions.length>0?s.jsx("td",{children:s.jsx(J,{align:"end",children:e.actions.filter(c=>ss(l,c.when)).map((c,u)=>s.jsx(Bi,{action:c,args:Ui(c.args,{data:r.data,row:l,scope:n}),disabled:i.busy,running:i.running===c.tool,row:l,onRun:(p,f)=>void i.run(p,f)},u))})}):null]},a))})]})]})}function LO(e,t,n){if(e.hint){const r=me(t,e.hint);if(r!=null&&r!=="")return String(r)}return e.fit==="truncate"&&n?n:void 0}function FO({column:e,row:t}){var l,a;const n=me(t,e.key);if(Array.isArray(n))return s.jsx(s.Fragment,{children:n.map((c,u)=>{var w;const p=c,f=typeof p=="object"&&p!==null?p.value:c;if(f==null||f==="")return null;const h=typeof p=="object"&&p!==null?p.tone:void 0,x=(w=e.pill)==null?void 0:w.labels,j=x&&Object.prototype.hasOwnProperty.call(x,String(f))?x[String(f)]:jt(f,e.type??"text",null);return s.jsx(pe,{tone:Sh(Nh(typeof h=="string"?h:void 0,t)),children:j},u)})});const r=(l=e.pill)==null?void 0:l.labels,i=String(n),o=r&&Object.prototype.hasOwnProperty.call(r,i)?r[i]:jt(n,e.type??"text",null);return s.jsx(pe,{tone:Sh(Nh((a=e.pill)==null?void 0:a.tone,t)),children:o})}function zO({component:e,data:t}){const n=cs(e.query,t);return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsx($s,{title:e.title,note:e.note,children:s.jsxs(G,{gap:"lg",children:[e.fields.length>0?s.jsx(At,{items:e.fields.map(r=>({key:r.label,label:r.label,value:jt(ke(n.data,r.value),r.unit??"text",null)}))}):null,e.body.map((r,i)=>s.jsx(Rs,{component:r,data:n.data},i))]})})}function UO({component:e,data:t}){const n=bt(),r=cs(e.initial,t),i=Sl(),[o,l]=d.useState(!1),a=JSON.stringify([r.data??null,n.version]),c=s.jsx(BO,{component:e,data:t,initialData:r.data,act:i,onDone:()=>l(!1)},a);return e.drawer?s.jsxs(Y,{title:e.title,aside:e.note,actions:s.jsx(R,{variant:"accent",onClick:()=>l(!0),children:e.drawer.button}),children:[s.jsx(oo,{act:i}),o?s.jsx(qt,{title:e.drawer.title,onClose:()=>l(!1),children:c}):null]}):s.jsxs($s,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),c]})}function BO({component:e,data:t,initialData:n,act:r,onDone:i}){const o=d.useContext(_k),l=bt(),[a,c]=d.useState(()=>Ic(e.fields,n)),u=$k(e.fields,a,n),p=e.fields.some(f=>f.required&&!u.has(f.name)&&(a[f.name]===""||a[f.name]===void 0));return s.jsxs(G,{children:[s.jsx(_m,{fields:e.fields,values:a,data:n,onChange:(f,h)=>c(x=>({...x,[f]:h}))}),e.drawer?null:s.jsx(oo,{act:r}),s.jsx(J,{align:"end",className:o?"ui-panel-foot":void 0,children:s.jsx(Bi,{action:e.submit,args:Ui(e.submit.args,{data:t,fields:a,shape:e.fields,omit:u,scope:l}),disabled:r.busy||p,running:r.running===e.submit.tool,onRun:(f,h)=>void r.run(f,h,i)})})]})}function WO(e,t){var r;if(e.type==="checkbox")return e.label;const n=(r=e.options)==null?void 0:r.find(i=>i.value===t);return`${e.label}: ${n?n.label:t}`}function Bv(e){return e!=null&&e!==""&&e!==!1&&e!=="false"}function HO({component:e,data:t}){const n=bt(),[r,i]=d.useState(()=>Ic(e.fields,t)),[o,l]=d.useState(e.auto===!0),[a,c]=d.useState(!1),u=e.fields.every(C=>!C.required||String(r[C.name]??"")!==""),p=cs(o&&u?e.query:void 0,t),f=Wi(p.data,e.rows),h=e.count===void 0?void 0:me(p.data,e.count),x=e.note===void 0?void 0:me(p.data,e.note),j=e.fields.find(C=>C.type==="text"||C.type==="email")??null,w=e.fields.filter(C=>C!==j),b=C=>{n.setParams(Object.fromEntries(e.fields.map(P=>[P.name,String(C[P.name]??"")||null]))),l(!0)},v=(C,P)=>{const E={...r,[C]:P};i(E),e.auto&&b(E)},m=()=>{const C=Ic(e.fields,null);i(C),e.auto?b(C):(n.setParams(Object.fromEntries(e.fields.map(P=>[P.name,null]))),l(!1))},y=o?w.filter(C=>Bv(n.params[C.name])):[],g=j?y.map(C=>s.jsx(ch,{label:C.label,onRemove:()=>{const P={...r,[C.name]:C.type==="checkbox"?!1:""};i(P),b(P)},children:WO(C,String(n.params[C.name]))},C.name)):[],k=w.filter(C=>Bv(r[C.name])).length,S=e.auto&&!e.reset?null:s.jsxs(s.Fragment,{children:[e.reset?s.jsx(R,{variant:"ghost",onClick:m,children:"Clear"}):null,e.auto?null:s.jsx(R,{type:"submit",variant:"accent",disabled:!u,children:"Search"})]}),N=e.results.to?e.results:e.to?{...e.results,to:e.to}:e.results;return s.jsx($s,{title:e.title,children:s.jsxs(G,{children:[s.jsx(Q0,{label:e.title??"Search",onSubmit:()=>{!e.auto&&u&&b(r)},main:j?s.jsx("input",{id:`f-${j.name}`,name:j.name,type:j.type==="email"?"email":"search","aria-label":j.label,placeholder:j.hint??j.label,title:j.hint,required:j.required,value:String(r[j.name]??""),onChange:C=>v(j.name,C.target.value)}):void 0,filters:w.length>0?s.jsx(_m,{fields:w,values:r,data:t,compact:!0,onChange:v}):void 0,...j&&w.length>0?{filtersOpen:a,onToggleFilters:()=>c(C=>!C),active:k}:{},chips:g.length>0?g:void 0,actions:S}),s.jsx(re,{message:p.error}),o&&(h!==void 0||x!==void 0)?s.jsxs("p",{className:"ui-card-meta",children:[h===void 0?"":`${jt(h,"number",null)} in all. `,x===void 0?"":String(x)]}):null,o?f.length===0?s.jsx(ie,{children:p.loading?"Searching…":e.empty??"Nothing matches."}):s.jsx("div",{className:"ui-panel","data-flush":"true",children:s.jsx(Ft,{children:f.map((C,P)=>{const E=Dk(n,N,C);return s.jsx(Kt,{title:E.title,sub:E.sub,side:E.side},P)})})}):null]})})}function VO({component:e,data:t}){const n=bt(),r=e.selection==="local",[i,o]=d.useState(null),l=r?i:n.params[e.param]??n.item,a=r&&i!==null?{...n,params:{...n.params,[e.param]:i}}:null,c=s.jsx(G,{gap:"lg",divided:!0,children:e.detail.map((u,p)=>s.jsx(Rs,{component:u,data:t},p))});return s.jsx(fl.Provider,{value:!1,children:s.jsx(q0,{list:s.jsx(Ok.Provider,{value:!0,children:s.jsx(Rs,{component:e.list,data:t,chosen:l??null,...r?{choose:o}:{}})}),detail:l?a?s.jsx(Im.Provider,{value:a,children:c}):c:void 0,empty:e.empty??"Choose one to see it here."})})}function KO({component:e,data:t}){const n=bt(),r=cs(e.query,t),i=Wi(r.data,e.rows);return s.jsxs($s,{title:e.title,note:e.note,children:[s.jsx(re,{message:r.error}),i.length===0?r.loading?s.jsx(ie,{children:"Loading…"}):s.jsx(Om,{text:e.empty??"Nothing here yet."}):s.jsx(G,{gap:"lg",divided:!0,children:Lk(i,e.key,{plugin:n.plugin,page:n.page,component:`repeat "${e.title??e.rows}"`}).map(({key:o,row:l})=>s.jsx(Y,{children:s.jsx(G,{children:e.body.map((a,c)=>s.jsx(Rs,{component:a,data:l},c))})},o))})]})}function GO({component:e,data:t}){const[n,r]=d.useState(!1),i=cs(n?e.query:void 0,t),o=typeof e.label=="string"?e.label:String(ke(t,e.label)??"");return s.jsxs(wt,{summary:o,boxed:!0,onToggle:l=>r(l),children:[s.jsx(re,{message:i.error}),i.data===void 0?s.jsx(ie,{children:"Loading…"}):s.jsx(G,{children:e.body.map((l,a)=>s.jsx(Rs,{component:l,data:i.data},a))})]})}function YO({component:e,data:t}){const n=bt(),r=Sl();return s.jsxs(s.Fragment,{children:[s.jsx(J,{align:"end",children:s.jsx(Bi,{action:e.action,args:Ui(e.action.args,{data:t,row:t,scope:n}),disabled:r.busy,running:r.running===e.action.tool,row:t,onRun:(i,o)=>void r.run(i,o)})}),s.jsx(oo,{act:r})]})}function qO({component:e}){const t=bt();return s.jsx(Pm,{plugin:t.plugin,agent:e.agent,text:e.text,label:e.label})}function QO({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(Ch,{id:n})}function JO({component:e,data:t}){const n=me(t,e.path);return typeof n!="string"||n===""?null:s.jsx(J,{children:s.jsx("a",{href:xu(n),children:e.label})})}function XO({component:e,data:t}){const n=cs(e.query,t),r=Sl();return n.error?s.jsx(re,{message:n.error}):n.data===void 0?s.jsx(ie,{children:e.empty??"Loading…"}):s.jsxs(s.Fragment,{children:[s.jsx(oo,{act:r}),s.jsx(ZO,{component:e,data:t,loaded:n.data,act:r},JSON.stringify(n.data))]})}function ZO({component:e,data:t,loaded:n,act:r}){const i=bt(),[o,l]=d.useState(()=>Ic(e.fields,n)),a={...o,version:me(n,e.version)},c=$k(e.fields,o,n),u=e.readOnlyWhen!==void 0&&ss(n,e.readOnlyWhen),p=(e.actions??[]).filter(x=>x.placement==="leading"),f=(e.actions??[]).filter(x=>x.placement!=="leading"),h=(x,j)=>s.jsx(Bi,{action:x,args:Ui(x.args,{data:t,fields:a,shape:e.fields,omit:c,scope:i}),disabled:r.busy,running:r.running===x.tool,onRun:(w,b)=>void r.run(w,b)},`${x.tool}-${j}`);return s.jsx($s,{title:e.title,note:e.note,children:s.jsxs(G,{children:[s.jsx(_m,{fields:e.fields,values:o,data:n,disabled:u,onChange:(x,j)=>l(w=>({...w,[x]:j}))}),u?null:s.jsxs(J,{align:"end",children:[p.map(h),p.length>0?s.jsx(ro,{}):null,h(e.save,-1),f.map(h)]}),e.footnote?s.jsx("p",{className:"ui-toolbar-note",children:e.footnote}):null]})})}function Fk({page:e,item:t,navigate:n,timezone:r,embedded:i,siblings:o}){const[l,a]=d.useState({}),[c,u]=d.useState(0),p={plugin:e.plugin,page:e.id,pages:o??[e],item:t??null,params:{...l,...t?{item:t}:{},...tD(e,t)},setParams:j=>a(w=>{const b={...w};for(const[v,m]of Object.entries(j))m===null?delete b[v]:b[v]=m;return b}),navigate:n,timezone:r,version:c,refresh:()=>u(j=>j+1),sensitive:new Set(e.sensitive??[])},f=e.body[0],h=!i&&(f==null?void 0:f.kind)==="notice"&&typeof f.text=="string"&&f.when===void 0&&f.title===void 0&&(f.tone===void 0||f.tone==="neutral")?f.text:void 0,x=h===void 0?e:{...e,body:e.body.slice(1)};return s.jsx(Im.Provider,{value:p,children:s.jsx(an,{embedded:i,title:e.title,lede:h,children:s.jsx(eD,{page:x,boxed:i===!0})})})}function eD({page:e,boxed:t}){const n=bt();return e.data&&n.sensitive.has(e.data.query)?s.jsx(Pk,{children:s.jsx(Wv,{page:e,boxed:t})}):s.jsx(Wv,{page:e,boxed:t})}function Wv({page:e,boxed:t}){const n=cs(e.data,null);return s.jsxs(G,{gap:"lg",divided:!t,children:[s.jsx(re,{message:n.error}),s.jsx(fl.Provider,{value:t,children:e.body.map((r,i)=>s.jsx(Rs,{component:r,data:n.data??null},i))})]})}function tD(e,t){if(!t)return{};const n=[],r=i=>{for(const o of i)o.kind==="list-detail"?(n.push(o.param),r(o.detail)):(o.kind==="section"||o.kind==="detail"||o.kind==="expand")&&r(o.body)};return r(e.body),Object.fromEntries(n.map(i=>[i,t]))}function nD(e){return s.jsx(Fk,{...e,embedded:!0})}function Om({text:e}){const t=e.search(/[.!?]\s/),n=t===-1?e.replace(/[.]$/,""):e.slice(0,t+(e[t]==="."?0:1)),r=t===-1?"":e.slice(t+1).trim();return s.jsx(yt,{title:n,children:r||null})}function Hv(e,t){return(e??[]).filter(n=>n.place===t).map((n,r)=>({page:n,index:r})).sort((n,r)=>(n.page.order??0)-(r.page.order??0)||n.index-r.index).map(n=>n.page)}function zk(e=!1){const[t,n]=d.useState([]);return d.useEffect(()=>{if(e)return;let r=!1;return Promise.resolve().then(()=>A.pages()).then(i=>{r||n(Array.isArray(i==null?void 0:i.pages)?i.pages:[])}).catch(()=>{}),()=>{r=!0}},[e]),{all:t,rail:Hv(t,"rail"),settings:Hv(t,"settings"),find:(r,i)=>t.find(o=>o.plugin===r&&o.id===i)}}const Vv=[{id:"",label:"All files"},{id:"produced",label:"Created by agents"},{id:"uploaded",label:"Uploaded by you"}],sD=["","image","pdf","table","text","code","audio","video","archive","file"];function rD({hash:e,timezone:t,navigate:n,agents:r}){var D;const i=p2(e),o=(i==null?void 0:i.artifactId)??null,l=(i==null?void 0:i.filters.origin)??"",a=(i==null?void 0:i.filters.family)??"",c=(i==null?void 0:i.filters.q)??"",[u,p]=d.useState(c);d.useEffect(()=>{p(c)},[c]);const f=(T,z=!1)=>n(oa(o,{q:c,origin:l,family:a,...T}),z);d.useEffect(()=>{if(u===c)return;const T=window.setTimeout(()=>f({q:u},!0),250);return()=>window.clearTimeout(T)},[u]);const[h,x]=d.useState(null),[j,w]=d.useState(null),[b,v]=d.useState(null),[m,y]=d.useState(!1),[g,k]=d.useState(!1),S=T=>{var z;return T?((z=r.find(q=>q.id===T))==null?void 0:z.name)??T:""},N=d.useRef(0);d.useEffect(()=>{const T=++N.current;x(null),w(null),y(!1),v(null),A.library({...c?{q:c}:{},...l?{origin:l}:{},...a?{family:a}:{}}).then(z=>{N.current===T&&(x(z.entries),w(z.next))}).catch(z=>{N.current===T&&v(z instanceof ce?z.message:String(z))})},[c,l,a]);const C=()=>{if(!j||m)return;y(!0);const T=N.current;A.library({...c?{q:c}:{},...l?{origin:l}:{},...a?{family:a}:{},cursor:j}).then(z=>{N.current===T&&(x(q=>{const K=new Set((q??[]).map(M=>M.id));return[...q??[],...z.entries.filter(M=>!K.has(M.id))]}),w(z.next))}).catch(z=>{N.current===T&&v(z instanceof ce?z.message:String(z))}).finally(()=>{N.current===T&&y(!1)})},P=(l?1:0)+(a?1:0),E=((D=Vv.find(T=>T.id===l))==null?void 0:D.label)??l,O=s.jsxs(s.Fragment,{children:[h===null?s.jsx(ie,{children:"Loading…"}):h.length===0?s.jsx(ie,{children:"No file matches that."}):s.jsx(Ft,{children:h.map(T=>s.jsx(Y0,{href:oa(T.id,{q:c,origin:l,family:a}),current:T.id===o,onClick:()=>n(oa(T.id,{q:c,origin:l,family:a})),lead:s.jsx("span",{className:"files-row-visual","data-family":T.family,children:T.family==="image"&&!T.deleted?s.jsx("img",{src:zr(T.id),alt:"",loading:"lazy"}):s.jsx(Em,{family:T.family})}),title:T.filename??"Untitled file",meta:s.jsx("span",{title:Re(T.createdAt,t),children:Se(T.createdAt)}),sub:`${Rr[T.family]} · ${An(T.sizeBytes)} · ${Uk(T,S)}${iD(T,S)}`},T.id))}),j?s.jsx("div",{className:"files-more",children:s.jsx(R,{size:"sm",onClick:C,disabled:m,children:m?"Loading…":"Show more"})}):null]}),L=h!==null&&h.length===0&&!c&&!l&&!a&&!u;return s.jsxs("div",{className:"ui-page files","data-selected":o?"true":void 0,children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Files"}),s.jsx("p",{className:"ui-page-lede",children:"What your agents made or were given."})]}),L?s.jsx(yt,{icon:"files",title:"Nothing here yet",children:"Drop a file into any conversation and it shows up here too."}):s.jsxs(s.Fragment,{children:[s.jsx(Q0,{label:"Files",onSubmit:()=>f({q:u},!0),main:s.jsx("input",{type:"search",value:u,placeholder:"Search by filename","aria-label":"Search files by name",onChange:T=>p(T.target.value)}),filters:s.jsxs(Ts,{dense:!0,children:[s.jsx(ee,{label:"Origin",children:s.jsx("select",{value:l,"aria-label":"Origin",onChange:T=>f({origin:T.target.value}),children:Vv.map(T=>s.jsx("option",{value:T.id,children:T.label},T.id))})}),s.jsx(ee,{label:"Kind",children:s.jsx("select",{value:a,"aria-label":"Kind",onChange:T=>f({family:T.target.value}),children:sD.map(T=>s.jsx("option",{value:T,children:T===""?"Any kind":Rr[T]},T))})})]}),filtersOpen:g,onToggleFilters:()=>k(T=>!T),active:P,chips:P>0?s.jsxs(s.Fragment,{children:[l?s.jsx(ch,{label:"Origin",onRemove:()=>f({origin:""}),children:E}):null,a?s.jsx(ch,{label:"Kind",onRemove:()=>f({family:""}),children:Rr[a]}):null]}):void 0}),s.jsx(re,{message:b}),s.jsx(q0,{className:"files-split",label:"Files",list:O,detail:o?s.jsx(oD,{id:o,timezone:t,agents:r,navigate:n,onBack:()=>n(oa(null,{q:c,origin:l,family:a}))},o):void 0,empty:"Choose a file to see it here."})]})]})}function iD(e,t){var i,o;const n=(i=e.context)!=null&&i.groupName?`in ${e.context.groupName}`:(o=e.context)!=null&&o.agentId&&e.context.agentId!==e.agentId?`with ${t(e.context.agentId)}`:"",r=e.contexts>1?`${e.contexts} conversations`:"";return[n,r].filter(Boolean).map(l=>` · ${l}`).join("")}function Uk(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 oD({id:e,timezone:t,agents:n,navigate:r,onBack:i}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null);d.useEffect(()=>{let m=!1;return l(null),p(null),A.libraryEntry(e).then(y=>{m||l(y)}).catch(y=>{m||p(y instanceof ce&&y.status===404?"This file is no longer in the library.":y instanceof ce?y.message:String(y))}),()=>{m=!0}},[e]);const f=m=>{var y;return m?((y=n.find(g=>g.id===m))==null?void 0:y.name)??m:""};if(u)return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(R,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsx(V,{tone:"critical",children:u})]});if(!o)return s.jsx("div",{className:"files-detail-body",children:s.jsx(ie,{children:"Loading…"})});const{entry:h,contexts:x,contextsTotal:j,available:w}=o,b=h.filename??"Untitled file",v=()=>{c(!0),A.libraryEntry(e,x.length).then(m=>l(y=>y&&{...y,contexts:[...y.contexts,...m.contexts],contextsTotal:m.contextsTotal})).catch(()=>{}).finally(()=>c(!1))};return s.jsxs("div",{className:"files-detail-body",children:[s.jsx(R,{size:"sm",onClick:i,className:"files-back",children:"Back to Files"}),s.jsxs("header",{className:"files-detail-head",children:[s.jsx("span",{className:"files-detail-mark","data-family":h.family,"aria-hidden":"true",children:s.jsx(Em,{family:h.family})}),s.jsxs("div",{className:"files-detail-text",children:[s.jsx("h3",{className:"files-detail-name",children:b}),s.jsxs("p",{className:"files-detail-meta",children:[Rr[h.family]," · ",An(h.sizeBytes)," · ",Re(h.createdAt,t)]})]}),w?s.jsx("a",{className:"ui-btn","data-variant":"accent",href:xu(h.id),download:b,children:"Download"}):null]}),w?null:s.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."}),s.jsx(lk,{artifactId:h.id,filename:h.filename,mime:h.mime,family:h.family,available:w}),s.jsx(At,{items:[{label:"Origin",value:Uk(h,f)},...h.agentId&&h.origin==="produced"?[{label:"Made by",value:s.jsxs("span",{className:"files-agent",children:[s.jsx(Zt,{agents:n,id:h.agentId,size:"sm"}),f(h.agentId)]})}]:[],{label:"Type",value:s.jsx("span",{className:"mono",children:h.mime})},{label:"Id",value:s.jsx("span",{className:"mono",children:h.id})}]}),s.jsxs("section",{className:"files-conversations",children:[s.jsx("h4",{className:"ui-section-title",children:"Conversations"}),x.length===0?s.jsx("p",{className:"muted",children:"No conversation is recorded for this file. It may date from before the library kept track."}):s.jsx("ul",{className:"files-ctx",role:"list",children:x.map(m=>{const y=m.groupId?Fo(m.groupId,m.conversationId):ze(m.conversationAgentId,m.conversationId),g=m.groupId?m.groupName??"a group":f(m.conversationAgentId);return s.jsxs("li",{className:"files-ctx-row",children:[s.jsxs("span",{className:"files-ctx-text",children:[s.jsx("span",{children:m.groupId?`Group: ${g}`:g}),s.jsxs("span",{className:"muted",children:[" · ",m.kind==="produced"?`made by ${f(m.agentId)||"an agent"}`:m.kind==="reused"?"sent again":"sent by you"," · ",Se(m.at)]})]}),s.jsx("a",{className:"ui-btn","data-size":"sm",href:y,onClick:k=>{k.preventDefault(),r(y)},children:"Open conversation"})]},`${m.conversationId}:${m.kind}`)})}),x.length<j?s.jsx(J,{align:"end",children:s.jsx(R,{size:"sm",onClick:v,disabled:a,children:a?"Loading…":`Show ${j-x.length} more`})}):null]})]})}const lD={mail:"mail",money:"money",calendar:"calendar",people:"agents",file:"files",chart:"chart",bell:"bell",plug:"plug",key:"key",globe:"globe"};function Bk(e){return e&&lD[e]||"plug"}function aD({attention:e,place:t,onNavigate:n,theme:r,onTheme:i,plugins:o=[],updateAvailable:l=!1,version:a}){return s.jsxs("nav",{className:"rail","aria-label":"Places",children:[s.jsx("a",{className:"rail-mark",href:Vt,onClick:c=>{c.preventDefault(),n(Vt)},"aria-label":"buddi home",children:s.jsx(J0,{})}),b2.filter(c=>c.route!==Jt).map(c=>s.jsx($d,{label:c.label,href:c.route,active:t===c.route,badge:c.route===Vt?e:0,onClick:()=>n(c.route),children:Kv[c.route]},c.route)),o.map(c=>{const u=cl(c.plugin,c.id);return s.jsx($d,{label:c.title,href:u,active:t===u,badge:0,onClick:()=>n(u),children:s.jsx(De,{name:Bk(c.icon)})},u)}),s.jsx("div",{className:"rail-spacer"}),s.jsx($d,{label:"Settings",href:Jt,active:t===Jt,badge:0,dot:l?"a newer buddi is ready":void 0,onClick:()=>n(Jt),children:Kv[Jt]}),s.jsx(uD,{theme:r,onTheme:i,onNavigate:n,version:a})]})}const cD=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function uD({theme:e,onTheme:t,onNavigate:n,version:r}){var a,c;const o=((c=(a=se(()=>A.owner(),[]).data)==null?void 0:a.preferredName)==null?void 0:c.trim())||null,l=(o??"You").slice(0,1).toUpperCase();return s.jsx("div",{className:"rail-owner",children:s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.jsx("button",{type:"button",className:"rail-owner-btn","aria-label":o?`You: ${o}`:"You",children:s.jsx("span",{className:"rail-owner-face","aria-hidden":"true",children:l})})}),s.jsx(im,{children:s.jsxs(om,{className:"ui-menu rail-owner-menu",side:"right",align:"end",sideOffset:10,children:[s.jsxs("div",{className:"rail-owner-head",children:[s.jsx("span",{className:"rail-owner-face","data-size":"lg","aria-hidden":"true",children:l}),s.jsxs("span",{className:"rail-owner-who",children:[s.jsx("span",{className:"rail-owner-name",children:o??"You"}),s.jsx("span",{className:"rail-owner-sub",children:"On this Mac"})]})]}),s.jsx(za,{className:"ui-menu-sep"}),s.jsx(lm,{className:"ui-menu-label",children:"Theme"}),s.jsx("div",{className:"rail-owner-theme",children:s.jsx(Ba,{label:"Theme",options:cD,value:e,onChange:t})}),s.jsx(za,{className:"ui-menu-sep"}),s.jsx(sh,{className:"ui-menu-item",onSelect:()=>n(st("appearance")),children:"Change appearance"}),r?s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"ui-menu-sep"}),s.jsxs(sh,{className:"ui-menu-item rail-owner-version","data-update":r.updateAvailable?"true":void 0,onSelect:()=>n(st("system")),children:[s.jsxs("span",{className:"mono",children:["buddi ",r.current]}),r.updateAvailable&&r.latest?s.jsxs("span",{className:"rail-owner-update",children:["A newer buddi is ready: ",r.latest]}):null]})]}):null]})})]})})}function $d({label:e,href:t,active:n,badge:r,dot:i,onClick:o,children:l}){return s.jsxs("a",{className:"rail-link",href:t,"data-active":n?"true":void 0,"aria-current":n?"page":void 0,"aria-label":r>0?`${e}, ${r} waiting`:i?`${e}, ${i}`:e,onClick:a=>{a.preventDefault(),o()},children:[s.jsxs("span",{className:"rail-icon",children:[l,r>0?s.jsx("span",{className:"rail-badge","aria-hidden":"true",children:r>99?"99+":r}):null,r===0&&i?s.jsx("span",{className:"ui-badge rail-dot","data-kind":"dot","data-testid":"rail-dot","aria-hidden":"true"}):null]}),s.jsx("span",{className:"rail-label",children:e})]})}const Kv={[Lr]:s.jsx(De,{name:"files"}),[Vt]:s.jsx(De,{name:"home"}),[Fi]:s.jsx(De,{name:"chat"}),[et]:s.jsx(De,{name:"agents"}),[Ze]:s.jsx(De,{name:"activity"}),[Jt]:s.jsx(De,{name:"settings"})},Wk="buddi.theme";function dD(e=Hk()){try{const t=e==null?void 0:e.getItem(Wk);return t==="light"||t==="dark"||t==="system"?t:"system"}catch{return"system"}}function fD(e,t=Hk()){try{t==null||t.setItem(Wk,e)}catch{}}function hD(e,t=document.documentElement){t&&(e==="system"?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e))}function Hk(){try{return window.localStorage}catch{return}}const Vk="buddi.ground",Kk="buddi.pageWidth";function pD(e=qk()){const t=i=>{try{return(e==null?void 0:e.getItem(i))??null}catch{return null}},n=t(Vk),r=t(Kk);return{theme:dD(e),ground:n==="sand"?"sand":"blue",width:r==="narrow"||r==="full"?r:"wide"}}function Gk(e,t=document.documentElement){t&&(hD(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 mD(e,t=qk()){fD(e.theme,t);try{t==null||t.setItem(Vk,e.ground),t==null||t.setItem(Kk,e.width)}catch{}}let Ti=null;const Eh=new Set;function Ah(){return Ti||(Ti=pD()),Ti}function gD(e){return Eh.add(e),()=>Eh.delete(e)}function xD(e){Ti={...Ah(),...e},Gk(Ti),mD(Ti);for(const t of Eh)t()}function Yk(){return[d.useSyncExternalStore(gD,Ah,Ah),xD]}function qk(){try{return window.localStorage}catch{return}}function vD({timezone:e,embedded:t}){var h,x;const{data:n,error:r,reload:i}=se(()=>A.sentinels(),[],3e4),o=se(()=>A.missions(),[]),[l,a]=d.useState(null),c=((x=(h=o.data)==null?void 0:h.missions.find(j=>j.id==="sentinel-wake"))==null?void 0:x.agentId)??null,u=async(j,w)=>{a(null);try{await A.snoozeAlert(j,w),i()}catch(b){a(b instanceof Error?b.message:String(b))}},p=((n==null?void 0:n.open)??[]).filter(j=>!j.snoozedAt),f=((n==null?void 0:n.open)??[]).filter(j=>j.snoozedAt);return s.jsxs(an,{embedded:t,title:"Alerts",lede:"What the watchers found.",children:[s.jsx(re,{message:r??l}),s.jsx(V,{children:"An alert closes on its own once the fact behind it changes: record the payment, update the balance, and the watcher clears it on its next run. Snooze one you have decided to live with; it stays quiet until it resolves."}),s.jsx(_d,{title:"Open",findings:p,timezone:e,askAgentId:c,onSnooze:j=>u(j,!0),empty:"Nothing open. Your watchers are quiet."}),f.length>0?s.jsx(_d,{title:"Snoozed",findings:f,timezone:e,askAgentId:c,onSnooze:j=>u(j,!1),empty:""}):null,s.jsx(_d,{title:"Resolved",findings:(n==null?void 0:n.resolved)??[],timezone:e,empty:"Nothing has resolved yet."}),s.jsx(rt,{title:"Waiting for the weekly recap",flush:!0,children:!n||n.digest.length===0?s.jsx(yt,{icon:"bell",title:"Nothing waiting for the recap"}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Title"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Noted"})]})}),s.jsx("tbody",{children:n.digest.map(j=>s.jsxs("tr",{children:[s.jsxs("td",{children:[Li(j.title),s.jsx(Jk,{text:Li(j.detail)})]}),s.jsx("td",{children:s.jsx(Qk,{severity:j.severity})}),s.jsx("td",{className:"nowrap",children:Re(j.createdAt,e)})]},j.id))})]})})]})}function Qk({severity:e}){return s.jsx(pe,{tone:e==="urgent"?"critical":void 0,children:e})}function Jk({text:e}){const[t,n]=d.useState(!1),r=e.length>240||e.split(`
|
|
104
|
-
`).length>3;return s.jsxs("div",{className:"sub alert-detail","data-clamp":r&&!t?"true":void 0,children:[e,r?s.jsx("button",{type:"button",className:"wb-link alert-more",onClick:()=>n(i=>!i),children:t?"Less":"More"}):null]})}function jD(e){return`About this alert: "${Li(e.title)}". ${Li(e.detail)}
|
|
105
|
-
|
|
106
|
-
What should I do about it, and what do you need from me to clear it?`}function _d({title:e,findings:t,timezone:n,askAgentId:r,onSnooze:i,empty:o}){const l=e==="Snoozed";return s.jsx(rt,{title:e,flush:!0,children:t.length===0?s.jsx(ie,{children:o}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Finding"}),s.jsx("th",{children:"Severity"}),s.jsx("th",{children:"Since"}),i?s.jsx("th",{}):null]})}),s.jsx("tbody",{children:t.map(a=>s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:Li(a.title)}),s.jsx(Jk,{text:Li(a.detail)}),a.data?s.jsx(wt,{summary:"evidence",children:s.jsx(at,{children:on(a.data)})}):null]}),s.jsx("td",{children:s.jsx(Qk,{severity:a.severity})}),s.jsxs("td",{className:"nowrap",children:[Re(a.firstSeenAt,n),s.jsxs("div",{className:"sub",title:Re(a.lastSeenAt,n),children:["last seen ",Se(a.lastSeenAt)]})]}),i?s.jsx("td",{children:s.jsxs(J,{align:"end",children:[r?s.jsx(Un,{size:"sm",href:ze(r,"new"),onClick:()=>cO(r,jD(a)),children:"Ask about it"}):null,s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(a.key),children:l?"Wake":"Snooze"})]})}):null]},a.key))})]})})}const Gv=5e3,Yv=50;function yD({timezone:e,embedded:t}){var v;const[n,r]=d.useState(""),[i,o]=d.useState(""),[l,a]=d.useState(null),c=se(()=>A.eventKinds(),[]),{data:u,error:p}=se(()=>A.events({kind:n||void 0,q:i||void 0,limit:Yv}),[n,i],Gv),[f,h]=d.useState({events:[],cursor:null,busy:!1,error:null});d.useEffect(()=>{h({events:[],cursor:null,busy:!1,error:null})},[n,i]);const x=f.events.length>0?f.cursor:(u==null?void 0:u.nextCursor)??null,j=async()=>{if(x){h(m=>({...m,busy:!0,error:null}));try{const m=await A.events({kind:n||void 0,q:i||void 0,before:x,limit:Yv});h(y=>({events:[...y.events,...m.events],cursor:m.nextCursor,busy:!1,error:null}))}catch(m){h(y=>({...y,busy:!1,error:m instanceof Error?m.message:String(m)}))}}},w=new Set(((u==null?void 0:u.events)??[]).map(m=>m.id)),b=[...(u==null?void 0:u.events)??[],...f.events.filter(m=>!w.has(m.id))];return s.jsxs(an,{embedded:t,title:"Events",lede:"The append-only log. Everything the installation did, including what you do here.",children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Event kind",value:n,onChange:m=>r(m.target.value),children:[s.jsx("option",{value:"",children:"every kind"}),(((v=c.data)==null?void 0:v.kinds)??[]).map(m=>s.jsxs("option",{value:m.kind,children:[m.kind," (",m.count,")"]},m.kind))]}),s.jsx("input",{"aria-label":"Payload contains",placeholder:"payload contains…",value:i,onChange:m=>o(m.target.value),size:28}),n||i?s.jsx(R,{onClick:()=>{r(""),o("")},children:"Clear"}):null,s.jsxs("span",{className:"muted",children:["refreshes every ",Gv/1e3,"s"]})]}),s.jsx(re,{message:p}),s.jsx(rt,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No events match."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"When"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Payload"})]})}),s.jsx("tbody",{children:b.map(m=>s.jsxs("tr",{"data-clickable":"true",onClick:()=>a(m),children:[s.jsx("td",{className:"mono muted",children:m.id}),s.jsxs("td",{className:"nowrap",children:[Re(m.createdAt,e),s.jsx("div",{className:"sub",children:Se(m.createdAt)})]}),s.jsx("td",{className:"mono nowrap",children:m.kind}),s.jsx("td",{className:"mono muted",children:As(on(m.payload).replace(/\s+/g," "),120)})]},m.id))})]})}),x||f.error?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," shown",x?", older ones are kept":"","."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),f.error?s.jsx("span",{className:"critical",children:f.error}):null,x?s.jsx(R,{disabled:f.busy,onClick:()=>void j(),children:f.busy?"Loading…":"Load older"}):null]}):null,l?s.jsxs(qt,{title:l.kind,onClose:()=>a(null),children:[s.jsxs("p",{className:"muted",children:["Event ",l.id," · ",Re(l.createdAt,e),l.conversationId?s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:`#/conversations/${l.conversationId}`,children:"conversation"})]}):null]}),s.jsx(at,{children:on(l.payload)})]}):null]})}const wD=["pending","leased","suspended","failed","succeeded","cancelled"],So=50;function bD({timezone:e,embedded:t,initialState:n}){const[r,i]=d.useState(n??""),[o,l]=d.useState(null),[a,c]=d.useState(null),{data:u,error:p,reload:f}=se(()=>A.jobs({...r?{state:r}:{},limit:String(So)}),[r],1e4),[h,x]=d.useState({jobs:[],done:!1,busy:!1});d.useEffect(()=>{x({jobs:[],done:!1,busy:!1})},[r]);const j=async()=>{x(N=>({...N,busy:!0}));try{const N=await A.jobs({...r?{state:r}:{},limit:String(So),offset:String(So+h.jobs.length)});x(C=>({jobs:[...C.jobs,...N.jobs],done:N.jobs.length<So,busy:!1}))}catch(N){c(N instanceof Error?N.message:String(N)),x(C=>({...C,busy:!1}))}},w=new Set(((u==null?void 0:u.jobs)??[]).map(N=>N.id)),b=[...(u==null?void 0:u.jobs)??[],...h.jobs.filter(N=>!w.has(N.id))],v=r?(u==null?void 0:u.counts[r])??0:Object.values((u==null?void 0:u.counts)??{}).reduce((N,C)=>N+C,0),m=!h.done&&b.length<v&&((u==null?void 0:u.jobs.length)??0)>=So,[y,g]=d.useState(null),k=async N=>{c(null),g(N);try{const C=(await A.jobs({state:"failed",limit:"500"})).jobs;for(const P of C)await(N==="retry"?A.retryJob(P.id):A.cancelJob(P.id));f()}catch(C){c(C instanceof Error?C.message:String(C))}finally{g(null)}},S=async N=>{c(null);try{await N,l(null),f()}catch(C){c(C instanceof Error?C.message:String(C))}};return s.jsxs(an,{embedded:t,title:"Jobs",lede:`${u!=null&&u.paused?"Paused: nothing is being claimed. ":""}Bounded retries with backoff; past the budget a job waits for you.`,actions:t?void 0:s.jsx(R,{size:"sm",variant:u!=null&&u.paused?"accent":void 0,onClick:()=>S(A.setPaused(!((u==null?void 0:u.paused)??!1))),children:u!=null&&u.paused?"Resume the queue":"Pause the queue"}),children:[s.jsxs(J,{children:[s.jsxs("select",{"aria-label":"Job state",value:r,onChange:N=>i(N.target.value),children:[s.jsx("option",{value:"",children:"every state"}),wD.map(N=>s.jsxs("option",{value:N,children:[N," (",(u==null?void 0:u.counts[N])??0,")"]},N))]}),((u==null?void 0:u.counts.failed)??0)>0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("span",{className:"muted",children:[u.counts.failed," failed."]}),s.jsx(R,{size:"sm",disabled:y!==null,onClick:()=>void k("retry"),children:y==="retry"?"Retrying…":"Retry all failed"}),s.jsx(R,{size:"sm",variant:"danger",disabled:y!==null,onClick:()=>void k("cancel"),children:y==="cancel"?"Cancelling…":"Cancel all failed"})]}):null]}),s.jsx(re,{message:p??a}),s.jsx(rt,{flush:!0,children:!u||b.length===0?s.jsx(ie,{children:"No jobs match."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"State"}),s.jsx("th",{className:"num",children:"Attempts"}),s.jsx("th",{children:"Last error"}),s.jsx("th",{children:"Updated"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:b.map(N=>s.jsxs("tr",{children:[s.jsxs("td",{className:"clickable",onClick:()=>l(N),children:[N.kind,s.jsx("div",{className:"sub mono",children:al(N.id)})]}),s.jsxs("td",{children:[s.jsx(hu,{state:N.state}),N.suspendedReason?s.jsx("div",{className:"sub",children:As(N.suspendedReason,40)}):null]}),s.jsxs("td",{className:"num",children:[N.attempts,"/",N.maxAttempts]}),s.jsx("td",{className:N.lastError?"critical":"muted",children:N.lastError?As(N.lastError,80):"—"}),s.jsxs("td",{className:"nowrap",children:[Re(N.updatedAt,e),s.jsx("div",{className:"sub",children:Se(N.updatedAt)})]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[["failed","cancelled","suspended"].includes(N.state)?s.jsx(R,{size:"sm",onClick:()=>S(A.retryJob(N.id)),children:"Retry"}):null,["pending","leased","suspended","failed"].includes(N.state)?s.jsx(R,{size:"sm",variant:"danger",onClick:()=>S(A.cancelJob(N.id)),children:"Cancel"}):null]})})]},N.id))})]})}),m?s.jsxs(J,{children:[s.jsxs("span",{className:"muted",children:[b.length," of ",v," shown."]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{disabled:h.busy,onClick:()=>void j(),children:h.busy?"Loading…":"Load older"})]}):null,o?s.jsxs(qt,{title:o.kind,onClose:()=>l(null),children:[s.jsx("p",{className:"muted mono",children:o.id}),s.jsx(Y,{title:"Payload",children:s.jsx(at,{children:on(o.payload)})}),s.jsx(Y,{title:"Result",children:s.jsx(at,{children:on(o.result)})}),o.conversationId?s.jsx("p",{children:s.jsx("a",{href:`#/conversations/${o.conversationId}`,children:"open the transcript"})}):null]}):null]})}const kD=[{id:"conversations",label:"Conversations"},{id:"jobs",label:"Jobs"},{id:"approvals",label:"Approvals"},{id:"alerts",label:"Alerts"},{id:"events",label:"Events"}];function SD({hash:e,timezone:t,navigate:n,agents:r}){var u,p;const i=/^#\/activity\/conversations\/(.+)$/.exec(e),o=f=>{var h;return((h=r.find(x=>x.id===f))==null?void 0:h.name)??f};if(i){let f=i[1];try{f=decodeURIComponent(f)}catch{}return s.jsx(ED,{id:f,timezone:t,navigate:n,nameOf:o})}const l=((u=/^#\/activity\/([a-z]+)/.exec(e))==null?void 0:u[1])??"conversations",a=(p=/[?&]state=([a-z]+)/.exec(e))==null?void 0:p[1],c=f=>h=>{h.preventDefault(),n(f)};return s.jsxs("div",{className:"ui-page",children:[s.jsx(ym,{title:"Activity",lede:"Everything your agents ran, newest first.",actions:s.jsx(RD,{})}),s.jsx(PD,{}),s.jsx(mu,{children:kD.map(f=>{const h=f.id==="conversations"?Ze:`${Ze}/${f.id}`;return s.jsx(gu,{href:h,active:l===f.id,onClick:c(h),children:f.label},f.id)})}),l==="conversations"?s.jsx(ND,{timezone:t,navigate:n,nameOf:o,agents:r}):null,l==="jobs"?s.jsx(bD,{timezone:t,embedded:!0,initialState:a},a??""):null,l==="approvals"?s.jsx(CD,{timezone:t,nameOf:o}):null,l==="alerts"?s.jsx(vD,{timezone:t,embedded:!0}):null,l==="events"?s.jsx(yD,{timezone:t,embedded:!0}):null]})}function ND({timezone:e,navigate:t,nameOf:n,agents:r}){const{data:i,error:o}=se(()=>A.conversations(),[],3e4);return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:o}),s.jsx(rt,{flush:!0,children:i?i.conversations.length===0?s.jsx(yt,{icon:"activity",title:"Nothing has run yet",children:"Conversations and runs show up here as your agents work."}):s.jsx(Ft,{children:i.conversations.map(l=>s.jsx(Kt,{href:zi(l.id),onClick:()=>t(zi(l.id)),lead:s.jsx(Zt,{agents:r,id:l.agentId,size:"sm"}),title:l.opening?As(l.opening,100):"Untitled conversation",sub:`${n(l.agentId)}, ${l.messageCount} message${l.messageCount===1?"":"s"}, ${l.runs} run${l.runs===1?"":"s"}, ${Lt(l.usage.input)} in / ${Lt(l.usage.output)} out`,side:s.jsx("span",{title:Re(l.lastMessageAt??l.createdAt,e),children:Se(l.lastMessageAt??l.createdAt)})},l.id))}):s.jsx(ie,{children:"Loading…"})})]})}function CD({timezone:e,nameOf:t}){const{data:n,error:r}=se(()=>A.approvals(),[],1e4),i=[...(n==null?void 0:n.pending)??[],...(n==null?void 0:n.recent)??[]];return s.jsxs(s.Fragment,{children:[s.jsx(re,{message:r}),s.jsx(rt,{flush:!0,children:n?i.length===0?s.jsx(yt,{icon:"bell",title:"No approvals yet",children:"When an agent asks before acting, the request and your answer are kept here."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Tool"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Asked by"}),s.jsx("th",{children:"Decided"}),s.jsx("th",{children:"Created"})]})}),s.jsx("tbody",{children:i.map(o=>s.jsxs("tr",{children:[s.jsxs("td",{children:[o.tool,s.jsx("div",{className:"sub mono",children:al(o.id)})]}),s.jsx("td",{children:s.jsx(hu,{state:o.state})}),s.jsx("td",{children:t(o.agentId)}),s.jsx("td",{className:"nowrap",children:o.decidedAt?s.jsxs(s.Fragment,{children:[Re(o.decidedAt,e),s.jsxs("div",{className:"sub",children:["via ",o.decidedVia??"—"]})]}):s.jsx("span",{className:"muted",children:"—"})}),s.jsxs("td",{className:"nowrap",children:[Re(o.createdAt,e),s.jsx("div",{className:"sub",children:Se(o.createdAt)})]})]},o.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function ED({id:e,timezone:t,navigate:n,nameOf:r}){const[i,o]=d.useState(null),[l,a]=d.useState(null);d.useEffect(()=>{let u=!1;return A.conversation(e).then(p=>{u||o(p)}).catch(p=>{u||a(p instanceof Error?p.message:String(p))}),()=>{u=!0}},[e]);const c=u=>p=>{p.preventDefault(),n(u)};return s.jsxs("div",{className:"ui-page",children:[s.jsx("p",{className:"page-crumbs",children:s.jsx("a",{href:Ze,onClick:c(Ze),children:"Activity"})}),s.jsxs("header",{className:"ui-page-head",children:[s.jsxs("div",{className:"ui-page-head-row",children:[s.jsxs("h2",{className:"ui-page-title",children:[s.jsx(R,{size:"sm",onClick:()=>n(Ze),children:"← Back"}),s.jsx("span",{children:"Transcript"})]}),i?s.jsx("div",{className:"ui-page-actions",children:s.jsx(Un,{size:"sm",href:ze(i.agentId,e),onClick:c(ze(i.agentId,e)),children:"Open in chat"})}):null]}),s.jsx("p",{className:"ui-page-lede mono",children:e})]}),s.jsx(re,{message:l}),i?s.jsxs(s.Fragment,{children:[s.jsxs(pu,{children:[s.jsx(Zn,{label:"Agent",value:r(i.agentId),size:"sm"}),s.jsx(Zn,{label:"Runs",value:i.runs.length}),s.jsx(Zn,{label:"Tokens",value:`${Lt(i.usage.input)} / ${Lt(i.usage.output)}`,note:"input / output"}),s.jsx(Zn,{label:"Started",value:Re(i.createdAt,t),size:"sm"})]}),i.runs.length>0?s.jsx(rt,{title:"Runs",flush:!0,children:s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Started"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{className:"num",children:"Turns"}),s.jsx("th",{children:"Stopped"}),s.jsx("th",{className:"num",children:"Tokens"})]})}),s.jsx("tbody",{children:i.runs.map((u,p)=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Re(u.startedAt,t)," ",u.resumed?s.jsx(pe,{children:"resumed"}):null]}),s.jsx("td",{className:"nowrap",children:Re(u.finishedAt,t)}),s.jsx("td",{className:"num",children:u.turns??"—"}),s.jsxs("td",{children:[u.stopped??"—",u.actionId?s.jsxs("div",{className:"sub mono",children:["action ",al(u.actionId)]}):null]}),s.jsxs("td",{className:"num muted nowrap",children:[Lt(u.usage.input)," / ",Lt(u.usage.output)]})]},p))})]})}):null,s.jsx(Y,{title:"Messages",children:s.jsx(G,{children:i.messages.map(u=>s.jsxs("article",{className:"transcript-msg",children:[s.jsxs("header",{className:"transcript-who",children:[u.speaker===qv?"approved action, result":u.role,", ",Re(u.createdAt,t)]}),s.jsxs("div",{className:"transcript-body",children:[u.blocks.length===0?s.jsx("span",{className:"muted",children:"(empty)"}):null,u.speaker===qv?u.blocks.map((p,f)=>s.jsx(AD,{block:p},f)):u.blocks.map((p,f)=>s.jsx(TD,{block:p},f))]})]},u.id))})})]}):s.jsx(ie,{children:"Loading…"})]})}const qv="approval:resume";function AD({block:e}){return s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:"← approved action"}),s.jsx(at,{children:e.type==="text"?e.text??"":on(e)})]})}function TD({block:e}){return e.type==="text"?s.jsx("div",{className:"transcript-text",children:s.jsx(cr,{text:e.text??""})}):e.type==="thinking"?s.jsxs("details",{className:"transcript-thinking",children:[s.jsx("summary",{children:"Thoughts"}),s.jsx("div",{className:"transcript-thinking-text",children:s.jsx(cr,{text:e.text??""})})]}):e.type==="tool_use"?s.jsxs("div",{className:"transcript-tool",children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["→ ",e.name]}),s.jsx(at,{children:on(e.input)})]}):e.type==="tool_result"?s.jsxs("div",{className:"transcript-tool","data-tone":e.isError?"critical":void 0,children:[s.jsxs("div",{className:"transcript-tool-name mono",children:["← ",e.isError?"error":"result"]}),s.jsx(at,{children:e.content??""})]}):s.jsxs("div",{className:"transcript-tool",children:[s.jsx("div",{className:"transcript-tool-name mono",children:e.type}),s.jsx(at,{children:on(e.ref)})]})}function RD(){const{data:e,reload:t}=se(()=>A.overview(),[],1e4),[n,r]=d.useState(!1);if(!e)return null;const i=()=>{r(!0),A.setPaused(!e.paused).then(t,t).finally(()=>r(!1))};return s.jsx(R,{size:"sm",variant:e.paused?"accent":void 0,disabled:n,onClick:i,children:e.paused?"Resume all":"Pause all"})}function PD(){const{data:e}=se(()=>A.overview(),[],1e4);if(!e)return null;const t=r=>e.jobs[r]??0,n=t("leased");return s.jsxs(pu,{children:[s.jsx(Zn,{label:"Jobs done",value:Lt(t("succeeded"))}),s.jsx(Zn,{label:"Failed",value:Lt(t("failed")),...t("failed")>0?{tone:"critical"}:{}}),s.jsx(Zn,{label:"Queued",value:Lt(t("pending")),note:`${n} running`}),s.jsx(Zn,{label:"Approvals",value:Lt(e.approvals.pending),note:"waiting for you"})]})}const ID=["replay-all","coalesce","latest-only","skip-after-deadline"];function Xk({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=se(()=>A.missions(),[],3e4),l=((r==null?void 0:r.missions)??[]).filter(p=>!n||p.agentId===n),[a,c]=d.useState(null),u=async p=>{c(null);try{await p,o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.jsxs(an,{embedded:t,title:"Missions",lede:"Standing schedules. A disabled mission materializes nothing.",children:[s.jsx(re,{message:i??a}),!r||l.length===0?s.jsxs(yt,{icon:"calendar",title:"No missions yet",children:["Run ",s.jsx("code",{children:"buddi missions add-defaults"})," for the standard set."]}):s.jsx(G,{children:l.map(p=>s.jsx(MD,{mission:p,timezone:e,onRun:u},p.id))})]})}function MD({mission:e,timezone:t,onRun:n}){const[r,i]=d.useState(!1);return s.jsxs(Fr,{tone:e.enabled?"good":"muted",title:s.jsxs(s.Fragment,{children:[e.name," ",s.jsx("span",{className:"mono muted",children:e.id})]}),meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:e.agentId}),e.alwaysDeliver?s.jsx(pe,{children:"always delivers"}):null,e.enabled?null:s.jsx(pe,{tone:"warning",children:"disabled"})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",onClick:()=>n(A.setMissionEnabled(e.id,!e.enabled)),children:e.enabled?"Disable":"Enable"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(o=>!o),"aria-expanded":r,children:r?"Less":"More"})]}),children:[s.jsxs("p",{className:"ui-card-meta",children:[e.schedule?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mono",children:e.schedule.cron})," ",e.schedule.timezone," · rev"," ",e.schedule.revision," · next"," ",e.nextRun?`${Re(e.nextRun,t)} (${Se(e.nextRun)})`:"—"]}):"no schedule — enqueued by hand or by a sentinel",s.jsx("br",{}),"Last notification:"," ",e.lastNotification?`${e.lastNotification.kind==="mission.delivered"?"delivered":"silent"} ${Se(e.lastNotification.at)}${e.lastNotification.reason?` — ${e.lastNotification.reason}`:""}`:"none"]}),r?s.jsxs("div",{className:"ui-card-foot",children:[e.schedule?s.jsxs(J,{children:[s.jsx(ee,{inline:!0,label:"Misfire policy",children:s.jsx("select",{value:e.schedule.misfirePolicy,onChange:o=>n(A.setMisfirePolicy(e.id,o.target.value)),children:ID.map(o=>s.jsx("option",{value:o,children:o},o))})}),s.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,s.jsx(Y,{title:"Prompt",children:s.jsx(at,{children:e.prompt})}),s.jsx(Y,{title:"Recent occurrences",children:s.jsx(rt,{flush:!0,children:e.occurrences.length===0?s.jsx(ie,{children:"Never run."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Scheduled"}),s.jsx("th",{children:"State"}),s.jsx("th",{children:"Finished"}),s.jsx("th",{children:"Detail"})]})}),s.jsx("tbody",{children:e.occurrences.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"nowrap",children:Re(o.scheduledAt,t)}),s.jsx("td",{children:s.jsx(hu,{state:o.state})}),s.jsx("td",{className:"nowrap",children:Re(o.finishedAt,t)}),s.jsxs("td",{className:o.error?"critical":"muted",children:[o.error?As(o.error,120):null,o.runConversationId?s.jsx("a",{href:`#/conversations/${o.runConversationId}`,children:"transcript"}):null]})]},o.id))})]})})})]}):null]})}function $D(e,t){const n=`${e} offer${e===1?"":"s"}`,r=t?` from ${t}`:"";return`Dismiss ${n}${r}? They stop appearing everywhere. Nothing runs, and you can still see them under "Dismissed and lapsed" for a week.`}function Zk({ids:e,agentName:t,onDone:n}){const r=e.length,[i,o]=d.useState(!1),[l,a]=d.useState(!1);return r<=0?null:i?s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:$D(r,t)}),s.jsx(R,{size:"sm",variant:"danger",disabled:l,onClick:()=>{a(!0),A.dismissOffers(e).then(()=>{o(!1),n()}).finally(()=>a(!1))},children:`Dismiss ${r}`}),s.jsx(R,{size:"sm",variant:"ghost",disabled:l,onClick:()=>o(!1),children:"Keep them"})]}):s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>o(!0),children:"Dismiss all"})}function eS({embedded:e,agentId:t,agentName:n}){const{data:r,error:i,reload:o}=se(()=>A.offers(),[],2e4),l=v=>!t||v.agentId===t,a=((r==null?void 0:r.offers)??[]).filter(l),c=((r==null?void 0:r.closed)??[]).filter(l),[u,p]=d.useState(null),[f,h]=d.useState(null),[x,j]=d.useState(null),w=async(v,m)=>{p(null),h(v);try{const y=await A.takeOffer(v);j(y.jobId?`On it — ${m}. Started as job ${y.jobId}.`:`Taken — ${m}. No worker is running here, so nothing has started yet.`),o()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}},b=async(v,m)=>{p(null),h(v);try{await A.dismissOffer(v),j(`Dismissed — ${m}. It will not come back.`),o()}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(null)}};return s.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:[s.jsx(re,{message:i??u}),x?s.jsx(V,{tone:"good",role:"status",children:x}):null,a.length>0?s.jsxs(J,{children:[s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(Zk,{ids:a.map(v=>v.id),agentName:n,onDone:()=>{j(null),o()}})]}):null,!r||a.length===0?s.jsx(yt,{icon:"bulb",title:"Nothing on offer",children:"When an agent works out something you might want done, it waits here."}):s.jsx(G,{children:a.map(v=>s.jsx(Fr,{tone:"accent",title:v.label,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{mono:!0,children:v.agentId}),s.jsxs("span",{className:"muted",children:["expires ",Se(v.expiresAt)]})]}),actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{size:"sm",variant:"ghost",disabled:f===v.id,onClick:()=>void b(v.id,v.label),children:"Not now"}),s.jsx(R,{variant:"accent",size:"sm",disabled:f===v.id,onClick:()=>void w(v.id,v.label),children:"Take"})]}),children:s.jsx("p",{className:"ui-card-meta",children:v.prompt})},v.id))}),c.length>0?s.jsxs(wt,{summary:`Dismissed and lapsed (${c.length})`,boxed:!0,children:[s.jsx(rt,{flush:!0,children:s.jsx(Ft,{children:c.map(v=>s.jsx(Kt,{title:v.label,sub:`${v.agentId} — ${IT(v)}`,side:Se(v.dismissedAt??v.lapsedAt??v.createdAt)},v.id))})}),s.jsx("p",{className:"muted",children:"These stop being shown a week after they closed."})]}):null]})}const _D=["fact","observation","todo"];function tS({embedded:e,agents:t,timezone:n,agentId:r}){const{data:i,error:o,reload:l}=se(()=>A.memory(r),[r],3e4),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(null),x=g=>{var k;return g==="shared"?"Everyone":((k=t.find(S=>S.id===g))==null?void 0:k.name)??g},j=async g=>{h(null);try{await g,l()}catch(k){h(k instanceof ce?k.message:String(k))}},w={nameOf:x,timezone:n,onChangePreference:g=>c({key:g.key,scope:g.scope}),onForgetPreference:g=>void j(A.forgetPreference({key:g.key,scope:g.scope})),onEditNote:g=>p(g),onForgetNote:g=>void j(A.forgetNote(g.id))},b=r?x(r):"",v=r&&i?{preferences:i.preferences.filter(g=>g.scope===r),notes:i.notes.filter(g=>g.scope===r)}:null,m=r&&i?{preferences:i.preferences.filter(g=>g.scope==="shared"),notes:i.notes.filter(g=>g.scope==="shared")}:null,y=s.jsx(R,{variant:"accent",size:"sm",onClick:()=>c({key:"",scope:r??"shared"}),children:"Add a preference"});return s.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:[s.jsx(re,{message:o??f}),v&&m?s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:`what you told ${b} alone`,actions:y,panel:!0,flush:!0,children:s.jsx(Od,{preferences:v.preferences,empty:`Nothing stated to ${b} alone yet.`,...w})}),s.jsx(Y,{title:"Notes",aside:`what ${b} wrote down for itself`,panel:!0,flush:!0,children:s.jsx(Dd,{notes:v.notes,empty:`${b} has kept no private notes yet.`,...w})}),s.jsx(wt,{summary:`Shared with every agent, which ${b} also reads · ${m.preferences.length} preferences, ${m.notes.length} notes`,children:s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Shared preferences",panel:!0,flush:!0,children:s.jsx(Od,{preferences:m.preferences,empty:"No shared preferences.",...w})}),s.jsx(Y,{title:"Shared notes",panel:!0,flush:!0,children:s.jsx(Dd,{notes:m.notes,empty:"No shared notes.",...w})})]})})]}):s.jsxs(G,{gap:"lg",children:[s.jsx(Y,{title:"Preferences",aside:"what you said you want, one current value each",actions:y,panel:!0,flush:!0,children:i?s.jsx(Od,{preferences:i.preferences,empty:'Nothing stated yet. Tell any agent "from now on…" or add one here.',...w}):s.jsx(ie,{children:"Loading…"})}),s.jsx(Y,{title:"Notes",aside:"what an agent wrote down, with who wrote it",panel:!0,flush:!0,children:i?s.jsx(Dd,{notes:i.notes,empty:"No notes yet. An agent writes one when you state something durable about your life.",...w}):s.jsx(ie,{children:"Loading…"})})]}),a?s.jsx(OD,{agents:t,existing:(i==null?void 0:i.preferences)??[],initial:a,onClose:()=>c(null),onSave:async g=>{await j((async()=>{await A.setPreference(g),a.key===g.key&&a.scope!==g.scope&&await A.forgetPreference({key:a.key,scope:a.scope})})()),c(null)}}):null,u?s.jsx(DD,{note:u,agents:t,onClose:()=>p(null),onSave:g=>j(A.updateNote(u.id,g)).then(()=>p(null))}):null]})}function Od({preferences:e,empty:t,nameOf:n,onChangePreference:r,onForgetPreference:i}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Preference"}),s.jsx("th",{children:"Value"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{className:"num",children:"Since"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(o=>s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:o.key}),s.jsx("td",{children:o.value}),s.jsx("td",{children:s.jsx(nS,{scope:o.scope,name:n(o.scope)})}),s.jsxs("td",{className:"num muted",title:o.updatedAt??"",children:[o.updatedAt?Se(o.updatedAt,Date.now()):"",o.revision>1?` · rev ${o.revision}`:""]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(R,{size:"sm",onClick:()=>r(o),title:"Store a new value for this key",children:"Change"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>i(o),children:"Forget"})]})})]},`${o.scope}:${o.key}`))})]})}function Dd({notes:e,empty:t,nameOf:n,timezone:r,onEditNote:i,onForgetNote:o}){return e.length===0?s.jsx(ie,{children:t}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Note"}),s.jsx("th",{children:"Kind"}),s.jsx("th",{children:"Who sees it"}),s.jsx("th",{children:"Written by"}),s.jsx("th",{className:"num",children:"When"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{className:"memory-note",children:l.content}),s.jsx("td",{children:s.jsx(pe,{tone:l.kind==="todo"?"warning":l.kind==="fact"?"good":void 0,children:l.kind})}),s.jsx("td",{children:s.jsx(nS,{scope:l.scope,name:n(l.scope)})}),s.jsx("td",{className:"muted",children:l.createdByAgent?n(l.createdByAgent):""}),s.jsxs("td",{className:"num muted",title:l.createdAt??"",children:[l.createdAt?Se(l.createdAt,Date.now()):"",l.expiresAt?s.jsxs("span",{className:"memory-expires",children:[" · until ",new Date(l.expiresAt).toLocaleDateString(void 0,{timeZone:r})]}):null]}),s.jsx("td",{className:"num",children:s.jsxs(J,{align:"end",children:[s.jsx(R,{size:"sm",onClick:()=>i(l),children:"Edit"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>o(l),children:"Forget"})]})})]},l.id))})]})}function nS({scope:e,name:t}){return s.jsx(pe,{tone:e==="shared"?"accent":void 0,title:e==="shared"?"Every agent reads this":`Only ${t} reads this`,children:t})}function sS({value:e,agents:t,onChange:n}){return s.jsxs("select",{value:e,onChange:r=>n(r.target.value),children:[s.jsx("option",{value:"shared",children:"Everyone"}),t.map(r=>s.jsxs("option",{value:r.id,children:["Only ",r.name]},r.id))]})}function OD({agents:e,existing:t,initial:n,onClose:r,onSave:i}){const o=t.find(m=>m.key===n.key&&m.scope===n.scope),[l,a]=d.useState(n.key),[c,u]=d.useState((o==null?void 0:o.value)??""),[p,f]=d.useState(n.scope),[h,x]=d.useState(!1),j=l.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),w=t.find(m=>m.key===j&&m.scope===p),b=!o||j!==o.key||c.trim()!==o.value||p!==o.scope,v=j!==""&&c.trim()!==""&&b;return s.jsx(qt,{title:"A preference",onClose:r,children:s.jsxs(G,{children:[s.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.'}),s.jsx(ee,{label:"Key",hint:j&&j!==l?`Stored as ${j}`:"Short and stable, like reporting_currency or tone.",children:s.jsx("input",{value:l,autoFocus:n.key==="",onChange:m=>a(m.target.value),placeholder:"reporting_currency"})}),s.jsx(ee,{label:"Value",children:s.jsx("textarea",{rows:3,value:c,maxLength:2e3,autoFocus:n.key!=="",onChange:m=>u(m.target.value),placeholder:"EUR"})}),s.jsx(ee,{label:"Who should know",hint:"Shared reaches every agent. Private stays with one.",children:s.jsx(sS,{value:p,agents:e,onChange:f})}),w&&w!==o?s.jsxs(V,{tone:"warning",children:['This replaces the value already stored for this key here, "',w.value,'" (revision ',w.revision,")."]}):null,o&&p!==o.scope?s.jsxs(V,{children:["It moves: the copy for ",o.scope==="shared"?"everyone":"that agent"," is retired and this one takes over."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:r,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!v||h,onClick:()=>{x(!0),i({key:j,value:c.trim(),scope:p}).finally(()=>x(!1))},children:o?"Save change":"Save"})]})]})})}function DD({note:e,agents:t,onClose:n,onSave:r}){var x;const[i,o]=d.useState(e.content),[l,a]=d.useState(e.scope),[c,u]=d.useState(e.kind),[p,f]=d.useState(!1),h=i.trim()!==e.content||l!==e.scope||c!==e.kind;return s.jsx(qt,{title:"A note",onClose:n,children:s.jsxs(G,{children:[s.jsx(ee,{label:"What it says",hint:"One sentence that makes sense months from now, on its own.",children:s.jsx("textarea",{rows:4,value:i,maxLength:2e3,autoFocus:!0,onChange:j=>o(j.target.value)})}),s.jsxs(Ts,{children:[s.jsx(ee,{label:"Kind",children:s.jsx("select",{value:c,onChange:j=>u(j.target.value),children:_D.map(j=>s.jsx("option",{value:j,children:j},j))})}),s.jsx(ee,{label:"Who sees it",children:s.jsx(sS,{value:l,agents:t,onChange:a})})]}),e.createdByAgent?s.jsxs("p",{className:"muted",children:["Written by ",((x=t.find(j=>j.id===e.createdByAgent))==null?void 0:x.name)??e.createdByAgent,e.createdAt?`, ${Se(e.createdAt,Date.now())}`:"",". Editing keeps that record."]}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{variant:"accent",disabled:!h||i.trim()===""||p,onClick:()=>{f(!0);const j={};i.trim()!==e.content&&(j.content=i.trim()),l!==e.scope&&(j.scope=l),c!==e.kind&&(j.kind=c),r(j).finally(()=>f(!1))},children:"Save"})]})]})})}function LD({agentId:e,agentName:t}){const{data:n,error:r,reload:i}=se(()=>A.agentSkills(e),[e],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),f=async j=>{l(null),c(null),p(j.name);try{const w=await A.removeSkill(e,j.name);c(`Removed ${w.name}. Its versions are kept, and ${t} will not propose it again for 90 days.`),i()}catch(w){l(w instanceof ce?w.message:String(w))}finally{p(null)}};if(!n)return r?s.jsx(re,{message:r}):s.jsx(ie,{children:"Loading…"});const h=n.skills.filter(j=>j.learned!==null),x=n.skills.filter(j=>j.learned===null);return s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:r??o}),a?s.jsx(V,{tone:"good",role:"status",children:a}):null,s.jsx(Y,{title:"Learned",aside:s.jsxs("span",{className:"muted",children:["what ",t," proposed and you kept"]}),children:h.length===0?s.jsx(yt,{icon:"bulb",title:"Nothing learned yet",children:n.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.`}):s.jsx(rt,{flush:!0,children:s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"Version"}),s.jsx("th",{children:"Came from"}),s.jsx("th",{className:"num",children:"Kept"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:h.map(j=>s.jsx(zD,{skill:j,busy:u===j.name,onRemove:()=>void f(j)},j.name))})]})})}),s.jsx(Y,{title:"From files and plugins",aside:s.jsx("span",{className:"muted",children:"read-only here"}),children:x.length===0?s.jsx(ie,{children:"No other skills."}):s.jsx(rt,{flush:!0,children:s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Skill"}),s.jsx("th",{children:"What it is for"}),s.jsx("th",{children:"Whose"})]})}),s.jsx("tbody",{children:x.map(j=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(wt,{summary:s.jsx("span",{className:"mono",children:j.name}),children:[s.jsx(at,{children:j.body}),s.jsx("p",{className:"muted mono skill-file",children:j.file})]})}),s.jsx("td",{children:j.description}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[s.jsx(pe,{children:j.scope==="shared"?"shared":`${t} only`}),s.jsx("span",{className:"muted",children:FD(j)})]})})]},`${j.scope}:${j.name}`))})]})})})]})}function FD(e){return e.provenance==="imported"?e.source?`from ${e.source}`:"imported":e.provenance==="agent"?"written by an agent":"yours"}function zD({skill:e,busy:t,onRemove:n}){const r=e.learned;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsxs(wt,{summary:s.jsxs("span",{children:[r.title," ",s.jsx("span",{className:"muted mono",children:e.name})]}),children:[s.jsxs("p",{className:"muted",children:["When: ",e.description]}),s.jsx(at,{children:e.body}),s.jsxs("p",{className:"muted mono skill-file",children:[e.file,r.versions.length>1?` · earlier versions in ${r.versionsDir}`:""]})]})}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[s.jsxs("span",{children:["v",r.version,r.edited?" · your correction":""]}),r.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null]})}),s.jsx("td",{children:s.jsxs(G,{gap:"sm",children:[r.conversation?s.jsx("a",{href:zi(r.conversation),children:r.turn?`conversation, turn ${r.turn}`:"conversation"}):s.jsx("span",{className:"muted",children:"no conversation"}),s.jsx("a",{href:st("proposals"),children:"the proposal"}),r.sources.length>0?s.jsx("ul",{className:"proposal-sources",children:r.sources.map(i=>s.jsx("li",{className:"mono",children:i},i))}):null]})}),s.jsx("td",{className:"num muted",title:r.keptAt,children:r.keptAt?Se(r.keptAt,Date.now()):""}),s.jsx("td",{className:"num",children:s.jsx(J,{align:"end",children:s.jsx(R,{size:"sm",variant:"ghost",disabled:t,onClick:n,children:"Remove"})})})]})}function rS({timezone:e,embedded:t,agentId:n}){const{data:r,error:i,reload:o}=se(()=>A.reminders(),[],3e4),l=((r==null?void 0:r.reminders)??[]).filter(p=>!n||p.agentId===n),[a,c]=d.useState(null),u=async p=>{c(null);try{await A.cancelReminder(p),o()}catch(f){c(f instanceof Error?f.message:String(f))}};return s.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:[s.jsx(re,{message:i??a}),s.jsx(rt,{flush:!0,children:r?l.length===0?s.jsx(yt,{icon:"bell",title:"No reminders",children:"Ask any agent to remind you of something, and it shows up here."}):s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Due"}),s.jsx("th",{children:"Agent"}),s.jsx("th",{children:"Note"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:l.map(p=>s.jsxs("tr",{children:[s.jsxs("td",{className:"nowrap",children:[Re(p.dueAt,e),s.jsx("div",{className:"sub",children:Se(p.dueAt)})]}),s.jsx("td",{className:"mono",children:p.agentId}),s.jsxs("td",{children:[p.text,p.context?s.jsx(wt,{summary:"context",children:s.jsx(at,{children:on(p.context)})}):null]}),s.jsxs("td",{children:[s.jsx(hu,{state:p.state}),p.cancelReason?s.jsx("div",{className:"sub",children:p.cancelReason}):null]}),s.jsx("td",{children:p.state==="pending"?s.jsx(R,{size:"sm",variant:"danger",onClick:()=>u(p.id),children:"Cancel"}):null})]},p.id))})]}):s.jsx(ie,{children:"Loading…"})})]})}function Dm({accountId:e,label:t,value:n,onChange:r,disabled:i=!1}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(""),[f,h]=d.useState(!1),x=d.useRef(0),j=async m=>{if(!e)return;const y=++x.current;c(!0),p("");try{const g=await A.accountModels(e,m);y===x.current&&l(g)}catch(g){y===x.current&&p(g instanceof Error?g.message:"Could not load models. Custom entry is still available.")}finally{y===x.current&&c(!1)}};if(d.useEffect(()=>(l(null),h(!1),p(""),j(!1),()=>{x.current++}),[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:t,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:m=>r(m.target.value)})}),s.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 w=(o==null?void 0:o.models)??[],b=!!n&&!w.some(m=>m.id===n),v=[o&&!w.length?"This account returned no models. You can enter a custom model.":null,o!=null&&o.truncated?"Showing the first part of this provider’s list. Custom model entry is available.":null,o?"Uses saved account settings. Listed models may not support every agent tool. Your selection is unchanged until you save.":null].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:t,children:s.jsxs("select",{value:f?"__buddi_custom__":n,disabled:i,onChange:m=>{m.target.value==="__buddi_custom__"?h(!0):(h(!1),r(m.target.value))},children:[s.jsx("option",{value:"",disabled:!0,children:"Choose a model"}),b&&s.jsxs("option",{value:n,children:[n," (current",o?", not listed":"",")"]}),w.map(m=>s.jsxs("option",{value:m.id,children:[m.name===m.id?m.id:`${m.name} — ${m.id}`,m.isDefault?" (provider default)":""]},m.id)),s.jsx("option",{value:"__buddi_custom__",children:"Custom model…"})]})}),s.jsx(R,{disabled:i||a,onClick:()=>void j(!0),children:a?"Loading models…":"Refresh models"}),f&&s.jsx(ee,{label:`Custom ${t.toLowerCase()}`,children:s.jsx("input",{required:!0,maxLength:150,value:n,disabled:i,onChange:m=>r(m.target.value)})}),u&&s.jsx("p",{role:"alert",className:"ui-toolbar-note critical",children:u}),v.length>0&&s.jsx("p",{className:"ui-toolbar-note",children:v.join(" ")})]})}function UD(e,t){const n=new Set(t),r=[],i=new Set;for(const o of e){for(const a of o.tools)i.add(a.name);const l=o.tools.filter(a=>n.has(a.name));l.length!==0&&(o.glob&&l.length===o.tools.length?r.push(o.glob):r.push(...l.map(a=>a.name)))}return r.push(...t.filter(o=>!i.has(o))),r}function BD(e,t){return[...e].sort().join(",")===[...t].sort().join(",")}const WD="This agent will not remember anything between conversations.";function HD({view:e,chosen:t,onChange:n,disabled:r}){var k;const[i,o]=d.useState(""),[l,a]=d.useState(null),[c,u]=d.useState(()=>new Set),p=S=>u(N=>{const C=new Set(N);return C.has(S)?C.delete(S):C.add(S),C}),f=S=>{o(S),u(new Set)},h=d.useId(),x=new Set(t),j=new Set(e.groups.flatMap(S=>S.tools.filter(N=>N.core).map(N=>N.name))),w=(S,N)=>{const C=N.filter(P=>x.has(P));if(C.length!==0){if(C.some(P=>j.has(P))){a({plugin:S,names:C});return}n(t.filter(P=>!C.includes(P)))}},b=S=>{n([...t,...S.filter(N=>!x.has(N))])},v=i.trim().toLowerCase(),m=(S,N)=>v===""||S.toLowerCase().includes(v)||N.toLowerCase().includes(v),y=e.groups.map(S=>({group:S,tools:S.tools.filter(N=>m(N.name,N.description))})).filter(S=>S.tools.length>0),g=(((k=e.suggested)==null?void 0:k.tools)??[]).filter(S=>!x.has(S.name));return s.jsxs("div",{className:"tool-picker",children:[e.suggested&&g.length>0?s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":`${h}-suggested`,children:[s.jsx("div",{className:"tool-picker-head",children:s.jsx("span",{id:`${h}-suggested`,className:"tool-picker-plugin",children:e.suggested.label})}),s.jsx("ul",{className:"ui-list tool-picker-list","aria-label":e.suggested.label,children:g.map(S=>s.jsxs("li",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsx("span",{className:"ui-list-title mono",children:S.name}),s.jsx("span",{className:"ui-list-sub",children:S.description})]}),s.jsx(R,{size:"sm",disabled:r,"aria-label":`Add ${S.name}`,onClick:()=>b([S.name]),children:"Add"})]},S.name))})]}):null,s.jsxs("label",{className:"tool-picker-search",children:[s.jsx("span",{className:"ui-field-label",children:"Find a tool"}),s.jsx("input",{type:"search",value:i,placeholder:"Name or what it does",onChange:S=>f(S.target.value)})]}),y.length===0?s.jsxs(ie,{children:["No installed tool matches “",i.trim(),"”."]}):null,y.map(({group:S,tools:N})=>{const C=S.tools.filter(T=>T.grantable).map(T=>T.name),P=S.tools.filter(T=>x.has(T.name)).length,E=!!S.glob&&P===S.tools.length,O=`${h}-${S.plugin}`,L=`${h}-${S.plugin}-list`,D=v!==""?!c.has(S.plugin):c.has(S.plugin);return s.jsxs("div",{className:"tool-picker-group",role:"group","aria-labelledby":O,"data-open":D?"true":void 0,children:[s.jsxs("div",{className:"tool-picker-head",children:[s.jsxs("button",{type:"button",className:"tool-picker-toggle","aria-expanded":D,"aria-controls":L,onClick:()=>p(S.plugin),children:[s.jsx(VD,{}),s.jsx("span",{id:O,className:"tool-picker-plugin",children:S.plugin}),s.jsx("span",{className:"muted",children:E?`all ${S.tools.length}`:`${P} of ${S.tools.length} granted`})]}),s.jsx(R,{size:"sm",variant:"ghost","aria-label":`All ${S.plugin} tools`,disabled:r||C.every(T=>x.has(T)),onClick:()=>b(C),children:"all"}),s.jsx(R,{size:"sm",variant:"ghost","aria-label":`No ${S.plugin} tools`,disabled:r||!C.some(T=>x.has(T)),onClick:()=>w(S.plugin,C),children:"none"})]}),(l==null?void 0:l.plugin)===S.plugin?s.jsx(V,{tone:"warning",role:"alert",children:s.jsxs("div",{className:"tool-picker-confirm",children:[s.jsx("span",{children:WD}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{size:"sm",onClick:()=>a(null),children:"Keep"}),s.jsx(R,{size:"sm",variant:"danger",onClick:()=>{n(t.filter(T=>!l.names.includes(T))),a(null)},children:"Remove"})]})}):null,s.jsx("ul",{id:L,className:"ui-list tool-picker-list",hidden:!D,children:N.map(T=>{const z=`${h}-${T.name}`;return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:z,checked:x.has(T.name),disabled:r||!T.grantable,onChange:q=>q.target.checked?b([T.name]):w(S.plugin,[T.name])}),s.jsxs("label",{htmlFor:z,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[s.jsx("span",{className:"mono",children:T.name}),T.core?s.jsx(pe,{tone:"accent",children:"core"}):null,T.gated?s.jsx(pe,{tone:"warning",children:"asks you"}):null]}),s.jsx("span",{className:"ui-list-sub",children:T.grantable?T.description:`${T.description} Granted only by editing the file by hand.`})]})]},T.name)})})]},S.plugin)})]})}function VD(){return s.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:s.jsx("path",{d:"M2.8 4.2 5.5 6.9l2.7-2.7"})})}const KD="buddi",GD=["core","coding","finance","garage","mail","maker","playground","research"],vu=e=>`./mascot/${e}.png`,YD=["🙂","📚","🧭","🦊","🛟","🌿","🛠️","🎧"],qD="Introduce yourself by name, say one thing you can do today, and ask one question.",B={opening:["Hi. I'm buddi. 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 in a minute."],later:"Set up later",name:{ask:"First, what should we call you?",placeholder:"Your first name",submit:"That's me"},clock:{ask:(e,t)=>`Nice to meet you, ${e}. I'll set your clock to ${t}, which is what this browser says. Right?`,yes:"Yes",another:"Pick another",label:"Your clock",answer:e=>e},brain:{ask:"Your assistant needs a brain: an AI it thinks with. Which of these do you already have?",cards:{claude:{title:"Claude",line:"I pay for Claude",know:"Uses your Claude plan's monthly Agent SDK credits; after them, an API key."},key:{title:"A key from Anthropic or OpenAI",line:"I have an API key"},ollama:{title:"Ollama",line:"Free, on this computer"},service:{title:"Ollama Cloud, or another service",line:"I have an address and a key"}},claude:{start:"Sign in with Claude",open:"Open the Claude sign-in page",paste:"Paste what Claude gave you",finish:"Done",waiting:"Sign in, then paste the code Claude shows you."},key:{field:"Your key",placeholder:"Paste it here",submit:"Use this key",which:"Not right?",anthropic:"Anthropic",openai:"OpenAI",refused:"That key was refused. Check it and paste it again."},ollama:{found:"Found it, running now",missing:"Install Ollama, then come back",connect:"Use Ollama",download:"Get Ollama",looking:"Looking for it on this computer…"},model:{ask:"Which one should it think with?",label:"The model",submit:"Use this one"},checking:{key:"Checking that key…",service:"Asking the service…",ollama:"Asking Ollama…",claude:"Checking with Claude…"},back:"Back",service:{address:"Address",addressPlaceholder:"The address they gave you",key:"Key",submit:"Connect it"},works:e=>`That works. Your assistant will think with ${e}.`,refused:e=>e,answer:e=>e},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.",skip:"Skip for now",skipped:"Skipped. Settings → Computer & browser can install it whenever you like.",missing:"No browser for your assistant yet. Settings → Computer & browser can install one.",failed:e=>`That did not work: ${e}`,retry:"Try again"},assistant:{ask:"Last thing: your assistant. I've picked a name and a face; change either, or keep them.",name:"Name",face:"A face",mascot:e=>e==="core"?"Buddi Blob":`Buddi Blob, ${e}`,purpose:"What should it help you with?",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(`
|
|
107
|
-
`),submit:"Introduce us"},restore:{offer:"I have a backup from another buddi",file:"The backup file",passphrase:"Its passphrase",passphraseHint:"Only if it was locked with one.",submit:"Restore",cancel:"Never mind",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."},tagline:"Setting up, on this Mac.",taglineElsewhere:"Setting up, on this computer.",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 above.",again:"Pick another brain"},offers:{phone:"Talk to me from your phone",notNow:"Not now"},done:{said:"You're all set. This conversation carries on in your dashboard.",leaving:"Opening buddi…",ready:"Ready when you are.",open:"Open buddi"},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 there."},change:"change"},QD=(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 iS(e){const t=await fetch(vu(e));if(!t.ok)throw new Error(`The picture could not be read (${t.status}).`);const n=await t.blob();return new File([n],`buddi-blob-${e}.png`,{type:"image/png"})}function oS({face:e,onPick:t,label:n=B.assistant.face,kept:r,disabled:i,disableEmoji:o,children:l}){return s.jsxs("div",{className:"meet-faces",role:"group","aria-label":n,children:[s.jsxs("div",{className:"meet-face-row",children:[r?s.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:s.jsx("img",{src:r,alt:""})}):null,GD.map(a=>{const c={kind:"mascot",role:a},u=QD(e,c);return s.jsx("button",{type:"button",className:"meet-face","data-kind":"image","data-chosen":u?"true":void 0,"aria-pressed":u,"aria-label":B.assistant.mascot(a),disabled:i,onClick:()=>t(c),children:s.jsx("img",{src:vu(a),alt:""})},a)})]}),s.jsx("div",{className:"meet-face-row",children:YD.map(a=>{const c=(e==null?void 0:e.kind)==="emoji"&&e.value===a;return s.jsx("button",{type:"button",className:"meet-face","data-chosen":c?"true":void 0,"aria-pressed":c,disabled:i||o,onClick:()=>t({kind:"emoji",value:a}),children:a},a)})}),l]})}const JD=["mirror","en","fr"],lS=[{id:"identity",label:"Identity"},{id:"brain",label:"Brain"},{id:"access",label:"Access"}],Qv=e=>{var t;return((t=lS.find(n=>n.id===e))==null?void 0:t.id)??"identity"};function XD({agentId:e,section:t,navigate:n}){var w,b,v;const{data:r,error:i,reload:o}=se(()=>A.agents(),[]),[l,a]=d.useState(null),[c,u]=d.useState(null),[p,f]=d.useState(Qv(t));d.useEffect(()=>f(Qv(t)),[t]);const h=m=>{f(m),n==null||n(ft(e,"setup",m))},x=async m=>{a(null),u(null);try{const y=await m;u(y.changed.length===0?`No file change needed. ${y.note}.`:`Changed ${y.changed.join(", ")}. ${y.note}.`),o()}catch(y){a(y instanceof Error?y.message:String(y))}},j=r==null?void 0:r.agents.find(m=>m.id===e);return s.jsxs(G,{gap:"lg",children:[s.jsx(mu,{level:"secondary",label:"Setup",children:lS.map(m=>s.jsx(gu,{href:ft(e,"setup",m.id),active:p===m.id,onClick:y=>{y.preventDefault(),h(m.id)},children:m.label},m.id))}),s.jsx(re,{message:i??l}),c?s.jsx(V,{tone:"good",role:"status",children:c}):null,r?j?s.jsx(ZD,{agent:j,all:r.agents,engine:r.engines.find(m=>m.id===j.id),providers:r.providers,accounts:r.providerAccounts,shown:p,onShow:h,onRun:x,onSaved:o},`${j.id}:${(w=r.engines.find(m=>m.id===j.id))==null?void 0:w.model}:${(v=(b=r.providerAccounts)==null?void 0:b.bindings.find(m=>m.agentId===j.id))==null?void 0:v.accountId}`):s.jsx(ie,{children:"This agent is not installed as a file."}):s.jsx(ie,{children:"Loading…"})]})}function ZD({agent:e,all:t,engine:n,providers:r,accounts:i,shown:o,onShow:l,onRun:a,onSaved:c}){const u=(n==null?void 0:n.provider)??e.provider.kind,p=r.find(g=>g.kind===u),f=(n==null?void 0:n.model)??e.model,[h,x]=d.useState(String((n==null?void 0:n.maxTurns)??e.maxTurns)),j=g=>{a(A.setAgentEngine(e.id,g))},w=g=>{const k=r.find(S=>S.kind===g);j({provider:g,model:(k==null?void 0:k.defaultModel)??f})},b=(p==null?void 0:p.models.map(g=>g.id))??[],v=b.includes(f)?b:[f,...b],m=n?n.available:!0,y=(n==null?void 0:n.unavailableReason)??"no credential";return s.jsxs(s.Fragment,{children:[s.jsx("div",{hidden:o!=="identity",children:s.jsxs(G,{gap:"lg",children:[m?null:s.jsxs(V,{tone:"warning",children:["This agent cannot run right now."," ",s.jsx("a",{href:ft(e.id,"setup","brain"),onClick:g=>{g.preventDefault(),l("brain")},children:"See Brain."})]}),s.jsx(eL,{agent:e,onSaved:c})]})}),s.jsx("div",{hidden:o!=="brain",children:s.jsxs(G,{gap:"lg",children:[m?null:s.jsxs(V,{tone:"warning",children:["This agent cannot run right now: ",y,"."]}),s.jsx(Y,{panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{title:"Runs on",children:[i?s.jsx(rL,{agentId:e.id,accounts:i,onRun:a}):s.jsxs(Ts,{children:[s.jsx(ee,{label:"Provider",children:s.jsx("select",{value:u,onChange:g=>w(g.target.value),children:r.map(g=>s.jsxs("option",{value:g.kind,children:[g.kind,g.usable?"":" (no credential)"]},g.kind))})}),s.jsxs(ee,{label:"Model",children:[s.jsx("input",{list:`models-${e.id}`,defaultValue:f,onBlur:g=>{g.target.value.trim()!==""&&g.target.value.trim()!==f&&j({model:g.target.value.trim()})}}),s.jsx("datalist",{id:`models-${e.id}`,children:v.map(g=>s.jsx("option",{value:g},g))})]})]}),i?null:s.jsxs("p",{className:"ui-card-meta",children:[(n==null?void 0:n.credentialKind)??e.provider.credentialKind," from"," ",s.jsx("span",{className:"mono",children:(n==null?void 0:n.credentialEnv)??e.provider.credentialEnv}),p&&!p.usable?` · default model ${p.defaultModel} (${p.defaultFrom})`:""]}),n!=null&&n.restartRequired?s.jsx("p",{className:"warning",children:"This file has changed since the service loaded it. Run `buddi service restart`."}):null]}),s.jsx(Y,{title:"Behaviour",aside:"saved as you change them",children:s.jsxs(Ts,{children:[s.jsx(ee,{label:"Max turns",hint:"Per run. The agent stops when it runs out.",children:s.jsx("input",{type:"number",min:1,value:h,onChange:g=>x(g.target.value),onBlur:()=>{const g=Number(h);Number.isInteger(g)&&g>=1&&g!==((n==null?void 0:n.maxTurns)??e.maxTurns)&&j({maxTurns:g})}})}),s.jsx(ee,{label:"Language",hint:"Mirror answers in whatever language you write.",children:s.jsx("select",{value:(n==null?void 0:n.language)??e.language,onChange:g=>j({language:g.target.value}),children:JD.map(g=>s.jsx("option",{value:g,children:g},g))})}),s.jsx(ee,{label:"Thinking",hint:"Reasoning before the answer. Off is faster; the model's default is usually on for local models.",children:s.jsxs("select",{"aria-label":"Thinking",value:(n==null?void 0:n.thinking)??"default",onChange:g=>j({thinking:g.target.value==="default"?null:g.target.value}),children:[s.jsx("option",{value:"default",children:"Model default"}),s.jsx("option",{value:"on",children:"On"}),s.jsx("option",{value:"off",children:"Off"})]})})]})})]})})]})}),s.jsx("div",{hidden:o!=="access",children:s.jsxs(G,{gap:"lg",children:[s.jsx(tL,{agent:e,all:t,onSaved:c}),s.jsx(lL,{agent:e,all:t,onSaved:c}),s.jsx(wt,{summary:"Built-in context",boxed:!0,children:s.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."})})]})})]})}function aS({dirty:e,busy:t,failure:n,label:r,onSave:i}){return s.jsxs(s.Fragment,{children:[n?s.jsx("span",{className:"critical save-error",role:"alert",children:n}):s.jsx("span",{className:e?"warning":"muted",children:e?"Not saved yet.":"Saved. Applies to new runs."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:!e||t,onClick:i,children:r})]})}const cS=s.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 eL({agent:e,onSaved:t}){var D;const[n,r]=d.useState(e.name),[i,o]=d.useState(e.handle),[l,a]=d.useState(e.description),[c,u]=d.useState(e.avatar??""),[p,f]=d.useState(!1),h=se(()=>A.agentFile(e.id),[e.id]),[x,j]=d.useState(null),w=((D=h.data)==null?void 0:D.persona.trim())??"",b=x??w,v=h.data!==void 0&&x!==null&&x.trim()!==w,[m,y]=d.useState(!1),[g,k]=d.useState(null),[S,N]=d.useState(null),C=n.trim()!==e.name||i.trim().replace(/^@/,"")!==e.handle||l.trim()!==e.description||c.trim()!==(e.avatar??"")||v,P=c.trim()!==""&&(c.trim()!==(e.avatar??"")||!e.picture),E=Th(P?{...e,avatar:c.trim()}:e),O={...E?{avatar:E}:{},...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...!P&&e.picture?{picture:e.picture}:{}},L=async()=>{y(!0),k(null),N(null);try{const T=await A.updateAgentFile(e.id,{name:n.trim(),handle:i.trim().replace(/^@/,""),description:l.trim(),...c.trim()===""?{}:{avatar:c.trim()},...v&&b.trim()!==""?{persona:b.trim()}:{}});e.picture&&c.trim()!==""&&c.trim()!==(e.avatar??"")&&(await A.removeAgentPicture(e.id),window.dispatchEvent(new Event(ll))),j(null),h.reload(),N(T.message),t()}catch(T){k(T instanceof Error?T.message:String(T))}finally{y(!1)}};return s.jsx(Y,{title:"Who it is",aside:s.jsx("span",{className:"mono",children:e.id}),panel:!0,foot:e.isExample?void 0:s.jsx(aS,{dirty:C,busy:m,failure:g,label:"Save who it is",onSave:()=>void L()}),children:s.jsxs(G,{children:[e.isExample?cS:null,S?s.jsx(V,{tone:"good",role:"status",children:S}):null,s.jsxs(Ts,{children:[s.jsx(ee,{label:"Name",hint:"What it is called, everywhere.",children:s.jsx("input",{value:n,disabled:m||e.isExample,onChange:T=>r(T.target.value)})}),s.jsx(ee,{label:"Handle",hint:"What you type to reach it. One handle, one agent.",children:s.jsx("input",{value:i,disabled:m||e.isExample,onChange:T=>o(T.target.value)})})]}),s.jsxs(J,{children:[s.jsx(as,{id:e.id,name:n.trim()||e.name,size:"xl",face:O}),s.jsx(R,{"aria-expanded":p,onClick:()=>f(T=>!T),children:p?"Hide faces":"Change face"})]}),p?s.jsx(nL,{agent:e,avatar:c,onEmoji:u,onChanged:t,disabled:m}):null,s.jsx(ee,{label:"Description",hint:"One or two sentences. Its colleagues read this.",children:s.jsx("textarea",{rows:2,value:l,disabled:m||e.isExample,onChange:T=>a(T.target.value)})}),s.jsx(ee,{label:"Persona",hint:s.jsxs(s.Fragment,{children:["Who it is and how it works, in its own file. It reads this before every conversation; ",s.jsx("code",{children:"{{today}}"})," is filled in with the date at run time."]}),wide:!0,children:h.error?s.jsx(re,{message:h.error}):h.data?s.jsx("textarea",{className:"setup-persona",value:b,rows:Math.max(6,b.split(`
|
|
108
|
-
`).length+1),disabled:m||e.isExample,onChange:T=>j(T.target.value)}):s.jsx(ie,{children:"Reading its file…"})})]})})}function tL({agent:e,all:t,onSaved:n}){var P;const r=se(()=>A.agentTools(e.id),[e.id]),[i,o]=d.useState(null),[l,a]=d.useState(()=>new Set((e.roles??[]).filter(cv))),[c,u]=d.useState((e.roles??[]).filter(E=>!cv(E)).join(", ")),[p,f]=d.useState(!1),[h,x]=d.useState(null),[j,w]=d.useState(null),b=(E,O)=>E.split(O).map(L=>L.trim()).filter(L=>L!==""),v=((P=r.data)==null?void 0:P.granted)??e.tools,m=i??v,y=r.data!==void 0&&!BD(m,v),g=uv(l,b(c,/[\n,]/)),k=E=>a(O=>{const L=new Set(O);return L.has(E)?L.delete(E):L.add(E),L}),N=y||!((E,O)=>E.join(",")===O.join(","))(g,uv(new Set(e.roles??[]),e.roles??[])),C=async()=>{f(!0),x(null),w(null);try{const E=await A.updateAgentFile(e.id,{...y&&r.data?{tools:UD(r.data.groups,m)}:{},roles:g});w(E.message),o(null),r.reload(),n()}catch(E){x(E instanceof Error?E.message:String(E))}finally{f(!1)}};return s.jsx(Y,{title:"Roles and tools",panel:!0,foot:e.isExample?void 0:s.jsx(aS,{dirty:N,busy:p,failure:h,label:"Save roles and tools",onSave:()=>void C()}),children:s.jsxs(G,{children:[e.isExample?cS:null,j?s.jsx(V,{tone:"good",role:"status",children:j}):null,s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",id:`roles-${e.id}`,children:"Roles"}),s.jsx("div",{className:"role-chips",role:"group","aria-labelledby":`roles-${e.id}`,children:mm.map(E=>{const O=A2(t,E.id),L=O&&O.id!==e.id?O:void 0;return s.jsxs("button",{type:"button",className:"role-chip","aria-pressed":l.has(E.id),"data-on":l.has(E.id)?"true":void 0,disabled:p||e.isExample,onClick:()=>k(E.id),children:[s.jsx("span",{className:"role-chip-label",children:E.label}),s.jsx("span",{className:"role-chip-meaning",children:E.meaning}),L?s.jsxs("span",{className:"role-chip-holder",children:["Held by ",L.name,". If both claim it, the one listed first keeps it."]}):null]},E.id)})}),s.jsx("span",{className:"ui-field-hint",children:"Where buddi sends things when you do not say who. Tools are granted below."})]}),s.jsx(ee,{label:"Other roles",hint:"Only a plugin that asks for a role by name reads these. Comma separated.",children:s.jsx("input",{value:c,disabled:p||e.isExample,onChange:E=>u(E.target.value)})}),s.jsxs("div",{className:"ui-field",children:[s.jsxs("span",{className:"ui-field-label",children:["Tools · ",v.length," granted"]}),r.error?s.jsx(re,{message:r.error}):r.data?s.jsx(HD,{view:r.data,chosen:m,onChange:o,disabled:p||e.isExample}):s.jsx(ie,{children:"Loading the installed tools…"})]})]})})}function Th(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 nL({agent:e,avatar:t,onEmoji:n,onChanged:r,disabled:i}){const[o,l]=d.useState(null),[a,c]=d.useState(!1),[u,p]=d.useState(null),f=t.trim()!==""&&(t.trim()!==(e.avatar??"")||!e.picture),h=o??(f?{kind:"emoji",value:t.trim()}:e.picture?{kind:"kept",url:e.picture}:null),x=async j=>{if(p(null),j.kind==="emoji"){n(j.value);return}if(j.kind==="kept"){n(e.avatar??"");return}l(j),c(!0);try{await A.uploadAgentPicture(e.id,await iS(j.role)),n(e.avatar??""),r(),window.dispatchEvent(new Event(ll))}catch(w){p(w instanceof Error?w.message:String(w))}finally{l(null),c(!1)}};return s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Face"}),s.jsx(oS,{face:h,label:"Face",kept:e.picture,disabled:i||a,disableEmoji:e.isExample,onPick:j=>void x(j),children:s.jsx(sL,{agent:e,onChanged:r})}),u?s.jsx("span",{className:"critical save-error",role:"alert",children:u}):null]})}function sL({agent:e,onChanged:t}){const[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),[h,x]=d.useState(0);d.useEffect(()=>{if(!n)return o(null);const N=URL.createObjectURL(n);return o(N),()=>URL.revokeObjectURL(N)},[n]);const j=N=>{r(null),x(C=>C+1),f(N),t(),window.dispatchEvent(new Event(ll))},w=async N=>{a(!0),u(null),f(null);try{j(await N())}catch(C){u(C instanceof Error?C.message:String(C))}finally{a(!1)}},b=()=>w(async()=>(await A.uploadAgentPicture(e.id,n)).note??null),v=()=>w(async()=>(await A.removeAgentPicture(e.id),null)),m={avatar:Th(e),...e.accent?{accent:e.accent}:{},roles:e.roles,tools:e.tools,...i??e.picture?{picture:i??e.picture}:{}},[y,g]=d.useState(!1),k=d.useRef(null),S=N=>{u(null),f(null),r(N??null)};return s.jsxs("div",{className:"setup-upload","data-dragging":y?"true":void 0,onDragOver:N=>{N.preventDefault(),l||g(!0)},onDragLeave:()=>g(!1),onDrop:N=>{var C;N.preventDefault(),g(!1),l||S((C=N.dataTransfer.files)==null?void 0:C[0])},children:[s.jsxs(J,{children:[s.jsx(as,{id:e.id,name:e.name,size:"xl",face:m}),s.jsx("input",{ref:k,className:"sr-only",type:"file","aria-label":"Choose a picture",accept:"image/png,image/gif,image/svg+xml,.png,.gif,.svg",disabled:l,onChange:N=>{var C;return S((C=N.target.files)==null?void 0:C[0])}},h),s.jsx(R,{disabled:l,onClick:()=>{var N;return(N=k.current)==null?void 0:N.click()},children:"Upload a picture"}),s.jsx("span",{className:"setup-upload-name",children:n?n.name:"or drop one here"}),s.jsx("span",{className:"ui-toolbar-spacer"}),e.picture&&!n?s.jsx(R,{variant:"ghost",disabled:l,onClick:()=>void v(),children:"Remove picture"}):null,s.jsx(R,{variant:"accent",disabled:!n||l,onClick:()=>void b(),children:"Save picture"})]}),c?s.jsx("span",{className:"critical save-error",role:"alert",children:c}):s.jsx("span",{className:"ui-field-hint",children:p??"Your own picture: a PNG, GIF or SVG up to 1 MB, kept as a square PNG; a GIF keeps its first frame."})]})}function rL({agentId:e,accounts:t,onRun:n}){const r=t.bindings.find(x=>x.agentId===e),[i,o]=d.useState((r==null?void 0:r.accountId)??""),[l,a]=d.useState((r==null?void 0:r.model)??""),[c,u]=d.useState(!1),p=t.accounts.find(x=>x.id===i),f=i!==((r==null?void 0:r.accountId)??"")||l!==((r==null?void 0:r.model)??""),h=t.accounts.find(x=>x.id===(r==null?void 0:r.accountId));return s.jsxs("div",{className:"ui-stack",children:[s.jsxs(J,{valign:"end",children:[s.jsx(ee,{label:"Account",children:s.jsxs("select",{value:i,disabled:c,onChange:x=>{var j;o(x.target.value),a(((j=t.accounts.find(w=>w.id===x.target.value))==null?void 0:j.defaultModel)??"")},children:[s.jsx("option",{value:"",children:"Choose an account"}),t.accounts.map(x=>s.jsxs("option",{value:x.id,disabled:!x.enabled,children:[x.label,x.enabled?x.configured?"":" (needs credential)":" (disabled)"]},x.id))]})}),s.jsx(Dm,{accountId:p!=null&&p.configured?i:void 0,label:"Model",value:l,onChange:a,disabled:c},`${i}:${p==null?void 0:p.revision}`)]}),s.jsxs(J,{children:[f&&i&&l.trim()?s.jsxs("span",{className:"warning",children:["Not saved yet. New runs still use ",h?`${h.label}, ${(r==null?void 0:r.model)??""}`:"nothing","."]}):s.jsx("span",{className:"muted",children:h?`Running on ${h.label} with ${(r==null?void 0:r.model)??"no model"}.`:"No account chosen yet: this agent cannot run until you save one."}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:c||!i||!l.trim()||!f,onClick:()=>{u(!0),n(A.assignProviderAccount(e,i,l).finally(()=>u(!1)))},children:"Save account selection"})]})]})}const iL=["platform.create_agent","platform.update_agent","platform.write_skill","platform.delete_agent","platform.accept_plugin_agent","platform.accept_plugin_skill"],oL=e=>e.tools.some(t=>iL.includes(t));function lL({agent:e,all:t,onSaved:n}){const[r,i]=d.useState(e.delegates),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(!1),[f,h]=d.useState(e.delegates),x=t.filter(m=>m.id!==e.id),j=[...r].sort().join(",")!==[...f].sort().join(","),w=t.filter(m=>m.id!==e.id&&m.delegates.includes(e.id)),b=m=>i(y=>y.includes(m)?y.filter(g=>g!==m):[...y,m]),v=async()=>{l(!0),c(null),p(!1);try{const m=await A.setDelegates(e.id,r);h(m.delegates),i(m.delegates),p(!0),n()}catch(m){c(m instanceof Error?m.message:String(m))}finally{l(!1)}};return s.jsx(Y,{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:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:j?"warning":"muted",children:j?"Not saved yet.":u?"Saved. Applies to the next run.":r.length===0?"Asks nobody.":`May ask ${r.length} agent${r.length===1?"":"s"}.`}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsx(R,{variant:"accent",disabled:!j||o,onClick:()=>void v(),children:"Save who it can ask"})]}),children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{title:"Can ask",children:[e.isExample?s.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,s.jsx(re,{message:a}),x.length===0?s.jsx(ie,{children:"Nobody else is installed."}):s.jsx("ul",{className:"ui-list delegate-list","aria-label":"Agents this one may ask",children:x.map(m=>{const y=oL(m);return s.jsxs("li",{className:"ui-list-row",children:[s.jsx("input",{type:"checkbox",id:`can-ask-${e.id}-${m.id}`,checked:r.includes(m.id),disabled:y||e.isExample||o,onChange:()=>b(m.id)}),s.jsxs("label",{htmlFor:`can-ask-${e.id}-${m.id}`,className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[m.name," ",s.jsxs("span",{className:"mono muted",children:["@",m.handle]})]}),s.jsx("span",{className:"ui-list-sub",children:y?"Makes and changes agents. Never reachable by delegation.":m.description})]})]},m.id)})})]}),s.jsx(Y,{title:"Asked by",children:w.length===0?s.jsxs("p",{className:"ui-card-meta",children:["No other agent may hand work to ",e.name,"."]}):s.jsx(_I,{children:w.map(m=>s.jsx(pe,{children:m.name},m.id))})})]})})}const aL=[{id:"team",label:"Team"},{id:"missions",label:"Missions"},{id:"offers",label:"Offers"},{id:"reminders",label:"Reminders"}],cL=[{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 uL({hash:e,timezone:t,navigate:n,agents:r,attention:i,defaultAgentId:o}){var b,v,m,y,g;const l=g2(e),a=((b=/[?&]tab=([a-z]+)/.exec(e))==null?void 0:b[1])??"team",c=k=>S=>{S.preventDefault(),n(k)},u=se(()=>A.agents(),[]),p=Am(),f=se(()=>A.offers(),[],2e4),h=Nk(),x=(((v=f.data)==null?void 0:v.offers.length)??0)+h.offers.length,j=((y=(m=u.data)==null?void 0:m.default)==null?void 0:y.defaultAgentId)??o??null,w=r.find(k=>k.roles.includes(gm));return s.jsxs("div",{className:"ui-page",children:[s.jsx(ym,{title:"Agents",lede:`Your team. Each one is a file on ${p} — what it can reach is listed on its page.`,actions:w?s.jsx(Un,{variant:"accent",href:ze(w.id),onClick:c(ze(w.id)),children:"Add an agent"}):null}),s.jsx(mu,{children:aL.map(k=>s.jsx(gu,{href:k.id==="team"?et:`${et}?tab=${k.id}`,active:a===k.id,count:k.id==="offers"?x:void 0,onClick:c(k.id==="team"?et:`${et}?tab=${k.id}`),children:k.label},k.id))}),a==="missions"?s.jsx(Xk,{timezone:t,embedded:!0}):null,a==="offers"?s.jsx(Ck,{offers:h.offers,reload:h.reload}):null,a==="offers"?s.jsx(eS,{embedded:!0}):null,a==="reminders"?s.jsx(rS,{timezone:t,embedded:!0}):null,a==="team"?s.jsx(dL,{data:u.data,error:u.error,reload:u.reload}):null,a==="team"?r.length===0?s.jsx(yt,{icon:"agents",title:"No agents yet",children:"Each agent is a file in the installation's agents folder."}):s.jsx("div",{className:"agents-grid",children:I0(r,j).map(k=>{const S=fu(i.get(k.id));return s.jsxs("div",{className:"ui-card agent-card","data-interactive":"true",...kl(bl(k)),"data-unavailable":k.available?void 0:"true",children:[s.jsx("div",{className:"agent-card-top"}),s.jsx("div",{className:"agent-card-face",children:s.jsx(as,{id:k.id,name:k.name,size:"xl",unavailable:!k.available,face:k})}),s.jsxs("div",{children:[s.jsxs("div",{className:"ui-card-title",children:[s.jsx("a",{className:"agent-card-link",href:ft(k.id,"conversations"),onClick:c(ft(k.id,"conversations")),children:k.name}),s.jsxs("span",{className:"agent-card-handle mono faint",children:["@",k.handle]})]}),s.jsx("p",{className:"ui-card-meta agent-card-desc",children:k.description})]}),s.jsxs("div",{className:"ui-row",children:[k.id===j?s.jsx(Ua,{children:"front desk"}):null,S?s.jsx(pe,{tone:"critical",dot:!0,children:"waiting for you"}):k.available?s.jsx(pe,{tone:"good",dot:!0,children:"ready"}):s.jsx(pe,{tone:"warning",children:As(k.unavailableReason??"cannot run",60)}),s.jsx(pe,{mono:!0,children:k.model}),s.jsx(Un,{className:"agent-card-talk",size:"sm",href:ze(k.id),onClick:c(ze(k.id)),"aria-label":`Talk to ${k.name}`,children:"Talk"})]})]},k.id)})}):null,l?s.jsx(qt,{title:((g=r.find(k=>k.id===l.agentId))==null?void 0:g.name)??l.agentId,size:"wide",onClose:()=>n(et),children:s.jsx(fL,{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:n,attention:i})}):null]})}function dL({data:e,error:t,reload:n}){const r=e==null?void 0:e.default,[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null);if(t)return s.jsx(re,{message:t});if(!r||r.choices.length===0)return null;const h=r.defaultAgentId,x=i??h??"",j=x!==""&&x!==h,w=r.problem,b=m=>m.map(y=>{var g;return((g=r.choices.find(k=>k.id===y))==null?void 0:g.name)??y}).join(" and "),v=async()=>{a(!0),u(null),f(null);try{const m=await A.setDefaultAgent(x);f(m.note),o(null),n()}catch(m){u(m instanceof Error?m.message:String(m))}finally{a(!1)}};return s.jsx(rt,{children:s.jsxs("div",{className:"ui-stack",children:[s.jsx(re,{message:c}),(w==null?void 0:w.code)==="multiple-defaults"?s.jsx(V,{tone:"warning",role:"status",children:`Two agents claim default in their files: ${b(w.agents)}. The one chosen here wins.`}):(w==null?void 0:w.code)==="no-default-agent"?s.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,p?s.jsx(V,{tone:"good",role:"status",children:p}):null,s.jsxs(J,{children:[s.jsxs("div",{className:"default-agent-text",children:[s.jsx("h3",{className:"default-agent-title",children:"Default agent"}),s.jsx("span",{className:"ui-field-hint",children:"Where a chat that names nobody lands."})]}),s.jsx("span",{className:"ui-toolbar-spacer"}),s.jsxs("select",{"aria-label":"Default agent",value:x,disabled:l,onChange:m=>o(m.target.value),children:[x===""?s.jsx("option",{value:"",children:"Choose an agent"}):null,r.choices.map(m=>s.jsxs("option",{value:m.id,disabled:!m.available,children:[m.name," @",m.handle,m.available?"":" (cannot run)"]},m.id))]}),s.jsx(R,{variant:"accent",disabled:l||!j,onClick:()=>void v(),children:"Save"})]})]})})}function fL({agentId:e,agent:t,agents:n,tab:r,section:i,timezone:o,navigate:l,attention:a}){const c=f=>h=>{h.preventDefault(),l(f)},u=fu(a.get(e)),p=(t==null?void 0:t.name)??e;return s.jsxs("div",{className:"ui-stack","data-gap":"lg",children:[s.jsxs("header",{className:"agent-head",children:[s.jsx(as,{id:e,name:p,size:"xl",unavailable:t?!t.available:!1,face:t}),s.jsxs("div",{className:"agent-head-text",children:[s.jsx("p",{className:"ui-page-lede",children:(t==null?void 0:t.description)??"This agent is not in the roster right now."}),s.jsxs("div",{className:"ui-row",children:[t?s.jsxs("span",{className:"muted mono",children:["@",t.handle]}):null,t?s.jsx("span",{className:"muted",children:t.model}):null,u?s.jsx(pe,{tone:"critical",children:u}):t&&!t.available?s.jsx(pe,{tone:"warning",children:t.unavailableReason??"cannot run"}):null]})]}),s.jsx("div",{className:"ui-page-actions",children:s.jsxs(Un,{variant:"accent",href:ze(e),onClick:c(ze(e)),children:["Talk to ",p]})})]}),t&&!t.available?s.jsxs(V,{tone:"warning",role:"status",children:[_0(t)," ",s.jsx("a",{href:st(ih(t).section),children:ih(t).label})]}):null,s.jsx(mu,{children:cL.map(f=>s.jsx(gu,{href:ft(e,f.id),active:r===f.id,onClick:c(ft(e,f.id)),children:f.label},f.id))}),r==="conversations"?s.jsx(hL,{agentId:e,navigate:l}):null,r==="missions"?s.jsx(Xk,{timezone:o,embedded:!0,agentId:e}):null,r==="offers"?s.jsx(eS,{embedded:!0,agentId:e,agentName:p}):null,r==="reminders"?s.jsx(rS,{timezone:o,embedded:!0,agentId:e}):null,r==="memory"?s.jsx(tS,{embedded:!0,agents:n,timezone:o,agentId:e}):null,r==="skills"?s.jsx(LD,{agentId:e,agentName:p}):null,r==="setup"?s.jsx(XD,{agentId:e,section:i,navigate:l}):null]})}function hL({agentId:e,navigate:t}){const{data:n,error:r}=se(()=>Fe.conversations(e,50),[e]);if(r)return s.jsx(ie,{children:r});const i=(n==null?void 0:n.conversations)??[];return s.jsx(rt,{flush:!0,children:n?i.length===0?s.jsx(yt,{icon:"chat",title:"No conversations yet",children:"Say hello, and the conversation shows up here."}):s.jsx(Ft,{children:i.map(o=>s.jsx(Kt,{href:ze(e,o.id),onClick:()=>t(ze(e,o.id)),title:As(o.preview||o.opening||"Untitled conversation",90),sub:`${o.messageCount} message${o.messageCount===1?"":"s"}`,side:Se(o.lastMessageAt??o.startedAt??o.createdAt??null)},o.id))}):s.jsx(ie,{children:"Loading…"})})}function pL({timezone:e,navigate:t,agents:n,defaultAgentId:r,attention:i,update:o}){var X,Z,ue,je,Ce,Pe,Ve,he,ge,ye,kt,ct,_e;const l=se(()=>A.overview(),[],15e3),a=se(()=>A.approvals(),[],1e4),c=se(()=>A.missions(),[],6e4),u=se(()=>A.reminders(),[],6e4),p=se(()=>A.conversations(),[],3e4),f=se(()=>A.offers(),[],3e4),h=se(()=>A.proposals(),[],6e4),x=se(()=>A.agentOffers(),[],6e4),j=se(()=>A.owner(),[]),w=se(()=>A.notifications(20),[],3e4),b=d.useMemo(()=>I0(n,r??null),[n,r]),{busy:v,note:m,failure:y,decide:g}=Tm(()=>{a.reload(),l.reload()}),k=l.data,S=$=>{var de;return((de=n.find(xe=>xe.id===$))==null?void 0:de.name)??$},N=$=>de=>{de.preventDefault(),t($)},C=((X=a.data)==null?void 0:X.pending)??[],P=((Z=k==null?void 0:k.jobs)==null?void 0:Z.failed)??0,E=((ue=k==null?void 0:k.sentinels)==null?void 0:ue.openUrgent)??0,O=((je=h.data)==null?void 0:je.open.length)??0,L=(((Ce=x.data)==null?void 0:Ce.offers)??[]).filter($=>!C.some(de=>Sk(de,$.plugin,$.agent))),D=xL(((Pe=w.data)==null?void 0:Pe.notifications)??[],C),[T,z]=d.useState(new Set),q=C.length+(P>0?1:0)+(E>0?1:0)+(k!=null&&k.paused?1:0)+(O>0?1:0)+L.length+D.length,K=d.useMemo(()=>{var $,de;return wL((($=c.data)==null?void 0:$.missions)??[],((de=u.data)==null?void 0:de.reminders)??[])},[c.data,u.data]),M=(((Ve=p.data)==null?void 0:Ve.conversations)??[]).slice(0,5),W=((he=f.data)==null?void 0:he.offers)??[],_=W.slice(0,vL),U=W.length-_.length;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"home-band",children:s.jsxs("header",{className:"home-hero",children:[s.jsxs("div",{className:"home-hero-text",children:[s.jsx("p",{className:"home-date",children:SL(k==null?void 0:k.now,e)}),s.jsx("h1",{className:"home-greeting",children:kL(k==null?void 0:k.now,e,((ge=j.data)==null?void 0:ge.preferredName)||((ye=j.data)==null?void 0:ye.displayName))}),s.jsx("p",{className:"home-lede",children:CL(q,C.length,P,E,(k==null?void 0:k.paused)??!1,O,L.length,D.length)})]}),s.jsx(F0,{size:"lg"})]})}),s.jsxs("div",{className:"home",children:[o&&o.updateAvailable&&!o.checkout&&o.latest?s.jsxs(V,{tone:"accent",children:["A newer buddi is ready: ",s.jsx("span",{className:"mono",children:o.latest}),"."," ",s.jsx("a",{href:st("system"),onClick:N(st("system")),children:"Upgrade from Settings → Version."})]}):null,s.jsx(re,{message:l.error??a.error??y}),m?s.jsx(V,{tone:"good",role:"status",children:m}):null,q>0?s.jsx(Y,{title:"Needs you",children:s.jsxs(G,{children:[k!=null&&k.paused?s.jsxs(V,{tone:"warning",title:"The installation is paused.",children:["Nothing is being claimed until you resume it."," ",s.jsx(R,{size:"sm",onClick:()=>{A.setPaused(!1).then(()=>l.reload())},children:"Resume"})]}):null,C.map($=>s.jsx(Rm,{action:$,timezone:e,busy:v===$.id,onDecide:g,agentName:S($.agentId)},$.id)),D.length>0?s.jsx(rt,{flush:!0,children:s.jsx(Ft,{children:D.filter($=>!T.has($.id)).map($=>s.jsx(Kt,{href:$.link??void 0,onClick:()=>{z(de=>new Set(de).add($.id)),A.notificationSeen($.id).catch(()=>{}),$.link&&t($.link)},lead:$.agentId?s.jsx(Zt,{agents:n,id:$.agentId,size:"sm"}):void 0,title:$.title,sub:$.agentId?S($.agentId):$.pluginId??gL[$.kind],side:$.state==="held"?"today":Se($.createdAt)},$.id))})}):null,P>0?s.jsx(V,{tone:"critical",children:s.jsxs("a",{href:`${Ze}/jobs?state=failed`,onClick:N(`${Ze}/jobs?state=failed`),children:[P," failed job",P===1?"":"s",". See why, then retry or cancel them, one by one or all at once."]})}):null,E>0?s.jsx(V,{tone:"critical",children:s.jsxs("a",{href:`${Ze}/alerts`,onClick:N(`${Ze}/alerts`),children:[E," urgent alert",E===1?"":"s"," from your watchers."]})}):null,L.map($=>s.jsx(rt,{children:s.jsx(Pm,{plugin:$.plugin,agent:$.agent,text:$.text,label:`Create @${$.handle}`,handle:$.handle,onDismiss:()=>{A.dismissAgentOffer($.plugin,$.agent).then(()=>x.reload())}})},`${$.plugin}/${$.agent}`)),O>0?s.jsx(V,{tone:"accent",children:s.jsxs("a",{href:st("proposals"),onClick:N(st("proposals")),children:[O," proposal",O===1?"":"s"," from your agents to keep or discard."]})}):null,(((kt=k==null?void 0:k.sentinels)==null?void 0:kt.errors)??[]).map($=>s.jsxs(V,{tone:"warning",children:["Watcher ",$.sentinelId," failed: ",$.error]},$.sentinelId)),((k==null?void 0:k.mail)??[]).filter($=>$.lastError).map($=>s.jsxs(V,{tone:"warning",children:["Source ",$.sourceId,": ",$.lastError]},$.sourceId))]})}):null,s.jsx(Y,{title:"Your team",aside:s.jsx("a",{href:et,onClick:N(et),children:"All agents"}),children:n.length===0?s.jsx(ie,{mascot:!0,children:"No agents yet. Add one under Agents."}):s.jsx("div",{className:"home-team",children:b.map($=>{const de=fu(i.get($.id));return s.jsxs("a",{className:"home-face",...kl(bl($)),href:ze($.id),onClick:N(ze($.id)),"data-waiting":de?"true":void 0,"data-unavailable":$.available?void 0:"true",children:[s.jsx(as,{id:$.id,name:$.name,size:"lg",unavailable:!$.available,face:$}),s.jsxs("span",{className:"home-face-text",children:[s.jsx("span",{className:"home-face-name",children:$.name}),s.jsx("span",{className:"home-face-status",children:de?uS(de):$.available?As($.description,60):$.unavailableReason??"Cannot run right now."})]})]},$.id)})})}),_.length>0?s.jsx(Y,{title:"On offer",aside:s.jsxs("span",{className:"ui-row",children:[U>0?s.jsxs("a",{href:`${et}?tab=offers`,onClick:N(`${et}?tab=offers`),children:[U," more"]}):null,s.jsx(Zk,{ids:W.map($=>$.id),onDone:()=>f.reload()})]}),children:s.jsx("div",{className:"home-offers",children:_.map($=>s.jsx(yL,{offer:$,agents:n,open:N(ft($.agentId,"offers")),onDismissed:()=>f.reload()},$.id))})}):null,(_e=(ct=h.data)==null?void 0:ct.digest)!=null&&_e.latest?s.jsx(NL,{digest:h.data.digest.latest,go:N}):null,s.jsxs("div",{className:"home-columns",children:[s.jsx(Y,{title:"Coming up",aside:s.jsx("a",{href:`${et}?tab=missions`,onClick:N(`${et}?tab=missions`),children:"All missions"}),children:s.jsx(rt,{flush:!0,children:K.length===0?s.jsx(ie,{mascot:!0,children:"Nothing scheduled. Missions and reminders will show here."}):s.jsx(Ft,{children:K.map($=>s.jsx(Kt,{href:$.route,onClick:()=>t($.route),lead:s.jsx(Zt,{agents:n,id:$.agentId,size:"sm"}),title:$.title,sub:`${$.kind} for ${S($.agentId)}`,side:Se($.at)},$.key))})})}),s.jsx(Y,{title:"Lately",aside:s.jsx("a",{href:Ze,onClick:N(Ze),children:"All activity"}),children:s.jsx(rt,{flush:!0,children:M.length===0?s.jsx(ie,{mascot:!0,children:"Nothing has run yet. Say hello to someone on your team."}):s.jsx(Ft,{children:M.map($=>s.jsx(Kt,{href:ze($.agentId,$.id),onClick:()=>t(ze($.agentId,$.id)),lead:s.jsx(Zt,{agents:n,id:$.agentId,size:"sm"}),title:$.opening?As($.opening,80):"Untitled conversation",sub:`${S($.agentId)}, ${$.messageCount} message${$.messageCount===1?"":"s"}`,side:Se($.lastMessageAt??$.createdAt)},$.id))})})})]}),((k==null?void 0:k.home)??[]).map($=>s.jsx(EL,{block:$},$.id)),k!=null&&k.jobs&&k.missions?s.jsxs("p",{className:"home-foot muted",children:[Lt(k.jobs.pending??0)," queued, ",Lt(k.jobs.leased??0)," running, ",Lt(k.missions.enabled)," of ",Lt(k.missions.total)," missions on."," ",k.paused?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})," ",s.jsx("a",{href:zi("").replace(/\/conversations\/$/,""),onClick:N(Ze),children:"Activity"})," · ",s.jsx("a",{href:st("system"),onClick:N(st("system")),children:"System"})]}):null]})]})}const mL=new Set(["watcher","reminder","failure","recap","plugin"]),gL={approval:"Approval",question:"Question",watcher:"Watcher",reminder:"Reminder",failure:"Failure",recap:"Report",plugin:"Plugin"};function xL(e,t){const n=new Set(t.map(r=>r.id));return e.filter(r=>mL.has(r.kind)&&r.actedAt===null&&r.state!=="stored"&&(r.seenAt===null||r.state==="held")&&!(r.actionId&&n.has(r.actionId)))}const vL=6,jL=500;function yL({offer:e,agents:t,open:n,onDismissed:r}){const[i,o]=d.useState(!1),l=d.useRef(null),a=d.useRef(!1),c=()=>{i||(o(!0),A.dismissOffer(e.id).then(r).finally(()=>o(!1)))},u=()=>{l.current!==null&&clearTimeout(l.current),l.current=null};return s.jsxs("span",{className:"home-offer-chip",children:[s.jsxs("a",{className:"home-offer",href:ft(e.agentId,"offers"),onClick:p=>{if(a.current){a.current=!1,p.preventDefault();return}n(p)},title:e.prompt,onTouchStart:()=>{a.current=!1,u(),l.current=setTimeout(()=>{a.current=!0,c()},jL)},onTouchEnd:u,onTouchMove:u,onTouchCancel:u,children:[s.jsx(Zt,{agents:t,id:e.agentId,size:"sm"}),s.jsx("span",{children:e.label})]}),s.jsx("button",{type:"button",className:"home-offer-x","aria-label":`Dismiss ${e.label}`,disabled:i,onClick:c,children:"×"})]})}function wL(e,t){const n=[];for(const r of e)r.enabled&&r.nextRun&&n.push({key:`m-${r.id}`,at:r.nextRun,title:r.name,kind:"Mission",agentId:r.agentId,route:ft(r.agentId,"missions")});for(const r of t)r.state==="pending"&&n.push({key:`r-${r.id}`,at:r.dueAt,title:r.text,kind:"Reminder",agentId:r.agentId,route:ft(r.agentId,"reminders")});return n.sort((r,i)=>r.at.localeCompare(i.at)).slice(0,5)}function bL(e,t){try{const n=new Intl.DateTimeFormat("en-GB",{hour:"numeric",hourCycle:"h23",timeZone:t}).format(e?new Date(e):new Date);return Number(n)}catch{return new Date().getHours()}}function kL(e,t,n){const r=bL(e,t),i=n!=null&&n.trim()?`, ${n.trim()}`:"";return r<5?`Still up${i}?`:r<12?`Good morning${i}.`:r<18?`Good afternoon${i}.`:`Good evening${i}.`}function SL(e,t){try{const n=e?new Date(e):new Date,r=new Intl.DateTimeFormat("en-GB",{weekday:"long",timeZone:t}).format(n),i=new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",timeZone:t}).format(n);return`${r}, ${i}`}catch{return Re(e??null,t)}}function ga(e,t,n){return e.count===0?null:`${e.count} ${e.count===1?t:n}${e.names.length>0?`: ${e.names.join("; ")}${e.count>e.names.length?"; …":""}`:""}`}function NL({digest:e,go:t}){const n=[ga(e.memory,"memory note","memory notes"),ga(e.skills,"skill kept","skills kept"),ga(e.rules,"rule kept","rules kept"),ga(e.changes,"change to an agent kept","changes to agents kept")].filter(i=>i!==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(([,i])=>i>0).map(([i,o])=>`${i} ${o}`).join(", ")}).`:"No rule you kept acted this week.";return s.jsx(Y,{title:"What buddi learned this week",aside:s.jsx("span",{className:"muted",children:Se(e.at)}),children:s.jsx(rt,{children:s.jsxs(G,{divided:!0,children:[s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Learned"}),n.length===0?s.jsx("p",{children:"Nothing new."}):s.jsx("ul",{className:"home-digest-list",children:n.map(i=>s.jsx("li",{children:i},i))})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Proposes"}),s.jsx("p",{children:e.open>0?s.jsxs("a",{href:st("proposals"),onClick:t(st("proposals")),children:[e.open," proposal",e.open===1?"":"s"," waiting for you to keep or discard."]}):"Nothing was waiting for you."})]}),s.jsxs("div",{children:[s.jsx("p",{className:"ui-card-meta",children:"Stopped doing"}),s.jsx("p",{children:r})]})]})})})}function CL(e,t,n,r,i,o=0,l=0,a=0){if(e===0)return"Nothing needs you. Your agents are on it.";const c=[];t>0&&c.push(`${t} approval${t===1?"":"s"} waiting`),n>0&&c.push(`${n} failed job${n===1?"":"s"}`),r>0&&c.push(`${r} urgent alert${r===1?"":"s"}`),i&&c.push("the installation is paused"),o>0&&c.push(`${o} proposal${o===1?"":"s"} to review`),l>0&&c.push(`${l===1?"an agent":`${l} agents`} to set up`),a>0&&c.push(`${a} message${a===1?"":"s"} for you`);const u=c.length<=1?c.join(""):`${c.slice(0,-1).join(", ")} and ${c[c.length-1]}`;return`${uS(u)}.`}function uS(e){return e.charAt(0).toUpperCase()+e.slice(1)}function EL({block:e}){const[t,n]=d.useState(!1),r=e.sensitive===!0&&!t;d.useEffect(()=>{if(!e.sensitive||!t)return;const o=()=>{document.visibilityState==="hidden"&&n(!1)};return document.addEventListener("visibilitychange",o),window.addEventListener("blur",o),()=>{document.removeEventListener("visibilitychange",o),window.removeEventListener("blur",o)}},[e.sensitive,t]);const i=s.jsxs("span",{className:"ui-row",children:[e.rows.length>0&&e.rowsTitle&&!r?s.jsxs("span",{className:"muted",children:[e.rowsTitle.toLowerCase()," below"]}):null,e.sensitive?s.jsx(R,{size:"sm",variant:"ghost","aria-pressed":!r,onClick:()=>n(o=>!o),children:r?"Show":"Hide"}):null]});return s.jsxs(Y,{title:e.title,aside:i,children:[e.note?s.jsx(V,{tone:"warning",children:e.note}):null,e.stats.length>0?s.jsx(pu,{children:e.stats.map(o=>s.jsx(Zn,{label:o.label,value:r?"••••":o.value,note:r?void 0:o.note,tone:r?void 0:o.tone},o.label))}):null,e.rows.length>0?r?s.jsxs("p",{className:"muted",children:[e.rows.length," item",e.rows.length===1?"":"s"," hidden."]}):s.jsx(rt,{flush:!0,children:s.jsx(Ft,{children:e.rows.map((o,l)=>s.jsx(Kt,{title:o.title,sub:o.sub,side:o.side?s.jsx("span",{className:o.tone==="critical"?"critical":o.tone==="good"?"good":void 0,children:o.side}):void 0},`${o.title}-${l}`))})}):null]})}const dS="(max-width: 900px)";function Rh(e){const[t,n]=d.useState(()=>{try{return window.matchMedia(e).matches}catch{return!1}});return d.useEffect(()=>{var o;let r;try{r=window.matchMedia(e)}catch{return}const i=l=>n(l.matches);return(o=r.addEventListener)==null||o.call(r,"change",i),()=>{var l;return(l=r.removeEventListener)==null?void 0:l.call(r,"change",i)}},[e]),t}const AL=3e4;function fS(){const{data:e,reload:t}=se(()=>A.recovery(),[],AL);return{data:e,reload:t}}const TL="This buddi was restored from a backup. Nothing runs on its own until you finish the checklist.";function RL({active:e,onNavigate:t}){return e?s.jsxs("div",{className:"recovery-banner",role:"status",children:[s.jsx("span",{children:TL}),s.jsx("a",{href:av,onClick:n=>{n.preventDefault(),t(av)},children:"Finish the checklist"})]}):null}function PL({view:e,onLeft:t}){const{secrets:n,plugins:r,pending:i,grants:o}=e.checklist,[l,a]=d.useState(!0),[c,u]=d.useState([]),[p,f]=d.useState(!1),[h,x]=d.useState(null),[j,w]=d.useState(!1),b=r.filter(g=>!g.installed),v=i.jobs+i.missions+i.approvals+i.telegramChats,m=g=>{u(k=>k.includes(g)?k.filter(S=>S!==g):[...k,g])},y=()=>{f(!0),x(null),A.leaveRecovery({dropPending:l,keepGrants:c}).then(()=>{w(!0),t==null||t()}).catch(g=>x(g instanceof ce?g.message:String(g))).finally(()=>f(!1))};return s.jsx(rt,{title:"Back from a backup",children:s.jsxs(G,{divided:!0,children:[s.jsxs(Y,{children:[s.jsx(At,{items:[{label:"Restored",value:e.restoredAt??"just now"},{label:"From",value:s.jsx("span",{className:"mono",children:e.archive??"—"})}]}),s.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."})]}),s.jsx(Y,{title:"Keys to paste again",children:n.length===0?s.jsx(ie,{children:"Nothing is missing."}):s.jsx("ul",{className:"recovery-list",children:n.map(g=>s.jsxs("li",{children:[g.settingsRoute?s.jsx("a",{href:g.settingsRoute,children:g.name}):g.name," ",s.jsx("span",{className:"ui-card-meta",children:g.kind})]},`${g.kind}:${g.name}`))})}),s.jsx(Y,{title:"Add-ons to install again",children:b.length===0?s.jsx(ie,{children:"Everything the backup named is installed."}):s.jsx("ul",{className:"recovery-list",children:b.map(g=>s.jsxs("li",{children:[s.jsx("span",{className:"mono",children:g.name})," ",g.version," ",s.jsx("span",{className:"ui-card-meta",children:g.source})]},g.name))})}),s.jsx(Y,{title:"Work that was waiting",children:v===0?s.jsx(ie,{children:"Nothing was in flight when the backup was taken."}):s.jsxs(G,{gap:"sm",children:[s.jsx(At,{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)}]}),s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:g=>a(g.target.checked)}),s.jsx("span",{children:"Drop it. It was queued somewhere else, days ago."})]})]})}),s.jsx(Y,{title:"Standing permissions",children:o.length===0?s.jsx(ie,{children:"No agent had a standing permission."}):s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Each of these lets an agent act without asking. Keep only the ones you meant."}),s.jsx("ul",{className:"recovery-list",children:o.map(g=>s.jsx("li",{children:s.jsxs("label",{className:"recovery-check",children:[s.jsx("input",{type:"checkbox",checked:c.includes(g.id),onChange:()=>m(g.id),"aria-label":`Keep ${g.tool} for ${g.agent}`}),s.jsxs("span",{children:[s.jsx("span",{className:"mono",children:g.tool})," for ",g.agent," ",s.jsx("span",{className:"ui-card-meta",children:g.scope}),g.description?s.jsxs("span",{className:"ui-card-meta",children:[" — ",g.description]}):null]})]})},g.id))})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:h}),j?s.jsx(V,{tone:"good",role:"status",children:"Turning everything back on. This page comes back in a few seconds."}):s.jsx("p",{className:"ui-card-meta",children:"Leaving starts the schedules, the watchers and the phone again. buddi restarts itself to do it."}),s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:p||j,onClick:y,children:"Leave recovery mode"})})]})})]})})}const IL=2e3,ML={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 Jv(e){return ML[e.phase]??e.detail??e.phase}const $L=new Set(["done","failed","rolled-back"]);function hS(e){return e!==void 0&&($L.has(e.phase)||!!e.finishedAt)}function _L(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(!1),[o,l]=d.useState(null),a=d.useRef(!1);return d.useEffect(()=>{if(!e){n(void 0),i(!1),a.current=!1;return}let c=!1;const u=()=>{A.backupJob(e).then(f=>{if(!c){if(a.current){window.location.reload();return}n(f),l(null),hS(f)&&(c=!0)}}).catch(f=>{if(!c){if(f instanceof ce&&f.status!==0&&f.status<500){l(f.message);return}a.current=!0,i(!0)}})};u();const p=window.setInterval(u,IL);return()=>{c=!0,window.clearInterval(p)}},[e]),{job:t,away:r,error:o}}function OL({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.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"?s.jsxs(V,{tone:"critical",role:"alert",children:[Jv(e)," ",e.error??""]}):s.jsxs(V,{tone:e.phase==="done"?"good":void 0,role:"status",children:[Jv(e),e.copyLate?" The backup was made, but the copy to your folder did not go through.":"",e.error?` ${e.error}`:""]}):null}function DL(){var b,v,m,y,g,k,S;const e=se(()=>A.backups(),[],3e4),t=fS(),n=se(()=>A.service(),[]),[r,i]=d.useState(null),o=_L(r),[l,a]=d.useState(null),[c,u]=d.useState(!1),[p,f]=d.useState(null),h=((b=e.data)==null?void 0:b.supervised)??((v=n.data)==null?void 0:v.supervised),x=p!==null||h===!1,j=((m=e.data)==null?void 0:m.archives)??[],w=N=>{u(!0),a(null),N.then(C=>{var P;return i(((P=C.job)==null?void 0:P.id)??null)}).catch(C=>{C instanceof ce&&C.status===409?f(C.message):a(C instanceof ce?C.message:String(C))}).finally(()=>{u(!1),e.reload()})};return d.useEffect(()=>{hS(o.job)&&e.reload()},[(y=o.job)==null?void 0:y.phase]),s.jsxs(G,{gap:"lg",children:[(g=t.data)!=null&&g.active?s.jsx(PL,{view:t.data,onLeft:t.reload}):null,s.jsx(re,{message:e.error??l}),s.jsx(OL,{...o}),s.jsx(FL,{onSaved:()=>e.reload()}),s.jsx(Y,{title:"Backups",panel:!0,actions:s.jsx(R,{variant:"accent",size:"sm",disabled:c,onClick:()=>w(A.startBackup(!0)),children:"Back up now"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs("p",{className:"ui-card-meta",children:["Kept in ",s.jsx("span",{className:"mono",children:((k=e.data)==null?void 0:k.dir)??"…"}),". A backup holds your agents, conversations, memory and files. It never holds a key."]})}),s.jsx(Y,{children:e.data&&j.length===0?s.jsx(yt,{icon:"archive",title:"No backups yet",children:"Make one now, or turn on the nightly backup."}):e.data?s.jsxs(ln,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Name"}),s.jsx("th",{children:"Taken"}),s.jsx("th",{children:"Size"}),s.jsx("th",{children:"State"}),s.jsx("th",{})]})}),s.jsx("tbody",{children:j.map(N=>{var C;return s.jsx(zL,{archive:N,busy:c,database:(C=e.data)==null?void 0:C.database,checkout:x,onVerify:()=>w(A.verifyArchive(N.name)),onRestore:(P,E)=>w(A.restoreArchive({name:N.name,...P?{passphrase:P}:{},...E?{confirm:E}:{}}))},N.name)})})]}):s.jsx(ie,{children:"Loading…"})})]})}),s.jsx(UL,{}),s.jsx(BL,{busy:c,checkout:x,checkoutSaid:p,database:(S=e.data)==null?void 0:S.database,onRestore:(N,C,P)=>w(A.restoreUpload(N,{passphrase:C,confirm:P}))})]})}const LL={enabled:!1,time:"03:00",keep:7,encryptLocal:!0,copyTo:null};function FL({onSaved:e}){var x;const t=se(()=>A.backupSchedule(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1);d.useEffect(()=>{t.data&&r(t.data)},[t.data]);const p={...LL,...n??t.data??{}};if(((x=t.data)==null?void 0:x.supervised)===!1)return s.jsx(Y,{title:"Every night",panel:!0,children:s.jsx(Y,{children:s.jsx(V,{tone:"warning",children:t.data.error??"This installation schedules its own backups."})})});const f=j=>{u(!1),r({...p,...j})},h=()=>{o(!0),a(null),A.setBackupSchedule(p).then(j=>{r(j),u(!0),e()}).catch(j=>a(j instanceof ce?j.message:String(j))).finally(()=>o(!1))};return s.jsx(Y,{title:"Every night",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:i,onClick:h,children:"Save"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:l}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.enabled,onChange:j=>f({enabled:j.target.checked})}),s.jsx("span",{children:"Back this buddi up on its own"})]}),s.jsxs(Ts,{children:[s.jsx(ee,{label:"At",children:s.jsx("input",{type:"time",value:p.time,onChange:j=>f({time:j.target.value})})}),s.jsx(ee,{label:"Keep",hint:"How many to keep before the oldest is thrown away.",children:s.jsx("input",{type:"number",min:1,max:365,value:p.keep,onChange:j=>f({keep:Number(j.target.value)||1})})})]}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:p.encryptLocal,onChange:j=>f({encryptLocal:j.target.checked})}),s.jsx("span",{children:"Lock each one with the passphrase"})]})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(ee,{label:"Also copy to a folder",hint:"A second disk, or a folder that syncs somewhere. Left empty, backups stay on this machine.",children:s.jsx("input",{type:"text",value:p.copyTo??"",placeholder:"/Volumes/backup/buddi",onChange:j=>f({copyTo:j.target.value===""?null:j.target.value})})}),c?s.jsxs(V,{tone:"good",role:"status",children:["Saved.",p.lastRunAt?` Last run ${Se(p.lastRunAt)}.`:""]}):null]})})]})})}function zL({archive:e,busy:t,database:n,checkout:r,onVerify:i,onRestore:o}){const[l,a]=d.useState(!1),[c,u]=d.useState(""),[p,f]=d.useState("");return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{children:[s.jsx("td",{className:"mono",children:e.name}),s.jsx("td",{children:Se(e.createdAt)}),s.jsx("td",{children:An(e.bytes)}),s.jsxs("td",{children:[e.encrypted?s.jsx(pe,{tone:"good",children:"locked"}):s.jsx(pe,{tone:"muted",children:"plain"})," ",e.envelopeOk===!1?s.jsx(pe,{tone:"critical",children:"damaged"}):null]}),s.jsx("td",{children:s.jsxs(J,{align:"end",children:[s.jsx(R,{size:"sm",disabled:t,onClick:i,children:"Verify"}),s.jsx(R,{size:"sm",variant:"ghost",onClick:()=>a(!l),children:"Restore…"})]})})]}),l?s.jsx("tr",{children:s.jsx("td",{colSpan:5,children:r?s.jsx(V,{tone:"warning",children:pS}):s.jsx(mS,{what:`${e.name}, taken ${Se(e.createdAt)}, ${An(e.bytes)}`,database:n,needsPassphrase:e.encrypted,passphrase:c,onPassphrase:u,confirm:p,onConfirm:f,busy:t,onCancel:()=>a(!1),onGo:()=>o(c,p)})})}):null]})}const pS="Restoring needs the packaged installation. In a checkout, run: buddi backup restore <file>";function mS({what:e,database:t,needsPassphrase:n,passphrase:r,onPassphrase:i,confirm:o,onConfirm:l,busy:a,onCancel:c,onGo:u}){const p=t??"",f=p===""?o.trim()!=="":o.trim()===p;return s.jsxs(G,{gap:"sm",children:[s.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."]}),n?s.jsx(ee,{label:"The passphrase this one was locked with",children:s.jsx("input",{type:"password",autoComplete:"off",value:r,onChange:h=>i(h.target.value)})}):null,s.jsx(ee,{label:p?`Type ${p} to confirm`:"Type the name of this database to confirm",hint:p?void 0:"The same name buddi shows on the System tab.",children:s.jsx("input",{value:o,onChange:h=>l(h.target.value)})}),s.jsxs(J,{align:"end",children:[s.jsx(R,{variant:"ghost",onClick:c,children:"Cancel"}),s.jsx(R,{variant:"danger",disabled:a||!f||n&&r==="",onClick:u,children:"Restore"})]})]})}function UL(){const[e,t]=d.useState(null),[n,r]=d.useState(""),[i,o]=d.useState(!1),[l,a]=d.useState(null),[c,u]=d.useState(!1),p=()=>{o(!0),a(null),A.backupPassphrase().then(h=>t(h.passphrase)).catch(h=>a(h instanceof ce?h.message:String(h))).finally(()=>o(!1))},f=()=>{o(!0),a(null),A.setBackupPassphrase(n.trim()).then(h=>{t(h.passphrase),r(""),u(!0)}).catch(h=>a(h instanceof ce?h.message:String(h))).finally(()=>o(!1))};return s.jsx(Y,{title:"The passphrase",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:l}),s.jsx("p",{className:"ui-card-meta",children:"This is the only thing that opens an encrypted backup. Write it down."}),e?s.jsx("p",{className:"backup-phrase mono",children:e}):s.jsx(J,{align:"end",children:s.jsx(R,{disabled:i,onClick:p,children:"Show it"})}),c?s.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]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(ee,{label:"Use my own",hint:"Six words you can read out loud beat a short one nobody can.",children:s.jsx("input",{type:"text",autoComplete:"off",value:n,onChange:h=>{u(!1),r(h.target.value)}})}),s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:i||n.trim()==="",onClick:f,children:"Use this one"})})]})})]})})}function BL({busy:e,checkout:t,checkoutSaid:n,database:r,onRestore:i}){const[o,l]=d.useState(null),[a,c]=d.useState(""),[u,p]=d.useState(""),[f,h]=d.useState(!1);return t?s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsx(Y,{children:s.jsx(V,{tone:"warning",children:n??pS})})}):s.jsx(Y,{title:"Restore from a file",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"A backup from another buddi, or one you keep somewhere else."}),s.jsxs(Ts,{children:[s.jsx(ee,{label:"The backup file",children:s.jsx("input",{type:"file",onChange:x=>{var j;h(!1),l(((j=x.target.files)==null?void 0:j[0])??null)}})}),s.jsx(ee,{label:"Its passphrase",hint:"Only if it was locked with one.",children:s.jsx("input",{type:"password",autoComplete:"off",value:a,onChange:x=>c(x.target.value)})})]}),f?null:s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||!o,onClick:()=>h(!0),children:"Restore"})})]})}),f&&o?s.jsx(Y,{children:s.jsx(mS,{what:`${o.name}, ${An(o.size)}`,database:r,needsPassphrase:!1,passphrase:a,onPassphrase:c,confirm:u,onConfirm:p,busy:e,onCancel:()=>h(!1),onGo:()=>i(o,a,u)})}):null]})})}function WL({embedded:e}={}){const{data:t,error:n,reload:r,loading:i}=se(()=>A.providerAccounts(),[]),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(""),[f,h]=d.useState(!1),[x,j]=d.useState(!1),[w,b]=d.useState(null),v=t==null?void 0:t.accounts.some(k=>{var S;return((S=k.login)==null?void 0:S.state)==="pending"&&k.login.expiresAt&&Date.parse(k.login.expiresAt)>Date.now()});d.useEffect(()=>{if(!v)return;const k=setInterval(r,2e3);return()=>clearInterval(k)},[v,r]);const m=async(k,S)=>{l(!0),c(null),p(""),j(!1);try{const N=await k();return p((N==null?void 0:N.warning)??S),r(),!0}catch(N){return c(N instanceof Error?N.message:"Could not apply change."),r(),!1}finally{l(!1)}},y=(t==null?void 0:t.accounts)??[],g=y.find(k=>k.id===w)??y[0];return s.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:[s.jsx(re,{message:n??a}),u&&s.jsx(V,{tone:"good",role:"status",children:u}),x&&s.jsx(V,{role:"status",children:i?"Refreshing account status…":n?"Could not refresh account status. Try again.":"Account status refreshed. This checks saved credentials; it does not renew subscription tokens or test connections."}),!t&&!n&&s.jsx(ie,{children:"Loading accounts…"}),n&&s.jsx(J,{children:s.jsx(R,{onClick:r,children:"Retry"})}),t&&s.jsxs(s.Fragment,{children:[(t.vault.locked||t.vault.kind==="none")&&s.jsx(V,{tone:"warning",children:t.vault.advice||"Run buddi init on the host to configure secure credential storage."}),f&&s.jsx(qt,{title:"Add an account",onClose:()=>h(!1),children:s.jsx("div",{id:"new-provider-account",children:s.jsx(qL,{accounts:y,codexEnabled:t.codexEnabled,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:o,run:m,onDone:k=>{h(!1),k&&b(k)}})})}),s.jsx(Y,{title:"Accounts",aside:`Secrets live in the ${HL(t.vault.kind)}; Postgres holds names and assignments only.`,actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",size:"sm",disabled:o||i,onClick:()=>{c(null),p(""),j(!0),r()},children:i?"Refreshing…":"Refresh status"}),s.jsx(R,{variant:"accent",size:"sm",disabled:o,"aria-expanded":f,"aria-controls":"new-provider-account",onClick:()=>h(!f),children:"Add account"})]}),panel:!0,flush:!0,children:y.length===0?s.jsx(yt,{icon:"chip",title:"No accounts yet",children:"Add one to give your agents a model to run on."}):s.jsxs("div",{className:"accounts",children:[s.jsx("nav",{className:"accounts-list","aria-label":"Accounts",children:y.map(k=>s.jsxs("button",{type:"button",className:"accounts-row","aria-pressed":(g==null?void 0:g.id)===k.id,onClick:()=>b(k.id),children:[s.jsx(VL,{kind:k.kind,auth:k.auth}),s.jsxs("span",{className:"accounts-row-text",children:[s.jsx("span",{className:"accounts-row-name",children:k.label}),s.jsxs("span",{className:"accounts-row-sub",children:[Lm(k)," · ",k.assignedAgents.length===0?"no agents":`${k.assignedAgents.length} agent${k.assignedAgents.length===1?"":"s"}`]})]}),s.jsx(gS,{account:k})]},k.id))}),g?s.jsx(GL,{account:g,anthropicOAuthEnabled:t.anthropicOAuthEnabled,busy:o,run:m},`${g.id}:${g.revision}`):null]})})]})]})}function HL(e){return e==="keychain"?"macOS Keychain":e==="file"?"encrypted file vault":e==="none"?"vault (none configured)":e}function Lm(e){return e.kind==="codex"?"ChatGPT subscription":e.kind==="anthropic"?e.auth==="anthropic-oauth"?"Claude subscription":e.auth==="legacy-subscription-token"?"Claude setup token":"Anthropic API":e.kind==="openai"?"OpenAI API":"OpenAI-compatible"}function VL({kind:e,auth:t}){const n=e==="anthropic"?"A":e==="codex"?"G":e==="openai"?"O":"∞",r=e==="anthropic"?"3":e==="codex"?"2":e==="openai"?"5":"4";return s.jsx("span",{className:"ui-avatar","data-tint":r,"aria-hidden":"true",title:`${e} · ${t}`,children:n})}function KL(e){return e==="connected"?"good":["rate-limited","quota-exhausted","provider-unavailable"].includes(e)?"warning":"critical"}function gS({account:e}){const t=e.enabled?e.configured?"good":"warning":void 0,n=e.enabled?e.configured?"Configured":"Needs credential":"Disabled";return s.jsx(pe,{tone:t,children:n})}function xS(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 GL({account:e,busy:t,run:n,anthropicOAuthEnabled:r}){const[i,o]=d.useState(!1),[l,a]=d.useState(!1);return s.jsxs("section",{className:"accounts-detail","aria-label":e.label,children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:e.label}),s.jsx(gS,{account:e})]}),s.jsx(At,{items:[{label:"Provider",value:Lm(e)},{label:"Default model",value:s.jsx("span",{className:"mono",children:e.defaultModel||"—"})},{label:"Context window",value:s.jsx("span",{className:"mono",children:`${(e.contextWindowTokens??e.detectedContextWindowTokens??0).toLocaleString()} tokens${e.contextWindowTokens?"":" (detected)"}`})},...e.baseUrl?[{label:"Endpoint",value:s.jsx("span",{className:"mono",children:e.baseUrl})}]:[],{label:"Used by",value:e.assignedAgents.length?s.jsx("span",{className:"ui-row",children:e.assignedAgents.map(c=>s.jsx("a",{href:ft(c,"setup","brain"),children:c},c))}):s.jsxs("span",{className:"ui-row",children:[s.jsx("span",{className:"muted",children:"No agents"}),s.jsx("a",{href:et,children:"Assign to an agent"})]})},...e.tokenExpiresAt?[{label:"Access token",value:`expires ${new Date(e.tokenExpiresAt).toLocaleString()} (not your subscription renewal date)`}]:[]]}),e.removalPending&&s.jsx(V,{tone:"warning",children:"Removal is pending. Unlock the vault, then retry Remove account."}),e.reconnectRequired&&s.jsx(V,{tone:"warning",children:"Token refresh did not finish. Reconnect this Claude account."}),e.auth==="anthropic-oauth"&&s.jsx(jS,{account:e,enabled:!!r,busy:t,run:n}),e.kind==="codex"&&s.jsx(vS,{account:e,busy:t,run:n}),s.jsxs(J,{children:[s.jsx(R,{disabled:t||e.removalPending,onClick:()=>o(!0),children:"Edit account"}),s.jsx(R,{disabled:t||e.removalPending,onClick:()=>void n(()=>A.saveProviderAccount({...xS(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"&&s.jsx(R,{disabled:t||!e.enabled||!e.configured,onClick:()=>void n(()=>A.testProviderAccount(e.id),"Connection test finished."),children:"Test connection"}),s.jsx(R,{variant:"danger",disabled:t||e.assignedAgents.length>0,title:e.assignedAgents.length?"Reassign its agents before removing this account":void 0,onClick:()=>a(!0),children:"Remove account"})]}),e.test&&s.jsxs(s.Fragment,{children:[s.jsxs(V,{role:"status",tone:KL(e.test.state),children:[s.jsx("p",{children:e.test.message}),e.test.retryAt?s.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)&&s.jsx("p",{children:"The provider did not supply a usable Retry-After time. Reset time is unknown."})]}),s.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."]})]}),i&&s.jsx(qt,{title:`Edit ${e.label}`,onClose:()=>o(!1),children:s.jsx(YL,{account:e,busy:t,run:n,onDone:()=>o(!1)})}),l&&s.jsxs(V,{tone:"critical",children:[s.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."]}),s.jsxs(J,{children:[s.jsx(R,{variant:"danger",disabled:t,onClick:()=>void n(()=>A.removeProviderAccount(e.id,e.revision),"Account removed from Buddi."),children:"Confirm removal"}),s.jsx(R,{disabled:t,onClick:()=>a(!1),children:"Cancel"})]})]}),s.jsx(wt,{summary:"Details",children:s.jsxs("div",{className:"ui-prose muted",children:[e.auth==="legacy-subscription-token"&&s.jsx("p",{children:"Legacy subscription token: not refreshable, token expiry and subscription renewal date unknown."}),e.kind==="codex"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Runs through the Codex App Server. Credentials stay in Buddi’s vault and are staged in a private temporary file during native sessions. Codex manages refresh. Subscription renewal date is unknown."}),s.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."}),s.jsx("p",{children:"After connecting, assign this account to an agent and send a test message. Model turns use your subscription allowance."})]}):s.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==="anthropic-oauth"&&s.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."}),s.jsx("p",{children:"Subscription login is separate from API-key access. Existing Claude setup tokens remain legacy accounts, without automatic refresh or a known expiry."})]})})]})}function vS({account:e,busy:t,run:n}){var r,i,o;return s.jsxs(s.Fragment,{children:[s.jsxs(J,{children:[s.jsx(R,{disabled:t||!e.enabled||e.removalPending||((r=e.login)==null?void 0:r.state)==="pending",onClick:()=>void n(()=>A.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"&&s.jsx(R,{disabled:t,onClick:()=>void n(()=>A.codexAccountAction(e.id,"cancel-login",e.revision),"Sign-in cancelled."),children:"Cancel sign-in"}),s.jsx(R,{disabled:t||!e.configured,onClick:()=>void n(()=>A.codexAccountAction(e.id,"logout",e.revision),"Subscription disconnected from Buddi. Your regular Codex login is unchanged."),children:"Disconnect"})]}),((o=e.login)==null?void 0:o.state)==="pending"&&s.jsxs(V,{tone:"accent",role:"status",children:[s.jsxs("p",{children:["Open ",s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:e.login.verificationUrl})," and enter ",s.jsx("code",{children:e.login.userCode}),"."]}),s.jsxs("p",{className:"muted",children:["Buddi stops waiting at ",e.login.expiresAt&&new Date(e.login.expiresAt).toLocaleTimeString(),". This is the sign-in timeout, not your subscription expiry."]})]}),e.login&&e.login.state!=="pending"&&s.jsx("p",{role:"status",className:"muted",children:e.login.message??`Sign-in ${e.login.state}.`})]})}function YL({account:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o}){const[l,a]=d.useState((e==null?void 0:e.label)??""),[c,u]=d.useState((e==null?void 0:e.kind)??"anthropic"),[p,f]=d.useState((e==null?void 0:e.auth)??"api-key"),[h,x]=d.useState((e==null?void 0:e.baseUrl)??""),[j,w]=d.useState((e==null?void 0:e.defaultModel)??"claude-sonnet-5"),[b,v]=d.useState(""),[m,y]=d.useState(e!=null&&e.contextWindowTokens?String(e.contextWindowTokens):""),g=S=>{u(S),f(S==="codex"?"chatgpt":"api-key"),v(""),x(S==="openai-compatible"?"http://localhost:11434/v1":""),w(S==="anthropic"?"claude-sonnet-5":S==="openai"?"gpt-5":"")},k=!l.trim()||!j.trim();return s.jsxs("form",{className:"ui-stack",onSubmit:S=>{S.preventDefault();const N=b;v(""),n(()=>A.saveProviderAccount({...e?{id:e.id,revision:e.revision}:{},label:l,kind:c,auth:p,baseUrl:h,defaultModel:j,enabled:(e==null?void 0:e.enabled)??!0,contextWindowTokens:m.trim()?Number(m):null,...N.trim()?{secret:N}:{}}),"Account saved. Agent model selections are unchanged.").then(C=>{C&&r()})},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(ee,{label:"Account name",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:l,onChange:S=>a(S.target.value),placeholder:"Anthropic — Personal"})}),s.jsx(ee,{label:"Provider",children:s.jsxs("select",{disabled:!!e,value:p==="anthropic-oauth"?"anthropic-oauth":c,onChange:S=>{S.target.value==="anthropic-oauth"?(g("anthropic"),f("anthropic-oauth")):g(S.target.value)},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint"}),(o||(e==null?void 0:e.auth)==="anthropic-oauth")&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),(i||(e==null?void 0:e.kind)==="codex")&&s.jsx("option",{value:"codex",children:"ChatGPT subscription through Codex"})]})}),c==="openai-compatible"&&s.jsxs(s.Fragment,{children:[s.jsx(ee,{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:s.jsx("input",{required:!0,type:"url",value:h,onChange:S=>x(S.target.value)})}),s.jsx(ee,{label:"Authentication",children:s.jsxs("select",{disabled:!!e,value:p,onChange:S=>{f(S.target.value),v("")},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),s.jsx(J,{valign:"end",children:s.jsx(Dm,{accountId:e!=null&&e.configured&&e.enabled?e.id:void 0,label:"Default model",value:j,onChange:w,disabled:t},`${e==null?void 0:e.id}:${e==null?void 0:e.revision}`)}),s.jsx(ee,{label:"Context window",hint:"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:s.jsx("input",{type:"number",inputMode:"numeric",min:8e3,max:2e6,step:1e3,value:m,placeholder:e!=null&&e.detectedContextWindowTokens?String(e.detectedContextWindowTokens):"detected from the model",onChange:S=>y(S.target.value)})}),c==="codex"&&s.jsx("p",{className:"muted",children:"Enter a model available to your Codex subscription. API model availability is different; there is no automatic model fallback."}),p==="anthropic-oauth"&&s.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."}),p==="api-key"&&s.jsx(ee,{label:e?"Replacement API key (leave blank to keep)":"API key",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:b,onChange:S=>v(S.target.value)})}),e&&s.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."}),s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:r,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:k,children:"Save account"})]})]}),k&&s.jsx("p",{className:"muted",children:"Enter an account name and default model to enable Save account. The example name is a placeholder."})]})}function jS({account:e,enabled:t,busy:n,run:r}){var l,a,c,u,p;const[i,o]=d.useState("");return d.useEffect(()=>{o("")},[(l=e.login)==null?void 0:l.attemptId,(a=e.login)==null?void 0:a.state]),s.jsxs(s.Fragment,{children:[!t&&s.jsx(V,{tone:"warning",children:"Claude subscription sign-in is turned off on this host."}),s.jsxs(J,{children:[s.jsx(R,{disabled:n||!t||!e.enabled||e.removalPending||((c=e.login)==null?void 0:c.state)==="pending",onClick:()=>void r(()=>A.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"&&s.jsx(R,{disabled:n,onClick:()=>{o(""),r(()=>A.anthropicAccountAction(e.id,"cancel-login",e.revision),"Claude sign-in cancelled.")},children:"Cancel sign-in"}),s.jsx(R,{disabled:n||!e.configured||e.removalPending,onClick:()=>{o(""),r(()=>A.anthropicAccountAction(e.id,"logout",e.revision),"Claude disconnected from Buddi. This does not revoke access at Anthropic.")},children:"Disconnect Claude"})]}),((p=e.login)==null?void 0:p.state)==="pending"&&s.jsxs("form",{className:"ui-notice","data-tone":"accent",onSubmit:f=>{f.preventDefault();const h=i;o(""),r(()=>A.anthropicAccountAction(e.id,"complete-login",e.revision,{attemptId:e.login.attemptId,code:h}),"Claude connected. Edit account to load its model list, then assign it to an agent.")},children:[s.jsx("p",{children:s.jsx("a",{href:e.login.verificationUrl,target:"_blank",rel:"noreferrer",children:"Open Claude consent page"})}),s.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&&new Date(e.login.expiresAt).toLocaleTimeString(),"; restarting Buddi also ends it."]}),s.jsx(ee,{label:"Claude authorization code",children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,maxLength:8192,value:i,onChange:f=>o(f.target.value),disabled:n})}),s.jsx(J,{align:"end",children:s.jsx(R,{type:"submit",variant:"accent",disabled:n||!i.trim(),children:"Complete Claude sign-in"})})]})]})}const Ld={anthropic:"claude-sonnet-5",openai:"gpt-5",codex:"gpt-5"};function Xv(e,t,n){const r=e==="codex"?"ChatGPT subscription":e==="anthropic"?t==="anthropic-oauth"?"Claude subscription":"Anthropic API":e==="openai"?"OpenAI API":"Local endpoint",i=new Set(n.map(o=>o.trim().toLowerCase()));if(!i.has(r.toLowerCase()))return r;for(let o=2;o<100;o+=1)if(!i.has(`${r} ${o}`.toLowerCase()))return`${r} ${o}`;return r}function qL({accounts:e,busy:t,run:n,onDone:r,codexEnabled:i,anthropicOAuthEnabled:o}){const l=e.map(Z=>Z.label),[a,c]=d.useState(null),[u,p]=d.useState("anthropic"),[f,h]=d.useState("api-key"),[x,j]=d.useState(()=>Xv("anthropic","api-key",l)),[w,b]=d.useState(!1),[v,m]=d.useState(""),[y,g]=d.useState(""),[k,S]=d.useState(null),[N,C]=d.useState(!1),[P,E]=d.useState(""),[O,L]=d.useState(""),[D,T]=d.useState(!1),z=(Z,ue)=>{p(Z),h(ue),g(""),S(null),E(""),L(""),T(!1),m(Z==="openai-compatible"?"http://localhost:11434/v1":""),w||j(Xv(Z,ue,l))},q=a?e.find(Z=>Z.id===a):void 0;if(a)return q?s.jsx(QL,{account:q,busy:t,run:n,anthropicOAuthEnabled:o,onDone:()=>r(q.id)}):s.jsx(ie,{children:"Saving…"});const K=u==="openai-compatible",M=u==="codex"||f==="anthropic-oauth",W=!M&&(f==="none"||y.trim()!=="")&&(!K||v.trim()!==""),_=async()=>{var Z,ue;C(!0),E("");try{const je=await A.probeModels({kind:u,auth:f,...K?{baseUrl:v}:{},...y.trim()?{secret:y}:{}});S(je),O||L(((Z=je.models.find(Ce=>Ce.isDefault))==null?void 0:Z.id)??((ue=je.models[0])==null?void 0:ue.id)??"")}catch(je){E(je instanceof Error?je.message:"Could not load models. You can still enter a custom model.")}finally{C(!1)}},U=O.trim(),X=!x.trim()||K&&!v.trim()||K&&!U;return s.jsxs("form",{className:"ui-stack",onSubmit:Z=>{Z.preventDefault();const ue=y;g("");const je=U||Ld[u]||"claude-sonnet-5";(async()=>{let Ce;!await n(async()=>(Ce=await A.saveProviderAccount({label:x,kind:u,auth:f,baseUrl:v,defaultModel:je,enabled:!0,...ue.trim()?{secret:ue}:{}}),Ce),"Account saved.")||!Ce||(U||!M?r(Ce.id):c(Ce.id))})()},children:[s.jsxs("fieldset",{disabled:t,className:"ui-fields","data-stack":"true",children:[s.jsx(ee,{label:"Provider",children:s.jsxs("select",{value:f==="anthropic-oauth"?"anthropic-oauth":u,onChange:Z=>{if(Z.target.value==="anthropic-oauth")z("anthropic","anthropic-oauth");else{const ue=Z.target.value;z(ue,ue==="codex"?"chatgpt":"api-key")}},children:[s.jsx("option",{value:"anthropic",children:"Anthropic API"}),s.jsx("option",{value:"openai",children:"OpenAI API"}),s.jsx("option",{value:"openai-compatible",children:"OpenAI-compatible endpoint (Ollama, OpenRouter, vLLM…)"}),o&&s.jsx("option",{value:"anthropic-oauth",children:"Claude subscription"}),i&&s.jsx("option",{value:"codex",children:"ChatGPT subscription through Codex"})]})}),s.jsx(ee,{label:"Account name",hint:"Proposed from the provider. Change it to anything you will recognise.",children:s.jsx("input",{autoFocus:!0,required:!0,maxLength:100,value:x,onChange:Z=>{j(Z.target.value),b(!0)},placeholder:"Anthropic — Personal"})}),K&&s.jsxs(s.Fragment,{children:[s.jsx(ee,{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:s.jsx("input",{required:!0,type:"url",value:v,onChange:Z=>{m(Z.target.value),S(null)}})}),s.jsx(ee,{label:"Authentication",children:s.jsxs("select",{value:f,onChange:Z=>{h(Z.target.value),g(""),S(null)},children:[s.jsx("option",{value:"api-key",children:"API key"}),s.jsx("option",{value:"none",children:"No key (local/self-hosted)"})]})})]}),f==="api-key"&&s.jsx(ee,{label:"API key",hint:"Stored in the vault, never shown again.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,value:y,onChange:Z=>{g(Z.target.value),S(null)}})}),M?s.jsx("p",{className:"muted",children:u==="codex"?"You will connect your ChatGPT subscription on the next step, with a device code, and pick a model then.":"You will connect your Claude subscription on the next step, in your browser, and pick a model then."}):s.jsxs("div",{className:"ui-field",children:[s.jsx("span",{className:"ui-field-label",children:"Model"}),k?s.jsxs("div",{className:"ui-row",children:[s.jsxs("select",{"aria-label":"Model",value:D?"__custom__":O,onChange:Z=>{Z.target.value==="__custom__"?(T(!0),L("")):(T(!1),L(Z.target.value))},children:[k.models.map(Z=>s.jsxs("option",{value:Z.id,children:[Z.name===Z.id?Z.id:`${Z.name} — ${Z.id}`,Z.isDefault?" (provider default)":"",Z.thinks?" · thinks":""]},Z.id)),s.jsx("option",{value:"__custom__",children:"Custom model…"})]}),s.jsx(R,{size:"sm",disabled:N||!W,onClick:()=>void _(),children:N?"Loading…":"Reload"})]}):s.jsxs("div",{className:"ui-row",children:[s.jsx(R,{disabled:N||!W,onClick:()=>void _(),children:N?"Loading models…":"Load models"}),K?s.jsx("span",{className:"muted",children:"Ask the endpoint what it serves."}):s.jsxs("span",{className:"muted",children:["Optional now: ",Ld[u]," is used until you pick one."]})]}),D||K&&!k?s.jsx("input",{"aria-label":"Custom model",required:K,maxLength:150,value:O,onChange:Z=>L(Z.target.value),placeholder:K?"qwen3:8b":Ld[u]}):null,P?s.jsx("span",{className:"ui-field-hint critical",role:"alert",children:P}):null,k!=null&&k.truncated?s.jsx("span",{className:"ui-field-hint",children:"Showing the first part of the provider’s list."}):null]}),s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:()=>r(),children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:X,children:"Save account"})]})]}),X&&s.jsxs("p",{className:"muted",children:["Enter an account name",K?", an endpoint and a model":""," to enable Save account."]})]})}function QL({account:e,busy:t,run:n,anthropicOAuthEnabled:r,onDone:i}){const[o,l]=d.useState(e.defaultModel),a=e.configured;return s.jsxs(G,{gap:"lg",children:[s.jsxs(V,{tone:"good",children:["Saved “",e.label,"”."]}),e.auth==="anthropic-oauth"&&!a?s.jsx(jS,{account:e,enabled:!!r,busy:t,run:n}):null,e.kind==="codex"&&!a?s.jsx(vS,{account:e,busy:t,run:n}):null,a?s.jsxs(s.Fragment,{children:[s.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."}),s.jsx(J,{valign:"end",children:s.jsx(Dm,{accountId:e.enabled?e.id:void 0,label:"Default model",value:o,onChange:l,disabled:t},`${e.id}:${e.revision}`)}),s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:i,children:"Skip for now"}),s.jsx(R,{variant:"accent",disabled:t||!o.trim(),onClick:()=>{if(o===e.defaultModel){i();return}n(()=>A.saveProviderAccount({...xS(e),defaultModel:o}),"Default model saved.").then(c=>{c&&i()})},children:"Done"})]})]}):s.jsx(J,{children:s.jsx(R,{onClick:i,children:"Finish later"})})]})}const Zv=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 JL(e){const t=e.toLowerCase().replace(/\.$/,"");if(!t.includes(".")||Zv.has(t))return!0;const n=t.slice(t.indexOf(".")+1);return Zv.has(`*.${n}`)}function XL(e){return typeof e=="string"&&e.includes("*")}function ZL(e){const t=/^(https?):\/\/([^/?#@\s]+)(?:[/?#]\S*)?$/i.exec(e.trim());if(t===null)return{ok:!1,reason:"invalid"};const[,n,r]=t;if(!r.startsWith("*.")||r.slice(2).includes("*"))return{ok:!1,reason:"placement"};let i;try{i=new URL(`${n.toLowerCase()}://${r.slice(2)}`)}catch{return{ok:!1,reason:"invalid"}}const o=i.hostname;return o===""||o.startsWith("[")||/^[\d.]+$/.test(o)||o.startsWith(".")||o.includes("..")?{ok:!1,reason:"invalid"}:JL(o)?{ok:!1,reason:"public-suffix"}:{ok:!0,value:{pattern:`${i.protocol}//*.${i.host}`,protocol:i.protocol,suffix:o,port:i.port}}}const ej=["every-time","first-time","pre-approved"],yS={"every-time":"every time","first-time":"first time only","pre-approved":"pre-approved"};function eF(e){const t=ej.indexOf(e);return ej.slice(0,t<0?1:t+1)}function wS(e){return e.endsWith(".account")}const tF="This account’s process holds the value for as long as its connection lives.",Fm="Stored, not usable until it has a binding.";function nF(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==="developer.env"?"the workspace, then the variable name — e.g. cour des comptes ADMIN_PASSWORD":wS(e)?"the account id, e.g. acct-1":'the place, as JSON — e.g. {"host":"localhost","header":"Authorization"}'}const bS={"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})},"developer.env":{hint:"a workspace, then the variable name",build:(e,t)=>({workspace:e,variable:t})}},sF="A wildcard may only stand for the leftmost part of a site, like *.wikimedia.org.",rF=e=>`That is a public suffix; ${e} would match every site.`,tj="Give the site as an origin, like https://en.wikipedia.org.";function nj(e){const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:["https:","//",e].join("");if(XL(e)){const n=ZL(t);if(n.ok)return{ok:!0,target:n.value.pattern};if(n.reason==="placement")return{ok:!1,error:sF};if(n.reason==="public-suffix"){const r=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").replace(/[/?#:].*$/,"").toLowerCase();return{ok:!1,error:rF(r)}}return{ok:!1,error:tj}}try{const n=new URL(t);if(n.origin==="null"||n.protocol!=="https:"&&n.protocol!=="http:")throw new Error("not an origin");return{ok:!0,target:n.origin}}catch{return{ok:!1,error:tj}}}function iF(e){const t=e.search(/\s\S+\s*$/);if(t<=0)return null;const n=e.slice(t).trim(),r=e.slice(0,t).trim();return r&&n?[r,n]:null}function kS(e,t){const n=t.trim();if(n==="")return{ok:!1,error:"Give the exact place this value may go."};if(n.startsWith("{"))try{const o=JSON.parse(n);return o!==null&&typeof o=="object"&&!Array.isArray(o)?{ok:!0,target:o}:{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 nj(n);if(e==="browser.native.type"||wS(e))return{ok:!0,target:n};const r=bS[e];if(r===void 0)return{ok:!0,target:n};const i=iF(n);if(i===null)return{ok:!1,error:`${e} needs both: ${r.hint}.`};if(e==="browser.form.data"){const o=nj(i[0]);return o.ok?{ok:!0,target:r.build(o.target,i[1])}:o}return{ok:!0,target:r.build(i[0],i[1])}}function oF(e){if(typeof e=="string")return e;try{return JSON.stringify(e)??""}catch{return""}}function lF(e,t){if(typeof t=="string")return t;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const n=t,r=bS[e];if(r!==void 0){const i=Object.keys(r.build("a","b")),o=i.map(l=>n[l]);if(i.every(l=>typeof n[l]=="string"))return o.join(" · ")}}try{return JSON.stringify(t)??String(t)}catch{return String(t)}}const SS="accounts.provider";function aF(e,t){for(const n of e)if(n.kind===SS&&typeof n.target=="string"){const r=t.get(n.target);if(r)return r}}function Ph(e,t,n){if(e===SS&&typeof t=="string"){const r=n.get(t);if(r)return r.label}return lF(e,t)}function NS(e){if(e==="delivered")return"good";if(e==="held"||e==="pending")return"warning";if(e==="refused"||e==="failed")return"critical"}function CS(e,t){if(typeof e!="object"||e===null)return[];const n=e[t];return Array.isArray(n)?n.flatMap(r=>{if(typeof r!="object"||r===null)return[];const i=r.place,o=r.count;return typeof i!="string"||typeof o!="number"||!(o>0)?[]:[{place:i,count:o}]}):[]}function ES(e){const t=e.map(({place:n,count:r})=>`${r.toLocaleString("en-GB")} ${r===1?n.replace(/s$/,""):n}`);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function cF(e){const t=CS(e,"found");return t.length?`The value already sits in ${ES(t)}.`:""}function uF(e){const t=CS(e,"scrubbed");return t.length?`Replaced with ‹secret:…› in ${ES(t)}.`:""}async function Ur(e,t,n,r){n(!0),r(null);try{return(await A.secretsAct(e,t)).result}catch(i){return r(i instanceof Error?i.message:String(i)),null}finally{n(!1)}}function dF({embedded:e,timezone:t}={}){const n=se(()=>A.secrets(),[]),r=se(()=>A.providerAccounts(),[]),i=d.useMemo(()=>{var c;return new Map((((c=r.data)==null?void 0:c.accounts)??[]).map(u=>[u.id,{label:u.label,provider:Lm(u)}]))},[r.data]),[o,l]=d.useState(!1),a=n.data;return s.jsxs(an,{embedded:e,title:"Keys and secrets",lede:"What the agents may use and never see: a name, a value buddi keeps, and the exact places the value may go.",children:[s.jsxs(G,{gap:"lg",children:[!a&&!n.error?s.jsx(ie,{children:"Opening the vault…"}):null,n.error?s.jsx(J,{children:s.jsx(R,{onClick:n.reload,children:"Retry"})}):null,a?s.jsx(Y,{title:"Secrets",aside:"A value the agents use and never see: bound to where it may go, never shown again.",actions:s.jsx(R,{variant:"accent",size:"sm",onClick:()=>l(!0),children:"Add a secret"}),panel:!0,children:s.jsx(G,{divided:!0,children:a.secrets.length===0?s.jsx(yt,{icon:"key",title:"Nothing stored yet",children:"Add one — a site password, an API token — and bind it to the places an agent may use it."}):a.secrets.map(c=>s.jsx(fF,{secret:c,accounts:i,destinations:a.destinations,timezone:t,onChanged:n.reload},c.name))})}):null,a?s.jsx(Y,{title:"buddi’s own keys",aside:"Read-only.",children:s.jsxs(G,{gap:"sm",children:[a.ownKeys.length===0?s.jsx(ie,{children:"No keys of buddi’s own right now."}):s.jsx("div",{className:"ui-list",children:a.ownKeys.map(c=>s.jsx("div",{className:"ui-list-row",children:s.jsx("span",{className:"ui-list-main",children:s.jsx("span",{className:"mono",children:c})})},c))}),s.jsx("p",{className:"ui-card-meta",children:"These are the keys buddi itself runs on. They cannot be bound or replaced here, and the scrubber replaces them in what buddi sends out, exactly like your own secrets."})]})}):null]}),o&&a?s.jsx(pF,{destinations:a.destinations,onClose:()=>l(!1),onChanged:n.reload}):null]})}function fF({secret:e,accounts:t,destinations:n,timezone:r,onChanged:i}){const[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(!1),[x,j]=d.useState(!1),w=async()=>{await Ur("secrets.delete",{name:e.name},l,c)!==null&&(h(!1),i())},b=e.lastUse,v=aF(e.bindings,t);return s.jsxs(G,{gap:"sm",children:[s.jsxs("div",{className:"ui-card-head",children:[s.jsx("h3",{className:"ui-card-title",children:v?v.label:e.name}),v?s.jsx(Ua,{children:v.provider}):null,e.totp?s.jsx(Ua,{children:"TOTP"}):null,b?s.jsx(pe,{tone:NS(b.outcome),children:b.outcome}):null]}),v?s.jsx("p",{className:"ui-card-meta mono",children:e.name}):null,e.bindings.length===0?s.jsx("p",{className:"ui-card-meta",children:Fm}):s.jsx("div",{className:"ui-stack","data-gap":"sm",children:e.bindings.map((m,y)=>s.jsxs("div",{className:"ui-row",children:[s.jsx(Ua,{children:m.kind}),s.jsx("span",{className:"mono",children:Ph(m.kind,m.target,t)}),s.jsx(pe,{tone:"muted",children:yS[m.rule]??m.rule})]},y))}),e.bindings.some(m=>m.heldByPlugin)?s.jsx("p",{className:"ui-card-meta",children:tF}):null,s.jsx("p",{className:"ui-card-meta",children:b?`Last used ${Se(b.at)}${b.agentId?` by ${b.agentId}`:""} — ${b.kind}, ${Ph(b.kind,b.target,t)}.`:"Never used."}),s.jsx(re,{message:a}),f?s.jsxs(V,{tone:"critical",role:"alert",children:[s.jsxs("p",{children:["Delete “",e.name,"”? The value and its bindings go; the use log stays, under the name."]}),s.jsxs(J,{children:[s.jsx(R,{variant:"danger",disabled:o,onClick:()=>void w(),children:"Delete it"}),s.jsx(R,{disabled:o,onClick:()=>h(!1),children:"Cancel"})]})]}):null,s.jsxs(J,{children:[s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("replace"),children:"Replace value"}),s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("rename"),children:"Rename"}),s.jsx(R,{size:"sm",disabled:o,onClick:()=>p("rebind"),children:e.bindings.length===0?"Add a binding":"Rebind"}),s.jsx(R,{size:"sm",variant:"danger",disabled:o,onClick:()=>h(!0),children:"Delete"}),s.jsx(R,{size:"sm",variant:"ghost","aria-expanded":x,onClick:()=>j(!x),children:"Use log"})]}),x?s.jsx(hF,{name:e.name,accounts:t,timezone:r}):null,u==="replace"?s.jsx(mF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rename"?s.jsx(gF,{secret:e,onClose:()=>p(null),onChanged:i}):null,u==="rebind"?s.jsx(xF,{secret:e,destinations:n,onClose:()=>p(null),onChanged:i}):null]})}function hF({name:e,accounts:t,timezone:n}){const r=se(()=>A.secretUses(e,50),[e]);if(r.error)return s.jsx(re,{message:r.error});if(!r.data)return s.jsx(ie,{children:"Reading the log…"});const i=r.data.uses;return i.length===0?s.jsx(ie,{children:"No uses yet."}):s.jsx("div",{className:"ui-list",children:i.map((o,l)=>s.jsxs("div",{className:"ui-list-row",children:[s.jsxs("span",{className:"ui-list-main",children:[s.jsxs("span",{className:"ui-list-title",children:[Re(o.at,n??"UTC")," — ",o.kind,", ",Ph(o.kind,o.target,t)]}),s.jsxs("span",{className:"ui-list-sub",children:[o.agent?o.agent:"the owner",o.plugin?` · ${o.plugin}`:"",o.detail?` · ${o.detail}`:""]})]}),s.jsx("span",{className:"ui-list-side",children:s.jsx(pe,{tone:NS(o.outcome),children:o.outcome})})]},l))})}function AS({name:e,result:t,scrubbed:n,busy:r,failure:i,onScrub:o,onDone:l}){const a=cF(t);return s.jsxs(G,{gap:"sm",children:[s.jsxs(V,{tone:"good",role:"status",children:["Saved “",e,"”. Its value is never shown again."]}),s.jsx("p",{className:"ui-card-meta",children:a||"Nothing of the value sits where buddi already holds text."}),s.jsx(re,{message:i}),a?s.jsx(J,{children:s.jsx(R,{variant:"accent",disabled:r||n!==null,onClick:o,children:n===null?"Scrub the history":uF(n)||"Nothing of it was left to replace."})}):null,s.jsx(J,{align:"end",children:s.jsx(R,{onClick:l,children:"Done"})})]})}function TS({destinations:e,bindings:t,disabled:n,onChange:r}){const i=(o,l)=>{r(t.map((a,c)=>c===o?{...a,...l}:a))};return s.jsx(G,{gap:"sm",children:t.map((o,l)=>{const a=e.find(u=>u.kind===o.kind),c=(a==null?void 0:a.maxRule)??o.rule;return s.jsxs(J,{valign:"end",children:[s.jsx(ee,{label:"Kind",inline:!0,children:s.jsx("select",{value:o.kind,disabled:n,onChange:u=>{var f;const p=u.target.value;i(l,{kind:p,rule:((f=e.find(h=>h.kind===p))==null?void 0:f.maxRule)??o.rule})},children:(a?e:[...e,{kind:o.kind,plugin:"",maxRule:o.rule}]).map(u=>s.jsx("option",{value:u.kind,children:u.kind},u.kind))})}),s.jsx(ee,{label:"Target",inline:!0,grow:!0,children:s.jsx("input",{type:"text",spellCheck:!1,disabled:n,value:o.target,placeholder:nF(o.kind),onChange:u=>i(l,{target:u.target.value})})}),s.jsx(ee,{label:"Rule",inline:!0,children:s.jsx("select",{value:o.rule,disabled:n,onChange:u=>i(l,{rule:u.target.value}),children:eF(c).map(u=>s.jsx("option",{value:u,children:yS[u]},u))})}),s.jsx(R,{size:"sm",variant:"ghost",disabled:n,onClick:()=>r(t.filter((u,p)=>p!==l)),children:"Remove"})]},l)})})}function pF({destinations:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,l]=d.useState(""),[a,c]=d.useState(!1),[u,p]=d.useState(()=>e.length?[{kind:e[0].kind,target:"",rule:e[0].maxRule}]:[]),[f,h]=d.useState(!1),[x,j]=d.useState(null),[w,b]=d.useState(null),[v,m]=d.useState(null),y=async()=>{const k=u.map(P=>kS(P.kind,P.target)),S=k.findIndex(P=>!P.ok);if(S!==-1){j(`Binding ${S+1}: ${k[S].error}`);return}const N=o;l("");const C=await Ur("secrets.put",{name:r.trim(),value:N,totp:a,bindings:u.map((P,E)=>({kind:P.kind,target:k[E].target,rule:P.rule}))},h,j);C!==null&&(b({name:r.trim(),result:C}),n())},g=async()=>{const k=await Ur("secrets.scrub_history",{name:(w==null?void 0:w.name)??""},h,j);k!==null&&(m(k),n())};return s.jsx(qt,{title:"Add a secret",onClose:t,children:w?s.jsx(AS,{name:w.name,result:w.result,scrubbed:v,busy:f,failure:x,onScrub:()=>void g(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:k=>{k.preventDefault(),y()},children:s.jsxs("fieldset",{disabled:f,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"Name",hint:"What an agent calls it. Saving a name that exists replaces that secret’s value.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:k=>i(k.target.value),placeholder:"PNC password"})}),s.jsx(ee,{label:"Value",hint:"Kept in the vault, never shown again — not even here.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,value:o,onChange:k=>l(k.target.value)})}),s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:k=>c(k.target.checked)}),s.jsx("span",{children:"The code comes from this secret"})]}),s.jsx("p",{className:"ui-field-hint",children:"The seed and the code are one thing buddi holds — the owner’s explicit choice per secret."}),s.jsxs("div",{className:"ui-stack","data-gap":"sm",children:[s.jsx("span",{className:"ui-field-label",children:"Bindings — the places this value may go"}),s.jsx(TS,{destinations:e,bindings:u,disabled:f,onChange:p}),u.length===0?s.jsx("p",{className:"ui-field-hint",children:Fm}):null,e.length?s.jsx(J,{children:s.jsx(R,{size:"sm",onClick:()=>p([...u,{kind:e[0].kind,target:"",rule:e[0].maxRule}]),children:"Add a binding"})}):s.jsx("p",{className:"ui-field-hint",children:"No destination is registered on this installation yet, so there is nothing to bind to."})]}),x?s.jsx(V,{tone:"critical",role:"alert",children:x}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save secret"})]})]})})})}function mF({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(""),[o,l]=d.useState(!1),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState(null),x=async()=>{const w=r;i("");const b=await Ur("secrets.put",{name:e.name,value:w,totp:e.totp,bindings:e.bindings.map(({kind:v,target:m,rule:y})=>({kind:v,target:m,rule:y}))},l,c);b!==null&&(p(b),n())},j=async()=>{const w=await Ur("secrets.scrub_history",{name:e.name},l,c);w!==null&&(h(w),n())};return s.jsx(qt,{title:`Replace the value of “${e.name}”`,onClose:t,children:u?s.jsx(AS,{name:e.name,result:u,scrubbed:f,busy:o,failure:a,onScrub:()=>void j(),onDone:t}):s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:w=>{w.preventDefault(),x()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"New value",hint:"Replaces what is stored. The bindings stay as they are.",children:s.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,required:!0,autoFocus:!0,value:r,onChange:w=>i(w.target.value)})}),a?s.jsx(V,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save value"})]})]})})})}function gF({secret:e,onClose:t,onChanged:n}){const[r,i]=d.useState(e.name),[o,l]=d.useState(!1),[a,c]=d.useState(null),u=async()=>{await Ur("secrets.rename",{name:e.name,to:r.trim()},l,c)!==null&&(n(),t())};return s.jsx(qt,{title:`Rename “${e.name}”`,onClose:t,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:p=>{p.preventDefault(),u()},children:s.jsxs("fieldset",{disabled:o,className:"ui-stack","data-gap":"sm",children:[s.jsx(ee,{label:"New name",hint:"The vault entry never moves; only the name the agents ask for does.",children:s.jsx("input",{required:!0,autoFocus:!0,maxLength:200,value:r,onChange:p=>i(p.target.value)})}),a?s.jsx(V,{tone:"critical",role:"alert",children:a}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:t,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",disabled:!r.trim()||r.trim()===e.name,children:"Save name"})]})]})})})}function xF({secret:e,destinations:t,onClose:n,onChanged:r}){const[i,o]=d.useState(()=>e.bindings.map(f=>({kind:f.kind,target:oF(f.target),rule:f.rule}))),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=async()=>{const f=i.map(j=>kS(j.kind,j.target)),h=f.findIndex(j=>!j.ok);if(h!==-1){u(`Binding ${h+1}: ${f[h].error}`);return}await Ur("secrets.rebind",{name:e.name,bindings:i.map((j,w)=>({kind:j.kind,target:f[w].target,rule:j.rule}))},a,u)!==null&&(r(),n())};return s.jsx(qt,{title:`Rebind “${e.name}”`,onClose:n,children:s.jsx("form",{className:"ui-stack","data-gap":"sm",onSubmit:f=>{f.preventDefault(),p()},children:s.jsxs("fieldset",{disabled:l,className:"ui-stack","data-gap":"sm",children:[s.jsx(TS,{destinations:t,bindings:i,disabled:l,onChange:o}),i.length===0?s.jsx("p",{className:"ui-field-hint",children:Fm}):null,t.length?s.jsx(J,{children:s.jsx(R,{size:"sm",onClick:()=>o([...i,{kind:t[0].kind,target:"",rule:t[0].maxRule}]),children:"Add a binding"})}):null,c?s.jsx(V,{tone:"critical",role:"alert",children:c}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{onClick:n,children:"Cancel"}),s.jsx(R,{type:"submit",variant:"accent",children:"Save bindings"})]})]})})})}function vF({timezone:e,embedded:t}){const{data:n,error:r,reload:i}=se(()=>A.sentinels(),[],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),u=(n==null?void 0:n.installed)??[],p=((n==null?void 0:n.runs)??[]).filter(x=>x.lastError),f=u.filter(x=>!x.enabled),h=(x,j)=>{l(x),c(null),A.setSentinelEnabled(x,j).catch(w=>c(w instanceof ce?w.message:String(w))).finally(()=>{l(null),i()})};return s.jsxs(an,{embedded:t,title:"Watchers",children:[s.jsx(re,{message:r??a}),s.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."}),p.length>0?s.jsx(V,{tone:"warning",children:p.length===1?"One watcher failed on its last run.":`${p.length} watchers failed on their last run.`}):null,f.length>0?s.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,s.jsx(Y,{title:"Installed",aside:s.jsx("a",{href:`${Ze}/alerts`,children:"See what they found"}),panel:!0,flush:!0,children:n?u.length===0?s.jsx(yt,{icon:"eye",title:"No watchers are installed",children:"Plugins bring their own."}):s.jsx(Ft,{children:u.map(x=>{const j=n.runs.find(w=>w.sentinelId===x.id);return s.jsx(Kt,{lead:s.jsx(pe,{tone:x.enabled?j!=null&&j.lastError?"critical":j?"good":void 0:"muted",children:x.enabled?j!=null&&j.lastError?"failed":j?"ok":"never ran":"off"}),title:x.description,sub:`${x.id}, every ${jF(x.every)}${j!=null&&j.lastError?`. ${j.lastError}`:""}`,side:s.jsxs(s.Fragment,{children:[s.jsx("span",{title:j?Re(j.lastRunAt,e):void 0,children:j?Se(j.lastRunAt):"never ran"}),s.jsx(R,{size:"sm",disabled:o===x.id,onClick:()=>h(x.id,!x.enabled),children:x.enabled?"Turn off":"Turn on"})]})},x.id)})}):s.jsx(ie,{children:"Loading…"})})]})}function jF(e){if(e%86400===0){const n=e/86400;return n===1?"day":`${n} days`}if(e%3600===0){const n=e/3600;return n===1?"hour":`${n} hours`}const t=Math.max(1,Math.round(e/60));return t===1?"minute":`${t} minutes`}function yF({embedded:e}){const{data:t,error:n,reload:r}=se(()=>A.owner(),[]);return s.jsxs(an,{embedded:e,title:"You",lede:"What every agent knows about the person it is talking to.",children:[s.jsx(re,{message:n}),t?s.jsx(wF,{initial:t,onSaved:r}):null]})}function wF({initial:e,onSaved:t}){const[n,r]=d.useState(e.preferredName??""),[i,o]=d.useState(e.timezone??""),[l,a]=d.useState(e.language??""),[c,u]=d.useState(e.about??""),[p,f]=d.useState(!1),[h,x]=d.useState(!1),[j,w]=d.useState(null);d.useEffect(()=>{r(e.preferredName??""),o(e.timezone??""),a(e.language??""),u(e.about??"")},[e]);const b=n.trim()!==(e.preferredName??"")||i!==(e.timezone??"")||l.trim()!==(e.language??"")||c.trim()!==(e.about??""),v=async()=>{f(!0),w(null);try{await A.setOwner({preferredName:n.trim()===""?null:n.trim(),timezone:i===""?null:i,language:l.trim()===""?null:l.trim(),about:c.trim()===""?null:c.trim()}),x(!0),t()}catch(y){w(y instanceof ce?y.message:String(y))}finally{f(!1)}},m=e.zones.length>0?e.zones:[e.detectedTimezone];return s.jsx(Y,{title:"Your profile",aside:"read by every agent, as context",panel:!0,foot:s.jsxs(s.Fragment,{children:[h&&!b?s.jsx("span",{className:"muted",children:"Saved"}):null,s.jsx(R,{variant:"accent",disabled:!b||p,onClick:()=>void v(),children:p?"Saving…":"Save"})]}),children:s.jsxs(G,{divided:!0,gap:"lg",children:[s.jsx(Y,{title:"Name and place",children:s.jsxs(Ts,{children:[s.jsx(ee,{label:"What the agents call you",children:s.jsx("input",{value:n,maxLength:80,placeholder:e.displayName??"Your name",onChange:y=>{x(!1),r(y.target.value)}})}),s.jsx(ee,{label:"Timezone",hint:`This host is in ${e.detectedTimezone}. Existing schedules keep the zone they were made in.`,children:s.jsxs("select",{value:i,onChange:y=>{x(!1),o(y.target.value)},children:[s.jsx("option",{value:"",children:"Not set (use the host's)"}),m.map(y=>s.jsx("option",{value:y,children:y},y))]})}),s.jsx(ee,{label:"Answer me in",hint:"A language, as you would say it. Blank mirrors whatever you write in.",children:s.jsx("input",{value:l,maxLength:40,placeholder:"English, français…",onChange:y=>{x(!1),a(y.target.value)}})})]})}),s.jsxs(Y,{title:"About you",children:[s.jsx(ee,{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:s.jsx("textarea",{rows:4,maxLength:1e3,value:c,placeholder:"I run a small studio and prefer short answers with the numbers first. Call me by my first name.",onChange:y=>{x(!1),u(y.target.value)}})}),j?s.jsx(V,{tone:"critical",children:j}):null]})]})})}const bF=2e6;function sj(e,t){const n=e.replace(/\r\n/g,`
|
|
109
|
-
`).replace(/\n+$/,"").split(`
|
|
110
|
-
`),r=t.replace(/\r\n/g,`
|
|
111
|
-
`).replace(/\n+$/,"").split(`
|
|
112
|
-
`);if(e.trim()===t.trim())return"(no change)";if(n.length*r.length>bF)return[...n.map(c=>`-${c}`),...r.map(c=>`+${c}`)].join(`
|
|
113
|
-
`);const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let c=n.length-1;c>=0;c--)for(let u=r.length-1;u>=0;u--)i[c][u]=n[c]===r[u]?i[c+1][u+1]+1:Math.max(i[c+1][u],i[c][u+1]);const o=[];let l=0,a=0;for(;l<n.length&&a<r.length;)n[l]===r[a]?(o.push(` ${n[l]}`),l++,a++):i[l+1][a]>=i[l][a+1]?o.push(`-${n[l++]}`):o.push(`+${r[a++]}`);for(;l<n.length;)o.push(`-${n[l++]}`);for(;a<r.length;)o.push(`+${r[a++]}`);return o.join(`
|
|
114
|
-
`)}const kF={skill:"skill",policy:"rule",change:"change to itself"};function SF(e){return e===null||typeof e!="object"||Array.isArray(e)?String(e??""):Object.entries(e).filter(([t,n])=>!/Id$/.test(t)&&n!==null&&n!==void 0&&n!=="").map(([t,n])=>`${t} ${typeof n=="object"?JSON.stringify(n):String(n)}`).join(" · ")}function Ih(e){return[...new Set(e.split(/[,\n]/).map(t=>t.trim().replace(/^[-*]\s+/,"")).filter(t=>t!==""))]}function NF(e,t){const n=e.change;if(!n||n.part!=="tools")return[];if(t===e.editable)return n.added;const r=new Set(Ih(n.current??""));return Ih(t).filter(i=>!r.has(i))}function rj(e,t){return!t||e.kind==="policy"&&e.payload.plugin===t}function CF({embedded:e,plugin:t}){const{data:n,error:r,reload:i}=se(()=>A.proposals(),[],3e4),[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(null),[f,h]=d.useState({}),x=async(v,m,y=!1)=>{l(null),c(null),p(v),h(({[v]:g,...k})=>k);try{c(await m()),i()}catch(g){const k=g instanceof Error?g.message:String(g);y?h(S=>({...S,[v]:k})):l(k)}finally{p(null)}},j=Nk(),w=((n==null?void 0:n.open)??[]).filter(v=>rj(v,t)),b=((n==null?void 0:n.closed)??[]).filter(v=>rj(v,t));return s.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. Nothing here applies itself. Keep what is right, correct what is nearly right, discard the rest.",children:[s.jsx(re,{message:r??o}),t?s.jsxs(V,{role:"status",children:["Showing the rules ",t," proposes. ",s.jsx("a",{href:st("proposals"),children:"Show every proposal"})]}):null,a?s.jsx(V,{tone:"good",role:"status",children:a}):null,t?null:s.jsx(Ck,{offers:j.offers,reload:j.reload}),!n||w.length===0?s.jsx(Y,{title:"Waiting",panel:!0,children:n?t?s.jsx(yt,{icon:"bulb",title:`No rule from ${t} is waiting`,children:"It proposes one when you decide the same way several times running."}):s.jsx(yt,{icon:"bulb",title:"Nothing proposed",children:"When an agent learns something worth keeping, it waits here."}):s.jsx(ie,{children:"Loading…"})}):s.jsx(Y,{title:"Waiting",aside:`${w.length} to decide`,children:w.map(v=>s.jsx(RF,{proposal:v,busy:u===v.id,refusal:f[v.id]??null,onKeep:m=>void x(v.id,async()=>{const y=await A.keepProposal(v.id,m);return`${v.title}: ${y.note}`},!0),onDiscard:m=>void x(v.id,async()=>(await A.discardProposal(v.id,m),`Discarded: ${v.title}. ${v.agent} will be told once and will not propose it again for 90 days.`))},v.id))}),b.length>0?s.jsx(Y,{title:`Kept, discarded and expired (${b.length})`,aside:"These stop being shown a week after they were decided.",panel:!0,flush:!0,children:s.jsx(Ft,{children:b.map(v=>{var m;return s.jsx(Kt,{title:v.title,sub:`${v.agent}: ${EF(v)}`,side:v.kind==="skill"&&v.state==="kept"&&((m=v.skill)!=null&&m.live)?s.jsxs(J,{align:"end",children:[s.jsx("span",{className:"muted",children:Se(v.decidedAt??v.createdAt)}),s.jsx(R,{size:"sm",variant:"ghost",disabled:u===v.id,onClick:()=>void x(v.id,async()=>{const y=v.skill;return await A.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"})]}):Se(v.decidedAt??v.createdAt)},v.id)})})}):null,!t&&(n!=null&&n.digest)?s.jsx(TF,{schedule:n.digest.schedule,onSaved:i}):null]})}function EF(e){switch(e.state){case"kept":return 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 AF=Array.from({length:24},(e,t)=>t),ij=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function TF({schedule:e,onSaved:t}){const[n,r]=d.useState(e.day),[i,o]=d.useState(e.hour),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=n!==e.day||i!==e.hour,f=async()=>{a(!0),u(null);try{await A.setDigestSchedule(n,i),u({tone:"good",text:`The digest now runs on ${ij[n]} at ${String(i).padStart(2,"0")}:00.`}),t()}catch(h){u({tone:"critical",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}};return s.jsx(Y,{title:"Weekly digest",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:l||!p,onClick:()=>void f(),children:"Save"}),children:s.jsxs(G,{children:[s.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: ${Se(e.next)}.`:""]}),s.jsxs(J,{children:[s.jsx(ee,{label:"Day",children:s.jsx("select",{value:n,disabled:l,onChange:h=>r(Number(h.target.value)),children:ij.map((h,x)=>s.jsx("option",{value:x,children:h},h))})}),s.jsx(ee,{label:`Hour (${e.timezone})`,children:s.jsx("select",{value:i,disabled:l,onChange:h=>o(Number(h.target.value)),children:AF.map(h=>s.jsxs("option",{value:h,children:[String(h).padStart(2,"0"),":00"]},h))})})]}),c?s.jsx(V,{tone:c.tone,role:"status",children:c.text}):null]})})}function oj(e,t){return e==="tools"?Ih(t).join(`
|
|
115
|
-
`):t}function RF({proposal:e,busy:t,refusal:n,onKeep:r,onDiscard:i}){const[o,l]=d.useState(e.editable??""),[a,c]=d.useState(""),u=e.editable!==null&&o!==e.editable,p=e.payload,f=e.echoes??[],h=e.kind==="change"?e.change??null:null,x=NF(e,o);return s.jsx(Fr,{tone:e.untrusted?"warning":"accent",title:e.title,meta:s.jsxs(s.Fragment,{children:[s.jsx(pe,{children:kF[e.kind]}),s.jsx(pe,{mono:!0,children:e.agent}),e.untrusted?s.jsx(pe,{tone:"warning",children:"untrusted text in view"}):null,x.length>0?s.jsx(pe,{tone:"warning",children:"widens its tools"}):null]}),foot:s.jsxs(J,{align:"end",children:[n?s.jsx("span",{className:"proposal-refusal",role:"alert",children:n}):null,s.jsx("input",{"aria-label":"Reason for discarding (optional)",placeholder:"Reason for discarding (optional)",value:a,maxLength:300,disabled:t,onChange:j=>c(j.target.value)}),s.jsx(R,{variant:"ghost",size:"sm",disabled:t,onClick:()=>i(a.trim()||void 0),children:"Discard"}),s.jsx(R,{variant:"accent",size:"sm",disabled:t||e.editable!==null&&o.trim()==="",onClick:()=>r(u?o:void 0),children:u?"Keep my version":"Keep"})]}),children:s.jsxs(G,{gap:"sm",children:[e.why?s.jsx("p",{children:e.why}):null,s.jsxs("p",{className:"ui-card-meta",children:["Proposed by ",e.agent," ",Se(e.createdAt),e.conversationId?s.jsxs(s.Fragment,{children:[" in ",s.jsx("a",{href:zi(e.conversationId),children:e.turn?`this conversation, turn ${e.turn}`:"this conversation"})]}):null,"."]}),e.untrusted?s.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.",s.jsx("ul",{className:"proposal-sources",children:e.sources.map(j=>s.jsx("li",{className:"mono",children:j},j))}),f.length>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"proposal-echo-lede",children:"These sentences of it also appear in that text:"}),s.jsx("ul",{className:"proposal-sources","aria-label":"Sentences found in the untrusted text",children:f.map(j=>s.jsx("li",{children:s.jsx("mark",{className:"wb-diff-mark",children:j})},j))})]}):null]}):null,e.kind==="skill"?s.jsxs(s.Fragment,{children:[typeof p.when=="string"?s.jsxs("p",{className:"ui-card-meta",children:["When: ",p.when]}):null,e.skill?s.jsxs(G,{gap:"sm",children:[s.jsxs("p",{className:"ui-card-meta",children:[e.agent," already has this skill (",s.jsxs("a",{href:ft(e.agent,"skills"),children:[e.skill.name,", version ",e.skill.version]}),"). Keeping this writes version ",e.skill.version+1,"; the earlier ones stay readable."]}),s.jsx(Cc,{text:sj(e.skill.steps,o),marks:f,label:`Version ${e.skill.version} against this proposal`})]}):null,s.jsx(ee,{label:"The steps, as it would follow them",hint:"Correct them here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:j=>l(j.target.value)})})]}):null,e.kind==="change"?s.jsxs(s.Fragment,{children:[x.length>0?s.jsxs(V,{tone:"warning",title:`Adds: ${x.join(", ")}`,children:["Keeping this lets ",e.agent," call tools it cannot call now."]}):null,h!=null&&h.refusal&&!u?s.jsx(V,{tone:"warning",title:"Keeping this as proposed will be refused.",children:h.refusal}):null,h&&h.current!==null?s.jsx(Cc,{text:sj(oj(h.part,h.current),oj(h.part,o)),marks:f,label:`${e.agent}'s ${h.part==="tools"?"tool list":"instructions"} now, against this proposal`}):typeof p.before=="string"?s.jsx(wt,{summary:`What its ${p.part==="tools"?"tool list":"instructions"} said when proposed`,children:s.jsx(at,{children:p.before})}):null,s.jsx(ee,{label:p.part==="tools"?"Proposed tool list":"Proposed instructions",hint:"Correct it here and keep your version.",children:s.jsx("textarea",{rows:8,value:o,disabled:t,onChange:j=>l(j.target.value)})})]}):null,e.kind==="policy"?s.jsx(At,{items:[{label:"Plugin",value:s.jsx("span",{className:"mono",children:String(p.plugin??"")})},{label:"Matches",value:s.jsx("span",{className:"mono",children:SF(p.matcher??{})})},{label:"Does",value:String(p.action??"")},{label:"Learned from",value:(()=>{const j=Array.isArray(p.verdicts)?p.verdicts.length:0;return`${j} ${j===1?"decision":"decisions"}`})()}]}):null]})})}const PF=1500,IF={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."},MF="Restart buddi to load it. In a checkout, stop it and run: buddi serve",RS=[{id:"npm",label:"From npm"},{id:"file",label:"A file"},{id:"directory",label:"A directory I built"}],PS="buddi.plugins.install-mode";function $F(){try{const e=window.localStorage.getItem(PS);if(RS.some(t=>t.id===e))return e}catch{}return"npm"}function _F(e){try{window.localStorage.setItem(PS,e)}catch{}}const xa=".tgz";function OF(e){const t=[],n=(r,i,o)=>{r>0&&t.push(`${r} ${r===1?i:o}`)};return n(e.tools,"tool","tools"),n(e.sentinels,"watcher","watchers"),n(e.views,"view","views"),n(e.agents,"agent","agents"),t.length===0?"nothing on its own":t.join(", ")}function IS(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 DF(e,t){return e.kind==="directory"?"you, from this machine":e.kind==="tarball"?"a file on this machine":t??"nobody npm will name"}function LF(e){const[t,n]=d.useState(void 0),[r,i]=d.useState(null);return d.useEffect(()=>{if(!e){n(void 0),i(null);return}let o=!1;const l=()=>{A.pluginJob(e).then(c=>{o||(n(c),(c.phase==="done"||c.phase==="failed")&&(o=!0))}).catch(c=>{o||(i(c instanceof ce?c.message:String(c)),o=!0)})};l();const a=window.setInterval(l,PF);return()=>{o=!0,window.clearInterval(a)}},[e]),{job:t,error:r}}function FF(){const e=se(()=>A.plugins(),[],2e4),[t,n]=d.useState(null),{job:r,error:i}=LF(t),[o,l]=d.useState(null),[a,c]=d.useState(null);d.useEffect(()=>{((r==null?void 0:r.phase)==="done"||(r==null?void 0:r.phase)==="failed")&&e.reload()},[r==null?void 0:r.phase]);const u=e.data,p=(u==null?void 0:u.checkout)??!0;return s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:e.error??o??i}),u!=null&&u.unavailable?s.jsx(V,{tone:"warning",children:u.unavailable}):null,s.jsx(Y,{title:"Plugins",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(V,{tone:"warning",children:(u==null?void 0:u.trust)??""})}),s.jsx(Y,{children:s.jsx(UF,{busy:r!==void 0&&r.phase!=="done"&&r.phase!=="failed",onStaged:f=>{l(null),c(null),n(f)},onFailed:l})}),r?s.jsx(Y,{children:s.jsxs(V,{tone:r.phase==="failed"?"critical":r.phase==="done"?"good":void 0,role:"status",children:[IF[r.phase]," ",r.error??""]})}):null]})}),((u==null?void 0:u.staged)??[]).map(f=>s.jsx(WF,{staged:f,onInstalled:h=>{c(h),n(null),e.reload()},onGone:()=>e.reload()},f.id)),a||u!=null&&u.restartNeeded?s.jsx(HF,{checkout:p,name:a}):null,s.jsx(Y,{title:"Installed",panel:!0,children:u?u.installed.length===0?s.jsx(yt,{icon:"plug",title:"Nothing installed yet",children:"Only what buddi ships with is here."}):s.jsx(G,{divided:!0,children:u.installed.map(f=>s.jsx(Y,{children:s.jsx(KF,{plugin:f,onChanged:()=>e.reload(),onFailed:l})},f.name))}):s.jsx(ie,{children:"Loading…"})}),((u==null?void 0:u.builtIn)??[]).length>0?s.jsx(Y,{title:"Ships with buddi",panel:!0,children:s.jsx(G,{divided:!0,children:((u==null?void 0:u.builtIn)??[]).map(f=>s.jsx(Y,{children:s.jsx(zF,{plugin:f})},f.name))})}):null]})}function zF({plugin:e}){return s.jsxs(G,{gap:"sm",children:[s.jsx(At,{items:[{label:s.jsx("span",{children:e.name}),value:s.jsxs("span",{children:[e.version," · ",OF(e.contribution)]})}]}),e.description?s.jsx("p",{className:"ui-card-meta",children:e.description}):null]})}function UF({busy:e,onStaged:t,onFailed:n}){const[r,i]=d.useState($F),[o,l]=d.useState(""),[a,c]=d.useState(!1),[u,p]=d.useState(null),[f,h]=d.useState(null),[x,j]=d.useState(!1),w=d.useRef(null),b=g=>n(g instanceof ce?g.message:String(g)),v=g=>{i(g),_F(g),h(null)},m=()=>{c(!0),A.stagePlugin(o.trim()).then(g=>{t(g.job.id),l("")}).catch(b).finally(()=>c(!1))},y=g=>{if(g){if(!g.name.toLowerCase().endsWith(xa)){p(null),h(`${g.name} is not a ${xa}. A packed plugin is the file npm pack writes.`);return}h(null),p(g.name),c(!0),A.uploadPlugin(g).then(k=>t(k.job.id)).catch(b).finally(()=>c(!1))}};return s.jsxs(G,{gap:"sm",children:[s.jsx("div",{className:"plugin-modes",role:"radiogroup","aria-label":"Where it comes from",children:RS.map(g=>s.jsx("button",{type:"button",role:"radio","aria-checked":r===g.id,className:"plugin-mode","data-chosen":r===g.id?"true":void 0,onClick:()=>v(g.id),children:g.label},g.id))}),r==="file"?s.jsxs("div",{className:"plugin-drop",role:"group","aria-label":"A plugin file","data-state":x?"over":f?"refused":u?"chosen":void 0,onDragOver:g=>{g.preventDefault(),j(!0)},onDragLeave:()=>j(!1),onDrop:g=>{var k,S;g.preventDefault(),j(!1),y((S=(k=g.dataTransfer)==null?void 0:k.files)==null?void 0:S[0])},children:[s.jsx("p",{className:"ui-card-meta",children:f??(u?`${u} — reading it.`:`Drop a ${xa} here, or choose one.`)}),s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||a,onClick:()=>{var g;return(g=w.current)==null?void 0:g.click()},children:"Choose a file"})}),s.jsx("input",{ref:w,type:"file",accept:xa,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:g=>{var k;y((k=g.target.files)==null?void 0:k[0]),g.target.value=""}})]}):s.jsxs(s.Fragment,{children:[s.jsx(ee,{label:r==="npm"?"Install a plugin":"The directory it is in",hint:r==="npm"?"A package name, or a name@version.":"The folder with its package.json, already built.",children:s.jsx("input",{type:"text",value:o,placeholder:r==="npm"?"buddi-plugin-weather":"/home/you/code/buddi-plugin-weather",onChange:g=>l(g.target.value)})}),s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:e||a||o.trim()==="",onClick:m,children:"Read it first"})})]})]})}function BF({staged:e}){var r,i;const t=((r=e.uses)==null?void 0:r.areas)??[],n=((i=e.uses)==null?void 0:i.dropped)??[];return s.jsx(Y,{title:"What it reaches in buddi",children:s.jsxs(G,{gap:"sm",children:[t.length===0?s.jsx("p",{className:"ui-card-meta",children:"Nothing beyond its own tables, its own folder and its own tools' approvals."}):s.jsx("ul",{className:"plugin-uses",children:t.map(o=>s.jsxs("li",{children:["It ",o.words,"."," ",o.added?s.jsxs(pe,{tone:"warning",children:["new in ",e.version]}):null]},o.use))}),n.length>0?s.jsxs("p",{className:"ui-card-meta",children:["No longer: ",n.map(o=>o.words).join("; "),"."]}):null]})})}function WF({staged:e,onInstalled:t,onGone:n}){const[r,i]=d.useState(e.plan??null),[o,l]=d.useState(!1),[a,c]=d.useState(null),u=h=>{l(!0),c(null),A.approveStaged(e.id,{integrity:e.integrity??"",...h?{acknowledgeDrift:!0}:{}}).then(x=>{x.installed?t(e.name):x.plan&&i(x.plan)}).catch(x=>c(x instanceof ce?x.message:String(x))).finally(()=>l(!1))},p=()=>{l(!0),c(null),A.rejectStaged(e.id).then(()=>n()).catch(h=>c(h instanceof ce?h.message:String(h))).finally(()=>l(!1))},f=(r==null?void 0:r.drift)??[];return s.jsxs(G,{gap:"lg",children:[s.jsx(Fr,{tone:"accent",title:`${e.name} ${e.version}`,meta:s.jsx(pe,{tone:"muted",children:"read, not installed"}),children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:a}),s.jsx(At,{items:[{label:"From",value:e.uploadedName?`a file you chose · ${e.uploadedName}`:IS(e.source)},{label:"Published by",value:e.publisher??"nobody npm will name"},{label:"Integrity",value:s.jsx("span",{className:"mono",children:e.integrity===void 0||e.integrity===""?"none — this came off a disk":e.integrity})},...e.stagedHash?[{label:"Files on disk",value:s.jsx("span",{className:"mono",children:e.stagedHash})}]:[],{label:"Dependencies",value:e.dependencies.count===0?"none":`${e.dependencies.count}${e.dependencies.withScripts.length===0?", none of which run install scripts":`, of which these run install scripts: ${e.dependencies.withScripts.join(", ")}`}`}]}),s.jsx(BF,{staged:e}),s.jsx(Y,{title:"What the package says about itself",children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"This is its claim, taken from its own buddi.md. Nothing has checked it yet."}),s.jsx(At,{items:[{label:"Schema it owns",value:e.claims.schema??"it claims none"},{label:"Hosts it reaches",value:e.claims.hosts.length===0?"it claims none":e.claims.hosts.join(", ")}]}),e.claims.missing?s.jsx("p",{className:"ui-card-meta",children:"It ships no buddi.md, so it says nothing about itself at all."}):s.jsx("p",{className:"ui-card-meta",children:e.claims.text})]})}),s.jsxs(J,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:o,onClick:p,children:"Not this one"}),s.jsx(R,{variant:"accent",disabled:o||f.length>0,onClick:()=>u(!1),children:"Install"})]})]})}),f.length>0?s.jsx(Fr,{tone:"warning",title:"What it said, and what it does",meta:s.jsx(pe,{tone:"warning",children:"read this first"}),children:s.jsxs(G,{gap:"sm",children:[s.jsx("p",{className:"ui-card-meta",children:"Its prose and its manifest do not agree. Neither is authoritative; the manifest is what actually runs."}),s.jsx("ul",{className:"plugin-drift",children:f.map(h=>s.jsx("li",{children:h},h))}),s.jsx(MS,{unlocks:(r==null?void 0:r.agents)??[]}),s.jsxs(J,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:o,onClick:p,children:"Not this one"}),s.jsx(R,{variant:"danger",disabled:o,onClick:()=>u(!0),children:"Install anyway"})]})]})}):null]})}function HF({checkout:e,name:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(null),l=t?`${t} is installed.`:"Something is installed that this buddi has not loaded.";return s.jsx(Y,{title:"Restart to load it",panel:!0,children:s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:i}),s.jsxs(V,{tone:e?"warning":void 0,role:"status",children:[l," ",e?MF:"Its tools appear once buddi restarts. That closes this dashboard for a few seconds."]}),e?null:s.jsx(J,{align:"end",children:s.jsx(R,{variant:"accent",disabled:n,onClick:()=>{r(!0),o(null),A.serviceAction("restart").catch(a=>o(a instanceof ce?a.message:String(a))).finally(()=>r(!1))},children:"Restart to load it"})})]})})})}function MS({plugin:e,unlocks:t}){return t.length===0?null:s.jsx(Y,{title:"Agents it would unlock",children:s.jsxs(G,{gap:"sm",divided:!0,children:[t.map(n=>s.jsx(VF,{plugin:e,unlock:n},n.id)),s.jsxs("p",{className:"ui-card-meta",children:["Nothing here is created by installing. Accept creates the agent with the tools listed. You can change or remove it ",s.jsx("a",{href:et,children:"on the Agents page"}),"."]})]})})}function VF({plugin:e,unlock:t}){const n=bk(e,t.id),r=t.drift.state!=="not-accepted";return s.jsxs(G,{gap:"sm",children:[s.jsxs(J,{children:[s.jsxs("span",{className:"mono",children:["@",t.handle]}),s.jsx(pe,{tone:t.drift.state==="up-to-date"?"good":"warning",children:t.drift.state}),s.jsx("span",{className:"ui-card-meta",children:t.drift.message}),s.jsx(ro,{}),e&&!r&&!n.created?s.jsx(R,{size:"sm",disabled:n.busy,onClick:n.accept,children:"Accept"}):null]}),s.jsx(re,{message:n.failure}),n.created?s.jsx(kk,{agent:n.created}):null]})}function KF({plugin:e,onChanged:t,onFailed:n}){const[r,i]=d.useState(!1),[o,l]=d.useState(!1),[a,c]=d.useState(""),[u,p]=d.useState(!1),f=x=>{p(!0),x.then(()=>{i(!1),l(!1),c(""),t()}).catch(j=>n(j instanceof ce?j.message:String(j))).finally(()=>p(!1))},h=e.contribution;return s.jsxs(G,{gap:"sm",children:[s.jsx(Fr,{tone:e.loaded?void 0:"critical",title:`${e.name} ${e.version}`,meta:e.loaded?s.jsx(pe,{tone:"good",children:"loaded"}):s.jsx(pe,{tone:"critical",children:"did not load"}),actions:s.jsxs(J,{align:"end",children:[s.jsx(R,{size:"sm",variant:"ghost",disabled:u,onClick:()=>i(!r),children:"Remove…"}),s.jsx(R,{size:"sm",disabled:u,onClick:()=>f(A.updatePlugin(e.name)),children:"Update"})]}),children:s.jsxs(G,{gap:"sm",children:[e.error?s.jsx(V,{tone:"critical",children:e.error}):null,s.jsx(At,{items:[{label:"From",value:IS(e.source)},{label:"Published by",value:DF(e.source,e.publisher)},{label:"Installed",value:Se(e.installedAt)},{label:"Contributes",value:`${h.tools} tool${h.tools===1?"":"s"}, ${h.sentinels} on a timer, ${h.views} view${h.views===1?"":"s"}, ${h.agents} agent${h.agents===1?"":"s"} proposed`}]}),s.jsx(MS,{plugin:e.name,unlocks:e.unlocks})]})}),r?s.jsxs(G,{gap:"sm",children:[s.jsx(V,{tone:"warning",children:"Removing it stops its code loading and leaves its tables exactly where they are, so installing it again picks up where it left off."}),s.jsxs("label",{className:"plugin-check",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:x=>{l(x.target.checked),c("")}}),s.jsx("span",{children:"Also drop its data. Its tables are not recoverable afterwards."})]}),o?s.jsx(ee,{label:`Type ${e.name} to confirm`,children:s.jsx("input",{value:a,onChange:x=>c(x.target.value)})}):null,s.jsxs(J,{align:"end",children:[s.jsx(R,{variant:"ghost",disabled:u,onClick:()=>{i(!1),l(!1),c("")},children:"Cancel"}),s.jsx(R,{variant:"danger",disabled:u||o&&a.trim()!==e.name,onClick:()=>f(A.uninstallPlugin(e.name,o?{purge:!0,confirm:a.trim()}:{})),children:o?"Remove and drop its data":"Remove"})]})]}):null]})}var Nl={},GF=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},$S={},jn={};let zm;const YF=[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];jn.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};jn.getSymbolTotalCodewords=function(t){return YF[t]};jn.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};jn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');zm=t};jn.isKanjiModeEnabled=function(){return typeof zm<"u"};jn.toSJIS=function(t){return zm(t)};var ju={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.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: "+n)}}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}}})(ju);function _S(){this.buffer=[],this.length=0}_S.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 n=0;n<t;n++)this.putBit((e>>>t-n-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 qF=_S;function Cl(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)}Cl.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Cl.prototype.get=function(e,t){return this.data[e*this.size+t]};Cl.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Cl.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var QF=Cl,OS={};(function(e){const t=jn.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,o=t(r),l=o===145?26:Math.ceil((o-13)/(2*i-2))*2,a=[o-7];for(let c=1;c<i-1;c++)a[c]=a[c-1]-l;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],o=e.getRowColCoords(r),l=o.length;for(let a=0;a<l;a++)for(let c=0;c<l;c++)a===0&&c===0||a===0&&c===l-1||a===l-1&&c===0||i.push([o[a],o[c]]);return i}})(OS);var DS={};const JF=jn.getSymbolSize,lj=7;DS.getPositions=function(t){const n=JF(t);return[[0,0],[n-lj,0],[0,n-lj]]};var LS={};(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 o=i.size;let l=0,a=0,c=0,u=null,p=null;for(let f=0;f<o;f++){a=c=0,u=p=null;for(let h=0;h<o;h++){let x=i.get(f,h);x===u?a++:(a>=5&&(l+=t.N1+(a-5)),u=x,a=1),x=i.get(h,f),x===p?c++:(c>=5&&(l+=t.N1+(c-5)),p=x,c=1)}a>=5&&(l+=t.N1+(a-5)),c>=5&&(l+=t.N1+(c-5))}return l},e.getPenaltyN2=function(i){const o=i.size;let l=0;for(let a=0;a<o-1;a++)for(let c=0;c<o-1;c++){const u=i.get(a,c)+i.get(a,c+1)+i.get(a+1,c)+i.get(a+1,c+1);(u===4||u===0)&&l++}return l*t.N2},e.getPenaltyN3=function(i){const o=i.size;let l=0,a=0,c=0;for(let u=0;u<o;u++){a=c=0;for(let p=0;p<o;p++)a=a<<1&2047|i.get(u,p),p>=10&&(a===1488||a===93)&&l++,c=c<<1&2047|i.get(p,u),p>=10&&(c===1488||c===93)&&l++}return l*t.N3},e.getPenaltyN4=function(i){let o=0;const l=i.data.length;for(let c=0;c<l;c++)o+=i.data[c];return Math.abs(Math.ceil(o*100/l/5)-10)*t.N4};function n(r,i,o){switch(r){case e.Patterns.PATTERN000:return(i+o)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(i+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return i*o%2+i*o%3===0;case e.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case e.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,o){const l=o.size;for(let a=0;a<l;a++)for(let c=0;c<l;c++)o.isReserved(c,a)||o.xor(c,a,n(i,c,a))},e.getBestMask=function(i,o){const l=Object.keys(e.Patterns).length;let a=0,c=1/0;for(let u=0;u<l;u++){o(u),e.applyMask(u,i);const p=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(u,i),p<c&&(c=p,a=u)}return a}})(LS);var yu={};const Ks=ju,va=[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],ja=[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];yu.getBlocksCount=function(t,n){switch(n){case Ks.L:return va[(t-1)*4+0];case Ks.M:return va[(t-1)*4+1];case Ks.Q:return va[(t-1)*4+2];case Ks.H:return va[(t-1)*4+3];default:return}};yu.getTotalCodewordsCount=function(t,n){switch(n){case Ks.L:return ja[(t-1)*4+0];case Ks.M:return ja[(t-1)*4+1];case Ks.Q:return ja[(t-1)*4+2];case Ks.H:return ja[(t-1)*4+3];default:return}};var FS={},wu={};const zo=new Uint8Array(512),Mc=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)zo[n]=t,Mc[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)zo[n]=zo[n-255]})();wu.log=function(t){if(t<1)throw new Error("log("+t+")");return Mc[t]};wu.exp=function(t){return zo[t]};wu.mul=function(t,n){return t===0||n===0?0:zo[Mc[t]+Mc[n]]};(function(e){const t=wu;e.mul=function(r,i){const o=new Uint8Array(r.length+i.length-1);for(let l=0;l<r.length;l++)for(let a=0;a<i.length;a++)o[l+a]^=t.mul(r[l],i[a]);return o},e.mod=function(r,i){let o=new Uint8Array(r);for(;o.length-i.length>=0;){const l=o[0];for(let c=0;c<i.length;c++)o[c]^=t.mul(i[c],l);let a=0;for(;a<o.length&&o[a]===0;)a++;o=o.slice(a)}return o},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let o=0;o<r;o++)i=e.mul(i,new Uint8Array([1,t.exp(o)]));return i}})(FS);const zS=FS;function Um(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Um.prototype.initialize=function(t){this.degree=t,this.genPoly=zS.generateECPolynomial(this.degree)};Um.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=zS.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r};var XF=Um,US={},gr={},Bm={};Bm.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var us={};const BS="[0-9]+",ZF="[A-Z $%*+\\-./:]+";let hl="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";hl=hl.replace(/u/g,"\\u");const e4="(?:(?![A-Z0-9 $%*+\\-./:]|"+hl+`)(?:.|[\r
|
|
116
|
-
]))+`;us.KANJI=new RegExp(hl,"g");us.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");us.BYTE=new RegExp(e4,"g");us.NUMERIC=new RegExp(BS,"g");us.ALPHANUMERIC=new RegExp(ZF,"g");const t4=new RegExp("^"+hl+"$"),n4=new RegExp("^"+BS+"$"),s4=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");us.testKanji=function(t){return t4.test(t)};us.testNumeric=function(t){return n4.test(t)};us.testAlphanumeric=function(t){return s4.test(t)};(function(e){const t=Bm,n=us;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(o,l){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?o.ccBits[0]:l<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.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(o,l){if(e.isValid(o))return o;try{return r(o)}catch{return l}}})(gr);(function(e){const t=jn,n=yu,r=ju,i=gr,o=Bm,l=7973,a=t.getBCHDigit(l);function c(h,x,j){for(let w=1;w<=40;w++)if(x<=e.getCapacity(w,j,h))return w}function u(h,x){return i.getCharCountIndicator(h,x)+4}function p(h,x){let j=0;return h.forEach(function(w){const b=u(w.mode,x);j+=b+w.getBitsLength()}),j}function f(h,x){for(let j=1;j<=40;j++)if(p(h,j)<=e.getCapacity(j,x,i.MIXED))return j}e.from=function(x,j){return o.isValid(x)?parseInt(x,10):j},e.getCapacity=function(x,j,w){if(!o.isValid(x))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=i.BYTE);const b=t.getSymbolTotalCodewords(x),v=n.getTotalCodewordsCount(x,j),m=(b-v)*8;if(w===i.MIXED)return m;const y=m-u(w,x);switch(w){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(x,j){let w;const b=r.from(j,r.M);if(Array.isArray(x)){if(x.length>1)return f(x,b);if(x.length===0)return 1;w=x[0]}else w=x;return c(w.mode,w.getLength(),b)},e.getEncodedBits=function(x){if(!o.isValid(x)||x<7)throw new Error("Invalid QR Code version");let j=x<<12;for(;t.getBCHDigit(j)-a>=0;)j^=l<<t.getBCHDigit(j)-a;return x<<12|j}})(US);var WS={};const Mh=jn,HS=1335,r4=21522,aj=Mh.getBCHDigit(HS);WS.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Mh.getBCHDigit(i)-aj>=0;)i^=HS<<Mh.getBCHDigit(i)-aj;return(r<<10|i)^r4};var VS={};const i4=gr;function Hi(e){this.mode=i4.NUMERIC,this.data=e.toString()}Hi.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Hi.prototype.getLength=function(){return this.data.length};Hi.prototype.getBitsLength=function(){return Hi.getBitsLength(this.data.length)};Hi.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const o=this.data.length-n;o>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,o*3+1))};var o4=Hi;const l4=gr,Fd=["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 Vi(e){this.mode=l4.ALPHANUMERIC,this.data=e}Vi.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Vi.prototype.getLength=function(){return this.data.length};Vi.prototype.getBitsLength=function(){return Vi.getBitsLength(this.data.length)};Vi.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=Fd.indexOf(this.data[n])*45;r+=Fd.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(Fd.indexOf(this.data[n]),6)};var a4=Vi;const c4=gr;function Ki(e){this.mode=c4.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Ki.getBitsLength=function(t){return t*8};Ki.prototype.getLength=function(){return this.data.length};Ki.prototype.getBitsLength=function(){return Ki.getBitsLength(this.data.length)};Ki.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var u4=Ki;const d4=gr,f4=jn;function Gi(e){this.mode=d4.KANJI,this.data=e}Gi.getBitsLength=function(t){return t*13};Gi.prototype.getLength=function(){return this.data.length};Gi.prototype.getBitsLength=function(){return Gi.getBitsLength(this.data.length)};Gi.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=f4.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
117
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var h4=Gi,KS={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var o={},l={};l[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var c,u,p,f,h,x,j,w,b;!a.empty();){c=a.pop(),u=c.value,f=c.cost,h=n[u]||{};for(p in h)h.hasOwnProperty(p)&&(x=h[p],j=f+x,w=l[p],b=typeof l[p]>"u",(b||w>j)&&(l[p]=j,a.push(p,j),o[p]=u))}if(typeof i<"u"&&typeof l[i]>"u"){var v=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(v)}return o},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],o=r;o;)i.push(o),n[o],o=n[o];return i.reverse(),i},find_path:function(n,r,i){var o=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},o;n=n||{};for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,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})(KS);var p4=KS.exports;(function(e){const t=gr,n=o4,r=a4,i=u4,o=h4,l=us,a=jn,c=p4;function u(v){return unescape(encodeURIComponent(v)).length}function p(v,m,y){const g=[];let k;for(;(k=v.exec(y))!==null;)g.push({data:k[0],index:k.index,mode:m,length:k[0].length});return g}function f(v){const m=p(l.NUMERIC,t.NUMERIC,v),y=p(l.ALPHANUMERIC,t.ALPHANUMERIC,v);let g,k;return a.isKanjiModeEnabled()?(g=p(l.BYTE,t.BYTE,v),k=p(l.KANJI,t.KANJI,v)):(g=p(l.BYTE_KANJI,t.BYTE,v),k=[]),m.concat(y,g,k).sort(function(N,C){return N.index-C.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function h(v,m){switch(m){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return o.getBitsLength(v);case t.BYTE:return i.getBitsLength(v)}}function x(v){return v.reduce(function(m,y){const g=m.length-1>=0?m[m.length-1]:null;return g&&g.mode===y.mode?(m[m.length-1].data+=y.data,m):(m.push(y),m)},[])}function j(v){const m=[];for(let y=0;y<v.length;y++){const g=v[y];switch(g.mode){case t.NUMERIC:m.push([g,{data:g.data,mode:t.ALPHANUMERIC,length:g.length},{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.ALPHANUMERIC:m.push([g,{data:g.data,mode:t.BYTE,length:g.length}]);break;case t.KANJI:m.push([g,{data:g.data,mode:t.BYTE,length:u(g.data)}]);break;case t.BYTE:m.push([{data:g.data,mode:t.BYTE,length:u(g.data)}])}}return m}function w(v,m){const y={},g={start:{}};let k=["start"];for(let S=0;S<v.length;S++){const N=v[S],C=[];for(let P=0;P<N.length;P++){const E=N[P],O=""+S+P;C.push(O),y[O]={node:E,lastCount:0},g[O]={};for(let L=0;L<k.length;L++){const D=k[L];y[D]&&y[D].node.mode===E.mode?(g[D][O]=h(y[D].lastCount+E.length,E.mode)-h(y[D].lastCount,E.mode),y[D].lastCount+=E.length):(y[D]&&(y[D].lastCount=E.length),g[D][O]=h(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,m))}}k=C}for(let S=0;S<k.length;S++)g[k[S]].end=0;return{map:g,table:y}}function b(v,m){let y;const g=t.getBestModeForData(v);if(y=t.from(m,g),y!==t.BYTE&&y.bit<g.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(y)+`.
|
|
118
|
-
Suggested mode is: `+t.toString(g));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new o(v);case t.BYTE:return new i(v)}}e.fromArray=function(m){return m.reduce(function(y,g){return typeof g=="string"?y.push(b(g,null)):g.data&&y.push(b(g.data,g.mode)),y},[])},e.fromString=function(m,y){const g=f(m,a.isKanjiModeEnabled()),k=j(g),S=w(k,y),N=c.find_path(S.map,"start","end"),C=[];for(let P=1;P<N.length-1;P++)C.push(S.table[N[P]].node);return e.fromArray(x(C))},e.rawSplit=function(m){return e.fromArray(f(m,a.isKanjiModeEnabled()))}})(VS);const bu=jn,zd=ju,m4=qF,g4=QF,x4=OS,v4=DS,$h=LS,_h=yu,j4=XF,$c=US,y4=WS,w4=gr,Ud=VS;function b4(e,t){const n=e.size,r=v4.getPositions(t);for(let i=0;i<r.length;i++){const o=r[i][0],l=r[i][1];for(let a=-1;a<=7;a++)if(!(o+a<=-1||n<=o+a))for(let c=-1;c<=7;c++)l+c<=-1||n<=l+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?e.set(o+a,l+c,!0,!0):e.set(o+a,l+c,!1,!0))}}function k4(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function S4(e,t){const n=x4.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],o=n[r][1];for(let l=-2;l<=2;l++)for(let a=-2;a<=2;a++)l===-2||l===2||a===-2||a===2||l===0&&a===0?e.set(i+l,o+a,!0,!0):e.set(i+l,o+a,!1,!0)}}function N4(e,t){const n=e.size,r=$c.getEncodedBits(t);let i,o,l;for(let a=0;a<18;a++)i=Math.floor(a/3),o=a%3+n-8-3,l=(r>>a&1)===1,e.set(i,o,l,!0),e.set(o,i,l,!0)}function Bd(e,t,n){const r=e.size,i=y4.getEncodedBits(t,n);let o,l;for(o=0;o<15;o++)l=(i>>o&1)===1,o<6?e.set(o,8,l,!0):o<8?e.set(o+1,8,l,!0):e.set(r-15+o,8,l,!0),o<8?e.set(8,r-o-1,l,!0):o<9?e.set(8,15-o-1+1,l,!0):e.set(8,15-o-1,l,!0);e.set(r-8,8,1,!0)}function C4(e,t){const n=e.size;let r=-1,i=n-1,o=7,l=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!e.isReserved(i,a-c)){let u=!1;l<t.length&&(u=(t[l]>>>o&1)===1),e.set(i,a-c,u),o--,o===-1&&(l++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function E4(e,t,n){const r=new m4;n.forEach(function(c){r.put(c.mode.bit,4),r.put(c.getLength(),w4.getCharCountIndicator(c.mode,e)),c.write(r)});const i=bu.getSymbolTotalCodewords(e),o=_h.getTotalCodewordsCount(e,t),l=(i-o)*8;for(r.getLengthInBits()+4<=l&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(l-r.getLengthInBits())/8;for(let c=0;c<a;c++)r.put(c%2?17:236,8);return A4(r,e,t)}function A4(e,t,n){const r=bu.getSymbolTotalCodewords(t),i=_h.getTotalCodewordsCount(t,n),o=r-i,l=_h.getBlocksCount(t,n),a=r%l,c=l-a,u=Math.floor(r/l),p=Math.floor(o/l),f=p+1,h=u-p,x=new j4(h);let j=0;const w=new Array(l),b=new Array(l);let v=0;const m=new Uint8Array(e.buffer);for(let N=0;N<l;N++){const C=N<c?p:f;w[N]=m.slice(j,j+C),b[N]=x.encode(w[N]),j+=C,v=Math.max(v,C)}const y=new Uint8Array(r);let g=0,k,S;for(k=0;k<v;k++)for(S=0;S<l;S++)k<w[S].length&&(y[g++]=w[S][k]);for(k=0;k<h;k++)for(S=0;S<l;S++)y[g++]=b[S][k];return y}function T4(e,t,n,r){let i;if(Array.isArray(e))i=Ud.fromArray(e);else if(typeof e=="string"){let u=t;if(!u){const p=Ud.rawSplit(e);u=$c.getBestVersionForData(p,n)}i=Ud.fromString(e,u||40)}else throw new Error("Invalid data");const o=$c.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
|
119
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
120
|
-
Minimum version required to store current data is: `+o+`.
|
|
121
|
-
`);const l=E4(t,n,i),a=bu.getSymbolSize(t),c=new g4(a);return b4(c,t),k4(c),S4(c,t),Bd(c,n,0),t>=7&&N4(c,t),C4(c,l),isNaN(r)&&(r=$h.getBestMask(c,Bd.bind(null,c,n))),$h.applyMask(r,c),Bd(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}$S.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=zd.M,i,o;return typeof n<"u"&&(r=zd.from(n.errorCorrectionLevel,zd.M),i=$c.from(n.version),o=$h.from(n.maskPattern),n.toSJISFunc&&bu.setToSJISFunction(n.toSJISFunc)),T4(t,i,r,o)};var GS={},Wm={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),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,o=r.width&&r.width>=21?r.width:void 0,l=r.scale||4;return{width:o,scale:o?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 o=e.getScale(r,i);return Math.floor((r+i.margin*2)*o)},e.qrToImageData=function(r,i,o){const l=i.modules.size,a=i.modules.data,c=e.getScale(l,o),u=Math.floor((l+o.margin*2)*c),p=o.margin*c,f=[o.color.light,o.color.dark];for(let h=0;h<u;h++)for(let x=0;x<u;x++){let j=(h*u+x)*4,w=o.color.light;if(h>=p&&x>=p&&h<u-p&&x<u-p){const b=Math.floor((h-p)/c),v=Math.floor((x-p)/c);w=f[a[b*l+v]?1:0]}r[j++]=w.r,r[j++]=w.g,r[j++]=w.b,r[j]=w.a}}})(Wm);(function(e){const t=Wm;function n(i,o,l){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=l,o.width=l,o.style.height=l+"px",o.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(o,l,a){let c=a,u=l;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),l||(u=r()),c=t.getOptions(c);const p=t.getImageWidth(o.modules.size,c),f=u.getContext("2d"),h=f.createImageData(p,p);return t.qrToImageData(h.data,o,c),n(f,u,p),f.putImageData(h,0,0),u},e.renderToDataURL=function(o,l,a){let c=a;typeof c>"u"&&(!l||!l.getContext)&&(c=l,l=void 0),c||(c={});const u=e.render(o,l,c),p=c.type||"image/png",f=c.rendererOpts||{};return u.toDataURL(p,f.quality)}})(GS);var YS={};const R4=Wm;function cj(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Wd(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function P4(e,t,n){let r="",i=0,o=!1,l=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),u=Math.floor(a/t);!c&&!o&&(o=!0),e[a]?(l++,a>0&&c>0&&e[a-1]||(r+=o?Wd("M",c+n,.5+u+n):Wd("m",i,0),i=0,o=!1),c+1<t&&e[a+1]||(r+=Wd("h",l),l=0)):i++}return r}YS.render=function(t,n,r){const i=R4.getOptions(n),o=t.modules.size,l=t.modules.data,a=o+i.margin*2,c=i.color.light.a?"<path "+cj(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",u="<path "+cj(i.color.dark,"stroke")+' d="'+P4(l,o,i.margin)+'"/>',p='viewBox="0 0 '+a+" "+a+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+p+' shape-rendering="crispEdges">'+c+u+`</svg>
|
|
122
|
-
`;return typeof r=="function"&&r(null,h),h};const I4=GF,Oh=$S,qS=GS,M4=YS;function Hm(e,t,n,r,i){const o=[].slice.call(arguments,1),l=o.length,a=typeof o[l-1]=="function";if(!a&&!I4())throw new Error("Callback required as last argument");if(a){if(l<2)throw new Error("Too few arguments provided");l===2?(i=n,n=t,t=r=void 0):l===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(l<1)throw new Error("Too few arguments provided");return l===1?(n=t,t=r=void 0):l===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(c,u){try{const p=Oh.create(n,r);c(e(p,t,r))}catch(p){u(p)}})}try{const c=Oh.create(n,r);i(null,e(c,t,r))}catch(c){i(c)}}Nl.create=Oh.create;Nl.toCanvas=Hm.bind(null,qS.render);Nl.toDataURL=Hm.bind(null,qS.renderToDataURL);Nl.toString=Hm.bind(null,function(e,t,n){return M4.render(e,n)});async function $4(e){const t=await Nl.toString(e,{type:"svg",margin:1,errorCorrectionLevel:"M"});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}const uj=10*6e4,_4=2e3;function QS(e,t){const[n,r]=d.useState(null),[i,o]=d.useState(null),[l,a]=d.useState(!1),[c,u]=d.useState(!1),p=d.useRef(e);p.current=e;const f=d.useRef(t);f.current=t;const h=d.useCallback(async()=>{const x=await A.telegramPairing();r(x),u(!1),a(!1),o(await $4(x.link).catch(()=>""))},[]);return d.useEffect(()=>{if(!n||l||c)return;let x=!1;const j=Math.min(Date.parse(n.expiresAt)||Date.now()+uj,Date.now()+uj),w=window.setInterval(()=>{if(Date.now()>=j){u(!0);return}p.current().then(b=>{var v;x||!b||(a(!0),(v=f.current)==null||v.call(f))}).catch(()=>{})},_4);return()=>{x=!0,window.clearInterval(w)}},[n,l,c]),{offer:n,square:i,paired:l,stale:c,ask:h}}function JS({offer:e,square:t,children:n}){return s.jsxs("div",{className:"meet-pair",children:[t?s.jsx("img",{className:"meet-qr",src:t,alt:e.link}):null,s.jsx("a",{className:"meet-link",href:e.link,target:"_blank",rel:"noreferrer",children:e.link}),n]})}const XS=new Set(["approval","question"]),ya={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."}};function O4({timezone:e}){var w,b;const t=se(()=>A.notificationSettings(),[]),n=se(()=>A.notifications(20),[],3e4),[r,i]=d.useState(null),[o,l]=d.useState(!1),[a,c]=d.useState(!1),[u,p]=d.useState(null),f=((w=t.data)==null?void 0:w.channels)??[],h=r??((b=t.data)==null?void 0:b.settings),x=v=>{h&&(c(!1),i({...h,...v}))},j=()=>{h&&(l(!0),c(!1),p(null),A.saveNotificationSettings(h).then(()=>{c(!0),i(null),t.reload()}).catch(v=>p(v instanceof ce?v.message:String(v))).finally(()=>l(!1)))};return s.jsxs(G,{gap:"lg",children:[s.jsx(D4,{timezone:e,onChange:t.reload}),s.jsx(Y,{title:"Notifications",aside:"What buddi tells you when you are not looking at this page.",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:o||!h,onClick:j,children:"Save"}),children:s.jsxs(G,{divided:!0,children:[s.jsx(re,{message:t.error??u}),s.jsx(Y,{title:"Where buddi reaches you",children:h?f.length===0?s.jsx("p",{className:"ui-card-meta",children:"No channel yet, so everything waits for you here. Pair Telegram and buddi can reach you on your phone."}):s.jsx(G,{gap:"sm",children:f.map(v=>{var m;return s.jsx(z4,{channel:v,checked:(h.defaultChannel??((m=f[0])==null?void 0:m.kind))===v.kind,onPick:()=>x({defaultChannel:v.kind})},v.kind)})}):s.jsx(ie,{children:"Loading…"})}),s.jsx(Y,{title:"By kind",children:h?s.jsxs(G,{gap:"sm",children:[MT.map(v=>s.jsxs("div",{className:"pref-row nt-kind",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:ya[v].label}),s.jsx("span",{className:"ui-field-hint",children:ya[v].hint})]}),s.jsxs("select",{"aria-label":ya[v].label,value:U4(h,v,f),onChange:m=>{const y={...h.perKind};m.target.value==="default"?delete y[v]:y[v]=m.target.value,x({perKind:y})},children:[s.jsx("option",{value:"default",children:"Default"}),f.map(m=>s.jsx("option",{value:m.kind,children:m.label},m.kind)),XS.has(v)?null:s.jsx("option",{value:"off",children:"Off"})]})]},v)),s.jsx("p",{className:"ui-field-hint",children:"Off keeps it in the list below and never sends it."})]}):null}),s.jsx(Y,{title:"Quiet hours",children:h?s.jsxs(G,{gap:"sm",children:[s.jsxs("div",{className:"nt-times",children:[s.jsx(ee,{label:"From",children:s.jsx("input",{type:"time",value:h.quietStart??"",onChange:v=>x({quietStart:v.target.value||null})})}),s.jsx(ee,{label:"Until",children:s.jsx("input",{type:"time",value:h.quietEnd??"",onChange:v=>x({quietEnd:v.target.value||null})})}),s.jsx(ee,{label:"End of the day",children:s.jsx("input",{type:"time",value:h.endOfDay,onChange:v=>x({endOfDay:v.target.value})})})]}),s.jsxs("p",{className:"ui-field-hint",children:["Messages wait until quiet hours end. Approvals and questions still come through. At the end of the day, what could wait goes out as one message. Times are on your clock (",e,")."]})]}):null}),a?s.jsx(V,{tone:"good",role:"status",children:"Saved."}):null]})}),s.jsxs(Y,{title:"The last twenty",panel:!0,flush:!0,children:[s.jsx(re,{message:n.error}),n.data?n.data.notifications.length===0?s.jsx(ie,{children:"Nothing yet. What buddi tells you will be listed here."}):s.jsx(Ft,{children:n.data.notifications.map(v=>s.jsx(Kt,{title:v.title,sub:`${Re(v.createdAt,e)} · ${ya[v.kind].label.toLowerCase()} · ${B4(v,f)}`,side:s.jsx(W4,{row:v})},v.id))}):s.jsx(ie,{children:"Loading…"})]})]})}function D4({timezone:e,onChange:t}){var C,P;const n=se(()=>A.telegramBot(),[]),r=se(()=>A.telegramDevices(),[]),[i,o]=d.useState(!1),[l,a]=d.useState(""),[c,u]=d.useState(!1),[p,f]=d.useState(null),[h,x]=d.useState(null),j=d.useRef(new Set),w=QS(()=>A.telegramDevices().then(E=>E.devices.some(O=>!j.current.has(O.id))),()=>{r.reload(),t()}),b=((C=n.data)==null?void 0:C.configured)??!1,v=!b||i,m=()=>{var O;if(l.trim()===""||c)return;u(!0),f(null);const E=i&&(((O=n.data)==null?void 0:O.running)??!1);A.saveTelegramToken(l.trim()).then(L=>{a(""),o(!1),f(L.restartNeeded?{ok:!1,text:L.note??"Saved. It will be ready the next time buddi starts."}:E?{ok:!0,text:"Saved. The new bot takes over the next time buddi starts."}:{ok:!0,text:"Saved."}),n.reload(),t()}).catch(L=>f({ok:!1,text:L instanceof ce?L.message:String(L)})).finally(()=>u(!1))},y=()=>{var E;x(null),j.current=new Set((((E=r.data)==null?void 0:E.devices)??[]).map(O=>O.id)),w.ask().catch(O=>x(O instanceof ce?O.message:String(O)))},{offer:g,square:k,paired:S,stale:N}=w;return s.jsx(Y,{title:"Telegram",aside:"Talk to buddi from your phone.",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{title:"The bot",foot:v?s.jsxs(s.Fragment,{children:[i?s.jsx(R,{variant:"ghost",onClick:()=>{o(!1),a("")},children:"Cancel"}):null,s.jsx(R,{variant:"accent",disabled:c||l.trim()==="",onClick:m,children:"Save token"})]}):void 0,children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:n.error}),!n.data&&!n.error?s.jsx(ie,{children:"Loading…"}):b&&!i?s.jsxs("div",{className:"nt-channel",children:[s.jsx("span",{className:"pref-label",children:(P=n.data)!=null&&P.username?`Bot: @${n.data.username}`:"A bot token is saved."}),s.jsx(R,{variant:"ghost",size:"sm",onClick:()=>{o(!0),f(null)},children:"Replace token"})]}):null,v?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Ask @BotFather for a bot and paste its token here."}),s.jsx(ee,{label:"Bot token",grow:!0,children:s.jsx("input",{type:"password",value:l,autoComplete:"off",spellCheck:!1,onChange:E=>a(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),m())}})})]}):null,p?s.jsx(V,{tone:p.ok?"good":"warning",role:"status",children:p.text}):null]})}),s.jsxs(Y,{title:"Your devices",children:[s.jsx(re,{message:r.error}),r.data?r.data.devices.length===0?s.jsx("p",{className:"ui-card-meta",children:"No phone is paired yet."}):s.jsx(Ft,{children:r.data.devices.map(E=>s.jsx(Kt,{title:E.name??`Telegram user ${E.userId}`,sub:`Paired ${Re(E.pairedAt,e)} · ${E.lastSeenAt?`last spoke ${Se(E.lastSeenAt)}`:"has not spoken yet"}`,side:s.jsx(L4,{id:E.id,onGone:()=>{r.reload(),t()}})},E.id))}):r.error?null:s.jsx(ie,{children:"Loading…"})]}),s.jsx(Y,{title:"Pair a device",foot:b&&(!g||S)?s.jsx(R,{variant:g?void 0:"accent",onClick:y,children:"Pair a phone"}):b&&N?s.jsx(R,{variant:"accent",onClick:y,children:"New code"}):void 0,children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:h}),b?S?s.jsx(V,{tone:"good",role:"status",children:"Paired."}):g&&N?s.jsx("p",{className:"ui-card-meta",children:"That code has run out."}):g?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"ui-card-meta",children:"Open this on your phone, then send /start to the bot."}),s.jsx(JS,{offer:g,square:k,children:s.jsx(F4,{text:g.link})}),s.jsxs("p",{className:"ui-field-hint",children:["The code works until ",Re(g.expiresAt,e),"."]})]}):s.jsx("p",{className:"ui-card-meta",children:"Pair another phone, or the first one if you skipped it."}):s.jsx("p",{className:"ui-card-meta",children:"Save a bot token first."})]})})]})})}function L4({id:e,onGone:t}){const[n,r]=d.useState(!1),[i,o]=d.useState(!1),[l,a]=d.useState(null);if(!n)return s.jsx(R,{size:"sm",onClick:()=>r(!0),children:"Unpair"});const c=()=>{o(!0),a(null),A.unpairTelegramDevice(e).then(t).catch(u=>a(u instanceof ce?u.message:String(u))).finally(()=>o(!1))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx("span",{className:"ui-field-hint",role:l?"alert":void 0,children:l??"It will no longer reach your agents."}),s.jsx(R,{size:"sm",variant:"ghost",disabled:i,onClick:()=>r(!1),children:"Keep"}),s.jsx(R,{size:"sm",variant:"danger",disabled:i,onClick:c,children:"Unpair"})]})}function F4({text:e}){const[t,n]=d.useState(null),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("Select the link to copy it.");return}navigator.clipboard.writeText(e).then(()=>n("Copied."),()=>n("Select the link to copy it."))};return s.jsxs("span",{className:"nt-channel",children:[s.jsx(R,{size:"sm",onClick:r,children:"Copy"}),t?s.jsx("span",{className:"ui-field-hint",role:"status",children:t}):null]})}function z4({channel:e,checked:t,onPick:n}){const[r,i]=d.useState(!1),[o,l]=d.useState(null),a=()=>{i(!0),l(null),A.testChannel(e.kind).then(()=>l({ok:!0,text:"Sent. Check that it arrived."})).catch(c=>l({ok:!1,text:c instanceof ce?c.message:String(c)})).finally(()=>i(!1))};return s.jsxs("div",{className:"nt-channel",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:"nt-default-channel",checked:t,onChange:n}),s.jsxs("span",{className:"nt-channel-text",children:[s.jsxs("span",{className:"pref-label",children:[e.label,e.where?`, ${e.where}`:""]}),s.jsxs("span",{className:"ui-field-hint",children:["The title and a few lines of each message go to ",e.label,"."]}),o?s.jsx("span",{className:"nt-channel-sent","data-tone":o.ok?void 0:"critical",role:"status",children:o.text}):null]})]}),s.jsx(R,{size:"sm",disabled:r,onClick:a,children:"Send a test"})]})}function U4(e,t,n){const r=e.perKind[t];return r==="off"?XS.has(t)?"default":"off":r&&n.some(i=>i.kind===r)?r:"default"}function B4(e,t){var n;return e.channel&&e.channel!=="dashboard"?((n=t.find(r=>r.kind===e.channel))==null?void 0:n.label)??e.channel:"dashboard"}function W4({row:e}){return e.state==="failed"?s.jsxs("span",{className:"nt-state","data-tone":"critical",children:["Failed: ",e.error??"no reason given"]}):e.actedAt?s.jsx("span",{className:"nt-state",children:"Acted on"}):e.seenAt?s.jsx("span",{className:"nt-state",children:"Seen"}):e.state==="held"?s.jsx("span",{className:"nt-state",children:"Waiting"}):e.state==="stored"?s.jsx("span",{className:"nt-state",children:"Kept"}):e.state==="sent"?s.jsx("span",{className:"nt-state",children:"Sent"}):s.jsx("span",{className:"nt-state",children:"Not seen"})}const H4={you:"person",appearance:"sun",notifications:"bell",memory:"notebook",proposals:"bulb",accounts:"key",computer:"monitor",secrets:"key",watchers:"eye",backup:"archive",system:"chip",plugins:"plug"};function V4(e){const t=S2.map(r=>({id:r.id,route:st(r.id),label:r.label,icon:H4[r.id],group:r.group})),n=[...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:A0(r.plugin,r.id),route:hm(r.plugin,r.id),label:r.title,icon:Bk(r.icon),group:"plugins"}));return[...t,...n]}function ZS(e){return k2.map(t=>({id:t.id,label:t.label,entries:e.filter(n=>n.group===t.id)})).filter(t=>t.entries.length>0)}function e1(e,t){return t?`${e}, ${t} open`:e}function K4({entries:e,active:t,counts:n={},navigate:r}){var c;const i=d.useRef(null),o=ZS(e),l=e.some(u=>u.id===t)?t:(c=e[0])==null?void 0:c.id,a=u=>{var x;const p=[...((x=i.current)==null?void 0:x.querySelectorAll("a.settings-nav-link"))??[]],f=p.indexOf(document.activeElement);if(f===-1)return;const h=j=>{var w;u.preventDefault(),(w=p[Math.max(0,Math.min(p.length-1,j))])==null||w.focus()};if(u.key==="ArrowDown")h(f+1);else if(u.key==="ArrowUp")h(f-1);else if(u.key==="Home")h(0);else if(u.key==="End")h(p.length-1);else if(u.key==="Enter"||u.key===" "){u.preventDefault();const j=p[f].getAttribute("href");j&&r(j)}};return s.jsx("nav",{className:"settings-nav","aria-label":"Settings sections",ref:i,onKeyDown:a,children:o.map(u=>s.jsxs("div",{className:"settings-nav-group",role:"group","aria-labelledby":`settings-nav-${u.id}`,children:[s.jsx("div",{className:"settings-nav-label",id:`settings-nav-${u.id}`,children:u.label}),u.entries.map(p=>{const f=p.id===t,h=n[p.id];return s.jsxs("a",{className:"settings-nav-link",href:p.route,"data-active":f?"true":void 0,"aria-current":f?"page":void 0,"aria-label":h?e1(p.label,h):void 0,tabIndex:p.id===l?0:-1,onClick:x=>{x.preventDefault(),r(p.route)},children:[s.jsx(De,{name:p.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:p.label}),h?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:h>99?"99+":h}):null]},p.id)})]},u.id))})}function G4({entries:e,active:t,counts:n={},navigate:r}){const i=ZS(e),o=e.find(l=>l.id===t)??e[0];return s.jsx("nav",{className:"settings-menu","aria-label":"Settings sections",children:s.jsxs(sm,{modal:!1,children:[s.jsx(rm,{asChild:!0,children:s.jsxs("button",{type:"button",className:"settings-menu-trigger","aria-label":`Settings section: ${(o==null?void 0:o.label)??""}`,children:[o?s.jsx(De,{name:o.icon,className:"settings-nav-icon"}):null,s.jsx("span",{className:"settings-nav-text",children:o==null?void 0:o.label}),s.jsx(De,{name:"chevron-down",className:"settings-menu-chevron"})]})}),s.jsx(im,{children:s.jsx(om,{className:"ui-menu settings-menu-list",align:"start",sideOffset:6,children:s.jsx(zP,{value:t,onValueChange:l=>{const a=e.find(c=>c.id===l);a&&r(a.route)},children:i.map((l,a)=>s.jsxs(FP,{children:[a>0?s.jsx(za,{className:"ui-menu-sep"}):null,s.jsx(lm,{className:"ui-menu-label",children:l.label}),l.entries.map(c=>{const u=n[c.id];return s.jsxs(UP,{value:c.id,className:"ui-menu-item settings-menu-item","data-active":c.id===t?"true":void 0,"aria-label":u?e1(c.label,u):void 0,children:[s.jsxs("span",{className:"settings-menu-entry",children:[s.jsx(De,{name:c.icon,className:"settings-nav-icon"}),s.jsx("span",{className:"settings-nav-text",children:c.label})]}),u?s.jsx("span",{className:"ui-badge settings-nav-count","aria-hidden":"true",children:u>99?"99+":u}):null]},c.id)})]},l.id))})})})]})})}function Y4({hash:e,timezone:t,navigate:n,agents:r,pluginPages:i}){var w,b;const o=N2(e),l=zk(i!==void 0),a=i??l,c=j2(e),u=c?a.find(c.plugin,c.page):void 0,p=Rh(dS),f=V4(a.settings),x={proposals:((b=(w=se(()=>Promise.resolve().then(()=>A.proposals()),[],3e4).data)==null?void 0:w.open)==null?void 0:b.length)??0},j={entries:f,active:o,counts:x,navigate:v=>n(v)};return s.jsxs("div",{className:"settings",children:[p?null:s.jsx(K4,{...j}),s.jsx("div",{className:"settings-body",children:s.jsxs("div",{className:"ui-page",children:[s.jsxs("header",{className:"ui-page-head",children:[s.jsx("h2",{className:"ui-page-title",children:"Settings"}),s.jsx("p",{className:"ui-page-lede",children:"How this installation runs, and where it reaches."})]}),p?s.jsx(G4,{...j}):null,u?s.jsx(nD,{page:u,navigate:n,timezone:t,siblings:a.all.filter(v=>v.plugin===u.plugin)}):null,o==="you"?s.jsx(yF,{embedded:!0}):null,o==="appearance"?s.jsx(q4,{}):null,o==="notifications"?s.jsx(O4,{timezone:t}):null,o==="memory"?s.jsx(tS,{embedded:!0,agents:r,timezone:t}):null,o==="proposals"?s.jsx(CF,{embedded:!0,plugin:w2(e)}):null,o==="accounts"?s.jsx(WL,{embedded:!0}):null,o==="computer"?s.jsx(b_,{embedded:!0,timezone:t}):null,o==="secrets"?s.jsx(dF,{embedded:!0,timezone:t}):null,o==="watchers"?s.jsx(vF,{timezone:t,embedded:!0}):null,o==="backup"?s.jsx(DL,{}):null,o==="plugins"?s.jsx(FF,{}):null,o==="system"?s.jsx(Q4,{timezone:t}):null]})})]})}function q4(){const[e,t]=Yk();return s.jsx(Y,{title:"Appearance",aside:"Kept in this browser only. Another browser keeps its own.",panel:!0,children:s.jsxs(G,{divided:!0,gap:"lg",children:[s.jsx(Hd,{label:"Theme",hint:"System follows your Mac.",children:s.jsx(Ba,{label:"Theme",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}],value:e.theme,onChange:n=>t({theme:n})})}),s.jsx(Hd,{label:"Background",hint:"Blue carries the first-run colours through the app. Sand is quieter.",children:s.jsx(Ba,{label:"Background",options:[{value:"blue",label:"Blue"},{value:"sand",label:"Sand"}],value:e.ground,onChange:n=>t({ground:n})})}),s.jsx(Hd,{label:"Page width",hint:"How far pages stretch on a wide screen.",children:s.jsx(Ba,{label:"Page width",options:[{value:"narrow",label:"Narrow"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}],value:e.width,onChange:n=>t({width:n})})})]})})}function Hd({label:e,hint:t,children:n}){return s.jsxs("div",{className:"pref-row ui-section",children:[s.jsxs("div",{className:"pref-text",children:[s.jsx("span",{className:"pref-label",children:e}),s.jsx("span",{className:"ui-field-hint",children:t})]}),n]})}function Q4({timezone:e}){const t=se(()=>A.overview(),[],15e3),n=se(()=>A.session(),[]),r=se(()=>A.providerAccounts(),[]),i=t.data;return s.jsxs(G,{gap:"lg",children:[s.jsx(re,{message:t.error}),s.jsx(u3,{}),i?s.jsx(Y,{title:"The queue",panel:!0,actions:s.jsx(R,{size:"sm",variant:i.paused?"accent":void 0,onClick:()=>{A.setPaused(!i.paused).then(()=>t.reload())},children:i.paused?"Resume the queue":"Pause the queue"}),children:s.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?s.jsx(pe,{tone:"warning",children:"paused"}):s.jsx(pe,{tone:"good",children:"running"})]})}):null,s.jsxs(Y,{title:"This host",panel:!0,children:[s.jsx(At,{items:[{label:"Time zone",value:e},{label:"Server time",value:i?Re(i.now,e):"…"},{label:"Bound to",value:n.data?`${n.data.host}:${n.data.port}`:"…"},{label:"Credential vault",value:r.data?e3(r.data.vault.kind):"…"}]}),r.data&&(r.data.vault.locked||r.data.vault.kind==="none")?s.jsx(V,{tone:"warning",children:r.data.vault.advice||"Run buddi init on the host to configure secure credential storage."}):null]}),s.jsx(Z4,{}),s.jsx(J4,{}),s.jsx(Y,{title:"Mail and sources",panel:!0,children:i?i.mail.length===0?s.jsx(ie,{children:"No sources are installed."}):s.jsx(At,{items:i.mail.map(o=>({key:o.sourceId,label:s.jsx("span",{className:"mono",children:o.sourceId}),value:o.lastError?s.jsx("span",{className:"critical",children:o.lastError}):s.jsxs("span",{children:["polled ",Se(o.lastRunAt)]})}))}):s.jsx(ie,{children:"Loading…"})})]})}function J4(){var x;const e=se(()=>A.tailscale(),[]),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,l]=d.useState(null),[a,c]=d.useState(!1),u=e.data,p=t??((u==null?void 0:u.login)||((x=u==null?void 0:u.self)==null?void 0:x.login)||""),f=(u==null?void 0:u.proxied)===!0,h=j=>{i(!0),l(null),c(!1),A.setTailscale({enabled:j,login:p.trim()}).then(()=>{c(!0)}).catch(w=>l(w instanceof ce?w.message:String(w))).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Sign in through Tailscale",panel:!0,foot:s.jsx(R,{variant:"accent",disabled:r||!u||f,onClick:()=>h((u==null?void 0:u.enabled)??!1),children:"Save"}),children:s.jsx(G,{divided:!0,children:s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:e.error??o}),s.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?s.jsxs(s.Fragment,{children:[s.jsx(V,{tone:"warning",children:"Change this from the computer buddi runs on."}),s.jsx("p",{className:"ui-card-meta",children:u!=null&&u.enabled?`On, for ${p}`:"Off"})]}):null,s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,disabled:r||!u||f,onChange:j=>h(j.target.checked)}),s.jsx("span",{children:"Let this Tailscale login sign in"})]}),s.jsx(ee,{label:"Tailscale login",children:s.jsx("input",{type:"text",value:p,placeholder:"you@example.com",disabled:r||!u||f,onChange:j=>n(j.target.value)})}),s.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:"}),s.jsxs("div",{className:"tailscale-command",children:[s.jsx("code",{className:"mono",children:(u==null?void 0:u.serveCommand)??"tailscale serve"}),s.jsx(R,{size:"sm",disabled:r||!u,onClick:()=>{X4((u==null?void 0:u.serveCommand)??"")},children:"Copy"})]}),s.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."}),a?s.jsx(V,{tone:"good",role:"status",children:"Saved."}):null]})})})})}async function X4(e){var t;try{await((t=navigator.clipboard)==null?void 0:t.writeText(e))}catch{}}function Z4(){var u;const e=se(()=>A.service(),[],1e4),[t,n]=d.useState(null),[r,i]=d.useState(!1),[o,l]=d.useState(null),a=(u=e.data)!=null&&u.supervised?e.data.status:void 0;if(!a)return null;const c=p=>{i(!0),l(null),A.serviceAction(p).then(()=>{n(null)}).catch(f=>{l(f.message)}).finally(()=>{i(!1),e.reload()})};return s.jsx(Y,{title:"Service",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(At,{items:[{label:"Database",value:s.jsx(dj,{state:a.database,pid:a.databasePid})},{label:"Gateway",value:s.jsx(dj,{state:a.gateway,pid:a.gatewayPid})},{label:"Supervisor",value:s.jsxs("span",{className:"mono",children:["pid ",a.supervisorPid]})}]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:o}),t?s.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 closes this dashboard for a few seconds. If it does not come back on its own, run buddi in a terminal."}):s.jsx("p",{className:"ui-card-meta",children:"Stopping the gateway ends this dashboard until buddi is run again."}),s.jsx(J,{align:"end",children:t?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",disabled:r,onClick:()=>{n(null),l(null)},children:"Cancel"}),s.jsx(R,{variant:t==="stop"?"danger":"accent",disabled:r,onClick:()=>{c(t)},children:t==="stop"?"Stop it":"Restart it"})]}):s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>{n("stop")},children:"Stop gateway"}),s.jsx(R,{variant:"accent",onClick:()=>{n("restart")},children:"Restart gateway"})]})})]})})]})})}function dj({state:e,pid:t}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e==="running"?"good":e==="stopped"?"warning":e==="failed"?"critical":"muted",children:e})," ",t===null?s.jsx("span",{className:"ui-card-meta",children:"no process"}):s.jsxs("span",{className:"mono",children:["pid ",t]})]})}function e3(e){return e==="keychain"?"macOS Keychain":e==="file"?"Encrypted file vault":e==="none"?"None":e}const t3=2e3,fj={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.",restarting:"Restarting buddi on the new version.",migrating:"Bringing the database up to date.",done:"Done.",failed:"That did not work."},n3=new Set(["done","failed","rolled-back"]),s3="The check asks the npm registry for the newest version and sends nothing else.",r3="This takes a backup, installs the new version and restarts buddi. This page closes and comes back on its own.",i3="A checkout upgrades with git pull, then buddi upgrade in a terminal.",o3=10*6e4,l3="buddi did not come back. Run buddi doctor in a terminal.";function a3(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 c3(e,t,n,r){const[i,o]=d.useState(void 0),[l,a]=d.useState(!1),[c,u]=d.useState(null),p=d.useRef(!1),f=d.useRef(n),h=d.useRef(r);return f.current=n,h.current=r,d.useEffect(()=>{if(!e){o(void 0),a(!1),p.current=!1;return}let x=!1,j=0;const w=()=>{p.current=!0,j=Date.now()+o3,a(!0)},b=()=>{if(Date.now()<j){A.session().then(y=>{x||y.version!==void 0&&y.version===t||(x=!0,f.current())}).catch(()=>{}),A.version().then(y=>{const g=y.history[y.history.length-1];x||(g==null?void 0:g.outcome)!=="failed"||(x=!0,a(!1),u(a3(g)))}).catch(()=>{});return}x=!0,a(!1),u(l3)},v=()=>{if(!x){if(p.current)return b();A.upgradeJob(e).then(y=>{var g;x||(o(y),u(null),(n3.has(y.phase)||y.finishedAt)&&(x=!0,y.phase==="failed"&&((g=h.current)==null||g.call(h,y))))}).catch(y=>{x||(y instanceof ce&&y.status!==0&&y.status<500?u(y.message):w())})}};v();const m=window.setInterval(v,t3);return()=>{x=!0,window.clearInterval(m)}},[e,t]),{job:i,away:l,error:c}}function u3({reload:e}){var g;const t=se(()=>A.version(),[]),[n,r]=d.useState(null),[i,o]=d.useState(!1),[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),h=(g=t.data)==null?void 0:g.current,x=e??(()=>window.location.reload()),j=d.useCallback(k=>{r(null),f(k)},[]),w=c3(n,h,x,j),b=t.data,v=()=>{a(!0),u(null),A.checkVersion().catch(k=>u(k instanceof ce?k.message:String(k))).finally(()=>{a(!1),t.reload()})},m=k=>{a(!0),u(null),A.setVersionCheck(k).catch(S=>u(S instanceof ce?S.message:String(S))).finally(()=>{a(!1),t.reload()})},y=()=>{a(!0),u(null),f(null),A.startUpgrade(b==null?void 0:b.latest).then(k=>{var S;o(!1),r(((S=k.job)==null?void 0:S.id)??null)}).catch(k=>u(k instanceof ce?k.message:String(k))).finally(()=>a(!1))};return b!=null&&b.checkout?s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsx(At,{items:[{label:"Running",value:s.jsx("span",{className:"mono",children:b.current})}]})}),s.jsx(Y,{children:s.jsx("p",{className:"ui-card-meta",children:i3})})]})}):s.jsx(Y,{title:"Version",panel:!0,children:s.jsxs(G,{divided:!0,children:[s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(re,{message:t.error??c}),s.jsx(At,{items:[{label:"Running",value:b?s.jsx("span",{className:"mono",children:b.current}):"…"},{label:"Newest",value:b?b.updateAvailable&&b.latest?s.jsxs("span",{children:["A newer buddi is available: ",s.jsx("span",{className:"mono",children:b.latest})]}):b.checkedAt?s.jsxs("span",{children:["This is the latest, as of ",Se(b.checkedAt),"."]}):s.jsx("span",{children:"Not checked yet."}):"…"}]}),b!=null&&b.error?s.jsxs(V,{tone:"warning",children:["The last check did not get an answer: ",b.error]}):null,s.jsx(J,{align:"end",children:s.jsx(R,{disabled:l,onClick:v,children:"Check now"})})]})}),s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsxs("label",{className:"backup-check",children:[s.jsx("input",{type:"checkbox",checked:(b==null?void 0:b.checkEnabled)??!1,disabled:l||!b,onChange:k=>m(k.target.checked)}),s.jsx("span",{children:"Check once a day"})]}),s.jsx("p",{className:"ui-card-meta",children:s3})]})}),b!=null&&b.updateAvailable&&b.latest&&b.latestNotes?s.jsx(Y,{title:`What changes in ${b.latest}`,children:s.jsx(cr,{text:b.latestNotes})}):null,s.jsx(Y,{children:s.jsxs(G,{gap:"sm",children:[s.jsx(d3,{...w,job:w.job??p??void 0}),i?s.jsx(V,{tone:"warning",role:"alert",children:r3}):null,s.jsx(J,{align:"end",children:i?s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",disabled:l,onClick:()=>o(!1),children:"Cancel"}),s.jsxs(R,{variant:"accent",disabled:l,onClick:y,children:["Upgrade to ",b==null?void 0:b.latest]})]}):s.jsx(R,{variant:"accent",disabled:l||n!==null||!(b!=null&&b.updateAvailable),onClick:()=>o(!0),children:b!=null&&b.updateAvailable&&b.latest?`Upgrade to ${b.latest}`:"Upgrade"})})]})}),b&&b.history.length>0?s.jsx(Y,{title:"Upgrades so far",children:s.jsx(At,{items:b.history.slice().reverse().map(k=>({key:k.startedAt,label:s.jsxs("span",{className:"mono",children:[k.from," → ",k.to]}),value:s.jsx(f3,{attempt:k})}))})}):null]})})}function d3({job:e,away:t,error:n}){return n?s.jsx(re,{message:n}):t?s.jsx(V,{tone:"warning",role:"status",children:"buddi is restarting. This page comes back on its own when it answers again."}):e?e.phase==="failed"?s.jsxs(V,{tone:"critical",role:"alert",children:[fj.failed," ",e.error??""," buddi is still running on the version it had."]}):s.jsx(V,{tone:e.phase==="done"?"good":void 0,role:"status",children:fj[e.phase]??e.detail??e.phase}):null}function f3({attempt:e}){return s.jsxs("span",{children:[s.jsx(pe,{tone:e.outcome==="done"?"good":e.outcome==="failed"?"critical":"warning",children:e.outcome})," ",Se(e.startedAt),e.step?`, at ${e.step}`:"",e.error?`: ${e.error}`:"",e.backup?s.jsxs("span",{className:"ui-card-meta",children:[" Backup: ",s.jsx("span",{className:"mono",children:e.backup})]}):null]})}const Dh=["name","clock","brain","browser","assistant","handover"],t1={name:"you",clock:"you",brain:"model",browser:"browser",assistant:"agent",handover:"hello"};function h3(e){return((e==null?void 0:e.accounts)??[]).filter(t=>t.enabled&&t.configured&&t.removalPending!==!0)}function p3(e){var o,l,a;const t=h3(e.accounts),n=e.assistant?(((o=e.accounts)==null?void 0:o.bindings)??[]).find(c=>c.agentId===e.assistant.id):void 0,r=(n==null?void 0:n.accountId)??((a=(l=e.onboarding)==null?void 0:l.details)==null?void 0:a.accountId);if(!r)return;const i=t.find(c=>c.id===r);if(i)return{accountId:i.id,label:i.label,model:(n==null?void 0:n.model)??i.defaultModel}}function n1(e){var r,i,o;const t=p3(e),n=e.onboarding&&!e.onboarding.needs.agent?e.assistant:void 0;return{...(r=e.owner)!=null&&r.preferredName?{name:e.owner.preferredName}:{},...(i=e.owner)!=null&&i.timezone?{clock:e.owner.timezone}:{},...t?{brain:t}:{},...(o=e.onboarding)!=null&&o.stepsDone.includes("browser")||n?{browser:e.browser??"other"}:{},...n?{assistant:n}:{}}}function m3(e,t){return t==="name"?typeof e.name=="string"&&e.name!=="":t==="clock"?typeof e.clock=="string"&&e.clock!=="":t==="brain"?e.brain!==void 0:t==="browser"?e.browser!==void 0:t==="assistant"?e.assistant!==void 0:!1}function Lh(e){return Dh.find(t=>!m3(e,t))??"handover"}function g3(e,t){const n=Dh.indexOf(t);return Dh.filter((r,i)=>i<n||r===t)}function x3(e,t){const n={...e};return delete n[t],n}const Fh="buddi.firstRun.restore";function Vd(e){try{e===null?window.sessionStorage.removeItem(Fh):window.sessionStorage.setItem(Fh,e)}catch{}}function s1(){try{return window.sessionStorage.getItem(Fh)}catch{return null}}function v3(e){const t=n1(e),n=Lh(t);return{answers:t,open:n,stay:n!=="handover"}}function j3(e){return e.trim().startsWith("sk-ant-")?"anthropic":"openai"}function y3(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 w3=550,b3=6e4,k3=5*6e4,r1=1500,S3=3e3;function El(){const e=d.useRef(null);return d.useEffect(()=>{let t=0,n=0;const r=l=>{const a=l.ownerDocument.activeElement;return a===null||a===l.ownerDocument.body||a===l.ownerDocument.documentElement},i=()=>{const l=e.current;l&&r(l)&&l.focus()},o=()=>{i(),n=window.setTimeout(i,0)};return typeof window.requestAnimationFrame=="function"?t=window.requestAnimationFrame(o):o(),window.addEventListener("focus",i),()=>{t&&window.cancelAnimationFrame(t),window.clearTimeout(n),window.removeEventListener("focus",i)}},[]),e}function i1(){const[e,t]=d.useState(()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}});return d.useEffect(()=>{var i;let n;try{n=window.matchMedia("(prefers-reduced-motion: reduce)")}catch{return}const r=o=>t(o.matches);return(i=n.addEventListener)==null||i.call(n,"change",r),()=>{var o;return(o=n.removeEventListener)==null?void 0:o.call(n,"change",r)}},[]),e}function Le({children:e,at:t=0}){const n=i1(),[r,i]=d.useState(n||t===0);return d.useEffect(()=>{if(n){i(!0);return}const o=window.setTimeout(()=>i(!0),w3*t);return()=>window.clearTimeout(o)},[n,t]),r?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:e})}):s.jsx(ur,{})}function ur({line:e}){return s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsxs("span",{className:"wb-working",role:"status","aria-live":"polite",children:[e,s.jsxs("span",{className:"wb-dots","aria-hidden":"true",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]})]})})}function Me({children:e}){return s.jsxs("div",{className:"meet-turn",children:[s.jsxs("div",{className:"wb-msg-who",children:[s.jsx(J0,{size:"sm"}),s.jsx("span",{children:"buddi"})]}),e]})}const o1=d.createContext({body:null,actions:null});function l1({children:e,actions:t}){const n=d.useContext(o1),r=e==null?null:n.body?Di.createPortal(e,n.body):e,i=t==null?null:n.actions?Di.createPortal(t,n.actions):t;return s.jsxs(s.Fragment,{children:[r,i]})}function wa({text:e,onChange:t}){return s.jsxs("div",{className:"wb-msg","data-role":"user",children:[s.jsx("div",{className:"wb-bubble",children:e}),s.jsx("button",{type:"button",className:"meet-change",onClick:t,children:B.change})]})}function Tt({children:e,actions:t}){return s.jsx(l1,{actions:t?s.jsx("span",{className:"meet-actions",children:t}):null,children:e?s.jsx("div",{className:"meet-ask",children:e}):null})}function ku({onClick:e,disabled:t}){return s.jsxs(R,{variant:"ghost",onClick:e,disabled:t,children:[s.jsx(De,{name:"chevron-left"}),B.brain.back]})}function N3({navigate:e,timezone:t}){const[n,r]=d.useState(void 0);d.useEffect(()=>{A.session().then(he=>r(he.platform)).catch(()=>{})},[]);const[i,o]=d.useState({}),[l,a]=d.useState(null),[c,u]=d.useState(void 0),[p,f]=d.useState(void 0),[h,x]=d.useState([]),[j,w]=d.useState(null),[b,v]=d.useState(null),[m,y]=d.useState(!1),[g,k]=d.useState(null),[S,N]=d.useState(null),[C,P]=d.useState(null),[E,O]=d.useState(null),L=d.useMemo(()=>({body:C,actions:E}),[C,E]),[D,T]=d.useState(null),[z,q]=d.useState(!1),K=d.useCallback(()=>q(!0),[]),[M,W]=d.useState(()=>s1()?"running":"idle"),_=d.useMemo(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||t}catch{return t}},[t]),U=d.useRef(e);U.current=e;const X=d.useCallback(async(he=!0,ge=!1)=>{var cn,Tn,xr,_s,Rn,Vn,F,ae;const[ye,kt,ct,_e,$,de]=await Promise.all([A.onboarding().catch(()=>{}),A.owner().catch(()=>{}),A.providerAccounts().catch(()=>{}),Fe.agents().catch(()=>{}),A.browser().catch(()=>{}),A.providers().catch(()=>{})]);u(ct);const xe=(Tn=(cn=de==null?void 0:de.providers.find(Ae=>Ae.kind==="anthropic"))==null?void 0:cn.defaultModel)==null?void 0:Tn.trim();f(xe||void 0),x((kt==null?void 0:kt.zones)??[]),k(((xr=ye==null?void 0:ye.details)==null?void 0:xr.conversationId)??null);const be=(_e==null?void 0:_e.agents.find(Ae=>Ae.id===_e.defaultAgentId))??(_e==null?void 0:_e.agents[0]);be&&w(be),N(ye&&!ye.needs.agent&&be?{id:be.id,name:be.name,avatar:((_s=be.avatar)==null?void 0:_s.kind)==="emoji"?be.avatar.value:"",description:be.description,...be.picture?{picture:be.picture}:{}}:null);const it={onboarding:ye,owner:kt,accounts:ct,browser:(Rn=$==null?void 0:$.browser)==null?void 0:Rn.engine,...be?{assistant:{id:be.id,name:be.name,avatar:((Vn=be.avatar)==null?void 0:Vn.kind)==="emoji"?be.avatar.value:""}}:{}},St=n1(it);if(ge){const Ae=v3(it);if(o(Ae.answers),a(Ae.open),!Ae.stay){const Pt=(F=ye==null?void 0:ye.details)==null?void 0:F.conversationId;U.current(Pt&&be?ze(be.id,Pt):Vt,!0)}return}if(he&&(ye==null?void 0:ye.state)==="done"){const Ae=(ae=ye.details)==null?void 0:ae.conversationId;U.current(Ae&&be?ze(be.id,Ae):Vt,!0);return}he&&(o(St),a(Ae=>Ae??Lh(St)))},[]);d.useEffect(()=>{X()},[X]);const Z=(he,ge={})=>{A.onboardingStep(t1[he],ge).catch(()=>{})},ue=(he,ge)=>{v(null),o(ge),Z(he,he==="brain"&&ge.brain?{accountId:ge.brain.accountId}:{}),a(Lh(ge))},je=he=>{v(null),o(ge=>x3(ge,he)),a(he)},Ce=()=>{y(!0),A.skipOnboarding().then(()=>e(Vt)).catch(he=>v(he instanceof ce?he.message:String(he))).finally(()=>y(!1))},Pe=M==="form"||M==="running"?[]:l?g3(i,l):[],Ve=d.useRef(null);return d.useEffect(()=>{const he=Ve.current;if(!he)return;const ge=()=>{he.scrollTop=he.scrollHeight};ge();let ye;try{ye=new ResizeObserver(ge),he.firstElementChild&&ye.observe(he.firstElementChild)}catch{}return()=>ye==null?void 0:ye.disconnect()},[Pe.length,l,i,b]),s.jsx(o1.Provider,{value:L,children:s.jsx("div",{className:"meet",children:s.jsxs("div",{className:"meet-stack",children:[s.jsxs("header",{className:"meet-head",children:[s.jsx("img",{className:"meet-head-mascot",src:vu("core"),alt:"","aria-hidden":"true"}),s.jsxs("span",{className:"meet-head-who",children:[s.jsx("span",{className:"meet-head-name",children:"buddi"}),s.jsx("span",{className:"meet-head-line",children:n===void 0||n==="darwin"?B.tagline:B.taglineElsewhere})]})]}),s.jsxs("div",{className:"meet-board",children:[s.jsx("div",{className:"meet-scroll thin-scroll",ref:Ve,children:s.jsxs("div",{className:"meet-thread","data-testid":"meet-thread",children:[s.jsx(Me,{children:B.opening.map((he,ge)=>s.jsx(Le,{at:ge,children:he},he))}),s.jsx(C3,{state:M,offered:l==="name"&&i.name===void 0,name:i.name,onState:W,onDone:()=>{W("idle"),X(!0,!0)},onTrouble:v}),Pe.map(he=>s.jsx(E3,{id:he,openNow:l===he,answers:i,accounts:c,claudeModel:p,zones:h,browserZone:_,assistantAgent:j,met:g,onMet:k,existing:S,navigate:e,onCarriesOn:T,onClosed:K,onSettled:ge=>ue(he,ge),onChange:()=>je(he),onTrouble:v,onReload:()=>void X(!1),onPickAnotherBrain:()=>je("brain")},he)),b?s.jsx(Me,{children:s.jsx(Le,{children:b})}):null]})}),s.jsxs("footer",{className:"meet-dock",children:[s.jsx("div",{className:"meet-dock-ask",ref:P}),s.jsxs("div",{className:"meet-dock-row",children:[z?s.jsx("span",{}):D?s.jsx("a",{className:"meet-later",href:D,onClick:he=>{he.preventDefault(),e(D,!0)},children:B.done.open}):s.jsx("button",{className:"meet-later",type:"button",disabled:m,onClick:Ce,children:B.later}),s.jsx("div",{className:"meet-dock-actions",ref:O})]})]})]})]})})})}function C3({state:e,offered:t,name:n,onState:r,onDone:i,onTrouble:o}){const[l,a]=d.useState(()=>s1()),[c,u]=d.useState([]),[p,f]=d.useState(!1),[h,x]=d.useState(null),[j,w]=d.useState(""),[b,v]=d.useState(!1);d.useEffect(()=>{if(!l)return;let g=!1;const k=()=>{A.backupJob(l).then(N=>{g||(u(C=>C.includes(N.phase)?C:[...C,N.phase]),N.phase==="done"?(g=!0,Vd(null),f(!0),i()):(N.phase==="rolled-back"||N.phase==="failed")&&(g=!0,Vd(null),a(null),o(N.error??B.restore.phases[N.phase]),r("idle")))}).catch(()=>{})};k();const S=window.setInterval(k,r1);return()=>{g=!0,window.clearInterval(S)}},[l]);const m=()=>{!h||b||(v(!0),o(null),A.firstRunRestore(h,j.trim()).then(g=>{Vd(g.job.id),a(g.job.id),r("running")}).catch(g=>o(g instanceof ce?g.message:String(g))).finally(()=>v(!1)))},y=c.filter(g=>g in B.restore.phases);return s.jsxs(s.Fragment,{children:[t&&e==="idle"&&!p?s.jsx("button",{type:"button",className:"meet-later",onClick:()=>r("form"),children:B.restore.offer}):null,e==="form"?s.jsxs(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>r("idle"),children:B.restore.cancel}),s.jsx(R,{variant:"accent",disabled:b||!h,onClick:m,children:B.restore.submit})]}),children:[s.jsx(ee,{label:B.restore.file,grow:!0,children:s.jsx("input",{type:"file",onChange:g=>{var k;return x(((k=g.target.files)==null?void 0:k[0])??null)}})}),s.jsx(ee,{label:B.restore.passphrase,hint:B.restore.passphraseHint,children:s.jsx("input",{type:"password",autoComplete:"off",value:j,onChange:g=>w(g.target.value)})})]}):null,e==="running"||p?s.jsxs(Me,{children:[s.jsx(Le,{children:B.restore.started}),y.map(g=>s.jsx(Le,{children:B.restore.phases[g]},g))]}):null,p?s.jsxs(Me,{children:[n?s.jsx(Le,{children:B.restore.welcome(n)}):null,s.jsx(Le,{children:B.restore.keys})]}):null]})}function E3(e){var o,l,a,c;const{id:t,openNow:n,answers:r,onChange:i}=e;if(t==="name")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{at:1,children:B.name.ask})}),n?s.jsx(A3,{...e}):s.jsx(wa,{text:r.name??"",onChange:i})]});if(t==="clock")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{at:1,children:B.clock.ask(r.name??"",r.clock??e.browserZone)})}),n?s.jsx(T3,{...e}):s.jsx(wa,{text:B.clock.answer(r.clock??""),onChange:i})]});if(t==="brain")return s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{at:1,children:B.brain.ask})}),n?s.jsx(R3,{...e}):s.jsxs(s.Fragment,{children:[s.jsx(wa,{text:B.brain.answer(((o=r.brain)==null?void 0:o.label)??""),onChange:i}),s.jsx(Me,{children:s.jsx(Le,{children:B.brain.works(((l=r.brain)==null?void 0:l.model)??"")})})]})]});if(t==="browser"){if(n)return s.jsx(W3,{...e});const u=B3(r.browser);return u?s.jsx(Me,{children:s.jsx(Le,{children:u})}):null}return t==="assistant"?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{at:1,children:B.assistant.ask})}),n?s.jsx(V3,{...e}):s.jsx(wa,{text:`${((a=r.assistant)==null?void 0:a.avatar)??""} ${((c=r.assistant)==null?void 0:c.name)??""}`.trim(),onChange:i})]}):s.jsx(K3,{...e})}function A3({answers:e,onSettled:t,onTrouble:n}){const r=El(),[i,o]=d.useState(e.name??""),[l,a]=d.useState(!1),c=()=>{const u=i.trim();u===""||l||(a(!0),A.setOwner({preferredName:u}).then(()=>t({...e,name:u})).catch(p=>n(p instanceof ce?p.message:String(p))).finally(()=>a(!1)))};return s.jsx(Tt,{actions:s.jsx(R,{variant:"accent",disabled:l||i.trim()==="",onClick:c,children:B.name.submit}),children:s.jsx("input",{ref:r,className:"meet-input","aria-label":B.name.placeholder,placeholder:B.name.placeholder,maxLength:80,value:i,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())}})})}function T3({answers:e,zones:t,browserZone:n,onSettled:r,onTrouble:i}){const[o,l]=d.useState(!1),[a,c]=d.useState(n),[u,p]=d.useState(!1),f=h=>{p(!0),A.setOwner({timezone:h}).then(()=>r({...e,clock:h})).catch(x=>i(x instanceof ce?x.message:String(x))).finally(()=>p(!1))};return o?s.jsx(Tt,{actions:s.jsx(R,{variant:"accent",disabled:u,onClick:()=>f(a),children:B.clock.yes}),children:s.jsx("select",{className:"meet-input","aria-label":B.clock.label,value:a,onChange:h=>c(h.target.value),children:(t.includes(a)?t:[a,...t]).map(h=>s.jsx("option",{value:h,children:h},h))})}):s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>l(!0),children:B.clock.another}),s.jsx(R,{variant:"accent",disabled:u,onClick:()=>f(n),children:B.clock.yes})]})})}function R3(e){const{accounts:t,answers:n,onSettled:r,onReload:i}=e,[o,l]=d.useState(null),[a,c]=d.useState(null),[u,p]=d.useState(!1),[f,h]=d.useState(null),[x,j]=d.useState(null),w=(t==null?void 0:t.anthropicOAuthEnabled)===!0;d.useEffect(()=>{let y=!1;const g=()=>{A.ollama().then(S=>{y||h(S)}).catch(()=>{})};g();const k=window.setInterval(g,4e3);return()=>{y=!0,window.clearInterval(k)}},[]);const b=async y=>{if(n.assistant)try{await A.bindBrain({accountId:y.accountId,model:y.model})}catch(k){return k instanceof ce?k.message:String(k)}return i(),r({...n,brain:y}),null},v=async(y,g)=>{p(!0),c(null);try{const k=await A.saveProviderAccount(y),S=await A.testProviderAccount(k.id);if(S.state!=="connected"){try{const C=(await A.providerAccounts()).accounts.find(P=>P.id===k.id);C&&await A.removeProviderAccount(k.id,C.revision)}catch{}c(S.message);return}const N=await b({accountId:k.id,label:g,model:y.defaultModel});N&&c(N)}catch(k){c(k instanceof ce?k.message:String(k))}finally{p(!1)}},m=(y,g,k)=>{if(y.length<=1){v(g(y[0]??""),k);return}j({models:y,make:g,label:k})};return x?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{children:B.brain.model.ask})}),u?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.service})}):a?s.jsx(Me,{children:s.jsx(Le,{children:a})}):null,s.jsx(_3,{busy:u,models:x.models,onUse:y=>void v(x.make(y),x.label)})]}):o==="key"?s.jsx(O3,{busy:u,problem:a,onBack:()=>l(null),onUse:v}):o==="service"?s.jsx(L3,{busy:u,problem:a,address:(f==null?void 0:f.cloudBaseUrl)??"",onBack:()=>l(null),onOffer:m}):o==="ollama"?s.jsx(D3,{busy:u,problem:a,probe:f,onBack:()=>l(null),onOffer:m}):o==="claude"?s.jsx(z3,{busy:u,problem:a,onBack:()=>l(null),onConnected:b,...e}):s.jsx(l1,{children:s.jsxs("div",{className:"meet-cards",role:"group","aria-label":B.brain.ask,children:[w?s.jsx(ba,{mark:s.jsx(P3,{}),card:B.brain.cards.claude,onPick:()=>l("claude")}):null,s.jsx(ba,{mark:s.jsx(I3,{}),card:B.brain.cards.key,onPick:()=>l("key")}),s.jsx(ba,{mark:s.jsx(M3,{}),card:B.brain.cards.ollama,note:f===null?B.brain.ollama.looking:f.running?B.brain.ollama.found:B.brain.ollama.missing,onPick:()=>l("ollama")}),s.jsx(ba,{mark:s.jsx($3,{}),card:B.brain.cards.service,onPick:()=>l("service")})]})})}function ba({mark:e,card:t,note:n,onPick:r}){return s.jsxs("button",{type:"button",className:"meet-card",onClick:r,children:[s.jsx("span",{className:"meet-card-mark","aria-hidden":"true",children:e}),s.jsxs("span",{className:"meet-card-words",children:[s.jsx("span",{className:"meet-card-title",children:t.title}),s.jsx("span",{className:"meet-card-line",children:n??t.line}),t.know?s.jsx("span",{className:"meet-card-know",children:t.know}):null]})]})}function P3(){const e=[0,45,90,135,180,225,270,315];return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",children:e.map(t=>s.jsx("rect",{x:"11.1",y:"2.6",width:"1.8",height:"8.6",rx:"0.9",fill:"currentColor",transform:`rotate(${t} 12 12)`},t))})}function I3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"8",cy:"8",r:"3.6"}),s.jsx("path",{d:"M10.6 10.6 19.4 19.4"}),s.jsx("path",{d:"M13.8 13.8 11.9 15.7"}),s.jsx("path",{d:"M16.6 16.6 14.7 18.5"})]})}function M3(){return s.jsxs("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3.2",y:"4.6",width:"17.6",height:"11.2",rx:"2"}),s.jsx("path",{d:"M9.4 19.4h5.2"}),s.jsx("path",{d:"M12 15.8v3.6"})]})}function $3(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M7.2 18.3h9.6a3.8 3.8 0 0 0 .5-7.6 5.4 5.4 0 0 0-10.3-1.2 3.9 3.9 0 0 0 .2 8.8Z"})})}function _3({busy:e,models:t,onUse:n}){const[r,i]=d.useState(t[0]??"");return s.jsx(Tt,{actions:s.jsx(R,{variant:"accent",disabled:e||r==="",onClick:()=>n(r),children:B.brain.model.submit}),children:s.jsx(ee,{label:B.brain.model.label,grow:!0,children:s.jsx("select",{value:r,onChange:o=>i(o.target.value),children:t.map(o=>s.jsx("option",{value:o,children:o},o))})})})}function O3({busy:e,problem:t,onBack:n,onUse:r}){const i=El(),[o,l]=d.useState(""),[a,c]=d.useState(null),[u,p]=d.useState(!1),f=e||u,h=a??j3(o),x=()=>{const j=o.trim();j===""||f||(p(!0),(async()=>{var b;let w=h==="anthropic"?"claude-sonnet-5":"gpt-5";try{w=((b=(await A.probeModels({kind:h,auth:"api-key",secret:j})).models.find(m=>m.isDefault))==null?void 0:b.id)??w}catch{}p(!1),await r({label:h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai,kind:h,auth:"api-key",baseUrl:"",defaultModel:w,enabled:!0,secret:j},h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai)})())};return s.jsxs(s.Fragment,{children:[f?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.key})}):t?s.jsx(Me,{children:s.jsx(Le,{children:B.brain.key.refused})}):null,s.jsxs(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:n,disabled:f}),s.jsx(R,{variant:"accent",disabled:f||o.trim()==="",onClick:x,children:B.brain.key.submit})]}),children:[s.jsx(ee,{label:B.brain.key.field,grow:!0,children:s.jsx("input",{ref:i,type:"password",autoComplete:"off",spellCheck:!1,placeholder:B.brain.key.placeholder,value:o,onChange:j=>l(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),x())}})}),s.jsxs("button",{type:"button",className:"meet-quiet",onClick:()=>c(h==="anthropic"?"openai":"anthropic"),children:[h==="anthropic"?B.brain.key.anthropic:B.brain.key.openai," · ",B.brain.key.which]})]})]})}function D3({busy:e,problem:t,probe:n,onBack:r,onOffer:i}){const o=(n==null?void 0:n.models)??[],l=()=>{n&&i(o,a=>({label:B.brain.cards.ollama.title,kind:"openai-compatible",auth:"none",baseUrl:n.baseUrl,defaultModel:a,enabled:!0}),B.brain.cards.ollama.title)};return s.jsxs(s.Fragment,{children:[e?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.ollama})}):t?s.jsx(Me,{children:s.jsx(Le,{children:t})}):null,s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:r,disabled:e}),n!=null&&n.running?s.jsx(R,{variant:"accent",disabled:e||o.length===0,onClick:l,children:B.brain.ollama.connect}):n?s.jsx(Un,{variant:"accent",href:n.downloadUrl,target:"_blank",rel:"noreferrer",children:B.brain.ollama.download}):null]}),children:s.jsx("span",{className:"meet-line",children:n===null?B.brain.ollama.looking:n.running?B.brain.ollama.found:B.brain.ollama.missing})})]})}function L3({busy:e,problem:t,address:n,onBack:r,onOffer:i}){const o=El(),[l,a]=d.useState(n),[c,u]=d.useState(""),[p,f]=d.useState(!1),h=e||p,x=()=>{l.trim()===""||h||(f(!0),(async()=>{var m;const j=c.trim()?"api-key":"none",w=y=>({label:B.brain.cards.service.title,kind:"openai-compatible",auth:j,baseUrl:l.trim(),defaultModel:y,enabled:!0,...c.trim()?{secret:c.trim()}:{}});let b=[],v;try{const y=await A.probeModels({kind:"openai-compatible",auth:j,baseUrl:l.trim(),...c.trim()?{secret:c.trim()}:{}});b=y.models.map(g=>g.id),v=(m=y.models.find(g=>g.isDefault))==null?void 0:m.id}catch{}f(!1),i(v?[v]:b,w,B.brain.cards.service.title)})())};return s.jsxs(s.Fragment,{children:[h?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.service})}):t?s.jsx(Me,{children:s.jsx(Le,{children:t})}):null,s.jsxs(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:r,disabled:h}),s.jsx(R,{variant:"accent",disabled:h||l.trim()==="",onClick:x,children:B.brain.service.submit})]}),children:[s.jsx(ee,{label:B.brain.service.address,grow:!0,children:s.jsx("input",{ref:o,value:l,placeholder:B.brain.service.addressPlaceholder,onChange:j=>a(j.target.value)})}),s.jsx(ee,{label:B.brain.service.key,children:s.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:c,onChange:j=>u(j.target.value)})})]})]})}const F3="claude-sonnet-5";function z3({busy:e,problem:t,onBack:n,onConnected:r,accounts:i,claudeModel:o}){const[l,a]=d.useState(!1),[c,u]=d.useState(null),[p,f]=d.useState(null),[h,x]=d.useState(""),j=o??F3,w=()=>{a(!0),u(null);const v=typeof window.open=="function"?window.open("","_blank"):null;(async()=>{try{const m=((i==null?void 0:i.accounts)??[]).find(N=>N.auth==="anthropic-oauth"),y=m?{id:m.id}:await A.saveProviderAccount({label:B.brain.cards.claude.title,kind:"anthropic",auth:"anthropic-oauth",baseUrl:"",defaultModel:j,enabled:!0}),k=(await A.providerAccounts()).accounts.find(N=>N.id===y.id),S=await A.anthropicAccountAction(k.id,"login",k.revision);f({id:k.id,revision:k.revision+1,url:S.verificationUrl??"",attemptId:S.attemptId??""}),v&&S.verificationUrl?v.location.href=S.verificationUrl:v==null||v.close()}catch(m){v==null||v.close(),u(m instanceof ce?m.message:String(m))}finally{a(!1)}})()},b=()=>{!p||h.trim()===""||(a(!0),(async()=>{try{await A.anthropicAccountAction(p.id,"complete-login",p.revision,{attemptId:p.attemptId,code:h.trim()});const v=await A.testProviderAccount(p.id);if(v.state!=="connected"){u(v.message);return}u(await r({accountId:p.id,label:B.brain.cards.claude.title,model:j}))}catch(v){u(v instanceof ce?v.message:String(v))}finally{a(!1)}})())};return s.jsxs(s.Fragment,{children:[l||e?s.jsx(Me,{children:s.jsx(ur,{line:B.brain.checking.claude})}):t??c?s.jsx(Me,{children:s.jsx(Le,{children:t??c})}):null,p?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{children:B.brain.claude.waiting})}),s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(Un,{href:p.url,target:"_blank",rel:"noreferrer",children:B.brain.claude.open}),s.jsx(R,{variant:"accent",disabled:l||h.trim()==="",onClick:b,children:B.brain.claude.finish})]}),children:s.jsx(ee,{label:B.brain.claude.paste,grow:!0,children:s.jsx(U3,{value:h,onChange:x})})})]}):s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(ku,{onClick:n,disabled:e||l}),s.jsx(R,{variant:"accent",disabled:e||l,onClick:w,children:B.brain.claude.start})]})})]})}function U3({value:e,onChange:t}){const n=El();return s.jsx("input",{ref:n,type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r=>t(r.target.value)})}function B3(e){switch(e){case"chrome":return B.browser.chrome;case"chromium":return B.browser.chromium;case"installed":return B.browser.installed;case"skipped":return B.browser.skipped;case"none":return B.browser.missing;default:return null}}function W3({answers:e,onSettled:t}){const[n,r]=d.useState("checking"),[i,o]=d.useState(null),[l,a]=d.useState(null),[c,u]=d.useState(void 0),[p,f]=d.useState(0),h=d.useRef(!1),x=d.useRef(!1),j=d.useRef(()=>{});if(j.current=b=>{x.current||(x.current=!0,t({...e,browser:b}))},d.useEffect(()=>{let b=!1,v;const m=S=>{b||j.current(S)},y=(S,N)=>{b||(h.current=!1,r("failed"),o(S),a(N??null))},g=async S=>{r("launching");let N;try{N=await A.browserCheck()}catch(C){return y(C instanceof ce?C.message:String(C))}if(!b)return N.ok?m(h.current?"installed":S):y(N.message,N.command)},k=async()=>{var C,P;let S;try{S=await A.browser()}catch{return m("other")}if(b)return;const N=S.browser;if(!N)return m("other");if(((C=N.install)==null?void 0:C.state)==="running"){r("installing"),u(N.install.progress),v=window.setTimeout(()=>void k(),1e3);return}if(N.engine!=="none")return g(N.engine);if(h.current)return y(((P=N.install)==null?void 0:P.line)??"");h.current=!0,r("installing"),u(void 0);try{await A.browserInstall()}catch(E){return y(E instanceof ce?E.message:String(E))}b||(v=window.setTimeout(()=>void k(),1e3))};return k(),()=>{b=!0,window.clearTimeout(v)}},[p]),n==="checking")return s.jsx(ur,{});const w=n==="installing"||n==="launching";return s.jsxs(s.Fragment,{children:[s.jsxs(Me,{children:[h.current||n==="installing"?s.jsx(Le,{children:B.browser.needs}):null,n==="installing"?s.jsx("div",{className:"wb-msg","data-role":"assistant",children:s.jsx("div",{className:"wb-bubble",children:s.jsx(xk,{progress:c})})}):n==="launching"?s.jsx(ur,{line:B.browser.launching}):s.jsx(Le,{children:B.browser.failed(i??"")})]}),s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:()=>j.current("skipped"),children:B.browser.skip}),s.jsx(R,{variant:"accent",disabled:w,onClick:()=>{r("launching"),a(null),f(b=>b+1)},children:w?B.browser.installing:B.browser.retry})]}),children:n==="failed"&&l?s.jsx(H3,{command:l}):null})]})}function H3({command:e}){const[t,n]=d.useState("idle"),r=()=>{var i;if(!((i=navigator.clipboard)!=null&&i.writeText)){n("failed");return}navigator.clipboard.writeText(e).then(()=>n("done"),()=>n("failed"))};return s.jsxs(G,{gap:"sm",children:[s.jsx(at,{label:"The command to run",children:e}),s.jsxs(J,{align:"end",children:[t==="failed"?s.jsx("span",{className:"ui-toolbar-note",children:"Select it to copy."}):null,s.jsx(R,{size:"sm",onClick:r,children:t==="done"?"Copied":"Copy"})]})]})}function V3({answers:e,existing:t,onSettled:n,onTrouble:r,onReload:i}){const[o,l]=d.useState(()=>(t==null?void 0:t.name)??KD),[a,c]=d.useState(()=>t!=null&&t.picture?{kind:"kept",url:t.picture}:t!=null&&t.avatar?{kind:"emoji",value:t.avatar}:{kind:"mascot",role:"core"}),[u,p]=d.useState(t?null:B.assistant.purposeValue),[f,h]=d.useState(t?"":B.assistant.purposeValue);d.useEffect(()=>{if(!t)return;let b=!1;return A.firstAgentPersona().then(v=>{b||(p(v.persona),h(v.persona))},v=>{b||r(v instanceof ce?v.message:String(v))}),()=>{b=!0}},[t==null?void 0:t.id]);const[x,j]=d.useState(!1),w=()=>{if(o.trim()===""||x)return;j(!0);const b=a.kind==="emoji"?{avatar:a.value}:{},v=!t||u!==null&&f.trim()!==""&&f.trim()!==u.trim()?{instructions:f.trim()}:{},m=t?A.updateFirstAgent({name:o.trim(),...v,...b}):A.createFirstAgent({name:o.trim(),handle:y3(o),description:"",...v,...b,...e.brain?{accountId:e.brain.accountId}:{}});(async()=>{let y;try{y=await m}catch(k){r(k instanceof ce?k.message:String(k)),j(!1);return}let g=null;try{a.kind==="mascot"?await A.uploadAgentPicture(y.id,await iS(a.role)):a.kind==="emoji"&&(t!=null&&t.picture)&&await A.removeAgentPicture(y.id)}catch(k){g=k instanceof ce?k.message:String(k)}j(!1),i(),n({...e,assistant:{id:y.id,name:o.trim(),avatar:a.kind==="emoji"?a.value:""}}),g&&r(g)})()};return s.jsxs(Tt,{actions:s.jsx(R,{variant:"accent",disabled:x||o.trim()===""||u===null,onClick:w,children:B.assistant.submit}),children:[s.jsx("span",{className:"meet-chosen-face","data-kind":a.kind==="emoji"?"emoji":"image","aria-hidden":"true",children:a.kind==="emoji"?a.value:s.jsx("img",{src:a.kind==="mascot"?vu(a.role):a.url,alt:""})}),s.jsx(ee,{label:B.assistant.name,children:s.jsx("input",{value:o,maxLength:60,onChange:b=>l(b.target.value)})}),s.jsx(oS,{face:a,onPick:c}),s.jsx(ee,{label:B.assistant.purpose,wide:!0,children:s.jsx("textarea",{className:"meet-purpose",value:f,maxLength:8e3,rows:Math.max(4,f.split(`
|
|
123
|
-
`).length+1),onChange:b=>h(b.target.value)})})]})}function K3({answers:e,assistantAgent:t,met:n,onMet:r,onCarriesOn:i,onClosed:o,navigate:l,onPickAnotherBrain:a}){const c=e.assistant,[u,p]=d.useState(n),[f,h]=d.useState([]),[x,j]=d.useState(!1),[w,b]=d.useState(!1),[v,m]=d.useState(!0),[y,g]=d.useState("open"),[k,S]=d.useState(!1),N=i1(),C=d.useRef(!1),P=d.useMemo(()=>t?[t]:[],[t]);d.useEffect(()=>{if(!c||C.current)return;if(C.current=!0,n){p(n);return}let D=!1;return(async()=>{try{const T=await Fe.startConversation(c.id);if(D)return;p(T.conversationId),r(T.conversationId),await A.onboardingStep(t1.handover,{conversationId:T.conversationId}).catch(()=>{}),await Fe.send(c.id,{conversationId:T.conversationId,text:qD,opening:!0})}catch{D||(m(!1),j(!0))}})(),()=>{D=!0}},[c==null?void 0:c.id,n]),d.useEffect(()=>{if(!u)return;let D=!1;const T=Date.now(),z=()=>{Fe.conversation(u).then(K=>{if(D)return;h(K.messages);const M=Date.now()-T;if(K.messages.some(hj)){m(!1),j(!1),b(!1);return}const W=K.runs??[],_=W.some(X=>X.finishedAt===null),U=W.length>0&&!_;b(_&&M>=b3),(U||M>=k3)&&(m(!1),j(!0))}).catch(()=>{})};z();const q=window.setInterval(z,r1);return()=>{D=!0,window.clearInterval(q)}},[u]);const E=c&&u?ze(c.id,u):null,O=f.some(hj);d.useEffect(()=>{O&&E&&i(E)},[O,E,i]),d.useEffect(()=>{if(!k||!E||N)return;const D=window.setTimeout(()=>l(E,!0),S3);return()=>window.clearTimeout(D)},[k,E,N,l]);const L=k&&E!==null;return d.useEffect(()=>{L&&o()},[L,o]),s.jsxs(s.Fragment,{children:[s.jsx(hk,{messages:f,live:[],now:Date.now(),onOpen:()=>{},working:v,agents:P,agentName:(c==null?void 0:c.name)??"",emptyHint:B.handover.waiting,plain:!0,workingLine:B.handover.looking((c==null?void 0:c.name)??"")}),w&&!x?s.jsx(Me,{children:s.jsx(Le,{children:B.handover.slow})}):null,x?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{children:B.handover.silent})}),s.jsx(Tt,{actions:s.jsx(R,{variant:"accent",onClick:a,children:B.handover.again})})]}):null,k?s.jsx(Me,{children:s.jsx(Le,{children:B.done.said})}):null,O&&y==="open"?s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{onClick:()=>g("phone"),children:B.offers.phone}),s.jsx(R,{variant:"accent",onClick:()=>{g("gone"),S(!0)},children:B.offers.notNow})]})}):null,O&&y==="phone"?s.jsx(G3,{onPaired:()=>S(!0),onDismiss:()=>{g("gone"),S(!0)}}):null,L&&E?s.jsx(Tt,{actions:s.jsx(Un,{variant:"accent",href:E,onClick:D=>{D.preventDefault(),l(E,!0)},children:B.done.open}),children:s.jsx("span",{className:"meet-line",children:N?B.done.ready:B.done.leaving})}):null]})}function hj(e){return e.role==="assistant"&&(e.blocks??[]).some(t=>t.type==="text"&&t.text.trim()!=="")}function G3({onPaired:e,onDismiss:t}){const n=El(),[r,i]=d.useState(""),[o,l]=d.useState(!1),[a,c]=d.useState(null),{offer:u,square:p,paired:f,stale:h,ask:x}=QS(()=>A.telegram().then(b=>b.paired),e),j=()=>{r.trim()===""||o||(l(!0),c(null),(async()=>{try{const b=await A.saveTelegramToken(r.trim());if(i(""),b.restartNeeded){c(b.note??B.telegram.restart);return}await x()}catch(b){c(b instanceof ce?b.message:String(b))}finally{l(!1)}})())},w=()=>{c(null),x().catch(b=>c(b instanceof ce?b.message:String(b)))};return f?s.jsx(Me,{children:s.jsx(Le,{children:B.telegram.paired})}):u?s.jsxs(s.Fragment,{children:[s.jsx(Me,{children:s.jsx(Le,{children:h?B.telegram.expired:B.telegram.scan})}),s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:t,children:B.offers.notNow}),h?s.jsx(R,{variant:"accent",onClick:w,children:B.telegram.newCode}):null]}),children:h?null:s.jsx(JS,{offer:u,square:p})})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Me,{children:[s.jsx(Le,{children:B.telegram.how}),a?s.jsx(Le,{children:a}):null]}),s.jsx(Tt,{actions:s.jsxs(s.Fragment,{children:[s.jsx(R,{variant:"ghost",onClick:t,children:B.offers.notNow}),s.jsx(R,{variant:"accent",disabled:o||r.trim()==="",onClick:j,children:B.telegram.submit})]}),children:s.jsx(ee,{label:B.telegram.field,grow:!0,children:s.jsx("input",{ref:n,type:"password",value:r,autoComplete:"off",spellCheck:!1,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),j())}})})})]})}const Y3="(max-width: 1080px)";function q3(){const[e,t]=d.useState(()=>window.location.hash||Vt);d.useEffect(()=>{const r=()=>t(window.location.hash||Vt);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]);const n=d.useCallback((r,i=!1)=>{i?window.history.replaceState(null,"",r):window.location.hash=r,t(r)},[]);return[e,n]}function Q3(){const[e,t]=Yk();d.useEffect(()=>{Gk(e)},[e]);const n=d.useCallback(r=>t({theme:r}),[t]);return[e.theme,n]}function J3(){var ct,_e;const[e,t]=q3(),[n,r]=d.useState("UTC"),[i,o]=d.useState({approvals:0,failed:0}),[l,a]=Q3(),c=Rh(dS),[u,p]=d.useState(!1),[f,h]=d.useState([]),[x,j]=d.useState(null),[w,b]=d.useState(null),[v,m]=d.useState([]),[y,g]=d.useState(!1),[k,S]=d.useState(null),N=z2(),C=Rh(Y3),P=fS(),E=zk(),O=se(()=>Promise.resolve().then(()=>A.version()),[],60*6e4).data,L=O&&!O.checkout&&O.updateAvailable?O:null,[D,T]=d.useState(new Map);d.useEffect(()=>{const $=()=>{A.conversations().then(xe=>{const be=new Map;for(const it of xe.conversations){const St=it.lastMessageAt??it.createdAt,cn=be.get(it.agentId);(!cn||St>cn)&&be.set(it.agentId,St)}T(be)}).catch(()=>{})};$();const de=window.setInterval($,3e4);return()=>window.clearInterval(de)},[e]);const[z,q]=d.useState(!1);d.useEffect(()=>{if(z)return;let $=!1;return A.onboarding().then(de=>{$||(q(!0),de.state==="pending"&&de.needs.model&&!lv(window.location.hash)&&t(h2,!0))}).catch(()=>{$||q(!0)}),()=>{$=!0}},[z,t]),d.useEffect(()=>{const $=C2(e);$&&t($,!0)},[e,t]),d.useEffect(()=>{let $=!1;const de=()=>{Fe.agents().then(be=>{$||(h(be.agents),I2(be.defaultAgentId??null),j(be.defaultAgentId??null),b(it=>{var St;return it??be.defaultAgentId??((St=be.agents[0])==null?void 0:St.id)??null}))}).catch(()=>{})};de();const xe=window.setInterval(de,15e3);return window.addEventListener("focus",de),window.addEventListener(ll,de),()=>{$=!0,window.clearInterval(xe),window.removeEventListener("focus",de),window.removeEventListener(ll,de)}},[e]),d.useEffect(()=>{let $=!1;const de=()=>{Fe.groups().then(be=>{$||m(be.groups)}).catch(()=>{})};de();const xe=window.setInterval(de,3e4);return()=>{$=!0,window.clearInterval(xe)}},[e]);const K=P0(f,x),M=m2(e),W=E0(e),_=W?v.find($=>$.id===W.groupId)??null:null,U=W?null:(M==null?void 0:M.agentId)??w;d.useEffect(()=>{M&&b(M.agentId)},[M==null?void 0:M.agentId]);const X=$=>{b($),t(ze($))},Z=$=>t(Fo($)),ue=d.useCallback(($,de,xe=!0)=>t(W?Fo(W.groupId,de):ze($,de),xe),[t,W==null?void 0:W.groupId]),[je,Ce]=d.useState(!1);d.useEffect(()=>{A.session().then($=>{r($.timezone),Ce(!0)}).catch(()=>{})},[]);const Pe=xO(je);bO(je,Pe.refresh,()=>Ce(!1)),d.useEffect(()=>{const $=()=>{A.overview().then(xe=>o({approvals:xe.approvals.pending,failed:xe.jobs.failed??0})).catch(()=>{})};$();const de=window.setInterval($,2e4);return()=>window.clearInterval(de)},[]);const Ve=lv(e),he=E2(e),ge=he===Fi,ye=k?v.find($=>$.id===k)??null:null,kt=y?s.jsx(Uv,{agents:f,onClose:()=>g(!1),onCreated:$=>{m(de=>[...de,$]),g(!1),t(Fo($.id))}}):ye?s.jsx(Uv,{agents:f,group:ye,onClose:()=>S(null),onSaved:$=>{m(de=>de.map(xe=>xe.id===$.id?$:xe)),S(null)},onArchived:$=>{m(de=>de.filter(xe=>xe.id!==$)),S(null),t(Fi)}}):null;return Ve?s.jsx(Yx,{delayDuration:400,children:s.jsxs(_x,{swipeDirection:"right",children:[s.jsx(N3,{navigate:t,timezone:n}),s.jsx(Ox,{className:"ui-toasts"})]})}):s.jsx(eI,{picture:(ct=f.find($=>$.id===x))==null?void 0:ct.picture,children:s.jsx(Yx,{delayDuration:400,children:s.jsxs(_x,{swipeDirection:"right",children:[kt,s.jsxs("div",{className:"wb-shell",children:[s.jsx(RL,{active:((_e=P.data)==null?void 0:_e.active)===!0,onNavigate:t}),s.jsxs("div",{className:"wb",children:[s.jsx(aD,{attention:i.approvals+i.failed,place:he,onNavigate:t,theme:l,onTheme:a,plugins:E.rail,updateAvailable:L!==null,version:O&&!O.checkout?{current:O.current,latest:O.latest,updateAvailable:O.updateAvailable}:O?{current:O.current,updateAvailable:!1}:void 0}),ge&&!C?s.jsx(D0,{agents:K,currentId:U,attention:N,onSelect:X,lastActivity:D,groups:v,currentGroupId:(_==null?void 0:_.id)??null,onSelectGroup:Z,onNewGroup:()=>g(!0)}):null,ge?s.jsx(iO,{timezone:n,agents:K,agentId:_?_.coordinator:U,defaultAgentId:x,group:_,onEditGroup:_?()=>S(_.id):void 0,requestedConversationId:(W==null?void 0:W.conversationId)??(M==null?void 0:M.conversationId),requestedTab:M==null?void 0:M.tab,onConversationOpened:ue,onSelectAgent:X,attention:N,agentsInHeader:C,narrow:c,canvasOpen:u,onOpenCanvas:()=>p(!0),onCloseCanvas:()=>p(!1)}):s.jsx("main",{"data-ground":X3(he,e)?"plain":void 0,"data-layout":he===Jt?"split":void 0,children:s.jsx(Z3,{hash:e,place:he,timezone:n,navigate:t,agents:f,defaultAgentId:x,attention:N,pluginPages:E,update:L})})]})]}),s.jsx(vO,{queue:Pe.queue,agents:f,navigate:t,onDismiss:Pe.dismiss}),s.jsx(Ox,{className:"ui-toasts"})]})})})}function X3(e,t){return fm(t)!==null}function Z3({place:e,pluginPages:t,...n}){const r={...n,pluginPages:t},i=fm(n.hash);if(i){const o=t.find(i.plugin,i.page);if(o)return s.jsx(Fk,{page:o,item:i.item??null,navigate:n.navigate,timezone:n.timezone,siblings:t.all.filter(l=>l.plugin===i.plugin)});if(t.all.length===0)return s.jsx(s.Fragment,{})}switch(e){case et:return s.jsx(uL,{...n});case Ze:return s.jsx(SD,{...n});case Jt:return s.jsx(Y4,{...r});case Lr:return s.jsx(rD,{...n});default:return s.jsx(pL,{...n})}}const pj=document.getElementById("root");pj&&Ew(pj).render(s.jsx(d.StrictMode,{children:s.jsx(J3,{})}));
|