@xopcai/xopc 0.0.164 → 0.0.166

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 (95) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/telegram/xopc.extension.json +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-RpxkQtQ3.js → agent-avatar-dicebear-Tr2hgn4j.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-CxpwxMPE.js → agents-DZ69tC4K.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-DLdjfMXB.js → app-management-settings-panel-D7Nrbhez.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-C89-uxkq.js → appearance-settings-DNNbABFj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-k-tZbaRB.js → apps-page-0zXIeywq.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-CqbH5geE.js → archive-plugin-CizqFy4G.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-CeU4Qiot.js → attachment-load-DU8KjTua.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automation-suggestion-card-WiOuqXq9.js → automation-suggestion-card-3pqyIveW.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-Bdn3dgC_.js → automations-page-DSz3xDsi.js} +1 -1
  13. package/dist/gateway/static/root/assets/{binary-plugins-C5TdzrhJ.js → binary-plugins-CipUnsOr.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-BjvWhphG.js → block-editor-XoEq6qiv.js} +3 -3
  15. package/dist/gateway/static/root/assets/{browser-settings-page-GsVTGfGs.js → browser-settings-page-COYvq3y5.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-workflow-inputs-DXmzQ3nk.js → browser-workflow-inputs-DRH995XI.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflows-page-C1-ptRe4.js → browser-workflows-page-65edjhpz.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capabilities-settings-panel-6d4kVjzl.js → capabilities-settings-panel-LOQyfdsM.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capability-presets-api-C0pVlUyc.js → capability-presets-api-XL4h7dCK.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DCxy5Ls_.js → capability-presets-settings-panel-KPJFkt1h.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channels-settings-Bg3P8k0f.js → channels-settings-D8nH0mve.js} +1 -1
  22. package/dist/gateway/static/root/assets/{connector-logo-CuI5w4qM.js → connector-logo-n4Hg41iD.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-6UR7yhIZ.js → connectors-page-jvRWZn3Y.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-BvG8vDXZ.js → desktop-pet-D4OzBOwm.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-CR__kZ8C.js → desktop-pet-settings-CDGezbaf.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-BblWMz3e.js → directory-picker-path-field-DmL4AUXQ.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-DHMPugDE.js → dreaming-settings-ClUcBKnd.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-ByVY1gZg.js → extension-debug-page-DsV_KUDM.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-DLCKKtbK.js → extension-page-DJv_G1jY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-M-rhlFBC.js → extension-settings-page-DUAlJ4CU.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-DZHqhbXH.js → gateway-config-api-SVYgzqv7.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-CZswIehx.js → gateway-settings-YL6f2C_F.js} +1 -1
  33. package/dist/gateway/static/root/assets/{goal-create-dialog-TbyRfDas.js → goal-create-dialog-CJJe-4Co.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-detail-page-B-QBVOf2.js → goal-detail-page-Da9VMWRd.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goals-config-api-DMxG6f0N.js → goals-config-api-st_Itxa9.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-page-BGxki8BR.js → goals-page-B6pC7PYZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-settings-G-w1gCYD.js → goals-settings-BEZePZ5m.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-settings-Csb90R59.js → heartbeat-settings-DpeD9GQ9.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-CGwuxvzr.js → index-BhQMnKH1.js} +6 -6
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C_Bl3YOr.js → keyboard-shortcuts-settings-fhssr2-J.js} +1 -1
  41. package/dist/gateway/static/root/assets/{local-app-workbench-page-BR2tBhO3.js → local-app-workbench-page-Ctia6lSG.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-apps-page-_8Rv-tSk.js → local-apps-page-DWF9rpWQ.js} +1 -1
  43. package/dist/gateway/static/root/assets/{logs-page-CwF0C_Z2.js → logs-page-D3gL6vHX.js} +1 -1
  44. package/dist/gateway/static/root/assets/{markdown-split-CZnZS6gq.js → markdown-split-BuduJ0Ev.js} +1 -1
  45. package/dist/gateway/static/root/assets/{media-plugins-C2XLYC6G.js → media-plugins-CLASZjhT.js} +1 -1
  46. package/dist/gateway/static/root/assets/{notes-page-BkuZxTFo.js → notes-page-ve3XiBDF.js} +1 -1
  47. package/dist/gateway/static/root/assets/{notes-workbench-CD4FADi7.js → notes-workbench-oHU532lp.js} +2 -2
  48. package/dist/gateway/static/root/assets/{page-tabs-DR2FGC4E.js → page-tabs-DU85jn98.js} +1 -1
  49. package/dist/gateway/static/root/assets/{preview-open-alternatives-B65O8wBL.js → preview-open-alternatives-CtchTuRQ.js} +1 -1
  50. package/dist/gateway/static/root/assets/{product-open-page-Cag-utLH.js → product-open-page-DFT6Fx6y.js} +1 -1
  51. package/dist/gateway/static/root/assets/{project-detail-page-COKtUblD.js → project-detail-page-Ceu0NoC1.js} +1 -1
  52. package/dist/gateway/static/root/assets/{projects-page-QYmqanBN.js → projects-page-CdpqOmO8.js} +1 -1
  53. package/dist/gateway/static/root/assets/{remote-access-hub-BU_gBU0f.js → remote-access-hub-D1NKLyiR.js} +1 -1
  54. package/dist/gateway/static/root/assets/{save-bar-controls-DCWpFnPc.js → save-bar-controls-CmcrHpMc.js} +1 -1
  55. package/dist/gateway/static/root/assets/{schedule-field-ClacZdvE.js → schedule-field-DmIkP6JV.js} +1 -1
  56. package/dist/gateway/static/root/assets/{schema-form-BVlbEipU.js → schema-form-Dkk9blN0.js} +1 -1
  57. package/dist/gateway/static/root/assets/{sessions-page-u-Pjbzfm.js → sessions-page-CMj_JaOk.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-advanced-gate-DR9Q2ZyF.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-form-section-GSNlQWSW.js → settings-form-section-CuQzWvg5.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-loading-skeleton-08Ae5sB_.js → settings-loading-skeleton-C5FNbyej.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-BseJD4I-.js → settings-page-a-A2yTGE.js} +1 -1
  62. package/dist/gateway/static/root/assets/{settings-page-layout-bSliH-Y3.js → settings-page-layout-MuXpamWD.js} +1 -1
  63. package/dist/gateway/static/root/assets/{setup-status-panel-CGRhJVlt.js → setup-status-panel-BUdh8FKY.js} +1 -1
  64. package/dist/gateway/static/root/assets/{share-preview-page-C114OpTx.js → share-preview-page-BfzzmTgg.js} +1 -1
  65. package/dist/gateway/static/root/assets/{shares-settings-BRFpWFgI.js → shares-settings-8a9qnLF8.js} +1 -1
  66. package/dist/gateway/static/root/assets/{skill-reload-api-cVjU2GnN.js → skill-reload-api-da5gLCer.js} +1 -1
  67. package/dist/gateway/static/root/assets/{skills-page-CoMTjtRT.js → skills-page-CmHj-CKY.js} +1 -1
  68. package/dist/gateway/static/root/assets/{system-settings-panel-El8cDcTY.js → system-settings-panel-CyhRkWMi.js} +1 -1
  69. package/dist/gateway/static/root/assets/{time-picker-CU7hhD8T.js → time-picker-WEPp3HrB.js} +1 -1
  70. package/dist/gateway/static/root/assets/{typed-models-lib-kToxD7Rc.js → typed-models-lib-Bi1uoxFR.js} +1 -1
  71. package/dist/gateway/static/root/assets/{user-context-page-C0xYCSXB.js → user-context-page-BObEyiim.js} +1 -1
  72. package/dist/gateway/static/root/assets/{voice-api-key-field-DzEpwYaU.js → voice-api-key-field-Gvgodhec.js} +1 -1
  73. package/dist/gateway/static/root/assets/{work-discovery-page-DakZqR85.js → work-discovery-page-BHnjvGH1.js} +1 -1
  74. package/dist/gateway/static/root/assets/{work-item-detail-page-CswqPbTT.js → work-item-detail-page-CQ8ybkxx.js} +1 -1
  75. package/dist/gateway/static/root/assets/{work-page-DYRXEk8m.js → work-page-D_U_En23.js} +1 -1
  76. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BwSxyVMM.js → workflow-run-setup-panel-B-Sk6gFn.js} +1 -1
  77. package/dist/gateway/static/root/assets/{workflows-page-CiLSYGuN.js → workflows-page-DT0pzfkz.js} +1 -1
  78. package/dist/gateway/static/root/index.html +1 -1
  79. package/dist/package.js +1 -1
  80. package/dist/src/agent/embedded/run-turn.js +9 -2
  81. package/dist/src/agent/index.js +1 -1
  82. package/dist/src/cli/commands/channels.js +1 -1
  83. package/dist/src/cli/commands/connectors.js +1 -1
  84. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  85. package/dist/src/cli/commands/models.js +1 -1
  86. package/dist/src/cli/commands/onboard.js +1 -1
  87. package/dist/src/extensions/sdk/index.js +1 -1
  88. package/dist/src/gateway/hono/routes/workflows.js +1 -1
  89. package/dist/src/gateway/service.js +2 -2
  90. package/dist/src/providers/index.js +5 -2
  91. package/dist/src/providers/model-ref.d.ts +6 -0
  92. package/dist/src/providers/model-ref.js +15 -0
  93. package/dist/src/providers/model-registry.js +5 -2
  94. package/package.json +1 -1
  95. package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +0 -1
