@xopcai/xopc 0.0.174 → 0.0.176
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CyEDJeIt.js → activity-store-DsFM1upC.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DF7Bol6I.js → agent-avatar-dicebear-DvdMLOga.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +2 -0
- package/dist/gateway/static/root/assets/{api-DYunqroX.js → api-BdPLCCBm.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DwyUxpgY.js → api-Bop4IQRW.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4xJyvDu.js → app-management-settings-panel-DMLDOHul.js} +1 -1
- package/dist/gateway/static/root/assets/appearance-settings-DbI9foFR.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DWhBmmjD.js → archive-plugin-Dfdxuwvb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BOpZfa_I.js → attachment-load-Dn3RlnYD.js} +2 -2
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-DonnL2dL.js → attachment-preview-renderer-Cmo-5BP5.js} +2 -2
- package/dist/gateway/static/root/assets/{attachment-process-heavy-RnGYy9bC.js → attachment-process-heavy-B2_kr5EA.js} +3 -3
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Byu3I7Rs.js → automation-suggestion-card-Bc0Y7A9u.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-6AG1qatz.js → binary-plugins-0XtB-xC0.js} +2 -2
- package/dist/gateway/static/root/assets/{block-editor-CJhrn98_.js → block-editor-C4fXWbEE.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-lC86-drr.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CBVb4mt9.js → browser-workflow-inputs-CZmzNymN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Cq4XUKbu.js → browser-workflows-page-CBYM9HqG.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-hbW4NAKO.js → capability-presets-api-BiJxmmhW.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CzMjHb17.js → channel-recipient-api-BKTUZDp-.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-B9Au6gMZ.js → connector-logo-Pr4RIKjj.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNff5TFb.js → desktop-pet-settings-CEQacUDF.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Bf956uo-.js → directory-picker-path-field-DWnxdZtc.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CHM8FE1g.js → dreaming-settings-D2e2w2Ho.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-ZqM_0eUs.js → extension-debug-page-BLjTGbv3.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D4hvXOMM.js → extension-page-D2_UC6hy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-GsqxaJjA.js → extension-settings-page-BsH6o_PX.js} +1 -1
- package/dist/gateway/static/root/assets/{focus-detail-page-CE6uwrl1.js → focus-detail-page-BBXUtxRB.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B4THmgnS.js → gateway-config-api-C-DkC6UJ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CPv-MxGE.js → gateway-settings-DEOGiimF.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-MP3K71pP.js → gateway-startup-retry-BlSLh1TF.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CSFcRE_N.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-DCcDuIjG.js → goals-config-api-CcdS9qek.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BAcErdch.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-o9QMXvNq.js → goals-settings-BY7crl0z.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DixwpXnH.js → heartbeat-settings-DtTkS0gs.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BOGH9FGi.js → image-generation-api-WGgkbwDZ.js} +1 -1
- package/dist/gateway/static/root/assets/index-2UImfRDC.js +212 -0
- package/dist/gateway/static/root/assets/index-CS9sVShT.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D4o4ZPF6.js → keyboard-shortcuts-settings-C5lpWQ3f.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-GzMmpO7G.js → local-apps-page-b05wWvXG.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CAuhEGCn.js → locale-store-sToMfHX_.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-cDE1jLJv.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CIX8D1pv.js → markdown-split-0gPVst5y.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bp3eIA45.js → media-plugins-Rxyq_KTm.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CarlxqXV.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-RVFiYAoO.js → notes-page-DRhNDl_Q.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BGAYH3Ef.js → page-tabs-cOEOQqHh.js} +1 -1
- package/dist/gateway/static/root/assets/pdf-D4PI9qAw.js +54 -0
- package/dist/gateway/static/root/assets/pdf.worker.min-CHFwMXne.mjs +29 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BM6pDkHp.js → preview-open-alternatives-BopOLFvu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BiMetEmn.js → product-open-page-DWVPmmOq.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BdjV8MK5.js → save-bar-controls-BfZmKe1t.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-ChlqXU46.js → schedule-field-Cpi4jCRV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DDKf5ZSH.js → schema-form-OXFkcZQe.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CPG0KGVs.js → settings-form-section-BwqkZCHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DRSDHucM.js → settings-loading-skeleton-BbqH_S3Y.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CeB7_xD0.js → settings-page-BoxC-JSa.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BENrkwd0.js → settings-page-layout-Ddu2iGaW.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z1Lwv0js.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DIzczJkG.js → share-preview-page-CVazOFjy.js} +2 -2
- package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +2 -0
- package/dist/gateway/static/root/assets/skills-page.utils-DgyB1tSo.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dp4d5Q1B.js → system-settings-panel-BoLSQL65.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CbGc1laW.js → theme-store-CBNcGOfj.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-gochWrny.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-DwPk3OPL.js → typed-models-lib-DvRnr7YB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CXrEu2dw.js → use-channel-catalog-CA9BFVB7.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DFoA79LB.js → voice-api-key-field-v8tgylEZ.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +1 -0
- package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +3 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CC3cJn5k.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +8 -8
- package/dist/src/agent/context/execution-scope.d.ts +26 -0
- package/dist/src/agent/context/execution-scope.js +84 -0
- package/dist/src/agent/context/project-context.d.ts +3 -1
- package/dist/src/agent/context/project-context.js +26 -8
- package/dist/src/agent/embedded/model-runtime.d.ts +1 -2
- package/dist/src/agent/embedded/model-runtime.js +17 -29
- package/dist/src/agent/embedded/session-runner.js +2 -3
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -0
- package/dist/src/agent/prompt/system-prompt.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +7 -4
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/session/session-config-service.d.ts +4 -1
- package/dist/src/agent/session/session-config-service.js +5 -3
- package/dist/src/agent/session/session-inspector.d.ts +6 -0
- package/dist/src/agent/session/session-inspector.js +9 -2
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/skills/index.d.ts +2 -0
- package/dist/src/agent/skills/index.js +14 -5
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/test-framework.js +1 -1
- package/dist/src/agent/workflow/subagent-runner.js +2 -0
- package/dist/src/agent/workflow/types.d.ts +1 -0
- package/dist/src/auth/model-credential-store.d.ts +17 -0
- package/dist/src/auth/model-credential-store.js +110 -0
- package/dist/src/auth/oauth/github-copilot.js +2 -2
- package/dist/src/auth/oauth/openai-codex.js +98 -7
- package/dist/src/auth/oauth/types.d.ts +4 -1
- package/dist/src/auth/oauth/xopc-cloud.js +124 -6
- package/dist/src/automations/domain/defaults.d.ts +1 -0
- package/dist/src/automations/domain/defaults.js +4 -0
- package/dist/src/automations/domain/index.d.ts +1 -0
- package/dist/src/automations/domain/index.js +2 -1
- package/dist/src/automations/index.js +2 -1
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +21 -0
- package/dist/src/config/schema.js +12 -2
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -0
- package/dist/src/gateway/hono/oauth-async.d.ts +5 -0
- package/dist/src/gateway/hono/oauth-async.js +20 -8
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +9 -0
- package/dist/src/gateway/hono/routes/goals.js +13 -0
- package/dist/src/gateway/hono/routes/home.d.ts +16 -3
- package/dist/src/gateway/hono/routes/home.js +98 -25
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/project-skills.d.ts +3 -0
- package/dist/src/gateway/hono/routes/project-skills.js +119 -0
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +2 -1
- package/dist/src/gateway/service.js +5 -5
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/projects/index.d.ts +1 -0
- package/dist/src/projects/index.js +2 -1
- package/dist/src/projects/project-skill-service.d.ts +67 -0
- package/dist/src/projects/project-skill-service.js +131 -0
- package/dist/src/providers/index.js +4 -2
- package/dist/src/providers/provider-auth-service.d.ts +22 -0
- package/dist/src/providers/provider-auth-service.js +66 -0
- package/dist/src/providers/register-runtime-providers.d.ts +6 -0
- package/dist/src/providers/register-runtime-providers.js +55 -0
- package/dist/src/providers/xopc-cloud-account-service.d.ts +2 -2
- package/dist/src/providers/xopc-cloud-account-service.js +6 -5
- package/dist/src/providers/xopc-cloud-config.d.ts +3 -0
- package/dist/src/providers/xopc-cloud-config.js +13 -0
- package/dist/src/providers/xopc-cloud-model-source.d.ts +2 -2
- package/dist/src/providers/xopc-cloud-model-source.js +6 -5
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/thinking-resolve.d.ts +8 -0
- package/dist/src/session/thinking-resolve.js +6 -3
- package/dist/src/storage/sqlite/home-attention-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/home-attention-repository.js +21 -0
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/067_home_attention_acknowledgements.sql +9 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +10 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +2 -2
- package/dist/src/tui/xopc-tui-keybindings.d.ts +44 -4
- package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
- package/dist/src/workflows/engine/workflow-engine.js +2 -0
- package/dist/src/workflows/service/workflow-run-service.js +11 -5
- package/dist/src/workflows/service/workflow-session-bridge.js +2 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agents-BVxEFPQ5.js +0 -2
- package/dist/gateway/static/root/assets/appearance-settings-B2PQxRiu.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BtIgd82S.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-CG_SCH5b.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CfLqPWZC.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DCJmm6cR.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CnkAYvWI.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-DtqqFpDn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C-5yHbc0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CaHfs8YF.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CvFMKYdb.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DAeb82xP.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-CwLSp01r.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-DvJQ6_4M.js +0 -2
- package/dist/gateway/static/root/assets/index-CfXiRNN5.css +0 -1
- package/dist/gateway/static/root/assets/index-eyttVNS_.js +0 -212
- package/dist/gateway/static/root/assets/local-app-workbench-page-CPcfqn_A.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DXABWCZp.js +0 -7
- package/dist/gateway/static/root/assets/messages-BiBdO1-O.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-DgJzZRX3.js +0 -4
- package/dist/gateway/static/root/assets/pdf-epILhEOn.js +0 -54
- package/dist/gateway/static/root/assets/pdf.worker.min-iDqQPrd3.mjs +0 -31
- package/dist/gateway/static/root/assets/project-detail-page-DF7F70Vg.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Cw3jyi5s.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ChAJsaNY.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BxZIxt7z.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DcDLS0xV.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-4Xa9NA7v.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BpN0o5Cf.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DvF2UAaL.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CGKXpNfy.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-BhgCeDuO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Dy_fKAK_.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BWkjb1NK.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DLBNFse5.js +0 -1
- package/dist/gateway/static/root/assets/work-page-Bn5RXMIE.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BuniGPO0.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-_vFhRrAl.js +0 -11
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-BiBdO1-O.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-CAuhEGCn.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,Bo as g,Ec as _,Et as v,Go as y,Ho as b,Ms as x,Rr as S,Ss as C,To as w,Uo as T,Vo as E,Wl as D,Wo as O,Ws as k,ai as A,as as j,bc as M,ec as N,fc as P,ii as F,io as I,ks as L,ls as R,oa as z,pu as B,ri as ee,ro as V,tl as H,ts as te,us as ne,zo as re}from"./index-eyttVNS_.js";import{n as ie,r as ae}from"./settings-page-layout-BENrkwd0.js";import{n as oe}from"./settings-loading-skeleton-DRSDHucM.js";import{t as se}from"./schema-form-DDKf5ZSH.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le,t as ue}from"./channels-status-swr-C-5yHbc0.js";import{t as de}from"./use-channel-catalog-CXrEu2dw.js";var U=e(t(),1),W=n();function fe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var pe=e(ce(),1),G=r();async function me(e){let t=await d(f(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function he(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,U.useMemo)(()=>fe(e),[e]),o=(0,U.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,U.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,U.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,U.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await me({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,U.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),pe.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,U.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||me({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:he(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),he(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),g=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,G.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,G.jsxs)(L,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,G.jsx)(H,{className:`size-4 animate-spin`}):(0,G.jsx)(_,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,G.jsxs)(L,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,G.jsx)(N,{className:`size-4`}),f]}):null]})]}),p?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,g?(0,G.jsxs)(`div`,{className:s(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,G.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,G.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,G.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,G.jsx)(V,{className:`size-48 rounded-md`})})}),(0,G.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,G.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,G.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,G.jsx)(V,{className:`h-4 w-48 max-w-full`}),(0,G.jsx)(V,{className:`h-4 w-36 max-w-full`})]}),m?(0,G.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,G.jsx)(D,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,G.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,G.jsx)(B,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,G.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,v?(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsx)(se,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,G.jsx)(L,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?s(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,R):s(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,W.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,_=n===`drawer`,[v,S]=(0,U.useState)(null),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,G.jsx)(T,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),t[0]=w):w=t[0];let D;t[1]!==n||t[2]!==h?(D=Se(n,h),t[1]=n,t[2]=h,t[3]=D):D=t[3];let k;t[4]===c?k=t[5]:(k=c?(0,G.jsx)(y,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=k);let A;t[6]===l?A=t[7]:(A=l?(0,G.jsx)(b,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=A);let M;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==_||t[12]!==a?(M=_?(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,G.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,G.jsx)(g,{asChild:!0,children:(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,G.jsx)(x,{className:`size-5`,strokeWidth:1.75})})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(g,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:s(C,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,G.jsx)(x,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=_,t[12]=a,t[13]=M):M=t[13];let N=_?`p-4`:`p-6`,P;t[14]===N?P=t[15]:(P=s(`min-h-0 flex-1 overflow-y-auto`,N),t[14]=N,t[15]=P);let F;t[16]!==d||t[17]!==P?(F=(0,G.jsx)(`div`,{className:P,children:d}),t[16]=d,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==f||t[20]!==v||t[21]!==k||t[22]!==A||t[23]!==M||t[24]!==F?(I=(0,G.jsxs)(j,{layer:`modal`,portalContainer:v,children:[k,A,M,F,f]}),t[19]=f,t[20]=v,t[21]=k,t[22]=A,t[23]=M,t[24]=F,t[25]=I):I=t[25];let R;t[26]!==I||t[27]!==D?(R=(0,G.jsxs)(O,{children:[w,(0,G.jsx)(E,{ref:S,className:D,onOpenAutoFocus:we,children:I})]}),t[26]=I,t[27]=D,t[28]=R):R=t[28];let z;return t[29]!==i||t[30]!==r||t[31]!==R?(z=(0,G.jsx)(re,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=z):z=t[32],z}function we(e){return e.preventDefault()}var Te=(0,U.memo)(function(e){let t=(0,W.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,G.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,G.jsx)(z,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,G.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,W.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,G.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,G.jsx)(L,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,G.jsx)(L,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,G.jsx)(L,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,G.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,G.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,W.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,U.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(e),r=fe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Xe(e,t){let n=fe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Qe(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,U.useState)(!1),i=(0,U.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,G.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,G.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,G.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,W.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=s(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=s(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,G.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,W.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,G.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,G.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,G.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,G.jsx)(et,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,G.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,G.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,G.jsx)(H,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,G.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,G.jsxs)(L,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,G.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function nt(e){return(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,G.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,W.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?B:n===`stopped`||n===`needs_setup`?o:H,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=s(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,G.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===l.connectionStatus?x=t[10]:(x=(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=x);let S;t[11]!==l||t[12]!==n?(S=Re(n,l),t[11]=l,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,G.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,D;t[22]===i?D=t[23]:(D=i?(0,G.jsx)(H,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=D);let O=i?l.checkingConnection:l.checkConnection,k;t[24]!==d||t[25]!==E||t[26]!==D||t[27]!==O?(k=(0,G.jsxs)(L,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:d,children:[D,O]}),t[24]=d,t[25]=E,t[26]=D,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(A=n===`stopped`?(0,G.jsxs)(L,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,G.jsx)(H,{className:`size-4 animate-spin`}):(0,G.jsx)(M,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=A):A=t[35];let j;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(j=c?(0,G.jsx)(L,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=j):j=t[43];let N;t[44]!==k||t[45]!==A||t[46]!==j?(N=(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[k,A,j]}),t[44]=k,t[45]=A,t[46]=j,t[47]=N):N=t[47];let P;return t[48]!==T||t[49]!==N?(P=(0,G.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,N]})}),t[48]=T,t[49]=N,t[50]=P):P=t[50],P}function at(e){let t=(0,W.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,G.jsx)(k,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,G.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,G.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,G.jsx)(`li`,{children:Qe(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,G.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,G.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,G.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,G.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=a(),{channelId:o}=i(),p=A(o),g=de(n,e),_=g.entries,{data:y,mutate:b,isValidating:x}=m(n?ue():null,le,{revalidateOnFocus:!0}),{data:C,mutate:T}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),E=C?.channels??{},O=C?.bindings??[],{data:k}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),j=w(e=>e.setPageHeader),M=w(e=>e.clearPageHeader),N=(0,U.useMemo)(()=>_.find(e=>e.id===p),[p,_]),I=N?Ie(N):null,{data:L,mutate:R}=m(n&&I?je(I):null,()=>Me(I)),[z,B]=(0,U.useState)(null),[V,H]=(0,U.useState)(!1),[ne,re]=(0,U.useState)(null),[ce,W]=(0,U.useState)(null),[pe,me]=(0,U.useState)(!1),[he,K]=(0,U.useState)(null),[q,J]=(0,U.useState)(null),_e=z??L??{},Y=t.channelsSettings,be=(0,U.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,U.useMemo)(()=>We(be,Ne),[be]),we=(0,U.useMemo)(()=>Be(N),[N]),De=(0,U.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,U.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,U.useMemo)(()=>Ge(De),[De]),Re=N?q??ve(O,N.id):``,Z=(0,U.useMemo)(()=>(k?.items??[]).map(e=>{let n=S(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),Ue=Ve?S(Ve,t.agentsSettings):k?.defaultId??``,Ke=(0,U.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,U.useMemo)(()=>new Map((y??[]).map(e=>[e.name,e])),[y]),Je=y!==void 0,Ye=(0,U.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,U.useCallback)(async()=>{await Promise.all([g.mutate(),b()])},[g,b]);Ae((0,U.useCallback)(e=>{let t=Oe(e);t&&b(t,!1)},[b]),n);let Xe=(0,U.useMemo)(()=>n?(0,G.jsx)(Te,{ch:Y,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,Y,n,x,Q]);(0,U.useLayoutEffect)(()=>(j({startExtra:null,main:(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,j]);let Ze=(0,U.useCallback)(e=>{r(F(e)),B(null),J(null),K(null)},[r]),Qe=(0,U.useCallback)(()=>{r(ee),B(null),J(null),K(null)},[r]),nt=(0,U.useCallback)(async e=>{W(e.id),K(null);try{let t=await d(f(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(null)}},[Q]);(0,U.useEffect)(()=>{J(null),me(!1)},[N?.id]);let rt=(0,U.useCallback)(async()=>{if(!N||!z&&q===null)return!1;let e=Ie(N);H(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(O,N.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await g.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{H(!1)}},[N,q,O,g,z,T,R]),ot=(0,U.useCallback)(async e=>{let t=X(e),n=Ie(e),r=N?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}re(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await g.mutate(),await T(),await b(),N?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{re(null)}},[N?.id,g,z,T,R,b,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!X(N).ready||pe:!1;return n?(0,G.jsxs)(ae,{gap:`gap-4`,children:[g.isLoading?(0,G.jsx)(oe,{sections:2}):g.error?(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,G.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,G.jsx)(tt,{entry:e,config:E[Ie(e)]?.config,runtime:Ye(e),busy:ne===e.id,restarting:ce===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),he?(0,G.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:he}):null,(0,G.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:N?.label??Y.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,G.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:V,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:N?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)($e,{entry:N}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,G.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,G.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(N).ready&&fe(N)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,G.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,G.jsx)(D,{className:`size-3.5`})]}):null]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,G.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(N).enabled?Y.enabledLabel:Y.disabledLabel}),(0,G.jsx)(et,{checked:X(N).enabled,disabled:ne===N.id,label:Y.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void ot(N)})]})]})}),(0,G.jsx)(it,{runtime:ct,restarting:ce===N.id,checking:x,showConnectionOptions:pe,canManageConnection:X(N).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(N),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,G.jsx)(at,{entry:N,ch:Y}),lt&&$?.placement!==`replace-config`?(0,G.jsx)(ge,{entry:N,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,G.jsx)(v,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,G.jsx)(v,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Fe?(0,G.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`mb-4`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,G.jsx)(se,{schema:De,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})]}):null,(0,G.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(P,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,G.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,G.jsx)(te,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:V||!k,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,G.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(P,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,G.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,G.jsx)(se,{schema:ke,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})})]}):null,he?(0,G.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:he}):null]}):null})]}):(0,G.jsxs)(ae,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,G.jsx)(ie,{title:t.settingsSections.channels}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./locale-store-CAuhEGCn.js";import{n as t}from"./channel-recipient-api-CzMjHb17.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-BiBdO1-O.js";import{l as u,n as d,r as f,s as p}from"./locale-store-CAuhEGCn.js";import{Ac as m,Bi as h,Bo as g,Ci as _,Cs as v,Ei as y,Go as b,Gs as x,Hc as S,Hi as C,Ho as w,Ko as T,Ls as E,Mc as D,Ms as O,Nc as k,Ns as A,Os as j,Qs as M,Rc as N,Rl as P,Sc as F,Si as I,To as L,Ui as R,Uo as z,Vi as B,Vo as ee,Wi as V,Wl as te,Wo as ne,Yl as re,_u as ie,bs as ae,fc as oe,gl as se,hc as ce,is as H,iu as le,jc as ue,ks as U,lc as de,ls as fe,no as pe,ns as me,oa as he,pc as ge,pu as _e,ru as ve,tc as ye,tl as W,to as G,ts as be,us as K,vc as q,wi as xe,xi as J,zo as Y}from"./index-eyttVNS_.js";import{t as Se}from"./page-tabs-BGAYH3Ef.js";import{A as Ce,C as we,D as Te,E as Ee,M as De,N as Oe,O as ke,P as Ae,S as je,T as Me,_ as Ne,a as Pe,b as Fe,c as Ie,d as Le,f as Re,g as ze,h as Be,i as Ve,j as He,k as Ue,l as We,m as Ge,n as Ke,o as qe,p as Je,r as Ye,s as Xe,t as Ze,u as Qe,v as $e,w as et,x as tt,y as nt}from"./connector-logo-B9Au6gMZ.js";var X=e(t(),1),Z=n(),Q=r();function rt(e){let t=(0,Z.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o.connect||t[5]!==o.connectedBadge||t[6]!==o.connectorBeta||t[7]!==o.connectorCapabilityLabels||t[8]!==o.connectorExperimental||t[9]!==o.connectorVerified){let e=n.capabilities.filter(it),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=o.connect,x=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==b||t[21]!==n||t[22]!==i?(C=e=>(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:s(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(S,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=C):C=t[23],c=C;let w;t[24]!==n||t[25]!==a?(w=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=w):w=t[26];let T=w,E=a?`cursor-pointer`:null;t[27]===E?p=t[28]:(p=s(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=p),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=t[31],_=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Q.jsx)(Ze,{connector:n}),t[32]=n,t[33]=D);let O;t[34]===n.displayName?O=t[35]:(O=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=O);let k;t[36]===x?k=t[37]:(k=x?(0,Q.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:x}):null,t[36]=x,t[37]=k);let A;t[38]!==O||t[39]!==k?(A=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==D||t[42]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,A]}),t[41]=D,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==r||t[45]!==c?(M=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==o.connectedBadge?(N=r?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(_e,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=N):N=t[49];let P;t[50]!==M||t[51]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[M,N]}),t[50]=M,t[51]=N,t[52]=P):P=t[52],t[53]!==j||t[54]!==P?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,P]}),t[53]=j,t[54]=P,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=v.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),y>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o.connect,t[5]=o.connectedBadge,t[6]=o.connectorBeta,t[7]=o.connectorCapabilityLabels,t[8]=o.connectorExperimental,t[9]=o.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=t[18],_=t[19];let v;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(v=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==c?(y=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==_?(b=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[66]=v,t[67]=y,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=_,t[73]=b):b=t[73],b}function it(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var at=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ot(e,t){return t.some(t=>t.connectorId===e.id)}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,Z.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 min-w-0 flex-1`,st)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,Q.jsx)(`div`,{className:s(`h-3 w-full`,st)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-[88%]`,st)})]})]})}),e[1]=n):n=e[1],n}var lt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ut(){let e=(0,Z.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,lt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 w-48 max-w-full`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,lt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,lt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-8 w-20 rounded-md`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,lt)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,lt)})]}),(0,Q.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}function dt(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function ft(e,t){return t.connectorCapabilityLabels[e]??e}function pt(e,t){if(e.runtime.type===`mcp`)return dt(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return dt(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function mt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function ht(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function gt(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(_t),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function _t(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function vt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(null),f=ht(e),p=e.capabilities.slice(0,8),m=Math.max(0,e.capabilities.length-p.length),h=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],_=async()=>{o(!0),d(null);try{l(await Fe(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Q.jsx)(Y,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(z,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(ee,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(_e,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(b,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(w,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,v.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?dt(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:mt(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:ft(e,i)},e)),m>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,m]}):null]})]}),u?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(gt,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(gt,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(gt,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??dt(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:mt(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),h.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:h.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ge,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:pt(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void _(),children:[a?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(U,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(k,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(S,{className:`size-4`}),i.connect]})]})]})]})})}var yt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j);function bt(e){let t=(0,Z.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(z,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(ue,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let h;t[5]===l.runtimeSettingsTitle?h=t[6]:(h=(0,Q.jsx)(b,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=h);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let y;t[9]!==h||t[10]!==_?(y=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[h,_]})]}),t[9]=h,t[10]=_,t[11]=y):y=t[11];let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,v.focusRingPanel),t[12]=x):x=t[12];let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let C;t[14]===l.modalClose?C=t[15]:(C=(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:x,"aria-label":l.modalClose,children:S})}),t[14]=l.modalClose,t[15]=C);let T;t[16]!==C||t[17]!==y?(T=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[y,C]}),t[16]=C,t[17]=y,t[18]=T):T=t[18];let E;t[19]===u.idleTtlLabel?E=t[20]:(E=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=E);let D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=s(yt,`w-40 flex-none`),t[21]=D):D=t[21];let k=r??``,A;t[22]===a?A=t[23]:(A=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=A);let j;t[24]!==u.idleTtlPlaceholder||t[25]!==k||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:D,value:k,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=k,t[26]=A,t[27]=j):j=t[27];let M;t[28]===u.idleTtlHint?M=t[29]:(M=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=M);let N;t[30]!==E||t[31]!==j||t[32]!==M?(N=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[E,j,M]})}),t[30]=E,t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(P=(0,Q.jsx)(U,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=P):P=t[37];let F;t[38]===o?F=t[39]:(F=()=>void o(),t[38]=o,t[39]=F);let I;t[40]===i?I=t[41]:(I=i?(0,Q.jsx)(W,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=I);let L;t[42]!==u.save||t[43]!==i||t[44]!==F||t[45]!==I?(L=(0,Q.jsxs)(U,{type:`button`,variant:`primary`,disabled:i,onClick:F,children:[I,u.save]}),t[42]=u.save,t[43]=i,t[44]=F,t[45]=I,t[46]=L):L=t[46];let R;t[47]!==P||t[48]!==L?(R=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[P,L]}),t[47]=P,t[48]=L,t[49]=R):R=t[49];let B;t[50]!==T||t[51]!==N||t[52]!==R?(B=(0,Q.jsxs)(ne,{children:[f,(0,Q.jsxs)(ee,{className:p,children:[T,N,R]})]}),t[50]=T,t[51]=N,t[52]=R,t[53]=B):B=t[53];let V;return t[54]!==n||t[55]!==d||t[56]!==B?(V=(0,Q.jsx)(Y,{open:n,onOpenChange:d,children:B}),t[54]=n,t[55]=d,t[56]=B,t[57]=V):V=t[57],V}var xt=(0,X.memo)(function(e){let t=(0,Z.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=s(`relative flex min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface`,a),t[0]=a,t[1]=o);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(ce,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`label`,{className:o,children:[c,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}),St=(0,X.memo)(function(e){let t=(0,Z.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(oe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(m,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(ie,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=h):h=t[8];let g;t[9]===a?g=t[10]:(g=(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsxs)(U,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,h]})}),t[9]=a,t[10]=g);let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,v.transition),t[11]=b):b=t[11];let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(M,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=x):x=t[12];let S;t[13]!==o||t[14]!==n?(S=(0,Q.jsxs)(I,{className:b,onSelect:n,children:[x,o]}),t[13]=o,t[14]=n,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,v.transition),t[16]=C):C=t[16];let w;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(A,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=w):w=t[17];let T;t[18]!==c||t[19]!==r?(T=(0,Q.jsxs)(I,{className:C,onSelect:r,children:[w,c]}),t[18]=c,t[19]=r,t[20]=T):T=t[20];let E;t[21]!==T||t[22]!==S?(E=(0,Q.jsx)(_,{children:(0,Q.jsxs)(J,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[S,T]})}),t[21]=T,t[22]=S,t[23]=E):E=t[23];let D;t[24]!==E||t[25]!==g?(D=(0,Q.jsxs)(xe,{children:[g,E]}),t[24]=E,t[25]=g,t[26]=D):D=t[26];let O;return t[27]!==D||t[28]!==f?(O=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,D]}),t[27]=D,t[28]=f,t[29]=O):O=t[29],O}),Ct=/^([^:=]+)[:=](.*)$/;function wt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Ct.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Tt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Et(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function Dt(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Ot(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Dt(t)&&(r[e]=t);return r}function kt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function At(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function jt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=kt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=At(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Tt(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function Mt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Et(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function Nt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function Pt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||Dt(t)?[]:[Mt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Ft(e){return jt(e)}async function It(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=jt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await p(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),G()}function Lt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Rt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function zt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Bt(e,t){let n=await p(f(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Lt(n.payload.tools),i=Rt(n.payload.resources),a=zt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function Vt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Ht(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Ut(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,f]=(0,X.useState)(null),p=Ut(e),m=(0,X.useCallback)(async()=>{o(!0),f(null);try{let t=await Bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,X.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(U,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(x,{className:`size-4`}),t.removeServer]})]})]})]})}function Gt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Kt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Gt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function qt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Jt(e){let t=(0,Z.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,X.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Kt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===o?d=t[8]:(d=o.trim(),t[7]=o,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(ce,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,j),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,Q.jsxs)(`div`,{className:`relative`,children:[p,(0,Q.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==a||t[24]!==r?(y=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||qt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Yt(e){let t=(0,Z.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(z,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,K)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=s(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,fe,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(A,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,Q.jsxs)(b,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let y;t[5]!==i||t[6]!==o||t[7]!==f.length?(y=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=y):y=t[8];let x;t[9]===y?x=t[10]:(x=(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=x);let S;t[11]!==v||t[12]!==x?(S=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[v,x]}),t[11]=v,t[12]=x,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[14]=C):C=t[14];let T;t[15]===d?T=t[16]:(T=(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:C})}),t[15]=d,t[16]=T);let E;t[17]!==S||t[18]!==T?(E=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[S,T]}),t[17]=S,t[18]=T,t[19]=E):E=t[19];let D;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(D=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Jt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=D):D=t[27];let k;t[28]===d?k=t[29]:(k=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(U,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=k);let j;t[30]!==E||t[31]!==D||t[32]!==k?(j=(0,Q.jsxs)(ne,{children:[m,(0,Q.jsxs)(ee,{className:h,children:[E,D,k]})]}),t[30]=E,t[31]=D,t[32]=k,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,Q.jsx)(Y,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}var Xt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j);function Zt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Qt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function $t(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function en({instance:e,t,onChanged:n}){let r=Zt(e),[i,o]=(0,X.useState)([]),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)([]),[v,y]=(0,X.useState)(null),[b,S]=(0,X.useState)([]),[C,w]=(0,X.useState)(`read`),[E,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),M=(0,X.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){k(!0),j(null);try{let[t,n,i,a,s,c,u,f]=await Promise.all([Be().catch(()=>[]),ze(r).catch(()=>[]),Ne(20).catch(()=>[]),Le(r).catch(()=>`read`),$e().catch(()=>[]),Qe(r).catch(()=>null),We(r).catch(()=>null),nt().catch(()=>[])]);o(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),w(a),p(s.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),y(u),S(f)}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,e.materialized,r]);(0,X.useEffect)(()=>{M()},[M]);let P=(0,X.useCallback)(async()=>{if(r){k(!0),j(null);try{let t=await ke(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(T()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);await Te((await Ae(r,t.connectionId)).id),await n?.(),await M()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,M,n,r]),I=(0,X.useCallback)(async e=>{if(r){w(e);try{await Me(r,e),await M()}catch(e){j(e instanceof Error?e.message:String(e))}}},[M,r]),L=(0,X.useCallback)(async(e,t)=>{k(!0),j(null);try{await we(e,t),await M()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},[M]),R=(0,X.useCallback)(async e=>{if(r){j(null);try{h(await De(r,e))}catch(e){j(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),z=(0,X.useCallback)(e=>{m&&R({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[R,m]),B=(0,X.useCallback)(async e=>{k(!0),j(null);try{await e(),await M()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},[M]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:E,onClick:()=>void P(),children:[E?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(se,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(U,{variant:`ghost`,disabled:E,onClick:()=>void M(),children:t.refresh})]})]}),A?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:A}):null,v?(0,Q.jsxs)(`div`,{className:s(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,v.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:v.status===`connected`?$(t.composioHealthConnected,{count:String(v.activeConnections)}):v.status===`reauthorization_required`?t.composioHealthReconnect:v.status===`degraded`?$t(v,t):t.composioHealthDisconnected}),v.recovery===`none`?null:(0,Q.jsx)(U,{variant:`ghost`,disabled:E,onClick:()=>void(v.recovery===`retry`?M():P()),children:v.recovery===`retry`?t.composioRetry:t.connectOAuth}),v.status===`degraded`&&v.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:v.message}):null]}):null,m?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(me,{className:s(Xt,`mt-1 h-9 py-1`),value:C,onChange:e=>void I(e.currentTarget.value),children:[(0,Q.jsx)(H,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(H,{value:`write`,children:t.composioAccessReadWrite}),C===`admin`?(0,Q.jsx)(H,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:C===`read`?t.composioAccessReadHint:C===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(me,{className:s(Xt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void R({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(H,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(H,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(H,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>z(e.id),children:e.name},e.id))})]})]}):null,f.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:E,onClick:()=>void L(e.id,`denied`),children:[(0,Q.jsx)(O,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(U,{disabled:E,onClick:()=>void L(e.id,`approved`),children:[(0,Q.jsx)(a,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),i.length?i.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(()=>{let n=b.find(t=>t.connectionId===e.id);return n?(0,Q.jsx)(`p`,{className:s(`text-xs`,n.status===`failed`?`text-red-600`:`text-fg-subtle`),children:$(t.connectorLearningStatus,{status:n.status,count:String(n.candidatesCreated)})}):null})(),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),(0,Q.jsx)(`input`,{className:s(Xt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&B(()=>He(e.id,{alias:t.currentTarget.value}))}}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:E||e.isDefault,onClick:()=>void B(async()=>{await He(e.id,{isDefault:!0}),r&&await De(r,{selectedConnectionIds:[e.id]})}),children:(0,Q.jsx)(ye,{className:s(`size-4`,e.isDefault&&`fill-current`)})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:E,onClick:()=>void B(()=>tt(e.id)),children:(0,Q.jsx)(F,{className:`size-4`})}),(0,Q.jsx)(U,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:E,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&B(()=>et(e.id))},children:(0,Q.jsx)(x,{className:`size-4 text-red-500`})})]}),e.status===`active`?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(U,{variant:`secondary`,className:`flex-1`,disabled:E,onClick:()=>void B(async()=>{await Te(e.id),await n?.()}),children:[E?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(F,{className:`size-4`}),t.composioSyncNow]}),(0,Q.jsx)(U,{variant:`ghost`,disabled:E||!b.some(t=>t.connectionId===e.id),onClick:()=>void B(async()=>{let t=b.find(t=>t.connectionId===e.id)?.status!==`paused`;await Ee(e.id,t)}),children:b.find(t=>t.connectionId===e.id)?.status===`paused`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{className:`size-4`}),t.connectorLearningResume]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N,{className:`size-4`}),t.connectorLearningPause]})})]}):null]},e.id)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(me,{className:s(Xt,`mt-1 h-9 py-1`),value:C,onChange:e=>void I(e.currentTarget.value),children:[(0,Q.jsx)(H,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(H,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(H,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Qt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var tn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j);function nn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function rn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function an(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function on(e){let t=(0,Z.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,Q.jsx)(B,{children:(0,Q.jsx)(h,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,c;t[2]===n?c=t[3]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,o]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function sn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),[h,_]=(0,X.useState)(null),[y,S]=(0,X.useState)(null),[C,T]=(0,X.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[E,D]=(0,X.useState)(!1),[j,M]=(0,X.useState)(()=>rn(t,e)),[N,F]=(0,X.useState)(null),I=t?.setup.config??[],L=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&I.length>0&&(t?.setup.secrets??[]).length===0,R=y?y.toolCount:e.usage.lastToolCount,B=(0,X.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,de,i.detailHealth],[`tools`,A,`${i.detailTools} ${y?y.toolCount:e.usage.lastToolCount??``}`],[`resources`,re,`${i.detailResources} ${y?y.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,P,`${i.detailPrompts} ${y?y.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,se,i.detailPermissions]]:[[`permissions`,se,i.detailPermissions]];return L?[...t,[`config`,re,i.connectorConfigLabel]]:t},[y,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,L,i]),V=(0,X.useCallback)(async()=>{c(!0),F(null);try{let t=await Ce(e.instanceId);S(t),t.toolCount>0&&T(`tools`),r()}catch(e){F(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),te=(0,X.useCallback)(async()=>{u(!0),F(null);try{await je(e.instanceId),await r(),n()}catch(e){F(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ie=(0,X.useCallback)(async()=>{if(!(!t||!L)){f(!0),F(null);try{let n={};for(let e of t.setup.config??[]){let t=an(e.type,j[e.key]??``);t!==void 0&&(n[e.key]=t)}await Oe(e.instanceId,{config:n}),await r(),T(`health`)}catch(e){F(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[j,t,e.instanceId,r,L]),ae=(0,X.useCallback)(async()=>{m(!0),_(null),F(null);try{_((await Ue(e.connectorId)).recordIds.length),await r()}catch(e){F(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(Y,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(z,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(ee,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,v.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[N?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:B.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:s(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,C===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>T(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[C===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:y?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:nn(y?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),y?.action?(0,Q.jsx)(`p`,{children:y.action}):null]}):null,C===`tools`?y?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(y.tools.length)})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>D(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.tools.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:R?$(i.toolsLastCheckSummary,{count:String(R)}):i.toolsRunTestHint}),(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),i.test]})]}):null,C===`resources`?y?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.resources.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,C===`prompts`?y?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.prompts.slice(0,8).map(e=>(0,Q.jsx)(on,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,C===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,C===`config`&&L?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:I.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:tn,value:j[e.key]??``,placeholder:e.placeholder,onChange:t=>M(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(en,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),h===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(h)})})]}),(0,Q.jsxs)(U,{disabled:p,onClick:()=>void ae(),children:[p?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(re,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(U,{variant:`secondary`,onClick:n,children:i.modalClose}),C===`config`&&L?(0,Q.jsxs)(U,{variant:`primary`,disabled:d,onClick:()=>void ie(),children:[d?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(q,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:l,onClick:()=>void te(),children:[l?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(x,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Yt,{open:E,onOpenChange:D,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:y?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var cn=[`understand`,`act`,`reach`];function ln(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function un(e){return ln(e)[0]??`act`}function dn(e,t){let n=t?un(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function fn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(null),m=(0,X.useCallback)(async()=>{l(!0),p(null);try{await Ce(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},[e.instanceId,i]),h=(0,X.useCallback)(async()=>{d(!0),p(null);try{await je(e.instanceId),await i()}catch(e){p(e instanceof Error?e.message:String(e)),d(!1)}},[e.instanceId,i]),g=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,_=e.usage.lastToolCount??0,v=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),y=dn(e,t).state,b=y===`ready`?{label:a.connectionReady,Icon:_e,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:y===`needs_setup`?{label:a.connectionNeedsSetup,Icon:o,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:ve,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:s(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,b.className),children:[(0,Q.jsx)(b.Icon,{className:`size-3`,"aria-hidden":!0}),b.label]}),v?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,g]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(_)})})]}),f?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:f}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[y===`needs_setup`?(0,Q.jsxs)(U,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(o,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(U,{variant:`secondary`,disabled:c,onClick:()=>void m(),children:[c?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(U,{variant:`ghost`,disabled:u,onClick:()=>void h(),children:[u?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(x,{className:`size-4`}),a.remove]})]})]})]})}var pn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j),mn=s(pn,`min-h-28 font-mono`);function hn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function gn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function _n(e){let t=(0,Z.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(vn),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function vn(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function yn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,[l,u]=(0,X.useState)(!o),[d,f]=(0,X.useState)(o),[p,m]=(0,X.useState)(``),[h,_]=(0,X.useState)(null),[y,x]=(0,X.useState)(!0);(0,X.useEffect)(()=>{if(!o)return;let e=!1;return Re().then(({configured:t})=>{e||u(t)}).catch(t=>{e||_(t instanceof Error?t.message:String(t))}).finally(()=>{e||f(!1)}),()=>{e=!0}},[a.id,o]);let C=e.result?`complete`:e.installing?`health`:`configure`,E=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],D=(0,X.useCallback)(async()=>{let n=T(),i=o&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),_(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!l&&(await Ke(p),u(!0));let s={};for(let t of a.setup.config??[]){let n=gn(t.type,e.config[t.key]??``);n!==void 0&&(s[t.key]=n)}let d=e.store?await Ge(e.store.packageName,{secrets:e.secrets,config:s},e.store.version):await Je(a.id,{secrets:e.secrets,config:s,definition:a.source===`registry`?a:void 0}),f=null;try{if(o)if((c?await We(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await Ae(c);y&&await Te(e.id)}else{let e=await ke(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await Ae(c,e.connectionId);i?.close(),y&&await Te(t.id)}}catch(n){i?.close(),t({...e,installing:!1,result:d,health:null,error:n instanceof Error?n.message:String(n)}),await r(d);return}if(!o)try{f=await Ce(d.instanceId)}catch{f=null}t({...e,installing:!1,result:d,health:f}),await r(d)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[p,l,c,a,e,o,y,t,r]);return(0,Q.jsx)(Y,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(z,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(ee,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(Ze,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(w,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,v.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:E.map((e,t)=>{let n=E.findIndex(e=>e.id===C);return(0,Q.jsxs)(`div`,{className:s(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&!l?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Q.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Q.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Q.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Q.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Q.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(ae,{className:`mt-3`,value:p,onChange:m,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,o?(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:y,onChange:e=>x(e.currentTarget.checked)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,e.store?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Q.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Q.jsx)(ae,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Q.jsx)(`textarea`,{className:mn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Q.jsx)(`input`,{className:pn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Q.jsx)(W,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,h?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:hn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(_n,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(_n,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(_n,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(U,{variant:`primary`,disabled:!!e.result||e.installing||d||o&&!l&&!p.trim(),onClick:()=>void D(),children:[e.installing?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(_e,{className:`size-4`}):(0,Q.jsx)(S,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function bn(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function xn(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return Nt(r)}function Sn(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function Cn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await c();if(!e){window.alert(a);return}let t=wt(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:s(Cn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>f(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:s(Cn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Q.jsx)(x,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Sn(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,v.press),onClick:p,children:[`+ `,n]})]})}var Tn=[`stdio`,`sse`,`streamable-http`];function En(e){let t=(0,Z.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Dn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,j)}function On(e){let t=(0,Z.c)(29),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,c=o===void 0?`all`:o,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(me,{className:Dn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Tn.map(e=>(0,Q.jsx)(H,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(En,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:Dn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(En,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(En,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(En,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:Dn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(En,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:s(Dn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(En,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:s(Dn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(wn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Q.jsx)(En,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:Dn(),value:Vt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Ht(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function kn(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function An(e){let t=(0,Z.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=kn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==o?(u=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Q.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(R,{children:[(0,Q.jsx)(V,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:l,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Q.jsx)(B,{children:(0,Q.jsx)(h,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function jn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,X.useState)(n),[m,h]=(0,X.useState)(!1),[_,y]=(0,X.useState)(!1),[x,S]=(0,X.useState)(null),[C,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)({status:`idle`}),[j,M]=(0,X.useState)(null),N=n.id.trim(),P=f.id.trim()!==N&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Ut(f),R=(0,X.useCallback)(async()=>{if(f.id.trim()){y(!0),S(null),D({status:`loading`});try{D({status:`ok`,tools:(await Bt(f.id.trim(),Ft(f))).tools})}catch(e){D({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},[f]),B=(0,X.useCallback)(async()=>{if(!(!I||m)){h(!0),S(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await It({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ot(a)),await d(),u()}catch(e){S(e instanceof Error?e.message:String(e))}finally{h(!1)}}},[I,a,r,n.clientKey,t,u,d,N,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(ne,{children:[(0,Q.jsx)(z,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(ee,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,v.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(O,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(ge,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Q.jsx)(On,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),S(null)},idConflictMessage:P??F})]}),E.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(A,{className:`size-4 text-accent`,"aria-hidden":!0}),E.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(E.tools.length))]}),E.tools.length>0?(0,Q.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>M(E.tools),children:c.viewAllTools}):null]}),E.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:E.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(An,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,E.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E.message}):null,x?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:x}):null,(0,Q.jsxs)(`details`,{open:C,onToggle:e=>T(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(ie,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(On,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),S(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(U,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void R(),children:[_?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(g,{asChild:!0,children:(0,Q.jsx)(U,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(U,{variant:`primary`,disabled:!I||m,onClick:()=>void B(),children:[m?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):(0,Q.jsx)(_e,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),j?(0,Q.jsx)(Yt,{open:!0,onOpenChange:e=>{e||M(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:j,stripPrefix:`${f.id.trim()}__`}):null]}):null}function Mn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Nn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Pn(e,t,n){return e.filter(e=>Nn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Fn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function In(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Ln=`all`,Rn=`builtin`,zn=`composio`,Bn=`xopc-store`;function Vn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function Hn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Un(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),a=!!r,[o,c]=i(),[f,p]=(0,X.useState)(o.get(`tab`)===`connected`?`connected`:`discover`),m=(0,X.useRef)(!1),[h,g]=(0,X.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(1),[C,w]=(0,X.useState)(void 0),[T,D]=(0,X.useState)(``),[O,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(``),[P,F]=(0,X.useState)(Rn),[I,R]=(0,X.useState)(`name`),[z,B]=(0,X.useState)(`all`),[ee,V]=(0,X.useState)(null),[te,ne]=(0,X.useState)(null),[re,ie]=(0,X.useState)(null),[ae,oe]=(0,X.useState)(null),[se,ce]=(0,X.useState)(null),[H,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(!1),[fe,me]=(0,X.useState)(void 0),[ge,_e]=(0,X.useState)(!1),{data:ve,mutate:ye}=pe(a),G=ve?.payload?.config,K=(0,X.useMemo)(()=>G===void 0?null:Pt(G),[G]),q=K?.servers??[],xe=h.instances.length+q.length;(0,X.useEffect)(()=>{K&&me(K.sessionIdleTtlMinutes)},[K]);let J=(0,X.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Pe(),qe(),Ve(``,12).catch(()=>null)]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,X.useEffect)(()=>{J()},[J]),(0,X.useEffect)(()=>{if(!a||f!==`connected`)return;let e=!1,t=window.setTimeout(()=>{j(!0),Ve(O,50).then(t=>{e||g(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||j(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[a,O,f]),(0,X.useEffect)(()=>{m.current||h.loading||a&&!K||(p(xe>0?`connected`:`discover`),m.current=!0)},[a,xe,K,h.loading]);let Y=(0,X.useCallback)(e=>{m.current=!0,p(e)},[]),Ce=(0,X.useMemo)(()=>[{id:zn,displayName:t.composioSourceName},{id:Bn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),we=(0,X.useCallback)(async e=>{if(!a||P===Rn){g(e=>({...e,registryCatalog:[]})),S(1),w(void 0);return}let t=M.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=P===Ln?Ce:Ce.filter(e=>e.id===P);if(i.length!==0){v(!0),r?g(e=>({...e,error:null})):(S(1),w(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===zn){let e=await Ye({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Xe({q:t||void 0,page:n,pageSize:24,sort:I===`source`?`newest`:`downloads`});return{connectors:r.items.map(Vn),totalPages:r.meta.totalPages}})),a=Hn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));S(n),w(o),g(e=>({...e,registryCatalog:r?Hn([...e.registryCatalog,...a]):a}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{v(!1)}}},[I,M,P,a,Ce]);(0,X.useEffect)(()=>{if(f!==`discover`||h.loading)return;if(P===Rn){g(e=>({...e,registryCatalog:[]})),S(1),w(void 0);return}let e=window.setTimeout(()=>{we()},M.trim()?350:0);return()=>window.clearTimeout(e)},[M,P,we,h.loading,f]);let Te=(0,X.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Ee=(0,X.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]);(0,X.useEffect)(()=>{if(h.loading)return;let e=o.get(`connector`),t=o.get(`instance`);if(!e&&!t)return;let n=h.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)m.current=!0,D(``),ie(n.instanceId),oe(n),p(`connected`);else if(e){let t=Ee.get(e);if(!t)return;m.current=!0,F(Rn),N(``),ne(t),p(`discover`)}let r=new URLSearchParams(o);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),c(r,{replace:!0})},[Ee,o,c,h.instances,h.loading]);let De=(0,X.useCallback)(async e=>{b(!0),g(e=>({...e,error:null}));try{let t=await Ie(e);V(bn(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}},[]),Oe=(0,X.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),ke=(0,X.useCallback)(async e=>{if(!K||G===void 0)return;let t=q.filter(t=>t.clientKey!==e.clientKey);await It({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Ot(G)),await ye(),await J()},[G,q,J,K,ye]),Ae=(0,X.useCallback)(()=>{le({mode:`add`,row:xn(q,Oe)})},[q,Oe]),je=(0,X.useCallback)(async()=>{if(!(!K||G===void 0||ge)){_e(!0);try{await It({sessionIdleTtlMinutes:fe,servers:q},Ot(G)),await ye(),de(!1)}finally{_e(!1)}}},[G,q,n.saved,K,ye,fe,ge]),Me=L(e=>e.setPageHeader),Ne=L(e=>e.clearPageHeader),Fe=(0,X.useMemo)(()=>(0,Q.jsx)(St,{onBrowseCatalog:()=>Y(`discover`),onAddCustomServer:Ae,onOpenRuntimeSettings:()=>de(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ae,Y]);(0,X.useLayoutEffect)(()=>(Me({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Fe}),()=>Ne()),[Ne,t.title,Fe,Me]);let Le=(0,X.useMemo)(()=>h.instances.map(e=>({instance:e,value:dn(e,Ee.get(e.connectorId))})),[Ee,h.instances]),Re=(0,X.useMemo)(()=>new Map(Le.map(({instance:e,value:t})=>[e.instanceId,t])),[Le]),ze=(0,X.useMemo)(()=>h.instances.filter(e=>Fn(e,T)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Re.get(e.instanceId)?.state??`checking`,i=Re.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[T,Re,h.instances]),Be=(0,X.useMemo)(()=>q.filter(e=>In(e,T)),[T,q]),He=ze.length+Be.length,Ue=(0,X.useMemo)(()=>h.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Mn(e)),[h.catalog]),We=(0,X.useMemo)(()=>P===Rn?Ue:P===Ln?Hn([...Ue,...h.registryCatalog]):h.registryCatalog,[Ue,P,h.registryCatalog]),Ge=(0,X.useMemo)(()=>Pn(z===`all`?We:We.filter(e=>ln(e).includes(z)),M,I),[I,M,We,z]),Ke=(0,X.useMemo)(()=>cn.filter(e=>We.some(t=>ln(t).includes(e))),[We]);(0,X.useEffect)(()=>{z!==`all`&&!Ke.includes(z)&&B(`all`)},[Ke,z]);let Je=f===`discover`&&P!==Rn&&!!(C&&x<C),Ze=(0,X.useMemo)(()=>h.instances.find(e=>e.instanceId===re)??ae,[re,ae,h.instances]),Qe=(0,X.useMemo)(()=>[{value:Ln,label:t.discoverSourceAll},{value:Rn,label:t.discoverSourceBuiltin},...Ce.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ce]),$e=[{id:`connected`,label:t.tabConnected,count:xe},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[a?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(Se,{items:$e,activeTab:f,onChange:Y,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),h.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,f===`connected`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(xt,{value:T,onChange:D,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(he,{className:`size-9 shrink-0 p-0`,loading:h.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:J})]}),h.peopleGraph&&(h.peopleGraph.people.length>0||O)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(E,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(h.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(h.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(xt,{value:O,onChange:k,placeholder:t.peopleGraphSearchPlaceholder}),A?(0,Q.jsx)(W,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),h.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:h.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(h.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,h.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.slice(0,3).map(e=>(0,Q.jsx)(ut,{},e))}):xe===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(U,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Y(`discover`),children:t.addFromCatalog})]}):He===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[ze.map(e=>(0,Q.jsx)(fn,{instance:e,definition:Ee.get(e.connectorId),highlighted:e.instanceId===se,onOpenDetails:e=>{ce(null),ie(e.instanceId),oe(e)},onChanged:J,t},e.instanceId)),Be.map(e=>(0,Q.jsx)(Wt,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>ke(e)},e.clientKey))]})]}):null,f===`discover`&&a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...Ke].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,z===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":z===e,onClick:()=>B(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(xt,{value:M,onChange:N,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,Q.jsx)(be,{value:P,options:Qe,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:F}),(0,Q.jsx)(be,{value:I,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>R(e)})]})]}),(h.loading||_)&&Ge.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.map(e=>(0,Q.jsx)(ct,{},e))}):Ge.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[_?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,Q.jsx)(W,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ge.map(e=>(0,Q.jsx)(rt,{connector:e,installed:Te.has(e.id)||ot(e,h.instances),onInstall:e=>{if(e.source===`store`){De(e.id);return}V(bn(e))},onOpenDetails:e.source===`store`?void 0:ne,t},e.id))}),Je?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(U,{type:`button`,variant:`secondary`,disabled:_||y,onClick:()=>void we({page:x+1,append:!0}),children:[_?(0,Q.jsx)(W,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ee?(0,Q.jsx)(yn,{draft:ee,onChange:V,onClose:()=>V(null),t,onInstalled:async e=>{await J(),await ye(),ce(e.instanceId),Y(`connected`)}}):null,te?(0,Q.jsx)(vt,{connector:te,installed:Te.has(te.id)||ot(te,h.instances),onClose:()=>ne(null),onInstall:e=>V(bn(e)),t}):null,Ze?(0,Q.jsx)(sn,{instance:Ze,definition:Ee.get(Ze.connectorId),onClose:()=>{ie(null),oe(null)},onChanged:J,t,mcp:n}):null,H?(0,Q.jsx)(jn,{open:!0,mode:H.mode,initialRow:H.row,existingCustomServers:q,sessionIdleTtlMinutes:fe,config:G,managedServerIds:Oe,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await ye(),await J(),Y(`connected`)}},`${H.mode}-${H.row.clientKey}`):null,(0,Q.jsx)(bt,{open:ue,sessionIdleTtlMinutes:fe,saving:ge,onChange:me,onSave:je,onClose:()=>de(!1),t,mcp:n})]})})}export{Un as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-BiBdO1-O.js";import{n as a}from"./locale-store-CAuhEGCn.js";import{Ms as o,_u as s,t as c}from"./index-eyttVNS_.js";import{t as l}from"./desktop-pet-sprite-DTqXSpqf.js";var u=e(t(),1),d=n(),f=9e4,p=3e4,m=20*6e4,h=45e3,g=45*6e4,_=58;function v(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=f}function y(e,t){return e.state===`running`&&t-e.timestamp>=p}function b(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function x(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>_?`${n.slice(0,_-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function S(e,t,n){if(y(e,t))return n.stale;if(v(e,t))return n.longRunning}function C(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function w(e){let t=e.now-e.lastActivityAt,n=t>=m?(t-m)%g:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=h&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:y(e,n)||t===`playful`||t===`companion`&&v(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.sessionKey];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.sessionKey]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function M(e){return e?`/chat/${e.sessionKey}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function F(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.sessionKey}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function z(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function B(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(z),[r,c]=(0,u.useState)({}),[d,f]=(0,u.useState)({}),[p,m]=(0,u.useState)(Date.now()),[h,_]=(0,u.useState)(()=>Date.now()),[v,y]=(0,u.useState)(0),[T,D]=(0,u.useState)(null),O=(0,u.useRef)(null),B=(0,u.useRef)(!1),V=(0,u.useRef)(null),H=(0,u.useRef)(null),U=(0,u.useRef)(null),W=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),G=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),K=(0,u.useMemo)(()=>j(Object.values(r),p),[r,p]),q=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?K.filter(e=>!A(e,d[e.sessionKey])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[K,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),ee=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?K.filter(e=>A(e,d[e.sessionKey])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[K,d,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=q[0]??K[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=T??(J?P(J):te),Y=e.personaPhrases[W?.persona?.tone??`calm`],X=w({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:q.length,activeCount:K.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),c(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>c(t=>(_(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,u.useEffect)(()=>{if(!t.relationshipMoment)return;D(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>D(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,u.useLayoutEffect)(()=>{let e=V.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[H.current,U.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),H.current&&r.observe(H.current),U.current&&r.observe(U.current),n(),()=>r.disconnect()},[X,q.length,t.prefs.collapsed,G]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.sessionKey,e.runId),c(t=>{let{[e.sessionKey]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(d).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,u.useCallback)(e=>{e.button===0&&(O.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,u.useCallback)(e=>{let t=O.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,D(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,u.useCallback)(e=>{let t=O.current;!t||t.pointerId!==e.pointerId||(O.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(D(`released`),window.setTimeout(()=>D(null),700),B.current=!0,window.setTimeout(()=>{B.current=!1},0)))},[]),oe=()=>{B.current||Z()};if(!W)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*G)}px`,"--desktop-pet-menu-size":`${Math.round(28*G)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*G)}px`},$=t.prefs.collapsed?q.length:ee;return(0,N.jsxs)(`div`,{ref:V,className:`desktop-pet-window`,style:se,children:[!t.prefs.collapsed&&q.length>0?(0,N.jsx)(`div`,{ref:H,className:`desktop-pet-bubble desktop-pet-queue`,children:q.map(t=>{let n=S(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=x(t,e.tipCompleteSummary),i=C(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,s=L(I(W,t,Y),a,!!(r||n||i)),c=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[s,r||n?``:b(t,p,e.tipTargetSuffix)]})]}),c?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:c}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.sessionKey,t.runId),f(e=>({...e,[t.sessionKey]:{runId:t.runId,state:t.state}}))},children:(0,N.jsx)(o,{size:12})})]},t.sessionKey)})}):null,X?(0,N.jsx)(`div`,{ref:H,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(W.persona?.phrases?.greeting??Y.greeting,{sessionKey:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+g),children:(0,N.jsx)(o,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:U,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&D(`greet`)},onPointerLeave:()=>{O.current||D(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,title:e.openApp,children:(0,N.jsx)(l,{pet:W,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*G)})})]})]})}function V(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsx)(B,{}),e[0]=t):t=e[0],t}export{V as DesktopPetPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-BiBdO1-O.js";import{n as a}from"./locale-store-CAuhEGCn.js";import{Ac as o,Go as s,Gs as c,Ho as l,Lr as u,Lt as d,Ms as f,Rr as ee,Uo as p,Vo as m,Wo as h,_u as g,ac as _,fc as v,is as y,ks as b,kt as x,ns as S,rs as C,zc as w,zo as T}from"./index-eyttVNS_.js";var E=e(t(),1);function D(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function O(e){let t=new Set,n=[];for(let r of e){let e=r.trim(),i=e.toLowerCase();!e||t.has(i)||(t.add(i),n.push(e))}return n}var k=n();function A(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function j(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function M(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),j(t)}function N(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),j(e)}function P(e){if(e===`today`)return M(0);if(e===`tomorrow`)return M(1);if(e===`friday`)return N();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),j(e)}return``}function F({open:e,t,chat:n,busy:j,options:M,onClose:N,onCreate:F,onDraftContract:I}){let L=i(a(e=>e.language)).agentsSettings,[R,z]=(0,E.useState)(()=>D()),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),J=x({chat:n});(0,E.useEffect)(()=>{e||(z(D()),V(!1),U(!1),G(null),q(!1),J.clearAttachments())},[J.clearAttachments,e]),(0,E.useEffect)(()=>{!e||!M.defaultAgentId||z(e=>e.agentId?e:{...e,agentId:M.defaultAgentId})},[e,M.defaultAgentId]);let Y=e=>z(t=>({...t,...e})),X=M.agents.length?M.agents:[{id:M.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],Z=X.find(e=>e.id===R.agentId)??X.find(e=>e.id===M.defaultAgentId)??X[0],Q=Z?u(Z,L):``,te=R.agentId||Z?.id||`main`,$=[...Z?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=M.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{Y({deadlineMode:e,deadline:P(e)})},ie=(e,t)=>{z(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{z(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{z(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{z(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{G(null),q(!0);try{Y(I?await I({...R,attachments:J.wireAttachmentsPayload()}):{objective:R.objective||R.title,scopeBoundary:R.scopeBoundary,evidencePlan:O(R.evidencePlan).length?R.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:R.checklist}),V(!0)}catch(e){G(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{q(!1)}},le=async()=>{if(G(null),!R.title.trim()){G(t.createDialog.titleRequired);return}try{await F({...R,attachments:J.wireAttachmentsPayload(),checklist:O(R.checklist)}),N()}catch(e){G(e instanceof Error?e.message:t.errors.create)}};return(0,k.jsx)(T,{open:e,onOpenChange:e=>!e&&N(),children:(0,k.jsxs)(h,{children:[(0,k.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,k.jsxs)(m,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(s,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,k.jsx)(l,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,k.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:N,children:(0,k.jsx)(f,{className:`size-5`,"aria-hidden":!0})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,k.jsxs)(`div`,{className:`grid gap-4`,children:[(0,k.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 p-3`,children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,k.jsxs)(b,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:K||!R.title.trim()&&!R.description.trim(),children:[(0,k.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),K?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,k.jsx)(`input`,{value:R.title,onChange:e=>Y({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,k.jsxs)(b,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>J.fileInputRef.current?.click(),children:[(0,k.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,k.jsx)(`textarea`,{value:R.description,onChange:e=>Y({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(`input`,{ref:J.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,J.processFiles(t)}}),(0,k.jsx)(d,{attachments:J.attachments,topPadded:!1,onRemove:J.removeAttachment})]}),(0,k.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>V(e=>!e),children:[(0,k.jsxs)(`span`,{className:`min-w-0`,children:[(0,k.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,k.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,k.jsx)(g,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,B&&`rotate-180`),"aria-hidden":!0})]}),B?(0,k.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,k.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:M.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,k.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[R.checklist.map((e,n)=>(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:A(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,k.jsx)(c,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,k.jsxs)(b,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({checklist:[...R.checklist,``]}),children:[(0,k.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,k.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,k.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,k.jsx)(`textarea`,{value:R.objective,onChange:e=>Y({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,k.jsx)(`textarea`,{value:R.scopeBoundary,onChange:e=>Y({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),R.evidencePlan.map((e,n)=>(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:A(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,k.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,k.jsx)(c,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,k.jsxs)(b,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({evidencePlan:[...R.evidencePlan,``]}),children:[(0,k.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,k.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>U(e=>!e),children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,k.jsx)(v,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,k.jsx)(g,{className:r(`size-4 text-fg-muted transition-transform`,H&&`rotate-180`),"aria-hidden":!0})]}),H?(0,k.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,k.jsx)(S,{value:te,onChange:e=>Y({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:X.map(e=>(0,k.jsx)(y,{value:e.id,children:ee(e,L)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Q?(0,k.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Q}):Z?.model?.primary?(0,k.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:A(t.createDialog.agentPrimaryModel,{model:Z.model.primary})}):null]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,k.jsxs)(S,{value:R.priority,onChange:e=>Y({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(y,{value:`normal`,children:t.priorities.normal}),(0,k.jsx)(y,{value:`high`,children:t.priorities.high}),(0,k.jsx)(y,{value:`low`,children:t.priorities.low})]})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,k.jsxs)(S,{value:R.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(y,{value:`none`,children:t.createDialog.deadlineNone}),(0,k.jsx)(y,{value:`today`,children:t.createDialog.deadlineToday}),(0,k.jsx)(y,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,k.jsx)(y,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,k.jsx)(y,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),R.deadlineMode===`none`?null:(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,k.jsx)(`input`,{type:`datetime-local`,value:R.deadline,onChange:e=>Y({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,k.jsx)(`input`,{type:`number`,min:1,max:500,value:R.maxTurns,onChange:e=>Y({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,k.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,k.jsxs)(S,{value:R.judgeModelRef,onChange:e=>Y({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,k.jsx)(y,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,k.jsx)(C,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,k.jsxs)(y,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,k.jsx)(C,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,k.jsxs)(y,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),W?(0,k.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:W}):null]})}),(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,k.jsx)(b,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:N,children:t.createDialog.cancel}),(0,k.jsxs)(b,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:j||!R.title.trim(),onClick:()=>void le(),children:[(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{O as n,F as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,l as o,t as s}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-BiBdO1-O.js";import{n as u,r as d,s as f}from"./locale-store-CAuhEGCn.js";import{A as p,Ac as m,Al as h,C as g,F as _,Gs as v,Iu as y,Js as b,Nu as x,R as S,Rl as C,Ru as w,Sc as T,To as E,Wl as D,Ws as ee,Ys as O,_ as k,_t as A,cl as j,du as te,eu as M,fu as N,gc as P,hu as ne,is as F,jl as re,k as I,ks as L,ns as R,ou as z,pu as ie,ro as B,su as ae,vt as oe,wu as se,y as ce,zl as le}from"./index-eyttVNS_.js";import{t as ue}from"./automation-suggestion-card-Byu3I7Rs.js";var de=n(),V=e(t(),1),H=r();function fe(e){return e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean)}function pe(){let e=(0,de.c)(7),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(B,{className:`h-5 w-20 rounded-full`}),(0,H.jsx)(B,{className:`h-4 w-28`}),(0,H.jsx)(B,{className:`h-4 w-24`})]}),n=(0,H.jsx)(B,{className:`mt-4 h-4 w-full max-w-3xl`}),r=(0,H.jsx)(B,{className:`mt-2 h-4 w-2/3 max-w-2xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[t,n,r,(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:[(0,H.jsx)(B,{className:`h-16 rounded-md`}),(0,H.jsx)(B,{className:`h-16 rounded-md`}),(0,H.jsx)(B,{className:`h-16 rounded-md`})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,H.jsx)(B,{className:`h-4 w-32`}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[a,(0,H.jsx)(`div`,{className:`mt-4 grid gap-3`,children:Array.from({length:5}).map(U)})]}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,H.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[i,(0,H.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[o,(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(B,{className:`h-4 w-28`}),(0,H.jsx)(B,{className:`mt-4 h-24 rounded-md`}),(0,H.jsx)(B,{className:`mt-3 h-24 rounded-md`})]})]})]}),e[6]=s):s=e[6],s}function U(e,t){return(0,H.jsx)(B,{className:`h-14 rounded-md`},t)}var W=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,me=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function he(e){return e===`command`||e===`test`?b:e===`diff`?M:e===`file`||e===`artifact`?C:e===`link`?D:P}function ge(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function G(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function K(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function _e(e){let t=(0,de.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=he(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=ge(n),a=G(e,`command`),g=K(e,`exitCode`),_=G(e,`path`)||n.uri,v=K(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,H.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,H.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,H.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=Oe(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,H.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,H.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,H.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,H.jsx)(`code`,{children:n.summary})}):(0,H.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=xe(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,H.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,H.jsx)(`span`,{children:q(i.exitCode,{code:g})}),d=v==null?null:(0,H.jsx)(`span`,{children:q(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,H.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,H.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,H.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function ve(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function ye(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function be(e){return e===`workflow_run`?h:e===`goal_run`?se:e===`queue`?te:e===`evidence`?C:w}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function J(e){return e===`zh`?`zh-CN`:`en-US`}function xe(e,t,n){return e?oe(e,J(t)):n.notSet}function Se(e,t,n){return e?A(e,J(t)):n.noDeadline}function Ce(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function we(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function Te(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function Ee(e,t){return e?t.statuses[e]??e:``}function De(e,t){return t.priorities[e]??e}function Oe(e,t){return t.evidenceKinds[e]??e}function ke(e){return!e||e.currentValue==null?!1:e.direction===`increase`?e.currentValue>=e.targetValue:e.currentValue<=e.targetValue}function Ae(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function je(e,t,n){let r=e.evidenceRequirements.some(e=>e.status!==`approved`),i=!!(e.contract?.outcomeMetric&&!ke(e.contract.outcomeMetric));if(e.status===`done`&&(r||i||t?.verdict===`continue`))return{title:n.progressPanel.executionFinishedTitle,body:n.progressPanel.executionFinishedFallback,tone:`attention`,needsReview:!0};if(e.status===`blocked`)return{title:n.progressPanel.blockedTitle,body:e.blockedReason||n.progressPanel.blockedFallback,tone:`attention`,needsReview:!1};if(e.status===`needs_input`){let t=e.blockedReason?.startsWith(`Completion review required`);return{title:t?n.progressPanel.executionFinishedTitle:n.progressPanel.needsInputTitle,body:t?n.progressPanel.executionFinishedFallback:e.blockedReason||e.nextAction||n.progressPanel.needsInputFallback,tone:`attention`,needsReview:!!t}}return e.status===`paused`?{title:n.progressPanel.pausedTitle,body:e.blockedReason||n.progressPanel.pausedFallback,tone:`normal`,needsReview:!1}:e.status===`done`?{title:n.progressPanel.doneTitle,body:n.progressPanel.doneFallback,tone:`done`,needsReview:!1}:e.status===`archived`?{title:n.progressPanel.archivedTitle,body:n.progressPanel.archivedFallback,tone:`normal`,needsReview:!1}:{title:n.progressPanel.activeTitle,body:e.nextAction||n.noNextAction,tone:`normal`,needsReview:!1}}function Me(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Ne(e){let t=(0,de.c)(210),{goal:n,latestRun:r,done:i,total:a,evidence:o,language:s,t:l,busy:u,primaryActionDisabled:d,onContinue:f,onOpenChat:p,onPause:m,onConfigureOutcome:h,onReviewEvidence:g}=e,_;t[0]!==n||t[1]!==r||t[2]!==l?(_=je(n,r,l),t[0]=n,t[1]=r,t[2]=l,t[3]=_):_=t[3];let v=_,y,b,x,S,C,w,T,E,k,A,j,M,P,F;if(t[4]!==i||t[5]!==o||t[6]!==n.contract?.outcomeMetric||t[7]!==n.deadlineAt||t[8]!==n.evidenceRequirements||t[9]!==n.priority||t[10]!==n.status||t[11]!==s||t[12]!==r||t[13]!==g||t[14]!==v.body||t[15]!==v.needsReview||t[16]!==v.title||t[17]!==v.tone||t[18]!==l||t[19]!==a){let e=n.evidenceRequirements.filter(Ie).length,u=n.evidenceRequirements.length,d,f,p,m,h;if(t[34]!==i||t[35]!==n.contract?.outcomeMetric||t[36]!==n.deadlineAt||t[37]!==n.evidenceRequirements||t[38]!==n.priority||t[39]!==n.status||t[40]!==s||t[41]!==r||t[42]!==v.body||t[43]!==v.needsReview||t[44]!==v.title||t[45]!==v.tone||t[46]!==l||t[47]!==a){b=n.evidenceRequirements.filter(Fe).slice(0,2);let e;t[58]!==i||t[59]!==a?(e=Me(i,a),t[58]=i,t[59]=a,t[60]=e):e=t[60],d=e,y=n.contract?.outcomeMetric,x=ke(y);let o=v.tone===`attention`?ee:v.tone===`done`?ie:te;w=`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,S=`grid gap-5`,f=`min-w-0`;let u;t[61]!==n.status||t[62]!==v.needsReview?(u=c(`rounded-full border px-2 py-0.5 text-xs`,ve(v.needsReview?`needs_input`:n.status)),t[61]=n.status,t[62]=v.needsReview,t[63]=u):u=t[63];let g;t[64]!==n.status||t[65]!==v.needsReview||t[66]!==l?(g=v.needsReview?l.progressPanel.reviewPendingLabel:Ee(n.status,l),t[64]=n.status,t[65]=v.needsReview,t[66]=l,t[67]=g):g=t[67];let _;t[68]!==u||t[69]!==g?(_=(0,H.jsx)(`span`,{className:u,children:g}),t[68]=u,t[69]=g,t[70]=_):_=t[70];let C;t[71]!==n.priority||t[72]!==l?(C=q(l.prioritySummary,{priority:De(n.priority,l)}),t[71]=n.priority,t[72]=l,t[73]=C):C=t[73];let T;t[74]===C?T=t[75]:(T=(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:C}),t[74]=C,t[75]=T);let E;t[76]!==n.deadlineAt||t[77]!==s||t[78]!==l?(E=n.deadlineAt?Se(n.deadlineAt,s,l):l.noDeadline,t[76]=n.deadlineAt,t[77]=s,t[78]=l,t[79]=E):E=t[79];let D;t[80]===E?D=t[81]:(D=(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:E}),t[80]=E,t[81]=D),t[82]!==_||t[83]!==T||t[84]!==D?(p=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_,T,D]}),t[82]=_,t[83]=T,t[84]=D,t[85]=p):p=t[85];let O=v.tone===`attention`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:v.tone===`done`?`bg-success-soft text-success`:`bg-accent-soft text-accent-fg`,k;t[86]===O?k=t[87]:(k=c(`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg`,O),t[86]=O,t[87]=k);let A;t[88]===o?A=t[89]:(A=(0,H.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[88]=o,t[89]=A);let j;t[90]!==k||t[91]!==A?(j=(0,H.jsx)(`div`,{className:k,children:A}),t[90]=k,t[91]=A,t[92]=j):j=t[92];let M;t[93]===v.title?M=t[94]:(M=(0,H.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:v.title}),t[93]=v.title,t[94]=M);let N;t[95]===v.body?N=t[96]:(N=(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:v.body}),t[95]=v.body,t[96]=N);let P;t[97]!==s||t[98]!==r||t[99]!==l?(P=r?.reason?(0,H.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs text-fg-subtle`,children:q(l.progressPanel.lastCheck,{time:xe(r.finishedAt??r.startedAt,s,l),reason:r.reason})}):null,t[97]=s,t[98]=r,t[99]=l,t[100]=P):P=t[100];let ne;t[101]!==M||t[102]!==N||t[103]!==P?(ne=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[M,N,P]}),t[101]=M,t[102]=N,t[103]=P,t[104]=ne):ne=t[104],t[105]!==j||t[106]!==ne?(m=(0,H.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[j,ne]}),t[105]=j,t[106]=ne,t[107]=m):m=t[107],h=b.length?(0,H.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-amber-800 dark:text-amber-200`,children:l.progressPanel.evidenceNeeded}),(0,H.jsx)(`ul`,{className:`mt-1 grid gap-1 text-xs text-amber-800 dark:text-amber-200`,children:b.map(Pe)})]}):null,t[34]=i,t[35]=n.contract?.outcomeMetric,t[36]=n.deadlineAt,t[37]=n.evidenceRequirements,t[38]=n.priority,t[39]=n.status,t[40]=s,t[41]=r,t[42]=v.body,t[43]=v.needsReview,t[44]=v.title,t[45]=v.tone,t[46]=l,t[47]=a,t[48]=d,t[49]=y,t[50]=b,t[51]=x,t[52]=S,t[53]=w,t[54]=f,t[55]=p,t[56]=m,t[57]=h}else d=t[48],y=t[49],b=t[50],x=t[51],S=t[52],w=t[53],f=t[54],p=t[55],m=t[56],h=t[57];t[108]!==f||t[109]!==p||t[110]!==m||t[111]!==h?(C=(0,H.jsxs)(`div`,{className:f,children:[p,m,h]}),t[108]=f,t[109]=p,t[110]=m,t[111]=h,t[112]=C):C=t[112],P=`grid gap-3 md:grid-cols-3`;let _;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,H.jsx)(re,{className:`size-4`,"aria-hidden":!0}),t[113]=_):_=t[113];let D;t[114]===l.progressPanel.execution?D=t[115]:(D=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,l.progressPanel.execution]}),t[114]=l.progressPanel.execution,t[115]=D);let O;t[116]!==i||t[117]!==l.checklistProgress||t[118]!==l.notSet||t[119]!==a?(O=a?q(l.checklistProgress,{done:i,total:a}):l.notSet,t[116]=i,t[117]=l.checklistProgress,t[118]=l.notSet,t[119]=a,t[120]=O):O=t[120];let N;t[121]===O?N=t[122]:(N=(0,H.jsx)(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-fg`,children:O}),t[121]=O,t[122]=N);let I=`${d}%`,L;t[123]===I?L=t[124]:(L=(0,H.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,H.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:I}})}),t[123]=I,t[124]=L),t[125]!==D||t[126]!==N||t[127]!==L?(F=(0,H.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[D,N,L]}),t[125]=D,t[126]=N,t[127]=L,t[128]=F):F=t[128],k=`button`,A=`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-left transition-colors hover:bg-surface-hover`,j=g;let R;t[129]===l.progressPanel.evidence?R=t[130]:(R=(0,H.jsx)(`span`,{children:l.progressPanel.evidence}),t[129]=l.progressPanel.evidence,t[130]=R);let z;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,H.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[131]=z):z=t[131],t[132]===R?M=t[133]:(M=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[R,z]}),t[132]=R,t[133]=M),T=`mt-2 text-lg font-semibold tabular-nums text-fg`,E=u?q(l.evidenceRequirementProgress,{approved:e,total:u}):q(l.progressPanel.evidenceCount,{count:o.length}),t[4]=i,t[5]=o,t[6]=n.contract?.outcomeMetric,t[7]=n.deadlineAt,t[8]=n.evidenceRequirements,t[9]=n.priority,t[10]=n.status,t[11]=s,t[12]=r,t[13]=g,t[14]=v.body,t[15]=v.needsReview,t[16]=v.title,t[17]=v.tone,t[18]=l,t[19]=a,t[20]=y,t[21]=b,t[22]=x,t[23]=S,t[24]=C,t[25]=w,t[26]=T,t[27]=E,t[28]=k,t[29]=A,t[30]=j,t[31]=M,t[32]=P,t[33]=F}else y=t[20],b=t[21],x=t[22],S=t[23],C=t[24],w=t[25],T=t[26],E=t[27],k=t[28],A=t[29],j=t[30],M=t[31],P=t[32],F=t[33];let I;t[134]!==T||t[135]!==E?(I=(0,H.jsx)(`p`,{className:T,children:E}),t[134]=T,t[135]=E,t[136]=I):I=t[136];let R=b.length?l.progressPanel.reviewNeeded:l.progressPanel.reviewComplete,z;t[137]===R?z=t[138]:(z=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:R}),t[137]=R,t[138]=z);let B;t[139]!==I||t[140]!==z||t[141]!==k||t[142]!==A||t[143]!==j||t[144]!==M?(B=(0,H.jsxs)(`button`,{type:k,className:A,onClick:j,children:[M,I,z]}),t[139]=I,t[140]=z,t[141]=k,t[142]=A,t[143]=j,t[144]=M,t[145]=B):B=t[145];let ae=y&&x?`border-success/30 bg-success-soft/40`:`border-edge-subtle bg-surface-panel/70`,oe;t[146]===ae?oe=t[147]:(oe=c(`rounded-lg border p-3 text-left transition-colors hover:bg-surface-hover`,ae),t[146]=ae,t[147]=oe);let se;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,H.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[148]=se):se=t[148];let ce;t[149]===l.progressPanel.outcome?ce=t[150]:(ce=(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[se,l.progressPanel.outcome]}),t[149]=l.progressPanel.outcome,t[150]=ce);let le;t[151]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,H.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[151]=le):le=t[151];let ue;t[152]===ce?ue=t[153]:(ue=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[ce,le]}),t[152]=ce,t[153]=ue);let V;t[154]!==y||t[155]!==l.progressPanel.currentMissing||t[156]!==l.progressPanel.outcomeNotSet||t[157]!==l.progressPanel.outcomeSummary?(V=y?q(l.progressPanel.outcomeSummary,{baseline:y.baselineValue,current:y.currentValue??l.progressPanel.currentMissing,target:y.targetValue,unit:y.unit?` ${y.unit}`:``}):l.progressPanel.outcomeNotSet,t[154]=y,t[155]=l.progressPanel.currentMissing,t[156]=l.progressPanel.outcomeNotSet,t[157]=l.progressPanel.outcomeSummary,t[158]=V):V=t[158];let fe;t[159]===V?fe=t[160]:(fe=(0,H.jsx)(`p`,{className:`mt-2 truncate text-lg font-semibold tabular-nums text-fg`,children:V}),t[159]=V,t[160]=fe);let pe=y?y.name:l.progressPanel.outcomeNotSetHint,U;t[161]===pe?U=t[162]:(U=(0,H.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:pe}),t[161]=pe,t[162]=U);let W;t[163]!==h||t[164]!==oe||t[165]!==ue||t[166]!==fe||t[167]!==U?(W=(0,H.jsxs)(`button`,{type:`button`,className:oe,onClick:h,children:[ue,fe,U]}),t[163]=h,t[164]=oe,t[165]=ue,t[166]=fe,t[167]=U,t[168]=W):W=t[168];let me;t[169]!==B||t[170]!==W||t[171]!==P||t[172]!==F?(me=(0,H.jsxs)(`div`,{className:P,children:[F,B,W]}),t[169]=B,t[170]=W,t[171]=P,t[172]=F,t[173]=me):me=t[173];let he;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[174]=he):he=t[174];let ge;t[175]!==n.nextAction||t[176]!==n.status||t[177]!==v.needsReview||t[178]!==l?(ge=v.needsReview&&n.nextAction?l.progressPanel.continueExecution:Ce(n.status,l),t[175]=n.nextAction,t[176]=n.status,t[177]=v.needsReview,t[178]=l,t[179]=ge):ge=t[179];let G;t[180]!==f||t[181]!==d||t[182]!==ge?(G=(0,H.jsxs)(L,{type:`button`,variant:`primary`,className:`h-9 flex-1 rounded-lg`,disabled:d,onClick:f,children:[he,ge]}),t[180]=f,t[181]=d,t[182]=ge,t[183]=G):G=t[183];let K;t[184]!==b.length||t[185]!==g||t[186]!==l.progressPanel.reviewEvidenceAction?(K=b.length?(0,H.jsx)(L,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:g,children:l.progressPanel.reviewEvidenceAction}):null,t[184]=b.length,t[185]=g,t[186]=l.progressPanel.reviewEvidenceAction,t[187]=K):K=t[187];let _e;t[188]!==n.activeSessionKey||t[189]!==p||t[190]!==l.chat?(_e=n.activeSessionKey?(0,H.jsx)(L,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.chat,onClick:p,children:(0,H.jsx)(D,{className:`size-4`,"aria-hidden":!0})}):null,t[188]=n.activeSessionKey,t[189]=p,t[190]=l.chat,t[191]=_e):_e=t[191];let ye=u!=null||n.status!==`active`,be;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,H.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[192]=be):be=t[192];let J;t[193]!==m||t[194]!==l.pause||t[195]!==ye?(J=(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.pause,disabled:ye,onClick:m,children:be}),t[193]=m,t[194]=l.pause,t[195]=ye,t[196]=J):J=t[196];let we;t[197]!==G||t[198]!==K||t[199]!==_e||t[200]!==J?(we=(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-4`,children:[G,K,_e,J]}),t[197]=G,t[198]=K,t[199]=_e,t[200]=J,t[201]=we):we=t[201];let Te;t[202]!==S||t[203]!==C||t[204]!==me||t[205]!==we?(Te=(0,H.jsxs)(`div`,{className:S,children:[C,me,we]}),t[202]=S,t[203]=C,t[204]=me,t[205]=we,t[206]=Te):Te=t[206];let Oe;return t[207]!==w||t[208]!==Te?(Oe=(0,H.jsx)(`section`,{className:w,children:Te}),t[207]=w,t[208]=Te,t[209]=Oe):Oe=t[209],Oe}function Pe(e){return(0,H.jsxs)(`li`,{className:`break-words`,children:[`- `,e.text]},e.id)}function Fe(e){return e.status!==`approved`}function Ie(e){return e.status===`approved`}function Le(e){let t=e?.trim();return!t||!t.startsWith(`/projects/`)||t.startsWith(`//`)||t.includes(`://`)?`/goals`:t}async function Re(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}`))).goal}async function ze(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Be(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function Ve(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function He(e){return(await f(d(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function Ue(){let{goalId:e=``}=i(),t=o(),n=u(e=>e.language),r=l(n).goalDetailPage,b=l(n).automations.suggestions,C=E(e=>e.setPageHeader),ee=E(e=>e.clearPageHeader),[A,M]=a(),[N,P]=(0,V.useState)(null),[re,oe]=(0,V.useState)([]),[se,de]=(0,V.useState)([]),[U,he]=(0,V.useState)([]),[K,ve]=(0,V.useState)([]),[J,Ce]=(0,V.useState)([]),[De,Me]=(0,V.useState)([]),[Pe,Fe]=(0,V.useState)(``),[Ie,Ue]=(0,V.useState)(`message`),[We,Ge]=(0,V.useState)(``),[Ke,qe]=(0,V.useState)(``),[Je,Ye]=(0,V.useState)(``),[Xe,Ze]=(0,V.useState)(``),[Qe,$e]=(0,V.useState)(``),[et,tt]=(0,V.useState)(``),[nt,rt]=(0,V.useState)(`normal`),[it,at]=(0,V.useState)(``),[ot,st]=(0,V.useState)(`10`),[ct,lt]=(0,V.useState)(``),[ut,dt]=(0,V.useState)(``),[ft,pt]=(0,V.useState)(``),[mt,ht]=(0,V.useState)(``),[gt,_t]=(0,V.useState)(``),[vt,yt]=(0,V.useState)(``),[bt,xt]=(0,V.useState)(``),[St,Ct]=(0,V.useState)(``),[wt,Tt]=(0,V.useState)(``),[Et,Dt]=(0,V.useState)(``),[Ot,kt]=(0,V.useState)(``),[At,jt]=(0,V.useState)(``),[Mt,Nt]=(0,V.useState)(``),[Pt,Ft]=(0,V.useState)(``),[It,Lt]=(0,V.useState)(``),[Rt,zt]=(0,V.useState)(!0),[Y,X]=(0,V.useState)(null),[Bt,Z]=(0,V.useState)(null),Vt=(0,V.useMemo)(()=>Le(A.get(`returnTo`)),[A]),Ht=(0,V.useCallback)(async()=>{if(e){zt(!0),Z(null);try{let[t,n,r]=await Promise.all([Re(e),ze(e),Be(e)]);P(t),oe(n);let[i,a]=await Promise.all([I(e,50),Ve(e)]);he(i),Me(a),ve(await He(e)),Ce(r)}catch(e){Z(e instanceof Error?e.message:r.errors.load)}finally{zt(!1)}}},[e,r.errors.load]);(0,V.useEffect)(()=>{Ht()},[Ht]),(0,V.useEffect)(()=>{let e=!1;return p().then(t=>{e||(de(t),Ft(e=>e||t[0]?.id||``))}).catch(t=>{e||Z(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,V.useEffect)(()=>{if(!N)return;$e(N.title),tt(N.description??``),rt(N.priority),at(N.deadlineAt?new Date(N.deadlineAt).toISOString().slice(0,10):``),st(String(N.maxTurns)),lt(N.judgeModelRef??``),dt(N.nextAction??``),pt(N.blockedReason??``),ht(N.contract?.objective??N.title),_t(N.contract?.scopeBoundary??``),yt(N.checklist.map(e=>e.text).join(`
|
|
3
|
-
`)),xt(N.contract?.evidencePlan.join(`
|
|
4
|
-
`)??``);let e=N.contract?.outcomeMetric;Ct(e?.name??``),Tt(e?String(e.baselineValue):``),Dt(e?String(e.targetValue):``),kt(e?.currentValue==null?``:String(e.currentValue)),jt(e?.unit??``),Nt(e?.sourceUrl??``),Ze(e=>N.evidenceRequirements.some(t=>t.id===e)?e:N.evidenceRequirements[0]?.id??``),Lt(e=>e||N.nextAction||N.title)},[N?.id,N?.updatedAt]);let Ut=async()=>{if(N){X(`continue`);try{N.status===`done`&&await f(d(`/api/goals/${encodeURIComponent(N.id)}/reopen`),{method:`POST`,body:JSON.stringify({})});let e=await f(d(`/api/goals/${encodeURIComponent(N.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.continue)}finally{X(null)}}},Wt=async e=>{if(e.preventDefault(),!N)return;let t=Qe.trim();if(t){X(`details:save`),Z(null);try{let e=Number.parseInt(ot,10);P((await f(d(`/api/goals/${encodeURIComponent(N.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:et.trim()||void 0,priority:nt,deadlineAt:it?new Date(`${it}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:N.maxTurns,judgeModelRef:ct.trim()||void 0,nextAction:ut.trim()||void 0,blockedReason:ft.trim()||void 0})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Gt=async e=>{if(e.preventDefault(),!N)return;let t=mt.trim();if(t){X(`contract:save`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:t,scopeBoundary:gt.trim()||void 0,criteria:fe(vt),evidencePlan:fe(bt)})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Kt=async e=>{if(e.preventDefault(),!N)return;let t=Ae(wt),n=Ae(Et),i=Ae(Ot);if(!(!St.trim()||t==null||n==null)){X(`outcome:save`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:N.contract?.objective??N.title,scopeBoundary:N.contract?.scopeBoundary,criteria:N.checklist.map(e=>e.text),evidencePlan:N.contract?.evidencePlan??[],outcomeMetric:{name:St.trim(),baselineValue:t,targetValue:n,currentValue:i,unit:At.trim()||void 0,sourceUrl:Mt.trim()||void 0,measuredAt:i==null?void 0:Date.now()}})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},qt=async()=>{if(N){X(`outcome:clear`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:N.contract?.objective??N.title,scopeBoundary:N.contract?.scopeBoundary,criteria:N.checklist.map(e=>e.text),evidencePlan:N.contract?.evidencePlan??[],outcomeMetric:null})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Jt=async e=>{if(N){X(e);try{await f(d(`/api/goals/${encodeURIComponent(N.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.action)}finally{X(null)}}},Yt=async()=>{if(!(!N||!Pt)){X(`workflow:run`),Z(null);try{let e=await S({goalId:N.id,definitionId:Pt,goal:It.trim()||N.nextAction||N.title});await Ht(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.startWorkflow)}finally{X(null)}}},Q=async e=>{try{Me(await Ve(e))}catch{}},Xt=async e=>{try{let[t,n,r]=await Promise.all([I(e,50),Ve(e),He(e)]);he(t),Me(n),ve(r)}catch{}},Zt=async e=>{if(N){X(`workflow:${e.id}:cancel`),Z(null);try{await g(e.id,{ownerAgentId:N.agentId}),await Xt(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{X(null)}}},Qt=async e=>{if(N){X(`workflow:${e.id}:retry`),Z(null);try{let n=await _(e.id,{ownerAgentId:N.agentId});await Xt(N.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{X(null)}}},$t=async e=>{if(e.preventDefault(),!N)return;let t=Pe.trim();if(t){X(`checklist:add`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Fe(``),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addChecklist)}finally{X(null)}}},en=async(e,t)=>{if(N){X(`checklist:${e}:${t}`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.updateChecklist)}finally{X(null)}}},tn=async e=>{if(N){X(`checklist:${e}:delete`),Z(null);try{P((await f(d(`/api/goals/${encodeURIComponent(N.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{X(null)}}},nn=async e=>{if(e.preventDefault(),!N)return;let t=We.trim();if(t){X(`evidence:add`),Z(null);try{let e=await f(d(`/api/goals/${encodeURIComponent(N.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Ie,title:t,summary:Ke.trim()||void 0,uri:Je.trim()||void 0,requirementId:Xe||void 0})});Ce(t=>[e.evidence,...t]),P(await Re(N.id)),Ge(``),qe(``),Ye(``),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},rn=async e=>{if(N){X(`requirement:${e}:review`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(N.id)}/evidence-requirements/${encodeURIComponent(e)}/review`),{method:`POST`,body:JSON.stringify({modelRef:N.judgeModelRef})}),P(await Re(N.id)),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},an=async e=>{if(N){X(`requirement:${e}:approve`),Z(null);try{await f(d(`/api/goals/${encodeURIComponent(N.id)}/evidence-requirements/${encodeURIComponent(e)}/approve`),{method:`POST`,body:JSON.stringify({})}),P(await Re(N.id)),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},on=async e=>{if(!N||!e.summary)return;Z(null);let t=l(n).automations,r=await f(d(`/api/goals/${encodeURIComponent(N.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:ce(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});Ce(e=>[r.evidence,...e]),await Q(N.id)},sn=N?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,cn=N?.checklist.length??0,ln=(0,V.useMemo)(()=>{let e=new Set;for(let t of J){let n=G(ge(t),`automationRunId`);n&&e.add(n)}return e},[J]),un=(0,V.useMemo)(()=>{let e=new Set;return J.filter(t=>{if(t.title.trim().toLowerCase().startsWith(`missing evidence:`))return!1;let n=`${t.kind}\u0000${t.title.trim()}\u0000${t.summary?.trim()??``}`;return e.has(n)?!1:(e.add(n),!0)})},[J]),dn=U.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=re[0],fn=Te(A.get(`timeline`))?A.get(`timeline`):`all`,pn=fn===`all`?De:De.filter(e=>e.kind===fn),mn=U.filter(e=>e.status===`queued`||e.status===`running`),hn=N?je(N,$,r):null,gn=N?.status===`done`&&!hn?.needsReview,_n=Y!=null||N?.status===`archived`||gn,vn=(0,V.useMemo)(()=>N?(0,H.jsxs)(H.Fragment,{children:[N.activeSessionKey?(0,H.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(N.activeSessionKey)}`),children:[(0,H.jsx)(D,{className:`size-4`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:Y!=null||N.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&Jt(`archive`)},children:[(0,H.jsx)(y,{className:`size-4`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[Y,N,t,r]);(0,V.useLayoutEffect)(()=>(C({startExtra:(0,H.jsx)(s,{to:Vt,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,H.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[Rt?(0,H.jsx)(B,{className:`h-5 w-48 max-w-full`}):(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:N?.title??r.notFound}),N?(0,H.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[hn?.title??Ee(N.status,r),` · `,q(r.agent,{agentId:N.agentId})]}):null]}),end:vn}),()=>ee()),[Vt,ee,N,vn,Rt,C,hn?.title,r]);let yn=e=>{let t=new URLSearchParams(A);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),M(t,{replace:!0})};return(0,H.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[Bt?(0,H.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:Bt}):null,!Rt&&!N?(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,Rt?(0,H.jsx)(pe,{}):N?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{goal:N,latestRun:$,done:sn,total:cn,evidence:J,language:n,t:r,busy:Y,primaryActionDisabled:_n,onContinue:()=>void Ut(),onOpenChat:()=>N.activeSessionKey&&t(`/chat/${encodeURIComponent(N.activeSessionKey)}`),onPause:()=>void Jt(`pause`),onConfigureOutcome:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),onReviewEvidence:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`})}),(0,H.jsxs)(`section`,{id:`goal-outcome-metric`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),r.outcomeMetric.title]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.outcomeMetric.hint})]}),N.contract?.outcomeMetric?(0,H.jsx)(`span`,{className:c(`rounded-full border px-2 py-0.5 text-xs font-medium`,ke(N.contract.outcomeMetric)?`border-success/30 bg-success-soft text-success`:`border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:ke(N.contract.outcomeMetric)?r.outcomeMetric.achieved:r.outcomeMetric.notAchieved}):null]}),(0,H.jsxs)(`form`,{className:`mt-4 grid gap-3`,onSubmit:Kt,children:[(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(12rem,1.4fr)_repeat(3,minmax(7rem,0.7fr))]`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.name,(0,H.jsx)(`input`,{value:St,onChange:e=>Ct(e.target.value),className:W,placeholder:r.outcomeMetric.namePlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.baseline,(0,H.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.current,(0,H.jsx)(`input`,{value:Ot,onChange:e=>kt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.target,(0,H.jsx)(`input`,{value:Et,onChange:e=>Dt(e.target.value),className:W,type:`number`,step:`any`,inputMode:`decimal`})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)_auto] md:items-end`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.unit,(0,H.jsx)(`input`,{value:At,onChange:e=>jt(e.target.value),className:W,placeholder:r.outcomeMetric.unitPlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.source,(0,H.jsx)(`input`,{value:Mt,onChange:e=>Nt(e.target.value),className:W,placeholder:r.outcomeMetric.sourcePlaceholder})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N.contract?.outcomeMetric?(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`h-9`,disabled:Y!=null,onClick:()=>void qt(),children:r.outcomeMetric.clear}):null,(0,H.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9`,disabled:Y!=null||!St.trim()||Ae(wt)==null||Ae(Et)==null,children:r.outcomeMetric.save})]})]})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalBrief}),N.description?(0,H.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:N.description}):null,N.contract?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.goalContract}),(0,H.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:N.contract.objective}),N.contract.scopeBoundary?(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.scopeBoundary}),(0,H.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:N.contract.scopeBoundary})]}):null,N.contract.evidencePlan.length?(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.completionEvidence}),(0,H.jsx)(`ul`,{className:`mt-1 grid gap-1 text-sm text-fg-muted`,children:N.contract.evidencePlan.map(e=>(0,H.jsxs)(`li`,{children:[`• `,e]},e))})]}):null,(0,H.jsxs)(`details`,{className:`mt-3 rounded-md bg-surface-base/70 px-3 py-2`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editContract}),(0,H.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Gt,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.contractObjective,(0,H.jsx)(`textarea`,{value:mt,onChange:e=>ht(e.target.value),name:`contractObjective`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:r.contractObjectivePlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.scopeBoundary,(0,H.jsx)(`textarea`,{value:gt,onChange:e=>_t(e.target.value),name:`contractScopeBoundary`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:r.scopeBoundaryPlaceholder})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.acceptanceCriteria,(0,H.jsx)(`textarea`,{value:vt,onChange:e=>yt(e.target.value),name:`contractCriteria`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.completionEvidence,(0,H.jsx)(`textarea`,{value:bt,onChange:e=>xt(e.target.value),name:`contractEvidencePlan`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,H.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!mt.trim(),children:r.saveContract})]})]})]}):null]}),(0,H.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,H.jsxs)(`section`,{id:`goal-verification`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(j,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),$?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{children:q(r.latestJudgement,{status:Ee($.verdict??$.status,r)})}),(0,H.jsx)(`time`,{children:xe($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,H.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:q(r.latestNext,{next:$.nextAction})}):null]}):null,(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(j,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),(0,H.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:$t,children:[(0,H.jsx)(`input`,{value:Pe,onChange:e=>Fe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:c(W,`flex-1`)}),(0,H.jsxs)(L,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:Y!=null||!Pe.trim(),children:[(0,H.jsx)(m,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),N.checklist.length?(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:N.checklist.map(e=>(0,H.jsx)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,H.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:we(e.status)}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:Y!=null||e.status===`pending`,onClick:()=>void en(e.id,`pending`),children:(0,H.jsx)(z,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:Y!=null||e.status===`completed`,onClick:()=>void en(e.id,`completed`),children:(0,H.jsx)(ie,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:Y!=null||e.status===`impossible`,onClick:()=>void en(e.id,`impossible`),children:(0,H.jsx)(ae,{className:`size-4`,"aria-hidden":!0})}),(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:Y!=null,onClick:()=>void tn(e.id),children:(0,H.jsx)(v,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,H.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,H.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),N.evidenceRequirements.length?(0,H.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.evidenceRequirements}),(0,H.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q(r.evidenceRequirementProgress,{approved:N.evidenceRequirements.filter(e=>e.status===`approved`).length,total:N.evidenceRequirements.length})})]}),N.evidenceRequirements.map(e=>(0,H.jsx)(`div`,{className:`rounded-md bg-surface-base px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`break-words text-sm text-fg`,children:e.text}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[q(r.linkedEvidenceCount,{count:e.evidenceIds.length}),` · `,r.evidenceRequirementStatuses[e.status]]}),e.reviewReason?(0,H.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:e.reviewReason}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,H.jsx)(L,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0,onClick:()=>void rn(e.id),children:r.reviewEvidence}),(0,H.jsx)(L,{type:`button`,variant:`secondary`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0||e.status===`approved`,onClick:()=>void an(e.id),children:r.approveEvidence})]})]})},e.id))]}):null,(0,H.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:nn,children:[(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,H.jsx)(R,{value:Ie,onChange:e=>Ue(e.target.value),className:W,name:`evidenceKind`,children:me.map(e=>(0,H.jsx)(F,{value:e,children:Oe(e,r)},e))})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,H.jsx)(`input`,{value:We,onChange:e=>Ge(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:W})]})]}),N.evidenceRequirements.length?(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.provesRequirement,(0,H.jsx)(R,{value:Xe,onChange:e=>Ze(e.target.value),name:`evidenceRequirement`,className:W,children:N.evidenceRequirements.map(e=>(0,H.jsx)(F,{value:e.id,children:e.text},e.id))})]}):null,(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,H.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:W})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,H.jsx)(`textarea`,{value:Ke,onChange:e=>qe(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:c(W,`resize-y`)})]}),(0,H.jsxs)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!We.trim(),children:[(0,H.jsx)(m,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),un.length?(0,H.jsx)(`ul`,{className:`space-y-2 text-sm`,children:un.slice(0,6).map(e=>(0,H.jsx)(_e,{item:e,language:n,t:r},e.id))}):(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,H.jsx)(w,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void Ht(),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),re.length?(0,H.jsx)(`ol`,{className:`mt-4 grid gap-2`,children:re.slice(0,6).map((e,t)=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`details`,{open:t===0&&e.verdict!==`done`,className:`group rounded-lg border border-edge-subtle bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 marker:hidden`,children:[(0,H.jsxs)(`span`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:q(r.executionProgress.runTitle,{number:re.length-t})}),(0,H.jsx)(`time`,{className:`mt-0.5 block text-xs text-fg-muted`,children:xe(e.finishedAt??e.startedAt,n,r)})]}),(0,H.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-fg-muted`,children:[Ee(e.verdict??e.status,r),(0,H.jsx)(ne,{className:`size-4 transition-transform group-open:rotate-90`,"aria-hidden":!0})]})]}),(0,H.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[e.reason?(0,H.jsx)(`p`,{className:`text-sm text-fg`,children:e.reason}):null,e.assistantPreview?(0,H.jsx)(`p`,{className:`mt-2 line-clamp-5 whitespace-pre-wrap text-xs text-fg-muted`,children:e.assistantPreview}):null,e.nextAction?(0,H.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-base px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.nextAction}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:e.nextAction})]}):null]})]})},e.id))}):(0,H.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.executionProgress.noRuns}),(0,H.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:q(r.executionProgress.systemActivity,{count:De.length})}),(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,H.jsx)(`button`,{type:`button`,className:c(`rounded-md border px-2.5 py-1 text-xs font-medium`,fn===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>yn(e),children:r.timelineFilters[e]},e))}),pn.length?(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:pn.map(e=>(0,H.jsx)(`li`,{className:`rounded-md bg-surface-muted/50 px-2.5 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,H.jsx)(be(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,H.jsx)(`span`,{children:Ee(e.status,r)}):null]}),(0,H.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,H.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,H.jsx)(`time`,{children:xe(e.createdAt,n,r)}),e.link?.type===`chat`?(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,H.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,H.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]})]}),(0,H.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/30 p-4`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:r.actionRail.nextTitle}),(0,H.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium text-fg`,children:gn?r.progressPanel.doneFallback:N.nextAction||r.noNextAction}),(0,H.jsxs)(L,{type:`button`,variant:`primary`,className:`mt-3 h-9 w-full gap-2`,disabled:Y!=null||N.status===`archived`,onClick:()=>{if(gn){window.confirm(r.archiveConfirm)&&Jt(`archive`);return}Ut()},children:[gn?(0,H.jsx)(y,{className:`size-4`,"aria-hidden":!0}):(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),gn?r.archive:r.actionRail.continueAction]})]}),N.evidenceRequirements.some(e=>e.status!==`approved`)||N.contract?.outcomeMetric&&!ke(N.contract.outcomeMetric)||$?.verdict===`continue`?(0,H.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:r.actionRail.needsYou}),(0,H.jsxs)(`ul`,{className:`mt-3 grid gap-2 text-sm text-amber-900 dark:text-amber-100`,children:[N.contract?.outcomeMetric&&!ke(N.contract.outcomeMetric)?(0,H.jsxs)(`li`,{children:[`• `,r.outcomeMetric.notAchieved]}):null,N.evidenceRequirements.some(e=>e.status!==`approved`)?(0,H.jsxs)(`li`,{children:[`• `,q(r.actionRail.reviewEvidenceCount,{count:N.evidenceRequirements.filter(e=>e.status!==`approved`).length})]}):null,$?.verdict===`continue`?(0,H.jsxs)(`li`,{children:[`• `,r.actionRail.latestCheckContinue]}):null]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[N.contract?.outcomeMetric&&!ke(N.contract.outcomeMetric)?(0,H.jsx)(L,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:r.actionRail.setOutcome}):null,N.evidenceRequirements.some(e=>e.status!==`approved`)?(0,H.jsx)(L,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r.actionRail.reviewEvidence}):null]})]}):null,(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.actionRail.automation}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[(0,H.jsx)(k,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:N.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),(0,H.jsx)(k,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:N.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),N.status===`blocked`||N.blockedReason?(0,H.jsx)(ue,{title:b.goalBlockedTitle,description:b.goalBlockedDescription,prompt:q(b.goalBlockedPrompt,{title:N.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:N.id,status:`blocked`}}}):null]})]}),(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.goalSettings}),(0,H.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:Se(N.deadlineAt,n,r)})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,H.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:N.judgeModelRef||r.default})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:Se(N.createdAt,n,r)})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,H.jsx)(`dd`,{className:`text-right text-fg`,children:xe(N.updatedAt,n,r)})]})]}),(0,H.jsxs)(`details`,{className:`mt-4 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,H.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Wt,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,H.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalTitle`,autoComplete:`off`,className:W,placeholder:`${r.title}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,H.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalDescription`,autoComplete:`off`,className:c(W,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,H.jsxs)(R,{value:nt,onChange:e=>rt(e.target.value),name:`goalPriority`,className:W,children:[(0,H.jsx)(F,{value:`low`,children:r.priorities.low}),(0,H.jsx)(F,{value:`normal`,children:r.priorities.normal}),(0,H.jsx)(F,{value:`high`,children:r.priorities.high})]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,H.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),name:`goalDeadline`,className:W,type:`date`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,H.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),name:`goalMaxTurns`,className:W,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,H.jsx)(`input`,{value:ct,onChange:e=>lt(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:W,placeholder:`${r.judgeModel}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,H.jsx)(`textarea`,{value:ut,onChange:e=>dt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,H.jsx)(`textarea`,{value:ft,onChange:e=>pt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:c(W,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,H.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!Qe.trim(),children:r.saveDetails})]})]})]}),(0,H.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 text-sm font-semibold text-fg marker:hidden`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),mn.length?(0,H.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:q(r.activeCount,{count:mn.length})}):null]}),(0,H.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.workflowHint}),K.length?(0,H.jsx)(`div`,{className:`mt-3 grid gap-2`,children:K.slice(0,2).map(e=>(0,H.jsxs)(`button`,{type:`button`,className:c(`min-w-0 rounded-md bg-surface-muted/40 px-2.5 py-2 text-left hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Pt===e.definitionId&&`bg-accent-soft/60 ring-1 ring-accent/30`),onClick:()=>{Ft(e.definitionId),Lt(N.nextAction||N.title)},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,H.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,H.jsxs)(R,{value:Pt,onChange:e=>Ft(e.target.value),className:W,name:`workflowDefinition`,disabled:se.length===0,children:[se.length===0?(0,H.jsx)(F,{value:``,children:r.noWorkflows}):null,se.map(e=>(0,H.jsx)(F,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,H.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,H.jsx)(`input`,{value:It,onChange:e=>Lt(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:W,placeholder:`${r.workflowGoal}…`})]}),(0,H.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!Pt||N.status===`done`||N.status===`archived`,onClick:()=>void Yt(),children:[(0,H.jsx)(te,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),U.length?(0,H.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,H.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>yn(`workflow_run`),children:r.viewTimeline})]}),(0,H.jsx)(`ul`,{className:`grid gap-2`,children:U.slice(0,3).map(e=>{let i=e.metadata?.sessionKey,a=e.status===`queued`||e.status===`running`,o=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,H.jsxs)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,H.jsx)(`span`,{className:c(`shrink-0 rounded-full border px-2 py-0.5`,ye(e.status)),children:Ee(e.status,r)})]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,H.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:xe(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,H.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[i?(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(i)}`),children:[(0,H.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,a?(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:Y!=null,onClick:()=>void Zt(e),children:[(0,H.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,o?(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,dn.length?(0,H.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,H.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:q(r.failedCount,{count:dn.length})})]}),(0,H.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:dn.slice(0,3).map(e=>(0,H.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,H.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,Ee(e.status,r)]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,H.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,H.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,H.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,H.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{Ue as GoalDetailPage};
|