@lacneu/atrium 0.91.3 → 0.91.4

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 (58) hide show
  1. package/dist/assets/{AccessTab-B7Qb2-lZ.js → AccessTab-CtjTuJS1.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-Bm0I1TOa.js → AdvancedFilter-BFXkHS7k.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-CK7t36QE.js → AgentFilesTab-EIaok7Cs.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-PBcXokbs.js → AnomaliesTab-D1h-Tspq.js} +1 -1
  5. package/dist/assets/{AuditTab-DVjMAHXs.js → AuditTab-CEji-XO8.js} +1 -1
  6. package/dist/assets/{BridgeTab-Dt95NA_7.js → BridgeTab-Bs8cvrzB.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-DZ9ZL3EP.js → ChatDefaultsTab-B76_pV-a.js} +1 -1
  8. package/dist/assets/{DataTableShell-P8WPv8pJ.js → DataTableShell-7VOYauXM.js} +1 -1
  9. package/dist/assets/{DetailChips-Bb_1pD-w.js → DetailChips-DxxeU-mf.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-B6sjorN_.js → FeedbacksTab-CQJddboV.js} +1 -1
  11. package/dist/assets/{FieldLabel-DaWvOVaq.js → FieldLabel-CZ-m3Yh8.js} +1 -1
  12. package/dist/assets/{FilesTab-CGrWd9d1.js → FilesTab-BLVuhYUu.js} +1 -1
  13. package/dist/assets/{FilterBar-BWsi04G_.js → FilterBar-B0W1nP3i.js} +1 -1
  14. package/dist/assets/{GroupsTab-6-wQE2Ui.js → GroupsTab-eCgjhSeI.js} +1 -1
  15. package/dist/assets/{InstancesTab-BWYzJd_a.js → InstancesTab-C9knJ9ku.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-CK7DSB-M.js → IntegrationsTab-GG79wWrt.js} +1 -1
  17. package/dist/assets/{KpiTab-C54gwXNq.js → KpiTab-BVMR3rMZ.js} +1 -1
  18. package/dist/assets/{PreferencesTab-BBpLdx_-.js → PreferencesTab-DOEuFzay.js} +1 -1
  19. package/dist/assets/{ProjectPage-BUGdPdmU.js → ProjectPage-CVpssY-3.js} +1 -1
  20. package/dist/assets/{PromptInjectionsTab-BHJ0-ZWI.js → PromptInjectionsTab-Dbp3yLMc.js} +1 -1
  21. package/dist/assets/{RolesTab-YmvPDwpq.js → RolesTab-CFa0qonh.js} +1 -1
  22. package/dist/assets/{ScheduledTab-BZiFyTay.js → ScheduledTab-QgcyWf16.js} +1 -1
  23. package/dist/assets/{ServiceAccountsTab-MGyT4mVz.js → ServiceAccountsTab-X_bQzXIS.js} +1 -1
  24. package/dist/assets/{SubAgentReportsTab-UQMDNwEo.js → SubAgentReportsTab-Jf1zcgs0.js} +1 -1
  25. package/dist/assets/{ThemeShowroom-KiqSBvlh.js → ThemeShowroom-DCxA68bn.js} +1 -1
  26. package/dist/assets/{TimeRangePicker-BVCNIF4U.js → TimeRangePicker-BgJKavXM.js} +1 -1
  27. package/dist/assets/{TimezoneCombobox-BB280Bgg.js → TimezoneCombobox-BkDGMdB2.js} +1 -1
  28. package/dist/assets/{TracesTab-yAjObtOK.js → TracesTab-Bzw8y55N.js} +1 -1
  29. package/dist/assets/{TrashPage-DK0mKtzJ.js → TrashPage-YhpHdmVr.js} +1 -1
  30. package/dist/assets/{TrashTab-S6IkI4t6.js → TrashTab-BuQ50Qu2.js} +1 -1
  31. package/dist/assets/{UsersTab-DTvPti51.js → UsersTab-zHZZ8QUo.js} +1 -1
  32. package/dist/assets/{VoiceTab-CYJea2dn.js → VoiceTab-IEStNr9Y.js} +1 -1
  33. package/dist/assets/api-DcB3BxUc.js +44 -0
  34. package/dist/assets/{button-D0Pgjwxf.js → button-DgaBsJDX.js} +1 -1
  35. package/dist/assets/{card-BaftCgRb.js → card-DnOLp6jN.js} +1 -1
  36. package/dist/assets/chevrons-up-down-R0Y7ndDn.js +1 -0
  37. package/dist/assets/{compatView-qPB4mG-_.js → compatView-Cyz2oaDo.js} +1 -1
  38. package/dist/assets/{dispatchErrorInfo-Wn57FY4L.js → dispatchErrorInfo-ALhveHh9.js} +1 -1
  39. package/dist/assets/{dist-CeZTHwrs.js → dist-BFXL2p5c.js} +1 -1
  40. package/dist/assets/{dist-CH3gjR1_.js → dist-CYBhnY4b.js} +1 -1
  41. package/dist/assets/{dist-DAKYY4yE.js → dist-D96qX4Zd.js} +1 -1
  42. package/dist/assets/{dist-By4rZwo-.js → dist-DHnmL-lz.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-D4p66OHE.js → highlighted-body-OFNGDK62-CJ8J6p8l.js} +1 -1
  44. package/dist/assets/{index-xhYNLD3V.js → index-Ds-ybIOh.js} +7 -7
  45. package/dist/assets/{list-Dx86Q3WV.js → list-CKshqcfm.js} +1 -1
  46. package/dist/assets/mermaid-GHXKKRXX-lChj9izi.js +1 -0
  47. package/dist/assets/{pdf-BW6qvf4R.js → pdf-DeAT0bfe.js} +1 -1
  48. package/dist/assets/roleDescriptions-DHMAPGYx.js +1 -0
  49. package/dist/assets/{table-DsK3yFpt.js → table-A3AeBsY1.js} +1 -1
  50. package/dist/assets/{use_paginated_query-JzX-Y80s.js → use_paginated_query-Dc9YWxua.js} +1 -1
  51. package/dist/assets/x-DJcI0sFP.js +1 -0
  52. package/dist/index.html +8 -8
  53. package/package.json +1 -1
  54. package/dist/assets/api-BiOKjOdr.js +0 -44
  55. package/dist/assets/chevrons-up-down-CogPekve.js +0 -1
  56. package/dist/assets/mermaid-GHXKKRXX-wpDfhXTf.js +0 -1
  57. package/dist/assets/roleDescriptions-DKA8gzL4.js +0 -1
  58. package/dist/assets/x-BXqaL85P.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,Qb as i,VY as a,Xb as o,Zb as s,ax as c,cx as l,ex as u,ix as d,jY as f,lx as p,nx as m,ox as h,rx as g,sx as _,t as v,tx as y,ux as b}from"./api-BiOKjOdr.js";import{Jt as x,St as S,bt as C,vt as w,xt as T,yt as E}from"./index-xhYNLD3V.js";var D=t(e(),1);function O(e){return e===`user`?u():e===`all`?r():i({group:e.group})}function k(e){return e===`common`?s():e===`owner`?o():i({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=a(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),r=a(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}),(0,A.jsxs)(w,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":p(),children:(0,A.jsx)(S,{placeholder:p()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(C,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):r===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:_()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:r.user.label}),(0,A.jsx)(x,{variant:`secondary`,children:r.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:h()}),r.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.groups.map(e=>(0,A.jsx)(x,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),r.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(x,{variant:`default`,children:y()}):null,(0,A.jsx)(x,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(x,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:d()}),r.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(x,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),r.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.permissions.map(e=>(0,A.jsx)(x,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$b as r,Qb as i,VY as a,Xb as o,Zb as s,ax as c,cx as l,ex as u,ix as d,jY as f,lx as p,nx as m,ox as h,rx as g,sx as _,t as v,tx as y,ux as b}from"./api-DcB3BxUc.js";import{Jt as x,St as S,bt as C,vt as w,xt as T,yt as E}from"./index-Ds-ybIOh.js";var D=t(e(),1);function O(e){return e===`user`?u():e===`all`?r():i({group:e.group})}function k(e){return e===`common`?s():e===`owner`?o():i({group:e.group})}var A=n();function j(e){return e.name||e.email||e.userId.slice(0,8)}function M(){let e=a(v.admin.listUsers,{}),[t,n]=(0,D.useState)(``),r=a(v.introspect.introspectUser,t?{userId:t}:`skip`);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:b()}),(0,A.jsxs)(w,{value:t,onValueChange:n,children:[(0,A.jsx)(T,{size:`sm`,"aria-label":p(),children:(0,A.jsx)(S,{placeholder:p()})}),(0,A.jsx)(E,{children:(e??[]).map(e=>(0,A.jsx)(C,{value:e.userId,children:j(e)},e._id))})]}),t===``?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):r===void 0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:f()}):(0,A.jsxs)(`div`,{className:`oc-introspect`,children:[(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:_()}),(0,A.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,A.jsx)(`strong`,{children:r.user.label}),(0,A.jsx)(x,{variant:`secondary`,children:r.role})]})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:h()}),r.groups.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.groups.map(e=>(0,A.jsx)(x,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:c()}),r.agents.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.agents.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,A.jsx)(x,{variant:`default`,children:y()}):null,(0,A.jsx)(x,{variant:`outline`,children:O(e.via)}),(0,A.jsx)(x,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:d()}),r.charts.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`ul`,{className:`oc-introspect__list`,children:r.charts.map(e=>(0,A.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,A.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,A.jsx)(x,{variant:`outline`,children:k(e.via)})]},e.key))})]}),(0,A.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,A.jsx)(`h3`,{className:`oc-introspect__title`,children:g()}),r.permissions.length===0?(0,A.jsx)(`p`,{className:`oc-admin__hint`,children:m()}):(0,A.jsx)(`div`,{className:`oc-introspect__chips`,children:r.permissions.map(e=>(0,A.jsx)(x,{variant:`secondary`,children:e},e))})]})]})]})}export{M as AccessTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AC as r,FC as i,MC as a,NC as o,PC as s,jC as c,kC as l}from"./api-BiOKjOdr.js";import{r as u}from"./dist-DAKYY4yE.js";import{t as d}from"./x-BXqaL85P.js";import{t as f}from"./button-D0Pgjwxf.js";import{$t as p,Ln as m,St as h,bt as g,vt as _,xt as v,yt as y}from"./index-xhYNLD3V.js";import{r as b}from"./TimeRangePicker-BVCNIF4U.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:i()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],w=1;function T(){return{id:w++,field:``,op:`eq`,value:``}}function E(e){return e.map(e=>({id:w++,field:e.field,op:e.op,value:String(e.value)}))}function D({fields:e,seed:t,onChange:n}){let i=(0,x.useRef)(t),w=!!(i.current&&i.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(i.current):[]);function j(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:b(e.value)})))}function M(e,t){let n=k.map(n=>n.id===e?{...n,...t}:n);A(n),j(n)}function N(){A(e=>[...e,T()])}function P(e){let t=k.filter(t=>t.id!==e);A(t),j(t)}let F=k.filter(e=>e.field!==``&&e.value!==``).length;return(0,S.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,S.jsx)(u,{className:`oc-advfilter__chevron`+(D?` is-open`:``),"aria-hidden":!0}),s(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(_,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(h,{placeholder:a()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(_,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(h,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(p,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:c()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(m,{}),l()]})]}):null]})}export{D as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AC as r,FC as i,MC as a,NC as o,PC as s,jC as c,kC as l}from"./api-DcB3BxUc.js";import{r as u}from"./dist-D96qX4Zd.js";import{t as d}from"./x-DJcI0sFP.js";import{t as f}from"./button-DgaBsJDX.js";import{$t as p,Ln as m,St as h,bt as g,vt as _,xt as v,yt as y}from"./index-Ds-ybIOh.js";import{r as b}from"./TimeRangePicker-BgJKavXM.js";var x=t(e(),1),S=n(),C=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:i()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],w=1;function T(){return{id:w++,field:``,op:`eq`,value:``}}function E(e){return e.map(e=>({id:w++,field:e.field,op:e.op,value:String(e.value)}))}function D({fields:e,seed:t,onChange:n}){let i=(0,x.useRef)(t),w=!!(i.current&&i.current.length>0),[D,O]=(0,x.useState)(w),[k,A]=(0,x.useState)(()=>w?E(i.current):[]);function j(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:b(e.value)})))}function M(e,t){let n=k.map(n=>n.id===e?{...n,...t}:n);A(n),j(n)}function N(){A(e=>[...e,T()])}function P(e){let t=k.filter(t=>t.id!==e);A(t),j(t)}let F=k.filter(e=>e.field!==``&&e.value!==``).length;return(0,S.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":D,onClick:()=>O(e=>!e),children:[(0,S.jsx)(u,{className:`oc-advfilter__chevron`+(D?` is-open`:``),"aria-hidden":!0}),s(),F>0?(0,S.jsx)(`span`,{className:`oc-advfilter__count`,children:F}):null]}),D?(0,S.jsxs)(`div`,{className:`oc-advfilter__body`,children:[k.length===0?(0,S.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):(0,S.jsx)(`ul`,{className:`oc-advfilter__rows`,children:k.map(t=>(0,S.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,S.jsxs)(_,{value:t.field||void 0,onValueChange:e=>M(t.id,{field:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-40`,children:(0,S.jsx)(h,{placeholder:a()})}),(0,S.jsx)(y,{children:e.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsxs)(_,{value:t.op,onValueChange:e=>M(t.id,{op:e}),children:[(0,S.jsx)(v,{size:`sm`,className:`w-28`,children:(0,S.jsx)(h,{})}),(0,S.jsx)(y,{children:C.map(e=>(0,S.jsx)(g,{value:e.value,children:e.label},e.value))})]}),(0,S.jsx)(p,{className:`oc-advfilter__value`,value:t.value,onChange:e=>M(t.id,{value:e.target.value}),placeholder:c()}),(0,S.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":r(),onClick:()=>P(t.id),children:(0,S.jsx)(d,{})})]},t.id))}),(0,S.jsxs)(f,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:N,children:[(0,S.jsx)(m,{}),l()]})]}):null]})}export{D as t};
