@xopcai/xopc 0.0.203 → 0.0.205

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 (108) 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/{activity-store-SZAay-ze.js → activity-store-DJBadfSX.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DPLJtxoS.js → agent-avatar-dicebear-Br6C32BX.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-DyjRuuRa.js → agents-DnFIy8Ye.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-C1cSt2ru.js → api-B5O7fKXa.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-B3PCMqor.js → app-management-settings-panel-Le1vJ1OO.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-txSx3REK.js → appearance-settings-CZlAU60t.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-BEhBaooZ.js → apps-page-CONlVc-f.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-B2VVc17j.js → archive-plugin-CRzXRXPE.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Crk7x8qR.js → attachment-load-CYAAQ6Qi.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-BUC6FL6O.js → automations-page-DuG69tIj.js} +1 -1
  13. package/dist/gateway/static/root/assets/{binary-plugins-CLlJsq5D.js → binary-plugins-CVR5cUmS.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-cJ5lVNAG.js → block-editor-CFe74rWi.js} +1 -1
  15. package/dist/gateway/static/root/assets/browser-settings-page-Cvt-8fqE.js +8 -0
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-WRiFG88u.js → browser-workflow-inputs-Bd68yluo.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-BHLdVoOC.js → browser-workflows-page-B0uiDLga.js} +1 -1
  18. package/dist/gateway/static/root/assets/capabilities-settings-panel-yk3QkGBP.js +7 -0
  19. package/dist/gateway/static/root/assets/{capability-presets-api-DmElfgC9.js → capability-presets-api-BerPMp6f.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CYlZQpLY.js → capability-presets-settings-panel-DJjVOCJY.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-BUEOtPft.js → channel-recipient-api-D2d21_XA.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-DlDiCMhO.js → channels-settings-CaNnYUQo.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-status-swr-CZ5P9jbB.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-api-BCdn44_o.js → connectors-api-Bq_vUzxP.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connectors-page-Ce-eaPHw.js → connectors-page-DTpCnOsQ.js} +1 -1
  26. package/dist/gateway/static/root/assets/{cron-expression-D2hF3t68.js → cron-expression-DZBxmKGR.js} +1 -1
  27. package/dist/gateway/static/root/assets/{date-picker-Dvjoq2mB.js → date-picker-BNHd7HT7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dependency-picker-zv1OIhk3.js → dependency-picker-D1kJBknt.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-DJZhKLTb.js → desktop-pet-Di75oHkC.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-B3ubM-eY.js → desktop-pet-settings-D6tD1uym.js} +1 -1
  31. package/dist/gateway/static/root/assets/{directory-picker-path-field-BZEJIWOT.js → directory-picker-path-field-Ly0TUflq.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-debug-page-Bvq3E1A1.js → extension-debug-page-D91_S7NQ.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-page-CuCJjWNm.js → extension-page-DHzmmr_N.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-settings-page-CpTk_ajr.js → extension-settings-page-BpJNtePi.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-config-api-C2yM6qj7.js → gateway-config-api-BAzLYTKZ.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-CN-JHMAh.js → gateway-config-swr-VVcfd3sG.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-COwi--2Q.js → gateway-settings-C5-aKkTp.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-Dq1RyCjz.js → gateway-startup-retry-qAX_T2t2.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-Dc6H4VGF.js → heartbeat-settings-CMZr1_Op.js} +1 -1
  40. package/dist/gateway/static/root/assets/{home-page-BB3RGxwm.js → home-page-CBG9Bk-1.js} +1 -1
  41. package/dist/gateway/static/root/assets/index-BBw9QL0p.js +85 -0
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-cue30Z5p.js → keyboard-shortcuts-settings-fpNjXnJK.js} +1 -1
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-Bi_0Sknt.js +2 -0
  44. package/dist/gateway/static/root/assets/{local-apps-page-DKQSCsa0.js → local-apps-page-DBpQIfNd.js} +1 -1
  45. package/dist/gateway/static/root/assets/{locale-store-81Gv0wwo.js → locale-store-CbPVxonP.js} +1 -1
  46. package/dist/gateway/static/root/assets/{logs-page-DODbODyl.js → logs-page-BmXcJCKz.js} +1 -1
  47. package/dist/gateway/static/root/assets/{management-settings--4H26QR-.js → management-settings-CiK7Xkvi.js} +1 -1
  48. package/dist/gateway/static/root/assets/{markdown-split-BTvpyjAi.js → markdown-split-DVgpcOze.js} +1 -1
  49. package/dist/gateway/static/root/assets/{markdown-view-B4iBrVWK.js → markdown-view-Dl-0_9JR.js} +1 -1
  50. package/dist/gateway/static/root/assets/{media-plugins-DrejWl8t.js → media-plugins-DMj1lW-n.js} +1 -1
  51. package/dist/gateway/static/root/assets/{messages-ELK_1h2D.js → messages-9zCa8KkW.js} +2 -2
  52. package/dist/gateway/static/root/assets/{notes-page-DfSzeQKd.js → notes-page-DvX1sTlf.js} +1 -1
  53. package/dist/gateway/static/root/assets/{notes-workbench-DxL4GhwV.js → notes-workbench-CMyosgjY.js} +2 -2
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-yjh1_7K3.js → preview-open-alternatives-DvsLigha.js} +1 -1
  55. package/dist/gateway/static/root/assets/{product-open-page-DopWBJLa.js → product-open-page-DbCraAI3.js} +1 -1
  56. package/dist/gateway/static/root/assets/{project-detail-page-Bl3LJHZB.js → project-detail-page-DkS-kbpj.js} +1 -1
  57. package/dist/gateway/static/root/assets/{projects-page-DStOErTC.js → projects-page-B3NxP6S4.js} +1 -1
  58. package/dist/gateway/static/root/assets/remote-access-hub-DwhrMhjl.js +1 -0
  59. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-_dHhbYV2.js → runtime-tools-settings-panel-DzuUglQo.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-DZhORvJZ.js → schema-form-plDnazVj.js} +1 -1
  61. package/dist/gateway/static/root/assets/{sessions-page-DDY21KYw.js → sessions-page-BOfXXmBL.js} +1 -1
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-sPrZfZVR.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-form-section-Du5eAgFS.js → settings-form-section-BwAxX_7e.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DWS27sv1.js → settings-loading-skeleton-B3OiTnF9.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-DPD0MwoN.js → settings-page-DvIWXBvp.js} +1 -1
  66. package/dist/gateway/static/root/assets/{setup-status-panel-CnXN4LH_.js → setup-status-panel-DThKKjLV.js} +1 -1
  67. package/dist/gateway/static/root/assets/{share-preview-page-D6HmH2ga.js → share-preview-page-CFnoGHJb.js} +1 -1
  68. package/dist/gateway/static/root/assets/shares-settings-Dvl13Udt.js +1 -0
  69. package/dist/gateway/static/root/assets/skill-reload-api-D9elkZOz.js +1 -0
  70. package/dist/gateway/static/root/assets/{skills-page-XVO7d3fh.js → skills-page-B38fY22S.js} +1 -1
  71. package/dist/gateway/static/root/assets/{skills-page.utils-DwxIpWrI.js → skills-page.utils-vLIlk1c3.js} +1 -1
  72. package/dist/gateway/static/root/assets/{system-settings-panel-BmKbxR8_.js → system-settings-panel-DRV2wljT.js} +1 -1
  73. package/dist/gateway/static/root/assets/{task-detail-page-DA6ItYrc.js → task-detail-page-Xd8PlB24.js} +1 -1
  74. package/dist/gateway/static/root/assets/{theme-store-hOF81tUQ.js → theme-store-Bc_eRUev.js} +1 -1
  75. package/dist/gateway/static/root/assets/{use-autosave-GJfDpf66.js → use-autosave-DTu23D9J.js} +1 -1
  76. package/dist/gateway/static/root/assets/{user-context-page-CQ1QrRE6.js → user-context-page-DCwqzN03.js} +1 -1
  77. package/dist/gateway/static/root/assets/{voice-api-key-field-B0zve9EE.js → voice-api-key-field-CVDMesWc.js} +1 -1
  78. package/dist/gateway/static/root/assets/{work-discovery-overlay-DrIbHnBz.js → work-discovery-overlay-cyt93k0V.js} +1 -1
  79. package/dist/gateway/static/root/assets/{work-discovery-page-CQW8pPec.js → work-discovery-page--DTi90d5.js} +1 -1
  80. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D-_zQxim.js → workflow-run-setup-panel-DrdcfX_N.js} +2 -2
  81. package/dist/gateway/static/root/assets/workflows-page-DXyButkm.js +5 -0
  82. package/dist/gateway/static/root/assets/{working-directory-picker-modal-5xYx48tV.js → working-directory-picker-modal-CYWdZUJ5.js} +1 -1
  83. package/dist/gateway/static/root/index.html +9 -9
  84. package/dist/package.js +1 -1
  85. package/dist/packages/realtime-client/src/index.js +11 -7
  86. package/dist/src/agent/memory/compaction-planner.js +20 -4
  87. package/dist/src/agent/memory/compaction.js +31 -4
  88. package/dist/src/config/agent-profile.js +1 -1
  89. package/dist/src/gateway/agents-admin.js +1 -1
  90. package/dist/src/gateway/chat-stream/mapper.js +44 -4
  91. package/dist/src/gateway/service.js +5 -5
  92. package/dist/src/providers/index.js +5 -4
  93. package/dist/src/providers/model-call.js +2 -2
  94. package/dist/src/providers/model-supplements.d.ts +2 -0
  95. package/dist/src/providers/model-supplements.js +23 -2
  96. package/dist/src/realtime/runtime.js +9 -2
  97. package/dist/src/realtime/writer.js +5 -0
  98. package/package.json +3 -3
  99. package/dist/gateway/static/root/assets/browser-settings-page-Bq2m4VpX.js +0 -8
  100. package/dist/gateway/static/root/assets/capabilities-settings-panel-BiQbVvYU.js +0 -7
  101. package/dist/gateway/static/root/assets/channels-status-swr-Dm_-934M.js +0 -1
  102. package/dist/gateway/static/root/assets/index-CPTLS-Zn.js +0 -85
  103. package/dist/gateway/static/root/assets/local-app-workbench-page-DfO6FOB9.js +0 -2
  104. package/dist/gateway/static/root/assets/remote-access-hub-C_hh9ztK.js +0 -1
  105. package/dist/gateway/static/root/assets/settings-advanced-gate-BJrHIcw8.js +0 -1
  106. package/dist/gateway/static/root/assets/shares-settings-U3lvtO3Y.js +0 -1
  107. package/dist/gateway/static/root/assets/skill-reload-api-B6GiZgZU.js +0 -1
  108. package/dist/gateway/static/root/assets/workflows-page-O21l_f5c.js +0 -5