@@ -1,2 +1,2 @@
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,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-C96Zjb0V.js";import{l as c,n as l}from"./locale-store-C_ax27uc.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$l as d,Ac as f,Es as p,Fu as m,Gl as h,Go as g,Gr as _,Is as v,Jo as y,Ko as b,Ls as x,Nc as S,Ns as C,Nu as w,Ou as T,Sc as E,Uo as D,Wo as O,Yo as k,Ys as A,_l as j,cs as M,dc as N,ls as ee,ms as P,os as te,ps as ne,qo as re,rl as ie}from"./index-CGwuxvzr.js";import{n as ae,r as F}from"./settings-page-layout-bSliH-Y3.js";import{n as oe,r as I}from"./settings-loading-skeleton-08Ae5sB_.js";import{n as L,t as se}from"./settings-form-section-GSNlQWSW.js";import{a as ce,i as le,n as ue,o as de,r as fe,s as pe,t as me}from"./capability-presets-api-C0pVlUyc.js";import{a as he,i as ge,o as R,t as _e}from"./typed-models-lib-kToxD7Rc.js";var z=e(t(),1),B=n(),V=r();function ve(e){let t=(0,B.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,V.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,V.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,V.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,V.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,V.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,V.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,V.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,V.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function H(e){return e.name||e.directoryId}function ye(e){let t=(0,B.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(H).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,V.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let E;t[21]===u.modeDenylist?E=t[22]:(E=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=E);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==x||t[28]!==S||t[29]!==w?(O=[x,S,w,E,D],t[25]=E,t[26]=D,t[27]=x,t[28]=S,t[29]=w,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,V.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==b?(j=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,A]}),t[36]=A,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,V.jsx)(I,{rows:3}):i.length===0?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=H(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,V.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,V.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,V.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var U=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],W=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],G=[`send_message`,`send_media`,`text_to_speech`,`create_share`],be=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],K=[...U,...G],q=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],xe=[`send_message`,`send_media`];function Se(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function Ce(e){let t=(0,B.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(J),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,m;if(t[5]!==d||t[6]!==n){m=[];for(let e of de){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&m.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=pe(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),m.push(e)}t[5]=d,t[6]=n,t[7]=m}else m=t[7];let h=m,g;t[12]!==i||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==i||t[16]!==r?(v=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=v):v=t[17];let y=v,b;t[18]!==d||t[19]!==i?(b=e=>{i(Se(d,e))},t[18]=d,t[19]=i,t[20]=b):b=t[20];let x=b;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let S;t[23]===l.quickActionsLabel?S=t[24]:(S=(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=S);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:w,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===x?E=t[32]:(E=()=>x([[U,`deny`]]),t[31]=x,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===x?O=t[38]:(O=()=>x([[W,`deny`]]),t[37]=x,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[G,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let N;t[49]===x?N=t[50]:(N=()=>x([[be,`allow`],[K,`deny`]]),t[49]=x,t[50]=N);let ee;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==N?(ee=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:N,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=N,t[54]=ee):ee=t[54];let P;t[55]===x?P=t[56]:(P=()=>x([[q,`allow`],[xe,`deny`]]),t[55]=x,t[56]=P);let ne;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==P?(ne=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:P,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=P,t[60]=ne):ne=t[60];let re;t[61]!==k||t[62]!==j||t[63]!==ee||t[64]!==ne||t[65]!==T||t[66]!==D?(re=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,ee,ne]}),t[61]=k,t[62]=j,t[63]=ee,t[64]=ne,t[65]=T,t[66]=D,t[67]=re):re=t[67];let ie;t[68]!==re||t[69]!==S?(ie=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,re]}),t[68]=re,t[69]=S,t[70]=ie):ie=t[70];let ae;t[71]===l.overrideSummaryTitle?ae=t[72]:(ae=(0,V.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=ae);let F;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(F=p.length>0?(0,V.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,V.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,V.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=F):F=t[78];let oe;t[79]!==ae||t[80]!==F?(oe=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[ae,F]}),t[79]=ae,t[80]=F,t[81]=oe):oe=t[81];let I;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==h||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==y?(I=(0,V.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,V.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,V.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,V.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,V.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,V.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,V.jsxs)(te,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,V.jsx)(M,{value:``,children:l.scopeInherit}),(0,V.jsx)(M,{value:`readonly`,children:l.scopeReadonly}),(0,V.jsx)(M,{value:`workspace`,children:l.scopeWorkspace}),(0,V.jsx)(M,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,V.jsx)(Te,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>we(e,`maxCallsPerTurn`,t))}),(0,V.jsx)(Te,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>we(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=h,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=I):I=t[100];let L;return t[101]!==ie||t[102]!==oe||t[103]!==I?(L=(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[ie,oe,I]}),t[101]=ie,t[102]=oe,t[103]=I,t[104]=L):L=t[104],L}function J(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function we(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function Te(e){let t=(0,B.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,V.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Ee=[`blank`,`safe-coder`,`read-only`,`low-cost`],De=[{id:`overview`,icon:d},{id:`models`,icon:j},{id:`tools`,icon:x},{id:`skills`,icon:f},{id:`advanced`,icon:N},{id:`impact`,icon:h}];function Oe(e){return ge(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function ke(e){return structuredClone(e?.tools?.builtin??{})}function Ae(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function je(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function Me(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-C96Zjb0V.js";import{l as c,n as l}from"./locale-store-C_ax27uc.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$l as d,Ac as f,Es as p,Fu as m,Gl as h,Go as g,Gr as _,Is as v,Jo as y,Ko as b,Ls as x,Nc as S,Ns as C,Nu as w,Ou as T,Sc as E,Uo as D,Wo as O,Yo as k,Ys as A,_l as j,cs as M,dc as N,ls as ee,ms as P,os as te,ps as ne,qo as re,rl as ie}from"./index-BhQMnKH1.js";import{n as ae,r as F}from"./settings-page-layout-MuXpamWD.js";import{n as oe,r as I}from"./settings-loading-skeleton-C5FNbyej.js";import{n as L,t as se}from"./settings-form-section-CuQzWvg5.js";import{a as ce,i as le,n as ue,o as de,r as fe,s as pe,t as me}from"./capability-presets-api-XL4h7dCK.js";import{a as he,i as ge,o as R,t as _e}from"./typed-models-lib-Bi1uoxFR.js";var z=e(t(),1),B=n(),V=r();function ve(e){let t=(0,B.c)(34),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===c.inheritanceTitle?d=t[3]:(d=(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,V.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,V.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,V.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(0,V.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,V.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,V.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,V.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,V.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,V.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function H(e){return e.name||e.directoryId}function ye(e){let t=(0,B.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(H).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,V.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let w;t[19]===u.modeAllowlist?w=t[20]:(w=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=w);let E;t[21]===u.modeDenylist?E=t[22]:(E=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=E);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==x||t[28]!==S||t[29]!==w?(O=[x,S,w,E,D],t[25]=E,t[26]=D,t[27]=x,t[28]=S,t[29]=w,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,V.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==b?(j=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,A]}),t[36]=A,t[37]=b,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(M=d?(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,V.jsx)(I,{rows:3}):i.length===0?(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=H(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,V.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,V.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,V.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==y?(N=(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,j,M]}),t[52]=j,t[53]=M,t[54]=y,t[55]=N):N=t[55],N}var U=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],W=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],G=[`send_message`,`send_media`,`text_to_speech`,`create_share`],be=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],K=[...U,...G],q=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],xe=[`send_message`,`send_media`];function Se(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function Ce(e){let t=(0,B.c)(105),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(J),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,m;if(t[5]!==d||t[6]!==n){m=[];for(let e of de){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&m.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=pe(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),m.push(e)}t[5]=d,t[6]=n,t[7]=m}else m=t[7];let h=m,g;t[12]!==i||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==i||t[16]!==r?(v=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=v):v=t[17];let y=v,b;t[18]!==d||t[19]!==i?(b=e=>{i(Se(d,e))},t[18]=d,t[19]=i,t[20]=b):b=t[20];let x=b;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let S;t[23]===l.quickActionsLabel?S=t[24]:(S=(0,V.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=S);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:w,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===x?E=t[32]:(E=()=>x([[U,`deny`]]),t[31]=x,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===x?O=t[38]:(O=()=>x([[W,`deny`]]),t[37]=x,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[G,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let N;t[49]===x?N=t[50]:(N=()=>x([[be,`allow`],[K,`deny`]]),t[49]=x,t[50]=N);let ee;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==N?(ee=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:N,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=N,t[54]=ee):ee=t[54];let P;t[55]===x?P=t[56]:(P=()=>x([[q,`allow`],[xe,`deny`]]),t[55]=x,t[56]=P);let ne;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==P?(ne=(0,V.jsx)(C,{type:`button`,variant:`secondary`,className:R,disabled:a,onClick:P,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=P,t[60]=ne):ne=t[60];let re;t[61]!==k||t[62]!==j||t[63]!==ee||t[64]!==ne||t[65]!==T||t[66]!==D?(re=(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,ee,ne]}),t[61]=k,t[62]=j,t[63]=ee,t[64]=ne,t[65]=T,t[66]=D,t[67]=re):re=t[67];let ie;t[68]!==re||t[69]!==S?(ie=(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,re]}),t[68]=re,t[69]=S,t[70]=ie):ie=t[70];let ae;t[71]===l.overrideSummaryTitle?ae=t[72]:(ae=(0,V.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=ae);let F;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(F=p.length>0?(0,V.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,V.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,V.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=F):F=t[78];let oe;t[79]!==ae||t[80]!==F?(oe=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[ae,F]}),t[79]=ae,t[80]=F,t[81]=oe):oe=t[81];let I;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==h||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==y?(I=(0,V.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,V.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,V.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,V.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,V.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,V.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,V.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-3 dark:border-edge`,children:[(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,V.jsxs)(te,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,V.jsx)(M,{value:``,children:l.scopeInherit}),(0,V.jsx)(M,{value:`readonly`,children:l.scopeReadonly}),(0,V.jsx)(M,{value:`workspace`,children:l.scopeWorkspace}),(0,V.jsx)(M,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,V.jsx)(Te,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>we(e,`maxCallsPerTurn`,t))}),(0,V.jsx)(Te,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>we(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=h,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=I):I=t[100];let L;return t[101]!==ie||t[102]!==oe||t[103]!==I?(L=(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[ie,oe,I]}),t[101]=ie,t[102]=oe,t[103]=I,t[104]=L):L=t[104],L}function J(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function we(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function Te(e){let t=(0,B.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,V.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Ee=[`blank`,`safe-coder`,`read-only`,`low-cost`],De=[{id:`overview`,icon:d},{id:`models`,icon:j},{id:`tools`,icon:x},{id:`skills`,icon:f},{id:`advanced`,icon:N},{id:`impact`,icon:h}];function Oe(e){return ge(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function ke(e){return structuredClone(e?.tools?.builtin??{})}function Ae(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function je(){return{primary:``,fallbacks:``,timeoutMs:``,autoProviderFallback:``}}function Me(e){return{primary:e?.primary??``,fallbacks:e?.fallbacks?.join(`
2
2
  `)??``,timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Ne(){return{imageModel:je(),imageGenerationModel:je(),allowFallbacks:``,maxCostTier:``}}function Y(e){return{imageModel:Me(e?.models?.imageModel),imageGenerationModel:Me(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function X(e){return e===void 0?``:JSON.stringify(e,null,2)}function Z(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Pe(e){return{mcp:X(e?.tools?.mcp),workflows:X(e?.workflows),boundaries:X(e?.boundaries),runtime:X(e?.runtime),locks:X(e?.locks)}}function Fe(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Oe(e),modelAdvanced:Y(e),toolPolicies:ke(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Ae(e),extendsIds:[...e?.extends??[]],jsonFields:Pe(e)}}function Ie(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function Le(e,t){let n=_e(e.modelRows),r=Ie(e.modelAdvanced.imageModel),i=Ie(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function Re(e){return e.trim()?JSON.parse(e):void 0}function Q(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function $(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Re(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function ze(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Be(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function Ve(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Le(e,t),tools:{builtin:ze(e.toolPolicies),mcp:Q(e.jsonFields.mcp)},skills:Be(e),extends:[...e.extendsIds].toSorted(),workflows:Q(e.jsonFields.workflows),boundaries:Q(e.jsonFields.boundaries),runtime:Q(e.jsonFields.runtime),locks:Q(e.jsonFields.locks)}}function He(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:ze(e.tools?.builtin),mcp:Q(X(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Q(X(e.workflows)),boundaries:Q(X(e.boundaries)),runtime:Q(X(e.runtime)),locks:Q(X(e.locks))}:null}function Ue(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function We(){return{modelAdvanced:Ne(),extendsIds:[],jsonFields:Z()}}function Ge(e,t){return{extends:[...e.extendsIds],models:Le(e,t)??void 0,tools:$(e)??void 0,skills:Be(e)??void 0,workflows:Re(e.jsonFields.workflows),boundaries:Re(e.jsonFields.boundaries),runtime:Re(e.jsonFields.runtime),locks:Re(e.jsonFields.locks)}}function Ke(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...We()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...We()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...We()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...We()}}function qe(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,V.jsx)(C,{asChild:!0,type:`button`,variant:`secondary`,children:(0,V.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,V.jsx)(w,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:T,error:M,isLoading:te,mutate:I}=u(r?`settings-capability-presets`:null,fe,{revalidateOnFocus:!1}),{data:de=[],isLoading:pe}=u(r?`settings-capability-presets-skills-catalog`:null,_,{revalidateOnFocus:!1}),[ge,R]=i(),[_e,B]=(0,z.useState)(``),[H,U]=(0,z.useState)(`overview`),[W,G]=(0,z.useState)(()=>Ke(`blank`,t)),[be,K]=(0,z.useState)(null),[q,xe]=(0,z.useState)(!1),[Se,J]=(0,z.useState)(null),[we,Te]=(0,z.useState)(!1),[Oe,ke]=(0,z.useState)(null),[Ae,je]=(0,z.useState)(null),Me=T?.presets??[],Ne=T?.defaultPresetId??`default`,Y=Me.find(e=>e.id===Ne)??null,X=Me.filter(e=>e.id!==Ne),Z=(0,z.useMemo)(()=>Me.find(e=>e.id===_e)??Me[0]??null,[Me,_e]),Pe=!Z||W.id.trim()!==Z.id,Ie=!!(Z&&Z.id===Ne),Le=JSON.stringify(Ve(W,Z))!==JSON.stringify(He(Z)),Q=Ve(W,Z),$=He(Z),ze=[Q.id!==$?.id||Q.name!==$?.name||Q.description!==$?.description?t.tabs.overview:``,JSON.stringify(Q.models)===JSON.stringify($?.models)?``:t.tabs.models,JSON.stringify(Q.tools)===JSON.stringify($?.tools)?``:t.tabs.tools,JSON.stringify(Q.skills)===JSON.stringify($?.skills)?``:t.tabs.skills,JSON.stringify({extends:Q.extends,workflows:Q.workflows,boundaries:Q.boundaries,runtime:Q.runtime,locks:Q.locks})===JSON.stringify({extends:$?.extends,workflows:$?.workflows,boundaries:$?.boundaries,runtime:$?.runtime,locks:$?.locks})?``:t.tabs.advanced].filter(Boolean),Be=Se??(M instanceof Error?M.message:null),We=ge.get(`action`)===`new`||!!ge.get(`preset`),qe=ge.get(`action`)===`new`&&be===null,Xe=Pe?t.newPreset:Z?.name??t.editorTitle,Ze=t=>e.agentsSettings.toolsDisableGroups[t],Qe=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,z.useEffect)(()=>{if(!T||q)return;if(ge.get(`action`)===`new`){B(``),G(Ke(`blank`,t)),U(`overview`);return}let e=ge.get(`preset`)?.trim(),n=e?T.presets.find(t=>t.id===e):null;if(n){B(n.id),G(Fe(n)),U(ge.get(`tab`)??`overview`);return}Z&&(B(Z.id),G(e=>e.id===Z.id?e:Fe(Z)))},[q,T,ge,Z]);function $e(e){K(null),B(e.id),G(Fe(e)),R({preset:e.id},{replace:!0}),U(`overview`)}function et(){K(null),B(``),G(Ke(`blank`,t)),J(null),R({action:`new`},{replace:!0}),U(`overview`)}function tt(e){K(e),G(Ke(e,t)),J(null),U(`overview`)}function nt(){if(be){let e=Ke(be,t);if(JSON.stringify(Ve(W,null))!==JSON.stringify(Ve(e,null))&&!window.confirm(t.changeTemplateConfirm))return}K(null),J(null)}function rt(){!qe&&Le&&!window.confirm(t.discardConfirm)||(Te(!1),ke(null),R({},{replace:!0}),K(null),J(null),G(Fe(Z)),U(`overview`))}async function it(){let e=he(W.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){J(e),U(`models`);return}for(let e of[W.modelAdvanced.imageModel,W.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks.split(/\r?\n|,/)].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){J(t.invalidModelRef),U(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){J(t.advancedPositiveIntegerError),U(`models`);return}}for(let e of Object.values(W.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){J(t.advancedPositiveIntegerError),U(`tools`);return}for(let e of Object.keys(W.jsonFields))try{Re(W.jsonFields[e])}catch{J(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),U(`advanced`);return}xe(!0),J(null);try{let e=Ge(W,Z);if(Pe){let t=await me({id:W.id.trim(),name:W.name.trim(),...W.description.trim()?{description:W.description.trim()}:{},...e});await I(t.presets,{revalidate:!1}),B(t.presetId),K(null),R({preset:t.presetId},{replace:!0})}else Z&&await I(await le(Z.id,{name:W.name.trim(),description:W.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){J(e instanceof Error?e.message:t.saveError)}finally{xe(!1)}}async function at(){if(Z){xe(!0),J(null),ke(null);try{await I(await ue(Z.id),{revalidate:!1}),Te(!1),B(``),K(null),G(Ke(`blank`,t)),U(`overview`),R({},{replace:!0})}catch(e){ke(e instanceof Error?e.message:t.deleteError)}finally{xe(!1)}}}return r?(0,V.jsxs)(F,{gap:`gap-5`,className:`pb-24`,children:[(0,V.jsx)(ae,{title:t.title,subtitle:t.subtitle,actions:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,V.jsxs)(C,{type:`button`,onClick:et,disabled:q,children:[(0,V.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Be?(0,V.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Be}):null,te?(0,V.jsx)(oe,{sections:2}):(0,V.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Y?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:j,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>$e(Y),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Y.name}),(0,V.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Y.id})]}),(0,V.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Y.description?(0,V.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Y.description}):null,(0,V.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Ue(Y,t)})]})]}):null,(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:j,title:t.listTitle,subtitle:t.listHint}),X.length===0?(0,V.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,V.jsx)(`p`,{children:t.empty}),(0,V.jsxs)(C,{type:`button`,variant:`secondary`,onClick:et,disabled:q,children:[(0,V.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,V.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>$e(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,V.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,V.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,V.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,V.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:Ue(e,t)})]},e.id))})]})]}),(0,V.jsx)(D,{open:We,onOpenChange:e=>{e||rt()},children:(0,V.jsxs)(y,{children:[(0,V.jsx)(re,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),(0,V.jsx)(g,{ref:je,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,ne),onOpenAutoFocus:e=>e.preventDefault(),children:(0,V.jsxs)(ee,{layer:`modal`,portalContainer:Ae,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!qe&&Pe&&be?(0,V.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:nt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,V.jsx)(m,{className:`size-4`,"aria-hidden":!0})}):null,(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(k,{className:`truncate text-base font-semibold text-fg`,children:Xe}),(0,V.jsx)(b,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:qe?t.templatePickerSubtitle:Pe&&be?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[be].title)}`:Pe?t.editorHint:W.id})]})]}),(0,V.jsx)(O,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:o(p,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,V.jsx)(v,{className:`size-4`,"aria-hidden":!0})})})]}),qe?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,V.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Ee.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>tt(e),children:[(0,V.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,V.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,V.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,V.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,V.jsx)(C,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,V.jsxs)(V.Fragment,{children:[Be?(0,V.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Be}):null,(0,V.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:De.map(({id:e,icon:n})=>(0,V.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,H===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>U(e),children:[(0,V.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,V.jsxs)(`div`,{className:`w-full`,children:[H===`overview`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:d,title:t.overviewTitle,subtitle:t.overviewHint}),(0,V.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,V.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.id,disabled:q||!Pe,onChange:e=>G(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&Z?(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,V.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String(Z.version))})]}):null,(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,V.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.name,disabled:q,onChange:e=>G(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,V.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:W.description,disabled:q,onChange:e=>G(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,V.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,V.jsx)(Je,{icon:j,label:t.modelsTitle,value:String(W.modelRows.length)}),(0,V.jsx)(Je,{icon:x,label:t.toolsTitle,value:String(Object.keys(W.toolPolicies).length)}),(0,V.jsx)(Je,{icon:f,label:t.skillsTitle,value:t.skillModeLabels[W.skillMode]})]})]}):null,H===`models`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:j,title:t.modelsTitle,subtitle:t.modelsHint}),(0,V.jsx)(ce,{rows:W.modelRows,onChange:e=>G(t=>({...t,modelRows:e})),disabled:q,defaultRole:Z?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,visionBadge:t.modelVisionBadge,visionAutoHint:t.modelVisionAutoHint,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,V.jsx)(Ye,{value:W.modelAdvanced,onChange:e=>G(t=>({...t,modelAdvanced:e})),disabled:q,cp:t})]}):null,H===`tools`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:x,title:t.toolsTitle,subtitle:t.toolsHint}),(0,V.jsx)(Ce,{builtinToolIds:T?.builtinToolIds??[],toolPolicies:W.toolPolicies,onChange:e=>G(t=>({...t,toolPolicies:e})),disabled:q,getToolDescription:Qe,getGroupTitle:Ze,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,H===`skills`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:f,title:t.skillsTitle,subtitle:t.skillsHint}),(0,V.jsx)(ye,{mode:W.skillMode,selected:W.skillPick,catalog:de,loading:pe,disabled:q,onModeChange:e=>G(t=>({...t,skillMode:e})),onSelectedChange:e=>G(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,H===`advanced`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:N,title:t.advancedTitle,subtitle:t.advancedHint}),(0,V.jsx)(ve,{extendsIds:W.extendsIds,onExtendsChange:e=>G(t=>({...t,extendsIds:e})),presetOptions:Me.filter(e=>e.id!==Z?.id&&e.id!==Ne),jsonFields:W.jsonFields,onJsonFieldsChange:e=>G(t=>({...t,jsonFields:e})),disabled:q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,H===`impact`?(0,V.jsxs)(se,{children:[(0,V.jsx)(L,{icon:h,title:t.usageTitle,subtitle:t.usageHint}),(0,V.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.join(`、`)):t.changePreviewEmpty})]}),Z?.usage.length?(0,V.jsx)(`div`,{className:`grid gap-2`,children:Z.usage.map(e=>(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,V.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,V.jsx)(`div`,{className:`font-medium text-fg`,children:Le?t.unsavedTitle:t.noUnsavedTitle}),(0,V.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Le?(Z?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String(Z?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Le?(0,V.jsx)(C,{type:`button`,variant:`secondary`,disabled:q,onClick:()=>G(Fe(Z)),children:t.discard}):null,Z&&!Ie?(0,V.jsxs)(C,{type:`button`,variant:`secondary`,disabled:q,onClick:()=>{ke(null),Te(!0)},children:[(0,V.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,V.jsxs)(C,{type:`button`,disabled:q||!W.id.trim()||!W.name.trim()||!Le,onClick:()=>void it(),children:[(0,V.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,V.jsx)(D,{open:we,onOpenChange:e=>{q||(Te(e),e||ke(null))},children:(0,V.jsxs)(y,{children:[(0,V.jsx)(re,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,P)}),(0,V.jsxs)(g,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,ne),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,V.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,V.jsx)(k,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,V.jsx)(b,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:Z?t.deleteConfirm.replace(`{{name}}`,Z.name):t.deleteConfirmFallback})]}),Oe?(0,V.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:Oe}):null,(0,V.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,V.jsx)(C,{type:`button`,variant:`secondary`,disabled:q,onClick:()=>Te(!1),children:t.cancel}),(0,V.jsxs)(C,{type:`button`,disabled:q||!Z,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void at(),children:[q?(0,V.jsx)(ie,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,V.jsx)(A,{className:`size-4`,"aria-hidden":!0}),q?t.deleting:t.delete]})]})]})]})})]}):(0,V.jsxs)(F,{gap:`gap-3`,children:[(0,V.jsx)(ae,{title:t.title,actions:n}),(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Je(e){let t=(0,B.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,V.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Ye(e){let t=(0,B.c)(77),{value:n,onChange:r,disabled:i,cp:a}=e,o;t[0]!==r||t[1]!==n?(o=(e,t)=>{r({...n,[e]:t})},t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;t[3]===a.modelAdvancedTitle?c=t[4]:(c=(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[3]=a.modelAdvancedTitle,t[4]=c);let l;t[5]===a.modelAdvancedHint?l=t[6]:(l=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[5]=a.modelAdvancedHint,t[6]=l);let u;t[7]===s?u=t[8]:(u=e=>s(`imageModel`,e),t[7]=s,t[8]=u);let d;t[9]!==a||t[10]!==i||t[11]!==u||t[12]!==n.imageModel?(d=(0,V.jsx)(Xe,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:u,disabled:i,cp:a}),t[9]=a,t[10]=i,t[11]=u,t[12]=n.imageModel,t[13]=d):d=t[13];let f;t[14]===s?f=t[15]:(f=e=>s(`imageGenerationModel`,e),t[14]=s,t[15]=f);let p;t[16]!==a||t[17]!==i||t[18]!==f||t[19]!==n.imageGenerationModel?(p=(0,V.jsx)(Xe,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:f,disabled:i,cp:a}),t[16]=a,t[17]=i,t[18]=f,t[19]=n.imageGenerationModel,t[20]=p):p=t[20];let m;t[21]!==d||t[22]!==p?(m=(0,V.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[d,p]}),t[21]=d,t[22]=p,t[23]=m):m=t[23];let h;t[24]===a.modelAllowFallbacksLabel?h=t[25]:(h=(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[24]=a.modelAllowFallbacksLabel,t[25]=h);let g;t[26]!==r||t[27]!==n?(g=e=>r({...n,allowFallbacks:e.target.value}),t[26]=r,t[27]=n,t[28]=g):g=t[28];let _;t[29]===a.policyInherit?_=t[30]:(_=(0,V.jsx)(M,{value:``,children:a.policyInherit}),t[29]=a.policyInherit,t[30]=_);let v;t[31]===a.policyEnabled?v=t[32]:(v=(0,V.jsx)(M,{value:`true`,children:a.policyEnabled}),t[31]=a.policyEnabled,t[32]=v);let y;t[33]===a.policyDisabled?y=t[34]:(y=(0,V.jsx)(M,{value:`false`,children:a.policyDisabled}),t[33]=a.policyDisabled,t[34]=y);let b;t[35]!==i||t[36]!==_||t[37]!==v||t[38]!==y||t[39]!==g||t[40]!==n.allowFallbacks?(b=(0,V.jsxs)(te,{value:n.allowFallbacks,disabled:i,onChange:g,children:[_,v,y]}),t[35]=i,t[36]=_,t[37]=v,t[38]=y,t[39]=g,t[40]=n.allowFallbacks,t[41]=b):b=t[41];let x;t[42]!==b||t[43]!==h?(x=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[h,b]}),t[42]=b,t[43]=h,t[44]=x):x=t[44];let S;t[45]===a.modelMaxCostTierLabel?S=t[46]:(S=(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[45]=a.modelMaxCostTierLabel,t[46]=S);let C;t[47]!==r||t[48]!==n?(C=e=>r({...n,maxCostTier:e.target.value}),t[47]=r,t[48]=n,t[49]=C):C=t[49];let w;t[50]===a.policyInherit?w=t[51]:(w=(0,V.jsx)(M,{value:``,children:a.policyInherit}),t[50]=a.policyInherit,t[51]=w);let T;t[52]===a.costTierLow?T=t[53]:(T=(0,V.jsx)(M,{value:`low`,children:a.costTierLow}),t[52]=a.costTierLow,t[53]=T);let E;t[54]===a.costTierMedium?E=t[55]:(E=(0,V.jsx)(M,{value:`medium`,children:a.costTierMedium}),t[54]=a.costTierMedium,t[55]=E);let D;t[56]===a.costTierHigh?D=t[57]:(D=(0,V.jsx)(M,{value:`high`,children:a.costTierHigh}),t[56]=a.costTierHigh,t[57]=D);let O;t[58]!==i||t[59]!==C||t[60]!==w||t[61]!==T||t[62]!==E||t[63]!==D||t[64]!==n.maxCostTier?(O=(0,V.jsxs)(te,{value:n.maxCostTier,disabled:i,onChange:C,children:[w,T,E,D]}),t[58]=i,t[59]=C,t[60]=w,t[61]=T,t[62]=E,t[63]=D,t[64]=n.maxCostTier,t[65]=O):O=t[65];let k;t[66]!==S||t[67]!==O?(k=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[S,O]}),t[66]=S,t[67]=O,t[68]=k):k=t[68];let A;t[69]!==x||t[70]!==k?(A=(0,V.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-panel/70 p-3 shadow-surface sm:grid-cols-2`,children:[x,k]}),t[69]=x,t[70]=k,t[71]=A):A=t[71];let j;return t[72]!==c||t[73]!==l||t[74]!==A||t[75]!==m?(j=(0,V.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-5 dark:border-edge`,children:[c,l,m,A]}),t[72]=c,t[73]=l,t[74]=A,t[75]=m,t[76]=j):j=t[76],j}function Xe(e){let t=(0,B.c)(64),{title:n,value:r,onChange:i,disabled:a,cp:s}=e,c;t[0]===n?c=t[1]:(c=(0,V.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=c);let l=s.modelToolPrimaryLabel,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]!==i||t[4]!==r?(d=e=>i({...r,primary:e.target.value}),t[3]=i,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==a||t[7]!==d||t[8]!==r.primary?(f=(0,V.jsx)(`input`,{className:u,value:r.primary,disabled:a,placeholder:`provider/model`,onChange:d}),t[6]=a,t[7]=d,t[8]=r.primary,t[9]=f):f=t[9];let p;t[10]!==s.modelToolPrimaryLabel||t[11]!==f?(p=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l,f]}),t[10]=s.modelToolPrimaryLabel,t[11]=f,t[12]=p):p=t[12];let m=s.modelToolFallbacksLabel,h;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(h=o(`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,`min-h-20 resize-y font-mono text-xs`),t[13]=h):h=t[13];let g;t[14]!==i||t[15]!==r?(g=e=>i({...r,fallbacks:e.target.value}),t[14]=i,t[15]=r,t[16]=g):g=t[16];let _;t[17]!==s.modelToolFallbacksPlaceholder||t[18]!==a||t[19]!==g||t[20]!==r.fallbacks?(_=(0,V.jsx)(`textarea`,{className:h,value:r.fallbacks,disabled:a,placeholder:s.modelToolFallbacksPlaceholder,onChange:g}),t[17]=s.modelToolFallbacksPlaceholder,t[18]=a,t[19]=g,t[20]=r.fallbacks,t[21]=_):_=t[21];let v;t[22]!==s.modelToolFallbacksLabel||t[23]!==_?(v=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[m,_]}),t[22]=s.modelToolFallbacksLabel,t[23]=_,t[24]=v):v=t[24];let y;t[25]!==i||t[26]!==r?(y=e=>i({...r,timeoutMs:e.target.value}),t[25]=i,t[26]=r,t[27]=y):y=t[27];let b;t[28]!==a||t[29]!==y||t[30]!==r.timeoutMs?(b=(0,V.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:y}),t[28]=a,t[29]=y,t[30]=r.timeoutMs,t[31]=b):b=t[31];let x;t[32]!==s.toolTimeoutLabel||t[33]!==b?(x=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.toolTimeoutLabel,b]}),t[32]=s.toolTimeoutLabel,t[33]=b,t[34]=x):x=t[34];let S;t[35]!==i||t[36]!==r?(S=e=>i({...r,autoProviderFallback:e.target.value}),t[35]=i,t[36]=r,t[37]=S):S=t[37];let C;t[38]===s.policyInherit?C=t[39]:(C=(0,V.jsx)(M,{value:``,children:s.policyInherit}),t[38]=s.policyInherit,t[39]=C);let w;t[40]===s.policyEnabled?w=t[41]:(w=(0,V.jsx)(M,{value:`true`,children:s.policyEnabled}),t[40]=s.policyEnabled,t[41]=w);let T;t[42]===s.policyDisabled?T=t[43]:(T=(0,V.jsx)(M,{value:`false`,children:s.policyDisabled}),t[42]=s.policyDisabled,t[43]=T);let E;t[44]!==a||t[45]!==S||t[46]!==C||t[47]!==w||t[48]!==T||t[49]!==r.autoProviderFallback?(E=(0,V.jsxs)(te,{value:r.autoProviderFallback,disabled:a,onChange:S,children:[C,w,T]}),t[44]=a,t[45]=S,t[46]=C,t[47]=w,t[48]=T,t[49]=r.autoProviderFallback,t[50]=E):E=t[50];let D;t[51]!==s.modelAutoProviderFallbackLabel||t[52]!==E?(D=(0,V.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[s.modelAutoProviderFallbackLabel,E]}),t[51]=s.modelAutoProviderFallbackLabel,t[52]=E,t[53]=D):D=t[53];let O;t[54]!==x||t[55]!==D?(O=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[x,D]}),t[54]=x,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==v||t[58]!==O||t[59]!==p?(k=(0,V.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[p,v,O]}),t[57]=v,t[58]=O,t[59]=p,t[60]=k):k=t[60];let A;return t[61]!==c||t[62]!==k?(A=(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 p-3 shadow-surface`,children:[c,k]}),t[61]=c,t[62]=k,t[63]=A):A=t[63],A}export{qe as CapabilityPresetsSettingsPanel};