@@ -1,3 +1,3 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,A_ as i,Ad as a,BY as o,C_ as s,D_ as c,E_ as l,F_ as u,Fd as d,HB as f,M_ as p,Md as m,NY as ee,N_ as h,Nd as g,O_ as _,P_ as v,Pd as y,Qd as b,RY as x,S_ as S,T_ as C,VY as w,Zd as T,__ as E,_f as D,af as O,b_ as te,c_ as k,cf as A,d_ as j,df as M,ef as N,f_ as P,ff as F,g_ as I,gf as L,h_ as ne,hf as R,if as z,jY as B,j_ as re,jd as V,k_ as ie,kd as H,l_ as ae,lf as oe,m_ as U,mf as se,nf as W,o_ as ce,of as le,p_ as ue,pf as de,rf as fe,s_ as pe,sf as me,ss as he,t as G,tf as ge,u_ as _e,uf as ve,v_ as ye,w_ as be,x_ as xe,xv as K,y_ as Se,yv as Ce}from"./api-BiOKjOdr.js";import{t as q}from"./button-D0Pgjwxf.js";import{Bt as we,Ct as Te,Dt as Ee,Gt as De,Ht as Oe,Jt as ke,Kt as Ae,Ot as je,St as Me,Tt as Ne,Ut as Pe,Vt as Fe,Wt as Ie,Yt as J,bt as Le,ft as Re,kn as Y,nt as ze,qt as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-xhYNLD3V.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-qPB4mG-_.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$d as r,A_ as i,Ad as a,BY as o,C_ as s,D_ as c,E_ as l,F_ as u,Fd as d,HB as f,M_ as p,Md as m,NY as ee,N_ as h,Nd as g,O_ as _,P_ as v,Pd as y,Qd as b,RY as x,S_ as S,T_ as C,VY as w,Zd as T,__ as E,_f as D,af as O,b_ as te,c_ as k,cf as A,d_ as j,df as M,ef as N,f_ as P,ff as F,g_ as I,gf as L,h_ as ne,hf as R,if as z,jY as B,j_ as re,jd as V,k_ as ie,kd as H,l_ as ae,lf as oe,m_ as U,mf as se,nf as W,o_ as ce,of as le,p_ as ue,pf as de,rf as fe,s_ as pe,sf as me,ss as he,t as G,tf as ge,u_ as _e,uf as ve,v_ as ye,w_ as be,x_ as xe,xv as K,y_ as Se,yv as Ce}from"./api-DcB3BxUc.js";import{t as q}from"./button-DgaBsJDX.js";import{Bt as we,Ct as Te,Dt as Ee,Gt as De,Ht as Oe,Jt as ke,Kt as Ae,Ot as je,St as Me,Tt as Ne,Ut as Pe,Vt as Fe,Wt as Ie,Yt as J,bt as Le,ft as Re,kn as Y,nt as ze,qt as Be,vt as Ve,wt as He,xt as Ue,yt as We}from"./index-Ds-ybIOh.js";import{n as Ge,t as Ke}from"./curation-CQksaIbm.js";import{a as qe}from"./compatView-Cyz2oaDo.js";/* empty css */var X=t(e(),1),Je=2e4,Ye=6e4;function Xe(e){return typeof e!=`number`||e<=0?0:Math.round(e/Je*100)}function Ze(e){return e<=0?0:Math.round(e/Ye*100)}function Z(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function Qe(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var $e=3;function et(e,t){let n=new Map;for(let t of e.split(`
2
2
  `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
3
3
  `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<$e&&a.push(e)):t>0&&(i+=t,o.length<$e&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function tt(e){return(e instanceof Error?e.message:String(e)).includes(`DASHBOARD_NOT_DEPLOYED`)}function nt(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var Q=n(),$=e=>`${e.instanceName}::${e.agentId}`;function rt(){let e=w(G.me.getMe,{host:Re}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=w(G.admin.listInstances,e!==void 0&&t?{}:`skip`),[a,o]=(0,X.useState)(null);(0,X.useEffect)(()=>{!t||!r||r.length===0||(!a||!r.some(e=>e.name===a))&&o(r[0].name)},[t,r,a]);let d=w(G.agents.listAgentsForInstance,t&&a?{instanceName:a}:`skip`),f=w(G.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),m=(0,X.useMemo)(()=>{if(e!==void 0){if(t)return a===null||d===void 0?r!==void 0&&r.length===0?[]:void 0:d.agents.map(e=>({instanceName:a,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(f!==void 0)return f.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,a,d,r,f]),[g,y]=(0,X.useState)(null);(0,X.useEffect)(()=>{!m||m.length===0||(!g||!m.some(e=>$(e)===g))&&y($(m[0]))},[m,g]);let b=m?.find(e=>$(e)===g)??null,S=x(G.agentFiles.listAgentFiles),[T,E]=(0,X.useState)({status:`idle`}),D=b?.instanceName??null,O=b?.agentId??null,te=w(G.compat.forInstance,n&&D!==null?{instanceName:D}:`skip`),k=n&&D!==null?ze(te,`agentFiles`):null,A=k===null?!1:k===`loading`?null:k.blocked,j=(0,X.useCallback)(async()=>{if(!(D===null||O===null)){E({status:`loading`});try{E({status:`done`,files:(await S({instanceName:D,agentId:O})).files})}catch(e){E({status:`error`,dashboardAbsent:tt(e)})}}},[S,D,O]);(0,X.useEffect)(()=>{A===!1&&j()},[j,A]);let[M,N]=(0,X.useState)(null),P=w(G.agentFileCuration.listCurations,t&&D!==null&&O!==null?{instanceName:D,agentId:O}:`skip`),I=w(G.agentFileCuration.curationSettings,t&&D!==null?{instanceName:D}:`skip`),L=x(G.agentFileCuration.requestCuration),[ne,R]=(0,X.useState)(null),[z,V]=(0,X.useState)(null),{toast:H}=J(),ae=(0,X.useMemo)(()=>{let e=new Map;for(let t of P??[])e.has(t.name)||e.set(t.name,t);return e},[P]),oe=(0,X.useCallback)(async e=>{if(!(D===null||O===null)){R(e);try{let t=await L({instanceName:D,agentId:O,name:e,trigger:`manual`});t.ok?H({title:se(),variant:`success`}):H({title:de({reason:t.reason??`unknown`}),variant:`error`})}catch{H({title:F(),variant:`error`})}finally{R(null)}}},[L,D,O,H]),U=ee(),W=(0,X.useMemo)(()=>new Intl.NumberFormat(U,{maximumFractionDigits:0}),[U]);return e===void 0||m===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):(0,Q.jsxs)(`div`,{className:`oc-afiles`,children:[(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:u()}),(0,Q.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,Q.jsxs)(Ve,{value:a??``,onValueChange:e=>o(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":v(),children:(0,Q.jsx)(Me,{})}),(0,Q.jsx)(We,{children:(r??[]).map(e=>(0,Q.jsx)(Le,{value:e.name,children:e.name},e.name))})]}):null,m.length>0?(0,Q.jsxs)(Ve,{value:g??``,onValueChange:e=>y(e),children:[(0,Q.jsx)(Ue,{size:`sm`,"aria-label":h(),children:(0,Q.jsx)(Me,{})}),(0,Q.jsx)(We,{children:m.map(e=>(0,Q.jsx)(Le,{value:$(e),children:e.label},$(e)))})]}):(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}),b===null?null:k===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):k!==null&&k.blocked?(0,Q.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,Q.jsx)(Y,{size:14,"aria-hidden":!0}),` `,qe(k.gatewayVersion,k.provider)]}):T.status===`loading`||T.status===`idle`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):T.status===`error`?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[T.dashboardAbsent?he():i(),` `,!T.dashboardAbsent&&(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void j(),children:Ce()})]}):T.files.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:re()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`oc-afiles__list`,children:T.files.map(e=>{let n=Xe(e.size),r=n>=80;return(0,Q.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,Q.jsx)(ke,{variant:`outline`,children:ie()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`oc-afiles__size`,children:_({size:Z(e.size,U)})}),(0,Q.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,Q.jsx)(`span`,{className:`oc-afiles__pct`,children:c({pct:W.format(n)})}),r?(0,Q.jsx)(Y,{size:14,className:`oc-afiles__warn`,"aria-label":l()}):(0,Q.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>N(e),children:t?be():s()}),t&&!e.missing?(0,Q.jsx)(it,{curatable:Ke.includes(e.name),size:e.size??0,budget:I?.budgetChars??null,enabled:I?.enabled??!1,curation:ae.get(e.name)??null,inFlight:ne===e.name,onCurate:()=>void oe(e.name),onReview:e=>V(e)}):null]},e.name)})}),(0,Q.jsx)(`p`,{className:`oc-afiles__budget`,children:C({used:Z(Qe(T.files),U),total:Z(Ye,U),pct:W.format(Ze(Qe(T.files)))})})]}),M&&b?(0,Q.jsx)(at,{instanceName:b.instanceName,agentId:b.agentId,name:M.name,isAdmin:t,onClose:()=>N(null),onSaved:()=>void j()}):null,z?(0,Q.jsx)(ot,{curationId:z,onClose:()=>V(null),onApplied:()=>{V(null),j()}}):null]})}function it({curatable:e,size:t,budget:n,enabled:r,curation:i,inFlight:a,onCurate:o,onReview:s}){return i?.status===`proposed`?(0,Q.jsx)(q,{variant:`default`,size:`sm`,className:`oc-afiles__curate`,onClick:()=>s(i._id),children:L()}):a||i?.status===`dispatched`||i?.status===`applying`?(0,Q.jsx)(ke,{variant:`outline`,className:`oc-afiles__curate-status`,children:R()}):e&&r&&n!==null&&Ge(t,n)?(0,Q.jsx)(q,{variant:`outline`,size:`sm`,className:`oc-afiles__curate`,onClick:o,children:D()}):null}function at({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=x(G.agentFiles.getAgentFile),s=x(G.agentFiles.setAgentFile),c=J(),[l,u]=(0,X.useState)(null),[d,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),D=(0,X.useCallback)(async r=>{p(!1);try{let i=await o({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||h(i.content),C(!1)}catch{p(!0)}},[o,e,t,n]);(0,X.useEffect)(()=>{D(!1)},[D]);async function O(){if(l!==null){y(!0),T(!1);try{await s({instanceName:e,agentId:t,name:n,content:m,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(I({name:n})),a(),await D(!1)}catch(e){nt(e)?C(!0):T(!0)}finally{y(!1)}}}let A=l!==null&&m!==l.content,M=(0,X.useMemo)(()=>l===null?null:et(l.content,m),[l,m]),N=m.length>Je,F=ee(),L=(0,X.useMemo)(()=>new Intl.NumberFormat(F),[F]);return(0,Q.jsx)(Te,{open:!0,onOpenChange:e=>!e&&i(),children:(0,Q.jsxs)(He,{className:`oc-afiles__editor`,children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(je,{children:S({name:n})}),(0,Q.jsxs)(Ne,{children:[xe({agent:t,instance:e}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` · `,te()]})]})]}),d?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[U(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void D(!1),children:Ce()})]}):l===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{className:`oc-afiles__source`,value:m,readOnly:!r,spellCheck:!1,onChange:e=>h(e.target.value),"aria-label":S({name:n})}),(0,Q.jsx)(`p`,{className:`oc-afiles__hint`,children:Se()}),b?(0,Q.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[ue(),` `,(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void D(!0),children:P()})]}):null,w?(0,Q.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:ne()}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__count${N?` is-over`:``}`,children:ye({count:L.format(m.length),max:L.format(Je)})}),r?(0,Q.jsx)(q,{size:`sm`,disabled:!A||v||b,onClick:()=>_(!0),children:v?K():E()}):null]})]}),(0,Q.jsx)(we,{open:g,onOpenChange:_,children:(0,Q.jsxs)(Pe,{children:[(0,Q.jsxs)(Ae,{children:[(0,Q.jsx)(Be,{children:j({name:n})}),(0,Q.jsx)(Ie,{children:_e({agent:t})})]}),M?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:ae({added:M.added,removed:M.removed})}),M.sampleAdded.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:k()}),M.sampleAdded.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,M.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,Q.jsx)(`span`,{className:`oc-afiles__diff-label`,children:pe()}),M.sampleRemoved.map((e,t)=>(0,Q.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,Q.jsxs)(De,{children:[(0,Q.jsx)(Oe,{children:f()}),(0,Q.jsx)(Fe,{onClick:()=>void O(),children:ce()})]})]})})]})})}function ot({curationId:e,onClose:t,onApplied:n}){let i=w(G.agentFileCuration.getProposal,{curationId:e}),s=x(G.agentFileCuration.approveCuration),c=o(G.agentFileCuration.rejectCuration),{toast:l}=J(),[u,f]=(0,X.useState)(null),[p,h]=(0,X.useState)(!1),[_,v]=(0,X.useState)(``),S=ee(),C=(0,X.useMemo)(()=>i?et(i.beforeContent,i.proposedContent):null,[i]);async function E(){f(`approve`);try{let t=await s({curationId:e});t.ok?(l({title:M(),variant:`success`}),n()):l({title:t.reason===`conflict`?oe():A({reason:t.reason??`unknown`}),variant:`error`})}catch{l({title:F(),variant:`error`})}finally{f(null)}}async function D(n){f(`reject`);try{let r=_.trim();(await c({curationId:e,...r?{comment:r}:{},relaunch:n})).ok?l({title:n?a():ve(),variant:`success`}):l({title:O(),variant:`error`}),t()}catch{l({title:F(),variant:`error`})}finally{f(null)}}return(0,Q.jsx)(Te,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,Q.jsxs)(He,{className:`oc-afiles__review`,children:[(0,Q.jsxs)(Ee,{children:[(0,Q.jsx)(je,{children:i?me({name:i.name}):B()}),(0,Q.jsx)(Ne,{children:le()})]}),i===void 0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:B()}):i===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:O()}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`oc-afiles__review-sizes`,children:[z({before:Z(i.beforeSize,S),after:Z(i.proposedSize,S)}),i.overBudget?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(Y,{size:13,"aria-hidden":!0}),` `,fe()]}):null]}),C?(0,Q.jsx)(`p`,{className:`oc-afiles__review-diff`,children:W({added:C.added,removed:C.removed})}):null,i.feedback?(0,Q.jsx)(`p`,{className:`oc-afiles__review-feedback`,children:H({feedback:i.feedback})}):null,C&&C.sampleRemoved.length>0?(0,Q.jsxs)(`div`,{className:`oc-afiles__review-removed`,children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:T()}),(0,Q.jsx)(`ul`,{children:C.sampleRemoved.map((e,t)=>(0,Q.jsx)(`li`,{children:e||`\xA0`},t))})]}):null,(0,Q.jsxs)(`div`,{className:`oc-afiles__review-panes oc-afiles__review-panes--2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:b()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.beforeContent})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`oc-afiles__review-label`,children:ge()}),(0,Q.jsx)(`pre`,{className:`oc-afiles__review-pre`,children:i.proposedContent})]})]})]}),p?(0,Q.jsxs)(`div`,{className:`oc-afiles__reject-form`,children:[(0,Q.jsx)(`label`,{className:`oc-afiles__review-label`,htmlFor:`curation-reject-comment`,children:d()}),(0,Q.jsx)(`textarea`,{id:`curation-reject-comment`,className:`oc-afiles__reject-textarea`,rows:3,placeholder:y(),value:_,onChange:e=>v(e.target.value)}),(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`ghost`,onClick:()=>h(!1),disabled:u!==null,children:g()}),(0,Q.jsx)(q,{variant:`outline`,onClick:()=>void D(!1),disabled:u!==null,children:u===`reject`?K():m()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void D(!0),disabled:u!==null,children:u===`reject`?K():V()})]})]}):(0,Q.jsxs)(`div`,{className:`oc-afiles__review-actions`,children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>h(!0),disabled:u!==null||i==null,children:N()}),(0,Q.jsx)(q,{variant:`default`,onClick:()=>void E(),disabled:u!==null||i==null,children:u===`approve`?K():r()})]})]})})}export{rt as AgentFilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$j as r,AM as i,BY as ee,CM as te,DM as a,EM as ne,FM as re,Gj as o,IM as ie,Jj as s,Kj as c,LM as l,MM as ae,NM as oe,OM as se,PM as ce,Qj as le,RM as u,SM as ue,TM as de,VY as d,Wj as f,Xj as p,Yj as m,Zj as h,_M as fe,aM as g,bM as pe,cM as me,dM as _,eM as he,fM as ge,gM as v,hM as _e,iM as ve,jM as ye,kM as be,lM as y,mM as xe,nM as Se,oM as Ce,pM as we,qj as b,rM as x,sM as S,t as C,tM as w,uM as T,vM as E,wM as D,xM as O,yM as k,zM as A}from"./api-BiOKjOdr.js";import{At as j,Ct as M,Dt as N,Jt as P,Ot as F,St as I,Yt as Te,bt as L,ct as Ee,dr as R,fr as De,ft as z,i as Oe,o as ke,vt as B,wt as V,xt as H,yt as U}from"./index-xhYNLD3V.js";import{n as Ae}from"./TimeRangePicker-BVCNIF4U.js";import{t as je}from"./FilterBar-BWsi04G_.js";import{t as Me}from"./DataTableShell-P8WPv8pJ.js";import{t as W}from"./dispatchErrorInfo-Wn57FY4L.js";var G=t(e(),1),K=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]),q=new Set([`assistant.cause.provider_auth_revoked`,`assistant.cause.provider_permission_denied`,`assistant.cause.provider_auth_failed`]);function J(e){let t=q.has(e.kind);if(!K.has(e.kind)&&!t||!e.evidence)return{};try{let n=JSON.parse(e.evidence);if(t){let e=Array.isArray(n.agents)?n.agents.filter(e=>typeof e==`string`):[],t=Array.isArray(n.providers)?n.providers.filter(e=>typeof e==`string`):[],r=e.length===1?e[0]:void 0;return{dominantCode:n.cause,sampleCorrelationId:n.sampleCorrelationId,context:{...r===void 0?{}:{agentId:r.slice(r.lastIndexOf(`/`)+1)},...t.length===1?{provider:t[0]}:{}}}}return{dominantCode:n.dominantCode,sampleCorrelationId:n.sampleCorrelationId}}catch{return{}}}var Y=n(),X=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?A():e===`acknowledged`?u():l()}var Fe=[`info`,`warn`,`critical`],Ie=[`detector`,`agent`,`user`],Le={kind:`relative`,from:`now-30d`,to:`now`},Re=200,Z=`all`;function Q(){let e=De({from:`/settings/anomalies`}),t=R({from:`/settings/anomalies`}),n=e.q??``,o=e.status===Z?X:e.status,s=e.severity??X,c=e.kind??X,[l,u]=(0,G.useState)(X),f=Oe(e.from,e.to),{from:p,to:m}=Ae(f),h=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),b=e=>void t({search:t=>({...t,status:e===X?Z:e})}),A=e=>void t({search:t=>({...t,severity:e===X?void 0:e})}),M=e=>void t({search:t=>({...t,kind:e===X?void 0:e})}),N=e=>void t({search:t=>({...t,...ke(e)})}),F=Ee(),V=Te(),W=ee(C.anomalies.resolveAnomaly),K=(d(C.me.getMe,{host:z})?.permissions??[]).includes(`admin.manage`),q=d(C.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:p,to:m,anomalyStatus:o===X?void 0:o,severity:s===X?void 0:s,source:l===X?void 0:l,kind:c===X?void 0:c}}),J=(0,G.useMemo)(()=>{let e=new Set;for(let t of q??[])e.add(t.kind);return[...e].sort()},[q]),Q=n!==``||o!==`open`||s!==X||l!==X||c!==X||f.kind!==`relative`||f.from!==Le.from;function $(){u(X),t({search:{status:`open`},replace:!0})}async function We(e){if(await F({title:ie(),description:(0,Y.jsxs)(Y.Fragment,{children:[re(),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ce(),` `,(0,Y.jsx)(`strong`,{children:oe()}),`.`,` `,ae()]}),confirmLabel:ye()}))try{await W({anomalyId:e._id,status:`resolved`}),V.success(i(),e.kind)}catch(e){V.error(be(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),V.success(se(),e.kind)}catch(e){V.error(a(),e)}}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,Y.jsx)(`strong`,{children:de()}),` `,D(),` `,(0,Y.jsx)(`strong`,{children:te()}),` `,ue(),` `,(0,Y.jsx)(`strong`,{children:O()}),` `,pe(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:k()})]}),(0,Y.jsxs)(je,{q:n,onQChange:h,searchPlaceholder:E(),timeRange:f,onTimeRangeChange:N,onReset:$,canReset:Q,children:[(0,Y.jsxs)(B,{value:o,onValueChange:b,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:fe()}),Ne.map(e=>(0,Y.jsx)(L,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,Y.jsxs)(B,{value:s,onValueChange:A,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:v()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:ge()}),Fe.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:l,onValueChange:u,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(I,{placeholder:_()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:T()}),Ie.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:c,onValueChange:M,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:y()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:me()}),J.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]})]}),(0,Y.jsx)(Me,{title:S(),rows:q,emptyHint:o===`open`?Ce():g(),rowActions:e=>K&&e.status===`open`?[{label:ve(),onSelect:()=>void We(e)},{label:x(),onSelect:()=>void Ge(e)}]:[],columns:[{header:Se(),cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:j(e.at)}),sort:e=>e.at},{header:y(),cell:e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:_e(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,Y.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:we({when:j(e.firstAt)}),children:xe({count:String(e.occurrenceCount)})}):(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:v(),cell:e=>(0,Y.jsx)(Ve,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:w(),cell:e=>(0,Y.jsx)(He,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:_(),cell:e=>(0,Y.jsx)(P,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:he(),cell:e=>(0,Y.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,Y.jsx)(Be,{row:e})]}),sort:e=>e.message},{header:r(),cell:e=>(0,Y.jsx)(ze,{row:e}),sort:e=>e.evidence??null},{header:le(),cell:e=>e.correlationId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:Ue(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function $(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function ze({row:e}){let t=R();if(e.kind===`subagent.failure`){let n=$(e);return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,h()]}):null]})}let n=J(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,Y.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,h()]})}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=W(n.dominantCode,n.context),i=n.sampleCorrelationId;return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,Y.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,h()]}):null]})}function Be({row:e}){let[t,n]=(0,G.useState)(!1),r=d(C.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[p(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,Y.jsx)(M,{open:t,onOpenChange:n,children:(0,Y.jsxs)(V,{className:`oc-anomaly__attachments-dialog`,children:[(0,Y.jsx)(N,{children:(0,Y.jsx)(F,{children:m()})}),r===void 0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:s()}):r.length===0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:b()}):(0,Y.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,Y.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,Y.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,Y.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Ve({severity:e}){return(0,Y.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function He({status:e}){return e===`open`?(0,Y.jsx)(P,{variant:`destructive`,children:c()}):e===`acknowledged`?(0,Y.jsx)(P,{variant:`secondary`,children:o()}):(0,Y.jsx)(P,{variant:`outline`,children:f()})}function Ue(e){return e.length>8?e.slice(0,8):e}export{Q as AnomaliesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$j as r,AM as i,BY as ee,CM as te,DM as a,EM as ne,FM as re,Gj as o,IM as ie,Jj as s,Kj as c,LM as l,MM as ae,NM as oe,OM as se,PM as ce,Qj as le,RM as u,SM as ue,TM as de,VY as d,Wj as f,Xj as p,Yj as m,Zj as h,_M as fe,aM as g,bM as pe,cM as me,dM as _,eM as he,fM as ge,gM as v,hM as _e,iM as ve,jM as ye,kM as be,lM as y,mM as xe,nM as Se,oM as Ce,pM as we,qj as b,rM as x,sM as S,t as C,tM as w,uM as T,vM as E,wM as D,xM as O,yM as k,zM as A}from"./api-DcB3BxUc.js";import{At as j,Ct as M,Dt as N,Jt as P,Ot as F,St as I,Yt as Te,bt as L,ct as Ee,dr as R,fr as De,ft as z,i as Oe,o as ke,vt as B,wt as V,xt as H,yt as U}from"./index-Ds-ybIOh.js";import{n as Ae}from"./TimeRangePicker-BgJKavXM.js";import{t as je}from"./FilterBar-B0W1nP3i.js";import{t as Me}from"./DataTableShell-7VOYauXM.js";import{t as W}from"./dispatchErrorInfo-ALhveHh9.js";var G=t(e(),1),K=new Set([`openclaw.dispatch_failures`,`assistant.announce_errors`]),q=new Set([`assistant.cause.provider_auth_revoked`,`assistant.cause.provider_permission_denied`,`assistant.cause.provider_auth_failed`]);function J(e){let t=q.has(e.kind);if(!K.has(e.kind)&&!t||!e.evidence)return{};try{let n=JSON.parse(e.evidence);if(t){let e=Array.isArray(n.agents)?n.agents.filter(e=>typeof e==`string`):[],t=Array.isArray(n.providers)?n.providers.filter(e=>typeof e==`string`):[],r=e.length===1?e[0]:void 0;return{dominantCode:n.cause,sampleCorrelationId:n.sampleCorrelationId,context:{...r===void 0?{}:{agentId:r.slice(r.lastIndexOf(`/`)+1)},...t.length===1?{provider:t[0]}:{}}}}return{dominantCode:n.dominantCode,sampleCorrelationId:n.sampleCorrelationId}}catch{return{}}}var Y=n(),X=`__all__`,Ne=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Pe(e){return e===`open`?A():e===`acknowledged`?u():l()}var Fe=[`info`,`warn`,`critical`],Ie=[`detector`,`agent`,`user`],Le={kind:`relative`,from:`now-30d`,to:`now`},Re=200,Z=`all`;function Q(){let e=De({from:`/settings/anomalies`}),t=R({from:`/settings/anomalies`}),n=e.q??``,o=e.status===Z?X:e.status,s=e.severity??X,c=e.kind??X,[l,u]=(0,G.useState)(X),f=Oe(e.from,e.to),{from:p,to:m}=Ae(f),h=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),b=e=>void t({search:t=>({...t,status:e===X?Z:e})}),A=e=>void t({search:t=>({...t,severity:e===X?void 0:e})}),M=e=>void t({search:t=>({...t,kind:e===X?void 0:e})}),N=e=>void t({search:t=>({...t,...ke(e)})}),F=Ee(),V=Te(),W=ee(C.anomalies.resolveAnomaly),K=(d(C.me.getMe,{host:z})?.permissions??[]).includes(`admin.manage`),q=d(C.anomalies.listAnomalies,{limit:Re,filter:{q:n||void 0,from:p,to:m,anomalyStatus:o===X?void 0:o,severity:s===X?void 0:s,source:l===X?void 0:l,kind:c===X?void 0:c}}),J=(0,G.useMemo)(()=>{let e=new Set;for(let t of q??[])e.add(t.kind);return[...e].sort()},[q]),Q=n!==``||o!==`open`||s!==X||l!==X||c!==X||f.kind!==`relative`||f.from!==Le.from;function $(){u(X),t({search:{status:`open`},replace:!0})}async function We(e){if(await F({title:ie(),description:(0,Y.jsxs)(Y.Fragment,{children:[re(),` `,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,ce(),` `,(0,Y.jsx)(`strong`,{children:oe()}),`.`,` `,ae()]}),confirmLabel:ye()}))try{await W({anomalyId:e._id,status:`resolved`}),V.success(i(),e.kind)}catch(e){V.error(be(),e)}}async function Ge(e){try{await W({anomalyId:e._id,status:`acknowledged`}),V.success(se(),e.kind)}catch(e){V.error(a(),e)}}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[ne(),` `,(0,Y.jsx)(`strong`,{children:de()}),` `,D(),` `,(0,Y.jsx)(`strong`,{children:te()}),` `,ue(),` `,(0,Y.jsx)(`strong`,{children:O()}),` `,pe(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:k()})]}),(0,Y.jsxs)(je,{q:n,onQChange:h,searchPlaceholder:E(),timeRange:f,onTimeRangeChange:N,onReset:$,canReset:Q,children:[(0,Y.jsxs)(B,{value:o,onValueChange:b,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:fe()}),Ne.map(e=>(0,Y.jsx)(L,{value:e.value,children:Pe(e.value)},e.value))]})]}),(0,Y.jsxs)(B,{value:s,onValueChange:A,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:v()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:ge()}),Fe.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:l,onValueChange:u,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(I,{placeholder:_()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:T()}),Ie.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]}),(0,Y.jsxs)(B,{value:c,onValueChange:M,children:[(0,Y.jsx)(H,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(I,{placeholder:y()})}),(0,Y.jsxs)(U,{children:[(0,Y.jsx)(L,{value:X,children:me()}),J.map(e=>(0,Y.jsx)(L,{value:e,children:e},e))]})]})]}),(0,Y.jsx)(Me,{title:S(),rows:q,emptyHint:o===`open`?Ce():g(),rowActions:e=>K&&e.status===`open`?[{label:ve(),onSelect:()=>void We(e)},{label:x(),onSelect:()=>void Ge(e)}]:[],columns:[{header:Se(),cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:j(e.at)}),sort:e=>e.at},{header:y(),cell:e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:_e(),cell:e=>e.occurrenceCount!==null&&e.occurrenceCount>1?(0,Y.jsx)(`span`,{className:`oc-traces__time`,title:e.firstAt===null?void 0:we({when:j(e.firstAt)}),children:xe({count:String(e.occurrenceCount)})}):(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:`—`}),sort:e=>e.occurrenceCount??0},{header:v(),cell:e=>(0,Y.jsx)(Ve,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:w(),cell:e=>(0,Y.jsx)(He,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:_(),cell:e=>(0,Y.jsx)(P,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:he(),cell:e=>(0,Y.jsxs)(`div`,{className:`oc-anomaly__msgcell`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),(0,Y.jsx)(Be,{row:e})]}),sort:e=>e.message},{header:r(),cell:e=>(0,Y.jsx)(ze,{row:e}),sort:e=>e.evidence??null},{header:le(),cell:e=>e.correlationId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:Ue(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function $(e){if(e.kind!==`subagent.failure`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{failedCount:t.failedCount,totalCount:t.totalCount,errorCategories:t.errorCategories}}catch{return{}}}function ze({row:e}){let t=R();if(e.kind===`subagent.failure`){let n=$(e);return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsx)(`div`,{className:`oc-anomaly__cause-head`,children:[...new Set(n.errorCategories??[])].map(e=>(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e},e))}),e.correlationId?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:e.correlationId,limit:100}}),children:[`↗ `,h()]}):null]})}let n=J(e);if(!n.dominantCode){let e=n.sampleCorrelationId;return e?(0,Y.jsx)(`div`,{className:`oc-anomaly__cause`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:e,limit:100}}),children:[`↗ `,h()]})}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}let r=W(n.dominantCode,n.context),i=n.sampleCorrelationId;return(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,Y.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,Y.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,Y.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{correlationId:i,limit:100}}),children:[`↗ `,h()]}):null]})}function Be({row:e}){let[t,n]=(0,G.useState)(!1),r=d(C.anomalies.getAnomalyAttachments,t?{anomalyId:e._id}:`skip`);return!e.attachments||e.attachments.length===0?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>n(!0),children:[p(),e.attachments.length>1?` (${e.attachments.length})`:``]}),(0,Y.jsx)(M,{open:t,onOpenChange:n,children:(0,Y.jsxs)(V,{className:`oc-anomaly__attachments-dialog`,children:[(0,Y.jsx)(N,{children:(0,Y.jsx)(F,{children:m()})}),r===void 0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:s()}):r.length===0?(0,Y.jsx)(`p`,{className:`oc-traces__muted`,children:b()}):(0,Y.jsx)(`div`,{className:`oc-anomaly__attachments`,children:r.map(e=>(0,Y.jsxs)(`section`,{className:`oc-anomaly__attachment`,children:[(0,Y.jsx)(`h4`,{className:`oc-anomaly__attachment-name`,children:(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.name})}),(0,Y.jsx)(`pre`,{className:`oc-anomaly__attachment-content`,children:e.content})]},e.name))})]})})]})}function Ve({severity:e}){return(0,Y.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function He({status:e}){return e===`open`?(0,Y.jsx)(P,{variant:`destructive`,children:c()}):e===`acknowledged`?(0,Y.jsx)(P,{variant:`secondary`,children:o()}):(0,Y.jsx)(P,{variant:`outline`,children:f()})}function Ue(e){return e.length>8?e.slice(0,8):e}export{Q as AnomaliesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Au as r,BN as i,Du as a,Eu as o,FN as s,GN as c,HN as l,IN as u,LN as d,MN as f,NN as p,Ou as m,PN as h,RN as g,UN as _,VN as v,VY as y,WN as b,jN as x,ju as S,ku as C,t as w,zN as T}from"./api-BiOKjOdr.js";import{At as E,St as D,a as O,bt as k,dr as A,fr as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-xhYNLD3V.js";import{n as ee}from"./TimeRangePicker-BVCNIF4U.js";import{t as z}from"./FilterBar-BWsi04G_.js";import{t as B}from"./AdvancedFilter-Bm0I1TOa.js";import{t as V}from"./DataTableShell-P8WPv8pJ.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:S()},{value:`realLabel`,label:r()},{value:`targetLabel`,label:C()},{value:`impersonated`,label:m()},{value:`resource`,label:a()},{value:`resourceId`,label:o()}];function q(){let e=j({from:`/settings/audit`}),t=A({from:`/settings/audit`}),n=e.q??``,r=e.action??G,a=e.impersonated??G,o=e.resource??G,m=M(e.from,e.to),S=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:C,to:N}=ee(m),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=y(w.admin.listAudit,{filter:{q:n||void 0,from:C,to:N,action:r===G?void 0:r,resource:o===G?void 0:o,impersonated:a===G?void 0:a===`yes`,advanced:S.length>0?S:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||a!==G||o!==G||S.length>0||m.kind!==`relative`||m.from!==W.from;function ie(){t({search:{},replace:!0})}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`oc-admin__hint`,children:[c(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:b()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:_(),timeRange:m,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(I,{value:r,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:l()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:v()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(I,{value:a,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:i()}),(0,U.jsx)(k,{value:`yes`,children:T()}),(0,U.jsx)(k,{value:`no`,children:g()})]})]}),(0,U.jsxs)(I,{value:o,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:d()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:u()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:S,onChange:Q}),(0,U.jsx)(V,{title:s(),rows:$,emptyHint:h(),columns:[{header:p(),cell:e=>E(e.at),sort:e=>e.at},{header:l(),cell:e=>e.action,sort:e=>e.action},{header:f(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:x(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:d(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Au as r,BN as i,Du as a,Eu as o,FN as s,GN as c,HN as l,IN as u,LN as d,MN as f,NN as p,Ou as m,PN as h,RN as g,UN as _,VN as v,VY as y,WN as b,jN as x,ju as S,ku as C,t as w,zN as T}from"./api-DcB3BxUc.js";import{At as E,St as D,a as O,bt as k,dr as A,fr as j,i as M,n as N,o as P,s as F,vt as I,xt as L,yt as R}from"./index-Ds-ybIOh.js";import{n as ee}from"./TimeRangePicker-BgJKavXM.js";import{t as z}from"./FilterBar-B0W1nP3i.js";import{t as B}from"./AdvancedFilter-BFXkHS7k.js";import{t as V}from"./DataTableShell-7VOYauXM.js";var H=t(e(),1),U=n(),W={kind:`relative`,from:N,to:`now`},G=`__all__`,K=[{value:`action`,label:S()},{value:`realLabel`,label:r()},{value:`targetLabel`,label:C()},{value:`impersonated`,label:m()},{value:`resource`,label:a()},{value:`resourceId`,label:o()}];function q(){let e=j({from:`/settings/audit`}),t=A({from:`/settings/audit`}),n=e.q??``,r=e.action??G,a=e.impersonated??G,o=e.resource??G,m=M(e.from,e.to),S=(0,H.useMemo)(()=>F(e.adv),[e.adv]),{from:C,to:N}=ee(m),q=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),J=e=>void t({search:t=>({...t,action:e===G?void 0:e})}),Y=e=>void t({search:t=>({...t,impersonated:e===G?void 0:e})}),X=e=>void t({search:t=>({...t,resource:e===G?void 0:e})}),Z=e=>void t({search:t=>({...t,...P(e)})}),Q=e=>void t({search:t=>({...t,adv:O(e)}),replace:!0}),$=y(w.admin.listAudit,{filter:{q:n||void 0,from:C,to:N,action:r===G?void 0:r,resource:o===G?void 0:o,impersonated:a===G?void 0:a===`yes`,advanced:S.length>0?S:void 0}}),te=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])e.add(t.action);return[...e].sort()},[$]),ne=(0,H.useMemo)(()=>{let e=new Set;for(let t of $??[])t.resource&&e.add(t.resource);return[...e].sort()},[$]),re=n!==``||r!==G||a!==G||o!==G||S.length>0||m.kind!==`relative`||m.from!==W.from;function ie(){t({search:{},replace:!0})}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`oc-admin__hint`,children:[c(),` `,(0,U.jsx)(`span`,{className:`oc-filter__window`,children:b()})]}),(0,U.jsxs)(z,{q:n,onQChange:q,searchPlaceholder:_(),timeRange:m,onTimeRangeChange:Z,onReset:ie,canReset:re,children:[(0,U.jsxs)(I,{value:r,onValueChange:J,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:l()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:v()}),te.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]}),(0,U.jsxs)(I,{value:a,onValueChange:Y,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:i()}),(0,U.jsx)(k,{value:`yes`,children:T()}),(0,U.jsx)(k,{value:`no`,children:g()})]})]}),(0,U.jsxs)(I,{value:o,onValueChange:X,children:[(0,U.jsx)(L,{size:`sm`,className:`w-40`,children:(0,U.jsx)(D,{placeholder:d()})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(k,{value:G,children:u()}),ne.map(e=>(0,U.jsx)(k,{value:e,children:e},e))]})]})]}),(0,U.jsx)(B,{fields:K,seed:S,onChange:Q}),(0,U.jsx)(V,{title:s(),rows:$,emptyHint:h(),columns:[{header:p(),cell:e=>E(e.at),sort:e=>e.at},{header:l(),cell:e=>e.action,sort:e=>e.action},{header:f(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:x(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:d(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}export{q as AuditTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,AO as i,Ak as a,BO as o,BY as s,Bg as c,Bk as l,CO as u,DO as d,E as f,EO as p,FO as m,Fk as ee,GO as h,Gg as g,HO as _,Hg as v,IO as y,Ik as te,JO as b,Jg as ne,Jl as re,KO as ie,Kg as ae,LO as oe,Lg as se,Lk as ce,MO as le,Mg as ue,NO as de,OO as fe,PO as pe,Pk as me,QO as he,RO as ge,RY as _e,Rg as ve,Rk as ye,SO as be,TO as xe,UO as Se,Ug as Ce,Uk as we,VO as Te,VY as x,Va as Ee,Vg as De,Vk as Oe,WO as ke,Wg as S,Wk as Ae,XO as je,Xl as Me,YO as Ne,Yg as Pe,Yl as Fe,ZO as Ie,Zl as Le,_O as Re,ak as ze,bO as Be,ck as Ve,cs as He,dO as Ue,ek as We,eu as Ge,fO as C,gO as Ke,hO as qe,ik as Je,jO as Ye,jk as Xe,kO as Ze,mO as Qe,nk as $e,ok as et,pO as tt,qO as nt,qg as rt,ql as it,rk as at,sk as ot,t as w,tk as st,uO as T,vO as ct,wO as E,xO as lt,yO as ut,zO as dt,zg as ft,zk as pt}from"./api-BiOKjOdr.js";import{r as D}from"./dist-DAKYY4yE.js";import{t as mt}from"./chevrons-up-down-CogPekve.js";import{i as ht,n as O,o as gt,r as _t,s as vt}from"./FieldLabel-DaWvOVaq.js";import{t as k}from"./button-D0Pgjwxf.js";import{$t as A,At as yt,Ct as bt,Dt as xt,Jn as St,Jt as j,L as Ct,Mt as wt,Ot as Tt,Pn as Et,St as M,Tt as Dt,Yt as Ot,ar as N,at as kt,bt as P,cn as At,dr as F,fr as jt,ft as Mt,it as Nt,jt as I,kn as L,on as Pt,or as Ft,ot as It,sn as Lt,sr as Rt,st as zt,vt as R,wt as Bt,xt as z,yt as B}from"./index-xhYNLD3V.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as V,n as Ut,o as H,r as U,t as Wt}from"./table-DsK3yFpt.js";import{t as Gt}from"./FilterBar-BWsi04G_.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-qPB4mG-_.js";import{t as W}from"./dispatchErrorInfo-Wn57FY4L.js";var $t=f(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=f(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function tn(e){return e.filter(e=>e.state===`error`)}function nn(e){return e.reachable&&tn(e.targets).length===0}function rn(e){return nn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function an(e){return e.state===`error`&&e.lastErrorCode!==null}function on(e){return!!e.lastDownstreamRejectCode}function K(e){return!!e.lastLocalRefusalCode}function sn(e){return an(e)||on(e)||K(e)}function q(e){return e.kind??`openclaw`}function cn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function ln(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,un={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function dn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function fn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function mn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Zt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function hn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=pn(t.key,e),a=pn(t.key,r);return i&&a?0:i?1:a?-1:n*mn(t.key,e,r)})}function gn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function _n(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>Z(e.label,t.label))}function vn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??Z(e,t))}var Q=n();function yn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(un),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),s=(0,G.useMemo)(()=>gn(o),[o]),c=(0,G.useMemo)(()=>_n(o),[o]),l=(0,G.useMemo)(()=>vn(o),[o]),d=(0,G.useMemo)(()=>hn(fn(o,n),i),[o,n,i]);function f(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Gt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:xe(),onReset:()=>r(un),canReset:dn(n),children:[(0,Q.jsxs)(R,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(M,{placeholder:u()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),s.map(e=>(0,Q.jsx)(P,{value:e,children:xn(e)},e))]})]}),(0,Q.jsxs)(R,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(M,{placeholder:be()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),c.map(e=>(0,Q.jsx)(P,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(R,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(M,{placeholder:lt()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),l.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))]})]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Be()}):(0,Q.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)($,{label:ut(),sortKey:`target`,sort:i,onSort:f}),(0,Q.jsx)($,{label:ct(),sortKey:`state`,sort:i,onSort:f}),(0,Q.jsx)($,{label:Re(),sortKey:`instance`,sort:i,onSort:f}),(0,Q.jsx)($,{label:Ke(),sortKey:`host`,sort:i,onSort:f}),(0,Q.jsx)($,{label:qe(),sortKey:`version`,sort:i,onSort:f}),(0,Q.jsx)(V,{children:Qe()}),(0,Q.jsx)($,{label:tt(),sortKey:`lastOk`,sort:i,onSort:f})]})}),(0,Q.jsx)(Ut,{children:d.map(e=>(0,Q.jsx)(bn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}):(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(mt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function bn({r:e}){let t=an(e)?W(e.lastErrorCode):null,n=on(e)?W(e.lastDownstreamRejectCode):null,r=K(e)?W(e.lastLocalRefusalCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(U,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(Sn,{state:e.state})}),(0,Q.jsx)(U,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(U,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:d({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(U,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:I(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),sn(e)?(0,Q.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${I(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Ee({label:r.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${I(e.lastLocalRefusalAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[p({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${I(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function xn(e){return e===`connected`?C():e===`error`?Ue():T()}function Sn({state:e}){return e===`connected`?(0,Q.jsx)(j,{variant:`secondary`,children:C()}):e===`error`?(0,Q.jsx)(j,{variant:`destructive`,children:Ue()}):(0,Q.jsx)(j,{variant:`outline`,children:T()})}function Cn(){return x(w.bridgeHealth.getBridgeHealth,{})}function wn(){let e=Cn(),t=x(w.compat.getBridgeCompat,{}),n=x(w.me.getMe,{host:Mt})?.role===`admin`,r=x(w.admin.listInstances,n?{}:`skip`),i=x(w.agents.usageForInstances,n?{}:`skip`),a=F(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=ln(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=jt({from:`/settings/bridge`}),l=F({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Xt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(Tn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:b()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:nt()}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(V,{children:Le()}),(0,Q.jsx)(V,{children:Me()}),(0,Q.jsx)(V,{children:Fe()}),(0,Q.jsx)(V,{children:re()}),(0,Q.jsx)(V,{children:it()})]})}),(0,Q.jsx)(Ut,{children:i.flatMap(e=>{let t=Ct(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(U,{children:t.provider}),(0,Q.jsx)(U,{children:t.label}),(0,Q.jsx)(U,{children:(0,Q.jsxs)(j,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(Nt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Q.jsx)(It,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(zt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Et,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(kt,{value:e.key,children:(0,Q.jsx)(En,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):null]})}function Tn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,a=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,o=t&&t!==null?(0,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),a?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:rt(),children:[`(`,a,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ae({build:t.buildVersion??`?`})]}):null,` · `,g(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:dt()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:ge()});let s=tn(e.targets),c=!e.reachable,l=rn(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=yt(e.checkedAt),p=e.startedAt==null?null:yt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(N,{size:22}):c||l===`gateways_unreachable`?(0,Q.jsx)(en,{size:22}):(0,Q.jsx)(L,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?oe():l===`gateways_unreachable`?de({count:u.length}):c?y():m({count:s.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)($t,{size:12,"aria-hidden":!0}),` `,pe({time:f})]}),p?(0,Q.jsx)(`span`,{children:Ye({time:p})}):null,o]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:le({names:u.join(`, `)})}):null,c?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:i()})]})}function En({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(Et,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),d?(0,Q.jsx)(j,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Pe()}),(0,Q.jsx)(On,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Dn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Rt,{size:13,"aria-hidden":!0}),Ze({count:t.length})]}),f?(0,Q.jsx)(yn,{connections:t,displayByInstance:c}):null]})}function Dn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ie(),i.length>0?(0,Q.jsx)(j,{variant:`destructive`,children:ke({count:i.length})}):a>0?(0,Q.jsx)(j,{variant:`destructive`,children:Se()}):(0,Q.jsx)(j,{variant:`secondary`,children:h()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[_({version:e.vendoredVersion}),r?` · `+Te({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:He({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Rt,{size:13,"aria-hidden":!0}),o({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function On({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:dt()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ne()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:Ge({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:De({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(Mn,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:se()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Q.jsx)(j,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function kn({instance:e,onClose:t}){return(0,Q.jsx)(bt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Bt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(xt,{children:[(0,Q.jsx)(Tt,{children:Ae({instance:e.displayName??e.name})}),(0,Q.jsx)(Dt,{children:we()})]}),(0,Q.jsx)(jn,{instance:e,onClose:t})]})})}function An({label:e,result:t}){return t?t.checked?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Q.jsx)(N,{"aria-hidden":!0}):(0,Q.jsx)(L,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?he():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Ie()]}):null}function jn({instance:e,onClose:t}){let n=s(w.admin.upsertInstanceConfig),i=_e(w.bridge.validateMediaPaths),o=Ot(),c=Vt(e.config?.contentLocale,void 0),[u,d]=(0,G.useState)(()=>ht(e.config??{},c)),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=u.inboundMediaMode===`shared-fs`,y=u.mediaMode===`shared-fs`,b=v||y;async function ne(){h(!0),_(null);try{_(await i({instanceName:e.name,inboundMediaMode:u.inboundMediaMode,mediaMode:u.mediaMode}))}catch(e){o.error($e(),e)}finally{h(!1)}}async function re(){p(!0);try{let r=e.config??{};await n({instanceId:e._id,config:_t(u,r,c)}),t()}catch(e){o.error(te(),e)}finally{p(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:Oe(),help:ee()}),(0,Q.jsxs)(R,{value:u.mediaMode,onValueChange:e=>d({...u,mediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(M,{})}),(0,Q.jsx)(B,{children:vt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:l(),help:me()}),(0,Q.jsxs)(R,{value:u.inboundMediaMode,onValueChange:e=>d({...u,inboundMediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(M,{})}),(0,Q.jsx)(B,{children:gt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:pt(),help:Xe()}),(0,Q.jsx)(A,{type:`number`,min:1,max:4096,className:`w-full`,value:u.mediaMaxMb,onChange:e=>d({...u,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:Ve(),help:ot()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:u.inboundAgentMount,onChange:e=>d({...u,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:et(),help:ze()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:u.outboundAgentMount,onChange:e=>d({...u,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(wt,{checked:u.rehydration,onCheckedChange:e=>d({...u,rehydration:e===!0})}),(0,Q.jsx)(O,{label:ye(),help:a()})]}),b&&g!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(L,{"aria-hidden":!0}),Ne({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{label:We(),result:g.inbound}),(0,Q.jsx)(An,{label:r(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:st()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(L,{"aria-hidden":!0}),je()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void ne(),disabled:m,children:[m?(0,Q.jsx)(St,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?at():Je()]}),(0,Q.jsx)(k,{size:`sm`,onClick:()=>void re(),disabled:f,children:ce()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(At,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?c():ft({count:e.length}),(0,Q.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Lt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:ve()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(j,{variant:`secondary`,children:e},e))})]})]})}export{wn as BridgeTab,kn as InstanceConfigDialog};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$O as r,AO as i,Ak as a,BO as o,BY as s,Bg as c,Bk as l,CO as u,DO as d,E as f,EO as p,FO as m,Fk as ee,GO as h,Gg as g,HO as _,Hg as v,IO as y,Ik as te,JO as b,Jg as ne,Jl as re,KO as ie,Kg as ae,LO as oe,Lg as se,Lk as ce,MO as le,Mg as ue,NO as de,OO as fe,PO as pe,Pk as me,QO as he,RO as ge,RY as _e,Rg as ve,Rk as ye,SO as be,TO as xe,UO as Se,Ug as Ce,Uk as we,VO as Te,VY as x,Va as Ee,Vg as De,Vk as Oe,WO as ke,Wg as S,Wk as Ae,XO as je,Xl as Me,YO as Ne,Yg as Pe,Yl as Fe,ZO as Ie,Zl as Le,_O as Re,ak as ze,bO as Be,ck as Ve,cs as He,dO as Ue,ek as We,eu as Ge,fO as C,gO as Ke,hO as qe,ik as Je,jO as Ye,jk as Xe,kO as Ze,mO as Qe,nk as $e,ok as et,pO as tt,qO as nt,qg as rt,ql as it,rk as at,sk as ot,t as w,tk as st,uO as T,vO as ct,wO as E,xO as lt,yO as ut,zO as dt,zg as ft,zk as pt}from"./api-DcB3BxUc.js";import{r as D}from"./dist-D96qX4Zd.js";import{t as mt}from"./chevrons-up-down-R0Y7ndDn.js";import{i as ht,n as O,o as gt,r as _t,s as vt}from"./FieldLabel-CZ-m3Yh8.js";import{t as k}from"./button-DgaBsJDX.js";import{$t as A,At as yt,Ct as bt,Dt as xt,Jn as St,Jt as j,L as Ct,Mt as wt,Ot as Tt,Pn as Et,St as M,Tt as Dt,Yt as Ot,ar as N,at as kt,bt as P,cn as At,dr as F,fr as jt,ft as Mt,it as Nt,jt as I,kn as L,on as Pt,or as Ft,ot as It,sn as Lt,sr as Rt,st as zt,vt as R,wt as Bt,xt as z,yt as B}from"./index-Ds-ybIOh.js";import{r as Vt}from"./locales-CPjguROj.js";import{a as Ht,i as V,n as Ut,o as H,r as U,t as Wt}from"./table-A3AeBsY1.js";import{t as Gt}from"./FilterBar-B0W1nP3i.js";import{c as Kt,i as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt}from"./compatView-Cyz2oaDo.js";import{t as W}from"./dispatchErrorInfo-ALhveHh9.js";var $t=f(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),en=f(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),G=t(e(),1);function tn(e){return e.filter(e=>e.state===`error`)}function nn(e){return e.reachable&&tn(e.targets).length===0}function rn(e){return nn(e)?(e.unreachableInstances??[]).length>0?`gateways_unreachable`:`ok`:`error`}function an(e){return e.state===`error`&&e.lastErrorCode!==null}function on(e){return!!e.lastDownstreamRejectCode}function K(e){return!!e.lastLocalRefusalCode}function sn(e){return an(e)||on(e)||K(e)}function q(e){return e.kind??`openclaw`}function cn(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function ln(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cn(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q(e)===r)}))}function J(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var Y=`__all__`,un={q:``,state:Y,instance:Y,version:Y},X={connected:0,error:1,idle:2};function dn(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function fn(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function Z(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pn(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function mn(e,t,n){switch(e){case`state`:return(X[t.state]??99)-(X[n.state]??99);case`instance`:return Z(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return Z(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return Zt(e,r)??Z(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return Z(t.targetLabel,n.targetLabel)}}function hn(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=pn(t.key,e),a=pn(t.key,r);return i&&a?0:i?1:a?-1:n*mn(t.key,e,r)})}function gn(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(X[e]??99)-(X[t]??99))}function _n(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>Z(e.label,t.label))}function vn(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>Zt(e,t)??Z(e,t))}var Q=n();function yn({connections:e,displayByInstance:t}){let[n,r]=(0,G.useState)(un),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount+(e.downstreamRejectCount??0)+(e.localRefusalCount??0),attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null,lastLocalRefusalCode:e.lastLocalRefusalCode??null,lastLocalRefusalAt:e.lastLocalRefusalAt??null})),[e,t]),s=(0,G.useMemo)(()=>gn(o),[o]),c=(0,G.useMemo)(()=>_n(o),[o]),l=(0,G.useMemo)(()=>vn(o),[o]),d=(0,G.useMemo)(()=>hn(fn(o,n),i),[o,n,i]);function f(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:fe()}):(0,Q.jsxs)(`div`,{className:`oc-conn`,children:[(0,Q.jsxs)(Gt,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:xe(),onReset:()=>r(un),canReset:dn(n),children:[(0,Q.jsxs)(R,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(M,{placeholder:u()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),s.map(e=>(0,Q.jsx)(P,{value:e,children:xn(e)},e))]})]}),(0,Q.jsxs)(R,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-40`,children:(0,Q.jsx)(M,{placeholder:be()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),c.map(e=>(0,Q.jsx)(P,{value:e.name,children:e.label},e.name))]})]}),(0,Q.jsxs)(R,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-36`,children:(0,Q.jsx)(M,{placeholder:lt()})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(P,{value:Y,children:E()}),l.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))]})]})]}),d.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Be()}):(0,Q.jsxs)(Wt,{className:`oc-conn__table`,children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)($,{label:ut(),sortKey:`target`,sort:i,onSort:f}),(0,Q.jsx)($,{label:ct(),sortKey:`state`,sort:i,onSort:f}),(0,Q.jsx)($,{label:Re(),sortKey:`instance`,sort:i,onSort:f}),(0,Q.jsx)($,{label:Ke(),sortKey:`host`,sort:i,onSort:f}),(0,Q.jsx)($,{label:qe(),sortKey:`version`,sort:i,onSort:f}),(0,Q.jsx)(V,{children:Qe()}),(0,Q.jsx)($,{label:tt(),sortKey:`lastOk`,sort:i,onSort:f})]})}),(0,Q.jsx)(Ut,{children:d.map(e=>(0,Q.jsx)(bn,{r:e},e._id))})]})]})}function $({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,Q.jsx)(V,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,Q.jsx)(Ft,{size:13,"aria-hidden":!0}):(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(mt,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function bn({r:e}){let t=an(e)?W(e.lastErrorCode):null,n=on(e)?W(e.lastDownstreamRejectCode):null,r=K(e)?W(e.lastLocalRefusalCode):null;return(0,Q.jsxs)(G.Fragment,{children:[(0,Q.jsxs)(H,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,Q.jsx)(U,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(Sn,{state:e.state})}),(0,Q.jsx)(U,{children:e.instanceLabel?(0,Q.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,Q.jsx)(U,{children:e.gatewayVersion?(0,Q.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,Q.jsx)(U,{children:(0,Q.jsx)(`span`,{className:`oc-conn__stats`,children:d({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,Q.jsx)(U,{children:e.lastOkAt?(0,Q.jsx)(`span`,{className:`oc-traces__mono`,children:I(e.lastOkAt)}):(0,Q.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),sn(e)?(0,Q.jsx)(H,{className:`oc-conn__detail-row`,children:(0,Q.jsxs)(U,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,Q.jsx)(`strong`,{children:t.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${I(e.lastErrorAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,r?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[Ee({label:r.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastLocalRefusalCode}),e.lastLocalRefusalAt?` · ${I(e.lastLocalRefusalAt)}`:``,(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:r.hint})]}):null,n?(0,Q.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[p({label:n.label}),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${I(e.lastDownstreamRejectAt)}`:``]}):null]})}):null]})}function xn(e){return e===`connected`?C():e===`error`?Ue():T()}function Sn({state:e}){return e===`connected`?(0,Q.jsx)(j,{variant:`secondary`,children:C()}):e===`error`?(0,Q.jsx)(j,{variant:`destructive`,children:Ue()}):(0,Q.jsx)(j,{variant:`outline`,children:T()})}function Cn(){return x(w.bridgeHealth.getBridgeHealth,{})}function wn(){let e=Cn(),t=x(w.compat.getBridgeCompat,{}),n=x(w.me.getMe,{host:Mt})?.role===`admin`,r=x(w.admin.listInstances,n?{}:`skip`),i=x(w.agents.usageForInstances,n?{}:`skip`),a=F(),o=()=>void a({to:`/settings/anomalies`,search:{status:`open`}}),s=ln(e?e.targets:[],t?t.targets:[],r??[]),{section:c}=jt({from:`/settings/bridge`}),l=F({from:`/settings/bridge`}),u=t?.compat??null,d=t===void 0?`loading`:t===null?`nodata`:`ready`,f=u!==null&&Xt(u,`hermes`)&&!s.some(e=>e.key===`hermes`);return(0,Q.jsxs)(`div`,{className:`oc-bridge`,children:[(0,Q.jsx)(Tn,{health:e,compat:t,onSeeAnomalies:o}),(0,Q.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:b()}),i&&i.length>0?(0,Q.jsxs)(`section`,{className:`oc-bridge__usage`,children:[(0,Q.jsx)(`h3`,{className:`oc-bridge__usage-title`,children:nt()}),(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Ht,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(V,{children:Le()}),(0,Q.jsx)(V,{children:Me()}),(0,Q.jsx)(V,{children:Fe()}),(0,Q.jsx)(V,{children:re()}),(0,Q.jsx)(V,{children:it()})]})}),(0,Q.jsx)(Ut,{children:i.flatMap(e=>{let t=Ct(e.usage,Date.now());return t?t.windows.map((t,n)=>(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{className:`font-medium`,children:n===0?e.instanceName:``}),(0,Q.jsx)(U,{children:t.provider}),(0,Q.jsx)(U,{children:t.label}),(0,Q.jsx)(U,{children:(0,Q.jsxs)(j,{variant:t.percentLeft<=10?`destructive`:t.percentLeft<=25?`outline`:`secondary`,children:[t.percentLeft,`%`]})}),(0,Q.jsx)(U,{className:`text-muted-foreground`,children:t.resetText??`—`})]},`${e.instanceName}:${t.provider}:${t.label}`)):[]})})]})]}):null,s.length>0?(0,Q.jsxs)(Nt,{value:s.some(e=>e.key===c)?c:s[0]?.key??`openclaw`,onValueChange:e=>void l({search:{section:e},replace:!0}),children:[(0,Q.jsx)(It,{className:`w-full`,children:s.map(e=>(0,Q.jsxs)(zt,{value:e.key,className:`flex-1 gap-1.5`,children:[(0,Q.jsx)(Et,{size:13,"aria-hidden":!0}),J(e.key)]},e.key))}),s.map(e=>(0,Q.jsx)(kt,{value:e.key,children:(0,Q.jsx)(En,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:u,compatStatus:d,compatReachable:t?.reachable??!0,protocol:e.key===`openclaw`?t?.protocol??null:null})},e.key))]}):null,f?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):null]})}function Tn({health:e,compat:t,onSeeAnomalies:n}){let r=t!=null&&t.buildVersion!=null&&t.bridgeVersion!=null&&t.buildVersion!==t.bridgeVersion,a=t?.buildRevision&&t.buildRevision!==`unknown`?t.buildRevision.slice(0,7):null,o=t&&t!==null?(0,Q.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(t.bridgeVersion)}),a?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{className:`oc-traces__mono`,title:rt(),children:[`(`,a,`)`]})]}):null,r?(0,Q.jsxs)(`strong`,{className:`oc-bridge-card__mismatch`,children:[` `,ae({build:t.buildVersion??`?`})]}):null,` · `,g(),` `,(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?S():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:dt()});if(e===null)return(0,Q.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:ge()});let s=tn(e.targets),c=!e.reachable,l=rn(e),u=e.unreachableInstances??[],d=l===`ok`?`ok`:l===`gateways_unreachable`?`warn`:`error`,f=yt(e.checkedAt),p=e.startedAt==null?null:yt(e.startedAt);return(0,Q.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${d}`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:l===`ok`?(0,Q.jsx)(N,{size:22}):c||l===`gateways_unreachable`?(0,Q.jsx)(en,{size:22}):(0,Q.jsx)(L,{size:22})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,Q.jsx)(`div`,{className:`oc-bridge-card__title`,children:l===`ok`?oe():l===`gateways_unreachable`?de({count:u.length}):c?y():m({count:s.length})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)($t,{size:12,"aria-hidden":!0}),` `,pe({time:f})]}),p?(0,Q.jsx)(`span`,{children:Ye({time:p})}):null,o]}),l===`gateways_unreachable`?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:le({names:u.join(`, `)})}):null,c?(0,Q.jsx)(`p`,{className:`oc-bridge-card__hint`,children:W(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,Q.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:i()})]})}function En({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a,protocol:o}){let s=r?Kt(r,e):null,c=new Map;for(let e of n)c.set(e.name,e.displayName??e.name);let l=[],u=new Set;for(let n of t){if(!n.instanceName||u.has(n.instanceName))continue;u.add(n.instanceName);let t=n.gatewayVersion??null;l.push({instanceName:n.instanceName,displayName:c.get(n.instanceName)??n.instanceName,version:t,state:Jt(t,e,r)})}let d=Qt(l.map(e=>e.state)),[f,p]=(0,G.useState)(!1);return(0,Q.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,Q.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,Q.jsx)(Et,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,Q.jsx)(`span`,{className:`oc-bridge-provider__name`,children:J(e)}),d?(0,Q.jsx)(j,{variant:d===`beyond`||d===`defective`?`destructive`:`secondary`,children:qt(d)}):null]}),(0,Q.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:Pe()}),(0,Q.jsx)(On,{providerName:J(e),support:s,compatStatus:i,compatReachable:a,manifest:r,instanceRows:l}),o?(0,Q.jsx)(Dn,{protocol:o}):null,(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Rt,{size:13,"aria-hidden":!0}),Ze({count:t.length})]}),f?(0,Q.jsx)(yn,{connections:t,displayByInstance:c}):null]})}function Dn({protocol:e}){let[t,n]=(0,G.useState)(!1),r=e.coverage,i=e.drift??[],a=(e.driftOverflow??0)+(e.driftTruncated??0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h4`,{className:`oc-bridge-provider__sub`,children:[ie(),i.length>0?(0,Q.jsx)(j,{variant:`destructive`,children:ke({count:i.length})}):a>0?(0,Q.jsx)(j,{variant:`destructive`,children:Se()}):(0,Q.jsx)(j,{variant:`secondary`,children:h()})]}),(0,Q.jsxs)(`p`,{className:`oc-admin__hint`,children:[_({version:e.vendoredVersion}),r?` · `+Te({handled:r.handled,ignored:r.ignored,gaps:r.gaps}):null]}),a>0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:He({overflow:e.driftOverflow??0,truncated:e.driftTruncated??0})}):null,i.length>0?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:i.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e.shape}),` × `,e.count]},e.shape))}):null,r&&r.gapList.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,Q.jsx)(D,{size:13,"aria-hidden":!0}):(0,Q.jsx)(Rt,{size:13,"aria-hidden":!0}),o({count:r.gapList.length})]}),t?(0,Q.jsx)(`ul`,{className:`oc-bridge-protocol__list`,role:`list`,children:r.gapList.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:e})},e))}):null]}):null]})}function On({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,providerName:a}){return t===`loading`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:dt()}):t===`nodata`?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ne()}):(0,Q.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}),r===null?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(0,Q.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__label`,children:Ge({provider:a})}),e&&e.range!==null?(0,Q.jsx)(`span`,{children:De({min:e.range.min,max:e.range.maxValidated})}):(0,Q.jsx)(`span`,{children:S()}),e?(0,Q.jsx)(Mn,{versions:e.validatedVersions}):null]}),i.length===0?(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:se()}):(0,Q.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,Q.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,Q.jsx)(`code`,{className:`oc-traces__mono`,children:Yt(e.version)}),(0,Q.jsx)(j,{variant:e.state===`supported`?`secondary`:e.state===`beyond`||e.state===`defective`?`destructive`:`outline`,children:qt(e.state)})]},e.instanceName))})]})}function kn({instance:e,onClose:t}){return(0,Q.jsx)(bt,{open:!0,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(Bt,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Q.jsxs)(xt,{children:[(0,Q.jsx)(Tt,{children:Ae({instance:e.displayName??e.name})}),(0,Q.jsx)(Dt,{children:we()})]}),(0,Q.jsx)(jn,{instance:e,onClose:t})]})})}function An({label:e,result:t}){return t?t.checked?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,Q.jsx)(N,{"aria-hidden":!0}):(0,Q.jsx)(L,{"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[e,` — `,t.ok?he():t.detail]})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,Ie()]}):null}function jn({instance:e,onClose:t}){let n=s(w.admin.upsertInstanceConfig),i=_e(w.bridge.validateMediaPaths),o=Ot(),c=Vt(e.config?.contentLocale,void 0),[u,d]=(0,G.useState)(()=>ht(e.config??{},c)),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(null),v=u.inboundMediaMode===`shared-fs`,y=u.mediaMode===`shared-fs`,b=v||y;async function ne(){h(!0),_(null);try{_(await i({instanceName:e.name,inboundMediaMode:u.inboundMediaMode,mediaMode:u.mediaMode}))}catch(e){o.error($e(),e)}finally{h(!1)}}async function re(){p(!0);try{let r=e.config??{};await n({instanceId:e._id,config:_t(u,r,c)}),t()}catch(e){o.error(te(),e)}finally{p(!1)}}return(0,Q.jsx)(`div`,{className:`oc-bridge-config`,children:(0,Q.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:Oe(),help:ee()}),(0,Q.jsxs)(R,{value:u.mediaMode,onValueChange:e=>d({...u,mediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(M,{})}),(0,Q.jsx)(B,{children:vt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:l(),help:me()}),(0,Q.jsxs)(R,{value:u.inboundMediaMode,onValueChange:e=>d({...u,inboundMediaMode:e}),children:[(0,Q.jsx)(z,{size:`sm`,className:`w-full`,children:(0,Q.jsx)(M,{})}),(0,Q.jsx)(B,{children:gt.map(e=>(0,Q.jsx)(P,{value:e,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:pt(),help:Xe()}),(0,Q.jsx)(A,{type:`number`,min:1,max:4096,className:`w-full`,value:u.mediaMaxMb,onChange:e=>d({...u,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),b&&(0,Q.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[v&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:Ve(),help:ot()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:u.inboundAgentMount,onChange:e=>d({...u,inboundAgentMount:e.target.value})})]}),y&&(0,Q.jsxs)(`label`,{className:`oc-field`,children:[(0,Q.jsx)(O,{label:et(),help:ze()}),(0,Q.jsx)(A,{className:`w-full`,spellCheck:!1,value:u.outboundAgentMount,onChange:e=>d({...u,outboundAgentMount:e.target.value})})]})]}),(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(wt,{checked:u.rehydration,onCheckedChange:e=>d({...u,rehydration:e===!0})}),(0,Q.jsx)(O,{label:ye(),help:a()})]}),b&&g!==null&&(0,Q.jsx)(`div`,{className:`oc-bridge-config__check`,children:g.reachable?!g.inbound&&!g.outbound?(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(L,{"aria-hidden":!0}),Ne({reason:g.reason??`?`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{label:We(),result:g.inbound}),(0,Q.jsx)(An,{label:r(),result:g.outbound}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:st()})]}):(0,Q.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,Q.jsx)(L,{"aria-hidden":!0}),je()]})}),(0,Q.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[b&&(0,Q.jsxs)(k,{variant:`outline`,size:`sm`,onClick:()=>void ne(),disabled:m,children:[m?(0,Q.jsx)(St,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?at():Je()]}),(0,Q.jsx)(k,{size:`sm`,onClick:()=>void re(),disabled:f,children:ce()})]})]})})}function Mn({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(At,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?c():ft({count:e.length}),(0,Q.jsx)(D,{size:13,"aria-hidden":!0})]})}),(0,Q.jsxs)(Lt,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,Q.jsx)(`p`,{className:`oc-compat__versions-title`,children:ve()}),(0,Q.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,Q.jsx)(j,{variant:`secondary`,children:e},e))})]})]})}export{wn as BridgeTab,kn as InstanceConfigDialog};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$l as i,BY as a,Ct as o,Hk as s,P_ as c,Qg as l,RY as u,St as d,Tt as f,VY as p,Xg as m,Zg as h,_p as g,_t as _,at as v,bt as y,ct as b,dp as x,dt as S,e_ as C,et as ee,fp as te,ft as ne,gp as w,gt as re,hp as ie,ht as T,hv as ae,i_ as oe,it as E,jY as D,lt as se,mp as O,mt as k,mv as ce,n_ as le,nt as ue,ot as de,pp as fe,pt as pe,r_ as A,rt as me,st as he,t as j,t_ as M,tt as ge,up as _e,ut as ve,vp as ye,vt as N,wt as P,xt as be,xv as F,yp as xe,yt as Se,yv as Ce}from"./api-BiOKjOdr.js";import{t as we}from"./use_paginated_query-JzX-Y80s.js";import{t as I}from"./button-D0Pgjwxf.js";import{$t as L,Mt as R,St as z,bt as B,kn as Te,nt as Ee,rt as De,tt as V,vt as H,xt as U,yt as W}from"./index-xhYNLD3V.js";import{a as Oe}from"./compatView-qPB4mG-_.js";/* empty css */var G=t(e(),1),ke=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Ae(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var K=[`auto`,`hybrid`,`tool`,`off`];function je(e){switch(e){case`auto`:return d();case`hybrid`:return be();case`tool`:return y();default:return Se()}}function q(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function J(e){return typeof e==`string`&&K.includes(e)}function Y(e){return{injection:J(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function X(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function Me(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?k():Z(e)?E():null:T(),i=Y(e),a=t.injection!==i.injection||!X(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),s=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:s,invalidReason:s?null:_()}}function Z(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ne(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?k():e.code===`stale_default`?pe():e.code===`write_unknown`||e.code===`not_confirmed`?ve():e.code===`not_applied`?se():e.code===`default_too_large`?ue():e.code===`allowlist_too_large`?me():e.code===`plugin_too_old`?E():e.code===`source_not_allowed`?v():e.code===`plugin_config_lag`?de():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?re():ne({code:e.code})}function Pe(e,t){let n=q(e),r=q(t);if(n.injection!==r.injection||!X(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function Fe({instanceName:e,row:t,supported:n}){let r=u(j.knowledge.setAgentKnowledgeDefault),[i,a]=(0,G.useState)(t),[s,c]=(0,G.useState)(()=>Y(t)),[d,f]=(0,G.useState)(`idle`),[p,m]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),v=e=>{a(e),c(Y(e)),m(null)},y=Pe(i,t);(0,G.useEffect)(()=>{g&&y&&(_(!1),v(t))},[g,y]);let b=Me(i,s,n),x=b.readOnlyReason===null;async function C(){f(`saving`),m(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:s.injection,sources:s.sources,expected:q(i)}));m(n),f(n===null?`done`:`idle`),n===null&&_(!0)}catch(e){m(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),f(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(H,{value:s.injection,onValueChange:e=>{J(e)&&c({...s,injection:e})},disabled:!x,children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":o(),children:(0,$.jsx)(z,{})}),(0,$.jsx)(W,{children:K.map(e=>(0,$.jsx)(B,{value:e,children:je(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:N()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:x?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(R,{checked:s.sources.includes(e.id),onCheckedChange:()=>c(Ne(t,s,e.id)),disabled:!x,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),y&&!g?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[ge(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>v(t),children:ee()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()}),x?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(I,{size:`sm`,disabled:!b.dirty||!b.valid||d===`saving`,onClick:()=>void C(),children:d===`saving`?F():l()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:b.readOnlyReason}),x&&b.dirty&&b.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:b.invalidReason}):null,d===`done`&&p===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,p===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p})]})]})}function Ie({instanceName:e}){let t=p(j.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:r,loadMore:i}=we(j.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&r!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":f(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:P()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:T()}),n.map(n=>(0,$.jsx)(Fe,{instanceName:e,row:n,supported:t.supported},n.agentId)),r===`CanLoadMore`||r===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b({shown:n.length})}),(0,$.jsx)(I,{variant:`outline`,size:`sm`,disabled:r===`LoadingMore`,onClick:()=>i(50),"data-knowledge-load-more":!0,children:he()})]}):null]})}function Le({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=p(j.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,o]=(0,G.useState)(r),[s,c]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(r),c(`idle`)},[e._id,r]);let u=`__none__`,d=i!==r;async function f(){c(`saving`);try{let n={...e.config??{}};i===``||i===u?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let g=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:w()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(H,{value:i===``?u:i,onValueChange:e=>o(e===u?``:e),children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":w(),children:(0,$.jsx)(z,{placeholder:O()})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(B,{value:u,children:O()}),g.map(e=>(0,$.jsx)(B,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(I,{size:`sm`,disabled:!d||s===`saving`,onClick:()=>void f(),children:s===`saving`?F():l()})]}),s===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,s===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null]})}function Re({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(r===null?``:String(r)),[u,d]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(n),c(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let f=s.trim(),p=f===``?null:/^\d+$/.test(f)?Number.parseInt(f,10):NaN,_=!i||p===null||Number.isInteger(p)&&p>=4e3&&p<=6e4,v=i!==n||(p??null)!==r;async function y(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||p===null||Number.isNaN(p)?delete n.curationBudgetChars:n.curationBudgetChars=p,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(R,{checked:i,onCheckedChange:e=>o(e===!0),"aria-label":g()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(L,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":fe(),disabled:!i}),(0,$.jsx)(I,{size:`sm`,disabled:!v||!_||u===`saving`,onClick:()=>void y(),children:u===`saving`?F():l()})]}),_?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:te()}),u===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,u===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]})}function ze({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,G.useState)(n===null?``:String(n)),[o,s]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{i(n===null?``:String(n)),s(`idle`)},[e._id,n]);let c=r.trim(),u=c===``?null:/^\d+$/.test(c)?Number.parseInt(c,10):NaN,d=u===null||Number.isInteger(u)&&u>=1e3&&u<=2e5,f=(u??null)!==n;async function p(){s(`saving`);try{let n={...e.config??{}};u===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=u,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:xe()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(L,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,$.jsx)(I,{size:`sm`,disabled:!f||!d||o===`saving`,onClick:()=>void p(),children:o===`saving`?F():l()})]}),d?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:_e()}),o===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,o===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ye()})]})}function Be(){let e=u(j.agentFiles.getChatDefaults),[t,n]=(0,G.useState)({status:`loading`}),a=p(j.admin.listInstances,{}),[o,l]=(0,G.useState)(null);(0,G.useEffect)(()=>{!a||a.length===0||(!o||!a.some(e=>e.name===o))&&l(a[0].name)},[a,o]);let d=(a?.length??0)>1,f=a!==void 0&&a.length===0,m=p(j.compat.forInstance,o?{instanceName:o}:`skip`),h=o?Ee(m,`configDefaults`):`loading`,g=h===`loading`?null:h.blocked,_=(0,G.useMemo)(()=>d&&o?{instanceName:o}:{},[d,o]),v=(0,G.useRef)(0),y=(0,G.useCallback)(async()=>{let t=++v.current;n({status:`loading`});try{let r=Ae(await e(_));if(v.current!==t)return;n({status:`done`,current:r})}catch{if(v.current!==t)return;n({status:`error`})}},[e,_]);(0,G.useEffect)(()=>{g===!1&&(d&&!o||y())},[y,g,d,o]);let b=t.status===`done`?t.current:null,x=(0,G.useMemo)(()=>ke.map(e=>({id:e,label:De(e)})),[]),S=(0,G.useMemo)(()=>[{id:`fast`,label:ae()},{id:`standard`,label:ce()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}),d&&o?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:c()}),(0,$.jsxs)(H,{value:o,onValueChange:e=>l(e),children:[(0,$.jsx)(U,{size:`sm`,"aria-label":c(),children:(0,$.jsx)(z,{})}),(0,$.jsx)(W,{children:(a??[]).map(e=>(0,$.jsx)(B,{value:e.name,children:e.name},e.name))})]})]}):null,f?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:s()}):h===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):h.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(Te,{size:14,"aria-hidden":!0}),` `,Oe(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[r(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:Ce()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:A()}),(0,$.jsx)(V,{field:`thinkingLevel`,options:x,value:b?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:A()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:le()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:M()}),(0,$.jsx)(V,{field:`fastMode`,options:S,value:b===null||b.fastModeDefault===null?null:b.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:M()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:C()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:i()})]}),(()=>{let e=a?.find(e=>e.name===(o??a[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{instance:e}),(0,$.jsx)(Re,{instance:e}),(0,$.jsx)(Le,{instance:e}),(0,$.jsx)(Ie,{instanceName:e.name})]}):null})()]})}export{Be as ChatDefaultsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,$l as i,BY as a,Ct as o,Hk as s,P_ as c,Qg as l,RY as u,St as d,Tt as f,VY as p,Xg as m,Zg as h,_p as g,_t as _,at as v,bt as y,ct as b,dp as x,dt as S,e_ as C,et as ee,fp as te,ft as ne,gp as w,gt as re,hp as ie,ht as T,hv as ae,i_ as oe,it as E,jY as D,lt as se,mp as O,mt as k,mv as ce,n_ as le,nt as ue,ot as de,pp as fe,pt as pe,r_ as A,rt as me,st as he,t as j,t_ as M,tt as ge,up as _e,ut as ve,vp as ye,vt as N,wt as P,xt as be,xv as F,yp as xe,yt as Se,yv as Ce}from"./api-DcB3BxUc.js";import{t as we}from"./use_paginated_query-Dc9YWxua.js";import{t as I}from"./button-DgaBsJDX.js";import{$t as L,Mt as R,St as z,bt as B,kn as Te,nt as Ee,rt as De,tt as V,vt as H,xt as U,yt as W}from"./index-Ds-ybIOh.js";import{a as Oe}from"./compatView-Cyz2oaDo.js";/* empty css */var G=t(e(),1),ke=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Ae(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}var K=[`auto`,`hybrid`,`tool`,`off`];function je(e){switch(e){case`auto`:return d();case`hybrid`:return be();case`tool`:return y();default:return Se()}}function q(e){return{injection:e.injection??`auto`,defaultSources:e.defaultSources,...e.config?{config:e.config}:{}}}function J(e){return typeof e==`string`&&K.includes(e)}function Y(e){return{injection:J(e.injection)?e.injection:`auto`,sources:e.defaultSources.filter(t=>e.sources.some(e=>e.id===t))}}function X(e,t){let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))}function Me(e,t,n){let r=n?e.defaultWriteRefused===`scope_refused`?k():Z(e)?E():null:T(),i=Y(e),a=t.injection!==i.injection||!X(t.sources,i.sources),o=new Set(e.sources.map(e=>e.id)),s=t.sources.length>0&&t.sources.length<=16&&t.sources.every(e=>o.has(e));return{readOnlyReason:r,dirty:a,valid:s,invalidReason:s?null:_()}}function Z(e){return(e.contract??1)<2&&e.ownAllowlist===!1}function Ne(e,t,n){let r=t.sources.includes(n)?t.sources.filter(e=>e!==n):[...t.sources,n];return{...t,sources:e.sources.map(e=>e.id).filter(e=>r.includes(e))}}function Q(e){return e.ok?null:e.code===`scope_refused`?k():e.code===`stale_default`?pe():e.code===`write_unknown`||e.code===`not_confirmed`?ve():e.code===`not_applied`?se():e.code===`default_too_large`?ue():e.code===`allowlist_too_large`?me():e.code===`plugin_too_old`?E():e.code===`source_not_allowed`?v():e.code===`plugin_config_lag`?de():e.code===`knowledge_unavailable`&&e.reason===`plugin_absent`?re():ne({code:e.code})}function Pe(e,t){let n=q(e),r=q(t);if(n.injection!==r.injection||!X(n.defaultSources,r.defaultSources))return!0;let i=n.config,a=r.config;return i===void 0||a===void 0?i!==a:i.injection!==a.injection||!((e,t)=>e===null||t===null?e===t:e.length===t.length&&e.every((e,n)=>e===t[n]))(i.sources,a.sources)}var $=n();function Fe({instanceName:e,row:t,supported:n}){let r=u(j.knowledge.setAgentKnowledgeDefault),[i,a]=(0,G.useState)(t),[s,c]=(0,G.useState)(()=>Y(t)),[d,f]=(0,G.useState)(`idle`),[p,m]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),v=e=>{a(e),c(Y(e)),m(null)},y=Pe(i,t);(0,G.useEffect)(()=>{g&&y&&(_(!1),v(t))},[g,y]);let b=Me(i,s,n),x=b.readOnlyReason===null;async function C(){f(`saving`),m(null);try{let n=Q(await r({instanceName:e,agentId:t.agentId,injection:s.injection,sources:s.sources,expected:q(i)}));m(n),f(n===null?`done`:`idle`),n===null&&_(!0)}catch(e){m(Q({ok:!1,code:String(e?.message??`error`).slice(0,60)})),f(`idle`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,"data-knowledge-agent":t.agentId,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:t.agentId}),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsxs)(H,{value:s.injection,onValueChange:e=>{J(e)&&c({...s,injection:e})},disabled:!x,children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":o(),children:(0,$.jsx)(z,{})}),(0,$.jsx)(W,{children:K.map(e=>(0,$.jsx)(B,{value:e,children:je(e)},e))})]})}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:N()}),t.sources.map(e=>(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:x?`pointer`:`default`},title:e.description||void 0,children:[(0,$.jsx)(R,{checked:s.sources.includes(e.id),onCheckedChange:()=>c(Ne(t,s,e.id)),disabled:!x,"aria-label":e.label,"data-knowledge-default-source":e.id}),(0,$.jsx)(`span`,{children:e.label})]},e.id)),y&&!g?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[ge(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>v(t),children:ee()})]}):null,t.overridesAllowed?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:S()}),x?(0,$.jsx)(`div`,{className:`oc-cdefaults__inline`,children:(0,$.jsx)(I,{size:`sm`,disabled:!b.dirty||!b.valid||d===`saving`,onClick:()=>void C(),children:d===`saving`?F():l()})}):(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:b.readOnlyReason}),x&&b.dirty&&b.invalidReason!==null?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:b.invalidReason}):null,d===`done`&&p===null?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,p===null?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:p})]})]})}function Ie({instanceName:e}){let t=p(j.knowledge.knowledgeAdminInstance,{instanceName:e}),{results:n,status:r,loadMore:i}=we(j.knowledge.agentKnowledgePage,{instanceName:e},{initialNumItems:50});return t===void 0||t.provider!==`openclaw`||n.length===0&&r!==`CanLoadMore`?null:(0,$.jsxs)(`section`,{className:`oc-cdefaults__row`,"aria-label":f(),children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:f()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:P()}),t.supported?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:T()}),n.map(n=>(0,$.jsx)(Fe,{instanceName:e,row:n,supported:t.supported},n.agentId)),r===`CanLoadMore`||r===`LoadingMore`?(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:b({shown:n.length})}),(0,$.jsx)(I,{variant:`outline`,size:`sm`,disabled:r===`LoadingMore`,onClick:()=>i(50),"data-knowledge-load-more":!0,children:he()})]}):null]})}function Le({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=p(j.agents.listAgentsForInstance,{instanceName:e.name}),r=typeof e.config?.converterAgentId==`string`?e.config.converterAgentId:``,[i,o]=(0,G.useState)(r),[s,c]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(r),c(`idle`)},[e._id,r]);let u=`__none__`,d=i!==r;async function f(){c(`saving`);try{let n={...e.config??{}};i===``||i===u?delete n.converterAgentId:n.converterAgentId=i,await t({instanceId:e._id,config:n}),c(`done`)}catch{c(`error`)}}let g=n?.agents??[];return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:w()}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:ie()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsxs)(H,{value:i===``?u:i,onValueChange:e=>o(e===u?``:e),children:[(0,$.jsx)(U,{className:`oc-cdefaults__select`,"aria-label":w(),children:(0,$.jsx)(z,{placeholder:O()})}),(0,$.jsxs)(W,{children:[(0,$.jsx)(B,{value:u,children:O()}),g.map(e=>(0,$.jsx)(B,{value:e.agentId,children:e.displayName?`${e.displayName} (${e.agentId})`:e.agentId},e.agentId))]})]}),(0,$.jsx)(I,{size:`sm`,disabled:!d||s===`saving`,onClick:()=>void f(),children:s===`saving`?F():l()})]}),s===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,s===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null]})}function Re({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=e.config?.curationEnabled===!0,r=typeof e.config?.curationBudgetChars==`number`?e.config.curationBudgetChars:null,[i,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(r===null?``:String(r)),[u,d]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{o(n),c(r===null?``:String(r)),d(`idle`)},[e._id,n,r]);let f=s.trim(),p=f===``?null:/^\d+$/.test(f)?Number.parseInt(f,10):NaN,_=!i||p===null||Number.isInteger(p)&&p>=4e3&&p<=6e4,v=i!==n||(p??null)!==r;async function y(){d(`saving`);try{let n={...e.config??{}};n.curationEnabled=i,!i||p===null||Number.isNaN(p)?delete n.curationBudgetChars:n.curationBudgetChars=p,await t({instanceId:e._id,config:n}),d(`done`)}catch{d(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsxs)(`label`,{className:`oc-cdefaults__inline`,style:{cursor:`pointer`},children:[(0,$.jsx)(R,{checked:i,onCheckedChange:e=>o(e===!0),"aria-label":g()}),(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:g()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(L,{type:`number`,min:4e3,max:6e4,step:1e3,placeholder:`20000`,value:s,onChange:e=>c(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!_,"aria-label":fe(),disabled:!i}),(0,$.jsx)(I,{size:`sm`,disabled:!v||!_||u===`saving`,onClick:()=>void y(),children:u===`saving`?F():l()})]}),_?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:te()}),u===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,u===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:x()})]})}function ze({instance:e}){let t=a(j.admin.upsertInstanceConfig),n=typeof e.config?.summarizeThresholdChars==`number`?e.config.summarizeThresholdChars:null,[r,i]=(0,G.useState)(n===null?``:String(n)),[o,s]=(0,G.useState)(`idle`);(0,G.useEffect)(()=>{i(n===null?``:String(n)),s(`idle`)},[e._id,n]);let c=r.trim(),u=c===``?null:/^\d+$/.test(c)?Number.parseInt(c,10):NaN,d=u===null||Number.isInteger(u)&&u>=1e3&&u<=2e5,f=(u??null)!==n;async function p(){s(`saving`);try{let n={...e.config??{}};u===null?delete n.summarizeThresholdChars:n.summarizeThresholdChars=u,await t({instanceId:e._id,config:n}),s(`done`)}catch{s(`error`)}}return(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:xe()}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__inline`,children:[(0,$.jsx)(L,{type:`number`,min:1e3,max:2e5,step:1e3,placeholder:`8000`,value:r,onChange:e=>i(e.target.value),className:`oc-cdefaults__number`,"aria-invalid":!d}),(0,$.jsx)(I,{size:`sm`,disabled:!f||!d||o===`saving`,onClick:()=>void p(),children:o===`saving`?F():l()})]}),d?null:(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:_e()}),o===`done`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:h()}):null,o===`error`?(0,$.jsx)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:m()}):null,(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:ye()})]})}function Be(){let e=u(j.agentFiles.getChatDefaults),[t,n]=(0,G.useState)({status:`loading`}),a=p(j.admin.listInstances,{}),[o,l]=(0,G.useState)(null);(0,G.useEffect)(()=>{!a||a.length===0||(!o||!a.some(e=>e.name===o))&&l(a[0].name)},[a,o]);let d=(a?.length??0)>1,f=a!==void 0&&a.length===0,m=p(j.compat.forInstance,o?{instanceName:o}:`skip`),h=o?Ee(m,`configDefaults`):`loading`,g=h===`loading`?null:h.blocked,_=(0,G.useMemo)(()=>d&&o?{instanceName:o}:{},[d,o]),v=(0,G.useRef)(0),y=(0,G.useCallback)(async()=>{let t=++v.current;n({status:`loading`});try{let r=Ae(await e(_));if(v.current!==t)return;n({status:`done`,current:r})}catch{if(v.current!==t)return;n({status:`error`})}},[e,_]);(0,G.useEffect)(()=>{g===!1&&(d&&!o||y())},[y,g,d,o]);let b=t.status===`done`?t.current:null,x=(0,G.useMemo)(()=>ke.map(e=>({id:e,label:De(e)})),[]),S=(0,G.useMemo)(()=>[{id:`fast`,label:ae()},{id:`standard`,label:ce()}],[]);return(0,$.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:oe()}),d&&o?(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:c()}),(0,$.jsxs)(H,{value:o,onValueChange:e=>l(e),children:[(0,$.jsx)(U,{size:`sm`,"aria-label":c(),children:(0,$.jsx)(z,{})}),(0,$.jsx)(W,{children:(a??[]).map(e=>(0,$.jsx)(B,{value:e.name,children:e.name},e.name))})]})]}):null,f?(0,$.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:s()}):h===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):h.blocked?(0,$.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,$.jsx)(Te,{size:14,"aria-hidden":!0}),` `,Oe(h.gatewayVersion,h.provider)]}):t.status===`loading`?(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):t.status===`error`?(0,$.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[r(),` `,(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>void y(),children:Ce()})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:A()}),(0,$.jsx)(V,{field:`thinkingLevel`,options:x,value:b?.thinkingDefault??null,onChange:()=>{},disabled:!0,ariaLabel:A()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:le()})]}),(0,$.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,$.jsx)(`span`,{className:`oc-cdefaults__label`,children:M()}),(0,$.jsx)(V,{field:`fastMode`,options:S,value:b===null||b.fastModeDefault===null?null:b.fastModeDefault?`fast`:`standard`,onChange:()=>{},disabled:!0,ariaLabel:M()}),(0,$.jsx)(`p`,{className:`oc-cdefaults__help`,children:C()})]}),(0,$.jsx)(`p`,{className:`oc-cdefaults__note`,children:i()})]}),(()=>{let e=a?.find(e=>e.name===(o??a[0]?.name));return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{instance:e}),(0,$.jsx)(Re,{instance:e}),(0,$.jsx)(Le,{instance:e}),(0,$.jsx)(Ie,{instanceName:e.name})]}):null})()]})}export{Be as ChatDefaultsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{GS as r,HS as i,KS as a,US as o,VS as s,WS as c,qS as l}from"./api-BiOKjOdr.js";import{r as u}from"./dist-DAKYY4yE.js";import{t as d}from"./chevrons-up-down-CogPekve.js";import{t as f}from"./button-D0Pgjwxf.js";import{An as p,Ln as m,Mt as h,an as g,en as _,in as v,nn as y,or as b,tn as x,tr as S}from"./index-xhYNLD3V.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-DsK3yFpt.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=l(),bulkActions:F,emptyHint:I=a(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(f,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(p,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(f,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(h,{"aria-label":c(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":s({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(b,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(d,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(h,{"aria-label":o(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":i(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(S,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{GS as r,HS as i,KS as a,US as o,VS as s,WS as c,qS as l}from"./api-DcB3BxUc.js";import{r as u}from"./dist-D96qX4Zd.js";import{t as d}from"./chevrons-up-down-R0Y7ndDn.js";import{t as f}from"./button-DgaBsJDX.js";import{An as p,Ln as m,Mt as h,an as g,en as _,in as v,nn as y,or as b,tn as x,tr as S}from"./index-Ds-ybIOh.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-A3AeBsY1.js";var k=t(e(),1);function A(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function j(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=A(i,a);return n===`asc`?c:-c})}var M=n();function N({title:e,rows:t,columns:n,rowActions:A,onAdd:N,addLabel:P=l(),bulkActions:F,emptyHint:I=a(),isExpanded:L,renderExpanded:R}){let[z,B]=(0,k.useState)(new Set),[V,H]=(0,k.useState)(null),U=t??[],W=V?n[V.index]:void 0,G=V&&W?.sort?j(U,W.sort,V.dir):U;function K(e){H(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let q=+!!F+n.length+ +!!A,J=U.length>0&&z.size===U.length,Y=z.size>0&&!J;function X(){B(J?new Set:new Set(U.map(e=>e._id)))}function Z(e){B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,M.jsxs)(`div`,{className:`oc-dt`,children:[(0,M.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,M.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,M.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[z.size>0&&F?F.map(e=>(0,M.jsxs)(f,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...z]),B(new Set)},children:[e.variant===`destructive`?(0,M.jsx)(p,{}):null,e.label,` (`,z.size,`)`]},e.label)):null,N?(0,M.jsxs)(f,{size:`sm`,onClick:N,children:[(0,M.jsx)(m,{}),` `,P]}):null]})]}),t===void 0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:r()}):U.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:I}):(0,M.jsxs)(O,{children:[(0,M.jsx)(C,{children:(0,M.jsxs)(E,{children:[F?(0,M.jsx)(w,{className:`w-8`,children:(0,M.jsx)(h,{"aria-label":c(),checked:J?!0:Y?`indeterminate`:!1,onCheckedChange:X})}):null,n.map((e,t)=>{let n=V?.index===t;return e.sort?(0,M.jsx)(w,{className:e.className,"aria-sort":n?V.dir===`asc`?`ascending`:`descending`:`none`,children:(0,M.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>K(t),"aria-label":s({column:e.header}),children:[e.header,n?V.dir===`asc`?(0,M.jsx)(b,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(u,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,M.jsx)(d,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,M.jsx)(w,{className:e.className,children:e.header},e.header)}),A?(0,M.jsx)(w,{className:`w-8`}):null]})}),(0,M.jsx)(T,{children:G.map(e=>{let t=A?.(e)??[],r=L?.(e)??!1;return(0,M.jsxs)(k.Fragment,{children:[(0,M.jsxs)(E,{className:`group/row`,children:[F?(0,M.jsx)(D,{children:(0,M.jsx)(h,{"aria-label":o(),checked:z.has(e._id),onCheckedChange:()=>Z(e._id)})}):null,n.map(t=>(0,M.jsx)(D,{className:t.className,children:t.cell(e)},t.header)),A?(0,M.jsx)(D,{children:t.length>0?(0,M.jsxs)(_,{children:[(0,M.jsx)(g,{asChild:!0,children:(0,M.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":i(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,M.jsx)(S,{})})}),(0,M.jsx)(x,{align:`end`,children:t.map((t,n)=>(0,M.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,M.jsx)(v,{}):null,(0,M.jsx)(y,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),r&&R?(0,M.jsx)(E,{className:`oc-dt__expansion`,children:(0,M.jsx)(D,{colSpan:q,className:`oc-dt__expansion-cell`,children:R(e)})}):null]},e._id)})})]})]})}export{N as t};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{Jt as t}from"./index-xhYNLD3V.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{Jt as t}from"./index-Ds-ybIOh.js";var n=e();function r({icon:e,total:r,items:i}){if(r===0)return(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let a=r-i.length;return(0,n.jsxs)(`div`,{className:`oc-group-detail`,children:[i.map((e,r)=>(0,n.jsxs)(t,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,n.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},r)),a>0?(0,n.jsxs)(t,{variant:`outline`,className:`oc-group-chip`,children:[`+`,a]}):null]})}export{r as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,BI as a,BY as o,CI as s,Cf as c,DI as l,EI as u,FI as d,GI as f,HI as p,II as m,JI as h,KI as g,LI as _,MI as v,NI as y,OI as b,PI as x,QI as ee,RI as te,SI as ne,TI as re,UI as ie,VI as ae,VY as S,WI as C,XI as w,YI as T,ZI as E,_I as D,_L as O,aL as k,bI as A,cL as j,dL as M,eL as N,fL as P,gI as F,gL as I,hI as L,hL as R,iL as z,jI as B,kI as V,lL as H,mL as U,nL as W,oL as G,pL as oe,qI as K,rL as q,sL as se,t as J,tL as ce,uL as le,vI as ue,wI as de,xI as fe,xf as pe,yI as me,zI as he}from"./api-BiOKjOdr.js";import{t as ge}from"./button-D0Pgjwxf.js";import{At as _e,ct as Y}from"./index-xhYNLD3V.js";import{t as ve}from"./DataTableShell-P8WPv8pJ.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>O(),incorrect:()=>I(),incoherence:()=>R(),formatting:()=>U(),latency:()=>oe(),api_error:()=>P(),other:()=>M()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:H()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:j()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:le()})}function be({data:e,reference:t,closeReason:n}){let i=e.snapshot,a=o(J.feedback.respondToFeedback),[s,l]=(0,X.useState)(e.thread),[u,m]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1);async function y(){let t=u.trim();if(!(!t||_)){v(!0);try{await a({feedbackId:e._id,text:t}),l(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{v(!1)}}}let b=[];try{b=i.contextJson?JSON.parse(i.contextJson):[]}catch{b=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:i.displayedMatchesStored,sourceWasOpen:i.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,i.messageRole,i.isRegeneration?` · ${se()}`:``,i.openclawModel?` · ${i.openclawModel}`:``,i.openclawRuntime?` (${i.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:d(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:G()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:fe()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:k()}),s.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:s.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Z.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?z():e.authorRole===`agent`?e.authorLabel??c():q()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:W()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:ce(),value:u,maxLength:2e3,rows:3,onChange:e=>m(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void y(),disabled:!u.trim()||_,children:_?N():r()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ee()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.messageText||E()})]}),i.clientInfo?.sourceWasOpen&&i.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.displayedText||E()})]}):null,i.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:T()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.promptText})]}):null,b.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:h({count:i.contextCount??b.length,truncated:i.contextTruncated?K():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,i.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[i.outboxText??``,i.outboxStatus?`\n[status: ${i.outboxStatus}]`:``]})]}):null,i.clientInfo?.extensionsDetected&&i.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:i.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:C()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[i.clientInfo?.language,i.clientInfo?.timezone,i.clientInfo?.theme?ie({theme:i.clientInfo.theme}):null,i.runId?`run ${i.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,i.clientInfo?.plugins&&i.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[p(),` `,i.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,ae()]})]}):null,i.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:i.clientInfo.userAgent}):null]})]})]})}function xe(){let e=S(J.feedback.listForAdmin,{}),t=o(J.feedback.readSnapshot),n=o(J.feedback.deleteFeedback),r=Y(),[c,d]=(0,X.useState)(null),[f,p]=(0,X.useState)({});async function h(e){if(c===e._id){d(null);return}if(!f[e._id]){let n=await t({feedbackId:e._id});p(t=>({...t,[e._id]:n}))}d(e._id)}async function g(e){await r({title:D(),description:F(),confirmLabel:L(),destructive:!0})&&(await n({feedbackId:e._id}),c===e._id&&d(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[a(),` `,(0,Z.jsx)(`strong`,{children:he()}),` `,te()]}),(0,Z.jsx)(ve,{title:_(),rows:e,emptyHint:m(),isExpanded:e=>c===e._id&&!!f[e._id],renderExpanded:e=>f[e._id]?(0,Z.jsx)(be,{data:f[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:x(),cell:e=>_e(e.at),sort:e=>e.at},{header:y(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:v(),cell:e=>e.messageRole===`user`?B():i(),sort:e=>e.messageRole},{header:V(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${b({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:l(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:u(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:re(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:de()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:s()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:pe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:ne()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:c===e._id?A():me(),onSelect:()=>void h(e)},{label:ue(),onSelect:()=>void g(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,AI as i,BI as a,BY as o,CI as s,Cf as c,DI as l,EI as u,FI as d,GI as f,HI as p,II as m,JI as h,KI as g,LI as _,MI as v,NI as y,OI as b,PI as x,QI as ee,RI as te,SI as ne,TI as re,UI as ie,VI as ae,VY as S,WI as C,XI as w,YI as T,ZI as E,_I as D,_L as O,aL as k,bI as A,cL as j,dL as M,eL as N,fL as P,gI as F,gL as I,hI as L,hL as R,iL as z,jI as B,kI as V,lL as H,mL as U,nL as W,oL as G,pL as oe,qI as K,rL as q,sL as se,t as J,tL as ce,uL as le,vI as ue,wI as de,xI as fe,xf as pe,yI as me,zI as he}from"./api-DcB3BxUc.js";import{t as ge}from"./button-DgaBsJDX.js";import{At as _e,ct as Y}from"./index-Ds-ybIOh.js";import{t as ve}from"./DataTableShell-7VOYauXM.js";var X=t(e(),1),Z=n(),ye={altered_words:()=>O(),incorrect:()=>I(),incoherence:()=>R(),formatting:()=>U(),latency:()=>oe(),api_error:()=>P(),other:()=>M()},Q=e=>ye[e]?.()??e;function $({matches:e,sourceWasOpen:t}){return t?e===!0?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:H()}):e===!1?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:j()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:le()})}function be({data:e,reference:t,closeReason:n}){let i=e.snapshot,a=o(J.feedback.respondToFeedback),[s,l]=(0,X.useState)(e.thread),[u,m]=(0,X.useState)(``),[_,v]=(0,X.useState)(!1);async function y(){let t=u.trim();if(!(!t||_)){v(!0);try{await a({feedbackId:e._id,text:t}),l(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),m(``)}finally{v(!1)}}}let b=[];try{b=i.contextJson?JSON.parse(i.contextJson):[]}catch{b=[]}return(0,Z.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Z.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,Z.jsx)($,{matches:i.displayedMatchesStored,sourceWasOpen:i.clientInfo?.sourceWasOpen??!1}),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Q(e.category),` · `,i.messageRole,i.isRegeneration?` · ${se()}`:``,i.openclawModel?` · ${i.openclawModel}`:``,i.openclawRuntime?` (${i.openclawRuntime})`:``]}),t?(0,Z.jsx)(`code`,{className:`oc-fbadmin__ref`,style:{userSelect:`all`,marginLeft:`auto`},title:d(),children:t}):null]}),e.comment?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:G()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,n?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:fe()}),(0,Z.jsx)(`p`,{className:`oc-fbadmin__comment`,children:n})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:k()}),s.length>0?(0,Z.jsx)(`div`,{className:`oc-fbadmin__thread`,children:s.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Z.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?z():e.authorRole===`agent`?e.authorLabel??c():q()}),(0,Z.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Z.jsx)(`p`,{className:`oc-fbadmin__meta`,children:W()}),(0,Z.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:ce(),value:u,maxLength:2e3,rows:3,onChange:e=>m(e.target.value.slice(0,2e3))}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Z.jsx)(ge,{size:`sm`,onClick:()=>void y(),disabled:!u.trim()||_,children:_?N():r()})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ee()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.messageText||E()})]}),i.clientInfo?.sourceWasOpen&&i.displayedText!==void 0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.displayedText||E()})]}):null,i.promptText?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:T()}),(0,Z.jsx)(`pre`,{className:`oc-msg__source-pre`,children:i.promptText})]}):null,b.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:h({count:i.contextCount??b.length,truncated:i.contextTruncated?K():``})}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:b.map((e,t)=>(0,Z.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,Z.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,i.outboxAvailable?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Z.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[i.outboxText??``,i.outboxStatus?`\n[status: ${i.outboxStatus}]`:``]})]}):null,i.clientInfo?.extensionsDetected&&i.clientInfo.extensionsDetected.length>0?(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:f()}),(0,Z.jsx)(`div`,{className:`oc-fbadmin__row`,children:i.clientInfo.extensionsDetected.map(e=>(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`oc-fbadmin__h`,children:C()}),(0,Z.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[i.clientInfo?.language,i.clientInfo?.timezone,i.clientInfo?.theme?ie({theme:i.clientInfo.theme}):null,i.runId?`run ${i.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,i.clientInfo?.plugins&&i.clientInfo.plugins.length>0?(0,Z.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[p(),` `,i.clientInfo.plugins.join(`, `),(0,Z.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,ae()]})]}):null,i.clientInfo?.userAgent?(0,Z.jsx)(`span`,{className:`oc-fbadmin__ua`,children:i.clientInfo.userAgent}):null]})]})]})}function xe(){let e=S(J.feedback.listForAdmin,{}),t=o(J.feedback.readSnapshot),n=o(J.feedback.deleteFeedback),r=Y(),[c,d]=(0,X.useState)(null),[f,p]=(0,X.useState)({});async function h(e){if(c===e._id){d(null);return}if(!f[e._id]){let n=await t({feedbackId:e._id});p(t=>({...t,[e._id]:n}))}d(e._id)}async function g(e){await r({title:D(),description:F(),confirmLabel:L(),destructive:!0})&&(await n({feedbackId:e._id}),c===e._id&&d(null))}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`oc-admin__hint`,children:[a(),` `,(0,Z.jsx)(`strong`,{children:he()}),` `,te()]}),(0,Z.jsx)(ve,{title:_(),rows:e,emptyHint:m(),isExpanded:e=>c===e._id&&!!f[e._id],renderExpanded:e=>f[e._id]?(0,Z.jsx)(be,{data:f[e._id],reference:e.reference,closeReason:e.userCloseReason}):null,columns:[{header:x(),cell:e=>_e(e.at),sort:e=>e.at},{header:y(),cell:e=>Q(e.category),sort:e=>Q(e.category)},{header:v(),cell:e=>e.messageRole===`user`?B():i(),sort:e=>e.messageRole},{header:V(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${b({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:l(),cell:e=>(0,Z.jsx)($,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:u(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:re(),cell:e=>e.userClosedAt==null?e.resolvedAt==null?e.answered?(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:de()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill`,children:s()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,title:e.resolvedBy??void 0,children:pe()}):(0,Z.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:ne()}),sort:e=>e.userClosedAt==null?e.resolvedAt==null?+!!e.answered:2:3}],rowActions:e=>[{label:c===e._id?A():me(),onSelect:()=>void h(e)},{label:ue(),onSelect:()=>void g(e),variant:`destructive`}]})]})}export{xe as FeedbacksTab};