@@ -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{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{i as o,t as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./interaction-BmQogeqz.js";import{t as m}from"./messages-ELK_1h2D.js";import{l as h,n as g,o as _,r as v,s as y}from"./locale-store-81Gv0wwo.js";import{i as b,o as x}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BPoKqzeH.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{Aa as A,An as j,Es as M,Fi as N,Is as P,Ms as F,Va as ee,Xn as I,Yn as L,Zn as R,ai as z,bl as B,is as te,ja as ne,ka as re,ps as ie,vl as ae}from"./index-CPTLS-Zn.js";import{n as oe,r as se}from"./settings-page-layout-BRQNel6r.js";import{n as ce}from"./settings-loading-skeleton-DWS27sv1.js";import{t as le}from"./schema-form-DZhORvJZ.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-Dm_-934M.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await _(v(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),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]),[s,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 p=(0,V.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(s.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),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let m=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=G(s.payload),_=K(s.payload,e.id),v=_?s.generatedQr:q(s.payload),y=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),b=s.payload?.type===`form`?s.payload:null,x=s.payload?.type===`diagnostics`?s.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:d(`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)(f,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(a[0]),children:[s.busy?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),m]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(f,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void p(`doctor.run`),children:[(0,U.jsx)(ie,{className:`size-4`}),h]}):null]})]}),g?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,s.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,y?(0,U.jsxs)(`div`,{className:d(`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:v?(0,U.jsx)(`img`,{src:v,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)(A,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:d(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(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)(A,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),_?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.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)(ae,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:s.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,U.jsx)(f,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(b.submitAction,s.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?d(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,b):d(`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)]`,b,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:m,children:h,footer:g,wide:_,headerExtra:v}=e,y=_===void 0?!1:_,b=n===`drawer`,[k,A]=(0,V.useState)(null),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,U.jsx)(S,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=j):j=t[0];let M;t[1]!==n||t[2]!==y?(M=Se(n,y),t[1]=n,t[2]=y,t[3]=M):M=t[3];let N;t[4]===c?N=t[5]:(N=c?(0,U.jsx)(D,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=N);let P;t[6]===l?P=t[7]:(P=l?(0,U.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=P);let F;t[8]!==m||t[9]!==s||t[10]!==v||t[11]!==b||t[12]!==a?(F=b?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":m,children:(0,U.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:d(p,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":m,children:(0,U.jsx)(u,{className:`size-4`})})}),v]}),t[8]=m,t[9]=s,t[10]=v,t[11]=b,t[12]=a,t[13]=F):F=t[13];let ee=b?`p-4`:`p-6`,I;t[14]===ee?I=t[15]:(I=d(`min-h-0 flex-1 overflow-y-auto`,ee),t[14]=ee,t[15]=I);let L;t[16]!==h||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:h}),t[16]=h,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==g||t[20]!==k||t[21]!==N||t[22]!==P||t[23]!==F||t[24]!==L?(R=(0,U.jsxs)(o,{layer:`modal`,portalContainer:k,children:[N,P,F,L,g]}),t[19]=g,t[20]=k,t[21]=N,t[22]=P,t[23]=F,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==M?(z=(0,U.jsxs)(T,{children:[j,(0,U.jsx)(E,{ref:A,className:M,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=M,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(O,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(N,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(f,{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 p=!r||i,m;t[7]!==n.discard||t[8]!==o||t[9]!==p?(m=(0,U.jsx)(f,{type:`button`,variant:`secondary`,disabled:p,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==h||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(f,{type:`button`,variant:`primary`,disabled:h,onClick:g,children:_}),t[13]=h,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==m||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,m,v]}),t[17]=d,t[18]=m,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(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,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function De(e){return v(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await y(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=k(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?v(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await y(v(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await y(v(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=h(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(v(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function nt(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`,l;t[2]!==s||t[3]!==c?(l=d(`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]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===u?f=t[6]:(f=d(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,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]!==l||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:p}=e,m;t[0]===n?m=t[1]:(m=Y(n),t[0]=n,t[1]=m);let h=m,g,_,v,y,b,x,S;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==p||t[8]!==u||t[9]!==i||t[10]!==h.enabled||t[11]!==h.ready){let e=Xe(n,r,s),o=$e(n,s);g=!h.enabled&&h.ready?u:i===`stopped`?p:c,x=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let l;t[19]===n?l=t[20]:(l=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=l);let f;t[21]===n.label?f=t[22]:(f=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=f);let m;t[23]===i?m=t[24]:(m=d(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=m);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==m||t[29]!==C?(w=(0,U.jsx)(`span`,{className:m,children:C}),t[28]=m,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==f?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[f,w]}),t[31]=w,t[32]=f,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==l?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[l,T]}),t[34]=T,t[35]=l,t[36]=E):E=t[36];let D=h.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]!==h.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=h.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(S=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=S):S=t[47],_=`button`,v=c,y=`mt-5 min-h-[6.25rem] text-left`,b=h.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=p,t[8]=u,t[9]=i,t[10]=h.enabled,t[11]=h.ready,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18];let C;t[48]!==_||t[49]!==v||t[50]!==y||t[51]!==b?(C=(0,U.jsx)(`button`,{type:_,onClick:v,className:y,children:b}),t[48]=_,t[49]=v,t[50]=y,t[51]=b,t[52]=C):C=t[52];let w=a||o,T;t[53]!==a||t[54]!==o?(T=a||o?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=T):T=t[55];let E;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(E=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=E):E=t[60];let D;t[61]!==g||t[62]!==T||t[63]!==E||t[64]!==w?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:g,disabled:w,children:[T,E]})}),t[61]=g,t[62]=T,t[63]=E,t[64]=w,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==x||t[68]!==S||t[69]!==C?(O=(0,U.jsxs)(`article`,{className:x,children:[S,C,D]}),t[66]=D,t[67]=x,t[68]=S,t[69]=C,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:u,onManageConnection:p}=e,m=n===`running`?ae:n===`stopped`||n===`needs_setup`?B:l,h=n===`running`&&`text-emerald-600 dark:text-emerald-400`,g=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==h||t[1]!==g||t[2]!==_||t[3]!==v||t[4]!==y?(b=d(`mt-0.5 size-5 shrink-0`,h,g,_,v,y),t[0]=h,t[1]=g,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==m||t[7]!==b?(x=(0,U.jsx)(m,{className:b}),t[6]=m,t[7]=b,t[8]=x):x=t[8];let S;t[9]===s.connectionStatus?S=t[10]:(S=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=S);let C;t[11]!==s||t[12]!==n?(C=Ve(n,s),t[11]=s,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,U.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,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?s.checkingConnection:s.checkConnection,A;t[24]!==u||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(f,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:u,children:[O,k]}),t[24]=u,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(f,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(F,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==p||t[41]!==r||t[42]!==a?(M=o?(0,U.jsx)(f,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:p,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=p,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(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,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(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:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=g(e=>e.language),t=m(e),n=h(e=>!!e.token),r=a(),{channelId:o}=i(),l=R(o),u=ke(n,e),f=u.entries,{data:p,mutate:y,isValidating:b}=k(n?fe():null,de,{revalidateOnFocus:!0}),{data:x,mutate:S}=k(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:T}=k(n?`channel-routing-agents`:null,re,{revalidateOnFocus:!1}),E=ee(e=>e.setPageHeader),D=ee(e=>e.clearPageHeader),O=(0,V.useMemo)(()=>f.find(e=>e.id===l),[l,f]),A=O?ze(O):null,{data:N,mutate:P}=k(n&&A?Pe(A):null,()=>Fe(A)),[F,B]=(0,V.useState)(null),[te,ne]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=F??N??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(O),[O]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=O?K??ve(w,O.id):``,Re=(0,V.useMemo)(()=>(T?.items??[]).map(e=>{let n=j(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),Ve=T?.items.find(e=>e.id===T.defaultId),X=Ve?j(Ve,t.agentsSettings):T?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((p??[]).map(e=>[e.name,e])),[p]),Je=p!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),y()])},[u,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:u.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,b,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(I(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(L),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await _(v(`/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||!F&&K===null)return!1;let e=ze(O);ne(!0),G(null);try{let t=await _(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({...F?{channels:{[e]:F}}:{},...K===null?{}:{bindings:ye(w,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return F&&await P(F,!1),await S(),await u.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,K,w,u,F,S,P]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=O?.id===e.id?F:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await _(v(`/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 S(),await y(),O?.id===e.id&&(await P(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,u,F,S,P,y,Ze]),$=O?.ui?.modal,st=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!Y(O).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[u.isLoading?(0,U.jsx)(ce,{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:f.map(e=>(0,U.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:O?.label??J.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,U.jsx)(Ee,{ch:J,dirty:!!F||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(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)(tt,{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:d(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&pe(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)(c,{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)(nt,{checked:Y(O).enabled,disabled:ie===O.id,label:J.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void it(O)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===O.id,checking:b,showConnectionOptions:me,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:O,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:O,locale:e,messages:J,compact:!0,onChanged:async()=>{await P(),await Q(),await S()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(z,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(z,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>B(e),disabled:te,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(M,{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)(s,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!T,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(M,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>B(e),disabled:te,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{i as o,t as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./interaction-BmQogeqz.js";import{t as m}from"./messages-9zCa8KkW.js";import{l as h,n as g,o as _,r as v,s as y}from"./locale-store-CbPVxonP.js";import{i as b,o as x}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BPoKqzeH.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{Aa as A,An as j,Es as M,Fi as N,Is as P,Ms as F,Va as ee,Xn as I,Yn as L,Zn as R,bl as z,ii as B,is as te,ja as ne,ka as re,ps as ie,vl as ae}from"./index-BBw9QL0p.js";import{n as oe,r as se}from"./settings-page-layout-BRQNel6r.js";import{n as ce}from"./settings-loading-skeleton-B3OiTnF9.js";import{t as le}from"./schema-form-plDnazVj.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-CZ5P9jbB.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await _(v(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),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]),[s,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 p=(0,V.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(s.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),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let m=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=G(s.payload),_=K(s.payload,e.id),v=_?s.generatedQr:q(s.payload),y=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),b=s.payload?.type===`form`?s.payload:null,x=s.payload?.type===`diagnostics`?s.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:d(`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)(f,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(a[0]),children:[s.busy?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),m]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(f,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void p(`doctor.run`),children:[(0,U.jsx)(ie,{className:`size-4`}),h]}):null]})]}),g?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,s.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,y?(0,U.jsxs)(`div`,{className:d(`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:v?(0,U.jsx)(`img`,{src:v,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)(A,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:d(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(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)(A,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),_?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.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)(ae,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:s.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,U.jsx)(f,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void p(b.submitAction,s.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?d(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,b):d(`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)]`,b,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:m,children:h,footer:g,wide:_,headerExtra:v}=e,y=_===void 0?!1:_,b=n===`drawer`,[k,A]=(0,V.useState)(null),j;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,U.jsx)(S,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=j):j=t[0];let M;t[1]!==n||t[2]!==y?(M=Se(n,y),t[1]=n,t[2]=y,t[3]=M):M=t[3];let N;t[4]===c?N=t[5]:(N=c?(0,U.jsx)(D,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=N);let P;t[6]===l?P=t[7]:(P=l?(0,U.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=P);let F;t[8]!==m||t[9]!==s||t[10]!==v||t[11]!==b||t[12]!==a?(F=b?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":m,children:(0,U.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(w,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:d(p,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":m,children:(0,U.jsx)(u,{className:`size-4`})})}),v]}),t[8]=m,t[9]=s,t[10]=v,t[11]=b,t[12]=a,t[13]=F):F=t[13];let ee=b?`p-4`:`p-6`,I;t[14]===ee?I=t[15]:(I=d(`min-h-0 flex-1 overflow-y-auto`,ee),t[14]=ee,t[15]=I);let L;t[16]!==h||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:h}),t[16]=h,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==g||t[20]!==k||t[21]!==N||t[22]!==P||t[23]!==F||t[24]!==L?(R=(0,U.jsxs)(o,{layer:`modal`,portalContainer:k,children:[N,P,F,L,g]}),t[19]=g,t[20]=k,t[21]=N,t[22]=P,t[23]=F,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==M?(z=(0,U.jsxs)(T,{children:[j,(0,U.jsx)(E,{ref:A,className:M,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=M,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(O,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(N,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(f,{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 p=!r||i,m;t[7]!==n.discard||t[8]!==o||t[9]!==p?(m=(0,U.jsx)(f,{type:`button`,variant:`secondary`,disabled:p,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!r||i,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==h||t[14]!==g||t[15]!==_?(v=(0,U.jsx)(f,{type:`button`,variant:`primary`,disabled:h,onClick:g,children:_}),t[13]=h,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==m||t[19]!==v?(y=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,m,v]}),t[17]=d,t[18]=m,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(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,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function De(e){return v(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await y(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=k(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?v(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await y(v(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await y(v(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=h(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(v(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function nt(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`,l;t[2]!==s||t[3]!==c?(l=d(`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]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===u?f=t[6]:(f=d(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,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]!==l||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:p}=e,m;t[0]===n?m=t[1]:(m=Y(n),t[0]=n,t[1]=m);let h=m,g,_,v,y,b,x,S;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==p||t[8]!==u||t[9]!==i||t[10]!==h.enabled||t[11]!==h.ready){let e=Xe(n,r,s),o=$e(n,s);g=!h.enabled&&h.ready?u:i===`stopped`?p:c,x=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let l;t[19]===n?l=t[20]:(l=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=l);let f;t[21]===n.label?f=t[22]:(f=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=f);let m;t[23]===i?m=t[24]:(m=d(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=m);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==m||t[29]!==C?(w=(0,U.jsx)(`span`,{className:m,children:C}),t[28]=m,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==f?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[f,w]}),t[31]=w,t[32]=f,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==l?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[l,T]}),t[34]=T,t[35]=l,t[36]=E):E=t[36];let D=h.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]!==h.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=h.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(S=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=S):S=t[47],_=`button`,v=c,y=`mt-5 min-h-[6.25rem] text-left`,b=h.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=p,t[8]=u,t[9]=i,t[10]=h.enabled,t[11]=h.ready,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x,t[18]=S}else g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17],S=t[18];let C;t[48]!==_||t[49]!==v||t[50]!==y||t[51]!==b?(C=(0,U.jsx)(`button`,{type:_,onClick:v,className:y,children:b}),t[48]=_,t[49]=v,t[50]=y,t[51]=b,t[52]=C):C=t[52];let w=a||o,T;t[53]!==a||t[54]!==o?(T=a||o?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=T):T=t[55];let E;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(E=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=E):E=t[60];let D;t[61]!==g||t[62]!==T||t[63]!==E||t[64]!==w?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:g,disabled:w,children:[T,E]})}),t[61]=g,t[62]=T,t[63]=E,t[64]=w,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==x||t[68]!==S||t[69]!==C?(O=(0,U.jsxs)(`article`,{className:x,children:[S,C,D]}),t[66]=D,t[67]=x,t[68]=S,t[69]=C,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:u,onManageConnection:p}=e,m=n===`running`?ae:n===`stopped`||n===`needs_setup`?z:l,h=n===`running`&&`text-emerald-600 dark:text-emerald-400`,g=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==h||t[1]!==g||t[2]!==_||t[3]!==v||t[4]!==y?(b=d(`mt-0.5 size-5 shrink-0`,h,g,_,v,y),t[0]=h,t[1]=g,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==m||t[7]!==b?(x=(0,U.jsx)(m,{className:b}),t[6]=m,t[7]=b,t[8]=x):x=t[8];let S;t[9]===s.connectionStatus?S=t[10]:(S=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=S);let C;t[11]!==s||t[12]!==n?(C=Ve(n,s),t[11]=s,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,U.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,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?s.checkingConnection:s.checkConnection,A;t[24]!==u||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(f,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:u,children:[O,k]}),t[24]=u,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(f,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(F,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==p||t[41]!==r||t[42]!==a?(M=o?(0,U.jsx)(f,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:p,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=p,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(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,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(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:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=g(e=>e.language),t=m(e),n=h(e=>!!e.token),r=a(),{channelId:o}=i(),l=R(o),u=ke(n,e),f=u.entries,{data:p,mutate:y,isValidating:b}=k(n?fe():null,de,{revalidateOnFocus:!0}),{data:x,mutate:S}=k(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:T}=k(n?`channel-routing-agents`:null,re,{revalidateOnFocus:!1}),E=ee(e=>e.setPageHeader),D=ee(e=>e.clearPageHeader),O=(0,V.useMemo)(()=>f.find(e=>e.id===l),[l,f]),A=O?ze(O):null,{data:N,mutate:P}=k(n&&A?Pe(A):null,()=>Fe(A)),[F,z]=(0,V.useState)(null),[te,ne]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=F??N??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(O),[O]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=O?K??ve(w,O.id):``,Re=(0,V.useMemo)(()=>(T?.items??[]).map(e=>{let n=j(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),Ve=T?.items.find(e=>e.id===T.defaultId),X=Ve?j(Ve,t.agentsSettings):T?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((p??[]).map(e=>[e.name,e])),[p]),Je=p!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),y()])},[u,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:u.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,b,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(I(e)),z(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(L),z(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await _(v(`/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||!F&&K===null)return!1;let e=ze(O);ne(!0),G(null);try{let t=await _(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({...F?{channels:{[e]:F}}:{},...K===null?{}:{bindings:ye(w,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return F&&await P(F,!1),await S(),await u.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,K,w,u,F,S,P]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=O?.id===e.id?F:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await _(v(`/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 S(),await y(),O?.id===e.id&&(await P(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,u,F,S,P,y,Ze]),$=O?.ui?.modal,st=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!Y(O).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[u.isLoading?(0,U.jsx)(ce,{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:f.map(e=>(0,U.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:O?.label??J.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,U.jsx)(Ee,{ch:J,dirty:!!F||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{z(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)(tt,{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:d(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&pe(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)(c,{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)(nt,{checked:Y(O).enabled,disabled:ie===O.id,label:J.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void it(O)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===O.id,checking:b,showConnectionOptions:me,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:O,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:O,locale:e,messages:J,compact:!0,onChanged:async()=>{await P(),await Q(),await S()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(B,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(B,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>z(e),disabled:te,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(M,{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)(s,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!T,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(M,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>z(e),disabled:te,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
@@ -0,0 +1 @@
1
+ import{r as e}from"./locale-store-CbPVxonP.js";import{n as t}from"./channel-recipient-api-D2d21_XA.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
@@ -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"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-81Gv0wwo.js";import{n as s}from"./gateway-config-swr-CN-JHMAh.js";import{Zs as c}from"./index-CPTLS-Zn.js";var l=n(),u=e(t(),1),d=r(),f={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function p(e){let t=(0,l.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,s=n?.branding?.logoUrl,[p,m]=(0,u.useState)(!1),h=f[o],g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{m(!1)},t[0]=g):g=t[0];let _;t[1]===s?_=t[2]:(_=[s],t[1]=s,t[2]=_),(0,u.useEffect)(g,_);let v;t[3]!==a||t[4]!==h.frame?(v=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,h.frame,a),t[3]=a,t[4]=h.frame,t[5]=v):v=t[5];let y;t[6]===n?y=t[7]:(y=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=y);let b=n?.displayName,x;t[8]!==h.fallback||t[9]!==h.image||t[10]!==p||t[11]!==s?(x=s&&!p?(0,d.jsx)(`img`,{src:s,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,h.image),onError:()=>m(!0)}):(0,d.jsx)(c,{className:i(`text-fg-muted`,h.fallback),"aria-hidden":!0}),t[8]=h.fallback,t[9]=h.image,t[10]=p,t[11]=s,t[12]=x):x=t[12];let S;return t[13]!==v||t[14]!==y||t[15]!==b||t[16]!==x?(S=(0,d.jsx)(`span`,{className:v,style:y,title:b,children:x}),t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S):S=t[17],S}function m(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function h(){return m(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function g(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),m(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function _(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),m(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function v(e,t){return m(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function y(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return s(),m(r,`Could not install Store connector.`).instance}async function b(){return m(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function x(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function S(){return m(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function C(e){m(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function w(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return s(),m(n,`Could not install connector.`).instance}async function T(e,t={}){return m(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function E(e,t){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function D(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),s()}async function O(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function k(){return m(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function A(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await k().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function j(e,t){return m(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function M(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function N(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function P(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function F(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function I(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return s(),m(n,`Could not update Composio scope.`).scope}async function L(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function R(e,t){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function z(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function B(e=50){return m(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function V(e){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function H(){return m(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function U(e){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function W(e,t){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update connector sync policy.`).policy}async function G(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function K(e=``,t=100){return m(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function q(e=`pending`){return m(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function J(e,t){return m(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}export{j as A,J as C,x as D,V as E,p as F,E as M,W as N,G as O,A as P,D as S,I as T,B as _,b as a,T as b,M as c,S as d,U as f,z as g,k as h,h as i,R as j,O as k,L as l,y as m,g as n,_ as o,w as p,K as r,v as s,C as t,F as u,q as v,P as w,N as x,H as y};
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"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-CbPVxonP.js";import{n as s}from"./gateway-config-swr-VVcfd3sG.js";import{Zs as c}from"./index-BBw9QL0p.js";var l=n(),u=e(t(),1),d=r(),f={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function p(e){let t=(0,l.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,s=n?.branding?.logoUrl,[p,m]=(0,u.useState)(!1),h=f[o],g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{m(!1)},t[0]=g):g=t[0];let _;t[1]===s?_=t[2]:(_=[s],t[1]=s,t[2]=_),(0,u.useEffect)(g,_);let v;t[3]!==a||t[4]!==h.frame?(v=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,h.frame,a),t[3]=a,t[4]=h.frame,t[5]=v):v=t[5];let y;t[6]===n?y=t[7]:(y=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=y);let b=n?.displayName,x;t[8]!==h.fallback||t[9]!==h.image||t[10]!==p||t[11]!==s?(x=s&&!p?(0,d.jsx)(`img`,{src:s,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,h.image),onError:()=>m(!0)}):(0,d.jsx)(c,{className:i(`text-fg-muted`,h.fallback),"aria-hidden":!0}),t[8]=h.fallback,t[9]=h.image,t[10]=p,t[11]=s,t[12]=x):x=t[12];let S;return t[13]!==v||t[14]!==y||t[15]!==b||t[16]!==x?(S=(0,d.jsx)(`span`,{className:v,style:y,title:b,children:x}),t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S):S=t[17],S}function m(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function h(){return m(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function g(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),m(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function _(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),m(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function v(e,t){return m(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function y(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return s(),m(r,`Could not install Store connector.`).instance}async function b(){return m(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function x(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function S(){return m(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function C(e){m(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function w(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return s(),m(n,`Could not install connector.`).instance}async function T(e,t={}){return m(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function E(e,t){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function D(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),s()}async function O(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function k(){return m(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function A(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await k().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function j(e,t){return m(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function M(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function N(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function P(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function F(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function I(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return s(),m(n,`Could not update Composio scope.`).scope}async function L(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function R(e,t){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function z(e){return m(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function B(e=50){return m(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function V(e){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function H(){return m(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function U(e){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function W(e,t){return m(await o(a(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update connector sync policy.`).policy}async function G(e){return m(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function K(e=``,t=100){return m(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function q(e=`pending`){return m(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function J(e,t){return m(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}export{j as A,J as C,x as D,V as E,p as F,E as M,W as N,G as O,A as P,D as S,I as T,B as _,b as a,T as b,M as c,S as d,U as f,z as g,k as h,h as i,R as j,O as k,L as l,y as m,g as n,_ as o,w as p,K as r,v as s,C as t,F as u,q as v,P as w,N as x,H as y};