@xopcai/xopc 0.0.194 → 0.0.195

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.
Files changed (128) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-4ln7j-oZ.js → agent-avatar-dicebear-DkYgzssq.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-COX-ZLtY.js +68 -0
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-B0IMpHk8.js → app-management-settings-panel-DVXLietl.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-BG6ZGIUf.js → appearance-settings-D7oohrYf.js} +1 -1
  8. package/dist/gateway/static/root/assets/apps-page-S52mdBX_.js +1 -0
  9. package/dist/gateway/static/root/assets/{archive-plugin-BNpjG4FR.js → archive-plugin-CpBzHKzI.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-BK25C_hA.js → attachment-load-DMWXe12h.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-page-DGGJQO9B.js +6 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-fbFe6Jqc.js → binary-plugins-BM0MgsHB.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-SQHwWg1e.js → block-editor-C2MT7mG3.js} +47 -47
  14. package/dist/gateway/static/root/assets/browser-settings-page-C_tkW-L_.js +8 -0
  15. package/dist/gateway/static/root/assets/{browser-workflow-inputs-DuUQ_Ycz.js → browser-workflow-inputs-V01qhcZc.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-workflows-page-B8I2FmrM.js → browser-workflows-page-DPmSKVWx.js} +2 -2
  17. package/dist/gateway/static/root/assets/capabilities-settings-panel-CPu6MIHF.js +7 -0
  18. package/dist/gateway/static/root/assets/capability-presets-settings-panel-ttuWLoiJ.js +3 -0
  19. package/dist/gateway/static/root/assets/channels-settings-DrWWVQjj.js +1 -0
  20. package/dist/gateway/static/root/assets/{connectors-api-Ne8mQrYN.js → connectors-api-CG0UqhPN.js} +1 -1
  21. package/dist/gateway/static/root/assets/connectors-page-CyfIrY2l.js +2 -0
  22. package/dist/gateway/static/root/assets/{cron-expression-DtWb3YAh.js → cron-expression-5SqAw4UD.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dependency-picker-3vjdusik.js → dependency-picker-eiaYMDYI.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-NmW7VWdO.js → desktop-pet-BtfzkmnU.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-DrdSI9lX.js → desktop-pet-settings-Dn3hnBOU.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-CG5XR1UD.js → directory-picker-path-field-Wa5zFvbb.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-debug-page-RjIezQyy.js → extension-debug-page-EWu0uOpw.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-page-D9Elz9mr.js → extension-page-2qZ7ngqL.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-settings-page-BvVjqFvm.js → extension-settings-page-4MOAwYPT.js} +1 -1
  30. package/dist/gateway/static/root/assets/{gateway-config-api-C-rYVz-n.js → gateway-config-api-aqPj1HAI.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-settings-CLS25-gm.js → gateway-settings-BbQBgKWH.js} +1 -1
  32. package/dist/gateway/static/root/assets/{heartbeat-settings-DSgDxtwJ.js → heartbeat-settings-DXtG-Sy0.js} +1 -1
  33. package/dist/gateway/static/root/assets/home-page-k21J7B1q.js +3 -0
  34. package/dist/gateway/static/root/assets/{index-Cb9y6tVR.js → index-peR_-O6U.js} +62 -62
  35. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-RcHmSHYI.js → keyboard-shortcuts-settings-WKmsr5WD.js} +1 -1
  36. package/dist/gateway/static/root/assets/local-app-workbench-page-r8wlEj3A.js +2 -0
  37. package/dist/gateway/static/root/assets/{local-apps-page-s7PKLTvO.js → local-apps-page-3-aNfJwB.js} +1 -1
  38. package/dist/gateway/static/root/assets/logs-page-OU3uRCoz.js +2 -0
  39. package/dist/gateway/static/root/assets/{management-settings-CWUHBXje.js → management-settings-D8vbsfLm.js} +1 -1
  40. package/dist/gateway/static/root/assets/{markdown-split-B-IuPr4L.js → markdown-split-DRFl6Vfw.js} +1 -1
  41. package/dist/gateway/static/root/assets/{media-plugins-CiejHVt4.js → media-plugins-C5J46ROp.js} +1 -1
  42. package/dist/gateway/static/root/assets/{notes-page-BSJAwHqy.js → notes-page-Z0lEBC-X.js} +1 -1
  43. package/dist/gateway/static/root/assets/notes-workbench-B74ylIVP.js +4 -0
  44. package/dist/gateway/static/root/assets/{page-tabs-D6YJ6_l_.js → page-tabs-Dyj6Snbu.js} +1 -1
  45. package/dist/gateway/static/root/assets/{preview-open-alternatives-Tw_G-6jb.js → preview-open-alternatives-CPDM4F7n.js} +1 -1
  46. package/dist/gateway/static/root/assets/{product-open-page-BlB3QjTV.js → product-open-page-8RFhWmcU.js} +1 -1
  47. package/dist/gateway/static/root/assets/project-detail-page-3ugVthse.js +1 -0
  48. package/dist/gateway/static/root/assets/projects-page-VVAyOeRA.js +1 -0
  49. package/dist/gateway/static/root/assets/remote-access-hub-C6XqOPzA.js +1 -0
  50. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D59bftC7.js → runtime-tools-settings-panel-BBgWkYk0.js} +2 -2
  51. package/dist/gateway/static/root/assets/{schema-form-DyXqGA71.js → schema-form-BJqF0l7i.js} +1 -1
  52. package/dist/gateway/static/root/assets/sessions-page-BMj-t4hX.js +1 -0
  53. package/dist/gateway/static/root/assets/settings-advanced-gate-B7WvJXGJ.js +1 -0
  54. package/dist/gateway/static/root/assets/{settings-form-section-DZUGXwFO.js → settings-form-section-CYL5uBzc.js} +1 -1
  55. package/dist/gateway/static/root/assets/{settings-loading-skeleton-Lz1ec5lN.js → settings-loading-skeleton-BabbixC0.js} +1 -1
  56. package/dist/gateway/static/root/assets/{settings-page-DLofKC7q.js → settings-page-B7OH9I8A.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-page-layout-BdkN2U81.js → settings-page-layout-D9X3eVDo.js} +1 -1
  58. package/dist/gateway/static/root/assets/setup-status-panel-BHdz-BO7.js +1 -0
  59. package/dist/gateway/static/root/assets/{share-preview-page-DrZVv8tB.js → share-preview-page-CMuJZ5Qq.js} +1 -1
  60. package/dist/gateway/static/root/assets/shares-settings-B0F1jbhj.js +1 -0
  61. package/dist/gateway/static/root/assets/skill-reload-api-Dnpq03tO.js +1 -0
  62. package/dist/gateway/static/root/assets/{skills-page-zOD__-H5.js → skills-page-C9U1pIT-.js} +1 -1
  63. package/dist/gateway/static/root/assets/{skills-page.utils-ZDcx95iD.js → skills-page.utils-C3iaLgk9.js} +1 -1
  64. package/dist/gateway/static/root/assets/{system-settings-panel-BJhat70L.js → system-settings-panel-CAN01aY0.js} +1 -1
  65. package/dist/gateway/static/root/assets/task-detail-page-Bs5oS-wN.js +1 -0
  66. package/dist/gateway/static/root/assets/{typed-models-lib-B1p3wMFK.js → typed-models-lib-C9FMLeH2.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-autosave-Frcfbncl.js → use-autosave-AAZNoD6t.js} +1 -1
  68. package/dist/gateway/static/root/assets/user-context-page-CRY8IE-7.js +1 -0
  69. package/dist/gateway/static/root/assets/{voice-api-key-field-CSNOUNF4.js → voice-api-key-field-yLXEYgwV.js} +1 -1
  70. package/dist/gateway/static/root/assets/{work-discovery-overlay-DTJGssPz.js → work-discovery-overlay-tbkbg-8l.js} +1 -1
  71. package/dist/gateway/static/root/assets/{work-discovery-page-Bt2-fzHu.js → work-discovery-page-Dtqgvs_0.js} +1 -1
  72. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D3uCmyag.js → workflow-run-setup-panel-BJHOxj4Z.js} +2 -2
  73. package/dist/gateway/static/root/assets/workflows-page-BBjCNaXn.js +5 -0
  74. package/dist/gateway/static/root/index.html +1 -1
  75. package/dist/package.js +1 -1
  76. package/dist/src/agent/agent-manager.js +1 -1
  77. package/dist/src/agent/memory/create-memory-manager.js +1 -1
  78. package/dist/src/agent-runtime/index.js +1 -1
  79. package/dist/src/agent-runtime/runtime-profile.js +1 -1
  80. package/dist/src/cli/commands/channels.js +1 -1
  81. package/dist/src/cli/commands/connectors.js +1 -1
  82. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  83. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  84. package/dist/src/cli/commands/models.js +1 -1
  85. package/dist/src/cli/commands/onboard/model.d.ts +2 -1
  86. package/dist/src/cli/commands/onboard/model.js +10 -3
  87. package/dist/src/cli/commands/onboard.js +1 -1
  88. package/dist/src/cli/commands/update.js +1 -1
  89. package/dist/src/config/agent-profile.js +1 -1
  90. package/dist/src/extensions/sdk/index.js +1 -1
  91. package/dist/src/gateway/agents-admin.js +1 -1
  92. package/dist/src/gateway/heartbeat/service.js +1 -1
  93. package/dist/src/gateway/hono/routes/local-apps.js +1 -1
  94. package/dist/src/gateway/hono/routes/update.js +2 -2
  95. package/dist/src/gateway/index.js +1 -1
  96. package/dist/src/gateway/run-loop.js +1 -1
  97. package/dist/src/gateway/service.js +6 -6
  98. package/dist/src/heartbeat/index.js +1 -1
  99. package/dist/src/infra/gateway-processes.js +1 -1
  100. package/dist/src/infra/update-restart.js +1 -1
  101. package/dist/src/infra/update-runner.js +2 -2
  102. package/dist/src/infra/update-startup.js +1 -1
  103. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  104. package/package.json +3 -3
  105. package/dist/gateway/static/root/assets/agents-C1Z-rurI.js +0 -68
  106. package/dist/gateway/static/root/assets/apps-page-CwsZENTk.js +0 -1
  107. package/dist/gateway/static/root/assets/automations-page-BedezAfO.js +0 -6
  108. package/dist/gateway/static/root/assets/browser-settings-page-CC0_TfTy.js +0 -8
  109. package/dist/gateway/static/root/assets/capabilities-settings-panel-ditT6VRs.js +0 -7
  110. package/dist/gateway/static/root/assets/capability-presets-settings-panel-bNVds1ta.js +0 -3
  111. package/dist/gateway/static/root/assets/channels-settings-DhsWSbJ2.js +0 -1
  112. package/dist/gateway/static/root/assets/connectors-page-hZA9M1z_.js +0 -2
  113. package/dist/gateway/static/root/assets/home-page-CDpUUelT.js +0 -3
  114. package/dist/gateway/static/root/assets/image-generation-api-Cki7jfEV.js +0 -1
  115. package/dist/gateway/static/root/assets/local-app-workbench-page-DvzXo7dx.js +0 -2
  116. package/dist/gateway/static/root/assets/logs-page-CNm5fu3L.js +0 -2
  117. package/dist/gateway/static/root/assets/notes-workbench-DTWRQ_EU.js +0 -4
  118. package/dist/gateway/static/root/assets/project-detail-page-DT7aWLWT.js +0 -1
  119. package/dist/gateway/static/root/assets/projects-page-B-i3U2fU.js +0 -1
  120. package/dist/gateway/static/root/assets/remote-access-hub-v-kXavTc.js +0 -1
  121. package/dist/gateway/static/root/assets/sessions-page-tEfg1Pru.js +0 -1
  122. package/dist/gateway/static/root/assets/settings-advanced-gate-tbguNxVJ.js +0 -1
  123. package/dist/gateway/static/root/assets/setup-status-panel-DQgoV7gj.js +0 -1
  124. package/dist/gateway/static/root/assets/shares-settings-I2bBkyDb.js +0 -1
  125. package/dist/gateway/static/root/assets/skill-reload-api-gFdcImEc.js +0 -1
  126. package/dist/gateway/static/root/assets/task-detail-page-DoyREaFj.js +0 -1
  127. package/dist/gateway/static/root/assets/user-context-page-DniWcH92.js +0 -1
  128. package/dist/gateway/static/root/assets/workflows-page-Ba5fVQWY.js +0 -5