@@ -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{l as i,u as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-C96Zjb0V.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-C_ax27uc.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,Es as g,Et as _,Go as v,Is as y,Jo as b,Js as x,Kl as S,Ko as C,Lr as w,Ns as T,To as E,Uo as D,Wo as O,Yo as k,aa as A,as as j,gc as M,hu as N,ic as P,ii as F,io as I,kc as L,ls as R,ms as z,ni as ee,ps as B,qo as te,ri as ne,rl as V,ro as re,wc as ie}from"./index-CGwuxvzr.js";import{n as ae,r as oe}from"./settings-page-layout-bSliH-Y3.js";import{n as se}from"./settings-loading-skeleton-08Ae5sB_.js";import{t as ce}from"./schema-form-BVlbEipU.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-DZZq0upi.js";import{t as fe}from"./use-channel-catalog-DBh0dOC9.js";var H=e(t(),1),U=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(le(),1),W=r();async function he(e){let t=await d(f(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>pe(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),g=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),_=c.payload?.type===`form`?c.payload:null,v=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(T,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(L,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(T,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(P,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,g?(0,W.jsxs)(`div`,{className:s(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,W.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(re,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(re,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(re,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.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,W.jsx)(N,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,_?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:_.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(_.submitAction,c.formDraft),children:n.saveSetup})]}):null,v?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:v.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?s(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,B):s(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,B,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,_=n===`drawer`,[x,S]=(0,H.useState)(null),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,W.jsx)(te,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[0]=w):w=t[0];let E;t[1]!==n||t[2]!==h?(E=Se(n,h),t[1]=n,t[2]=h,t[3]=E):E=t[3];let A;t[4]===c?A=t[5]:(A=c?(0,W.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=A);let j;t[6]===l?j=t[7]:(j=l?(0,W.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let M;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==_||t[12]!==a?(M=_?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(O,{asChild:!0,children:(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(y,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:s(g,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(y,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=_,t[12]=a,t[13]=M):M=t[13];let N=_?`p-4`:`p-6`,P;t[14]===N?P=t[15]:(P=s(`min-h-0 flex-1 overflow-y-auto`,N),t[14]=N,t[15]=P);let F;t[16]!==d||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:d}),t[16]=d,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==f||t[20]!==x||t[21]!==A||t[22]!==j||t[23]!==M||t[24]!==F?(I=(0,W.jsxs)(R,{layer:`modal`,portalContainer:x,children:[A,j,M,F,f]}),t[19]=f,t[20]=x,t[21]=A,t[22]=j,t[23]=M,t[24]=F,t[25]=I):I=t[25];let L;t[26]!==I||t[27]!==E?(L=(0,W.jsxs)(b,{children:[w,(0,W.jsx)(v,{ref:S,className:E,onOpenAutoFocus:we,children:I})]}),t[26]=I,t[27]=E,t[28]=L):L=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==L?(ee=(0,W.jsx)(D,{open:r,onOpenChange:i,children:L}),t[29]=i,t[30]=r,t[31]=L,t[32]=ee):ee=t[32],ee}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(A,{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,W.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,U.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,W.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,W.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(e),r=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 Xe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Qe(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=s(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=s(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,W.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,W.jsx)(et,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,W.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(T,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,W.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function nt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?N:n===`stopped`||n===`needs_setup`?o:V,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=s(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,W.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===l.connectionStatus?x=t[10]:(x=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=x);let S;t[11]!==l||t[12]!==n?(S=Re(n,l),t[11]=l,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,W.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let E;t[19]!==w||t[20]!==b?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(T,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(ie,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let P;t[44]!==A||t[45]!==j||t[46]!==M?(P=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=P):P=t[47];let F;return t[48]!==E||t[49]!==P?(F=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,P]})}),t[48]=E,t[49]=P,t[50]=F):F=t[50],F}function at(e){let t=(0,U.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,W.jsx)(x,{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,W.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,W.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,W.jsx)(`li`,{children:Qe(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=i(),{channelId:o}=a(),p=F(o),g=fe(n,e),v=g.entries,{data:y,mutate:b,isValidating:x}=m(n?de():null,ue,{revalidateOnFocus:!0}),{data:C,mutate:T}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),D=C?.channels??{},O=C?.bindings??[],{data:k}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),A=E(e=>e.setPageHeader),N=E(e=>e.clearPageHeader),P=(0,H.useMemo)(()=>v.find(e=>e.id===p),[p,v]),I=P?Ie(P):null,{data:L,mutate:R}=m(n&&I?je(I):null,()=>Me(I)),[z,B]=(0,H.useState)(null),[te,V]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[me,he]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),_e=z??L??{},Y=t.channelsSettings,be=(0,H.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Se=(0,H.useMemo)(()=>We(be,Ne),[be]),we=(0,H.useMemo)(()=>Be(P),[P]),De=(0,H.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,H.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,H.useMemo)(()=>Ge(De),[De]),Re=P?q??ve(O,P.id):``,Z=(0,H.useMemo)(()=>(k?.items??[]).map(e=>{let n=w(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),Ue=Ve?w(Ve,t.agentsSettings):k?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,H.useMemo)(()=>new Map((y??[]).map(e=>[e.name,e])),[y]),Je=y!==void 0,Ye=(0,H.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([g.mutate(),b()])},[g,b]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&b(t,!1)},[b]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,Y,n,x,Q]);(0,H.useLayoutEffect)(()=>(A({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>N()),[N,Xe,t.settingsSections.channels,A]);let Ze=(0,H.useCallback)(e=>{r(ne(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(ee),B(null),J(null),K(null)},[r]),nt=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await d(f(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),he(!1)},[P?.id]);let rt=(0,H.useCallback)(async()=>{if(!P||!z&&q===null)return!1;let e=Ie(P);V(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(O,P.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await g.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{V(!1)}},[P,q,O,g,z,T,R]),ot=(0,H.useCallback)(async e=>{let t=X(e),n=Ie(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await g.mutate(),await T(),await b(),P?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,g,z,T,R,b,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!X(P).ready||me:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[g.isLoading?(0,W.jsx)(se,{sections:2}):g.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:v.map(e=>(0,W.jsx)(tt,{entry:e,config:D[Ie(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:P?.label??Y.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:P?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)($e,{entry:P}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,W.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(P).ready&&pe(P)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,W.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(P).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(et,{checked:X(P).enabled,disabled:re===P.id,label:Y.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void ot(P)})]})]})}),(0,W.jsx)(it,{runtime:ct,restarting:le===P.id,checking:x,showConnectionOptions:me,canManageConnection:X(P).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(P),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,W.jsx)(at,{entry:P,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:P,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(_,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(_,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,st&&Fe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:De,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(M,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(j,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:te||!k,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(M,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:ke,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot 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{l as i,u as a}from"./chunk-KS7C4IRE-uQ0fehio.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-C96Zjb0V.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-C_ax27uc.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,Es as g,Et as _,Go as v,Is as y,Jo as b,Js as x,Kl as S,Ko as C,Lr as w,Ns as T,To as E,Uo as D,Wo as O,Yo as k,aa as A,as as j,gc as M,hu as N,ic as P,ii as F,io as I,kc as L,ls as R,ms as z,ni as ee,ps as B,qo as te,ri as ne,rl as V,ro as re,wc as ie}from"./index-BhQMnKH1.js";import{n as ae,r as oe}from"./settings-page-layout-MuXpamWD.js";import{n as se}from"./settings-loading-skeleton-C5FNbyej.js";import{t as ce}from"./schema-form-Dkk9blN0.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-DZZq0upi.js";import{t as fe}from"./use-channel-catalog-DBh0dOC9.js";var H=e(t(),1),U=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(le(),1),W=r();async function he(e){let t=await d(f(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>pe(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),g=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),_=c.payload?.type===`form`?c.payload:null,v=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(T,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(L,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(T,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(P,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,g?(0,W.jsxs)(`div`,{className:s(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,W.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(re,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(re,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(re,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.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,W.jsx)(N,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,_?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:_.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(_.submitAction,c.formDraft),children:n.saveSetup})]}):null,v?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:v.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?s(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,B):s(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,B,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,_=n===`drawer`,[x,S]=(0,H.useState)(null),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,W.jsx)(te,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,z)}),t[0]=w):w=t[0];let E;t[1]!==n||t[2]!==h?(E=Se(n,h),t[1]=n,t[2]=h,t[3]=E):E=t[3];let A;t[4]===c?A=t[5]:(A=c?(0,W.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=A);let j;t[6]===l?j=t[7]:(j=l?(0,W.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let M;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==_||t[12]!==a?(M=_?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(O,{asChild:!0,children:(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(y,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(O,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:s(g,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(y,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=_,t[12]=a,t[13]=M):M=t[13];let N=_?`p-4`:`p-6`,P;t[14]===N?P=t[15]:(P=s(`min-h-0 flex-1 overflow-y-auto`,N),t[14]=N,t[15]=P);let F;t[16]!==d||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:d}),t[16]=d,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==f||t[20]!==x||t[21]!==A||t[22]!==j||t[23]!==M||t[24]!==F?(I=(0,W.jsxs)(R,{layer:`modal`,portalContainer:x,children:[A,j,M,F,f]}),t[19]=f,t[20]=x,t[21]=A,t[22]=j,t[23]=M,t[24]=F,t[25]=I):I=t[25];let L;t[26]!==I||t[27]!==E?(L=(0,W.jsxs)(b,{children:[w,(0,W.jsx)(v,{ref:S,className:E,onOpenAutoFocus:we,children:I})]}),t[26]=I,t[27]=E,t[28]=L):L=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==L?(ee=(0,W.jsx)(D,{open:r,onOpenChange:i,children:L}),t[29]=i,t[30]=r,t[31]=L,t[32]=ee):ee=t[32],ee}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(A,{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,W.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,U.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,W.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,W.jsx)(T,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(T,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(T,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(e),r=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 Xe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function Qe(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(I,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=s(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=s(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,W.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,W.jsx)(et,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,W.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(T,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,W.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function nt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?N:n===`stopped`||n===`needs_setup`?o:V,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=s(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,W.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===l.connectionStatus?x=t[10]:(x=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=x);let S;t[11]!==l||t[12]!==n?(S=Re(n,l),t[11]=l,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,W.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let E;t[19]!==w||t[20]!==b?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(T,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(T,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(ie,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,W.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let P;t[44]!==A||t[45]!==j||t[46]!==M?(P=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=P):P=t[47];let F;return t[48]!==E||t[49]!==P?(F=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,P]})}),t[48]=E,t[49]=P,t[50]=F):F=t[50],F}function at(e){let t=(0,U.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,W.jsx)(x,{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,W.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,W.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,W.jsx)(`li`,{children:Qe(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=i(),{channelId:o}=a(),p=F(o),g=fe(n,e),v=g.entries,{data:y,mutate:b,isValidating:x}=m(n?de():null,ue,{revalidateOnFocus:!0}),{data:C,mutate:T}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),D=C?.channels??{},O=C?.bindings??[],{data:k}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),A=E(e=>e.setPageHeader),N=E(e=>e.clearPageHeader),P=(0,H.useMemo)(()=>v.find(e=>e.id===p),[p,v]),I=P?Ie(P):null,{data:L,mutate:R}=m(n&&I?je(I):null,()=>Me(I)),[z,B]=(0,H.useState)(null),[te,V]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[me,he]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),_e=z??L??{},Y=t.channelsSettings,be=(0,H.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Se=(0,H.useMemo)(()=>We(be,Ne),[be]),we=(0,H.useMemo)(()=>Be(P),[P]),De=(0,H.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,H.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,H.useMemo)(()=>Ge(De),[De]),Re=P?q??ve(O,P.id):``,Z=(0,H.useMemo)(()=>(k?.items??[]).map(e=>{let n=w(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),Ue=Ve?w(Ve,t.agentsSettings):k?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,H.useMemo)(()=>new Map((y??[]).map(e=>[e.name,e])),[y]),Je=y!==void 0,Ye=(0,H.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([g.mutate(),b()])},[g,b]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&b(t,!1)},[b]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,Y,n,x,Q]);(0,H.useLayoutEffect)(()=>(A({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>N()),[N,Xe,t.settingsSections.channels,A]);let Ze=(0,H.useCallback)(e=>{r(ne(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(ee),B(null),J(null),K(null)},[r]),nt=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await d(f(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),he(!1)},[P?.id]);let rt=(0,H.useCallback)(async()=>{if(!P||!z&&q===null)return!1;let e=Ie(P);V(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(O,P.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await g.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{V(!1)}},[P,q,O,g,z,T,R]),ot=(0,H.useCallback)(async e=>{let t=X(e),n=Ie(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await g.mutate(),await T(),await b(),P?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,g,z,T,R,b,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!X(P).ready||me:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[g.isLoading?(0,W.jsx)(se,{sections:2}):g.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:v.map(e=>(0,W.jsx)(tt,{entry:e,config:D[Ie(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:P?.label??Y.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:P?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)($e,{entry:P}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,W.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(P).ready&&pe(P)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,W.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(P).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(et,{checked:X(P).enabled,disabled:re===P.id,label:Y.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void ot(P)})]})]})}),(0,W.jsx)(it,{runtime:ct,restarting:le===P.id,checking:x,showConnectionOptions:me,canManageConnection:X(P).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(P),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,W.jsx)(at,{entry:P,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:P,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(_,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(_,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,st&&Fe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:De,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(M,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(j,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:te||!k,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.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,W.jsx)(M,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:ke,values:_e,onChange:e=>B(e),disabled:te,labels:Ke})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
@@ -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{Gc as a}from"./index-CGwuxvzr.js";var o=n(),s=e(t(),1),c=r(),l={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 u(e){let t=(0,o.c)(18),{connector:n,size:r,className:u}=e,d=r===void 0?`md`:r,f=n?.branding?.logoUrl,[p,m]=(0,s.useState)(!1),h=l[d],g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{m(!1)},t[0]=g):g=t[0];let _;t[1]===f?_=t[2]:(_=[f],t[1]=f,t[2]=_),(0,s.useEffect)(g,_);let v;t[3]!==u||t[4]!==h.frame?(v=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,h.frame,u),t[3]=u,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]!==f?(x=f&&!p?(0,c.jsx)(`img`,{src:f,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,h.image),onError:()=>m(!0)}):(0,c.jsx)(a,{className:i(`text-fg-muted`,h.fallback),"aria-hidden":!0}),t[8]=h.fallback,t[9]=h.image,t[10]=p,t[11]=f,t[12]=x):x=t[12];let S;return t[13]!==v||t[14]!==y||t[15]!==b||t[16]!==x?(S=(0,c.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}export{u as t};
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{Gc as a}from"./index-BhQMnKH1.js";var o=n(),s=e(t(),1),c=r(),l={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 u(e){let t=(0,o.c)(18),{connector:n,size:r,className:u}=e,d=r===void 0?`md`:r,f=n?.branding?.logoUrl,[p,m]=(0,s.useState)(!1),h=l[d],g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{m(!1)},t[0]=g):g=t[0];let _;t[1]===f?_=t[2]:(_=[f],t[1]=f,t[2]=_),(0,s.useEffect)(g,_);let v;t[3]!==u||t[4]!==h.frame?(v=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,h.frame,u),t[3]=u,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]!==f?(x=f&&!p?(0,c.jsx)(`img`,{src:f,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,h.image),onError:()=>m(!0)}):(0,c.jsx)(a,{className:i(`text-fg-muted`,h.fallback),"aria-hidden":!0}),t[8]=h.fallback,t[9]=h.image,t[10]=p,t[11]=f,t[12]=x):x=t[12];let S;return t[13]!==v||t[14]!==y||t[15]!==b||t[16]!==x?(S=(0,c.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}export{u as t};