@@ -1 +1 @@
1
- import{r as e}from"./bundle-mjs-C73ZY4La.js";import{E as t,JY as n}from"./api-BiOKjOdr.js";import{B as r,R as i,V as a,mn as o,pn as s,z as c}from"./index-xhYNLD3V.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var l=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),u=[`gateway-http`,`shared-fs`,`off`],d=[`inline`,`shared-fs`],f=[`reactive`,`sse`],p=`reactive`;n.object({mediaMode:n.optional(n.union(n.literal(`gateway-http`),n.literal(`shared-fs`),n.literal(`off`))),inboundMediaMode:n.optional(n.union(n.literal(`inline`),n.literal(`shared-fs`))),rehydration:n.optional(n.boolean()),mediaMaxMb:n.optional(n.number()),attachmentFixAttested:n.optional(n.boolean()),summarizeThresholdChars:n.optional(n.number()),curationEnabled:n.optional(n.boolean()),curationBudgetChars:n.optional(n.number()),converterAgentId:n.optional(n.string()),voiceEnabled:n.optional(n.boolean()),talkEnabled:n.optional(n.boolean()),widgetsEnabled:n.optional(n.boolean()),widgetPromptConfirm:n.optional(n.boolean()),voiceEngine:n.optional(n.union(n.literal(`browser`),n.literal(`gateway`))),voiceLang:n.optional(n.string()),voiceRate:n.optional(n.number()),voiceAutoRead:n.optional(n.boolean()),contentLocale:n.optional(n.string()),inboundAgentMount:n.optional(n.string()),outboundAgentMount:n.optional(n.string()),promptInjections:n.optional(n.record(n.string(),n.object({enabled:n.optional(n.boolean()),template:n.optional(n.string())})))});var m={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function h(e,t){let n={};for(let r of o){let i=e?.[r];n[r]={enabled:i?.enabled??!0,template:typeof i?.template==`string`&&i.template.length>0?i.template:s[r].defaultTemplate[t]}}return n}function g(e,t){let n={};for(let r of o){let i=s[r],a=e[r];if(!a)continue;let o={};i.togglable&&a.enabled===!1&&(o.enabled=!1);let c=a.template.trim();c.length>0&&c!==i.defaultTemplate[t]&&(o.template=c),(o.enabled!==void 0||o.template!==void 0)&&(n[r]=o)}return n}function _(e,t){return{mediaMode:e.mediaMode??m.mediaMode,inboundMediaMode:e.inboundMediaMode??m.inboundMediaMode,rehydration:e.rehydration??m.rehydration,mediaMaxMb:e.mediaMaxMb??m.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??m.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??m.outboundAgentMount,promptInjections:h(e.promptInjections,t)}}var v=[`attachmentFixAttested`,`summarizeThresholdChars`,`curationEnabled`,`curationBudgetChars`,`contentLocale`,`converterAgentId`,`voiceEnabled`,`talkEnabled`,`voiceEngine`,`voiceLang`,`voiceRate`,`voiceAutoRead`,`widgetsEnabled`,`widgetPromptConfirm`];function y(e,t,n){let r={},i=n=>{(e[n]!==m[n]||t[n]!==void 0)&&(r[n]=e[n])};i(`mediaMode`),i(`inboundMediaMode`),i(`rehydration`),i(`mediaMaxMb`),i(`inboundAgentMount`),i(`outboundAgentMount`);let a=g(e.promptInjections,n);Object.keys(a).length>0&&(r.promptInjections=a);let o=t;for(let e of v){let t=o[e];(typeof t==`number`||typeof t==`boolean`||typeof t==`string`)&&(r[e]=t)}return r}var b=e();function x({text:e}){return(0,b.jsx)(r,{delayDuration:150,children:(0,b.jsxs)(i,{children:[(0,b.jsx)(a,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,b.jsx)(l,{"aria-hidden":!0})})}),(0,b.jsx)(c,{className:`max-w-xs text-pretty`,children:e})]})})}function S({label:e,help:t}){return(0,b.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,b.jsx)(x,{text:t})]})}export{p as a,f as c,_ as i,S as n,d as o,y as r,u as s,x as t};
1
+ import{r as e}from"./bundle-mjs-C73ZY4La.js";import{E as t,JY as n}from"./api-DcB3BxUc.js";import{B as r,R as i,V as a,mn as o,pn as s,z as c}from"./index-Ds-ybIOh.js";import"./locales-CPjguROj.js";import"./curation-CQksaIbm.js";var l=t(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),u=[`gateway-http`,`shared-fs`,`off`],d=[`inline`,`shared-fs`],f=[`reactive`,`sse`],p=`reactive`;n.object({mediaMode:n.optional(n.union(n.literal(`gateway-http`),n.literal(`shared-fs`),n.literal(`off`))),inboundMediaMode:n.optional(n.union(n.literal(`inline`),n.literal(`shared-fs`))),rehydration:n.optional(n.boolean()),mediaMaxMb:n.optional(n.number()),attachmentFixAttested:n.optional(n.boolean()),summarizeThresholdChars:n.optional(n.number()),curationEnabled:n.optional(n.boolean()),curationBudgetChars:n.optional(n.number()),converterAgentId:n.optional(n.string()),voiceEnabled:n.optional(n.boolean()),talkEnabled:n.optional(n.boolean()),widgetsEnabled:n.optional(n.boolean()),widgetPromptConfirm:n.optional(n.boolean()),voiceEngine:n.optional(n.union(n.literal(`browser`),n.literal(`gateway`))),voiceLang:n.optional(n.string()),voiceRate:n.optional(n.number()),voiceAutoRead:n.optional(n.boolean()),contentLocale:n.optional(n.string()),inboundAgentMount:n.optional(n.string()),outboundAgentMount:n.optional(n.string()),promptInjections:n.optional(n.record(n.string(),n.object({enabled:n.optional(n.boolean()),template:n.optional(n.string())})))});var m={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function h(e,t){let n={};for(let r of o){let i=e?.[r];n[r]={enabled:i?.enabled??!0,template:typeof i?.template==`string`&&i.template.length>0?i.template:s[r].defaultTemplate[t]}}return n}function g(e,t){let n={};for(let r of o){let i=s[r],a=e[r];if(!a)continue;let o={};i.togglable&&a.enabled===!1&&(o.enabled=!1);let c=a.template.trim();c.length>0&&c!==i.defaultTemplate[t]&&(o.template=c),(o.enabled!==void 0||o.template!==void 0)&&(n[r]=o)}return n}function _(e,t){return{mediaMode:e.mediaMode??m.mediaMode,inboundMediaMode:e.inboundMediaMode??m.inboundMediaMode,rehydration:e.rehydration??m.rehydration,mediaMaxMb:e.mediaMaxMb??m.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??m.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??m.outboundAgentMount,promptInjections:h(e.promptInjections,t)}}var v=[`attachmentFixAttested`,`summarizeThresholdChars`,`curationEnabled`,`curationBudgetChars`,`contentLocale`,`converterAgentId`,`voiceEnabled`,`talkEnabled`,`voiceEngine`,`voiceLang`,`voiceRate`,`voiceAutoRead`,`widgetsEnabled`,`widgetPromptConfirm`];function y(e,t,n){let r={},i=n=>{(e[n]!==m[n]||t[n]!==void 0)&&(r[n]=e[n])};i(`mediaMode`),i(`inboundMediaMode`),i(`rehydration`),i(`mediaMaxMb`),i(`inboundAgentMount`),i(`outboundAgentMount`);let a=g(e.promptInjections,n);Object.keys(a).length>0&&(r.promptInjections=a);let o=t;for(let e of v){let t=o[e];(typeof t==`number`||typeof t==`boolean`||typeof t==`string`)&&(r[e]=t)}return r}var b=e();function x({text:e}){return(0,b.jsx)(r,{delayDuration:150,children:(0,b.jsxs)(i,{children:[(0,b.jsx)(a,{asChild:!0,children:(0,b.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,b.jsx)(l,{"aria-hidden":!0})})}),(0,b.jsx)(c,{className:`max-w-xs text-pretty`,children:e})]})})}function S({label:e,help:t}){return(0,b.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,b.jsx)(x,{text:t})]})}export{p as a,f as c,_ as i,S as n,d as o,y as r,u as s,x as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AJ as ee,BJ as r,BY as te,CJ as i,DJ as a,Df as o,EJ as ne,Ef as re,FJ as s,GJ as ie,HB as c,HJ as l,IJ as u,JJ as d,KJ as ae,LJ as f,MJ as oe,NJ as se,NY as ce,OJ as le,PJ as ue,QJ as de,RJ as p,SJ as fe,TJ as m,UJ as pe,VJ as h,VY as me,WJ as he,XJ as ge,YJ as g,ZJ as _e,_J as ve,bJ as ye,jJ as be,jY as xe,kJ as Se,qJ as _,t as v,vJ as y,wJ as b,xJ as x,yJ as S,zJ as C}from"./api-BiOKjOdr.js";import{t as w}from"./button-D0Pgjwxf.js";import{An as T,Bt as E,Gt as D,Ht as O,In as k,Jt as A,Kt as j,Mt as Ce,St as M,Ut as we,Vt as Te,Wt as Ee,Yt as De,an as Oe,bt as N,en as ke,nn as P,nr as F,qt as Ae,tn as je,tr as Me,vt as I,xt as L,yt as R}from"./index-xhYNLD3V.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-DsK3yFpt.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return h();case`audio`:return r();case`video`:return C();case`pdf`:return p();case`document`:return f();case`archive`:return u();default:return s()}}function K(){let[e,t]=(0,H.useState)(W),[n,r]=(0,H.useState)(W),[s,u]=(0,H.useState)(W),[f,p]=(0,H.useState)(W),[h,C]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=te(v.files.softDelete),Y=De();function Ie(){t(W),r(W),u(W),p(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(b())}catch(e){Y.error(i(),e)}}let X=me(v.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:s===W?void 0:s,category:f===W?void 0:f,includeAutoGenerated:h||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(ce(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:xe()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||s!==W||f!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:de()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":_e(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ge()}),(0,U.jsx)(N,{value:`inbound`,children:g()}),(0,U.jsx)(N,{value:`outbound`,children:d()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:r,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":_(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ae()}),Q.chats.map(e=>(0,U.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:s,onValueChange:u,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":ie(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:he()}),Q.instances.map(e=>(0,U.jsx)(N,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:f,onValueChange:p,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":pe(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:l()}),Q.categories.map(e=>(0,U.jsx)(N,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(Ce,{checked:h,onCheckedChange:e=>C(e===!0),"aria-label":o()}),(0,U.jsx)(`span`,{children:o()})]}),$?(0,U.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(k,{size:14,"aria-hidden":!0}),a()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?y():S()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:ue()}),(0,U.jsx)(z,{children:se()}),(0,U.jsx)(z,{children:oe()}),(0,U.jsx)(z,{children:be()}),(0,U.jsx)(z,{children:ee()}),(0,U.jsx)(z,{className:`text-right`,children:Se()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(A,{variant:`outline`,style:{marginLeft:6},children:re()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(A,{variant:`secondary`,children:e.direction===`inbound`?g():d()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(ke,{children:[(0,U.jsx)(Oe,{asChild:!0,children:(0,U.jsx)(w,{variant:`ghost`,size:`icon`,"aria-label":ne(),children:(0,U.jsx)(Me,{size:16})})}),(0,U.jsxs)(je,{align:`end`,children:[e.url?(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(F,{size:14}),le()]})}):(0,U.jsxs)(P,{disabled:!0,children:[(0,U.jsx)(F,{size:14}),ye()]}),(0,U.jsxs)(P,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(T,{size:14}),m()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ve({cap:Be})}):null]}),(0,U.jsx)(E,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(we,{children:[(0,U.jsxs)(j,{children:[(0,U.jsx)(Ae,{children:fe()}),(0,U.jsx)(Ee,{children:x()})]}),(0,U.jsxs)(D,{children:[(0,U.jsx)(O,{children:c()}),(0,U.jsx)(Te,{onClick:()=>void Le(),children:m()})]})]})})]})}export{K as FilesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AJ as ee,BJ as r,BY as te,CJ as i,DJ as a,Df as o,EJ as ne,Ef as re,FJ as s,GJ as ie,HB as c,HJ as l,IJ as u,JJ as d,KJ as ae,LJ as f,MJ as oe,NJ as se,NY as ce,OJ as le,PJ as ue,QJ as de,RJ as p,SJ as fe,TJ as m,UJ as pe,VJ as h,VY as me,WJ as he,XJ as ge,YJ as g,ZJ as _e,_J as ve,bJ as ye,jJ as be,jY as xe,kJ as Se,qJ as _,t as v,vJ as y,wJ as b,xJ as x,yJ as S,zJ as C}from"./api-DcB3BxUc.js";import{t as w}from"./button-DgaBsJDX.js";import{An as T,Bt as E,Gt as D,Ht as O,In as k,Jt as A,Kt as j,Mt as Ce,St as M,Ut as we,Vt as Te,Wt as Ee,Yt as De,an as Oe,bt as N,en as ke,nn as P,nr as F,qt as Ae,tn as je,tr as Me,vt as I,xt as L,yt as R}from"./index-Ds-ybIOh.js";import{a as Ne,i as z,n as Pe,o as B,r as V,t as Fe}from"./table-A3AeBsY1.js";var H=t(e(),1),U=n(),W=`all`;function G(e){switch(e){case`image`:return h();case`audio`:return r();case`video`:return C();case`pdf`:return p();case`document`:return f();case`archive`:return u();default:return s()}}function K(){let[e,t]=(0,H.useState)(W),[n,r]=(0,H.useState)(W),[s,u]=(0,H.useState)(W),[f,p]=(0,H.useState)(W),[h,C]=(0,H.useState)(!1),[K,q]=(0,H.useState)(null),J=te(v.files.softDelete),Y=De();function Ie(){t(W),r(W),u(W),p(W)}async function Le(){let e=K;if(q(null),e)try{await J({fileId:e.id}),Y.success(b())}catch(e){Y.error(i(),e)}}let X=me(v.files.listMine,{direction:e===W?void 0:e,chatId:n===W?void 0:n,instanceName:s===W?void 0:s,category:f===W?void 0:f,includeAutoGenerated:h||void 0}),Re=(0,H.useMemo)(()=>new Intl.DateTimeFormat(ce(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(X===void 0)return(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:xe()});let{files:Z,facets:Q,truncated:ze,cap:Be}=X,$=e!==W||n!==W||s!==W||f!==W;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:de()}),(0,U.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,U.jsxs)(I,{value:e,onValueChange:t,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":_e(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ge()}),(0,U.jsx)(N,{value:`inbound`,children:g()}),(0,U.jsx)(N,{value:`outbound`,children:d()})]})]}),(0,U.jsxs)(I,{value:n,onValueChange:r,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":_(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:ae()}),Q.chats.map(e=>(0,U.jsx)(N,{value:e.id,children:e.title},e.id))]})]}),Q.multiProvider?(0,U.jsxs)(I,{value:s,onValueChange:u,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":ie(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:he()}),Q.instances.map(e=>(0,U.jsx)(N,{value:e,children:e},e))]})]}):null,(0,U.jsxs)(I,{value:f,onValueChange:p,children:[(0,U.jsx)(L,{size:`sm`,"aria-label":pe(),children:(0,U.jsx)(M,{})}),(0,U.jsxs)(R,{children:[(0,U.jsx)(N,{value:W,children:l()}),Q.categories.map(e=>(0,U.jsx)(N,{value:e,children:G(e)},e))]})]}),(0,U.jsxs)(`label`,{className:`oc-files__autogen`,children:[(0,U.jsx)(Ce,{checked:h,onCheckedChange:e=>C(e===!0),"aria-label":o()}),(0,U.jsx)(`span`,{children:o()})]}),$?(0,U.jsxs)(w,{variant:`ghost`,size:`sm`,onClick:Ie,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,U.jsx)(k,{size:14,"aria-hidden":!0}),a()]}):null]}),Z.length===0?(0,U.jsx)(`p`,{className:`oc-admin__hint`,children:$?y():S()}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Fe,{children:[(0,U.jsx)(Ne,{children:(0,U.jsxs)(B,{children:[(0,U.jsx)(z,{children:ue()}),(0,U.jsx)(z,{children:se()}),(0,U.jsx)(z,{children:oe()}),(0,U.jsx)(z,{children:be()}),(0,U.jsx)(z,{children:ee()}),(0,U.jsx)(z,{className:`text-right`,children:Se()})]})}),(0,U.jsx)(Pe,{children:Z.map(e=>(0,U.jsxs)(B,{children:[(0,U.jsxs)(V,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:[e.filename,e.origin===`pasted`?(0,U.jsx)(A,{variant:`outline`,style:{marginLeft:6},children:re()}):null]}),(0,U.jsx)(V,{title:e.mimeType,children:G(e.category)}),(0,U.jsx)(V,{children:(0,U.jsx)(A,{variant:`secondary`,children:e.direction===`inbound`?g():d()})}),(0,U.jsx)(V,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,U.jsx)(V,{className:`whitespace-nowrap text-muted-foreground`,children:Re.format(e.createdAt)}),(0,U.jsx)(V,{className:`text-right`,children:(0,U.jsxs)(ke,{children:[(0,U.jsx)(Oe,{asChild:!0,children:(0,U.jsx)(w,{variant:`ghost`,size:`icon`,"aria-label":ne(),children:(0,U.jsx)(Me,{size:16})})}),(0,U.jsxs)(je,{align:`end`,children:[e.url?(0,U.jsx)(P,{asChild:!0,children:(0,U.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,U.jsx)(F,{size:14}),le()]})}):(0,U.jsxs)(P,{disabled:!0,children:[(0,U.jsx)(F,{size:14}),ye()]}),(0,U.jsxs)(P,{variant:`destructive`,onSelect:()=>q({id:e._id,filename:e.filename}),children:[(0,U.jsx)(T,{size:14}),m()]})]})]})})]},e._id))})]}),ze?(0,U.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:ve({cap:Be})}):null]}),(0,U.jsx)(E,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,U.jsxs)(we,{children:[(0,U.jsxs)(j,{children:[(0,U.jsx)(Ae,{children:fe()}),(0,U.jsx)(Ee,{children:x()})]}),(0,U.jsxs)(D,{children:[(0,U.jsx)(O,{children:c()}),(0,U.jsx)(Te,{onClick:()=>void Le(),children:m()})]})]})})]})}export{K as FilesTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{JS as r,YS as i}from"./api-BiOKjOdr.js";import{t as a}from"./button-D0Pgjwxf.js";import{$t as o,Fn as s,In as c}from"./index-xhYNLD3V.js";import{t as l}from"./TimeRangePicker-BVCNIF4U.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(o,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(c,{}),r()]})]})}export{p as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{JS as r,YS as i}from"./api-DcB3BxUc.js";import{t as a}from"./button-DgaBsJDX.js";import{$t as o,Fn as s,In as c}from"./index-Ds-ybIOh.js";import{t as l}from"./TimeRangePicker-BgJKavXM.js";var u=t(e(),1),d=n(),f=250;function p({q:e,onQChange:t,searchPlaceholder:n=i(),children:p,timeRange:m,onTimeRangeChange:h,onReset:g,canReset:_=!0}){let[v,y]=(0,u.useState)(e);(0,u.useEffect)(()=>{y(e)},[e]);let b=(0,u.useRef)(null);function x(e){y(e),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>t(e),f)}(0,u.useEffect)(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]);function S(){b.current!==null&&window.clearTimeout(b.current),g()}return(0,d.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,d.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,d.jsx)(s,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,d.jsx)(o,{value:v,onChange:e=>x(e.target.value),placeholder:n,"aria-label":n})]}),p?(0,d.jsx)(`div`,{className:`oc-filterbar__quick`,children:p}):null,m&&h?(0,d.jsx)(l,{value:m,onChange:h}):null,(0,d.jsxs)(a,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:S,disabled:!_,children:[(0,d.jsx)(c,{}),r()]})]})}export{p as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,$y as i,Ab as a,BY as o,Bb as s,By as c,Cb as l,Cy as u,Db as d,Dy as f,E as p,Eb as m,Ey as h,Fb as g,Fy as _,Gb as v,Gv as y,Gy as b,Hb as x,Hy as S,Ib as C,Iv as w,Iy as T,Jb as E,Jv as D,Jy as O,Kb as k,Kv as A,Ky as ee,Lb as te,Lv as ne,Ly as j,Mb as M,My as re,Nb as ie,Ny as N,Ob as ae,Oy as P,Pb as oe,Py as se,Qv as F,Qy as ce,Rb as I,Rv as le,Ry as ue,Sb as de,Sy as fe,Tb as pe,Ty as me,Ub as he,Uy as ge,VY as L,Vb as _e,Vy as ve,Wb as ye,Wy as be,Xv as xe,Xy as Se,Yb as Ce,Yv as we,Yy as Te,Zv as Ee,Zy as De,_b as Oe,_y as ke,ab as Ae,ay as je,bb as R,by as Me,cb as Ne,cy as Pe,db as z,dy as Fe,eb as Ie,ey as Le,fb as Re,fy as ze,gy as Be,hy as Ve,ib as He,iy as Ue,jb as We,kb as Ge,lb as Ke,ly as qe,my as Je,nb as Ye,ny as Xe,ob as Ze,oy as Qe,pb as $e,py as et,qb as tt,qv as nt,qy as rt,rb as it,ry as at,sb as ot,sy as st,t as B,tb as ct,ty as lt,ub as ut,uy as dt,vb as ft,vy as pt,wb as mt,wy as ht,xb as gt,xy as _t,yb as vt,yy as yt,zb as bt,zv as xt,zy as St}from"./api-BiOKjOdr.js";import{t as Ct}from"./x-BXqaL85P.js";import{t as V}from"./button-D0Pgjwxf.js";import{$ as wt,$t as H,Ct as Tt,Dn as Et,Dt,En as Ot,G as kt,J as U,Jt as W,K as At,Mn as jt,Mt as G,Nn as K,Ot as Mt,Pn as q,Q as Nt,St as Pt,Tt as Ft,W as J,X as It,Y as Lt,Yt as Y,Z as Rt,at as zt,b as Bt,bt as Vt,cr as Ht,ct as Ut,et as Wt,ft as Gt,it as Kt,jn as X,ot as qt,q as Jt,sr as Yt,st as Xt,vt as Zt,wt as Qt,xt as $t,yt as en}from"./index-xhYNLD3V.js";import{t as tn}from"./FilterBar-BWsi04G_.js";import{t as nn}from"./DataTableShell-P8WPv8pJ.js";import{t as Z}from"./DetailChips-Bb_1pD-w.js";var rn=p(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Q=t(e(),1),$=n(),an={name:``,description:``};function on(){let e=L(B.groups.listGroups,{}),t=L(B.me.getMe,{host:Gt})?.role===`admin`,n=o(B.groups.createGroup),r=o(B.groups.updateGroup),i=o(B.groups.deleteGroup),c=Ut(),l=Y(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(an),[_,y]=(0,Q.useState)(null),[b,S]=(0,Q.useState)(``),w=(0,Q.useMemo)(()=>{if(!e)return e;let t=b.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,b]);function T(){p(null),h(an),d(!0)}function D(e){p(e),h({name:e.name,description:e.description??``}),d(!0)}async function O(){try{f?await r({groupId:f._id,name:m.name,description:m.description}):await n({name:m.name,description:m.description||void 0}),h(an),p(null),d(!1)}catch(e){l.error(be(),e)}}async function A(e){if(await c({title:a({name:e.name}),description:Ge(),confirmWord:e.name,confirmLabel:ae(),cancelLabel:C(),destructive:!0}))try{await i({groupId:e._id})}catch(e){l.error(ge(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:E()}),t?(0,$.jsx)(pn,{}):null,(0,$.jsx)(tn,{q:b,onQChange:S,onReset:()=>S(``),canReset:b!==``,searchPlaceholder:_e()}),(0,$.jsx)(nn,{title:Ce(),rows:w,addLabel:tt(),onAdd:t?T:void 0,emptyHint:k(),columns:[{header:v(),cell:e=>e.name,sort:e=>e.name},{header:ye(),cell:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{icon:(0,$.jsx)(Ot,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(K,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,$.jsx)(W,{variant:`secondary`,children:re({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:he(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(q,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:x(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(rn,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(X,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:s(),onSelect:()=>y({groupId:e._id,name:e.name})},...t?[{label:bt(),onSelect:()=>D(e)},{label:I(),variant:`destructive`,onSelect:()=>void A(e)}]:[]]}),(0,$.jsx)(Bt,{open:u,onOpenChange:d,title:f?oe():g(),description:ie(),canSubmit:!!m.name.trim(),onSubmit:O,submitLabel:te(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:M()}),(0,$.jsx)(H,{value:m.name,onChange:e=>h({...m,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:We()}),(0,$.jsx)(H,{value:m.description,onChange:e=>h({...m,description:e.target.value})})]})]})}),(0,$.jsx)(ln,{groupId:_?.groupId??null,groupName:_?.name??``,open:_!==null,onOpenChange:e=>{e||y(null)}})]})}var sn=8;function cn({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Ht,{size:14,"aria-hidden":!0}),vt()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":Oe({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ft(),(0,$.jsx)(Yt,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=L(B.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,s=L(B.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),f=L(B.groups.listAssignableUsers,n&&a?{}:`skip`),p=o(B.groups.addMember),h=o(B.groups.removeMember),g=o(B.groups.bulkSetMembers),_=o(B.groups.setGroupManager),v=Y(),[y,b]=(0,Q.useState)(``),[x,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(`members`),[E,D]=(0,Q.useState)(1),[k,A]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(new Set),j=(0,Q.useRef)(null),M=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),ie=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),N=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>J(e.instanceName,e.agentId))),[i]),ae=(0,Q.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?J(e.instanceName,e.agentId):null},[i]);(0,Q.useEffect)(()=>{b(``),C(``),T(`members`),D(1),A(null),j.current=null},[n,e]),(0,Q.useEffect)(()=>{D(1)},[y]),(0,Q.useEffect)(()=>{n&&i&&e&&j.current!==e&&(j.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let P=(0,Q.useMemo)(()=>f?Jt(f,y,te):[],[f,y,te]);async function oe(t,n){if(e)try{n?await h({groupId:e,userId:t}):await p({groupId:e,userId:t})}catch(e){v.error(S(),U(e))}}async function se(t,n){if(e)try{await _({groupId:e,userId:t,manager:!n})}catch(e){v.error(ee(),e)}}let F=wt(P,e=>M.has(e.userId)),ce=P.filter(e=>M.has(e.userId)).length,I=Rt(P,E,sn);async function le(){if(!e||P.length===0)return;let t=P.map(e=>e.userId);try{await g({groupId:e,userIds:t,member:F!==`all`})}catch(e){v.error(S(),U(e))}}let ue=(e,t)=>(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":u({user:t}),title:u({user:t}),onClick:()=>A({userId:e,label:t}),children:[(0,$.jsx)(jt,{size:13,"aria-hidden":!0}),ht()]});return(0,$.jsx)(Tt,{open:n,onOpenChange:r,children:(0,$.jsxs)(Qt,{className:`oc-access`,children:[(0,$.jsxs)(Dt,{children:[(0,$.jsx)(Mt,{children:d({name:t})}),(0,$.jsx)(Ft,{children:i&&!a?c():m()})]}),(0,$.jsxs)(Kt,{value:w,onValueChange:T,className:`oc-access__tabs`,children:[(0,$.jsxs)(qt,{className:`w-full`,children:[(0,$.jsxs)(Xt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ot,{size:13,"aria-hidden":!0}),pe(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(Xt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(q,{size:13,"aria-hidden":!0}),l(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,$.jsxs)(Xt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(rn,{size:13,"aria-hidden":!0}),it(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(zt,{value:`members`,children:i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):a?f===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):f.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ke()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{value:y,onChange:e=>b(e.target.value),placeholder:mt(),className:`oc-access__search`}),P.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:gt()}):(0,$.jsxs)($.Fragment,{children:[P.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void le(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,$.jsxs)(W,{variant:`outline`,className:`oc-access__count`,children:[ce,` / `,P.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=M.has(e.userId),n=Wt(e),r=re.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:t,onCheckedChange:()=>void oe(e.userId,t),"aria-label":$e({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&ie.has(e.userId)?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:Nt(e.role)}),t?ue(e.userId,n.primary):null,(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?rt():O(),title:r?rt():O(),onClick:()=>void se(e.userId,r),children:(0,$.jsx)(K,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(cn,{page:I.page,pageCount:I.pageCount,onPage:D})]})]}):e?(0,$.jsx)(un,{groupId:e,members:i.members,agentsButton:ue}):null}),(0,$.jsxs)(zt,{value:`agents`,children:[i&&!a?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:et()}):null,s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ne()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{value:x,onChange:e=>C(e.target.value),placeholder:de(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,$.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:N,defaultKey:ae,viewerIsAdmin:a,query:x},`${e}-${t._id}`))})]})]}),(0,$.jsx)(zt,{value:`charts`,children:(0,$.jsx)(mn,{groupId:e})})]}),(0,$.jsx)(dn,{groupId:e,member:k,onOpenChange:e=>{e||A(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=L(B.groupInvites.listGroupInviteRequests,{groupId:e}),i=o(B.groupInvites.requestGroupInvite),a=o(B.groups.removeMember),s=Ut(),c=Y(),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(1),m=Rt(t,d,sn);async function g(t){t.preventDefault();let n=l.trim();if(n)try{await i({groupId:e,email:n}),u(``),c.success(_())}catch(e){c.error(se(),e)}}async function v(t,n){if(await s({title:P({user:n}),description:h({user:n}),confirmLabel:me(),cancelLabel:C(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){c.error(S(),U(e))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void g(e),children:[(0,$.jsx)(H,{type:`email`,value:l,onChange:e=>u(e.target.value),placeholder:j(),"aria-label":St()}),(0,$.jsxs)(V,{type:`submit`,size:`sm`,disabled:!l.trim(),children:[(0,$.jsx)(Et,{size:14,"aria-hidden":!0}),T()]})]}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ue()}),t.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:m.pageItems.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,n(e.userId,e.label),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":Te(),title:Te(),children:(0,$.jsx)(K,{size:15,"aria-hidden":!0})}):null}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":P({user:e.label}),title:e.manager?f():e.lastGroup?y():P({user:e.label}),onClick:()=>void v(e.userId,e.label),children:(0,$.jsx)(Ct,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,$.jsx)(cn,{page:m.page,pageCount:m.pageCount,onPage:p})]}),r!==void 0&&r.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:N()}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsx)(W,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Lt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=L(B.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=o(B.groups.setMemberAgents),s=o(B.groups.setMemberDefaultAgent),c=Y();async function l(e){try{await e()}catch(e){c.error(A(),e)}}let u=i?.agents??[],d=new Map(u.map(e=>[J(e.instanceName,e.agentId),e])),f=[...d.keys()],p=new Set(u.filter(e=>e.allowed).map(e=>J(e.instanceName,e.agentId)));function m(n){if(!e||!t||!i)return;let r=It(f,p,i.restricted,n).map(e=>{let t=d.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});l(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,$.jsx)(Tt,{open:t!==null,onOpenChange:n,children:(0,$.jsxs)(Qt,{className:`oc-access`,children:[(0,$.jsxs)(Dt,{children:[(0,$.jsx)(Mt,{children:lt({user:t?.label??``})}),(0,$.jsx)(Ft,{children:Le()})]}),i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):i===null||u.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:nt()}):(0,$.jsxs)($.Fragment,{children:[i.settable?null:(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}),i.adminNarrowed?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:xt()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):null,(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?F():r()}),i.restricted?(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void l(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:Ee()}):null]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:u.map(n=>{let r=J(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>m(r),"aria-label":xe({name:a})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:le()}):null,n.state===`deleted`?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,n.allowed?n.isMemberDefault?(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":we(),title:we(),onClick:()=>e&&t?void l(()=>s({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!i.settable,"aria-label":D(),title:D(),onClick:()=>e&&t?void l(()=>s({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,$.jsx)(X,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:s}){let c=L(B.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=o(B.groups.assignAgentToGroup),u=o(B.groups.removeAgentFromGroup),d=o(B.groups.bulkSetGroupAgents),f=o(B.groups.claimAgentForGroup),p=o(B.groups.setGroupDefaultAgent),m=Y(),[h,g]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{g(1)},[s]),!e)return null;let _=At(c?.agents??[],s),v=c?.discovery&&!c.discovery.lastPollOk,y=e=>kt({assigned:r.has(J(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),b=_.filter(e=>y(e)!==`claim`),x=_.filter(e=>y(e)===`claim`);if(s.trim()&&_.length===0)return null;let S=b.filter(e=>y(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),C=wt(S,e=>r.has(J(t,e.agentId))),w=Rt(b,h,sn);async function T(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(ve(),U(e))}}async function E(){if(S.length===0)return;let n=S.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:C!==`all`})}catch(e){m.error(ve(),U(e))}}async function D(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(Pe(),e)}}async function O(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(Xe(),e)}}let k=e=>e.reservedForGroup?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:st()}):e.reserved?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?je():Qe({group:e.reservedGroupName})}):null;return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(q,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(W,{variant:`outline`,className:`oc-access__kind`,children:n}),v?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__stale`,children:Ae()}):null]}),c===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ut()}):_.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v?Ze():ot()}):(0,$.jsxs)($.Fragment,{children:[S.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:C===`all`?!0:C===`some`?`indeterminate`:!1,onCheckedChange:()=>void E(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,w.pageItems.map(e=>{let n=J(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=y(e)===`locked`;return(0,$.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,$.jsx)(G,{checked:a,disabled:s&&!a,onCheckedChange:()=>void T(e.agentId,a),"aria-label":Re({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,k(e),o?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,a?i===n?(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":Ue(),title:Ue(),onClick:()=>void O(null),children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":at(),title:at(),onClick:()=>void O(e.agentId),children:(0,$.jsx)(X,{size:14})}):null]},e.agentId)}),(0,$.jsx)(cn,{page:w.page,pageCount:w.pageCount,onPage:g}),x.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:ze()}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Fe()}),x.map(e=>{let t=e.displayName??e.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":qe({name:t}),onClick:()=>void D(e.agentId),children:dt()})]},e.agentId)})]}):null]})]})}function pn(){let e=L(B.groupInvites.listPendingInviteRequests,{}),t=o(B.groupInvites.decideGroupInvite),n=Y();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(Je(),e)}}return(0,$.jsxs)(`section`,{className:`oc-invites`,"aria-label":Me(),children:[(0,$.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,$.jsx)(Et,{size:14,"aria-hidden":!0}),Me(),(0,$.jsx)(W,{variant:`secondary`,children:e.length})]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,yt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Be():Ve()}),(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:pt()}),(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:ke()})]},e._id))})]})}function mn({groupId:e}){let t=L(B.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=o(B.charts.assignChartToGroup),r=o(B.charts.removeChartFromGroup),a=o(B.charts.setGroupDefaultChart),s=o(B.charts.addChartToGroupPool),c=o(B.charts.removeChartFromGroupPool),l=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()});let{pool:u,addable:d,canManagePool:f}=t;if(u.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ye()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function h(t){try{await s({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function g(t){try{await c({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:u.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":ce({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":De(),title:De(),children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:Se()}):null,f?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":i({name:e.name}),title:i({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ct,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?d.length>0?(0,$.jsxs)(Zt,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)($t,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Pt,{placeholder:Ie()})}),(0,$.jsx)(en,{children:d.map(e=>(0,$.jsx)(Vt,{value:e.chartKey,children:e.name},e.chartKey))})]}):u.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ct()}):null:null]})}export{on as GroupsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,$y as i,Ab as a,BY as o,Bb as s,By as c,Cb as l,Cy as u,Db as d,Dy as f,E as p,Eb as m,Ey as h,Fb as g,Fy as _,Gb as v,Gv as y,Gy as b,Hb as x,Hy as S,Ib as C,Iv as w,Iy as T,Jb as E,Jv as D,Jy as O,Kb as k,Kv as A,Ky as ee,Lb as te,Lv as ne,Ly as j,Mb as M,My as re,Nb as ie,Ny as N,Ob as ae,Oy as P,Pb as oe,Py as se,Qv as F,Qy as ce,Rb as I,Rv as le,Ry as ue,Sb as de,Sy as fe,Tb as pe,Ty as me,Ub as he,Uy as ge,VY as L,Vb as _e,Vy as ve,Wb as ye,Wy as be,Xv as xe,Xy as Se,Yb as Ce,Yv as we,Yy as Te,Zv as Ee,Zy as De,_b as Oe,_y as ke,ab as Ae,ay as je,bb as R,by as Me,cb as Ne,cy as Pe,db as z,dy as Fe,eb as Ie,ey as Le,fb as Re,fy as ze,gy as Be,hy as Ve,ib as He,iy as Ue,jb as We,kb as Ge,lb as Ke,ly as qe,my as Je,nb as Ye,ny as Xe,ob as Ze,oy as Qe,pb as $e,py as et,qb as tt,qv as nt,qy as rt,rb as it,ry as at,sb as ot,sy as st,t as B,tb as ct,ty as lt,ub as ut,uy as dt,vb as ft,vy as pt,wb as mt,wy as ht,xb as gt,xy as _t,yb as vt,yy as yt,zb as bt,zv as xt,zy as St}from"./api-DcB3BxUc.js";import{t as Ct}from"./x-DJcI0sFP.js";import{t as V}from"./button-DgaBsJDX.js";import{$ as wt,$t as H,Ct as Tt,Dn as Et,Dt,En as Ot,G as kt,J as U,Jt as W,K as At,Mn as jt,Mt as G,Nn as K,Ot as Mt,Pn as q,Q as Nt,St as Pt,Tt as Ft,W as J,X as It,Y as Lt,Yt as Y,Z as Rt,at as zt,b as Bt,bt as Vt,cr as Ht,ct as Ut,et as Wt,ft as Gt,it as Kt,jn as X,ot as qt,q as Jt,sr as Yt,st as Xt,vt as Zt,wt as Qt,xt as $t,yt as en}from"./index-Ds-ybIOh.js";import{t as tn}from"./FilterBar-B0W1nP3i.js";import{t as nn}from"./DataTableShell-7VOYauXM.js";import{t as Z}from"./DetailChips-DxxeU-mf.js";var rn=p(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Q=t(e(),1),$=n(),an={name:``,description:``};function on(){let e=L(B.groups.listGroups,{}),t=L(B.me.getMe,{host:Gt})?.role===`admin`,n=o(B.groups.createGroup),r=o(B.groups.updateGroup),i=o(B.groups.deleteGroup),c=Ut(),l=Y(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(an),[_,y]=(0,Q.useState)(null),[b,S]=(0,Q.useState)(``),w=(0,Q.useMemo)(()=>{if(!e)return e;let t=b.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,b]);function T(){p(null),h(an),d(!0)}function D(e){p(e),h({name:e.name,description:e.description??``}),d(!0)}async function O(){try{f?await r({groupId:f._id,name:m.name,description:m.description}):await n({name:m.name,description:m.description||void 0}),h(an),p(null),d(!1)}catch(e){l.error(be(),e)}}async function A(e){if(await c({title:a({name:e.name}),description:Ge(),confirmWord:e.name,confirmLabel:ae(),cancelLabel:C(),destructive:!0}))try{await i({groupId:e._id})}catch(e){l.error(ge(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:E()}),t?(0,$.jsx)(pn,{}):null,(0,$.jsx)(tn,{q:b,onQChange:S,onReset:()=>S(``),canReset:b!==``,searchPlaceholder:_e()}),(0,$.jsx)(nn,{title:Ce(),rows:w,addLabel:tt(),onAdd:t?T:void 0,emptyHint:k(),columns:[{header:v(),cell:e=>e.name,sort:e=>e.name},{header:ye(),cell:e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{icon:(0,$.jsx)(Ot,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,$.jsx)(K,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),e.pendingInviteCount>0?(0,$.jsx)(W,{variant:`secondary`,children:re({count:String(e.pendingInviteCount)})}):null]}),sort:e=>e.memberCount},{header:he(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(q,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:x(),cell:e=>(0,$.jsx)(Z,{icon:(0,$.jsx)(rn,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,$.jsx)(X,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:s(),onSelect:()=>y({groupId:e._id,name:e.name})},...t?[{label:bt(),onSelect:()=>D(e)},{label:I(),variant:`destructive`,onSelect:()=>void A(e)}]:[]]}),(0,$.jsx)(Bt,{open:u,onOpenChange:d,title:f?oe():g(),description:ie(),canSubmit:!!m.name.trim(),onSubmit:O,submitLabel:te(),children:(0,$.jsxs)(`div`,{className:`oc-form`,children:[(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:M()}),(0,$.jsx)(H,{value:m.name,onChange:e=>h({...m,name:e.target.value})})]}),(0,$.jsxs)(`label`,{className:`oc-field`,children:[(0,$.jsx)(`span`,{className:`oc-field__label`,children:We()}),(0,$.jsx)(H,{value:m.description,onChange:e=>h({...m,description:e.target.value})})]})]})}),(0,$.jsx)(ln,{groupId:_?.groupId??null,groupName:_?.name??``,open:_!==null,onOpenChange:e=>{e||y(null)}})]})}var sn=8;function cn({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,$.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,$.jsx)(Ht,{size:14,"aria-hidden":!0}),vt()]}),(0,$.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":Oe({page:e,pages:t}),children:[e,` / `,t]}),(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[ft(),(0,$.jsx)(Yt,{size:14,"aria-hidden":!0})]})]})}function ln({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=L(B.groups.getGroup,n&&e?{groupId:e}:`skip`),a=i?.viewerIsAdmin===!0,s=L(B.groups.listAssignableInstances,n&&e?{groupId:e}:`skip`),f=L(B.groups.listAssignableUsers,n&&a?{}:`skip`),p=o(B.groups.addMember),h=o(B.groups.removeMember),g=o(B.groups.bulkSetMembers),_=o(B.groups.setGroupManager),v=Y(),[y,b]=(0,Q.useState)(``),[x,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(`members`),[E,D]=(0,Q.useState)(1),[k,A]=(0,Q.useState)(null),[te,ne]=(0,Q.useState)(new Set),j=(0,Q.useRef)(null),M=(0,Q.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),re=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),ie=(0,Q.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.restricted).map(e=>e.userId)),[i]),N=(0,Q.useMemo)(()=>new Set((i?.agents??[]).map(e=>J(e.instanceName,e.agentId))),[i]),ae=(0,Q.useMemo)(()=>{let e=(i?.agents??[]).find(e=>e.isDefault);return e?J(e.instanceName,e.agentId):null},[i]);(0,Q.useEffect)(()=>{b(``),C(``),T(`members`),D(1),A(null),j.current=null},[n,e]),(0,Q.useEffect)(()=>{D(1)},[y]),(0,Q.useEffect)(()=>{n&&i&&e&&j.current!==e&&(j.current=e,ne(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let P=(0,Q.useMemo)(()=>f?Jt(f,y,te):[],[f,y,te]);async function oe(t,n){if(e)try{n?await h({groupId:e,userId:t}):await p({groupId:e,userId:t})}catch(e){v.error(S(),U(e))}}async function se(t,n){if(e)try{await _({groupId:e,userId:t,manager:!n})}catch(e){v.error(ee(),e)}}let F=wt(P,e=>M.has(e.userId)),ce=P.filter(e=>M.has(e.userId)).length,I=Rt(P,E,sn);async function le(){if(!e||P.length===0)return;let t=P.map(e=>e.userId);try{await g({groupId:e,userIds:t,member:F!==`all`})}catch(e){v.error(S(),U(e))}}let ue=(e,t)=>(0,$.jsxs)(V,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7`,"aria-label":u({user:t}),title:u({user:t}),onClick:()=>A({userId:e,label:t}),children:[(0,$.jsx)(jt,{size:13,"aria-hidden":!0}),ht()]});return(0,$.jsx)(Tt,{open:n,onOpenChange:r,children:(0,$.jsxs)(Qt,{className:`oc-access`,children:[(0,$.jsxs)(Dt,{children:[(0,$.jsx)(Mt,{children:d({name:t})}),(0,$.jsx)(Ft,{children:i&&!a?c():m()})]}),(0,$.jsxs)(Kt,{value:w,onValueChange:T,className:`oc-access__tabs`,children:[(0,$.jsxs)(qt,{className:`w-full`,children:[(0,$.jsxs)(Xt,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(Ot,{size:13,"aria-hidden":!0}),pe(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:M.size}):null]}),(0,$.jsxs)(Xt,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(q,{size:13,"aria-hidden":!0}),l(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:N.size}):null]}),(0,$.jsxs)(Xt,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,$.jsx)(rn,{size:13,"aria-hidden":!0}),it(),i?(0,$.jsx)(W,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,$.jsx)(zt,{value:`members`,children:i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):a?f===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):f.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ke()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{value:y,onChange:e=>b(e.target.value),placeholder:mt(),className:`oc-access__search`}),P.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:gt()}):(0,$.jsxs)($.Fragment,{children:[P.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:F===`all`?!0:F===`some`?`indeterminate`:!1,onCheckedChange:()=>void le(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()}),(0,$.jsxs)(W,{variant:`outline`,className:`oc-access__count`,children:[ce,` / `,P.length]})]}):null,(0,$.jsx)(`div`,{className:`oc-access__list`,children:I.pageItems.map(e=>{let t=M.has(e.userId),n=Wt(e),r=re.has(e.userId);return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:t,onCheckedChange:()=>void oe(e.userId,t),"aria-label":$e({user:n.primary})}),(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,$.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),t&&ie.has(e.userId)?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:Nt(e.role)}),t?ue(e.userId,n.primary):null,(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:t?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?rt():O(),title:r?rt():O(),onClick:()=>void se(e.userId,r),children:(0,$.jsx)(K,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,$.jsx)(cn,{page:I.page,pageCount:I.pageCount,onPage:D})]})]}):e?(0,$.jsx)(un,{groupId:e,members:i.members,agentsButton:ue}):null}),(0,$.jsxs)(zt,{value:`agents`,children:[i&&!a?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:et()}):null,s===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):s.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ne()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{value:x,onChange:e=>C(e.target.value),placeholder:de(),className:`oc-access__search`}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:s.map(t=>(0,$.jsx)(fn,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:N,defaultKey:ae,viewerIsAdmin:a,query:x},`${e}-${t._id}`))})]})]}),(0,$.jsx)(zt,{value:`charts`,children:(0,$.jsx)(mn,{groupId:e})})]}),(0,$.jsx)(dn,{groupId:e,member:k,onOpenChange:e=>{e||A(null)}})]})})}function un({groupId:e,members:t,agentsButton:n}){let r=L(B.groupInvites.listGroupInviteRequests,{groupId:e}),i=o(B.groupInvites.requestGroupInvite),a=o(B.groups.removeMember),s=Ut(),c=Y(),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(1),m=Rt(t,d,sn);async function g(t){t.preventDefault();let n=l.trim();if(n)try{await i({groupId:e,email:n}),u(``),c.success(_())}catch(e){c.error(se(),e)}}async function v(t,n){if(await s({title:P({user:n}),description:h({user:n}),confirmLabel:me(),cancelLabel:C(),destructive:!0}))try{await a({groupId:e,userId:t})}catch(e){c.error(S(),U(e))}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`form`,{className:`oc-access__invite`,onSubmit:e=>void g(e),children:[(0,$.jsx)(H,{type:`email`,value:l,onChange:e=>u(e.target.value),placeholder:j(),"aria-label":St()}),(0,$.jsxs)(V,{type:`submit`,size:`sm`,disabled:!l.trim(),children:[(0,$.jsx)(Et,{size:14,"aria-hidden":!0}),T()]})]}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ue()}),t.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:_t()}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:m.pageItems.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.label,children:e.label}),e.restricted?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:fe()}):null,n(e.userId,e.label),(0,$.jsx)(`span`,{className:`oc-access__mgrslot`,children:e.manager?(0,$.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":Te(),title:Te(),children:(0,$.jsx)(K,{size:15,"aria-hidden":!0})}):null}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:e.manager||e.lastGroup,"aria-label":P({user:e.label}),title:e.manager?f():e.lastGroup?y():P({user:e.label}),onClick:()=>void v(e.userId,e.label),children:(0,$.jsx)(Ct,{size:14,"aria-hidden":!0})})]},e.userId))}),(0,$.jsx)(cn,{page:m.page,pageCount:m.pageCount,onPage:p})]}),r!==void 0&&r.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:N()}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsx)(W,{variant:e.status===`pending`?`secondary`:`outline`,className:`oc-access__role`,children:Lt(e.status)})]},e._id))})]}):null]})}function dn({groupId:e,member:t,onOpenChange:n}){let i=L(B.groups.getMemberAgentSettings,e&&t?{groupId:e,userId:t.userId}:`skip`),a=o(B.groups.setMemberAgents),s=o(B.groups.setMemberDefaultAgent),c=Y();async function l(e){try{await e()}catch(e){c.error(A(),e)}}let u=i?.agents??[],d=new Map(u.map(e=>[J(e.instanceName,e.agentId),e])),f=[...d.keys()],p=new Set(u.filter(e=>e.allowed).map(e=>J(e.instanceName,e.agentId)));function m(n){if(!e||!t||!i)return;let r=It(f,p,i.restricted,n).map(e=>{let t=d.get(e);return{instanceName:t.instanceName,agentId:t.agentId}});l(()=>a({groupId:e,userId:t.userId,agents:r}))}return(0,$.jsx)(Tt,{open:t!==null,onOpenChange:n,children:(0,$.jsxs)(Qt,{className:`oc-access`,children:[(0,$.jsxs)(Dt,{children:[(0,$.jsx)(Mt,{children:lt({user:t?.label??``})}),(0,$.jsx)(Ft,{children:Le()})]}),i===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()}):i===null||u.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:nt()}):(0,$.jsxs)($.Fragment,{children:[i.settable?null:(0,$.jsx)(`p`,{className:`oc-access__hint`,children:w()}),i.adminNarrowed?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:xt()}):null,i.restrictedByAdmin&&!i.viewerIsAdmin?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ne()}):null,(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,children:i.restricted?F():r()}),i.restricted?(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin,onClick:()=>e&&t?void l(()=>a({groupId:e,userId:t.userId,agents:null})):void 0,children:Ee()}):null]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:u.map(n=>{let r=J(n.instanceName,n.agentId),a=n.displayName??n.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:n.allowed,disabled:!i.settable||i.restrictedByAdmin&&!i.viewerIsAdmin&&!n.allowed,onCheckedChange:()=>m(r),"aria-label":xe({name:a})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:a,children:a}),n.limitedByAdmin?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:le()}):null,n.state===`deleted`?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,n.allowed?n.isMemberDefault?(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,disabled:!i.settable,"aria-label":we(),title:we(),onClick:()=>e&&t?void l(()=>s({groupId:e,userId:t.userId,agent:null})):void 0,children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,disabled:!i.settable,"aria-label":D(),title:D(),onClick:()=>e&&t?void l(()=>s({groupId:e,userId:t.userId,agent:{instanceName:n.instanceName,agentId:n.agentId}})):void 0,children:(0,$.jsx)(X,{size:14})}):null]},r)})})]})]})})}function fn({groupId:e,instanceName:t,kind:n,assigned:r,defaultKey:i,viewerIsAdmin:a,query:s}){let c=L(B.groups.listAssignableAgents,e?{instanceName:t,groupId:e}:`skip`),l=o(B.groups.assignAgentToGroup),u=o(B.groups.removeAgentFromGroup),d=o(B.groups.bulkSetGroupAgents),f=o(B.groups.claimAgentForGroup),p=o(B.groups.setGroupDefaultAgent),m=Y(),[h,g]=(0,Q.useState)(1);if((0,Q.useEffect)(()=>{g(1)},[s]),!e)return null;let _=At(c?.agents??[],s),v=c?.discovery&&!c.discovery.lastPollOk,y=e=>kt({assigned:r.has(J(t,e.agentId)),claimable:e.claimable,reservedForGroup:e.reservedForGroup,enabled:e.enabled,present:e.presentInLastOk!==!1},a),b=_.filter(e=>y(e)!==`claim`),x=_.filter(e=>y(e)===`claim`);if(s.trim()&&_.length===0)return null;let S=b.filter(e=>y(e)===`toggle`&&e.presentInLastOk!==!1&&e.enabled!==!1),C=wt(S,e=>r.has(J(t,e.agentId))),w=Rt(b,h,sn);async function T(n,r){try{r?await u({groupId:e,instanceName:t,agentId:n}):await l({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(ve(),U(e))}}async function E(){if(S.length===0)return;let n=S.map(e=>e.agentId);try{await d({groupId:e,instanceName:t,agentIds:n,assigned:C!==`all`})}catch(e){m.error(ve(),U(e))}}async function D(n){try{await f({groupId:e,instanceName:t,agentId:n})}catch(e){m.error(Pe(),e)}}async function O(n){try{await p({groupId:e,agent:n===null?null:{instanceName:t,agentId:n}})}catch(e){m.error(Xe(),e)}}let k=e=>e.reservedForGroup?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:st()}):e.reserved?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.reservedGroupName===null?je():Qe({group:e.reservedGroupName})}):null;return(0,$.jsxs)(`div`,{className:`oc-access__group`,children:[(0,$.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,$.jsx)(q,{size:13,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:t}),(0,$.jsx)(W,{variant:`outline`,className:`oc-access__kind`,children:n}),v?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__stale`,children:Ae()}):null]}),c===void 0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ut()}):_.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:v?Ze():ot()}):(0,$.jsxs)($.Fragment,{children:[S.length>1?(0,$.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,$.jsx)(G,{checked:C===`all`?!0:C===`some`?`indeterminate`:!1,onCheckedChange:()=>void E(),"aria-label":R()}),(0,$.jsx)(`span`,{className:`oc-access__label`,children:R()})]}):null,w.pageItems.map(e=>{let n=J(t,e.agentId),a=r.has(n),o=e.presentInLastOk===!1,s=y(e)===`locked`;return(0,$.jsxs)(`div`,{className:`oc-access__row${s?` is-disabled`:``}`,children:[(0,$.jsx)(G,{checked:a,disabled:s&&!a,onCheckedChange:()=>void T(e.agentId,a),"aria-label":Re({name:e.displayName??e.agentId})}),(0,$.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,k(e),o?(0,$.jsx)(W,{variant:`outline`,className:`oc-access__gone`,children:He()}):null,a?i===n?(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__fav`,"aria-label":Ue(),title:Ue(),onClick:()=>void O(null),children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":at(),title:at(),onClick:()=>void O(e.agentId),children:(0,$.jsx)(X,{size:14})}):null]},e.agentId)}),(0,$.jsx)(cn,{page:w.page,pageCount:w.pageCount,onPage:g}),x.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`oc-access__subhead`,children:ze()}),(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Fe()}),x.map(e=>{let t=e.displayName??e.agentId;return(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__label`,title:t,children:[e.emoji?`${e.emoji} `:``,t]}),e.model?(0,$.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,"aria-label":qe({name:t}),onClick:()=>void D(e.agentId),children:dt()})]},e.agentId)})]}):null]})]})}function pn(){let e=L(B.groupInvites.listPendingInviteRequests,{}),t=o(B.groupInvites.decideGroupInvite),n=Y();if(e===void 0||e.length===0)return null;async function r(e,r){try{await t({requestId:e,approve:r})}catch(e){n.error(Je(),e)}}return(0,$.jsxs)(`section`,{className:`oc-invites`,"aria-label":Me(),children:[(0,$.jsxs)(`h3`,{className:`oc-invites__title`,children:[(0,$.jsx)(Et,{size:14,"aria-hidden":!0}),Me(),(0,$.jsx)(W,{variant:`secondary`,children:e.length})]}),(0,$.jsx)(`div`,{className:`oc-access__list`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsxs)(`span`,{className:`oc-access__who`,children:[(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.email,children:e.email}),(0,$.jsxs)(`span`,{className:`oc-access__sub`,children:[e.groupName??`?`,` ·`,` `,yt({by:e.requestedBy})]})]}),e.account===`ready`?null:(0,$.jsx)(W,{variant:`outline`,className:`oc-access__role`,children:e.account===`none`?Be():Ve()}),(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7`,disabled:e.account!==`ready`,onClick:()=>void r(e._id,!0),children:pt()}),(0,$.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7`,onClick:()=>void r(e._id,!1),children:ke()})]},e._id))})]})}function mn({groupId:e}){let t=L(B.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=o(B.charts.assignChartToGroup),r=o(B.charts.removeChartFromGroup),a=o(B.charts.setGroupDefaultChart),s=o(B.charts.addChartToGroupPool),c=o(B.charts.removeChartFromGroupPool),l=Y();if(!e)return null;if(t===void 0)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:z()});let{pool:u,addable:d,canManagePool:f}=t;if(u.length===0&&!f)return(0,$.jsx)(`p`,{className:`oc-access__hint`,children:Ye()});async function p(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function m(t){try{await a({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function h(t){try{await s({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}async function g(t){try{await c({groupId:e,chartKey:t})}catch(e){l.error(b(),e)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`oc-access__list`,children:u.map(e=>(0,$.jsxs)(`div`,{className:`oc-access__row`,children:[(0,$.jsx)(G,{checked:e.selected,onCheckedChange:()=>void p(e.chartKey,e.selected),"aria-label":ce({name:e.name})}),(0,$.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,$.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":De(),title:De(),children:(0,$.jsx)(X,{size:14,fill:`currentColor`})}):(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void m(e.chartKey),children:Se()}):null,f?(0,$.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":i({name:e.name}),title:i({name:e.name}),onClick:()=>void g(e.chartKey),children:(0,$.jsx)(Ct,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),f?d.length>0?(0,$.jsxs)(Zt,{value:``,onValueChange:e=>void h(e),children:[(0,$.jsx)($t,{size:`sm`,className:`oc-access__search`,children:(0,$.jsx)(Pt,{placeholder:Ie()})}),(0,$.jsx)(en,{children:d.map(e=>(0,$.jsx)(Vt,{value:e.chartKey,children:e.name},e.chartKey))})]}):u.length===0?(0,$.jsx)(`p`,{className:`oc-access__hint`,children:ct()}):null:null]})}export{on as GroupsTab};