@@ -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"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Al as m,Ao as h,Ar as g,Da as _,Ea as v,Hs as y,Ko as b,La as x,Mo as S,Mr as C,Ni as w,No as T,Ns as E,Oa as D,Oo as O,Po as k,Uo as A,Xo as j,Zo as M,_s as N,bs as ee,dc as P,dr as F,dt as I,jo as L,jr as te,ko as R,ru as z,sc as ne,tc as re,tu as ie,us as ae,zc as B}from"./index-Cb9y6tVR.js";import{n as oe,r as se}from"./settings-page-layout-BdkN2U81.js";import{n as ce}from"./settings-loading-skeleton-Lz1ec5lN.js";import{t as le}from"./schema-form-DyXqGA71.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-DPaJSYX_.js";var V=e(t(),1),H=n();function pe(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 me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/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 W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(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,V.useMemo)(()=>pe(e),[e]),s=(0,V.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,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({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,V.useEffect)(()=>{let t=K(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),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(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=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),b=c.payload?.type===`form`?c.payload:null,x=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(N,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(y,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`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,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(_,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(_,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(_,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.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,U.jsx)(ie,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.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,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.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,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(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`?o(`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`,j):o(`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)]`,j,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,g=p===void 0?!1:p,_=n===`drawer`,[v,y]=(0,V.useState)(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,U.jsx)(S,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=x):x=t[0];let C;t[1]!==n||t[2]!==g?(C=Se(n,g),t[1]=n,t[2]=g,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let E;t[6]===l?E=t[7]:(E=l?(0,U.jsx)(L,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=E);let D;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==_||t[12]!==a?(D=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(ee,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ae,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(ee,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=_,t[12]=a,t[13]=D):D=t[13];let A=_?`p-4`:`p-6`,j;t[14]===A?j=t[15]:(j=o(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let P;t[16]!==d||t[17]!==j?(P=(0,U.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==v||t[21]!==w||t[22]!==E||t[23]!==D||t[24]!==P?(F=(0,U.jsxs)(b,{layer:`modal`,portalContainer:v,children:[w,E,D,P,f]}),t[19]=f,t[20]=v,t[21]=w,t[22]=E,t[23]=D,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==C?(I=(0,U.jsxs)(T,{children:[x,(0,U.jsx)(h,{ref:y,className:C,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=C,t[28]=I):I=t[28];let te;return t[29]!==i||t[30]!==r||t[31]!==I?(te=(0,U.jsx)(O,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=te):te=t[32],te}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.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,U.jsx)(w,{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,U.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,H.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,U.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,U.jsx)(N,{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,U.jsx)(N,{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,U.jsx)(N,{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,U.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,U.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}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(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 Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(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 Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(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(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(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 Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(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 Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(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 et(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 tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(D,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);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=o(`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=o(`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,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(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=Xe(n,r,c),s=$e(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,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.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=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.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,U.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,U.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,U.jsx)(nt,{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,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):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,U.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||s,C;t[53]!==a||t[54]!==s?(C=a||s?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(w=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,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,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(N,{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,U.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 it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?ie:n===`stopped`||n===`needs_setup`?z:B,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,g=n===`disabled`&&`text-fg-muted`,_=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,v;t[0]!==p||t[1]!==m||t[2]!==h||t[3]!==g||t[4]!==_?(v=o(`mt-0.5 size-5 shrink-0`,p,m,h,g,_),t[0]=p,t[1]=m,t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5];let y;t[6]!==f||t[7]!==v?(y=(0,U.jsx)(f,{className:v}),t[6]=f,t[7]=v,t[8]=y):y=t[8];let b;t[9]===c.connectionStatus?b=t[10]:(b=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=b);let x;t[11]!==c||t[12]!==n?(x=Ve(n,c),t[11]=c,t[12]=n,t[13]=x):x=t[13];let S;t[14]===x?S=t[15]:(S=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let C;t[16]!==S||t[17]!==b?(C=(0,U.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=C):C=t[18];let w;t[19]!==C||t[20]!==y?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,C]}),t[19]=C,t[20]=y,t[21]=w):w=t[21];let T=i||r,E;t[22]===i?E=t[23]:(E=i?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=E);let D=i?c.checkingConnection:c.checkConnection,O;t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D?(O=(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:u,children:[E,D]}),t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(k=n===`stopped`?(0,U.jsxs)(N,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(ne,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=k):k=t[35];let A;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(A=s?(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=A):A=t[43];let j;t[44]!==O||t[45]!==k||t[46]!==A?(j=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[O,k,A]}),t[44]=O,t[45]=k,t[46]=A,t[47]=j):j=t[47];let M;return t[48]!==w||t[49]!==j?(M=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[w,j]})}),t[48]=w,t[49]=j,t[50]=M):M=t[50],M}function ot(e){let t=(0,H.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=Y(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,U.jsx)(E,{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,U.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,U.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,U.jsx)(`li`,{children:et(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,U.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,U.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,U.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,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),h=C(f),_=ke(n,e),y=_.entries,{data:b,mutate:S,isValidating:w}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:T,mutate:E}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),D=T?.channels??{},O=T?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,v,{revalidateOnFocus:!1}),j=x(e=>e.setPageHeader),M=x(e=>e.clearPageHeader),N=(0,V.useMemo)(()=>y.find(e=>e.id===h),[h,y]),ee=N?ze(N):null,{data:P,mutate:L}=p(n&&ee?Pe(ee):null,()=>Fe(ee)),[R,z]=(0,V.useState)(null),[ne,ie]=(0,V.useState)(!1),[ae,B]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=R??P??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(N),[N]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=N?K??ve(O,N.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=F(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),X=Ve?F(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((b??[]).map(e=>[e.name,e])),[b]),Je=b!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([_.mutate(),S()])},[_,S]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&S(t,!1)},[S]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:_.isValidating||w,saveOk:!1,onRefresh:()=>void Q()}):null,[_.isValidating,J,n,w,Q]);(0,V.useLayoutEffect)(()=>(j({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.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,V.useCallback)(e=>{r(te(e)),z(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(g),z(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/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){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[N?.id]);let et=(0,V.useCallback)(async()=>{if(!N||!R&&K===null)return!1;let e=ze(N);ie(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:ye(O,N.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await E(),await _.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ie(!1)}},[N,K,O,_,R,E,L]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=N?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}B(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/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 _.mutate(),await E(),await S(),N?.id===e.id&&(await L(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{B(null)}},[N?.id,_,R,E,L,S,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!Y(N).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[_.isLoading?(0,U.jsx)(ce,{sections:2}):_.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(_.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:y.map(e=>(0,U.jsx)(rt,{entry:e,config:D[ze(e)]?.config,runtime:Ye(e),busy:ae===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:N?.label??J.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,U.jsx)(Ee,{ch:J,dirty:!!R||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{z(null),q(null)},onSave:et}):null,children:N?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:N}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.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,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(N).ready&&pe(N)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,U.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(N).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(N).enabled,disabled:ae===N.id,label:J.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void it(N)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===N.id,checking:w,showConnectionOptions:me,canManageConnection:Y(N).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(N),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:N,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:N,locale:e,messages:J,compact:!0,onChanged:async()=>{await L(),await Q(),await E()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(I,{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,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.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,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(A,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.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,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
@@ -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,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.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-DQ5X6cXp.js";import{l as u,n as d,r as f,s as p}from"./locale-store-Bjvw7jtg.js";import{Al as m,Ao as h,Bs as g,Dc as _,Fl as v,Fo as y,Gl as b,Go as x,Jr as S,Kr as C,La as w,Mo as T,Ni as E,No as D,Oo as O,Po as k,Ps as A,Qs as j,Tl as M,Ts as N,Uo as P,Us as F,Wl as I,Wo as L,Xo as R,Yr as z,Zo as B,Zr as ee,_s as V,ac as H,bs as te,cc as ne,cs as re,di as U,ds as ie,el as ae,fi as oe,gc as se,gs as W,hc as ce,hi as le,ic as ue,jo as de,ko as fe,mi as pe,mo as me,nc as he,ou as ge,pi as _e,po as ve,qr as ye,ru as be,tc as xe,tu as Se,vc as Ce,xs as G,zc as K}from"./index-Cb9y6tVR.js";import{t as we}from"./page-tabs-D6YJ6_l_.js";import{A as q,C as J,D as Y,E as Te,M as Ee,N as De,O as Oe,P as ke,S as Ae,T as je,_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,j as Ve,k as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze,v as Qe,w as $e,x as et,y as tt}from"./connectors-api-Ne8mQrYN.js";var X=n(),Z=e(t(),1),Q=r(),nt={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function rt(e){let t=(0,X.c)(18),{connector:n,size:r,className:i}=e,a=r===void 0?`md`:r,o=n?.branding?.logoUrl,[c,l]=(0,Z.useState)(!1),u=nt[a],d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{l(!1)},t[0]=d):d=t[0];let f;t[1]===o?f=t[2]:(f=[o],t[1]=o,t[2]=f),(0,Z.useEffect)(d,f);let p;t[3]!==i||t[4]!==u.frame?(p=s(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,u.frame,i),t[3]=i,t[4]=u.frame,t[5]=p):p=t[5];let m;t[6]===n?m=t[7]:(m=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=m);let h=n?.displayName,g;t[8]!==u.fallback||t[9]!==u.image||t[10]!==c||t[11]!==o?(g=o&&!c?(0,Q.jsx)(`img`,{src:o,alt:``,loading:`lazy`,draggable:!1,className:s(`object-contain`,u.image),onError:()=>l(!0)}):(0,Q.jsx)(_,{className:s(`text-fg-muted`,u.fallback),"aria-hidden":!0}),t[8]=u.fallback,t[9]=u.image,t[10]=c,t[11]=o,t[12]=g):g=t[12];let v;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g?(v=(0,Q.jsx)(`span`,{className:p,style:m,title:h,children:g}),t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=v):v=t[17],v}function it(e){let t=(0,X.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,m,h,g,v;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(at),y=e.slice(0,3),b=Math.max(0,e.length-y.length),x=o.connect,S=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==x||t[21]!==n||t[22]!==i?(C=e=>(0,Q.jsxs)(V,{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)(_,{className:`size-4`}),x]}),t[20]=x,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],v=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Q.jsx)(rt,{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]===S?k=t[37]:(k=S?(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:S}):null,t[36]=S,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)(Se,{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=y.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[y.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)),b>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,b]}):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]=v}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],v=t[19];let y;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(y=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=y):y=t[62];let b;t[63]!==r||t[64]!==c?(b=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]=b):b=t[65];let x;return t[66]!==y||t[67]!==b||t[68]!==p||t[69]!==m||t[70]!==h||t[71]!==g||t[72]!==v?(x=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:v,children:[y,b]}),t[66]=y,t[67]=b,t[68]=p,t[69]=m,t[70]=h,t[71]=g,t[72]=v,t[73]=x):x=t[73],x}function at(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ot=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function st(e,t){return t.some(t=>t.connectorId===e.id)}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,ct)}),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`,ct)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ct)})]}),(0,Q.jsx)(`div`,{className:s(`h-3 w-full`,ct)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-[88%]`,ct)})]})]})}),e[1]=n):n=e[1],n}var ut=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function dt(){let e=(0,X.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,ut)}),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`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,ut)})]}),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`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,ut)})]})]})]}),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`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,ut)})]}),(0,Q.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,ut)})]}),e[3]=i):i=e[3],i}function ft(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function pt(e,t){return t.connectorCapabilityLabels[e]??e}function mt(e,t){if(e.runtime.type===`mcp`)return ft(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 ft(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function ht(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function gt(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function _t(e){let t=(0,X.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(vt),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 vt(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 yt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=gt(e),p=e.capabilities.slice(0,8),m=Math.max(0,e.capabilities.length-p.length),g=[...(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}))],y=async()=>{o(!0),d(null);try{l(await Pe(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(rt,{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)(Se,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(de,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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)(G,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ft(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)(ae,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ht(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)(v,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ft(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:pt(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)(_t,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(_t,{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)(_t,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ft(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)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:ht(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)(v,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),g.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:g.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)(he,{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:mt(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)(fe,{asChild:!0,children:(0,Q.jsx)(V,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(G,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(V,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(Ce,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(V,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(_,{className:`size-4`}),i.connect]})]})]})]})})}var bt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W);function xt(e){let t=(0,X.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)(T,{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)(se,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[g,_]})]}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ie.focusRingPanel),t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===l.modalClose?x=t[15]:(x=(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:y,"aria-label":l.modalClose,children:b})}),t[14]=l.modalClose,t[15]=x);let S;t[16]!==x||t[17]!==v?(S=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[v,x]}),t[16]=x,t[17]=v,t[18]=S):S=t[18];let C;t[19]===u.idleTtlLabel?C=t[20]:(C=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=s(bt,`w-40 flex-none`),t[21]=w):w=t[21];let E=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]!==E||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:w,value:E,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=E,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]!==C||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:[C,j,M]})}),t[30]=C,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)(V,{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)(K,{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)(V,{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 z;t[50]!==S||t[51]!==N||t[52]!==R?(z=(0,Q.jsxs)(D,{children:[f,(0,Q.jsxs)(h,{className:p,children:[S,N,R]})]}),t[50]=S,t[51]=N,t[52]=R,t[53]=z):z=t[53];let B;return t[54]!==n||t[55]!==d||t[56]!==z?(B=(0,Q.jsx)(O,{open:n,onOpenChange:d,children:z}),t[54]=n,t[55]=d,t[56]=z,t[57]=B):B=t[57],B}var St=(0,Z.memo)(function(e){let t=(0,X.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)(ue,{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}),Ct=(0,Z.memo)(function(e){let t=(0,X.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)(xe,{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)(V,{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)(ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsxs)(V,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=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`,ie.transition),t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(g,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=v):v=t[12];let y;t[13]!==o||t[14]!==n?(y=(0,Q.jsxs)(ye,{className:_,onSelect:n,children:[v,o]}),t[13]=o,t[14]=n,t[15]=y):y=t[15];let b;t[16]===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`,ie.transition),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(G,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x):x=t[17];let w;t[18]!==c||t[19]!==r?(w=(0,Q.jsxs)(ye,{className:b,onSelect:r,children:[x,c]}),t[18]=c,t[19]=r,t[20]=w):w=t[20];let T;t[21]!==w||t[22]!==y?(T=(0,Q.jsx)(S,{children:(0,Q.jsxs)(C,{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:[y,w]})}),t[21]=w,t[22]=y,t[23]=T):T=t[23];let E;t[24]!==T||t[25]!==h?(E=(0,Q.jsxs)(z,{children:[h,T]}),t[24]=T,t[25]=h,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==f?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,E]}),t[27]=E,t[28]=f,t[29]=D):D=t[29],D}),wt=/^([^:=]+)[:=](.*)$/;function Tt(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=wt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Et(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 Dt(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 Ot(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 kt(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)||Ot(t)&&(r[e]=t);return r}function At(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function jt(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 Mt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=At(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=jt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Et(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Nt(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:Dt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function Pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Ft(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)||Ot(t)?[]:[Nt(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 It(e){return Mt(e)}async function Lt(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]=Mt(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})}),ve()}function Rt(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 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.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 Bt(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 Vt(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=Rt(n.payload.tools),i=zt(n.payload.resources),a=Bt(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 Ht(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Ut(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 Wt(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Gt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function Kt(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 qt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),p=Kt(e),m=(0,Z.useCallback)(async()=>{o(!0),f(null);try{let t=await Vt(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,Z.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)(V,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),t.removeServer]})]})]})]})}function Jt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Yt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Jt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function Xt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Zt(e){let t=(0,X.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,Z.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Yt(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)(ue,{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`,W),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||Xt(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 Qt(e){let t=(0,X.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)(T,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,B)}),t[0]=m):m=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=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`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(G,{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)(k,{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 b;t[9]===y?b=t[10]:(b=(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=b);let x;t[11]!==v||t[12]!==b?(x=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[v,b]}),t[11]=v,t[12]=b,t[13]=x):x=t[13];let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[14]=S):S=t[14];let C;t[15]===d?C=t[16]:(C=(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:S})}),t[15]=d,t[16]=C);let w;t[17]!==x||t[18]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[x,C]}),t[17]=x,t[18]=C,t[19]=w):w=t[19];let E;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(E=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Zt,{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]=E):E=t[27];let A;t[28]===d?A=t[29]:(A=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(V,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let j;t[30]!==w||t[31]!==E||t[32]!==A?(j=(0,Q.jsxs)(D,{children:[m,(0,Q.jsxs)(h,{className:g,children:[w,E,A]})]}),t[30]=w,t[31]=E,t[32]=A,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,Q.jsx)(O,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}function $t(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function en(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?e.isDefault===t.isDefault?$t(t)-$t(e):e.isDefault?-1:1:e.isCurrentAuthorization?-1:1}function tn(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(en);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>en(e.primary,t.primary))}var nn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W);function rn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function an(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function on(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 sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function ln({instance:e,t,onChanged:n}){let r=rn(e),[i,a]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)([]),[w,T]=(0,Z.useState)({}),[E,D]=(0,Z.useState)(`read`),[O,k]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),N=(0,Z.useMemo)(()=>tn(i),[i]),P=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){k(!0),M(null);try{let[t,n,i,o,s,c,u,f]=await Promise.all([ze().catch(()=>[]),Re(r).catch(()=>[]),Me(20).catch(()=>[]),Ze(r).catch(()=>`read`),Qe().catch(()=>[]),Ue(r).catch(()=>null),Fe(r).catch(()=>null),tt().catch(()=>[])]);a(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),D(o),p(s.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),b(u),C(f);let m=tn(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())).map(e=>e.primary).filter(e=>!!e.accountId),g=await Promise.all(m.map(async e=>[e.accountId,await Le(e.accountId)]).map(e=>e.catch(()=>null)));T(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,e.materialized,r]);(0,Z.useEffect)(()=>{P()},[P]);let I=(0,Z.useCallback)(async()=>{if(r){k(!0),M(null);try{let t=await Y(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(y()){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`);let i=await ke(r,t.connectionId);if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.(),await P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,P,n,r]),R=(0,Z.useCallback)(async e=>{if(r){D(e);try{await je(r,e),await P()}catch(e){M(e instanceof Error?e.message:String(e))}}},[P,r]),z=(0,Z.useCallback)(async(e,t)=>{k(!0),M(null);try{await J(e,t),await P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}},[P]),B=(0,Z.useCallback)(async e=>{if(r){M(null);try{h(await Ve(r,e))}catch(e){M(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,Z.useCallback)(e=>{m&&B({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[B,m]),H=(0,Z.useCallback)(async e=>{k(!0),M(null);try{await e(),await P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}},[P]);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)(V,{variant:`secondary`,disabled:O,onClick:()=>void I(),children:[O?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(ae,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(V,{variant:`ghost`,disabled:O,onClick:()=>void P(),children:t.refresh})]})]}),j?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:j}):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(N.filter(e=>e.primary.status===`active`).length)}):v.status===`reauthorization_required`?t.composioHealthReconnect:v.status===`degraded`?on(v,t):t.composioHealthDisconnected}),v.recovery===`none`?null:(0,Q.jsx)(V,{variant:`ghost`,disabled:O,onClick:()=>void(v.recovery===`retry`?P():I()),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)(L,{className:s(nn,`mt-1 h-9 py-1`),value:E,onChange:e=>void R(e.currentTarget.value),children:[(0,Q.jsx)(x,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(x,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,Q.jsx)(x,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(L,{className:s(nn,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void B({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(x,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(x,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(x,{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:()=>ee(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)(V,{variant:`secondary`,disabled:O,onClick:()=>void z(e.id,`denied`),children:[(0,Q.jsx)(te,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(V,{disabled:O,onClick:()=>void z(e.id,`approved`),children:[(0,Q.jsx)(o,{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}),N.length?[{title:t.composioConnectedAccounts,items:N.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:N.filter(e=>e.primary.status!==`active`)}].filter(e=>e.items.length>0).map(e=>(0,Q.jsxs)(`section`,{className:`mb-3 space-y-2`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-medium text-fg-muted`,children:[e.title,` · `,e.items.length]}),e.items.map(e=>{let i=e.primary,a=S.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?w[i.accountId]:void 0;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i.alias??i.workspace??i.accountEmail??i.username??t.composioUnnamedAuthorization}),i.connectedAt?(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:$(t.composioAuthorizedAt,{time:new Date(i.connectedAt).toLocaleString()})}):null,(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[$(t.composioAuthorizationCount,{count:String(e.authorizations.length)}),e.authorizations.length>1?` · ${$(t.composioDuplicateAuthorizations,{count:String(e.authorizations.length-1)})}`:``]})]}),(0,Q.jsxs)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,i.status===`active`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[sn(i.status,t),i.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),a||i.status===`active`?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.connectorLearningTitle}),(0,Q.jsx)(`p`,{className:s(`mt-1 text-xs`,a?.status===`failed`?`text-red-600`:`text-fg-subtle`),children:a?$(t.connectorLearningStatus,{status:cn(a,o,t),count:String(a.candidatesCreated)}):t.connectorLearningEmpty}),o?(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:O,onChange:e=>void H(()=>De(i.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:O||!o.scanEnabled,onChange:e=>void H(()=>De(i.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,Q.jsxs)(`label`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:[t.connectorScanInterval,(0,Q.jsxs)(L,{className:s(nn,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void H(()=>De(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,Q.jsxs)(x,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null]}):null,(0,Q.jsxs)(`details`,{className:`text-xs text-fg-subtle`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-lg bg-surface-base p-2`,children:[e.authorizations.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0 break-all font-mono`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,Q.jsx)(V,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:O,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&H(()=>$e(e.id))},children:(0,Q.jsx)(A,{className:`size-3.5 text-red-500`})})]},e.id)),(0,Q.jsx)(`input`,{className:s(nn,`h-8 py-1 text-xs`),defaultValue:i.alias??``,placeholder:t.composioAccountAlias,onBlur:e=>{e.currentTarget.value!==(i.alias??``)&&H(()=>q(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,Q.jsx)(V,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:O||i.isDefault||i.status!==`active`,onClick:()=>void H(async()=>{await q(i.id,{isDefault:!0}),r&&await Ve(r,{selectedConnectionIds:[i.id]})}),children:(0,Q.jsx)(F,{className:s(`size-4`,i.isDefault&&`fill-current`)})}),(0,Q.jsx)(V,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void H(()=>et(i.id)),children:(0,Q.jsx)(ne,{className:`size-4`})}),i.status===`active`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:O,onClick:()=>void H(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.()}),children:[O?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(ne,{className:`size-4`}),t.composioSyncNow]}):null]})]},e.key)})]},e.title)):(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)(L,{className:s(nn,`mt-1 h-9 py-1`),value:E,onChange:e=>void R(e.currentTarget.value),children:[(0,Q.jsx)(x,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(x,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(x,{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:[an(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 un=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W);function dn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function fn(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 pn(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 mn(e){let t=(0,X.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(_e,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(le,{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)(oe,{children:(0,Q.jsx)(U,{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 hn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[C,w]=(0,Z.useState)(!1),[E,N]=(0,Z.useState)(()=>fn(t,e)),[P,F]=(0,Z.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,z=(0,Z.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,j,i.detailHealth],[`tools`,G,`${i.detailTools} ${y?y.toolCount:e.usage.lastToolCount??``}`],[`resources`,v,`${i.detailResources} ${y?y.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,M,`${i.detailPrompts} ${y?y.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ae,i.detailPermissions]]:[[`permissions`,ae,i.detailPermissions]];return L?[...t,[`config`,v,i.connectorConfigLabel]]:t},[y,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,L,i]),B=(0,Z.useCallback)(async()=>{c(!0),F(null);try{let t=await He(e.instanceId);b(t),t.toolCount>0&&S(`tools`),r()}catch(e){F(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),ee=(0,Z.useCallback)(async()=>{u(!0),F(null);try{await Ae(e.instanceId),await r(),n()}catch(e){F(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ne=(0,Z.useCallback)(async()=>{if(!(!t||!L)){f(!0),F(null);try{let n={};for(let e of t.setup.config??[]){let t=pn(e.type,E[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ee(e.instanceId,{config:n}),await r(),S(`health`)}catch(e){F(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[E,t,e.instanceId,r,L]),re=(0,Z.useCallback)(async()=>{m(!0),_(null),F(null);try{_((await Oe(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)(O,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(rt,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(de,{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)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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:[P?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.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`,x===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>S(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:[x===`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:dn(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,x===`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)(V,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>w(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.tools.slice(0,8).map(e=>(0,Q.jsx)(mn,{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)(V,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void B(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),i.test]})]}):null,x===`resources`?y?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.resources.slice(0,8).map(e=>(0,Q.jsx)(mn,{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,x===`prompts`?y?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.prompts.slice(0,8).map(e=>(0,Q.jsx)(mn,{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,x===`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,x===`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:un,value:E[e.key]??``,placeholder:e.placeholder,onChange:t=>N(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(ln,{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}),g===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(g)})})]}),(0,Q.jsxs)(V,{disabled:p,onClick:()=>void re(),children:[p?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(v,{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)(V,{variant:`secondary`,onClick:n,children:i.modalClose}),x===`config`&&L?(0,Q.jsxs)(V,{variant:`primary`,disabled:d,onClick:()=>void ne(),children:[d?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(H,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void B(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void ee(),children:[l?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Qt,{open:C,onOpenChange:w,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 gn=[`understand`,`act`,`reach`];function _n(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 vn(e){return _n(e)[0]??`act`}function yn(e,t){let n=t?vn(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 bn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=(0,Z.useCallback)(async()=>{c(!0),f(null);try{await He(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,i]),m=(0,Z.useCallback)(async()=>{u(!0),f(null);try{await Ae(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,i]),h=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,g=e.usage.lastToolCount??0,_=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),v=yn(e,t).state,y=v===`ready`?{label:a.connectionReady,Icon:Se,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:v===`needs_setup`?{label:a.connectionNeedsSetup,Icon:be,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:I,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)(rt,{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`,y.className),children:[(0,Q.jsx)(y.Icon,{className:`size-3`,"aria-hidden":!0}),y.label]}),_?(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,` `,h]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(g)})})]}),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]})]}),(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:[v===`needs_setup`?(0,Q.jsxs)(V,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(be,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void p(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),a.remove]})]})]})]})}var xn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W),Sn=s(xn,`min-h-28 font-mono`);function Cn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function wn(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 Tn(e){let t=(0,X.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(En),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 En(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 Dn({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=a.understanding!=null,[u,d]=(0,Z.useState)(!o),[f,p]=(0,Z.useState)(o),[g,v]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(l);(0,Z.useEffect)(()=>{if(!o)return;let e=!1;return Ie().then(({configured:t})=>{e||d(t)}).catch(t=>{e||x(t instanceof Error?t.message:String(t))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[a.id,o]);let w=e.result?`complete`:e.installing?`health`:`configure`,E=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],A=(0,Z.useCallback)(async()=>{let n=y(),i=o&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),x(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!u&&(await Xe(g),d(!0));let s={};for(let t of a.setup.config??[]){let n=wn(t.type,e.config[t.key]??``);n!==void 0&&(s[t.key]=n)}let f=e.store?await We(e.store.packageName,{secrets:e.secrets,config:s},e.store.version):await qe(a.id,{secrets:e.secrets,config:s,definition:a.source===`registry`?a:void 0}),p=null;try{if(o)if((c?await Fe(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await ke(c);if(l&&S){if(!e.accountId)throw Error(`Connector account is unavailable.`);await Te(e.accountId)}}else{let e=await Y(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 ke(c,e.connectionId);if(i?.close(),l&&S){if(!t.accountId)throw Error(`Connector account is unavailable.`);await Te(t.accountId)}}}catch(n){i?.close(),t({...e,installing:!1,result:f,health:null,error:n instanceof Error?n.message:String(n)}),await r(f);return}if(!o)try{p=await He(f.instanceId)}catch{p=null}t({...e,installing:!1,result:f,health:p}),await r(f)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[l,g,u,c,a,e,o,S,t,r]);return(0,Q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(rt,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(de,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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===w);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&&!u?(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)(m,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(re,{className:`mt-3`,value:g,onChange:v,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,o&&l?(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:S,onChange:e=>C(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)(re,{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:Sn,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:xn,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)(K,{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,b?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b}):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:Cn(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)(Tn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(Tn,{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)(Tn,{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)(V,{variant:`primary`,disabled:!!e.result||e.installing||f||o&&!u&&!g.trim(),onClick:()=>void A(),children:[e.installing?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(Se,{className:`size-4`}):(0,Q.jsx)(_,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function On(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 kn(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 Pt(r)}function An(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 jn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W)}function Mn({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=Tt(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)(V,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(b,{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(jn(),`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(jn(),`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)(V,{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)(A,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},An(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,ie.press),onClick:p,children:[`+ `,n]})]})}var Nn=[`stdio`,`sse`,`streamable-http`];function Pn(e){let t=(0,X.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 Fn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,W)}function In(e){let t=(0,X.c)(35),{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)(Pn,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(L,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Nn.map(e=>(0,Q.jsx)(x,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(Pn,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:Fn(),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)(Pn,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Pn,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(Pn,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(Pn,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:s(Fn(),`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)(Pn,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:s(Fn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(Mn,{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)(Pn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:Fn(),value:Ht(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Ut(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;t[25]!==i||t[26]!==n||t[27]!==u||t[28]!==r?(m=u?(0,Q.jsx)(Pn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:14400,className:Fn(),value:Wt(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Gt(e.target.value)})})}):null,t[25]=i,t[26]=n,t[27]=u,t[28]=r,t[29]=m):m=t[29];let h;return t[30]!==d||t[31]!==f||t[32]!==p||t[33]!==m?(h=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p,m]}),t[30]=d,t[31]=f,t[32]=p,t[33]=m,t[34]=h):h=t[34],h}function Ln(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 Rn(e){let t=(0,X.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Ln(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)(_e,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(le,{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)(oe,{children:(0,Q.jsx)(U,{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 zn({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,Z.useState)(n),[m,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)({status:`idle`}),[E,A]=(0,Z.useState)(null),j=n.id.trim(),M=f.id.trim()!==j&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,N=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,P=f.id.trim().length>0&&!M&&!N&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),F=Kt(f),I=(0,Z.useCallback)(async()=>{if(f.id.trim()){v(!0),b(null),w({status:`loading`});try{w({status:`ok`,tools:(await Vt(f.id.trim(),It(f))).tools})}catch(e){w({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{v(!1)}}},[f]),L=(0,Z.useCallback)(async()=>{if(!(!P||m)){g(!0),b(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Lt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},kt(a)),await d(),u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[P,a,r,n.clientKey,t,u,d,j,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(k,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(te,{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)(he,{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:F||(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)(In,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),b(null)},idConflictMessage:M??N})]}),C.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)(G,{className:`size-4 text-accent`,"aria-hidden":!0}),C.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(C.tools.length))]}),C.tools.length>0?(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>A(C.tools),children:c.viewAllTools}):null]}),C.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:C.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(Rn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,C.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C.message}):null,y?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y}):null,(0,Q.jsxs)(`details`,{open:x,onToggle:e=>S(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)(ge,{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)(In,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),b(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)(V,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void I(),children:[_?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(V,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(V,{variant:`primary`,disabled:!P||m,onClick:()=>void L(),children:[m?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Se,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),E?(0,Q.jsx)(Qt,{open:!0,onOpenChange:e=>{e||A(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:E,stripPrefix:`${f.id.trim()}__`}):null]}):null}var Bn=`builtin`,Vn=`composio`,Hn=`xopc-store`;function Un(e){return Bn}function Wn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Gn(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 Kn(e,t,n){return e.filter(e=>Gn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function qn(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 Jn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Yn(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 Xn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Zn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/you?tab=sources`}function Qn(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),o=!!r,c=a(),[f,p]=i(),m=f.get(`understanding`)===`1`,h=Zn(f.get(`returnTo`)),g=f.get(`tab`),[_,v]=(0,Z.useState)(!m&&g===`connected`?`connected`:`discover`),y=(0,Z.useRef)(!1),[b,x]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[S,C]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(1),[A,j]=(0,Z.useState)(void 0),[M,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(!1),[B,ee]=(0,Z.useState)(m?f.get(`connector`)??``:``),[H,te]=(0,Z.useState)(Un(m?`understanding`:`default`)),[ne,re]=(0,Z.useState)(`name`),[U,ie]=(0,Z.useState)(m?`understand`:`all`),[ae,oe]=(0,Z.useState)(null),[se,W]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(null),[fe,pe]=(0,Z.useState)(null),[he,ge]=(0,Z.useState)(null),[_e,ve]=(0,Z.useState)(!1),[ye,be]=(0,Z.useState)(void 0),[xe,Se]=(0,Z.useState)(!1),{data:Ce,mutate:G}=me(o),q=Ce?.payload?.config,J=(0,Z.useMemo)(()=>q===void 0?null:Ft(q),[q]),Y=J?.servers??[],Te=b.instances.length+Y.length;(0,Z.useEffect)(()=>{J&&be(J.sessionIdleTtlMinutes)},[J]);let Ee=(0,Z.useCallback)(async()=>{if(!r){x({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}x(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Be(),Ne(),Je(``,12).catch(()=>null)]);x(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){x({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,Z.useEffect)(()=>{Ee()},[Ee]),(0,Z.useEffect)(()=>{if(!o||_!==`connected`)return;let e=!1,t=window.setTimeout(()=>{z(!0),Je(I,50).then(t=>{e||x(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||z(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[o,I,_]),(0,Z.useEffect)(()=>{y.current||b.loading||o&&!J||(v(m?`discover`:Te>0?`connected`:`discover`),y.current=!0)},[o,Te,J,m,b.loading]);let De=(0,Z.useCallback)(e=>{y.current=!0,v(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Vn,displayName:t.composioSourceName},{id:Hn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||H===`builtin`){x(e=>({...e,registryCatalog:[]})),k(1),j(void 0);return}let t=B.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=H===`all`?Oe:Oe.filter(e=>e.id===H);if(i.length!==0){C(!0),r?x(e=>({...e,error:null})):(k(1),j(void 0),x(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ge({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ke({q:t||void 0,page:n,pageSize:24,sort:ne===`source`?`newest`:`downloads`});return{connectors:r.items.map(Yn),totalPages:r.meta.totalPages}})),a=Xn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));k(n),j(o),x(e=>({...e,registryCatalog:r?Xn([...e.registryCatalog,...a]):a}))}catch(e){x(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{C(!1)}}},[ne,B,H,o,Oe]);(0,Z.useEffect)(()=>{if(_!==`discover`||b.loading)return;if(H===`builtin`){x(e=>({...e,registryCatalog:[]})),k(1),j(void 0);return}let e=window.setTimeout(()=>{ke()},B.trim()?350:0);return()=>window.clearTimeout(e)},[B,H,ke,b.loading,_]);let Ae=(0,Z.useMemo)(()=>new Set(b.instances.map(e=>e.connectorId)),[b.instances]),je=(0,Z.useMemo)(()=>new Map([...b.catalog,...b.registryCatalog].map(e=>[e.id,e])),[b.catalog,b.registryCatalog]);(0,Z.useEffect)(()=>{if(b.loading)return;let e=f.get(`connector`),t=f.get(`instance`);if(!e&&!t)return;let n=b.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)y.current=!0,F(``),le(n.instanceId),de(n),v(`connected`);else if(e){let t=je.get(e);if(!t)return;y.current=!0,te(Un(m?`understanding`:`default`)),ee(``),W(t),v(`discover`)}let r=new URLSearchParams(f);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),p(r,{replace:!0})},[je,m,f,p,b.instances,b.loading]);let Me=(0,Z.useCallback)(async e=>{D(!0),x(e=>({...e,error:null}));try{let t=await Ye(e);oe(On(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){x(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{D(!1)}},[]),Pe=(0,Z.useMemo)(()=>new Set(b.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[b.instances]),Fe=(0,Z.useCallback)(async e=>{if(!J||q===void 0)return;let t=Y.filter(t=>t.clientKey!==e.clientKey);await Lt({sessionIdleTtlMinutes:J.sessionIdleTtlMinutes,servers:t},kt(q)),await G(),await Ee()},[q,Y,Ee,J,G]),Ie=(0,Z.useCallback)(()=>{ge({mode:`add`,row:kn(Y,Pe)})},[Y,Pe]),Le=(0,Z.useCallback)(async()=>{if(!(!J||q===void 0||xe)){Se(!0);try{await Lt({sessionIdleTtlMinutes:ye,servers:Y},kt(q)),await G(),ve(!1)}finally{Se(!1)}}},[q,Y,n.saved,J,G,ye,xe]),Re=w(e=>e.setPageHeader),ze=w(e=>e.clearPageHeader),Ve=(0,Z.useMemo)(()=>(0,Q.jsx)(Ct,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Ie,onOpenRuntimeSettings:()=>ve(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ie,De]);(0,Z.useLayoutEffect)(()=>(Re({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:Ve}),()=>ze()),[ze,t.title,Ve,Re]);let He=(0,Z.useMemo)(()=>b.instances.map(e=>({instance:e,value:yn(e,je.get(e.connectorId))})),[je,b.instances]),Ue=(0,Z.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Z.useMemo)(()=>b.instances.filter(e=>qn(e,M)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[M,Ue,b.instances]),qe=(0,Z.useMemo)(()=>Y.filter(e=>Jn(e,M)),[M,Y]),Xe=We.length+qe.length,Ze=(0,Z.useMemo)(()=>b.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Wn(e)),[b.catalog]),Qe=(0,Z.useMemo)(()=>H===`builtin`?Ze:H===`all`?Xn([...Ze,...b.registryCatalog]):b.registryCatalog,[Ze,H,b.registryCatalog]),$e=(0,Z.useMemo)(()=>{let e=m?Qe.filter(e=>e.understanding?.mode===`activity`):Qe;return Kn(U===`all`?e:e.filter(e=>_n(e).includes(U)),B,ne)},[ne,B,Qe,m,U]),et=(0,Z.useMemo)(()=>gn.filter(e=>Qe.some(t=>_n(t).includes(e))),[Qe]);(0,Z.useEffect)(()=>{U!==`all`&&!et.includes(U)&&ie(`all`)},[et,U]);let tt=_===`discover`&&H!==`builtin`&&!!(A&&O<A),X=(0,Z.useMemo)(()=>b.instances.find(e=>e.instanceId===ce)??ue,[ce,ue,b.instances]),nt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Bn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),rt=[{id:`connected`,label:t.tabConnected,count:Te},{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:[o?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}),m?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,Q.jsx)(V,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>c(h),children:t.understandingSetupDone})]}):null,(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)(we,{items:rt,activeTab:_,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),b.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b.error}):null,_===`connected`&&o?(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)(St,{value:M,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(E,{className:`size-9 shrink-0 p-0`,loading:b.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Ee})]}),b.peopleGraph&&(b.peopleGraph.people.length>0||I)?(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)(N,{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(b.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(b.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(St,{value:I,onChange:L,placeholder:t.peopleGraphSearchPlaceholder}),R?(0,Q.jsx)(K,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),b.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:b.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(b.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,b.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.slice(0,3).map(e=>(0,Q.jsx)(dt,{},e))}):Te===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)(V,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Xe===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:[We.map(e=>(0,Q.jsx)(bn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===fe,onOpenDetails:e=>{pe(null),le(e.instanceId),de(e)},onChanged:Ee,t},e.instanceId)),qe.map(e=>(0,Q.jsx)(qt,{row:e,t:n,cs:t,onEdit:()=>ge({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Fe(e)},e.clientKey))]})]}):null,_===`discover`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[m?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...et].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,U===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":U===e,onClick:()=>ie(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(St,{value:B,onChange:ee,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:s(`grid min-w-0 grid-cols-1 gap-2 lg:ml-auto`,m?`lg:w-52`:`sm:grid-cols-2 lg:w-[26rem]`),children:[m?null:(0,Q.jsx)(P,{value:H,options:nt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:te}),(0,Q.jsx)(P,{value:ne,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=>re(e)})]})]}),(b.loading||S)&&$e.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:ot.map(e=>(0,Q.jsx)(lt,{},e))}):$e.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:[S?(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)(K,{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:$e.map(e=>(0,Q.jsx)(it,{connector:e,installed:Ae.has(e.id)||st(e,b.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}oe(On(e))},onOpenDetails:e.source===`store`?void 0:W,t},e.id))}),tt?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(V,{type:`button`,variant:`secondary`,disabled:S||T,onClick:()=>void ke({page:O+1,append:!0}),children:[S?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ae?(0,Q.jsx)(Dn,{draft:ae,onChange:oe,onClose:()=>oe(null),t,onInstalled:async e=>{await Ee(),await G(),pe(e.instanceId),De(`connected`)}}):null,se?(0,Q.jsx)(yt,{connector:se,installed:Ae.has(se.id)||st(se,b.instances),onClose:()=>W(null),onInstall:e=>oe(On(e)),t}):null,X?(0,Q.jsx)(hn,{instance:X,definition:je.get(X.connectorId),onClose:()=>{le(null),de(null)},onChanged:Ee,t,mcp:n}):null,he?(0,Q.jsx)(zn,{open:!0,mode:he.mode,initialRow:he.row,existingCustomServers:Y,sessionIdleTtlMinutes:ye,config:q,managedServerIds:Pe,t:n,cs:t,onClose:()=>ge(null),onSaved:async()=>{await G(),await Ee(),De(`connected`)}},`${he.mode}-${he.row.clientKey}`):null,(0,Q.jsx)(xt,{open:_e,sessionIdleTtlMinutes:ye,saving:xe,onChange:be,onSave:Le,onClose:()=>ve(!1),t,mcp:n})]})})}export{Qn as ConnectorsPage};
@@ -1,3 +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{c as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-DQ5X6cXp.js";import{n as u,o as d,r as f}from"./locale-store-Bjvw7jtg.js";import{n as p}from"./activity-store-BwmdJ5pv.js";import{Ao as m,Da as h,Du as g,La as _,Lc as v,Mo as y,No as b,Ns as x,Oo as S,Po as C,Ps as w,Sn as T,St as E,Wl as D,_s as O,_t as k,bs as A,bt as j,gt as M,hc as N,iu as ee,jo as P,ko as te,mt as ne,nl as F,pt as re,qs as I,rt as L,ru as R,su as ie,tu as ae,vt as oe,wt as se,xn as ce,xt as le,zc as z}from"./index-Cb9y6tVR.js";var B=e(t(),1),V=n();function H(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function U(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/chat\/([^/]+)\/?$/.exec(t);if(n){let e=H(n[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function W(e,t){let n=`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var G=r(),K=3,q={info:{Icon:F,className:`text-accent-fg bg-accent-soft`},success:{Icon:ae,className:`text-success bg-success-soft`},warning:{Icon:x,className:`text-warning bg-warning-soft`},error:{Icon:R,className:`text-danger bg-danger-soft`}};function ue(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function J(e){let t=(0,V.c)(55),{item:n,targetAvailability:r}=e,i=u(fe),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let s=a.projectsPage.home,d=p(de),{Icon:f,className:m}=q[n.tone],g;t[2]===m?g=t[3]:(g=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,m),t[2]=m,t[3]=g);let _;t[4]!==f||t[5]!==n.status?(_=n.status===`running`?(0,G.jsx)(z,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,G.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=_):_=t[6];let v;t[7]!==g||t[8]!==_?(v=(0,G.jsx)(`div`,{className:g,children:_}),t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===n.title?y=t[11]:(y=(0,G.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=y);let b;t[12]!==s.activityUnread||t[13]!==n.read?(b=n.read?null:(0,G.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=b):b=t[14];let x;t[15]!==y||t[16]!==b?(x=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S;t[18]===n.message?S=t[19]:(S=n.message?(0,G.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=S);let C;t[20]===n.source?C=t[21]:(C=n.source?(0,G.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=C);let w;t[22]!==n.updatedAt||t[23]!==i?(w=ue(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=w):w=t[24];let T;t[25]===w?T=t[26]:(T=(0,G.jsx)(`span`,{children:w}),t[25]=w,t[26]=T);let E;t[27]===n.occurrences?E=t[28]:(E=n.occurrences>1?(0,G.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=E);let D;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(D=n.href&&r===`available`?(0,G.jsxs)(o,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,G.jsx)(ee,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,G.jsx)(h,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,G.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==E||t[37]!==D||t[38]!==C?(O=(0,G.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[C,T,E,D]}),t[35]=T,t[36]=E,t[37]=D,t[38]=C,t[39]=O):O=t[39];let k;t[40]!==O||t[41]!==x||t[42]!==S?(k=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S,O]}),t[40]=O,t[41]=x,t[42]=S,t[43]=k):k=t[43];let j;t[44]!==n.id||t[45]!==d?(j=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=j):j=t[46];let M;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,G.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),t[47]=M):M=t[47];let N;t[48]!==s.activityRemove||t[49]!==j?(N=(0,G.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:j,children:M}),t[48]=s.activityRemove,t[49]=j,t[50]=N):N=t[50];let P;return t[51]!==k||t[52]!==N||t[53]!==v?(P=(0,G.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[v,k,N]}),t[51]=k,t[52]=N,t[53]=v,t[54]=P):P=t[54],P}function de(e){return e.remove}function fe(e){return e.language}function pe(){let e=(0,V.c)(14),t=l(u(be)).projectsPage.home,n=p(ye),r=p(ve),i=p(_e),[a,o]=(0,B.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,B.useState)(c),m;e[1]===n?m=e[2]:(m=n.filter($),e[1]=n,e[2]=m);let h=m.length,_;e[3]===n?_=e[4]:(_=n.filter(Q),e[3]=n,e[4]=_);let v=_.length,y;e[5]!==a||e[6]!==n?(y=a?n:n.slice(0,K),e[5]=a,e[6]=n,e[7]=y):y=e[7];let b=y,x;e[8]===n?x=e[9]:(x=[...new Set(n.flatMap(ge))].sort().join(`
2
- `),e[8]=n,e[9]=x);let S=x,C,T;e[10]===S?(C=e[11],T=e[12]):(C=()=>{let e=new AbortController,t=new Map((S?S.split(`
3
- `):[]).flatMap(he));return f(Object.fromEntries([...t.keys()].map(me))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await W(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch(Z),()=>e.abort()},T=[S],e[10]=S,e[11]=C,e[12]=T),(0,B.useEffect)(C,T);let E;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,G.jsx)(g,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=E):E=e[13],(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,(0,G.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,G.jsx)(z,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):v>0?(0,G.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[v,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v>0?(0,G.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,G.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(X)?(0,G.jsxs)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,G.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,G.jsxs)(`div`,{className:`mt-3 px-1`,children:[b.map(e=>(0,G.jsx)(J,{item:e,targetAvailability:e.href&&U(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>K?(0,G.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(Y),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(D,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`p`,{children:t.activityEmpty})]})]})}function Y(e){return!e}function X(e){return e.status===`done`}function Z(){}function me(e){return[e,`checking`]}function he(e){let t=U(e);return t?[[e,t]]:[]}function ge(e){return e.href&&U(e.href)?[e.href]:[]}function Q(e){return!e.read}function $(e){return e.status===`running`}function _e(e){return e.clearFinished}function ve(e){return e.markAllRead}function ye(e){return e.items}function be(e){return e.language}function xe(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Se(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:L(n)}function Ce(e){let t=(0,V.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,G.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,V.c)(18),{task:n,statusLabel:r,backgroundPath:i}=e,a;t[0]!==i||t[1]!==n.id?(a=T(i,n.id),t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,G.jsx)(`h3`,{className:`line-clamp-2 text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]===n.updatedAt?c=t[6]:(c=Se(n.updatedAt,``),t[5]=n.updatedAt,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c}),t[7]=c,t[8]=l);let u;t[9]!==s||t[10]!==l?(u=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11];let d;t[12]===r?d=t[13]:(d=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[12]=r,t[13]=d);let f;return t[14]!==a||t[15]!==u||t[16]!==d?(f=(0,G.jsxs)(o,{to:a,className:`group flex items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[14]=a,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Te(e){let t=(0,V.c)(12),{receipt:n,evidenceLabel:r,remainingLabel:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),t[0]=a):a=t[0];let o,s;t[1]===n.summary?(o=t[2],s=t[3]):(o=(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:n.summary}),s=(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[1]=n.summary,t[2]=o,t[3]=s);let c=n.remainingWork.length>0?` · ${n.remainingWork.length} ${i}`:``,l;t[4]!==r||t[5]!==n.evidence.length||t[6]!==c?(l=(0,G.jsxs)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:[n.evidence.length,` `,r,c]}),t[4]=r,t[5]=n.evidence.length,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==l?(u=(0,G.jsx)(`div`,{className:`block rounded-xl border border-edge-subtle px-3 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[o,s,l]})]})}),t[8]=o,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function Ee(){let e=(0,V.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,G.jsx)(h,{className:`h-20 rounded-2xl`}),(0,G.jsx)(h,{className:`h-72 rounded-2xl`}),(0,G.jsx)(h,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,V.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,a;t[0]===n.name?a=t[1]:(a=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=a);let s;t[2]===r?s=t[3]:(s=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Se(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,G.jsxs)(o,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Oe(e){let t=(0,V.c)(27),{item:n,href:r,kindLabel:i,reasonLabel:a,approveLabel:s,denyLabel:c,busy:l,onRespond:u}=e,d;t[0]===n.title?d=t[1]:(d=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=d);let f=n.projectName||i,p;t[2]===f?p=t[3]:(p=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==d||t[5]!==p?(m=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[4]=d,t[5]=p,t[6]=m):m=t[6];let h;t[7]===a?h=t[8]:(h=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[7]=a,t[8]=h);let g;t[9]!==m||t[10]!==h?(g=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]===n.detail?_=t[13]:(_=n.detail?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=_);let v;t[14]!==r||t[15]!==g||t[16]!==_?(v=(0,G.jsxs)(o,{to:r,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,_]}),t[14]=r,t[15]=g,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==s||t[19]!==l||t[20]!==c||t[21]!==n.response||t[22]!==u?(y=n.response?(0,G.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`deny`),children:c}),(0,G.jsx)(O,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`approve`),children:s})]}):null,t[18]=s,t[19]=l,t[20]=c,t[21]=n.response,t[22]=u,t[23]=y):y=t[23];let b;return t[24]!==v||t[25]!==y?(b=(0,G.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[v,y]}),t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function ke(e){let t=(0,V.c)(65),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,B.useState)(``),d=n.judgment,f;t[0]===n.title?f=t[1]:(f=(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===n.detail?p=t[3]:(p=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,G.jsx)(I,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=h):h=t[7];let g;t[8]===m?g=t[9]:(g=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[8]=m,t[9]=g);let _;t[10]!==d.whyNow||t[11]!==r.whyNow?(_=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=_):_=t[12];let v;t[13]!==d.impact||t[14]!==r.impact?(v=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=v):v=t[15];let y;t[16]!==d.workDone||t[17]!==r.workDone?(y=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=y):y=t[18];let b;t[19]!==d.recommendation||t[20]!==r.recommendation?(b=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=b):b=t[21];let x;t[22]!==_||t[23]!==v||t[24]!==y||t[25]!==b?(x=(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[_,v,y,b].map(Ae)}),t[22]=_,t[23]=v,t[24]=y,t[25]=b,t[26]=x):x=t[26];let S;t[27]!==i||t[28]!==d.decision||t[29]!==a?(S=d.decision?(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,G.jsxs)(O,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[27]=i,t[28]=d.decision,t[29]=a,t[30]=S):S=t[30];let C;t[31]!==i||t[32]!==r.snooze||t[33]!==o?(C=(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[31]=i,t[32]=r.snooze,t[33]=o,t[34]=C):C=t[34];let w;t[35]!==i||t[36]!==r.dismiss||t[37]!==s?(w=(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[35]=i,t[36]=r.dismiss,t[37]=s,t[38]=w):w=t[38];let T;t[39]!==C||t[40]!==w?(T=(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[C,w]}),t[39]=C,t[40]=w,t[41]=T):T=t[41];let E;t[42]!==l||t[43]!==c?(E=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[42]=l,t[43]=c,t[44]=E):E=t[44];let D;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>u(e.target.value),t[45]=D):D=t[45];let k;t[46]!==l||t[47]!==r.feedbackPlaceholder?(k=(0,G.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:D,placeholder:r.feedbackPlaceholder}),t[46]=l,t[47]=r.feedbackPlaceholder,t[48]=k):k=t[48];let A;t[49]!==i||t[50]!==l?(A=i||!l.trim(),t[49]=i,t[50]=l,t[51]=A):A=t[51];let j;t[52]!==r.applyFeedback||t[53]!==A?(j=(0,G.jsx)(O,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:A,children:r.applyFeedback}),t[52]=r.applyFeedback,t[53]=A,t[54]=j):j=t[54];let M;t[55]!==E||t[56]!==k||t[57]!==j?(M=(0,G.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:E,children:[k,j]}),t[55]=E,t[56]=k,t[57]=j,t[58]=M):M=t[58];let N;return t[59]!==x||t[60]!==S||t[61]!==T||t[62]!==M||t[63]!==g?(N=(0,G.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[g,x,S,T,M]}),t[59]=x,t[60]=S,t[61]=T,t[62]=M,t[63]=g,t[64]=N):N=t[64],N}function Ae(e){let[t,n]=e;return(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function je(e){let t=(0,V.c)(32),{item:n,href:r,statusLabel:i,retryLabel:a,viewLabel:s,acknowledgeLabel:c,busy:l,onView:u,onRetry:d,onAcknowledge:f}=e,p;t[0]===n.title?p=t[1]:(p=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=p);let m;t[2]===i?m=t[3]:(m=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:i}),t[2]=i,t[3]=m);let h;t[4]!==p||t[5]!==m?(h=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[4]=p,t[5]=m,t[6]=h):h=t[6];let g;t[7]===n.detail?g=t[8]:(g=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=g);let _;t[9]!==r||t[10]!==h||t[11]!==g?(_=(0,G.jsxs)(o,{to:r,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,g]}),t[9]=r,t[10]=h,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==c||t[14]!==l||t[15]!==f?(v=(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:f,children:c}),t[13]=c,t[14]=l,t[15]=f,t[16]=v):v=t[16];let y;t[17]!==l||t[18]!==u||t[19]!==s?(y=(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:u,children:s}),t[17]=l,t[18]=u,t[19]=s,t[20]=y):y=t[20];let b;t[21]!==l||t[22]!==d||t[23]!==a?(b=(0,G.jsx)(O,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:d,children:a}),t[21]=l,t[22]=d,t[23]=a,t[24]=b):b=t[24];let x;t[25]!==v||t[26]!==y||t[27]!==b?(x=(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[v,y,b]}),t[25]=v,t[26]=y,t[27]=b,t[28]=x):x=t[28];let S;return t[29]!==_||t[30]!==x?(S=(0,G.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[_,x]}),t[29]=_,t[30]=x,t[31]=S):S=t[31],S}function Me(){let e=u(e=>e.language),t=l(e).projectsPage,n=re(e),r=a(),s=i(),c=`${s.pathname}${s.search}`,d=_(e=>e.setPageHeader),f=_(e=>e.clearPageHeader),[p,h]=(0,B.useState)(null),[g,x]=(0,B.useState)(!0),[w,D]=(0,B.useState)(null),[ee,F]=(0,B.useState)(!1),[L,z]=(0,B.useState)(``),[V,H]=(0,B.useState)(()=>crypto.randomUUID()),[U,W]=(0,B.useState)(!1),[K,q]=(0,B.useState)(null),[ue,J]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),Y=(0,B.useCallback)(async(t=!1)=>{t&&x(!0),D(null);try{h(await oe(e))}catch(e){D(e instanceof Error?e.message:String(e))}finally{x(!1)}},[e]);(0,B.useEffect)(()=>{Y(!0)},[Y]),(0,B.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Y()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[Y]);let X=(0,B.useMemo)(()=>p?.decisions??[],[p]),Z=(0,B.useMemo)(()=>p?.attention??[],[p]),me=(0,B.useCallback)(async t=>{t.preventDefault();let n=L.trim();if(!(!n||U)){W(!0),q(null);try{let t=await M({idempotencyKey:V,title:n,locale:e,priority:`normal`,contract:{objective:n,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:[],context:[],authorityGrants:[],activation:{mode:`start`,executor:{kind:`agent`,agentId:`main`}}});F(!1),z(``),H(crypto.randomUUID()),r(T(c,t.task.id))}catch(e){q(e instanceof Error?e.message:String(e))}finally{W(!1)}}},[c,V,U,e,r,L]),he=(0,B.useMemo)(()=>(0,G.jsxs)(O,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>F(!0),children:[(0,G.jsx)(N,{className:`size-4`,"aria-hidden":!0}),n.newWork]}),[n.newWork]),ge=(0,B.useCallback)(async(e,t)=>{if(e.response){J(e.id),D(null);try{await le(e.response,t),await Y()}catch(e){D(e instanceof Error?e.message:String(e))}finally{J(null)}}},[Y]),Q=(0,B.useCallback)(async(e,t)=>{J(e.id),D(null);try{await t(),await Y()}catch(e){D(e instanceof Error?e.message:String(e))}finally{J(null)}},[Y]),$=(0,B.useCallback)(async(e,t)=>{fe(e.id),D(null);try{await t({kind:e.kind,runId:e.runId}),await Y()}catch(e){D(e instanceof Error?e.message:String(e))}finally{fe(null)}},[Y]);return(0,B.useLayoutEffect)(()=>(d({startExtra:null,main:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.home.subtitle})]}),end:he}),()=>f()),[f,he,d,t.title,t.home.subtitle]),(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,G.jsx)(S,{open:ee,onOpenChange:e=>{U||F(e),e&&(q(null),H(crypto.randomUUID()))},children:(0,G.jsxs)(b,{children:[(0,G.jsx)(y,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,G.jsxs)(m,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(C,{className:`text-base font-semibold text-fg`,children:n.dialogTitle}),(0,G.jsx)(P,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.dialogDescription})]}),(0,G.jsx)(te,{asChild:!0,children:(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:t.cancel,"aria-label":t.cancel,children:(0,G.jsx)(A,{className:`size-4`,"aria-hidden":!0})})})]}),(0,G.jsxs)(`form`,{onSubmit:me,className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,G.jsx)(`label`,{htmlFor:`new-work-task`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.intentLabel}),(0,G.jsx)(`textarea`,{id:`new-work-task`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:L,onChange:e=>{z(e.target.value),H(crypto.randomUUID())},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,G.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{children:t.home.submitShortcut}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[L.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),K?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:K}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,G.jsx)(te,{asChild:!0,children:(0,G.jsx)(O,{type:`button`,variant:`ghost`,disabled:U,children:t.cancel})}),(0,G.jsxs)(O,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!L.trim()||U,children:[(0,G.jsx)(I,{className:`size-4`,"aria-hidden":!0}),U?n.starting:n.submit]})]})]})]})]})}),w?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,G.jsx)(`span`,{children:w}),(0,G.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:t.home.retry})]}):null,g?(0,G.jsx)(Ee,{}):p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.home.briefingTitle}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:p.decisions.length+p.attention.length>0?xe(t.home.todaySummary,{attention:p.decisions.length+p.attention.length,moving:p.briefing.progress.movingCount+p.chats.running.length}):xe(t.home.todaySummaryClear,{moving:p.briefing.progress.movingCount+p.chats.running.length})}),p.briefing.summary?(0,G.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.briefing.summary}):null]}),p.tasks.running.length===0&&p.workflowRuns.active.length===0&&p.decisions.length===0&&p.attention.length===0&&p.chats.running.length===0&&p.chats.recent.length===0&&p.upcomingAutomations.length===0?(0,G.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,G.jsx)(v,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:t.home.emptyTitle}),(0,G.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:t.home.emptyBody}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(O,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:t.home.startChat}),(0,G.jsx)(O,{type:`button`,variant:`secondary`,onClick:()=>F(!0),children:n.newWork})]})]}):null,(0,G.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Z.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.runAttention}),(0,G.jsx)(Ce,{children:Z.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.map(e=>(0,G.jsx)(je,{item:e,href:ce(c,e.href),statusLabel:e.reason===`run_timeout`?t.home.attentionTimeout:t.home.attentionFailed,retryLabel:t.home.attentionRetry,viewLabel:t.home.attentionView,acknowledgeLabel:t.home.attentionAcknowledge,busy:de===e.id,onView:()=>r(ce(c,e.href)),onRetry:()=>void $(e,E),onAcknowledge:()=>void $(e,ne)},e.id))})]}):null,X.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.needsAttention}),(0,G.jsx)(Ce,{children:X.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,G.jsx)(ke,{item:e,labels:n,busy:ue===e.id,onDecide:t=>void Q(e,()=>k(e.judgment.inboxItemId,t)),onSnooze:()=>void Q(e,()=>se(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Q(e,()=>se(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Q(e,()=>j(e.judgment.inboxItemId,t))},e.id):(0,G.jsx)(Oe,{item:e,href:ce(c,e.href),kindLabel:t.home.decisionKinds[e.kind],reasonLabel:t.home.decisionReasons[e.reason],approveLabel:t.home.approve,denyLabel:t.home.deny,busy:ue===e.id,onRespond:t=>void ge(e,t)},e.id))})]}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),t.home.nothingNeedsYou]}),(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.running}),(0,G.jsx)(Ce,{children:p.tasks.running.length.toLocaleString()})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[p.tasks.running.map(e=>(0,G.jsx)(we,{task:e,statusLabel:n.taskStatuses.running,backgroundPath:c},e.id)),p.tasks.running.length===0?(0,G.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.emptyRunning}):null]})]}),p.chats.recent.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.recent})}),(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:p.chats.recent.slice(0,6).map(e=>(0,G.jsx)(De,{chat:e,statusLabel:n.openChat},e.key))})]}):null]}),(0,G.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":t.home.nowTitle,children:[(0,G.jsx)(`div`,{className:`px-1`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.home.nowTitle})}),p.upcomingAutomations.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ie,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.home.scheduled})]}),(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:p.upcomingAutomations.slice(0,3).map(e=>(0,G.jsxs)(o,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,G.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Se(e.nextRunAt,t.never)})]},e.id))})]}):null,p.recentTasks.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ae,{className:`size-4 text-success`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.recentTasks})]}),(0,G.jsx)(`div`,{className:`mt-3 space-y-2`,children:p.recentTasks.slice(0,3).map(e=>(0,G.jsx)(Te,{receipt:e,evidenceLabel:n.evidenceCount,remainingLabel:n.remainingCount},e.runId))})]}):null,(0,G.jsx)(pe,{}),p.briefing.wins.length>0?(0,G.jsxs)(o,{to:p.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,G.jsx)(`span`,{children:xe(t.home.completedSummary,{count:p.briefing.wins.length})}),(0,G.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[t.home.viewLatestResult,` →`]})]}):null]})]})]}):null]})}export{Me as HomePage};
@@ -1 +0,0 @@
1
- import{r as e,s as t}from"./locale-store-Bjvw7jtg.js";async function n(){let n=await t(e(`/api/image-generation/catalog`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid image provider catalog`);return n.payload.providers}async function r(){let n=await t(e(`/api/image-generation/custom-providers`));if(!Array.isArray(n.payload?.providers))throw Error(`Invalid custom image provider list`);return n.payload.providers}async function i(n,r){await t(e(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`PUT`,body:JSON.stringify(r)})}async function a(n){await t(e(`/api/image-generation/custom-providers/${encodeURIComponent(n)}`),{method:`DELETE`})}async function o(n,r){await t(e(`/api/image-generation/providers/${encodeURIComponent(n)}/credential`),{method:`PUT`,body:JSON.stringify({apiKey:r})})}async function s(n,r){let i=await t(e(`/api/image-generation/providers/${encodeURIComponent(n)}/test`),{method:`POST`,body:JSON.stringify({modelId:r})});if(!Array.isArray(i.payload?.images))throw Error(`Invalid image generation test response`);return{images:i.payload.images}}export{o as a,i,r as n,s as o,n as r,a 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{d as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{n as c,r as l}from"./locale-store-Bjvw7jtg.js";import{a as u,i as d}from"./vendor-swr-BIWyz7Rc.js";import{Al as f,Ao as p,Da as m,El as h,Fa as ee,Ic as g,Jl as _,La as v,Mo as y,No as b,Ns as x,Oo as S,Po as C,Ps as te,Qs as ne,Su as re,Tc as ie,Wl as w,_s as T,aa as ae,at as oe,bl as se,bs as ce,cc as le,cl as ue,da as de,jo as fe,ko as E,mc as pe,pc as me,qs as he,sc as ge,tu as _e,zc as D}from"./index-Cb9y6tVR.js";import{a as ve,c as ye,l as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./api-BM1hNzjw.js";var O=e(t(),1),Ee=`build-xopc-local-app`;function De(e){return(e.routing?.agentId??e.agentId??``).trim().toLowerCase()}function Oe(e){return e.find(e=>De(e)===`coder`)??null}function ke(e,t){let n=new URLSearchParams({skill:Ee}),r=t?.trim();return r&&n.set(`draft`,r),`/chat/${encodeURIComponent(e)}?${n.toString()}`}var k=new Set([`document`,`content`,`interaction`,`criteria`]),Ae=new Set([`passed`,`failed`,`skipped`]);function je(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.source!==`xopc-local-app-preview`||t.version!==1)return null;if(t.type===`ready`)return{type:`ready`,detail:{}};if(t.type===`criteria`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.scenarios)||e.scenarios.length>10)return null;let n=e.scenarios.map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!t.id.trim()||t.id.length>80||typeof t.name!=`string`||!t.name.trim()||t.name.length>120||t.status!==`passed`&&t.status!==`failed`||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,name:t.name,status:t.status,message:t.message.slice(0,500),failureKind:`scenario`}});if(n.some(e=>e===null))return null;let r=typeof e.scenarioCount==`number`&&Number.isInteger(e.scenarioCount)&&e.scenarioCount>=0&&e.scenarioCount<=10?e.scenarioCount:n.length;return{type:`criteria`,detail:{status:e.status,scenarioCount:r,scenarios:n}}}if(t.type===`acceptance`&&t.detail&&typeof t.detail==`object`){let e=t.detail;if(e.status!==`passed`&&e.status!==`failed`||!Array.isArray(e.checks))return null;let n=e.checks.slice(0,10).map(e=>{if(!e||typeof e!=`object`)return null;let t=e;return!k.has(t.id)||!Ae.has(t.status)||typeof t.message!=`string`||!t.message.trim()?null:{id:t.id,status:t.status,message:t.message.slice(0,500)}});if(!n.length||n.some(e=>e===null))return null;let r=typeof e.interactiveCount==`number`&&Number.isFinite(e.interactiveCount)&&e.interactiveCount>=0?Math.min(Math.floor(e.interactiveCount),1e4):0;return{type:`acceptance`,detail:{status:e.status,checks:n,interactiveCount:r}}}if(t.type!==`error`||!t.detail||typeof t.detail!=`object`)return null;let n=t.detail;return n.kind!==`script_error`&&n.kind!==`unhandled_rejection`||typeof n.message!=`string`||!n.message.trim()?null:{type:`error`,detail:{kind:n.kind,message:n.message.slice(0,500),filename:typeof n.filename==`string`?n.filename.slice(0,500):void 0,line:typeof n.line==`number`?n.line:void 0,column:typeof n.column==`number`?n.column:void 0}}}function Me(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function Ne(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}var Pe=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function Fe(e,t){let n=null,r=()=>{n?.close();let r=new MessageChannel;n=r.port1,n.onmessage=e=>t(e.data),n.start(),e.contentWindow?.postMessage(Pe,`*`,[r.port2])};return e.addEventListener(`load`,r),r(),()=>{e.removeEventListener(`load`,r),n?.close()}}var Ie=n(),A=r();function Le(e){let t=(0,Ie.c)(36),{scenarios:n,results:r,runningTarget:i,zh:a,onRunAll:o,onRunScenario:s,onAskCoder:c}=e;if(!n.length)return null;let l=a?`产品场景`:`Product scenarios`,u;t[0]===l?u=t[1]:(u=(0,A.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:l}),t[0]=l,t[1]=u);let d=a?`${n.length} 个关键用户路径`:`${n.length} critical user journey${n.length===1?``:`s`}`,f;t[2]===d?f=t[3]:(f=(0,A.jsx)(`p`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,A.jsxs)(`div`,{children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m=i!==null,h;t[7]===i?h=t[8]:(h=i===`all`?(0,A.jsx)(D,{className:`size-3 animate-spin`}):(0,A.jsx)(le,{className:`size-3`}),t[7]=i,t[8]=h);let ee=a?`全部重跑`:`Run all`,v;t[9]!==o||t[10]!==m||t[11]!==h||t[12]!==ee?(v=(0,A.jsxs)(T,{variant:`ghost`,className:`h-7 rounded-lg px-2 text-[11px]`,onClick:o,disabled:m,children:[h,ee]}),t[9]=o,t[10]=m,t[11]=h,t[12]=ee,t[13]=v):v=t[13];let y;t[14]!==p||t[15]!==v?(y=(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[p,v]}),t[14]=p,t[15]=v,t[16]=y):y=t[16];let b=a?`产品场景验收结果`:`Product scenario acceptance results`,x;if(t[17]!==c||t[18]!==s||t[19]!==r||t[20]!==i||t[21]!==n||t[22]!==a){let e;t[24]!==c||t[25]!==s||t[26]!==r||t[27]!==i||t[28]!==a?(e=e=>{let t=r[e.id],n=i===`all`||i===e.id?`running`:t?.status??`pending`;return(0,A.jsx)(`li`,{className:`py-2.5 first:pt-1`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:n===`running`?(0,A.jsx)(D,{className:`size-3.5 animate-spin text-accent`}):n===`passed`?(0,A.jsx)(_e,{className:`size-3.5 text-success`}):n===`failed`?(0,A.jsx)(_,{className:`size-3.5 text-danger`}):(0,A.jsx)(w,{className:`size-3.5 text-fg-subtle`})}),(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`truncate text-[11px] font-medium text-fg`,children:e.name}),(0,A.jsx)(`p`,{className:`mt-0.5 text-[10px] text-fg-subtle`,children:a?`${e.stepCount} 个步骤`:`${e.stepCount} step${e.stepCount===1?``:`s`}`})]}),(0,A.jsx)(T,{variant:`ghost`,className:`size-7 shrink-0 rounded-lg p-0`,onClick:()=>s(e.id),disabled:i!==null,"aria-label":a?`重跑${e.name}`:`Rerun ${e.name}`,title:a?`单独重跑`:`Rerun scenario`,children:(0,A.jsx)(le,{className:`size-3`})})]}),n===`running`?(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`正在隔离预览中执行…`:`Running in an isolated preview…`}):t?.status===`failed`?(0,A.jsxs)(`div`,{className:`mt-1.5`,children:[(0,A.jsx)(`p`,{className:`text-[11px] leading-4 text-danger`,children:t.message}),(0,A.jsxs)(T,{variant:`ghost`,className:`mt-1 h-7 rounded-lg px-2 text-[11px] text-danger hover:text-danger`,onClick:()=>c(e,t),children:[(0,A.jsx)(g,{className:`size-3`}),a?`让 Coder 修复`:`Ask Coder to fix`]})]}):t?.status===`passed`?(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`场景已通过`:`Scenario passed`}):(0,A.jsx)(`p`,{className:`mt-1 text-[11px] leading-4 text-fg-muted`,children:a?`等待运行`:`Waiting to run`})]})]})},e.id)},t[24]=c,t[25]=s,t[26]=r,t[27]=i,t[28]=a,t[29]=e):e=t[29],x=n.map(e),t[17]=c,t[18]=s,t[19]=r,t[20]=i,t[21]=n,t[22]=a,t[23]=x}else x=t[23];let S;t[30]!==b||t[31]!==x?(S=(0,A.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,"aria-label":b,children:x}),t[30]=b,t[31]=x,t[32]=S):S=t[32];let C;return t[33]!==y||t[34]!==S?(C=(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[y,S]}),t[33]=y,t[34]=S,t[35]=C):C=t[35],C}var Re=`allow-scripts allow-forms`;function ze(e,t){return oe(e,t)}function Be(e,t,n){return!!(t&&n&&e.sourceHash===t&&e.status===n.status&&e.interactiveCount===n.interactiveCount&&JSON.stringify(e.checks)===JSON.stringify(n.checks))}function j(){let{appId:e}=i(),t=e===`new`,n=c(e=>e.language)===`zh`,r=c(e=>e.language),_=a(),{mutate:w}=u(),oe=ee(e=>e.moveToFront),Ee=v(e=>e.setPageHeader),De=v(e=>e.clearPageHeader),{data:k,isLoading:Ae,error:Pe,mutate:Ie}=d(!t&&e?[`local-app`,e]:null,()=>xe(e)),{data:j,isLoading:Ve,mutate:He}=d(!t&&e?[`local-app-validation`,e]:null,()=>be(e)),[Ue,We]=(0,O.useState)(``),[Ge,Ke]=(0,O.useState)(``),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[qe,Je]=(0,O.useState)(!1),[Ye,Xe]=(0,O.useState)(!1),[I,Ze]=(0,O.useState)(0),[Qe,$e]=(0,O.useState)(``),[L,et]=(0,O.useState)(!1),[tt,nt]=(0,O.useState)(!1),[R,z]=(0,O.useState)(`booting`),[rt,it]=(0,O.useState)(null),[B,at]=(0,O.useState)(null),[V,ot]=(0,O.useState)({}),[H,st]=(0,O.useState)(`all`),[U,W]=(0,O.useState)(0),[ct,lt]=(0,O.useState)(0),[ut,dt]=(0,O.useState)(null),[G,ft]=(0,O.useState)(null),[pt,mt]=(0,O.useState)([]),[ht,gt]=(0,O.useState)(!1),_t=(0,O.useRef)(new Set),K=(0,O.useRef)(null),vt=(0,O.useRef)(null),yt=(0,O.useRef)(null),q=(0,O.useRef)(null),J=(0,O.useRef)(``),Y=j?.acceptanceScenarios??[],X=(0,O.useMemo)(()=>{if(!Y.length)return null;let e=Y.map(e=>V[e.id]).filter(e=>!!e);return e.length===Y.length?{status:e.some(e=>e.status===`failed`)?`failed`:`passed`,scenarioCount:Y.length,scenarios:e}:null},[Y,V]),Z=(0,O.useMemo)(()=>{if(!B)return null;if(!j?.acceptanceScenarioCount)return B;if(!X)return null;let e=X.scenarios.find(e=>e.status===`failed`),t={id:`criteria`,status:X.status,message:e?`${e.name}: ${e.message}`:`${X.scenarioCount} product scenario(s) passed`},n=[...B.checks,t];return{status:n.some(e=>e.status===`failed`)?`failed`:`passed`,checks:n,interactiveCount:B.interactiveCount}},[B,X,j?.acceptanceScenarioCount]),bt=(0,O.useCallback)(async(e,t)=>{let n=Oe(await de(e.projectId))??await ae(e.projectId,`coder`);_t.current.add(n.key),_(ke(n.key,t))},[_]),xt=(0,O.useCallback)(async(e=!0)=>{if(!k)return null;nt(!0);try{let t=await be(k.id);return await He(t,{revalidate:!1}),e&&(q.current=t.sourceHash??null,st(`all`),W(0),Ze(e=>e+1)),t}catch(e){return F(e instanceof Error?e.message:String(e)),null}finally{nt(!1)}},[k,He]);(0,O.useEffect)(()=>{if(!k)return;let e=!1;de(k.projectId).then(t=>{e||(_t.current=new Set(t.filter(e=>(e.routing?.agentId??e.agentId)?.toLowerCase()===`coder`).map(e=>e.key)))}).catch(()=>{});let t=e=>{let t=e.detail?.key;!t||!_t.current.has(t)||(K.current!==null&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>{K.current=null,xt(!0)},750))};return window.addEventListener(`session-transcript-updated`,t),()=>{e=!0,window.removeEventListener(`session-transcript-updated`,t),K.current!==null&&window.clearTimeout(K.current)}},[k,xt]),(0,O.useEffect)(()=>{mt(k?.acceptanceRuns??[])},[k?.acceptanceRuns]),(0,O.useEffect)(()=>{q.current=null},[k?.id]),(0,O.useEffect)(()=>{!j?.sourceHash||q.current||(q.current=j.sourceHash,st(`all`),W(0),Ze(e=>e+1))},[j?.sourceHash]),(0,O.useLayoutEffect)(()=>{if(!k)return;z(`booting`),it(null),at(null),ft(null),gt(!1),J.current=``;let e=window.setTimeout(()=>z(e=>e===`failed`?e:`timeout`),7e3),t=vt.current?Fe(vt.current,t=>{let n=je(t);if(n){if(n.type===`ready`){z(e=>e===`failed`?e:`healthy`);return}if(n.type===`acceptance`){window.clearTimeout(e),at(n.detail),ft(q.current);return}n.type!==`criteria`&&(window.clearTimeout(e),it(n.detail),z(`failed`))}}):()=>{};return()=>{window.clearTimeout(e),t()}},[k,I]),(0,O.useLayoutEffect)(()=>{if(!k||j?.status!==`healthy`||!Y.length){dt(null);return}let e=H===`all`?Y[U]:Y.find(e=>e.id===H),t=e?[e]:[];if(!t.length)return;dt(H),ot(e=>{if(H===`all`&&U===0)return{};let t={...e};return delete t[H],t});let r=!1,i=e=>{ot(n=>{let r={...n};for(let n of t)r[n.id]={id:n.id,name:n.name,status:`failed`,message:e,failureKind:`runner`};return r}),dt(null)},a=window.setTimeout(()=>i(r?n?`场景在 10 秒内未完成。`:`Scenario did not finish within 10 seconds.`:n?`验收执行器未能连接,请重新验收。`:`The acceptance runner did not connect. Run acceptance again.`),1e4),o=yt.current?Fe(yt.current,e=>{let t=je(e);t&&(t.type===`ready`?r=!0:t.type===`criteria`?(window.clearTimeout(a),ot(e=>{let n={...e};for(let e of t.detail.scenarios)(n[e.id]?.status!==`failed`||e.status===`failed`)&&(n[e.id]=e);return n}),H===`all`&&U+1<Y.length?(W(e=>e+1),lt(e=>e+1)):dt(null)):t.type===`error`&&(window.clearTimeout(a),i(Ne(t.detail))))}):()=>{};return()=>{window.clearTimeout(a),o()}},[Y,k,ct,H,U,I,j?.status,n]),(0,O.useEffect)(()=>{if(!k||!Z||!G||G!==j?.sourceHash)return;let e=`${k.id}:${G}:${JSON.stringify(Z)}`;J.current!==e&&(J.current=e,gt(!0),ve(k.id,G,Z).then(t=>{J.current===e&&mt(e=>[t,...e.filter(e=>e.id!==t.id)].toSorted((e,t)=>t.createdAt-e.createdAt).slice(0,20))}).catch(t=>{J.current===e&&(J.current=``,F(t instanceof Error?t.message:String(t)))}).finally(()=>{J.current===e&&gt(!1)}))},[Z,G,k,j?.sourceHash]);let Q=(0,O.useCallback)(async e=>{if(k){et(!0),F(null);try{await bt(k,e)}catch(e){F(e instanceof Error?e.message:String(e)),et(!1)}}},[k,bt]);(0,O.useLayoutEffect)(()=>(Ee({startExtra:(0,A.jsx)(o,{to:`/local-apps`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`返回本地应用`:`Back to local apps`,children:(0,A.jsx)(re,{className:`size-4`})}),main:(0,A.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.name||(n?`创建本地应用`:`Create local app`)}),end:k?(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(T,{asChild:!0,variant:`ghost`,className:`h-9`,children:(0,A.jsxs)(o,{to:`/projects/${encodeURIComponent(k.projectId)}`,children:[(0,A.jsx)(se,{className:`size-4`}),`Project`]})}),(0,A.jsxs)(T,{className:`h-9`,onClick:()=>void Q(),disabled:L,children:[L?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(g,{className:`size-4`}),n?`继续开发`:`Continue building`]})]}):null}),()=>De()),[k,L,De,Q,Ee,n]);async function St(e){e.preventDefault(),N(!0),F(null);try{let e=await Te({name:Ue,idea:Ge});await w(`local-apps-list`);let t=n?`请基于 APP_BRIEF.md 完成这个本地应用的首版。先检查现有草稿,再实现最小可用版本并运行校验;完成后告诉我可以如何预览。`:`Build the first usable version of this local app from APP_BRIEF.md. Inspect the existing draft, implement the smallest useful version, run validation, and tell me how to preview it.`;try{await bt(e,t)}catch{_(`/local-apps/${encodeURIComponent(e.id)}`,{replace:!0})}}catch(e){F(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function Ct(){if(k){N(!0),F(null);try{let e=await Ce(k.id);await Ie(e,{revalidate:!1}),await He(),await Promise.all([w(`local-apps-list`),w(`gateway-extensions-list`)]),oe(`ext:${e.extensionId}:app`),Je(!1)}catch(e){F(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function wt(e,t=!1){N(!0),F(null);try{let n=await e();return await Ie(n,{revalidate:!1}),await He(),await Promise.all([w(`local-apps-list`),w(`gateway-extensions-list`)]),t&&oe(`ext:${n.extensionId}:app`),!0}catch(e){return F(e instanceof Error?e.message:String(e)),!1}finally{N(!1)}}async function Tt(e){k&&await wt(()=>we(k.id,e),e)}async function Et(e){k&&await wt(()=>Se(k.id,e),!0)}async function Dt(){k&&await wt(()=>ye(k.id))&&Xe(!1)}function Ot(){let e=Array.from(new Set([...j?.issues.map(e=>e.message)??[],...rt?[Ne(rt)]:[],...Z?.checks.filter(e=>e.status===`failed`&&e.id!==`criteria`).map(e=>e.message)??[],...Object.values(V).filter(e=>e.status===`failed`).map(e=>`${e.name}: ${e.failureKind===`runner`?`[验收执行器] `:``}${e.message}`),...R===`timeout`?[n?`预览在 7 秒内未完成启动,可能存在白屏或阻塞。`:`The preview did not finish booting within 7 seconds and may be blank or blocked.`]:[]]));if(!e.length)return;let t=e.map(e=>`- ${e}`).join(`
2
- `);Q(n?`请修复当前本地应用草稿的校验问题,保持扩展 ID 和已安装版本不变。先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。\n\n${t}`:`Fix the current local-app draft validation issues without changing the extension id or installed release. Reproduce first and determine whether each issue comes from app behavior or the acceptance runner; do not weaken assertions to bypass it. Run the full validation afterward.\n\n${t}`)}function kt(){st(`all`),W(0),lt(e=>e+1)}function At(e){st(e),W(0),lt(e=>e+1)}function jt(e,t){let r=t.failureKind===`runner`?n?`验收执行器`:`acceptance runner`:n?`产品场景`:`product scenario`;Q(n?`请修复本地应用的${r}问题“${e.name}”。当前失败信息:${t.message}\n\n保持扩展 ID 和场景原意不变;先复现并判断问题来自应用行为还是验收执行器,不要通过弱化断言绕过问题。修复后运行完整校验。`:`Fix the local-app ${r} issue "${e.name}". Current failure: ${t.message}\n\nPreserve the extension id and scenario intent. Reproduce first and determine whether the issue comes from app behavior or the runner; do not weaken assertions to bypass it. Run the full validation afterward.`)}let Mt=pt.findIndex(e=>Be(e,G,Z)),$=Mt>=0?pt[Mt]:null,Nt=Mt>=0?pt[Mt+1]??null:pt[0]??null,Pt=Me(Z),Ft=Nt?Nt.checks.filter(e=>e.status===`failed`).map(e=>e.message):[],It=j?.status===`failed`||R===`failed`||R===`timeout`||Z?.status===`failed`||Object.values(V).some(e=>e.status===`failed`),Lt=Ft.filter(e=>!Pt.includes(e)).length;async function Rt(){let e=await xt(!1);if(e?.status===`healthy`&&e.sourceHash!==G){q.current=e.sourceHash??null,W(0),Ze(e=>e+1);return}e?.status===`healthy`&&R===`healthy`&&Z?.status===`passed`&&$&&$.sourceHash===e.sourceHash&&Je(!0)}return t?(0,A.jsx)(`div`,{className:`flex min-h-0 flex-1 bg-surface-panel p-3 sm:p-5 xl:p-6`,children:(0,A.jsxs)(`div`,{className:`mx-auto grid w-full max-w-6xl overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base shadow-surface lg:grid-cols-[minmax(280px,0.8fr)_minmax(0,1.5fr)]`,children:[(0,A.jsxs)(`form`,{onSubmit:St,className:`flex flex-col border-b border-edge-subtle p-5 lg:border-b-0 lg:border-r`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-accent`,children:[(0,A.jsx)(he,{className:`size-4`}),n?`告诉 Coder 你的想法`:`Tell Coder your idea`]}),(0,A.jsx)(`h2`,{className:`mt-4 text-xl font-semibold tracking-tight text-fg`,children:n?`你想创建什么?`:`What do you want to create?`}),(0,A.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`我们会建立一个 Coder Project,并把应用上下文和开发 Skill 带入对话。`:`We will create a Coder Project and carry the app context and development skill into chat.`}),(0,A.jsxs)(`label`,{className:`mt-6 text-xs font-medium text-fg-muted`,children:[n?`应用名称`:`App name`,(0,A.jsx)(`input`,{value:Ue,onChange:e=>We(e.target.value),required:!0,className:`mt-2 w-full rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:阅读清单`:`e.g. Reading list`})]}),(0,A.jsxs)(`label`,{className:`mt-4 text-xs font-medium text-fg-muted`,children:[n?`描述你的想法`:`Describe your idea`,(0,A.jsx)(`textarea`,{value:Ge,onChange:e=>Ke(e.target.value),required:!0,rows:7,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`我想要一个可以记录待读文章、标记进度并按主题筛选的小工具…`:`I want a small tool that tracks articles, reading progress, and topics…`})]}),P?(0,A.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:P}):null,(0,A.jsxs)(T,{type:`submit`,variant:`primary`,className:`mt-5 h-10`,disabled:M||!Ue.trim()||!Ge.trim(),children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(g,{className:`size-4`}),n?`进入 Coder 对话`:`Continue with Coder`]})]}),(0,A.jsx)(`div`,{className:`hidden min-h-[620px] place-items-center bg-surface-panel p-8 lg:grid`,children:(0,A.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,A.jsx)(`div`,{className:`mx-auto flex size-16 items-center justify-center rounded-2xl border border-edge bg-surface-base text-accent shadow-surface`,children:(0,A.jsx)(ie,{className:`size-7`})}),(0,A.jsx)(`h3`,{className:`mt-5 text-base font-semibold text-fg`,children:n?`创建后,这里就是实时预览`:`Your live preview appears here`}),(0,A.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n?`你可以先体验草稿,再决定是否把它添加到左侧导航。`:`Try the draft first, then decide whether to add it to the sidebar.`})]})})]})}):Ae?(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_260px]`,children:[(0,A.jsx)(m,{className:`rounded-xl`}),(0,A.jsx)(m,{className:`rounded-xl`}),(0,A.jsx)(m,{className:`rounded-xl`})]}):Pe||!k?(0,A.jsx)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,children:Pe instanceof Error?Pe.message:n?`找不到应用`:`App not found`}):(0,A.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-3 overflow-hidden bg-surface-panel p-3 lg:grid-cols-[280px_minmax(0,1fr)_300px]`,children:[(0,A.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.12em] text-accent`,children:[(0,A.jsx)(he,{className:`size-4`}),n?`创作对话`:`Build conversation`]}),(0,A.jsx)(`div`,{className:`mt-4 rounded-xl bg-surface-panel p-3 text-sm leading-6 text-fg`,children:k.idea}),(0,A.jsxs)(`div`,{className:`mt-4 rounded-xl bg-accent-soft p-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-accent-fg`,children:[(0,A.jsx)(_e,{className:`size-4`}),n?`草稿已准备好`:`Draft is ready`]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`继续迭代会进入对应 Project,由 Coder 读取应用上下文和专属 skill。`:`Continue in the Project where Coder has the app context and dedicated skill.`})]}),(0,A.jsxs)(`form`,{className:`mt-5`,onSubmit:e=>{e.preventDefault(),Q(Qe)},children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`local-app-change-request`,children:n?`下一步想改什么?`:`What should change next?`}),(0,A.jsx)(`textarea`,{id:`local-app-change-request`,value:Qe,onChange:e=>$e(e.target.value),rows:4,className:`mt-2 w-full resize-none rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm leading-6 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,placeholder:n?`例如:增加月视图,并支持按标签筛选`:`e.g. Add a monthly view and tag filters`}),(0,A.jsxs)(T,{type:`submit`,className:`mt-2 w-full`,disabled:L||!Qe.trim(),children:[L?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(g,{className:`size-4`}),n?`让 Coder 修改`:`Ask Coder to update`]})]}),(0,A.jsxs)(T,{variant:`ghost`,className:`mt-2 w-full`,onClick:()=>void Q(),disabled:L,children:[(0,A.jsx)(se,{className:`size-4`}),n?`打开已有开发对话`:`Open development chat`]})]}),(0,A.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between border-b border-edge-subtle px-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`size-2 rounded-full ${j?.status===`failed`||R===`failed`||R===`timeout`||Z?.status===`failed`?`bg-danger`:j?.status===`healthy`&&R===`healthy`&&Z?.status===`passed`&&$?.sourceHash===j.sourceHash&&!ht?`bg-success`:`bg-fg-subtle`}`}),R===`failed`||R===`timeout`?n?`预览运行异常`:`Preview runtime issue`:j?.status===`failed`||Z?.status===`failed`?n?`自动验收未通过`:`Acceptance needs attention`:R===`booting`||!Z?n?`自动验收中`:`Running acceptance`:ht||$?.sourceHash!==j?.sourceHash?n?`正在保存验收快照`:`Saving acceptance snapshot`:n?`草稿已通过验收`:`Draft accepted`]}),(0,A.jsxs)(T,{variant:`ghost`,className:`h-8 px-2`,onClick:()=>void xt(!0),disabled:tt,children:[tt?(0,A.jsx)(D,{className:`size-3.5 animate-spin`}):(0,A.jsx)(le,{className:`size-3.5`}),n?`重新验收`:`Run again`]})]}),(0,A.jsx)(`iframe`,{ref:vt,title:`${k.name} preview`,src:l(k.previewUrl),sandbox:Re,className:`min-h-0 w-full flex-1 bg-white`,onError:()=>{it({kind:`script_error`,message:`Preview document failed to load`}),z(`failed`)}},I),j?.status===`healthy`&&j.acceptanceScenarioCount>0?(0,A.jsx)(`iframe`,{ref:yt,title:`${k.name} acceptance runner`,src:`${l(k.previewUrl)}?xopcAcceptance=1&xopcScenario=${encodeURIComponent(H===`all`?Y[U]?.id??``:H)}`,sandbox:Re,"aria-hidden":`true`,tabIndex:-1,className:`pointer-events-none fixed left-[-200vw] top-0 h-[720px] w-[1024px] opacity-0`},`criteria-${I}-${ct}-${U}`):null]}),(0,A.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n?`发布状态`:`Release status`}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.installationState===`not_installed`?n?`尚未安装`:`Not installed`:k.enabled?n?`版本 ${k.activeVersion} 正在使用`:`Version ${k.activeVersion} is active`:n?`已禁用,版本仍保留`:`Disabled, release retained`})]}),(0,A.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full ${k.enabled?`bg-success`:`bg-fg-subtle`}`,"aria-hidden":!0})]}),(0,A.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 text-xs`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`当前草稿`:`Draft`}),(0,A.jsxs)(`dd`,{className:`mt-1 font-medium text-fg`,children:[`v`,k.draftVersion]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`已安装`:`Installed`}),(0,A.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:k.activeVersion?`v${k.activeVersion}`:`—`})]})]}),(0,A.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(h,{className:`size-4 text-accent`}),n?`草稿检查`:`Draft checks`]}),Ve||tt?(0,A.jsx)(D,{className:`size-3.5 animate-spin text-fg-muted`}):j?.status===`healthy`?(0,A.jsx)(_e,{className:`size-4 text-success`}):(0,A.jsx)(x,{className:`size-4 text-danger`})]}),j?(0,A.jsxs)(`div`,{className:`mt-2`,children:[(0,A.jsx)(`p`,{className:`text-xs leading-5 ${j.status===`healthy`?`text-fg-muted`:`text-danger`}`,children:j.status===`healthy`?j.hasDraftChanges?n?`${j.changedFileCount} 个文件有改动,可以安装新版本。`:`${j.changedFileCount} changed files are ready for a new release.`:n?`草稿与当前安装版本一致。`:`Draft matches the installed release.`:j.issues[0]?.message}),j.changedFiles.length?(0,A.jsx)(`ul`,{className:`mt-2 space-y-1`,children:j.changedFiles.slice(0,4).map(e=>(0,A.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,j.changedFileCount>4?(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-fg-subtle`,children:n?`还有 ${j.changedFileCount-4} 个文件`:`${j.changedFileCount-4} more files`}):null,(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,A.jsx)(`span`,{className:`size-2 rounded-full ${R===`healthy`?`bg-success`:R===`booting`?`bg-fg-subtle`:`bg-danger`}`}),n?`预览运行`:`Preview runtime`]}),(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 ${R===`failed`||R===`timeout`?`text-danger`:`text-fg-muted`}`,children:rt?Ne(rt):R===`healthy`?n?`已成功启动,未发现未捕获异常。`:`Started successfully with no uncaught errors.`:R===`timeout`?n?`7 秒内未完成启动,可能出现白屏或阻塞。`:`Did not finish booting within 7 seconds.`:n?`正在等待应用启动。`:`Waiting for the app to start.`})]}),(0,A.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,A.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg`,children:[(0,A.jsx)(`span`,{className:`size-2 rounded-full ${Z?.status===`passed`?`bg-success`:Z?.status===`failed`?`bg-danger`:`bg-fg-subtle`}`}),n?`自动验收`:`Automatic acceptance`]}),Z?(0,A.jsx)(`ul`,{className:`mt-2 space-y-1.5`,children:Z.checks.map(e=>(0,A.jsxs)(`li`,{className:`flex items-start gap-2 text-[11px] leading-4 ${e.status===`failed`?`text-danger`:`text-fg-muted`}`,children:[(0,A.jsx)(`span`,{className:`mt-1 size-1.5 shrink-0 rounded-full ${e.status===`failed`?`bg-danger`:e.status===`passed`?`bg-success`:`bg-fg-subtle`}`}),(0,A.jsx)(`span`,{children:e.message})]},e.id))}):(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:j?.acceptanceScenarioCount?n?`正在检查页面基础质量和 ${j.acceptanceScenarioCount} 个产品场景。`:`Checking page quality and ${j.acceptanceScenarioCount} product scenario(s).`:n?`正在检查页面内容和基础交互。`:`Checking rendered content and basic interaction.`}),ht?(0,A.jsxs)(`p`,{className:`mt-2 flex items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(D,{className:`size-3 animate-spin`}),n?`正在保存当前源码对应的验收快照…`:`Saving the acceptance snapshot for this source…`]}):$?(0,A.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-fg-muted`,children:Nt?n?`相比上次:已修复 ${Lt} 项,仍有 ${Pt.length} 项。`:`Since the previous run: ${Lt} fixed, ${Pt.length} remaining.`:n?`首个验收快照已保存。`:`First acceptance snapshot saved.`}):null,(0,A.jsx)(Le,{scenarios:Y,results:V,runningTarget:ut,zh:n,onRunAll:kt,onRunScenario:At,onAskCoder:jt})]}),It?(0,A.jsxs)(T,{className:`mt-3 w-full`,onClick:Ot,disabled:L,children:[(0,A.jsx)(g,{className:`size-4`}),n?`让 Coder 修复`:`Ask Coder to fix`]}):null]}):(0,A.jsx)(m,{className:`mt-2 h-12 rounded-lg`})]}),(0,A.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(ne,{className:`size-4 text-accent`}),n?`权限`:`Permissions`]}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(j?.permissions??k.permissions).map(e=>(0,A.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] text-fg-muted`,children:e},e))})]}),(0,A.jsx)(T,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void Rt(),disabled:M||Ve||tt||ht||j?.status===`failed`||R!==`healthy`||Z?.status!==`passed`||!$||$.sourceHash!==j?.sourceHash||k.installationState===`installed`&&j?.hasDraftChanges===!1,children:k.installationState===`installed`?n?`安装当前更新`:`Install current update`:n?`添加到左侧导航`:`Add to sidebar`}),k.installationState===`installed`?(0,A.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,A.jsxs)(T,{className:`min-w-0 flex-1`,onClick:()=>void Tt(!k.enabled),disabled:M,children:[k.enabled?(0,A.jsx)(pe,{className:`size-4`}):(0,A.jsx)(me,{className:`size-4`}),k.enabled?n?`禁用`:`Disable`:n?`启用`:`Enable`]}),(0,A.jsx)(T,{variant:`ghost`,className:`text-danger hover:text-danger`,onClick:()=>Xe(!0),disabled:M,"aria-label":n?`卸载应用`:`Uninstall app`,children:(0,A.jsx)(te,{className:`size-4`})})]}):null,(0,A.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4`,children:[(0,A.jsxs)(`h3`,{className:`flex items-center gap-2 text-xs font-semibold text-fg`,children:[(0,A.jsx)(ue,{className:`size-4`}),n?`版本历史`:`Release history`]}),k.releases.length?(0,A.jsx)(`ul`,{className:`mt-2 divide-y divide-edge-subtle`,children:k.releases.map(e=>(0,A.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2.5`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-fg`,children:[`v`,e.version,e.isActive?(0,A.jsx)(`span`,{className:`rounded-full bg-success-soft px-1.5 py-0.5 text-[10px] text-success`,children:n?`当前`:`Active`}):null]}),(0,A.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-fg-subtle`,children:ze(e.createdAt,r)})]}),e.isActive?null:(0,A.jsxs)(T,{variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>void Et(e.id),disabled:M,children:[(0,A.jsx)(ge,{className:`size-3.5`}),n?`恢复`:`Restore`]})]},e.id))}):(0,A.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n?`安装首个版本后,可以从这里恢复。`:`Install the first version to enable recovery.`})]}),P?(0,A.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-danger`,role:`alert`,children:P}):null]}),(0,A.jsx)(S,{open:qe,onOpenChange:Je,children:(0,A.jsxs)(b,{children:[(0,A.jsx)(y,{className:`fixed inset-0 z-50 bg-black/45`}),(0,A.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(560px,calc(100vh-32px))] w-[min(520px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(C,{className:`text-base font-semibold text-fg`,children:n?`确认安装到 XOPC`:`Confirm installation`}),(0,A.jsx)(fe,{className:`mt-1 text-sm text-fg-muted`,children:n?`当前草稿会成为左侧导航中的可用版本。`:`The current draft will become the version available in the sidebar.`})]}),(0,A.jsx)(E,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,A.jsx)(ce,{className:`size-4`})})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:k.name}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:k.extensionId})]}),(0,A.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`本次迭代`:`This iteration`}),(0,A.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-3 text-xs`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`文件变化`:`Changed files`}),(0,A.jsx)(`dd`,{className:`mt-1 font-medium text-fg`,children:j?.changedFileCount??0})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`dt`,{className:`text-fg-subtle`,children:n?`自动验收`:`Acceptance`}),(0,A.jsxs)(`dd`,{className:`mt-1 flex items-center gap-1.5 font-medium text-success`,children:[(0,A.jsx)(_e,{className:`size-3.5`}),n?`已通过并保存`:`Passed and saved`]})]})]}),j?.changedFiles.length?(0,A.jsx)(`ul`,{className:`mt-3 space-y-1`,children:j.changedFiles.slice(0,5).map(e=>(0,A.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2 text-[11px] text-fg-muted`,children:[(0,A.jsx)(`span`,{className:`w-4 shrink-0 font-medium text-fg-subtle`,children:e.status===`added`?`+`:e.status===`deleted`?`−`:`•`}),(0,A.jsx)(`span`,{className:`truncate font-mono`,children:e.path})]},e.path))}):null,(0,A.jsx)(`h4`,{className:`mt-5 text-xs font-semibold text-fg`,children:n?`请求权限`:`Requested permissions`}),(0,A.jsx)(`ul`,{className:`mt-2 space-y-2`,children:(j?.permissions??k.permissions).map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,A.jsx)(s,{className:`size-4 text-success`}),e,k.installationState===`installed`&&j?.permissionDelta.added.includes(e)?(0,A.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-[10px] text-warning`,children:n?`新增`:`New`}):null]},e))}),k.installationState===`installed`&&j?.permissionDelta.added.length?(0,A.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft p-3 text-xs leading-5 text-warning`,children:n?`此更新增加了权限,请确认这些能力符合你的修改意图。`:`This update adds permissions. Confirm they match the change you requested.`}):null,(0,A.jsx)(`p`,{className:`mt-5 rounded-xl bg-accent-soft p-3 text-xs leading-5 text-accent-fg`,children:n?`Phase 1 应用只能使用界面主题和本地存储,不能访问网络或运行系统命令。`:`Phase 1 apps can use theme and local storage only. They cannot access the network or run system commands.`})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,A.jsx)(E,{asChild:!0,children:(0,A.jsx)(T,{children:n?`取消`:`Cancel`})}),(0,A.jsxs)(T,{variant:`primary`,onClick:()=>void Ct(),disabled:M,children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(f,{className:`size-4`}),n?`确认安装`:`Install`]})]})]})]})}),(0,A.jsx)(S,{open:Ye,onOpenChange:Xe,children:(0,A.jsxs)(b,{children:[(0,A.jsx)(y,{className:`fixed inset-0 z-50 bg-black/45`}),(0,A.jsxs)(p,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(420px,calc(100vh-32px))] w-[min(500px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-base shadow-2xl focus:outline-none`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between border-b border-edge-subtle p-5`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(C,{className:`text-base font-semibold text-fg`,children:n?`卸载当前应用?`:`Uninstall this app?`}),(0,A.jsx)(fe,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:n?`应用会从侧栏移除,但 Project、源码、版本历史和本地数据都会保留。`:`The app leaves the sidebar, while its Project, source, release history, and local data remain.`})]}),(0,A.jsx)(E,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,children:(0,A.jsx)(ce,{className:`size-4`})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,A.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-4`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.name}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n?`之后可从任意保留版本重新安装。`:`You can reinstall any retained release later.`})]})}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle p-4`,children:[(0,A.jsx)(E,{asChild:!0,children:(0,A.jsx)(T,{children:n?`取消`:`Cancel`})}),(0,A.jsxs)(T,{variant:`ghost`,className:`text-danger hover:bg-danger-soft hover:text-danger`,onClick:()=>void Dt(),disabled:M,children:[M?(0,A.jsx)(D,{className:`size-4 animate-spin`}):(0,A.jsx)(te,{className:`size-4`}),n?`卸载但保留 Project`:`Uninstall and keep Project`]})]})]})]})})]})}export{j as LocalAppWorkbenchPage};