@xopcai/xopc 0.0.315 → 0.0.316

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 (186) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BbFOF2SH.js → agent-avatar-dicebear-XIyH14Sn.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-D9T-QGmd.js → agent-defaults-settings-panel-DJl_o7Xf.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-Ds5sQcPd.js → agents-CGFhxPFv.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-BzloAiIG.js → api-Dy056n2_.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-BpUHskXq.js → app-management-settings-panel-Dp7Fcj2Z.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CQd5Vo6f.js → appearance-settings-CSUffLjx.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-B7VIsfye.js → apps-page-DtIcKfJG.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-BM4O6WfL.js → archive-plugin-D3SdndlF.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Cdn9MYmI.js → attachment-load-BgxXYRkd.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-DnRx-Ra4.js → automations-page-krhofMgL.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-workspace-B5s10G5F.js → automations-workspace-EbpneB06.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-dkhUf4bm.js → binary-plugins-w6lazTqo.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-BTzqEuAy.js → block-editor-CxHqPODE.js} +3 -3
  16. package/dist/gateway/static/root/assets/{browser-automation-inputs-Bowij-nJ.js → browser-automation-inputs-hNdEgfGG.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-automations-page-CQ7SYTQj.js → browser-automations-page-BYsGJ_xs.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-settings-page-vqLoPOOg.js → browser-settings-page-CP_c5q0V.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DI68WGYd.js → capabilities-settings-panel-ljW3s3vv.js} +1 -1
  20. package/dist/gateway/static/root/assets/{channels-settings-Cimssy-S.js → channels-settings-CR9SRgFp.js} +1 -1
  21. package/dist/gateway/static/root/assets/{chat-terminal-dock-DzgFHd6l.js → chat-terminal-dock-medSiQoQ.js} +1 -1
  22. package/dist/gateway/static/root/assets/{computer-settings-page-380_vIqO.js → computer-settings-page-DJxO0CfY.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connector-service-page-DILFakXb.js → connector-service-page-WaoUqr8a.js} +1 -1
  24. package/dist/gateway/static/root/assets/{connectors-page-COmFp9HC.js → connectors-page-KIi15pQl.js} +1 -1
  25. package/dist/gateway/static/root/assets/{date-picker-CRVun-T5.js → date-picker-DalDr0E6.js} +1 -1
  26. package/dist/gateway/static/root/assets/{dependency-picker-BoWqt5yU.js → dependency-picker-ONChq2Yr.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-DPlkBjft.js → desktop-pet-b1a37SVn.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-D7FgfX_K.js → desktop-pet-settings-CwqZxGv4.js} +1 -1
  29. package/dist/gateway/static/root/assets/{device-pairing-wizard-BP6yxut8.js → device-pairing-wizard-C_MNpS30.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-debug-page-CT_QkSN_.js → extension-debug-page-CGthPGca.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-BF1NdcKP.js → extension-page-CExNJs0G.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-settings-page-CKQVZ3Xc.js → extension-settings-page-DBfxzKR8.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-swr-BPsZPoAT.js → gateway-config-swr-DFjsI4QK.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-3bIy7XMr.js → gateway-settings-BlpheZrf.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-cG6EqUJw.js → gateway-startup-retry-oRRqSoe9.js} +1 -1
  36. package/dist/gateway/static/root/assets/{home-page-DFNDLFgv.js → home-page-BvdT-uaI.js} +1 -1
  37. package/dist/gateway/static/root/assets/{image-generation-api-DI_QutIx.js → image-generation-api-CyDy_Sxu.js} +1 -1
  38. package/dist/gateway/static/root/assets/{imports-page-BUG6G72F.js → imports-page-Dnp2hmFL.js} +1 -1
  39. package/dist/gateway/static/root/assets/index-BYKatjhB.css +1 -0
  40. package/dist/gateway/static/root/assets/{index-BCi8nfxs.js → index-DhCnwCI9.js} +38 -38
  41. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-qnG-4FJs.js → keyboard-shortcuts-settings-1DUcGrYh.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-app-workbench-page-B3iJWhjN.js → local-app-workbench-page-BW2-80Og.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-apps-page-BpEGeURS.js → local-apps-page-C7_2zyV_.js} +1 -1
  44. package/dist/gateway/static/root/assets/{locale-store-BlgpZORR.js → locale-store-D6VmRI5e.js} +1 -1
  45. package/dist/gateway/static/root/assets/{logs-page-0QPGj-5c.js → logs-page-Cbr7bPM6.js} +1 -1
  46. package/dist/gateway/static/root/assets/{management-settings-Sl0wwidS.js → management-settings-G7GcFx2_.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-view-BzjjpL2H.js → markdown-view-B5MfZeKH.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-Bzkdhotn.js → media-plugins-IbcEpV96.js} +1 -1
  49. package/dist/gateway/static/root/assets/messages-BCqLsIZK.js +3 -0
  50. package/dist/gateway/static/root/assets/{note-detail-panel-BXtD71j1.js → note-detail-panel-C4DiKkDf.js} +3 -3
  51. package/dist/gateway/static/root/assets/{notes-page-DNY4vW-u.js → notes-page-DgHQmpVq.js} +1 -1
  52. package/dist/gateway/static/root/assets/{page-context-capture-button-CFt4hXQ6.js → page-context-capture-button-B5rZ_F0R.js} +1 -1
  53. package/dist/gateway/static/root/assets/{page-tabs-Dz_x22MQ.js → page-tabs-B84Yghg5.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-C1mkgFAl.js → preview-open-alternatives-CaEtDmZO.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DHZgzSDV.js → product-open-page-BK9z5b-v.js} +1 -1
  56. package/dist/gateway/static/root/assets/{project-detail-page-D3NhZ7ZZ.js → project-detail-page-Qj8Xb9qS.js} +1 -1
  57. package/dist/gateway/static/root/assets/{projects-page-CEr8DX9I.js → projects-page-BOp6swwM.js} +1 -1
  58. package/dist/gateway/static/root/assets/{registry-api-DMW2apOO.js → registry-api-sOL6E5LU.js} +1 -1
  59. package/dist/gateway/static/root/assets/{remote-access-hub-Db-B-Mf3.js → remote-access-hub-yb8l4ppq.js} +1 -1
  60. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DEJi0BLL.js → runtime-tools-settings-panel-BAvzw1T0.js} +1 -1
  61. package/dist/gateway/static/root/assets/{scenes-page-BUUX-PnI.js → scenes-page-CiAgb7hf.js} +1 -1
  62. package/dist/gateway/static/root/assets/{schema-form-RVltVpuG.js → schema-form-Dytkw9RZ.js} +1 -1
  63. package/dist/gateway/static/root/assets/{sessions-page-Rm4H2okS.js → sessions-page-43hcOW84.js} +1 -1
  64. package/dist/gateway/static/root/assets/settings-advanced-gate-C414vr2V.js +1 -0
  65. package/dist/gateway/static/root/assets/{settings-form-section-BkBO7woF.js → settings-form-section-DBJlmKQV.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-zl0XY203.js → settings-page-C9GbP-ZG.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-layout-lLvHc-zF.js → settings-page-layout-OvBOGen7.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-Difrpr4T.js → setup-status-panel-BCMym4xj.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-NC4Gj867.js → share-preview-page-D-sx26yN.js} +1 -1
  70. package/dist/gateway/static/root/assets/{shares-settings-DPLvEcB-.js → shares-settings-EdNGhsuF.js} +1 -1
  71. package/dist/gateway/static/root/assets/skill-reload-api-DYYM1qVn.js +1 -0
  72. package/dist/gateway/static/root/assets/{skills-page-CzekvBNQ.js → skills-page-Cgrfnet5.js} +1 -1
  73. package/dist/gateway/static/root/assets/{skills-page.utils-BLeiN245.js → skills-page.utils-COPGVfmB.js} +1 -1
  74. package/dist/gateway/static/root/assets/{system-settings-panel-Bp75s9nl.js → system-settings-panel-B9tptggE.js} +1 -1
  75. package/dist/gateway/static/root/assets/{task-detail-page-Bh8H4FYR.js → task-detail-page-BrsM6Xmm.js} +1 -1
  76. package/dist/gateway/static/root/assets/{tunnel-api-BDiaC6an.js → tunnel-api-qb33IFGP.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-autosave-C_ntK_Zu.js → use-autosave-DfhqCGRX.js} +1 -1
  78. package/dist/gateway/static/root/assets/{user-model-page-C7gFCGAV.js → user-model-page-Sg94U7zz.js} +1 -1
  79. package/dist/gateway/static/root/assets/{voice-api-key-field-D4cfuMp1.js → voice-api-key-field-taBVzvtI.js} +1 -1
  80. package/dist/gateway/static/root/assets/{voice-config-api-Cjvd6maH.js → voice-config-api-B4yjd1Kb.js} +1 -1
  81. package/dist/gateway/static/root/assets/{work-discovery-overlay-Ce6ToB0O.js → work-discovery-overlay-DWGTB3Uk.js} +1 -1
  82. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C80nrmKi.js → workflow-run-setup-panel-CP58uTNh.js} +1 -1
  83. package/dist/gateway/static/root/assets/{workflows-page-CVQjo3RI.js → workflows-page-Clka1xiQ.js} +1 -1
  84. package/dist/gateway/static/root/index.html +8 -8
  85. package/dist/package.js +1 -1
  86. package/dist/src/agent/agent-manager.js +18 -17
  87. package/dist/src/agent/background-review/run-background-review.js +1 -1
  88. package/dist/src/agent/embedded/model-runtime.js +1 -1
  89. package/dist/src/agent/embedded/run-for-session.js +1 -1
  90. package/dist/src/agent/embedded/run-turn.js +28 -15
  91. package/dist/src/agent/embedded/system-prompt-override.js +14 -3
  92. package/dist/src/agent/embedded/xopc-stream-bridge.js +13 -2
  93. package/dist/src/agent/image/tool-model-config.js +1 -1
  94. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  95. package/dist/src/agent/memory/context-budget.js +1 -1
  96. package/dist/src/agent/orchestration/agent-turn-policy.d.ts +2 -2
  97. package/dist/src/agent/prompt/agent-system-prompt.d.ts +3 -0
  98. package/dist/src/agent/prompt/agent-system-prompt.js +16 -0
  99. package/dist/src/agent/service.js +2 -2
  100. package/dist/src/agent/session/session-inspector.js +1 -1
  101. package/dist/src/agent/skills/hub-lock.js +1 -1
  102. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  103. package/dist/src/agent/tools/knowledge-memory-tool.js +1 -0
  104. package/dist/src/agent-config/schema.d.ts +8 -8
  105. package/dist/src/ai-assist/text-assist.js +3 -2
  106. package/dist/src/auth/credentials.js +2 -2
  107. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  108. package/dist/src/auth/profiles/store.js +1 -1
  109. package/dist/src/auth/sync-provider-auth.js +2 -2
  110. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  111. package/dist/src/chat-commands/agent-edit.js +1 -1
  112. package/dist/src/cli/commands/agent.js +1 -1
  113. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  114. package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
  115. package/dist/src/cli/commands/models.js +1 -1
  116. package/dist/src/computer/runtime.js +1 -1
  117. package/dist/src/config/index.js +4 -4
  118. package/dist/src/config/loader.js +2 -2
  119. package/dist/src/config/models-json.js +2 -2
  120. package/dist/src/config/schema.d.ts +5 -5
  121. package/dist/src/config/schema.js +1 -1
  122. package/dist/src/connectors/connected-source-ingestion.d.ts +1 -0
  123. package/dist/src/connectors/connected-source-ingestion.js +1 -0
  124. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  125. package/dist/src/connectors/connected-source-understanding.js +91 -31
  126. package/dist/src/connectors/content-enrichment.d.ts +1 -0
  127. package/dist/src/connectors/content-enrichment.js +3 -1
  128. package/dist/src/connectors/learning-coordinator.js +24 -24
  129. package/dist/src/extensions/lockfile.js +1 -1
  130. package/dist/src/gateway/agents-admin.js +1 -1
  131. package/dist/src/gateway/chat-stream/mapper.js +9 -4
  132. package/dist/src/gateway/chat-stream/protocol.d.ts +2 -1
  133. package/dist/src/gateway/file-path-classifier.js +1 -1
  134. package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -2
  135. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  136. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  137. package/dist/src/gateway/hono/routes/models.js +1 -1
  138. package/dist/src/gateway/hono/routes/user-model-refresh.js +2 -2
  139. package/dist/src/gateway/hono/routes/voice.js +1 -1
  140. package/dist/src/gateway/service/config-coordinator.js +1 -1
  141. package/dist/src/gateway/service.js +5 -5
  142. package/dist/src/knowledge/ingestion-service.d.ts +5 -2
  143. package/dist/src/knowledge/ingestion-service.js +24 -15
  144. package/dist/src/knowledge-memory/domain.d.ts +1 -1
  145. package/dist/src/notes/service.js +1 -1
  146. package/dist/src/platform/client.d.ts +1 -1
  147. package/dist/src/platform/contracts.d.ts +1 -1
  148. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  149. package/dist/src/providers/extension-stream-bridge.js +6 -4
  150. package/dist/src/providers/index.js +2 -2
  151. package/dist/src/providers/model-call.js +3 -3
  152. package/dist/src/providers/model-catalog-persistence.js +1 -1
  153. package/dist/src/providers/model-registry.js +1 -1
  154. package/dist/src/providers/presentation.js +4 -3
  155. package/dist/src/providers/register-runtime-providers.js +1 -1
  156. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +1 -2
  157. package/dist/src/storage/sqlite/context-extraction-repository.js +1 -9
  158. package/dist/src/storage/sqlite/index.d.ts +1 -2
  159. package/dist/src/storage/sqlite/index.js +2 -3
  160. package/dist/src/storage/sqlite/knowledge-repository.d.ts +1 -0
  161. package/dist/src/storage/sqlite/knowledge-repository.js +3 -0
  162. package/dist/src/storage/sqlite/migrations/200_connected_work_threads.sql +92 -0
  163. package/dist/src/storage/sqlite/migrations/201_connector_extraction_audit.sql +127 -0
  164. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  165. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  166. package/dist/src/storage/sqlite/schema.js +1 -1
  167. package/dist/src/storage/sqlite/schema.sql +1 -1
  168. package/dist/src/tui/backends/embedded-backend.js +1 -1
  169. package/dist/src/tui/tui-commands.js +1 -1
  170. package/dist/src/tui/tui-startup-resources.js +1 -1
  171. package/dist/src/tui/tui.js +2 -2
  172. package/dist/src/user-context/domain.d.ts +0 -13
  173. package/dist/src/user-context/sources/index.js +2 -2
  174. package/dist/src/user-context/sources/repository.d.ts +10 -0
  175. package/dist/src/user-context/sources/repository.js +19 -4
  176. package/dist/src/user-context/sources/types.d.ts +1 -0
  177. package/dist/src/voice/tts/audio.js +1 -1
  178. package/dist/src/work-discovery/service.js +2 -2
  179. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  180. package/package.json +7 -7
  181. package/dist/gateway/static/root/assets/index-DWgd1VK2.css +0 -1
  182. package/dist/gateway/static/root/assets/messages-2GhUD7SC.js +0 -3
  183. package/dist/gateway/static/root/assets/settings-advanced-gate-VxPItcOG.js +0 -1
  184. package/dist/gateway/static/root/assets/skill-reload-api-CKdLCf_-.js +0 -1
  185. package/dist/src/storage/sqlite/context-relation-repository.d.ts +0 -50
  186. package/dist/src/storage/sqlite/context-relation-repository.js +0 -98
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-B-GDnZO9.js";import{a as r,r as i}from"./locale-store-BlgpZORR.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-B-GDnZO9.js";import{a as r,r as i}from"./locale-store-D6VmRI5e.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as i}from"./locale-store-BlgpZORR.js";import{t as a}from"./button-CS04eWY9.js";import{t as o}from"./skeleton-BwbyijEw.js";import{Au as s,Cc as c,Co as l,Lu as u,Qu as d,Ru as f,Zc as p,bu as m,pc as h,tl as g}from"./index-BCi8nfxs.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-Bowij-nJ.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as i}from"./locale-store-D6VmRI5e.js";import{t as a}from"./button-CS04eWY9.js";import{t as o}from"./skeleton-BwbyijEw.js";import{Au as s,Cc as c,Co as l,Lu as u,Qu as d,Ru as f,Zc as p,bu as m,pc as h,tl as g}from"./index-DhCnwCI9.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-hNdEgfGG.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
2
2
  `):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
3
3
  `):String(e)}function E(){let e=i(e=>e.language),t=C[e],n=r(),E=l(e=>e.setPageHeader),D=l(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(a,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(d,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:G}),()=>D()),[D,G,E,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(o,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(o,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,S.jsx)(d,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(a,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(d,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(u,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(f,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(m,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(a,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(f,{className:`size-4`}):(0,S.jsx)(u,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(a,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(g,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(a,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(p,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(a,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(c,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-inset p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(s,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(a,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(h,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserAutomationsPage};
@@ -1,3 +1,3 @@
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,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{a as l,c as u,n as d,r as f}from"./locale-store-BlgpZORR.js";import{t as p}from"./messages-2GhUD7SC.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-CS04eWY9.js";import{n as g,r as _}from"./gateway-config-swr-BPsZPoAT.js";import{t as v}from"./skeleton-BwbyijEw.js";import{$r as y,Qc as b,Qr as x,Su as S,Tl as C,Uc as w,_u as T,dl as E,ei as D,fc as ee,gu as O,la as k,ni as A,ou as te,ri as j,ru as ne,ti as re,ua as M,wl as N}from"./index-BCi8nfxs.js";import{n as ie,r as P}from"./settings-page-layout-lLvHc-zF.js";import{n as ae}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as F,t as I}from"./use-autosave-C_ntK_Zu.js";import{t as oe}from"./settings-advanced-gate-VxPItcOG.js";var L=n(),R=e(t(),1);function se(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(null),l=(0,R.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,R.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await re(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,R.useCallback)(async()=>{l.current&&(i(!0),await x().catch(()=>{}),l.current.abort())},[])}}var z=r(),B={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function V(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),c=m(t?[`browser-control-status`,n]:null,y,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,g]=(0,R.useState)(null),_=r===`dirty`||r===`saving`;(0,R.useEffect)(()=>{r===`saved`&&c.mutate()},[r,c.mutate]);let x=(0,R.useCallback)(async(e,t,n)=>{u(e),f(null),g(null);try{await t(),g(n),await c.mutate()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(null)}},[c.mutate]),S=se((0,R.useCallback)(()=>{g(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),c.mutate()},[c.mutate,a])),T=c.data?.payload,E=T?.driverKind===n,D=t?_||!E?`syncing`:T?.state:`disabled`;return(0,z.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(D===`ready`?s:D===`syncing`?C:ee,{className:`size-4 shrink-0 ${D===`ready`?`text-success`:D===`syncing`?`animate-spin text-fg-muted`:D===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${D===`ready`?`bg-success-soft text-success`:D===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:D===`ready`?a?`已就绪`:`Ready`:D===`disabled`?a?`未启用`:`Disabled`:D===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[B[n],T?.detail&&E?` · ${T.detail}`:``]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(h,{variant:`ghost`,className:`h-9`,onClick:()=>void c.mutate(),disabled:c.isValidating,children:[(0,z.jsx)(w,{className:`size-3.5 ${c.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,z.jsxs)(h,{variant:`secondary`,className:`h-9`,disabled:!t||_||l!==null||S.running,onClick:()=>void x(`test`,j,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(b,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&c.isLoading?(0,z.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,z.jsx)(v,{className:`h-12`}),(0,z.jsx)(v,{className:`h-12`}),(0,z.jsx)(v,{className:`h-12`})]}):null,t&&c.error?(0,z.jsx)(W,{tone:`error`,children:c.error instanceof Error?c.error.message:String(c.error)}):null,d||S.error?(0,z.jsx)(W,{tone:`error`,children:d??S.error}):null,p?(0,z.jsx)(W,{tone:`success`,children:p}):null,t&&n===`extension`&&E?(0,z.jsx)(ce,{status:T?.driverStatus,zh:a,busy:l,run:x,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&E?(0,z.jsx)(H,{status:T?.driverStatus,zh:a,installer:S}):null,t&&n===`cdp`?(0,z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function ce(e){let t=(0,L.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,l=r?`扩展文件`:`Extension files`,u=s?.installed===!0,d=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,f;t[0]!==l||t[1]!==u||t[2]!==d?(f=(0,z.jsx)(U,{label:l,ok:u,value:d}),t[0]=l,t[1]=u,t[2]=d,t[3]=f):f=t[3];let p=r?`本机自动发现`:`Local auto-discovery`,m=s?.nativeHost?.installed===!0,g=s?.nativeHost?.installed?r?`已就绪`:`Ready`:s?.nativeHost?.reason??(r?`需要修复`:`Repair required`),_;t[4]!==p||t[5]!==m||t[6]!==g?(_=(0,z.jsx)(U,{label:p,ok:m,value:g}),t[4]=p,t[5]=m,t[6]=g,t[7]=_):_=t[7];let v=r?`安全通道`:`Secure channel`,y=n?.transport===`gateway-realtime`,x=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,S;t[8]!==x||t[9]!==v||t[10]!==y?(S=(0,z.jsx)(U,{label:v,ok:y,value:x}),t[8]=x,t[9]=v,t[10]=y,t[11]=S):S=t[11];let w=r?`Chrome 连接`:`Chrome connection`,E=n?.connected===!0,ee=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,O;t[12]!==w||t[13]!==E||t[14]!==ee?(O=(0,z.jsx)(U,{label:w,ok:E,value:ee}),t[12]=w,t[13]=E,t[14]=ee,t[15]=O):O=t[15];let k;t[16]!==S||t[17]!==O||t[18]!==f||t[19]!==_?(k=(0,z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[f,_,S,O]}),t[16]=S,t[17]=O,t[18]=f,t[19]=_,t[20]=k):k=t[20];let A=s?.extensionDir??`Gateway Realtime`,j;t[21]===A?j=t[22]:(j=(0,z.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:A}),t[21]=A,t[22]=j);let ne=s?.installed?`secondary`:`primary`,re=i!==null,M;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(M=()=>void a(`extension-install`,()=>D(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=M):M=t[26];let N;t[27]===i?N=t[28]:(N=i===`extension-install`?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(c,{className:`size-3.5`}),t[27]=i,t[28]=N);let ie=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,P;t[29]!==ne||t[30]!==re||t[31]!==M||t[32]!==N||t[33]!==ie?(P=(0,z.jsxs)(h,{className:`h-9`,variant:ne,disabled:re,onClick:M,children:[N,ie]}),t[29]=ne,t[30]=re,t[31]=M,t[32]=N,t[33]=ie,t[34]=P):P=t[34];let ae=!s?.installed||i!==null,F;t[35]!==a||t[36]!==r?(F=()=>void a(`extension-open`,ue,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,z.jsx)(T,{className:`size-3.5`}),t[38]=I):I=t[38];let oe=r?`打开扩展页`:`Open extensions`,R;t[39]!==ae||t[40]!==F||t[41]!==oe?(R=(0,z.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:ae,onClick:F,children:[I,oe]}),t[39]=ae,t[40]=F,t[41]=oe,t[42]=R):R=t[42];let se=!s?.installed||i!==null,B;t[43]!==a||t[44]!==r?(B=()=>void a(`extension-folder`,le,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=B):B=t[45];let V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,z.jsx)(te,{className:`size-3.5`}),t[46]=V):V=t[46];let ce=r?`打开扩展目录`:`Open folder`,H;t[47]!==se||t[48]!==B||t[49]!==ce?(H=(0,z.jsxs)(h,{className:`h-9`,variant:`ghost`,disabled:se,onClick:B,children:[V,ce]}),t[47]=se,t[48]=B,t[49]=ce,t[50]=H):H=t[50];let W=i!==null,G;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,z.jsx)(b,{className:`size-3.5`}),t[51]=G):G=t[51];let de=r?`连接远程 Chrome`:`Connect remote Chrome`,K;t[52]!==o||t[53]!==W||t[54]!==de?(K=(0,z.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:W,onClick:o,children:[G,de]}),t[52]=o,t[53]=W,t[54]=de,t[55]=K):K=t[55];let q;t[56]!==P||t[57]!==R||t[58]!==H||t[59]!==K?(q=(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[P,R,H,K]}),t[56]=P,t[57]=R,t[58]=H,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(J=n?.connected?null:(0,z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc, click Reload, then refresh status.`:r?`打开 xopc Chrome 扩展后,它会自动发现并安全连接本机 Gateway;只有连接另一台电脑时才需要一次性邀请和手动确认。`:`Open the xopc Chrome extension to discover and securely connect to a local Gateway automatically. A one-time invitation and explicit approval are only required for Chrome on another computer.`}),t[61]=n?.connected,t[62]=n?.socketConnected,t[63]=r,t[64]=J):J=t[64];let Y;return t[65]!==k||t[66]!==j||t[67]!==q||t[68]!==J?(Y=(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[k,j,q,J]}),t[65]=k,t[66]=j,t[67]=q,t[68]=J,t[69]=Y):Y=t[69],Y}function le(){return A(`folder`)}function ue(){return A(`chrome`)}function H(e){let t=(0,L.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),s;t[0]!==a||t[1]!==o?(s=(0,z.jsx)(U,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let l;t[3]===n?l=t[4]:(l=n?.executablePath?(0,z.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=l);let u;t[5]===i.progress?u=t[6]:(u=i.progress?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,z.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,z.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,z.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=u);let d=n?.installed?`secondary`:`primary`,f;t[7]===i?f=t[8]:(f=()=>void i.install(),t[7]=i,t[8]=f);let p;t[9]===i.running?p=t[10]:(p=i.running?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(c,{className:`size-3.5`}),t[9]=i.running,t[10]=p);let m=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(g=(0,z.jsxs)(h,{variant:d,className:`h-9`,disabled:i.running,onClick:f,children:[p,m]}),t[11]=i.running,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,z.jsx)(h,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=_):_=t[19];let v;t[20]!==_||t[21]!==g?(v=(0,z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=v):v=t[22];let y;return t[23]!==v||t[24]!==s||t[25]!==l||t[26]!==u?(y=(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[s,l,u,v]}),t[23]=v,t[24]=s,t[25]=l,t[26]=u,t[27]=y):y=t[27],y}function U(e){let t=(0,L.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,z.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,z.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function W(e){let t=(0,L.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,z.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function G(e){let t=(0,L.c)(36),{sectionId:n,vm:r,children:i}=e,a=d(de),o;t[0]===a?o=t[1]:(o=p(a),t[0]=a,t[1]=o);let s=o,c=s.agentSettings,l=s.settingsSections[n]??n;if(!r.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(S,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===l?n=t[4]:(n=(0,z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:l}),t[3]=l,t[4]=n);let r;t[5]===c.needToken?r=t[6]:(r=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,z.jsx)(P,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(r.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(P,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,z.jsx)(ae,{sections:1})}),t[10]=e):e=t[10],e}if(!r.form){let e=r.error??r.fetchError??c.loadError,n;t[11]===e?n=t[12]:(n=(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let i;t[13]===r?i=t[14]:(i=()=>void r.mutate(),t[13]=r,t[14]=i);let a;t[15]!==s.logs.refresh||t[16]!==i?(a=(0,z.jsx)(h,{type:`button`,variant:`secondary`,onClick:i,children:s.logs.refresh}),t[15]=s.logs.refresh,t[16]=i,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,z.jsxs)(P,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let u;t[21]!==r.autosaveStatus||t[22]!==r.error?(u=(0,z.jsx)(F,{status:r.autosaveStatus,error:r.error}),t[21]=r.autosaveStatus,t[22]=r.error,t[23]=u):u=t[23];let f;t[24]!==l||t[25]!==u?(f=(0,z.jsx)(ie,{title:l,actions:u}),t[24]=l,t[25]=u,t[26]=f):f=t[26];let m;t[27]===r.error?m=t[28]:(m=r.error?(0,z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,t[27]=r.error,t[28]=m);let g;t[29]===i?g=t[30]:(g=(0,z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=g);let _;return t[31]!==f||t[32]!==m||t[33]!==g||t[34]!==r.onBlurCapture?(_=(0,z.jsxs)(P,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[f,m,g]}),t[31]=f,t[32]=m,t[33]=g,t[34]=r.onBlurCapture,t[35]=_):_=t[35],_}function de(e){return e.language}var K={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function q(e){let t=X(X(e).browser),n=X(t.driver),r=X(t.observation),i=X(t.limits),a=X(t.security),o=n.kind;return{...K,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Z(n.executablePath,``),cdpEndpoint:Z(n.endpoint,K.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Z(n.apiKey,``),remoteProjectId:Z(n.projectId,``),remoteRegion:Z(n.region,``),maxNodes:Q(r.maxNodes,K.maxNodes),maxCharacters:Q(r.maxCharacters,K.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:Q(i.actionTimeoutMs,K.actionTimeoutMs),sessionTimeoutMs:Q(i.sessionTimeoutMs,K.sessionTimeoutMs),maxSequenceLength:Q(i.maxSequenceLength,K.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
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,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{a as l,c as u,n as d,r as f}from"./locale-store-D6VmRI5e.js";import{t as p}from"./messages-BCqLsIZK.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-CS04eWY9.js";import{n as g,r as _}from"./gateway-config-swr-DFjsI4QK.js";import{t as v}from"./skeleton-BwbyijEw.js";import{$r as y,Qc as b,Qr as x,Su as S,Tl as C,Uc as w,_u as T,dl as E,ei as D,fc as ee,gu as O,la as k,ni as A,ou as te,ri as j,ru as ne,ti as re,ua as M,wl as N}from"./index-DhCnwCI9.js";import{n as ie,r as P}from"./settings-page-layout-OvBOGen7.js";import{n as ae}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as F,t as I}from"./use-autosave-DfhqCGRX.js";import{t as oe}from"./settings-advanced-gate-C414vr2V.js";var L=n(),R=e(t(),1);function se(e){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(null),l=(0,R.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,R.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await re(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,R.useCallback)(async()=>{l.current&&(i(!0),await x().catch(()=>{}),l.current.abort())},[])}}var z=r(),B={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function V(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),c=m(t?[`browser-control-status`,n]:null,y,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,g]=(0,R.useState)(null),_=r===`dirty`||r===`saving`;(0,R.useEffect)(()=>{r===`saved`&&c.mutate()},[r,c.mutate]);let x=(0,R.useCallback)(async(e,t,n)=>{u(e),f(null),g(null);try{await t(),g(n),await c.mutate()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(null)}},[c.mutate]),S=se((0,R.useCallback)(()=>{g(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),c.mutate()},[c.mutate,a])),T=c.data?.payload,E=T?.driverKind===n,D=t?_||!E?`syncing`:T?.state:`disabled`;return(0,z.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(D===`ready`?s:D===`syncing`?C:ee,{className:`size-4 shrink-0 ${D===`ready`?`text-success`:D===`syncing`?`animate-spin text-fg-muted`:D===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${D===`ready`?`bg-success-soft text-success`:D===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:D===`ready`?a?`已就绪`:`Ready`:D===`disabled`?a?`未启用`:`Disabled`:D===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[B[n],T?.detail&&E?` · ${T.detail}`:``]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(h,{variant:`ghost`,className:`h-9`,onClick:()=>void c.mutate(),disabled:c.isValidating,children:[(0,z.jsx)(w,{className:`size-3.5 ${c.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,z.jsxs)(h,{variant:`secondary`,className:`h-9`,disabled:!t||_||l!==null||S.running,onClick:()=>void x(`test`,j,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(b,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&c.isLoading?(0,z.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,z.jsx)(v,{className:`h-12`}),(0,z.jsx)(v,{className:`h-12`}),(0,z.jsx)(v,{className:`h-12`})]}):null,t&&c.error?(0,z.jsx)(W,{tone:`error`,children:c.error instanceof Error?c.error.message:String(c.error)}):null,d||S.error?(0,z.jsx)(W,{tone:`error`,children:d??S.error}):null,p?(0,z.jsx)(W,{tone:`success`,children:p}):null,t&&n===`extension`&&E?(0,z.jsx)(ce,{status:T?.driverStatus,zh:a,busy:l,run:x,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&E?(0,z.jsx)(H,{status:T?.driverStatus,zh:a,installer:S}):null,t&&n===`cdp`?(0,z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,z.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function ce(e){let t=(0,L.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,l=r?`扩展文件`:`Extension files`,u=s?.installed===!0,d=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,f;t[0]!==l||t[1]!==u||t[2]!==d?(f=(0,z.jsx)(U,{label:l,ok:u,value:d}),t[0]=l,t[1]=u,t[2]=d,t[3]=f):f=t[3];let p=r?`本机自动发现`:`Local auto-discovery`,m=s?.nativeHost?.installed===!0,g=s?.nativeHost?.installed?r?`已就绪`:`Ready`:s?.nativeHost?.reason??(r?`需要修复`:`Repair required`),_;t[4]!==p||t[5]!==m||t[6]!==g?(_=(0,z.jsx)(U,{label:p,ok:m,value:g}),t[4]=p,t[5]=m,t[6]=g,t[7]=_):_=t[7];let v=r?`安全通道`:`Secure channel`,y=n?.transport===`gateway-realtime`,x=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,S;t[8]!==x||t[9]!==v||t[10]!==y?(S=(0,z.jsx)(U,{label:v,ok:y,value:x}),t[8]=x,t[9]=v,t[10]=y,t[11]=S):S=t[11];let w=r?`Chrome 连接`:`Chrome connection`,E=n?.connected===!0,ee=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,O;t[12]!==w||t[13]!==E||t[14]!==ee?(O=(0,z.jsx)(U,{label:w,ok:E,value:ee}),t[12]=w,t[13]=E,t[14]=ee,t[15]=O):O=t[15];let k;t[16]!==S||t[17]!==O||t[18]!==f||t[19]!==_?(k=(0,z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[f,_,S,O]}),t[16]=S,t[17]=O,t[18]=f,t[19]=_,t[20]=k):k=t[20];let A=s?.extensionDir??`Gateway Realtime`,j;t[21]===A?j=t[22]:(j=(0,z.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:A}),t[21]=A,t[22]=j);let ne=s?.installed?`secondary`:`primary`,re=i!==null,M;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(M=()=>void a(`extension-install`,()=>D(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=M):M=t[26];let N;t[27]===i?N=t[28]:(N=i===`extension-install`?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(c,{className:`size-3.5`}),t[27]=i,t[28]=N);let ie=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,P;t[29]!==ne||t[30]!==re||t[31]!==M||t[32]!==N||t[33]!==ie?(P=(0,z.jsxs)(h,{className:`h-9`,variant:ne,disabled:re,onClick:M,children:[N,ie]}),t[29]=ne,t[30]=re,t[31]=M,t[32]=N,t[33]=ie,t[34]=P):P=t[34];let ae=!s?.installed||i!==null,F;t[35]!==a||t[36]!==r?(F=()=>void a(`extension-open`,ue,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=F):F=t[37];let I;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,z.jsx)(T,{className:`size-3.5`}),t[38]=I):I=t[38];let oe=r?`打开扩展页`:`Open extensions`,R;t[39]!==ae||t[40]!==F||t[41]!==oe?(R=(0,z.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:ae,onClick:F,children:[I,oe]}),t[39]=ae,t[40]=F,t[41]=oe,t[42]=R):R=t[42];let se=!s?.installed||i!==null,B;t[43]!==a||t[44]!==r?(B=()=>void a(`extension-folder`,le,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=B):B=t[45];let V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,z.jsx)(te,{className:`size-3.5`}),t[46]=V):V=t[46];let ce=r?`打开扩展目录`:`Open folder`,H;t[47]!==se||t[48]!==B||t[49]!==ce?(H=(0,z.jsxs)(h,{className:`h-9`,variant:`ghost`,disabled:se,onClick:B,children:[V,ce]}),t[47]=se,t[48]=B,t[49]=ce,t[50]=H):H=t[50];let W=i!==null,G;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,z.jsx)(b,{className:`size-3.5`}),t[51]=G):G=t[51];let de=r?`连接远程 Chrome`:`Connect remote Chrome`,K;t[52]!==o||t[53]!==W||t[54]!==de?(K=(0,z.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:W,onClick:o,children:[G,de]}),t[52]=o,t[53]=W,t[54]=de,t[55]=K):K=t[55];let q;t[56]!==P||t[57]!==R||t[58]!==H||t[59]!==K?(q=(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[P,R,H,K]}),t[56]=P,t[57]=R,t[58]=H,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(J=n?.connected?null:(0,z.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc, click Reload, then refresh status.`:r?`打开 xopc Chrome 扩展后,它会自动发现并安全连接本机 Gateway;只有连接另一台电脑时才需要一次性邀请和手动确认。`:`Open the xopc Chrome extension to discover and securely connect to a local Gateway automatically. A one-time invitation and explicit approval are only required for Chrome on another computer.`}),t[61]=n?.connected,t[62]=n?.socketConnected,t[63]=r,t[64]=J):J=t[64];let Y;return t[65]!==k||t[66]!==j||t[67]!==q||t[68]!==J?(Y=(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[k,j,q,J]}),t[65]=k,t[66]=j,t[67]=q,t[68]=J,t[69]=Y):Y=t[69],Y}function le(){return A(`folder`)}function ue(){return A(`chrome`)}function H(e){let t=(0,L.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),s;t[0]!==a||t[1]!==o?(s=(0,z.jsx)(U,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let l;t[3]===n?l=t[4]:(l=n?.executablePath?(0,z.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=l);let u;t[5]===i.progress?u=t[6]:(u=i.progress?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,z.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,z.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,z.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=u);let d=n?.installed?`secondary`:`primary`,f;t[7]===i?f=t[8]:(f=()=>void i.install(),t[7]=i,t[8]=f);let p;t[9]===i.running?p=t[10]:(p=i.running?(0,z.jsx)(C,{className:`size-3.5 animate-spin`}):(0,z.jsx)(c,{className:`size-3.5`}),t[9]=i.running,t[10]=p);let m=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(g=(0,z.jsxs)(h,{variant:d,className:`h-9`,disabled:i.running,onClick:f,children:[p,m]}),t[11]=i.running,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,z.jsx)(h,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=_):_=t[19];let v;t[20]!==_||t[21]!==g?(v=(0,z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=v):v=t[22];let y;return t[23]!==v||t[24]!==s||t[25]!==l||t[26]!==u?(y=(0,z.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[s,l,u,v]}),t[23]=v,t[24]=s,t[25]=l,t[26]=u,t[27]=y):y=t[27],y}function U(e){let t=(0,L.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,z.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,z.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,z.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function W(e){let t=(0,L.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,z.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function G(e){let t=(0,L.c)(36),{sectionId:n,vm:r,children:i}=e,a=d(de),o;t[0]===a?o=t[1]:(o=p(a),t[0]=a,t[1]=o);let s=o,c=s.agentSettings,l=s.settingsSections[n]??n;if(!r.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(S,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===l?n=t[4]:(n=(0,z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:l}),t[3]=l,t[4]=n);let r;t[5]===c.needToken?r=t[6]:(r=(0,z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,z.jsx)(P,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(r.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,z.jsx)(P,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,z.jsx)(ae,{sections:1})}),t[10]=e):e=t[10],e}if(!r.form){let e=r.error??r.fetchError??c.loadError,n;t[11]===e?n=t[12]:(n=(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let i;t[13]===r?i=t[14]:(i=()=>void r.mutate(),t[13]=r,t[14]=i);let a;t[15]!==s.logs.refresh||t[16]!==i?(a=(0,z.jsx)(h,{type:`button`,variant:`secondary`,onClick:i,children:s.logs.refresh}),t[15]=s.logs.refresh,t[16]=i,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,z.jsxs)(P,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let u;t[21]!==r.autosaveStatus||t[22]!==r.error?(u=(0,z.jsx)(F,{status:r.autosaveStatus,error:r.error}),t[21]=r.autosaveStatus,t[22]=r.error,t[23]=u):u=t[23];let f;t[24]!==l||t[25]!==u?(f=(0,z.jsx)(ie,{title:l,actions:u}),t[24]=l,t[25]=u,t[26]=f):f=t[26];let m;t[27]===r.error?m=t[28]:(m=r.error?(0,z.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,t[27]=r.error,t[28]=m);let g;t[29]===i?g=t[30]:(g=(0,z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=g);let _;return t[31]!==f||t[32]!==m||t[33]!==g||t[34]!==r.onBlurCapture?(_=(0,z.jsxs)(P,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[f,m,g]}),t[31]=f,t[32]=m,t[33]=g,t[34]=r.onBlurCapture,t[35]=_):_=t[35],_}function de(e){return e.language}var K={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function q(e){let t=X(X(e).browser),n=X(t.driver),r=X(t.observation),i=X(t.limits),a=X(t.security),o=n.kind;return{...K,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Z(n.executablePath,``),cdpEndpoint:Z(n.endpoint,K.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Z(n.apiKey,``),remoteProjectId:Z(n.projectId,``),remoteRegion:Z(n.region,``),maxNodes:Q(r.maxNodes,K.maxNodes),maxCharacters:Q(r.maxCharacters,K.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:Q(i.actionTimeoutMs,K.actionTimeoutMs),sessionTimeoutMs:Q(i.sessionTimeoutMs,K.sessionTimeoutMs),maxSequenceLength:Q(i.maxSequenceLength,K.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
2
2
  `):``,crossDomainNavigation:pe(a.crossDomainNavigation),uploads:pe(a.uploads),consequentialActions:pe(a.consequentialActions)}}function J(e){let t=e.driverKind===`extension`?{kind:`extension`}:e.driverKind===`playwright`?{kind:`playwright`,headless:e.headless,...e.executablePath.trim()?{executablePath:e.executablePath.trim()}:{}}:e.driverKind===`cdp`?{kind:`cdp`,endpoint:e.cdpEndpoint.trim()}:{kind:`remote`,provider:e.remoteProvider,...e.remoteApiKey.trim()?{apiKey:e.remoteApiKey.trim()}:{},...e.remoteProjectId.trim()?{projectId:e.remoteProjectId.trim()}:{},...e.remoteRegion.trim()?{region:e.remoteRegion.trim()}:{}};return{enabled:e.enabled,driver:t,observation:{maxNodes:e.maxNodes,maxCharacters:e.maxCharacters,visualFallback:e.visualFallback},limits:{actionTimeoutMs:e.actionTimeoutMs,sessionTimeoutMs:e.sessionTimeoutMs,maxSequenceLength:e.maxSequenceLength},security:{privateNetworks:`deny`,allowedPrivateHosts:e.allowedPrivateHosts.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function Y(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function fe(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:J(e)})}),g()}function X(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e,t){return typeof e==`string`?e:t}function Q(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function pe(e){return e===`allow`||e===`deny`?e:`ask`}var me=k();function he(e){let t=!!u(e=>e.conversationId),[n,r]=(0,R.useReducer)(me,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,R.useRef)(!1),s=(0,R.useRef)(i);s.current=i;let c=(0,R.useRef)(null),{data:l,error:d,isLoading:f,mutate:p}=_(t);M({enabled:t,parsed:(0,R.useMemo)(()=>l?.payload?.config===void 0?null:q(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let m=!!(t&&f&&l===void 0&&!d),h=d instanceof Error?d.message:d?String(d):null,g=(0,R.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),v=(0,R.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),y=I({value:i,dirty:g,onSave:(0,R.useCallback)(async t=>{try{await fe(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:Y});return{hasToken:t,loading:m,fetchError:h,form:i,update:v,autosaveStatus:y.status,error:y.error,onBlurCapture:y.onBlurCapture,mutate:p}}var ge=[`extension`,`playwright`,`cdp`,`remote`];function _e(){let e=(0,L.c)(29),t=d(ve),n;e[0]===t?n=e[1]:(n=p(t),e[0]=t,e[1]=n);let r=he(n.agentSettings),i=r.form,s=t===`zh`,[c]=a(),l=(0,R.useRef)(!1),u;e[2]!==i||e[3]!==c||e[4]!==r?(u=()=>{if(!i||l.current)return;l.current=!0;let e=c.get(`driver`);ge.includes(e)&&e!==i.driverKind&&r.update({driverKind:e})},e[2]=i,e[3]=c,e[4]=r,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==r.update?(f=[i,c,r.update],e[6]=i,e[7]=c,e[8]=r.update,e[9]=f):f=e[9],(0,R.useEffect)(u,f);let m=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,h;e[10]===m?h=e[11]:(h={value:`extension`,label:m},e[10]=m,e[11]=h);let g;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(g={value:`playwright`,label:`Playwright Chromium`},e[12]=g):g=e[12];let _=s?`CDP 已有浏览器`:`Existing browser over CDP`,v;e[13]===_?v=e[14]:(v={value:`cdp`,label:_},e[13]=_,e[14]=v);let y=s?`远程浏览器`:`Remote browser`,b;e[15]===y?b=e[16]:(b={value:`remote`,label:y},e[15]=y,e[16]=b);let x;e[17]!==h||e[18]!==v||e[19]!==b?(x=[h,g,v,b],e[17]=h,e[18]=v,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]!==S||e[22]!==i||e[23]!==r||e[24]!==s?(C=i?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{enabled:i.enabled,driverKind:i.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,z.jsxs)(be,{title:s?`运行方式`:`Connection`,icon:(0,z.jsx)(E,{className:`size-4`}),children:[(0,z.jsx)(Ce,{label:s?`启用浏览器控制`:`Enable browser control`,checked:i.enabled,onChange:e=>r.update({enabled:e})}),(0,z.jsx)(xe,{label:s?`浏览器连接`:`Browser connection`,children:(0,z.jsx)(o,{value:i.driverKind,options:S,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,z.jsx)(ye,{kind:i.driverKind,zh:s}),i.driverKind===`playwright`?(0,z.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,z.jsx)(Ce,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察智能体的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:i.headless,onChange:e=>r.update({headless:e})}),(0,z.jsx)($,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:i.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,i.driverKind===`cdp`?(0,z.jsx)(`div`,{className:`rounded-lg bg-surface-inset p-4`,children:(0,z.jsx)($,{label:`CDP endpoint`,description:s?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:i.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,i.driverKind===`remote`?(0,z.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,z.jsx)(xe,{label:s?`服务商`:`Provider`,children:(0,z.jsx)(o,{value:i.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,z.jsx)($,{label:`API key`,type:`password`,autoComplete:`off`,value:i.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,z.jsx)($,{label:`Project ID`,value:i.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,z.jsx)($,{label:`Region`,value:i.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,z.jsx)(oe,{children:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(be,{title:s?`页面理解`:`Page understanding`,icon:(0,z.jsx)(O,{className:`size-4`}),children:[(0,z.jsx)(Ce,{label:s?`需要时附加截图`:`Attach screenshots when needed`,checked:i.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,z.jsx)(Se,{label:s?`语义节点上限`:`Semantic node limit`,description:`20–500`,min:20,max:500,value:i.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,z.jsx)(Se,{label:s?`文本字符上限`:`Text character limit`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:i.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,z.jsx)(be,{title:s?`执行限制`:`Execution limits`,icon:(0,z.jsx)(ne,{className:`size-4`}),children:(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,z.jsx)(Se,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:i.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,z.jsx)(Se,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:i.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,z.jsx)(Se,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:i.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,z.jsxs)(be,{title:s?`安全与审批`:`Safety and approvals`,icon:(0,z.jsx)(N,{className:`size-4`}),children:[(0,z.jsx)($,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个主机名或 IP,不支持通配符。`:`One hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:i.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,z.jsx)(we,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:i.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,z.jsx)(we,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:i.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,z.jsx)(we,{zh:s,label:s?`文件上传`:`File uploads`,value:i.uploads,onChange:e=>r.update({uploads:e})})]})]})]})})]}):null,e[21]=S,e[22]=i,e[23]=r,e[24]=s,e[25]=C):C=e[25];let w;return e[26]!==C||e[27]!==r?(w=(0,z.jsx)(G,{sectionId:`agent-browser`,vm:r,children:C}),e[26]=C,e[27]=r,e[28]=w):w=e[28],w}function ve(e){return e.language}function ye(e){let t=(0,L.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,z.jsx)(`p`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function be(e){let t=(0,L.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,z.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,z.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,z.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,z.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,z.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function xe(e){let t=(0,L.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,z.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,z.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,z.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function $(e){let t=(0,L.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,z.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,z.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,z.jsx)(xe,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function Se(e){let t=(0,L.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,z.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,z.jsx)(xe,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function Ce(e){let t=(0,L.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,z.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,z.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,z.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,z.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,z.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function we(e){let t=(0,L.c)(20),{zh:n,label:r,value:i,onChange:a}=e,s=n?`每次询问`:`Ask each time`,c;t[0]===s?c=t[1]:(c={value:`ask`,label:s},t[0]=s,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===a?g=t[11]:(g=e=>a(e),t[10]=a,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,z.jsx)(o,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,z.jsx)(xe,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{_e as AgentBrowserSettingsPage};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as u,r as d,t as f}from"./popover-select-B-GDnZO9.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./cn-JdwAhgNB.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-BlgpZORR.js";import{t as S}from"./messages-2GhUD7SC.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./dist-BGTk37IG.js";import{i as A}from"./vendor-swr-BIWyz7Rc.js";import{t as j}from"./button-CS04eWY9.js";import{n as M,r as N}from"./gateway-config-swr-BPsZPoAT.js";import{t as P}from"./skeleton-BwbyijEw.js";import{i as F,o as I}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as L}from"./electron-env-Dit0bHgy.js";import{Ao as R,At as z,Bu as B,Cc as V,Cl as ee,Ct as H,Dt as U,Eo as W,Et as te,Fc as G,Ft as K,Go as ne,Hl as re,Io as q,It as J,Kl as ie,Ko as Y,Lo as X,Lt as ae,Mc as Z,No as oe,Ns as se,Nt as ce,Ot as le,Ou as ue,Po as de,Ps as fe,Pt as pe,Ro as me,Rt as he,St as ge,Tl as _e,To as ve,Tt as ye,Uc as be,Uo as xe,Uu as Se,Vo as Ce,Wo as we,Xc as Te,Xo as Ee,Zc as De,Zo as Oe,_i as ke,_t as Ae,_u as je,ac as Me,bt as Ne,ct as Pe,dt as Fe,fc as Ie,ft as Le,gl as Re,gt as ze,gu as Be,ht as Ve,jo as He,jt as Ue,kc as We,kt as Ge,la as Ke,lt as qe,mt as Je,od as Ye,pc as Xe,pt as Ze,qo as Qe,sa as $e,sd as et,tl as tt,ua as nt,ut as rt,vt as it,wo as at,xt as ot,yn as st,yt as ct}from"./index-BCi8nfxs.js";import{n as lt,r as ut}from"./settings-page-layout-lLvHc-zF.js";import{n as dt,t as ft}from"./settings-form-section-BkBO7woF.js";import{t as pt}from"./page-tabs-Dz_x22MQ.js";import{t as mt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ht,t as gt}from"./use-autosave-C_ntK_Zu.js";import{a as _t,c as vt,d as yt,f as bt,h as xt,i as St,l as Ct,n as wt,o as Tt,p as Et,r as Dt,t as Ot,u as kt}from"./voice-config-api-Cjvd6maH.js";import{t as At}from"./voice-api-key-field-D4cfuMp1.js";import{t as jt}from"./settings-advanced-gate-VxPItcOG.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-DI_QutIx.js";var Rt=n(),Q=e(t(),1),$=r(),zt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Bt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Vt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Ht(e){let t=e.split(`
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as u,r as d,t as f}from"./popover-select-B-GDnZO9.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./cn-JdwAhgNB.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-D6VmRI5e.js";import{t as S}from"./messages-BCqLsIZK.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./dist-BGTk37IG.js";import{i as A}from"./vendor-swr-BIWyz7Rc.js";import{t as j}from"./button-CS04eWY9.js";import{n as M,r as N}from"./gateway-config-swr-DFjsI4QK.js";import{t as P}from"./skeleton-BwbyijEw.js";import{i as F,o as I}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as L}from"./electron-env-Dit0bHgy.js";import{Ao as R,At as z,Bu as B,Cc as V,Cl as ee,Ct as H,Dt as U,Eo as W,Et as te,Fc as G,Ft as K,Go as ne,Hl as re,Io as q,It as J,Kl as ie,Ko as Y,Lo as X,Lt as ae,Mc as Z,No as oe,Ns as se,Nt as ce,Ot as le,Ou as ue,Po as de,Ps as fe,Pt as pe,Ro as me,Rt as he,St as ge,Tl as _e,To as ve,Tt as ye,Uc as be,Uo as xe,Uu as Se,Vo as Ce,Wo as we,Xc as Te,Xo as Ee,Zc as De,Zo as Oe,_i as ke,_t as Ae,_u as je,ac as Me,bt as Ne,ct as Pe,dt as Fe,fc as Ie,ft as Le,gl as Re,gt as ze,gu as Be,ht as Ve,jo as He,jt as Ue,kc as We,kt as Ge,la as Ke,lt as qe,mt as Je,od as Ye,pc as Xe,pt as Ze,qo as Qe,sa as $e,sd as et,tl as tt,ua as nt,ut as rt,vt as it,wo as at,xt as ot,yn as st,yt as ct}from"./index-DhCnwCI9.js";import{n as lt,r as ut}from"./settings-page-layout-OvBOGen7.js";import{n as dt,t as ft}from"./settings-form-section-DBJlmKQV.js";import{t as pt}from"./page-tabs-B84Yghg5.js";import{t as mt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ht,t as gt}from"./use-autosave-DfhqCGRX.js";import{a as _t,c as vt,d as yt,f as bt,h as xt,i as St,l as Ct,n as wt,o as Tt,p as Et,r as Dt,t as Ot,u as kt}from"./voice-config-api-B4yjd1Kb.js";import{t as At}from"./voice-api-key-field-taBVzvtI.js";import{t as jt}from"./settings-advanced-gate-C414vr2V.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-CyDy_Sxu.js";var Rt=n(),Q=e(t(),1),$=r(),zt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Bt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Vt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Ht(e){let t=e.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Ut({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=zt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`bearer`),[y,b]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[A,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(`/images/generations`),[z,B]=(0,Q.useState)(`/images/edits`),[V,ee]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[W,te]=(0,Q.useState)([Vt()]),[G,ne]=(0,Q.useState)(``),[re,q]=(0,Q.useState)(),[J,ie]=(0,Q.useState)(!1),[Y,X]=(0,Q.useState)(),[ae,Z]=(0,Q.useState)(),[se,ce]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),v(t?.auth.type??`bearer`),b(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),M(t?.apiKeyUrl??``),P(t?.documentationUrl??``),R(t?.paths?.generations??`/images/generations`),B(t?.paths?.edits??`/images/edits`),ee(t?.network?.allowedHosts.join(`
4
4
  `)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
5
  `)),te(t?.models.map(Vt)??[Vt()]),ne(t?.defaultModel??``),Z(void 0),q(void 0),ie(!1),X(void 0),ce(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>W.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[W]),ue=(e,t)=>{te(n=>n.map((n,r)=>r===e?{...n,...t}:n))},fe=()=>{let e=s.trim(),t=W.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=G||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ht(H)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...A.trim()?{apiKeyUrl:A.trim()}:{},defaultModel:n,auth:_===`header`?{type:`header`,headerName:y.trim()}:{type:_},paths:{...L.trim()?{generations:L.trim()}:{},...z.trim()?{edits:z.trim()}:{}},...V.trim()?{network:{allowedHosts:V.split(`
@@ -1 +1 @@
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,m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-BlgpZORR.js";import{t as h}from"./messages-2GhUD7SC.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as E,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as O}from"./settings-shell-layer-context-BTQUDoJ2.js";import{Co as k,Fc as A,Hc as j,Hu as M,Kc as N,Ns as P,Sa as F,Sn as I,Tl as L,Zr as R,_n as z,_u as B,bn as ee,fc as te,oa as ne,xc as re,xn as ie,ya as ae}from"./index-BCi8nfxs.js";import{n as oe,r as se}from"./settings-page-layout-lLvHc-zF.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-RVltVpuG.js";var V=e(t(),1),H=n();async function de(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function fe(){return m(`/api/channels/status`)}var pe=de;function me(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 he=e(ce(),1),U=r();async function W(e){let t=await f(m(`/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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ge(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>me(e),[e]),o=(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,u]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,V.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await W({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,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){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(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||W({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||u(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 f=a?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=K(c.payload),h=q(c.payload,e.id),g=h?c.generatedQr:ge(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:l(`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)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(a[0]),children:[c.busy?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(N,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(w,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(re,{className:`size-4`}),p]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,U.jsxs)(`div`,{className:l(`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)(T,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:l(`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)(T,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(T,{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)(B,{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)(s,{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,v?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:v.schema,values:c.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,U.jsx)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.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 J=40;function ve(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===ve(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=ve(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:J,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(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 Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,E):l(`xopc-dialog-content 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)]`,E,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function we(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:h}=e,C=m===void 0?!1:m,T=n===`drawer`,[E,k]=(0,V.useState)(null),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,U.jsx)(g,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),t[0]=A):A=t[0];let j;t[1]!==n||t[2]!==C?(j=Ce(n,C),t[1]=n,t[2]=C,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,U.jsx)(x,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===u?N=t[7]:(N=u?(0,U.jsx)(_,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=N);let F;t[8]!==d||t[9]!==o||t[10]!==h||t[11]!==T||t[12]!==a?(F=T?(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,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,U.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:l(P,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,U.jsx)(c,{className:`size-4`})})}),h]}),t[8]=d,t[9]=o,t[10]=h,t[11]=T,t[12]=a,t[13]=F):F=t[13];let I=T?`p-4`:`p-6`,L;t[14]===I?L=t[15]:(L=l(`min-h-0 flex-1 overflow-y-auto`,I),t[14]=I,t[15]=L);let R;t[16]!==f||t[17]!==L?(R=(0,U.jsx)(`div`,{className:L,children:f}),t[16]=f,t[17]=L,t[18]=R):R=t[18];let z;t[19]!==p||t[20]!==E||t[21]!==M||t[22]!==N||t[23]!==F||t[24]!==R?(z=(0,U.jsxs)(O,{layer:`modal`,portalContainer:E,children:[M,N,F,R,p]}),t[19]=p,t[20]=E,t[21]=M,t[22]=N,t[23]=F,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==z||t[27]!==j?(B=(0,U.jsxs)(y,{children:[A,(0,U.jsx)(b,{ref:k,className:j,onOpenAutoFocus:Te,children:z})]}),t[26]=z,t[27]=j,t[28]=B):B=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==B?(ee=(0,U.jsx)(S,{open:r,onOpenChange:i,children:B}),t[29]=i,t[30]=r,t[31]=B,t[32]=ee):ee=t[32],ee}function Te(e){return e.preventDefault()}var Ee=(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)(ne,{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 De(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)(w,{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)(w,{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)(w,{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 Oe(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function ke(e){return(await u(Oe(e))).payload?.channels??[]}function Ae(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>ke(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}=C(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 je=`channels-status`;function Me(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ne(e){let t=t=>e(t.detail);return window.addEventListener(je,t),()=>window.removeEventListener(je,t)}function Pe(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 Ne(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 Fe(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ie(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Le=[`enabled`];async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(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 Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(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 We(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=>!Le.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Le.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 Ge(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 Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(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 Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ye(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Q(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(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 Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(tt(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Ye(t,e),n);i&&r.push(i)}let a=Q(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=me(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 $e(e,t){let n=me(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(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 tt(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 nt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(F,{sourceChannel:e.id,className:`size-7`})})}function rt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`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]!==o||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function it(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,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]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,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)(nt,{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=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,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]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.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)(rt,{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=c,_=`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(at)}):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:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map($)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,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||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==T||t[64]!==S?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,T]})}),t[61]=m,t[62]=C,t[63]=T,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function $(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 at(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?s:n===`stopped`||n===`needs_setup`?M:L,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,U.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let N;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(N=n===`stopped`?(0,U.jsxs)(w,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(j,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=N):N=t[35];let P;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(P=o?(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=P):P=t[43];let F;t[44]!==A||t[45]!==N||t[46]!==P?(F=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,N,P]}),t[44]=A,t[45]=N,t[46]=P,t[47]=F):F=t[47];let I;return t[48]!==E||t[49]!==F?(I=(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:[E,F]})}),t[48]=E,t[49]=F,t[50]=I):I=t[50],I}function st(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 bg-amber-50 px-4 py-3 text-amber-950 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)(te,{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:tt(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 ct(){let e=p(e=>e.language),t=h(e),n=d(e=>!!e.conversationId),r=i(),{channelId:s}=a(),c=I(s),u=Ae(n,e),g=u.entries,{data:_,mutate:v,isValidating:y}=C(n?fe():null,pe,{revalidateOnFocus:!0}),{data:b,mutate:x}=C(n?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),S=b?.channels??{},w=b?.bindings??[],{data:T}=C(n?`channel-routing-agents`:null,ae,{revalidateOnFocus:!1}),E=k(e=>e.setPageHeader),D=k(e=>e.clearPageHeader),O=(0,V.useMemo)(()=>g.find(e=>e.id===c),[c,g]),j=O?Be(O):null,{data:M,mutate:N}=C(n&&j?Fe(j):null,()=>Ie(j)),[P,F]=(0,V.useState)(null),[L,te]=(0,V.useState)(!1),[ne,re]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[de,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),ge=P??M??{},J=t.channelsSettings,ve=(0,V.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),xe=(0,V.useMemo)(()=>qe(ve,Le),[ve]),Ce=(0,V.useMemo)(()=>We(O),[O]),Te=(0,V.useMemo)(()=>Ge(xe,Ce),[Ce,xe]),Oe=(0,V.useMemo)(()=>qe(xe,Ce),[Ce,xe]),ke=(0,V.useMemo)(()=>Je(Te),[Te]),je=O?K??ye(w,O.id):``,Ne=(0,V.useMemo)(()=>(T?.items??[]).map(e=>{let n=z(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),ze=T?.items.find(e=>e.id===T.defaultId),He=ze?z(ze,t.agentsSettings):T?.defaultId??``,X=(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]),Z=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Ke=_!==void 0,Ye=(0,V.useCallback)(e=>Se(e,Z.get(e.id),Ke),[Z,Ke]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),v()])},[u,v]);Pe((0,V.useCallback)(e=>{let t=Me(e);t&&v(t,!1)},[v]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:u.isValidating||y,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,y,Q]);(0,V.useLayoutEffect)(()=>(E({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}),()=>D()),[D,Xe,t.settingsSections.channels,E]);let Ze=(0,V.useCallback)(e=>{r(ie(e)),F(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(ee),F(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await f(m(`/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)},[O?.id]);let et=(0,V.useCallback)(async()=>{if(!O||!P&&K===null)return!1;let e=Be(O);te(!0),G(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...P?{channels:{[e]:P}}:{},...K===null?{}:{bindings:be(w,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return P&&await N(P,!1),await x(),await u.mutate(),F(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{te(!1)}},[O,K,w,u,P,x,N]),tt=(0,V.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?P:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}re(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/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 u.mutate(),await x(),await v(),O?.id===e.id&&(await N(),F(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{re(null)}},[O?.id,u,P,x,N,v,Ze]),$=O?.ui?.modal,at=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!Y(O).ready||de:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,U.jsx)(le,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(it,{entry:e,config:S[Be(e)]?.config,runtime:Ye(e),busy:ne===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void tt(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)(we,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:O?.label??J.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,U.jsx)(De,{ch:J,dirty:!!P||K!==null,saving:L,onCancel:Qe,onDiscard:()=>{F(null),q(null)},onSave:et}):null,children:O?(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)(nt,{entry:O}),(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:O.label}),(0,U.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(ct)),children:Ve(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(O).ready&&me(O)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,U.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(B,{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(O).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(rt,{checked:Y(O).enabled,disabled:ne===O.id,label:J.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void tt(O)})]})]})}),(0,U.jsx)(ot,{runtime:ct,restarting:ce===O.id,checking:y,showConnectionOptions:de,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(st,{entry:O,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:O,locale:e,messages:J,compact:!0,onChanged:async()=>{await N(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(R,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(R,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,at&&ke?(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)(ue,{schema:Te,values:ge,onChange:e=>F(e),disabled:L,labels:X})]}):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)(A,{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)(o,{value:je,options:Ne,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,He||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:L||!T,onChange:e=>q(e)})]})]}),at&&Je(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)(A,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:ge,onChange:e=>F(e),disabled:L,labels:X})})]}):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{ct as ChannelsSettingsPanel};
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,m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-D6VmRI5e.js";import{t as h}from"./messages-BCqLsIZK.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as E,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as O}from"./settings-shell-layer-context-BTQUDoJ2.js";import{Co as k,Fc as A,Hc as j,Hu as M,Kc as N,Ns as P,Sa as F,Sn as I,Tl as L,Zr as R,_n as z,_u as B,bn as ee,fc as te,oa as ne,xc as re,xn as ie,ya as ae}from"./index-DhCnwCI9.js";import{n as oe,r as se}from"./settings-page-layout-OvBOGen7.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-Dytkw9RZ.js";var V=e(t(),1),H=n();async function de(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function fe(){return m(`/api/channels/status`)}var pe=de;function me(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 he=e(ce(),1),U=r();async function W(e){let t=await f(m(`/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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ge(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>me(e),[e]),o=(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,u]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,V.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await W({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,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){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(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||W({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||u(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 f=a?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=K(c.payload),h=q(c.payload,e.id),g=h?c.generatedQr:ge(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:l(`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)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(a[0]),children:[c.busy?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(N,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(w,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(re,{className:`size-4`}),p]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,U.jsxs)(`div`,{className:l(`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)(T,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:l(`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)(T,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(T,{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)(B,{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)(s,{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,v?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:v.schema,values:c.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,U.jsx)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.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 J=40;function ve(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===ve(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=ve(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:J,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(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 Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,E):l(`xopc-dialog-content 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)]`,E,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function we(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:h}=e,C=m===void 0?!1:m,T=n===`drawer`,[E,k]=(0,V.useState)(null),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,U.jsx)(g,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),t[0]=A):A=t[0];let j;t[1]!==n||t[2]!==C?(j=Ce(n,C),t[1]=n,t[2]=C,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,U.jsx)(x,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===u?N=t[7]:(N=u?(0,U.jsx)(_,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=N);let F;t[8]!==d||t[9]!==o||t[10]!==h||t[11]!==T||t[12]!==a?(F=T?(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,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,U.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:l(P,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,U.jsx)(c,{className:`size-4`})})}),h]}),t[8]=d,t[9]=o,t[10]=h,t[11]=T,t[12]=a,t[13]=F):F=t[13];let I=T?`p-4`:`p-6`,L;t[14]===I?L=t[15]:(L=l(`min-h-0 flex-1 overflow-y-auto`,I),t[14]=I,t[15]=L);let R;t[16]!==f||t[17]!==L?(R=(0,U.jsx)(`div`,{className:L,children:f}),t[16]=f,t[17]=L,t[18]=R):R=t[18];let z;t[19]!==p||t[20]!==E||t[21]!==M||t[22]!==N||t[23]!==F||t[24]!==R?(z=(0,U.jsxs)(O,{layer:`modal`,portalContainer:E,children:[M,N,F,R,p]}),t[19]=p,t[20]=E,t[21]=M,t[22]=N,t[23]=F,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==z||t[27]!==j?(B=(0,U.jsxs)(y,{children:[A,(0,U.jsx)(b,{ref:k,className:j,onOpenAutoFocus:Te,children:z})]}),t[26]=z,t[27]=j,t[28]=B):B=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==B?(ee=(0,U.jsx)(S,{open:r,onOpenChange:i,children:B}),t[29]=i,t[30]=r,t[31]=B,t[32]=ee):ee=t[32],ee}function Te(e){return e.preventDefault()}var Ee=(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)(ne,{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 De(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)(w,{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)(w,{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)(w,{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 Oe(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function ke(e){return(await u(Oe(e))).payload?.channels??[]}function Ae(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>ke(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}=C(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 je=`channels-status`;function Me(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ne(e){let t=t=>e(t.detail);return window.addEventListener(je,t),()=>window.removeEventListener(je,t)}function Pe(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 Ne(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 Fe(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ie(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Le=[`enabled`];async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(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 Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(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 We(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=>!Le.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Le.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 Ge(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 Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(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 Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ye(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Q(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(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 Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(tt(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Ye(t,e),n);i&&r.push(i)}let a=Q(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=me(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 $e(e,t){let n=me(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(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 tt(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 nt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(F,{sourceChannel:e.id,className:`size-7`})})}function rt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`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]!==o||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function it(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,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]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,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)(nt,{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=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,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]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.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)(rt,{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=c,_=`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(at)}):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:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map($)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,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||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==T||t[64]!==S?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,T]})}),t[61]=m,t[62]=C,t[63]=T,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function $(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 at(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?s:n===`stopped`||n===`needs_setup`?M:L,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,U.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,U.jsx)(L,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let N;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(N=n===`stopped`?(0,U.jsxs)(w,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(L,{className:`size-4 animate-spin`}):(0,U.jsx)(j,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=N):N=t[35];let P;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(P=o?(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=P):P=t[43];let F;t[44]!==A||t[45]!==N||t[46]!==P?(F=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,N,P]}),t[44]=A,t[45]=N,t[46]=P,t[47]=F):F=t[47];let I;return t[48]!==E||t[49]!==F?(I=(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:[E,F]})}),t[48]=E,t[49]=F,t[50]=I):I=t[50],I}function st(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 bg-amber-50 px-4 py-3 text-amber-950 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)(te,{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:tt(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 ct(){let e=p(e=>e.language),t=h(e),n=d(e=>!!e.conversationId),r=i(),{channelId:s}=a(),c=I(s),u=Ae(n,e),g=u.entries,{data:_,mutate:v,isValidating:y}=C(n?fe():null,pe,{revalidateOnFocus:!0}),{data:b,mutate:x}=C(n?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),S=b?.channels??{},w=b?.bindings??[],{data:T}=C(n?`channel-routing-agents`:null,ae,{revalidateOnFocus:!1}),E=k(e=>e.setPageHeader),D=k(e=>e.clearPageHeader),O=(0,V.useMemo)(()=>g.find(e=>e.id===c),[c,g]),j=O?Be(O):null,{data:M,mutate:N}=C(n&&j?Fe(j):null,()=>Ie(j)),[P,F]=(0,V.useState)(null),[L,te]=(0,V.useState)(!1),[ne,re]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[de,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),ge=P??M??{},J=t.channelsSettings,ve=(0,V.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),xe=(0,V.useMemo)(()=>qe(ve,Le),[ve]),Ce=(0,V.useMemo)(()=>We(O),[O]),Te=(0,V.useMemo)(()=>Ge(xe,Ce),[Ce,xe]),Oe=(0,V.useMemo)(()=>qe(xe,Ce),[Ce,xe]),ke=(0,V.useMemo)(()=>Je(Te),[Te]),je=O?K??ye(w,O.id):``,Ne=(0,V.useMemo)(()=>(T?.items??[]).map(e=>{let n=z(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),ze=T?.items.find(e=>e.id===T.defaultId),He=ze?z(ze,t.agentsSettings):T?.defaultId??``,X=(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]),Z=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Ke=_!==void 0,Ye=(0,V.useCallback)(e=>Se(e,Z.get(e.id),Ke),[Z,Ke]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),v()])},[u,v]);Pe((0,V.useCallback)(e=>{let t=Me(e);t&&v(t,!1)},[v]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:u.isValidating||y,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,y,Q]);(0,V.useLayoutEffect)(()=>(E({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}),()=>D()),[D,Xe,t.settingsSections.channels,E]);let Ze=(0,V.useCallback)(e=>{r(ie(e)),F(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(ee),F(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await f(m(`/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)},[O?.id]);let et=(0,V.useCallback)(async()=>{if(!O||!P&&K===null)return!1;let e=Be(O);te(!0),G(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...P?{channels:{[e]:P}}:{},...K===null?{}:{bindings:be(w,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return P&&await N(P,!1),await x(),await u.mutate(),F(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{te(!1)}},[O,K,w,u,P,x,N]),tt=(0,V.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?P:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}re(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/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 u.mutate(),await x(),await v(),O?.id===e.id&&(await N(),F(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{re(null)}},[O?.id,u,P,x,N,v,Ze]),$=O?.ui?.modal,at=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!Y(O).ready||de:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,U.jsx)(le,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(it,{entry:e,config:S[Be(e)]?.config,runtime:Ye(e),busy:ne===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void tt(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)(we,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:O?.label??J.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,U.jsx)(De,{ch:J,dirty:!!P||K!==null,saving:L,onCancel:Qe,onDiscard:()=>{F(null),q(null)},onSave:et}):null,children:O?(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)(nt,{entry:O}),(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:O.label}),(0,U.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(ct)),children:Ve(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(O).ready&&me(O)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,U.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(B,{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(O).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(rt,{checked:Y(O).enabled,disabled:ne===O.id,label:J.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void tt(O)})]})]})}),(0,U.jsx)(ot,{runtime:ct,restarting:ce===O.id,checking:y,showConnectionOptions:de,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(st,{entry:O,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:O,locale:e,messages:J,compact:!0,onChanged:async()=>{await N(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(R,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(R,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,at&&ke?(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)(ue,{schema:Te,values:ge,onChange:e=>F(e),disabled:L,labels:X})]}):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)(A,{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)(o,{value:je,options:Ne,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,He||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:L||!T,onChange:e=>q(e)})]})]}),at&&Je(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)(A,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:ge,onChange:e=>F(e),disabled:L,labels:X})})]}):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{ct as ChannelsSettingsPanel};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-BlgpZORR.js";import{t as o}from"./messages-2GhUD7SC.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{M as l,N as u,P as d,ja as f,wc as p}from"./index-BCi8nfxs.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./plus-Q2yW6OE7.js";import{t as i}from"./x-B_N4OPjy.js";import{n as a}from"./locale-store-D6VmRI5e.js";import{t as o}from"./messages-BCqLsIZK.js";import{t as s}from"./button-CS04eWY9.js";import{t as c}from"./skeleton-BwbyijEw.js";import{M as l,N as u,P as d,ja as f,wc as p}from"./index-DhCnwCI9.js";var m=2,h=1,ee=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,te=(e,t)=>{for(var n in t)g(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?_(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&g(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ne=`Terminal input`,re={get:()=>ne,set:e=>ne=e},ie=`Too much output to announce, navigate to rows manually to read`,b={get:()=>ie,set:e=>ie=e};function ae(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function S(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ae(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ce(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function le(e,t,n,r,i){ce(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function C(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function w(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ue=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},de=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},fe=``,pe=` `,me=class e{constructor(){this.fg=0,this.bg=0,this.extended=new he}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},he=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends me{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new he,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?C(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ge=`di$target`,_e=`di$dependencies`,ve=new Map;function ye(e){return e[_e]||[]}function E(e){if(ve.has(e))return ve.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);be(t,e,r)};return t._id=e,ve.set(e,t),t}function be(e,t,n){t[ge]===t?t[_e].push({id:e,index:n}):(t[_e]=[{id:e,index:n}],t[ge]=t)}var D=E(`BufferService`),xe=E(`CoreMouseService`),Se=E(`CoreService`),Ce=E(`CharsetService`),we=E(`InstantiationService`),Te=E(`LogService`),O=E(`OptionsService`),Ee=E(`OscLinkService`),De=E(`UnicodeService`),Oe=E(`DecorationService`),ke=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ae(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ke=v([y(0,D),y(1,O),y(2,Ee)],ke);function Ae(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var je=E(`CharSizeService`),Me=E(`CoreBrowserService`),Ne=E(`MouseService`),Pe=E(`RenderService`),Fe=E(`SelectionService`),Ie=E(`CharacterJoinerService`),Le=E(`ThemeService`),Re=E(`LinkProviderService`),ze=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ge.isErrorNoTelemetry(e)?new Ge(e.message+`
4
4
 
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{a,n as o,r as s}from"./locale-store-BlgpZORR.js";import{t as c}from"./messages-2GhUD7SC.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{t as u}from"./button-CS04eWY9.js";import{r as d}from"./gateway-config-swr-BPsZPoAT.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p,t as m}from"./registry-api-DMW2apOO.js";import{Cc as h,Mc as g,dn as _,fl as v,gi as y,pl as b,tu as x,un as S}from"./index-BCi8nfxs.js";import{n as C,r as w}from"./settings-page-layout-lLvHc-zF.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=l(`settings-agent-defaults`,S),r=l(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[d,h]=(0,E.useState)(!1),[g,v]=(0,E.useState)(``),[b,x]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{h(!0),v(``),x(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await S(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await _({...e.defaults,models:r});await n.mutate(i,!1),x(!0)}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(u,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(f,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(y,{value:o,onChange:e=>{s(e),x(!1)},disabled:d,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(u,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(u,{variant:`primary`,disabled:d||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(u,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=o(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:o}=d(!0),l=n?.payload?.config,[p,m]=(0,E.useState)(!1),[_,y]=(0,E.useState)(``),[S,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{m(!0),y(``);try{await e()}catch(e){y(e instanceof Error?e.message:String(e))}finally{m(!1)}},L=e=>I(async()=>{await a(s(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{y(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){y(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(u,{onClick:()=>{R()},children:[(0,D.jsx)(h,{className:`size-3.5`}),t.stop]})}),_&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:_}),S&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!l&&!o?(0,D.jsx)(f,{className:`h-40 w-full rounded-xl`}):o?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(o),` `,(0,D.jsx)(u,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(v,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":l?.computer?.enabled===!0,disabled:p,onClick:()=>{L(l?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${l?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${l?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.approvals,description:t.approvalsDescription,children:(0,D.jsx)(`span`,{className:`rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.approvalsRequired})}),(0,D.jsx)(k,{icon:(0,D.jsx)(x,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:l?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(u,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{a,n as o,r as s}from"./locale-store-D6VmRI5e.js";import{t as c}from"./messages-BCqLsIZK.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{t as u}from"./button-CS04eWY9.js";import{r as d}from"./gateway-config-swr-DFjsI4QK.js";import{t as f}from"./skeleton-BwbyijEw.js";import{n as p,t as m}from"./registry-api-sOL6E5LU.js";import{Cc as h,Mc as g,dn as _,fl as v,gi as y,pl as b,tu as x,un as S}from"./index-DhCnwCI9.js";import{n as C,r as w}from"./settings-page-layout-OvBOGen7.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=l(`settings-agent-defaults`,S),r=l(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[d,h]=(0,E.useState)(!1),[g,v]=(0,E.useState)(``),[b,x]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{h(!0),v(``),x(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await S(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await _({...e.defaults,models:r});await n.mutate(i,!1),x(!0)}catch(e){v(e instanceof Error?e.message:String(e))}finally{h(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(u,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.modelDescription}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelScope}),r.isLoading?(0,D.jsx)(f,{className:`h-10 w-full rounded-lg`}):(0,D.jsx)(y,{value:o,onChange:e=>{s(e),x(!1)},disabled:d,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[String(r.error),(0,D.jsx)(u,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(u,{variant:`primary`,disabled:d||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel}),(0,D.jsx)(u,{asChild:!0,variant:`ghost`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),b&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:t.modelSaved})]}),g&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:g})]}),(0,D.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:t.modelPrivacy})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface-base/70 text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 p-4 sm:flex-nowrap sm:p-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=o(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:o}=d(!0),l=n?.payload?.config,[p,m]=(0,E.useState)(!1),[_,y]=(0,E.useState)(``),[S,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),P=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,F=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!P)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await P.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[P]);let I=async e=>{m(!0),y(``);try{await e()}catch(e){y(e instanceof Error?e.message:String(e))}finally{m(!1)}},L=e=>I(async()=>{await a(s(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r()}),R=async()=>{y(``),T(!1);try{await P?.stop(),T(!0),P&&j(await P.status())}catch(e){y(e instanceof Error?e.message:String(e))}},z=A?.session?.status??`idle`,B=t.states[z]??z;return(0,D.jsxs)(w,{gap:`gap-7`,children:[(0,D.jsx)(C,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.experimental}),(0,D.jsx)(`span`,{className:`inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview})]}),(0,D.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:t.experimentalDescription})]}),actions:P&&(0,D.jsxs)(u,{onClick:()=>{R()},children:[(0,D.jsx)(h,{className:`size-3.5`}),t.stop]})}),_&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:_}),S&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),A?.controlPaused&&(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-warning-soft p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.pausedNotice}),(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{P&&j(await P.resume()),T(!1)})},children:t.resume})]}),(0,D.jsx)(O,{zh:e}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!l&&!o?(0,D.jsx)(f,{className:`h-40 w-full rounded-xl`}):o?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(o),` `,(0,D.jsx)(u,{onClick:()=>{I(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(v,{className:`size-5`}),title:t.desktop,description:t.desktopDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":l?.computer?.enabled===!0,disabled:p,onClick:()=>{L(l?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${l?.computer?.enabled?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${l?.computer?.enabled?`translate-x-5`:`translate-x-0`}`})})})}),(0,D.jsx)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.approvals,description:t.approvalsDescription,children:(0,D.jsx)(`span`,{className:`rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.approvalsRequired})}),(0,D.jsx)(k,{icon:(0,D.jsx)(x,{className:`size-5`}),title:t.browser,description:(0,D.jsxs)(D.Fragment,{children:[t.browserDescription,(0,D.jsx)(`span`,{className:`mt-1 block text-xs`,children:l?.browser?.enabled?t.browserEnabled:t.browserDisabled})]}),children:(0,D.jsx)(u,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})]}),(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:[t.safety,` `,t.lockedDescription]})]}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),P?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?(0,D.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1 [&>*]:rounded-lg [&>*]:bg-surface-base/45`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,B]}),A.reenrollmentRequired&&(0,D.jsx)(`p`,{className:`mt-1`,children:t.revoked})]}),children:A.reenrollmentRequired&&(0,D.jsx)(u,{disabled:p,onClick:()=>{I(async()=>{j(await P.reenroll())})},children:t.reenroll})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(g,{className:`size-5`}),title:t.accessibility,description:t.accessibilityDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{I(()=>F.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(b,{className:`size-5`}),title:t.screen,description:t.screenDescription,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(u,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{I(()=>F.requestScreen())},children:t.openSettings})]})]})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(f,{className:`h-52 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};
@@ -1 +1 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./x-B_N4OPjy.js";import{n as s}from"./locale-store-BlgpZORR.js";import{t as c}from"./messages-2GhUD7SC.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CS04eWY9.js";import{t as y}from"./skeleton-BwbyijEw.js";import{No as b,Qo as x,ls as S,sa as C,vs as w,wt as T,xs as E}from"./index-BCi8nfxs.js";var D=t({ConnectorServiceDialog:()=>F,ConnectorServicePage:()=>j}),O=r(),k=e(n(),1),A=i();function j(){let e=(0,O.c)(11),t=s(M),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,A.jsx)(a,{to:`/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,A.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),f=(0,A.jsx)(L,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,A.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function M(e){return e.language}function N(){let e=(0,O.c)(2),t=s(P)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,A.jsx)(A.Fragment,{children:t}),e[0]=t,e[1]=n),n}function P(e){return e.language}function F(){let e=(0,O.c)(22),t=s(I),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,a=i?`应用连接服务`:`Connection service`,_;e[2]===a?_=e[3]:(_=(0,A.jsx)(u,{asChild:!0,children:(0,A.jsx)(v,{type:`button`,variant:`secondary`,className:`shrink-0`,children:a})}),e[2]=a,e[3]=_);let y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),e[4]=y):y=e[4];let b=i?`应用连接服务`:`App connection service`,x;e[5]===b?x=e[6]:(x=(0,A.jsx)(h,{className:`text-base font-semibold text-fg`,children:b}),e[5]=b,e[6]=x);let S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,A.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),e[7]=S):S=e[7];let C;e[8]===x?C=e[9]:(C=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),e[8]=x,e[9]=C);let w;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,A.jsx)(o,{className:`size-5`,"aria-hidden":!0}),e[10]=w):w=e[10];let T;e[11]===r.modalClose?T=e[12]:(T=(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(v,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":r.modalClose,children:w})}),e[11]=r.modalClose,e[12]=T);let E;e[13]!==C||e[14]!==T?(E=(0,A.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[C,T]}),e[13]=C,e[14]=T,e[15]=E):E=e[15];let D;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,A.jsx)(L,{})}),e[16]=D):D=e[16];let k;e[17]===E?k=e[18]:(k=(0,A.jsxs)(p,{children:[y,(0,A.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[E,D]})]}),e[17]=E,e[18]=k);let j;return e[19]!==k||e[20]!==_?(j=(0,A.jsxs)(g,{children:[_,k]}),e[19]=k,e[20]=_,e[21]=j):j=e[21],j}function I(e){return e.language}function L(){let e=s(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,S),[o,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(),[m,h]=(0,k.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,A.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,A.jsx)(y,{className:`h-40 w-full`}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,A.jsx)(T,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,A.jsx)(v,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>E({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,A.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,A.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,A.jsx)(`li`,{children:t.composioSetupStepProject}),(0,A.jsx)(`li`,{children:t.composioSetupStepKey}),(0,A.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,A.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,A.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,A.jsx)(`span`,{children:`Composio API key`}),(0,A.jsx)(b,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,A.jsx)(v,{disabled:u||!o.trim(),onClick:()=>void g(()=>x(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{children:e.label}),(0,A.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>x(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>E({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,A.jsx)(C,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>w(e))}})]})}export{D as n,F as t};
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{t as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./x-B_N4OPjy.js";import{n as s}from"./locale-store-D6VmRI5e.js";import{t as c}from"./messages-BCqLsIZK.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-BGTk37IG.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-CS04eWY9.js";import{t as y}from"./skeleton-BwbyijEw.js";import{No as b,Qo as x,ls as S,sa as C,vs as w,wt as T,xs as E}from"./index-DhCnwCI9.js";var D=t({ConnectorServiceDialog:()=>F,ConnectorServicePage:()=>j}),O=r(),k=e(n(),1),A=i();function j(){let e=(0,O.c)(11),t=s(M),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,o;e[2]===r.title?o=e[3]:(o=(0,A.jsx)(a,{to:`/connectors`,className:`text-sm text-accent-fg`,children:r.title}),e[2]=r.title,e[3]=o);let l=i?`应用连接服务`:`App connection service`,u;e[4]===l?u=e[5]:(u=(0,A.jsx)(`h1`,{className:`text-xl font-semibold`,children:l}),e[4]=l,e[5]=u);let d,f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),f=(0,A.jsx)(L,{}),e[6]=d,e[7]=f):(d=e[6],f=e[7]);let p;return e[8]!==o||e[9]!==u?(p=(0,A.jsxs)(`main`,{className:`mx-auto w-full max-w-2xl space-y-6 p-6`,children:[o,u,d,f]}),e[8]=o,e[9]=u,e[10]=p):p=e[10],p}function M(e){return e.language}function N(){let e=(0,O.c)(2),t=s(P)===`zh`?`此设置决定新账号通过哪个服务连接。已有账号继续使用其原来的连接服务。`:`Choose the service for new accounts. Existing accounts keep their original service.`,n;return e[0]===t?n=e[1]:(n=(0,A.jsx)(A.Fragment,{children:t}),e[0]=t,e[1]=n),n}function P(e){return e.language}function F(){let e=(0,O.c)(22),t=s(I),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.connectorsSettings,i=t===`zh`,a=i?`应用连接服务`:`Connection service`,_;e[2]===a?_=e[3]:(_=(0,A.jsx)(u,{asChild:!0,children:(0,A.jsx)(v,{type:`button`,variant:`secondary`,className:`shrink-0`,children:a})}),e[2]=a,e[3]=_);let y;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,A.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),e[4]=y):y=e[4];let b=i?`应用连接服务`:`App connection service`,x;e[5]===b?x=e[6]:(x=(0,A.jsx)(h,{className:`text-base font-semibold text-fg`,children:b}),e[5]=b,e[6]=x);let S;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,A.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:(0,A.jsx)(N,{})}),e[7]=S):S=e[7];let C;e[8]===x?C=e[9]:(C=(0,A.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),e[8]=x,e[9]=C);let w;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,A.jsx)(o,{className:`size-5`,"aria-hidden":!0}),e[10]=w):w=e[10];let T;e[11]===r.modalClose?T=e[12]:(T=(0,A.jsx)(f,{asChild:!0,children:(0,A.jsx)(v,{variant:`ghost`,className:`shrink-0 p-1.5`,"aria-label":r.modalClose,children:w})}),e[11]=r.modalClose,e[12]=T);let E;e[13]!==C||e[14]!==T?(E=(0,A.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[C,T]}),e[13]=C,e[14]=T,e[15]=E):E=e[15];let D;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,A.jsx)(L,{})}),e[16]=D):D=e[16];let k;e[17]===E?k=e[18]:(k=(0,A.jsxs)(p,{children:[y,(0,A.jsxs)(m,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100dvh-2rem,42rem)] w-[min(100%-2rem,42rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-float`,children:[E,D]})]}),e[17]=E,e[18]=k);let j;return e[19]!==k||e[20]!==_?(j=(0,A.jsxs)(g,{children:[_,k]}),e[19]=k,e[20]=_,e[21]=j):j=e[21],j}function I(e){return e.language}function L(){let e=s(e=>e.language),t=c(e).connectorsSettings,n=e===`zh`,{data:r,error:i,mutate:a}=_(`connector-service`,S),[o,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(),[m,h]=(0,k.useState)();async function g(e){d(!0),p(void 0);try{await e(),l(``),await a()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}return(0,A.jsxs)(`div`,{className:`space-y-6`,children:[!r&&!i?(0,A.jsx)(y,{className:`h-40 w-full`}):null,r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h2`,{className:`font-medium`,children:`XOPC Cloud`}),(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioSetupHint}),(0,A.jsx)(T,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:r.mode===`managed`&&r.configured,onConnected:()=>{a()}}),(0,A.jsx)(v,{variant:`secondary`,disabled:u||r.mode===`managed`&&r.configured,onClick:()=>void g(()=>E({mode:`managed`})),children:r.mode===`managed`?n?`当前服务`:`Current service`:n?`使用 XOPC Cloud`:`Use XOPC Cloud`})]}),(0,A.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:t.composioSetupByok}),(0,A.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,A.jsxs)(`ol`,{className:`list-inside list-decimal text-sm text-fg-muted`,children:[(0,A.jsx)(`li`,{children:t.composioSetupStepProject}),(0,A.jsx)(`li`,{children:t.composioSetupStepKey}),(0,A.jsx)(`li`,{children:t.composioSetupStepPaste})]}),(0,A.jsx)(`a`,{href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,className:`text-sm text-accent-fg`,children:t.composioSetupOpenDashboard}),(0,A.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,A.jsx)(`span`,{children:`Composio API key`}),(0,A.jsx)(b,{value:o,onChange:l,labels:t.secretInputLabels,placeholder:t.composioSetupKeyPlaceholder})]}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSetupStorageHint}),(0,A.jsx)(v,{disabled:u||!o.trim(),onClick:()=>void g(()=>x(o)),children:n?`验证并使用新项目`:`Verify and use new project`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n?`验证只检查连接服务和现有账号访问,不执行写入。工具权限在实际使用时检查。环境变量密钥需在运行环境中修改。`:`Verification checks service and existing account access without writes. Tool permissions are checked on use. Environment keys must be updated in the gateway environment.`}),(0,A.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioSessionWritePermissionHint}),r.backends?.filter(e=>e.mode===`byok`).map(e=>(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{children:e.label}),(0,A.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.credentialSource===`environment`?n?`环境变量`:`Environment`:n?`本地保存`:`Stored locally`,e.verifiedAt&&` · ${new Date(e.verifiedAt).toLocaleString()}`]})]}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||!o.trim()||e.credentialSource===`environment`,onClick:()=>void g(()=>x(o,e.id)),children:n?`用上方密钥更新`:`Update with key above`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>void g(()=>E({backendId:e.id})),children:e.id===r.backendId?n?`当前服务`:`Current service`:n?`使用`:`Use`}),(0,A.jsx)(v,{variant:`ghost`,disabled:u||e.id===r.backendId,onClick:()=>h(e.id),children:n?`移除`:`Remove`})]},e.id))]})]})]}):null,f||i?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:f??String(i)}):null,(0,A.jsx)(C,{open:!!m,title:n?`移除连接服务`:`Remove connection service`,description:n?`移除此服务及其本地保存的密钥,不修改环境变量。需要先切换服务并断开该项目的账号,已有数据不会删除。`:`Remove this service and its saved key, without changing environment variables. Switch services and disconnect this project’s accounts first. Existing data is retained.`,confirmLabel:n?`移除`:`Remove`,cancelLabel:t.modalCancel,destructive:!0,onCancel:()=>h(void 0),onConfirm:()=>{let e=m;h(void 0),e&&g(()=>w(e))}})]})}export{D as n,F as t};