local-operator-ui 0.41.0 → 0.41.2

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 (96) hide show
  1. package/out/main/index.js +390 -50
  2. package/out/preload/index.js +19 -0
  3. package/out/renderer/assets/{_basePickBy--UFblcLV.js → _basePickBy-BgapP5T6.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-Ct7pRnI4.js → _baseUniq-B9rnfho3.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-Col1VcjS.js → agent-details-page-CKRUVtjJ.js} +2 -2
  6. package/out/renderer/assets/{agent-hub-page-CTPn6yGs.js → agent-hub-page-5qLVOZEV.js} +2 -2
  7. package/out/renderer/assets/{agents-page-CBWj1DTr.js → agents-page-tQooOOKH.js} +3 -3
  8. package/out/renderer/assets/{arc-B-YNVaQW.js → arc-Feq-cl9G.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DCzmuMLj.js → architectureDiagram-IEHRJDOE-BmZeJuzA.js} +1 -1
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-f1GS2_U0.js → blockDiagram-JOT3LUYC-DEqkKuOE.js} +1 -1
  11. package/out/renderer/assets/{book-open-Cb4F-cRs.js → book-open-C1uak1LZ.js} +1 -1
  12. package/out/renderer/assets/browser-page-CB-_usY1.js +1 -0
  13. package/out/renderer/assets/{browser-webauthn-prompt-ghcPWp0R.js → browser-webauthn-prompt-CKUBOIHd.js} +1 -1
  14. package/out/renderer/assets/{building-2-C_YBTC7O.js → building-2-Bpz1qaDa.js} +1 -1
  15. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BlePs8Im.js → c4Diagram-VJAJSXHY-EbhUbSdf.js} +1 -1
  16. package/out/renderer/assets/channel-CPGK3lub.js +1 -0
  17. package/out/renderer/assets/{chunk-4BMEZGHF-Bse1IaHb.js → chunk-4BMEZGHF-DIk7XDrx.js} +1 -1
  18. package/out/renderer/assets/{chunk-A2AXSNBT-CncpJ5It.js → chunk-A2AXSNBT-D_MflthZ.js} +1 -1
  19. package/out/renderer/assets/{chunk-AEK57VVT-37Z6jWz2.js → chunk-AEK57VVT-C0iLgwbv.js} +1 -1
  20. package/out/renderer/assets/{chunk-D6G4REZN-BR9ZpBMV.js → chunk-D6G4REZN-BbFuFCzc.js} +1 -1
  21. package/out/renderer/assets/{chunk-RZ5BOZE2-KrZ6g0pV.js → chunk-RZ5BOZE2-BxQo8VeZ.js} +1 -1
  22. package/out/renderer/assets/{chunk-XZIHB7SX-BUwRYMe9.js → chunk-XZIHB7SX-DnNtYGsR.js} +1 -1
  23. package/out/renderer/assets/classDiagram-GIVACNV2-hDc6ku-l.js +1 -0
  24. package/out/renderer/assets/classDiagram-v2-COTLJTTW-hDc6ku-l.js +1 -0
  25. package/out/renderer/assets/clone--PuuOIog.js +1 -0
  26. package/out/renderer/assets/{console-mirror-DPVG6sWK.js → console-mirror-Bxl6t4e9.js} +1 -1
  27. package/out/renderer/assets/{consoleCapture-Coky9UhD.js → consoleCapture-BzSftKjg.js} +1 -1
  28. package/out/renderer/assets/{conversation-input-sync-C2vqs6ad.js → conversation-input-sync-MZPvyAzc.js} +239 -239
  29. package/out/renderer/assets/{dagre-OKDRZEBW-CGv1CEcm.js → dagre-OKDRZEBW-qejdp-TF.js} +1 -1
  30. package/out/renderer/assets/{diagram-SSKATNLV-u_zFGYu8.js → diagram-SSKATNLV-qHrLhzXc.js} +1 -1
  31. package/out/renderer/assets/{diagram-VNBRO52H-Bme6bFvQ.js → diagram-VNBRO52H-q0teJTmh.js} +1 -1
  32. package/out/renderer/assets/{erDiagram-Q7BY3M3F-B-KkjVtc.js → erDiagram-Q7BY3M3F-DI6rp9FR.js} +1 -1
  33. package/out/renderer/assets/{error-boundary-DJSaJHcb.js → error-boundary-ZYkSCpZC.js} +2 -2
  34. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CSZy2b_d.js → flowDiagram-4HSFHLVR-xVi21DAI.js} +1 -1
  35. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CpYOSVKU.js → ganttDiagram-APWFNJXF-BUKGBOB_.js} +1 -1
  36. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-WOOSBsBb.js → gitGraphDiagram-7IBYFJ6S-CdE3ZeMn.js} +1 -1
  37. package/out/renderer/assets/{graph-Du8nFp-Q.js → graph-CRaHrZRK.js} +1 -1
  38. package/out/renderer/assets/hash-BN0ECl3H.js +6 -0
  39. package/out/renderer/assets/{heart-CVGkdUzT.js → heart-tKYqMVIH.js} +1 -1
  40. package/out/renderer/assets/{index-fw54FEnm.js → index-B9E-fwX4.js} +1 -1
  41. package/out/renderer/assets/index-BDzV3bGH.js +57 -0
  42. package/out/renderer/assets/{index-D8L83jtw.js → index-DknTGnAk.js} +206 -206
  43. package/out/renderer/assets/{index-AGCqaeOI.js → index-FsaxlHdZ.js} +1 -1
  44. package/out/renderer/assets/index-ZovyVTxQ.css +1 -0
  45. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BprulvMk.js → infoDiagram-PH2N3AL5-pOK9P20l.js} +1 -1
  46. package/out/renderer/assets/{installer-muZhWyyS.js → installer-Dw1P6j8q.js} +1 -1
  47. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DfdLRQAF.js → journeyDiagram-U35MCT3I-D5Sg1JPA.js} +1 -1
  48. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-R6IsuYWB.js → kanban-definition-NDS4AKOZ-BfhWqBCl.js} +1 -1
  49. package/out/renderer/assets/{layout-05Xak_7z.js → layout-IqsTm240.js} +1 -1
  50. package/out/renderer/assets/{legacy-agents-page-Dpl33Kla.js → legacy-agents-page-bdH6oKjE.js} +5 -5
  51. package/out/renderer/assets/library-page-DDvrG_aA.js +157 -0
  52. package/out/renderer/assets/{mermaid.core-BzKfajYZ.js → mermaid.core-D0YPuNli.js} +5 -5
  53. package/out/renderer/assets/{mesh-page-D6ZzFOeG.js → mesh-page-DYFNof_0.js} +1 -1
  54. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dn_l0i7j.js → mindmap-definition-ALO5MXBD-Tx5iMDRU.js} +1 -1
  55. package/out/renderer/assets/{mini-BgJE9L7J.js → mini-BoZCnSK9.js} +1 -1
  56. package/out/renderer/assets/{notebook-pen-CtAKsfVm.js → notebook-pen-C3CwzwGA.js} +1 -1
  57. package/out/renderer/assets/{org-access-BHt55LAw.js → org-access-DoZK5gF3.js} +1 -1
  58. package/out/renderer/assets/{org-surface-gate-CqFJQYmV.js → org-surface-gate-Dy0B7mtt.js} +1 -1
  59. package/out/renderer/assets/{page-header-BlIvE-Ti.js → page-header-6mrV9W-E.js} +1 -1
  60. package/out/renderer/assets/path-utils-CRYGE4mK.js +58 -0
  61. package/out/renderer/assets/{pieDiagram-IB7DONF6-_W_OzAAk.js → pieDiagram-IB7DONF6-D0rED3_3.js} +1 -1
  62. package/out/renderer/assets/{projects-page-DtZ_g9gZ.js → projects-page-D7j1GOvI.js} +1 -1
  63. package/out/renderer/assets/{publication-validation-D7f3xAgF.js → publication-validation-CLbFS0n9.js} +1 -1
  64. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-FQ5Wvxqm.js → quadrantDiagram-7GDLP6J5-D8jKSQt5.js} +1 -1
  65. package/out/renderer/assets/{radar-MK3ICKWK-BRufXucA.js → radar-MK3ICKWK-Co2EJbaJ.js} +1 -1
  66. package/out/renderer/assets/{radient-auth-buttons-7i7blC-7.js → radient-auth-buttons-B11cdRmS.js} +1 -1
  67. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CHO8Cq1H.js → requirementDiagram-KVF5MWMF-BI13h11j.js} +1 -1
  68. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-C4JDJOwX.js → sankeyDiagram-QLVOVGJD-D4hZ6_ML.js} +1 -1
  69. package/out/renderer/assets/{schedules-page-6tPgFgS_.js → schedules-page-DFfDDHYC.js} +1 -1
  70. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BFf3HnKw.js → sequenceDiagram-X6HHIX6F-U6CqBtco.js} +1 -1
  71. package/out/renderer/assets/{settings-page-CXOFCx8w.js → settings-page-CZ7NUDoe.js} +1 -1
  72. package/out/renderer/assets/{smartart-crAq3DvJ.js → smartart-BVm_cEaq.js} +1 -1
  73. package/out/renderer/assets/{stateDiagram-DGXRK772-BqFVSIKA.js → stateDiagram-DGXRK772-DBg11bkx.js} +1 -1
  74. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-jmaink9i.js +1 -0
  75. package/out/renderer/assets/team-bridge-page-u_OqiZGS.js +16 -0
  76. package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cp3uYUSs.js → timeline-definition-BDJGKUSR-WQ6aYia6.js} +1 -1
  77. package/out/renderer/assets/{use-download-agent-mutation-C_W8yx0C.js → use-download-agent-mutation-ZoivWizY.js} +2 -2
  78. package/out/renderer/assets/{use-session-snapshot-vFZD5qIO.js → use-session-snapshot-CdYiirKJ.js} +1 -1
  79. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DFcICu1Q.js → xychartDiagram-VJFVF3MP-f11BpHer.js} +1 -1
  80. package/out/renderer/console-capture.html +5 -5
  81. package/out/renderer/index.html +7 -7
  82. package/out/renderer/installer.html +4 -4
  83. package/out/renderer/mini.html +7 -7
  84. package/package.json +4 -3
  85. package/out/renderer/assets/browser-page-BfJd3-qS.js +0 -1
  86. package/out/renderer/assets/channel-BFAjMbH6.js +0 -1
  87. package/out/renderer/assets/classDiagram-GIVACNV2-CmW0Ezdi.js +0 -1
  88. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CmW0Ezdi.js +0 -1
  89. package/out/renderer/assets/clone-B_pc7cSP.js +0 -1
  90. package/out/renderer/assets/hash--PQTQMu2.js +0 -6
  91. package/out/renderer/assets/index-ALGblIL0.css +0 -1
  92. package/out/renderer/assets/index-BYeiLB51.js +0 -57
  93. package/out/renderer/assets/library-page-BNrffbLi.js +0 -157
  94. package/out/renderer/assets/path-utils-CYBk4q7C.js +0 -58
  95. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-aaVC-oiG.js +0 -1
  96. package/out/renderer/assets/team-bridge-page-BgjJrT3v.js +0 -26
@@ -1,6 +1,6 @@
1
- import{r,j as e,c as U,t as l}from"./index-BYeiLB51.js";import{E as zs,D as yt,l as ce,u as ie,a as Ce,c as re,r as es,d as fe,a3 as ps,j as ss,a2 as vt,O as Nt}from"./path-utils-CYBk4q7C.js";import{P as wt}from"./page-header-BlIvE-Ti.js";import{c as St,l as le,B as P,k as C,u as ke,y as _t,I as Ie,T as Ms,D as qe,a as Ue,b as He,d as Be,e as Ke,f as Qe,A as be,m as pe,n as ge,Y as Pt,Z as Tt,_ as Ct,$ as It,F as gs,G as fs,H as ks,J as js,K as ys}from"./error-boundary-DJSaJHcb.js";import{ao as ts,as as vs,be as Rt,bf as Ds,a4 as G,ap as je,bc as qs,bg as At,aq as Et,bh as Ot,P as Us,aw as Hs,bi as Se,bj as Lt,bk as Ft}from"./conversation-input-sync-C2vqs6ad.js";import{a as $t,p as Bs,P as Ks,u as zt}from"./publication-validation-D7f3xAgF.js";import{h as ae,O as Mt,A as Dt,d as qt,a as Ut,b as Ht,c as Bt,e as Qs,C as Kt,f as Qt,n as Vt,u as Wt,i as Yt}from"./use-download-agent-mutation-C_W8yx0C.js";import{H as Gt}from"./heart-CVGkdUzT.js";import{z as Jt,aP as Xt,aO as Zt,aQ as Vs,aR as Ws,aS as Ys,aT as ea,aU as sa,aK as as,aV as Ge,aD as ta,aB as Gs,aW as aa,az as ia,u as na,h as la,c as Ns,aI as ra,d as ca,H as oa,aX as da,x as ua,aY as ma}from"./index-D8L83jtw.js";import{n as ha,i as xa,H as ba,p as ws,a as pa,o as Js,u as ga}from"./org-access-BHt55LAw.js";import{R as Xs}from"./radient-auth-buttons-7i7blC-7.js";import{f as fa}from"./format-esAOn2VS.js";import{o as ka,a as Ve}from"./org-surface-gate-CqFJQYmV.js";import{B as ja}from"./building-2-C_YBTC7O.js";import"./en-US-CHJkXXr4.js";import"./book-open-Cb4F-cRs.js";import"./console-mirror-DPVG6sWK.js";/**
1
+ import{r,j as e,c as U,t as l}from"./index-BDzV3bGH.js";import{z as zs,D as yt,h as ce,u as ie,a as Ce,c as re,r as es,d as fe,$ as ps,f as ss,Z as vt,K as Nt}from"./path-utils-CRYGE4mK.js";import{P as wt}from"./page-header-6mrV9W-E.js";import{c as St,l as le,B as P,k as C,u as ke,y as _t,I as Ie,T as Ms,D as qe,a as Ue,b as He,d as Be,e as Ke,f as Qe,A as be,m as pe,n as ge,Y as Pt,Z as Tt,_ as Ct,a3 as It,F as gs,G as fs,H as ks,J as js,K as ys}from"./error-boundary-ZYkSCpZC.js";import{ao as ts,as as vs,bk as Rt,bl as Ds,a4 as G,ap as je,bc as qs,bm as At,aq as Lt,bn as Ot,P as Us,aw as Hs,bo as Se,bp as Et,bq as Ft}from"./conversation-input-sync-MZPvyAzc.js";import{a as $t,p as Bs,P as Ks,u as zt}from"./publication-validation-CLbFS0n9.js";import{h as ae,O as Mt,A as Dt,d as qt,a as Ut,b as Ht,c as Bt,e as Qs,C as Kt,f as Qt,n as Vt,u as Wt,i as Yt}from"./use-download-agent-mutation-ZoivWizY.js";import{H as Gt}from"./heart-tKYqMVIH.js";import{z as Jt,bH as Zt,aO as Xt,bI as Vs,bJ as Ws,bK as Ys,bL as ea,bM as sa,aK as as,bN as Ge,aD as ta,aB as Gs,bO as aa,az as ia,u as na,h as la,c as Ns,aI as ra,d as ca,H as oa,bP as da,x as ua,bQ as ma}from"./index-DknTGnAk.js";import{n as ha,i as xa,H as ba,p as ws,a as pa,o as Js,u as ga}from"./org-access-DoZK5gF3.js";import{R as Zs}from"./radient-auth-buttons-B11cdRmS.js";import{f as fa}from"./format-esAOn2VS.js";import{o as ka,a as Ve}from"./org-surface-gate-Dy0B7mtt.js";import{B as ja}from"./building-2-Bpz1qaDa.js";import"./en-US-CHJkXXr4.js";import"./book-open-C1uak1LZ.js";import"./console-mirror-Bxl6t4e9.js";/**
2
2
  * @license lucide-react v0.507.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ya=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=St("circle-ellipsis",ya),Na=({agent:s,isLiked:t,isFavourited:a,onLikeToggle:i,onFavouriteToggle:n,onDownload:u,isLikeActionLoading:m=!1,isFavouriteActionLoading:O=!1,isDownloading:p=!1,actionError:v=null,onRetryAction:L,showActions:_=!0,viewerStateKnown:b=!0,orgName:h=null})=>{const E=zs(),{isAuthenticated:f}=ts(),w=s.description??"",[I,F]=r.useState(!1),T=r.useRef(null),g=r.useCallback(A=>{if(T.current?.disconnect(),T.current=null,!A)return;const z=()=>F(A.scrollHeight-A.clientHeight>1);z();const H=new ResizeObserver(z);H.observe(A),T.current=H},[]),R=f?b?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",k=f?b?a?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",j=b?t?"Unlike agent":"Like agent":"Like state unavailable",y=b?a?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",o=s.visibility==="org",x=ae(s.name);return e.jsxs("div",{"data-glass-block":"",className:"flex h-full flex-col overflow-hidden rounded-md bg-surface transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("button",{type:"button",onClick:()=>E(`/agent-hub/${s.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${x}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:x}),o&&e.jsx(Mt,{orgName:h}),e.jsx(le,{content:I?w:"",children:e.jsx("span",{ref:g,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:w})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(Dt,{tags:s.tags,categories:s.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[s.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",qt(new Date(s.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":o?"org":f?b?"known":"unknown":"signed-out",children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx(le,{content:R,children:e.jsx("span",{children:e.jsxs(P,{variant:"ghost",size:"sm",onClick:f&&b?()=>i(s.id):void 0,disabled:m||!f||!b,"aria-label":j,className:U(t&&"text-danger"),children:[e.jsx(Gt,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.like_count??0})]})})}),e.jsx(le,{content:k,children:e.jsx("span",{children:e.jsxs(P,{variant:"ghost",size:"sm",onClick:f?()=>n(s.id):void 0,disabled:O||!f||!b,"aria-label":y,className:U(a&&"text-warning"),children:[e.jsx(Jt,{fill:a?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.favourite_count??0})]})})})]}),e.jsx(le,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(vs,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:p?e.jsx(C,{className:"h-3 w-6"}):(s.download_count??0).toLocaleString()})]})})]}),_&&u&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(P,{variant:"secondary",size:"sm",onClick:()=>u(s),disabled:p,"aria-label":`Download ${x}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(vs,{"data-testid":"agent-download"}),"Get"]})})]}),v&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:v}),L&&e.jsx(P,{variant:"ghost",size:"sm",onClick:L,children:"Try again"})]})]})},wa=({agent:s,status:t,viewerStateKnown:a=!0,orgName:i=null})=>{const{isAuthenticated:n}=ts(),[u,m]=r.useState(null),O=t?.liked??!1,p=t?.favourited??!1,v=Ut(),L=Ht(),_=Bt(),b=()=>{!n||v.isPending||(m(null),v.mutate({agentId:s.id,isCurrentlyLiked:O},{onError:()=>m("like")}))},h=()=>{!n||L.isPending||(m(null),L.mutate({agentId:s.id,isCurrentlyFavourited:p},{onError:()=>m("favourite")}))},E=()=>{_.isPending||(m(null),_.mutate({agentId:s.id,agentName:s.name},{onError:()=>m("download")}))},f=u?u==="like"?{action:"like",error:v.error,retry:b}:u==="favourite"?{action:"favourite",error:L.error,retry:h}:{action:"download",error:_.error,retry:E}:null;return e.jsx(Na,{agent:s,isLiked:n&&O,isFavourited:n&&p,onLikeToggle:b,onFavouriteToggle:h,onDownload:E,isLikeActionLoading:v.isPending,isFavouriteActionLoading:L.isPending,isDownloading:_.isPending,viewerStateKnown:a,orgName:i,actionError:f?$t(f.action,f.error,ae(s.name)):null,onRetryAction:f?.retry})},Ss=({selected:s,onClick:t,children:a,...i})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":s,className:U("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",s?Zt:"text-ink hover:bg-row-hover"),...i,children:a}),_s=Object.keys(Kt),Sa=s=>[...s].sort((t,a)=>{const i=_s.indexOf(t),n=_s.indexOf(a);return i!==-1&&n!==-1?i-n:i!==-1?-1:n!==-1?1:t.localeCompare(a)}),_a=({selectedCategory:s,onSelectCategory:t,categories:a})=>{ke();const i=Sa(s&&!a.includes(s)?[...a,s]:a);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:l("ui.hub.taxonomy.heading")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(Ss,{selected:s===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Xt,{size:16,"aria-hidden":"true"})}),l("ui.hub.taxonomy.all")]}),i.map(n=>{const u=Qs(n),m=n==="other"?e.jsx(va,{size:16}):u.icon;return e.jsxs(Ss,{selected:s===n,onClick:()=>t(n),"data-testid":`category-${n}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:m}),u.label]},n)})]})]})},is=({page:s,count:t,onChange:a,ariaLabel:i="Agent pages"})=>{const n=r.useRef(null),u=r.useRef(null),m=r.useRef(null);return r.useEffect(()=>{const O=m.current;m.current=null,O==="previous"&&n.current?.focus(),O==="next"&&u.current?.focus()},[s]),t<=1?null:e.jsxs("nav",{"aria-label":i,className:"mt-6 flex min-h-13 items-center justify-between gap-3 border-t border-hairline","data-testid":"agent-hub-pager",children:[e.jsxs("span",{className:"select-none text-meta text-ink-dim",children:["Page ",s," of ",t]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(P,{variant:"secondary",size:"sm",ref:n,onClick:()=>{s-1<=1&&(m.current="next"),a(s-1)},disabled:s<=1,"aria-label":"Previous page",children:[e.jsx(Rt,{"aria-hidden":"true"}),"Previous"]}),e.jsxs(P,{variant:"secondary",size:"sm",ref:u,onClick:()=>{s+1>=t&&(m.current="previous"),a(s+1)},disabled:s>=t,"aria-label":"Next page",children:["Next",e.jsx(_t,{"aria-hidden":"true"})]})]})]})},Pa=/alias/i;function Ps(s){return s instanceof yt?s.code==="alias-occupied"?!0:s.code==="origin-conflict"&&Pa.test(s.message):!1}const Ta=/\/+$/;function ns(s){const t=s.replace(Ta,"");try{const{pathname:a}=new URL(t);return a===""||a==="/"?`${t}/v1`:t}catch{return`${t}/v1`}}const Ts=s=>s?.skills===1&&s.revision_cas===1;function Ca(s,t=1,a=20){const i=new URL(Vs(s,"skills"));return i.searchParams.set("page",String(t)),i.searchParams.set("per_page",String(a)),Ws(i.toString())}function Ia(s,t){return Ws(Vs(s,"skills",t))}function Ra(s){return Ds({operation:"org_skills.list",tenantId:s})}function Aa(s,t){return Ds({operation:"org_skill.get",tenantId:s,skillId:t})}const ls=12,_e={all:["public-teams"],list:(s,t)=>[..._e.all,"list",{page:s,perPage:t}],detail:s=>[..._e.all,"detail",s]},Re=(s,t)=>t instanceof Ys?t.status===null?!1:t.status>=500&&s<1:s<1,Zs=({page:s=1,perPage:t=ls,enabled:a=!0}={})=>{const i=ce({queryKey:_e.list(s,t),queryFn:()=>ea(G.radientBaseUrl,s,t),select:n=>n.result,enabled:a,retry:Re,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,placeholderData:n=>n});return{...i,teams:i.data?.records??[],isRefreshing:i.isFetching&&i.data!==void 0,pagination:i.data?{page:i.data.page,perPage:i.data.per_page,totalPages:i.data.total_pages,totalRecords:i.data.total_records}:void 0}},Ea=({teamId:s,enabled:t=!0})=>{const a=ce({queryKey:_e.detail(s??""),queryFn:()=>sa(G.radientBaseUrl,s),select:i=>i.result,enabled:t&&!!s,retry:Re,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1});return{...a,team:a.data}};function oe(s){if(s.getQueryState(ps.capabilities)?.status!=="success"||!re(s.getQueryData(ps.capabilities),"hub_skills"))throw new Error("This backend does not support the complete Hub Skills adapter.")}function et(s,t,a){const i=ie(),n=Ce();return ce({queryKey:["hub-skills",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:a&&!n.isError&&re(n.data,"hub_skills"),queryFn:async()=>{if(oe(i),s.visibility==="org"){const m=(await Ra(s.tenantId)).result;return{rows:m.skills,pages:1,total:m.skills.length,contract:m.sync_contract}}const u=(await Ca(G.radientBaseUrl,t,20)).result;return{rows:u.records,pages:u.total_pages,total:u.total_records,contract:u.sync_contract}},staleTime:3e4,retry:s.visibility==="org"?es:Re,retryOnMount:!1,refetchOnWindowFocus:!1})}function Oa(s,t,a){const i=ie(),n=Ce();return ce({queryKey:["hub-skill",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:a&&t!==null&&!n.isError&&re(n.data,"hub_skills"),queryFn:async()=>(oe(i),(s.visibility==="org"?await Aa(s.tenantId,t):await Ia(G.radientBaseUrl,t)).result),staleTime:3e4,retry:s.visibility==="org"?es:Re,retryOnMount:!1})}function rs(s,t){s.setQueryData(as,t.links)}function cs(s){s.invalidateQueries({queryKey:as}),s.invalidateQueries({queryKey:["desktop","skills"]})}function La(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillPull",requestId:t.requestId,hubId:t.remoteId,hubSource:ns(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias,subscribe:t.subscribe,autoPush:t.autoPush,confirmPublicEgress:t.consent})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function Fa(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillSubscribe",requestId:t.requestId,hubId:t.remoteId,hubSource:ns(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function $a(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillUnpull",requestId:t.requestId,linkId:t.linkId})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function za(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillPublish",requestId:t.requestId,...t.draft,dryRun:t.previewReceipt===void 0,...t.previewReceipt?{previewReceipt:t.previewReceipt,confirmPublish:!0}:{}})),onSuccess:t=>{t.local_link_receipt?.state==="complete"&&(s.invalidateQueries({queryKey:as}),s.invalidateQueries({queryKey:["desktop","skills"]}),s.invalidateQueries({queryKey:["hub-skills"]}))}})}const Ma=/\/+$/;function Cs(s){return s.replace(Ma,"")}function Da(s,t){return t.visibility==="public"?s.visibility==="public"&&!s.tenant_id:s.visibility==="org"&&s.tenant_id===t.tenantId}function Je(s){const t=s.id??s.hub_id??"",a=s.tenantId??s.tenant_id??"";return`${t}\0${s.visibility}\0${a}`}function qa(s,t){const a=Cs(t),i=new Map;for(const n of s??[])n.kind==="skill"&&Cs(n.hub_source)===a&&i.set(Je({hub_id:n.hub_id,visibility:n.visibility,tenantId:n.tenant_id}),n);return i}function Is(s,t,a=!0){if(!a)return{kind:"unknown"};if(!s)return{kind:"not-present"};const i=Ge(s);return i==="present"&&(s.pull.state==="available"||t?.state==="available"&&!t.error_class)?{kind:"update",link:s,automatic:t?.auto_will_apply===!0||s.auto_will_apply}:i==="absent"?s.policy.subscribe?{kind:"subscribed",link:s}:{kind:"detached",link:s}:s.policy.subscribe?{kind:"pulled",link:s}:{kind:"manual",link:s}}function Ua(s){return s?"policy":"create"}function Ha(s){return JSON.stringify({op:"pull",selected:s.selected,scope:s.scope,localAlias:s.localAlias,subscribe:s.subscribe,autoPush:s.autoPush,consent:s.consent})}function Ba({scope:s,source:t,verifiedCas:a,enabled:i=!0,heading:n=!0}){ke();const u=r.useId(),[m,O]=r.useState(""),[p,v]=r.useState(""),[L,_]=r.useState(ha),[b,h]=r.useState(null),[E,f]=r.useState(!1),w=za(),I=r.useRef(null),F=ce({queryKey:["desktop","skills","hub-publication"],queryFn:()=>fe({op:"skills.list"}),staleTime:3e4,retry:!1}),T=`${s.visibility}:${s.tenantId??""}`,g=r.useRef(T);r.useEffect(()=>{g.current!==T&&(g.current=T,_(y=>({...y,autoPush:!1,confirmPublicEgress:!1})),h(null),f(!0))},[T]);const R={sourceSkill:m,localAlias:p,visibility:s.visibility,tenantId:s.tenantId,...L},k=b?xa(b,R):!1;r.useEffect(()=>{if(!b)return;const y=setTimeout(()=>{h(null),f(!0)},Math.max(0,Math.min(Date.parse(b.expires_at)-Date.now(),2147483647)));return()=>clearTimeout(y)},[b]);const j=y=>{if(!i||w.isPending||!m||!p||y&&!k)return;const o=JSON.stringify({draft:R,receipt:y?b?.preview_receipt:null}),x=I.current&&I.current.tuple===o&&(y||w.error)?I.current:{tuple:o,id:crypto.randomUUID()};I.current=x,y||(h(null),f(!1)),w.mutate({requestId:x.id,draft:R,...y&&b?{previewReceipt:b.preview_receipt}:{}},{onSuccess:A=>{A.preview?(h(A.preview),f(!1)):ws(A)&&h(null)}})};return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skill-publication":!0,children:[n&&e.jsx("h3",{className:"text-heading text-ink",children:l("ui.hub.skills.publish_title")}),e.jsx("label",{htmlFor:`${u}-source`,className:"text-body-sm text-ink",children:l("ui.hub.skills.select_authored")}),e.jsxs("select",{id:`${u}-source`,"data-testid":"hub-skill-publish-source",value:m,disabled:w.isPending||!i,className:"rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink",onChange:y=>{O(y.target.value),v(y.target.value),h(null),_(o=>({...o,autoPush:!1,confirmPublicEgress:!1}))},children:[e.jsx("option",{value:"",children:l("ui.hub.skills.select_authored")}),F.data?.data.skills.map(y=>e.jsx("option",{value:y.name,children:y.name},y.name))]}),e.jsx("label",{htmlFor:`${u}-alias`,className:"text-body-sm text-ink",children:l("ui.hub.subscriptions.alias")}),e.jsx(Ie,{id:`${u}-alias`,"data-testid":"hub-skill-publish-alias",value:p,disabled:w.isPending||!i,onChange:y=>{v(y.target.value),_(o=>({...o,autoPush:!1,confirmPublicEgress:!1}))}}),e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.text_limits")}),e.jsx(ba,{value:L,onChange:_,source:t,item:m||p,visibility:s.visibility,organization:s.organization,destinationKey:`${T}:${m}`,canEnableAutoPush:a,disabled:w.isPending||!i}),F.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.loading")}),F.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:l("ui.hub.status.other_error")}),w.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:l("ui.hub.links.action_failed",{direction:l("ui.hub.links.direction_push"),item:m||p,source:t})}),(E||b&&!k&&b.can_confirm)&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.links.preview_changed")}),b&&b.visibility===s.visibility&&b.tenant_id===s.tenantId&&e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("h4",{className:"text-body-sm text-ink",children:l("ui.hub.links.preview_payload",{source:t})}),e.jsx(Ms,{readOnly:!0,rows:12,"aria-label":l("ui.hub.links.preview_payload",{source:t}),value:JSON.stringify(b.proposal.fields,null,2),className:"max-h-96 bg-sunken text-mono-sm"}),b.warnings.map((y,o)=>e.jsx("p",{className:"break-words text-body-sm text-warning",children:y},`${o}-${y}`)),b.reason&&e.jsx("p",{className:"text-body-sm text-warning",children:ta(b.reason)})]}),w.data?.publication===null&&w.data.local_link_receipt?.state==="pending-reconciliation"&&e.jsx("output",{className:"text-body-sm text-warning","data-testid":"hub-skill-pending-reconcile",children:l("ui.hub.links.publication_pending")}),w.data?.publication&&e.jsx("output",{className:"text-body-sm text-ink","data-testid":"hub-skill-published",children:ws(w.data)?l("ui.hub.links.published",{item:w.data.link?.name??p,source:w.data.link?Gs(w.data.link):t}):l("ui.hub.skills.policy_pending")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline","data-testid":"hub-skill-publish-preview",disabled:!i||w.isPending||!m||!p,onClick:()=>j(!1),children:l("ui.hub.subscriptions.preview_publish")}),e.jsx(P,{"data-testid":"hub-skill-publish-confirm",disabled:!i||w.isPending||!k,onClick:()=>j(!0),children:l("ui.hub.links.confirm_publish")})]})]})}const Ka={available:"text-accent",applied:"text-success",failed:"text-danger",review:"text-warning",updating:"text-ink-muted"},Qa={available:"ui.hub.skills.update_available",applied:"ui.hub.skills.update_applied",failed:"ui.hub.skills.update_failed",review:"ui.hub.links.mark_review",updating:"ui.hub.links.mark_busy"},Va={"not-present":"ui.hub.skills.not_downloaded",subscribed:"ui.hub.skills.subscribed_absent",pulled:"ui.hub.skills.pulled",manual:"ui.hub.skills.manual",detached:"ui.hub.skills.detached"};function Rs(s,t,a){const i=t?ca(t):null;return i&&(s.kind==="update"||a&&(t?.state==="applied"||t?.state==="failed"||t?.error_class))?i:s.kind==="update"?{kind:"available",auto:s.automatic}:null}function As(s,t){return s.kind==="unknown"?t:s.kind!=="update"?l(Va[s.kind]):l(s.link.policy.subscribe?"ui.hub.skills.pulled":"ui.hub.skills.manual")}function Es({mark:s}){return ke(),s?e.jsxs("span",{"data-hub-mark-state":s.kind,className:U("flex shrink-0 items-center gap-1 text-meta",Ka[s.kind]),children:[e.jsx(oa,{mark:s}),e.jsx("span",{children:l(Qa[s.kind])})]}):null}function Os(s,t){const a=s.publisher?.trim();return a?l("ui.hub.skills.published_by",{publisher:a}):s.visibility==="org"?t??l("ui.hub.links.source_unavailable"):l("ui.hub.skills.public_hub")}function Wa({scope:s,signedIn:t,accessible:a=!0}){ke();const i=r.useId(),[n,u]=r.useState(1),[m,O]=r.useState(""),[p,v]=r.useState(null),[L,_]=r.useState(!1),[b,h]=r.useState("unsubscribe"),[E,f]=r.useState(!1),w=r.useRef(null),I=s.visibility==="public"?l("ui.hub.links.source_public"):s.organization?l("ui.hub.links.source_private",{organization:s.organization}):l("ui.hub.links.source_unavailable"),F=Ce(),T=a&&re(F.data,"hub_updates"),g=et(s,n,a&&(s.visibility==="public"||t)),R=Ts(g.data?.contract),k=Oa(s,p,R&&a),j=La(),y=Fa(),o=$a(),x=aa(),A=ia(a&&re(F.data,"hub_links")),z=na(T),H=r.useMemo(()=>qa(A.data?.links,ns(G.radientBaseUrl)),[A.data]),M=r.useMemo(()=>la(z.data),[z.data]),q=j.data?.link?.link_id,N=!A.isLoading&&!A.error,D=A.error?l("ui.hub.skills.inventory_unknown"):l("ui.hub.links.loading"),se=k.data?.visibility===s.visibility&&(s.visibility==="public"?!k.data.tenant_id:k.data.tenant_id===s.tenantId),te=a&&!k.error&&!g.error&&se&&Ts(k.data?.sync_contract)&&!!k.data?.revision,de=(g.data?.rows??[]).filter(d=>Da(d,s)),ye=de.filter(d=>`${d.name} ${d.description}`.toLocaleLowerCase().includes(m.toLocaleLowerCase())),Q=de.find(d=>d.id===p),S=Q?H.get(Je({id:Q.id,visibility:Q.visibility,tenantId:Q.tenant_id??null})):void 0,ve=S?M.get(Ns("skill",S.name)):void 0,ue=Is(S,ve,N),ee=S?Ge(S)==="present":!1,Ae=d=>{const $=H.get(Je({id:d.id,visibility:d.visibility,tenantId:d.tenant_id??null})),X=$?M.get(Ns("skill",$.name)):void 0;return{link:$,update:X,state:Is($,X,N)}},me=d=>(w.current?.tuple!==d&&(w.current={tuple:d,id:crypto.randomUUID()}),w.current.id),ne=d=>{if(!p||!te||!t)return;const $=d?.name??Q?.name??"";if(!$)return;const X=d?d.policy.subscribe:!1,xe=d?.policy.auto_push??!1,Ne=!1;j.mutate({requestId:me(Ha({selected:p,scope:s,localAlias:$,subscribe:X,autoPush:xe,consent:Ne})),remoteId:p,scope:s,alias:$,subscribe:X,autoPush:xe,consent:Ne})},Ee=()=>{if(!p||!te||!t)return;if(Ua(S)==="policy"&&S){if(S.policy.subscribe||x.isPending)return;h("subscribe"),x.mutate({link:S,patch:{subscribe:!0}});return}const d=Q?.name??"";d&&y.mutate({requestId:me(JSON.stringify({op:"subscribe",selected:p,scope:s,localAlias:d})),remoteId:p,scope:s,alias:d})},Oe=()=>{S&&o.mutate({requestId:me(JSON.stringify({op:"unpull",link:S.link_id})),linkId:S.link_id},{onSuccess:()=>{j.reset(),y.reset()}})},V=()=>{!S||S.policy.subscribe===!1||x.isPending||!x.canWrite||(h("unsubscribe"),x.mutate({link:S,patch:{subscribe:!1}}))},J=t&&R&&a&&!g.error,he=g.data?.total??de.length,B=g.error?null:g.isLoading?l("ui.hub.skills.loading"):s.organization?l("ui.hub.skills.count_shared",{count:he,organization:s.organization}):l("ui.hub.skills.count",{count:he});return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skills-library":!0,children:[s.visibility==="org"&&!t?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.no_credential")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:U("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(qs,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ie,{id:`${i}-search`,type:"search","data-testid":"hub-skill-search",value:m,placeholder:l("ui.hub.skills.search"),"aria-label":l("ui.hub.skills.search"),onChange:d=>O(d.target.value),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none"})]}),J&&e.jsx(P,{variant:"secondary","data-testid":"hub-skill-publish-open",onClick:()=>f(!0),children:l("ui.hub.skills.publish_title")})]}),B!==null&&e.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-dim","data-testid":"hub-skill-status",children:s.organization||g.isLoading?e.jsx("span",{"data-testid":"hub-skill-source",children:B}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:B})," · ",e.jsx("span",{"data-testid":"hub-skill-source",children:l("ui.hub.skills.public_hub")})]})}),g.error&&e.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-body-sm text-warning",children:[e.jsx("p",{children:l("ui.hub.skills.catalogue_failed",{source:I})}),e.jsx(P,{variant:"outline",className:"self-start",disabled:g.isFetching,onClick:()=>void g.refetch(),children:l("ui.hub.links.retry")})]}),g.isSuccess&&!R&&e.jsx("p",{className:"text-body-sm text-warning",children:l("ui.hub.skills.unavailable")}),R&&e.jsxs(e.Fragment,{children:[ye.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:l(m?"ui.hub.skills.search_empty":"ui.hub.skills.remote_empty")}),e.jsx("ul",{className:"grid list-none grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6 p-0",children:ye.map(d=>{const $=Ae(d),X=Rs($.state,$.update,$.link?Ge($.link)==="present":!1);return e.jsx("li",{className:"min-w-0",children:e.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p===d.id,"aria-label":l("ui.hub.skills.open_detail",{item:d.name}),"data-testid":"hub-skill-open","data-skill-id":d.id,"data-skill-state":$.state.kind,onClick:()=>{v(d.id),j.reset(),y.reset(),o.reset(),x.reset()},className:U("flex h-full w-full flex-col overflow-hidden rounded-md bg-surface text-left","transition-colors duration-fast ease-out-quart hover:bg-elevated","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-1"),children:[e.jsxs("span",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx("span",{className:"truncate font-medium text-heading text-ink",children:d.name}),d.description?e.jsx("span",{className:"line-clamp-3 text-body-sm text-ink-muted",children:d.description}):null,e.jsx("span",{className:"mt-auto truncate text-ink-dim text-meta",children:Os(d,s.organization)})]}),e.jsxs("span",{className:"flex items-center justify-between gap-2 border-t border-hairline px-4 py-2 text-meta",children:[e.jsx("span",{className:"truncate text-ink-muted",children:As($.state,D)}),e.jsx(Es,{mark:X})]})]})},d.id)})}),e.jsx(is,{page:n,count:g.data?.pages??1,onChange:u,ariaLabel:l("ui.hub.skills.title")})]})]}),!a&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.access_lost")}),e.jsx(qe,{open:!!p&&R,onOpenChange:d=>{d||v(null)},children:e.jsxs(Ue,{"data-hub-skill-detail":"",className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(He,{children:[e.jsx(Be,{"data-testid":"hub-skill-detail-name",children:k.data?.name??Q?.name??l("ui.hub.skills.title")}),e.jsx(Ke,{children:k.data&&se?Os(k.data,s.organization):I})]}),k.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.loading")}),k.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.other_error")}),k.data&&se&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-body-sm text-ink-muted",children:[As(ue,D),e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),l("ui.hub.skills.revision",{revision:String(k.data.content_revision)})]}),e.jsx(Es,{mark:Rs(ue,ve,ee)})]}),e.jsx("p",{"data-testid":"hub-skill-description",className:"max-w-3xl select-text whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:k.data.description}),S&&ee&&S.local_path&&e.jsx("p",{"data-testid":"hub-skill-local-path",className:"break-words font-mono text-meta text-ink-dim",children:l("ui.hub.skills.local_path",{path:`⁨${S.local_path}⁩`})}),e.jsx("h4",{className:"text-body-sm text-ink",children:l("ui.hub.skills.files")}),e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.file_count",{count:k.data.files.length})}),k.data.files.map(d=>e.jsxs("details",{className:"min-w-0",children:[e.jsx("summary",{className:"break-words text-mono-sm text-ink",children:d.path}),e.jsx(Ms,{readOnly:!0,rows:12,"aria-label":d.path,value:d.content,className:"max-h-96 bg-sunken text-mono-sm"})]},d.path)),S&&e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-3",children:[e.jsx(ra,{link:S}),S.policy.subscribe&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"sm","data-testid":"hub-skill-unsubscribe",disabled:x.isPending||!x.canWrite,onClick:V,children:l("ui.hub.skills.unsubscribe")}),e.jsx("span",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.unsubscribe_help")})]}),x.error&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:l("ui.hub.subscriptions.save_failed",{setting:b==="subscribe"?l("ui.hub.subscriptions.subscribe"):l("ui.hub.skills.unsubscribe"),source:I})})]}),S&&ee&&e.jsx(pa,{kind:"skill",name:S.name,enabled:T}),j.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:l(Ps(j.error)?"ui.hub.skills.local_exists":"ui.hub.skills.pull_failed")}),j.data&&!j.data.reports?.some(d=>d.applied||d.outcome==="unchanged")&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:l("ui.hub.skills.pull_failed")}),j.data?.link&&j.data.reports?.some(d=>d.link_id===q&&d.direction==="pull"&&d.applied)&&e.jsx("output",{"data-testid":"hub-skill-installed",className:"text-body-sm text-ink",children:l("ui.hub.skills.installed_alias",{item:j.data.link.name,source:Gs(j.data.link)})}),o.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-unpull-failed",children:l("ui.hub.skills.unpull_failed")}),y.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-subscribe-failed",children:l(Ps(y.error)?"ui.hub.skills.local_exists":"ui.hub.skills.subscribe_failed")}),!t&&e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.status.no_credential")}),(!S||!ee)&&e.jsxs(Qe,{className:"flex-row flex-wrap justify-start gap-2",children:[e.jsx(P,{"data-testid":"hub-skill-download",disabled:!t||!te||j.isPending||!N,"aria-label":l("ui.hub.skills.pull_title",{item:k.data.name,source:I}),onClick:()=>ne(S),children:l("ui.hub.skills.download")}),!S?.policy.subscribe&&e.jsx(P,{variant:"outline","data-testid":"hub-skill-subscribe",disabled:!t||!te||!N||y.isPending||x.isPending||(S?!x.canWrite:!1),onClick:Ee,children:l("ui.hub.subscriptions.subscribe")})]}),S&&ee&&e.jsx(Qe,{className:"flex-row flex-wrap justify-start gap-2",children:e.jsx(P,{variant:"outline","data-testid":"hub-skill-unpull",disabled:o.isPending,onClick:()=>{o.reset(),_(!0)},children:l("ui.hub.skills.unpull")})}),(!S||!ee)&&e.jsx("p",{className:"text-meta text-ink-muted",children:S?.policy.subscribe?l("ui.hub.skills.download_help"):l("ui.hub.skills.subscribe_help")})]})]})}),e.jsx(qe,{open:L,onOpenChange:d=>{d||_(!1)},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(He,{children:[e.jsx(Be,{children:l("ui.hub.skills.unpull_title",{item:k.data?.name??S?.name??""})}),e.jsx(Ke,{children:l("ui.hub.skills.unpull_body")})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"outline",onClick:()=>_(!1),children:l("ui.hub.subscriptions.cancel")}),e.jsx(P,{"data-testid":"hub-skill-unpull-confirm",disabled:o.isPending,onClick:()=>{Oe(),_(!1)},children:l("ui.hub.skills.unpull")})]})]})}),e.jsx(qe,{open:E,onOpenChange:f,children:e.jsxs(Ue,{className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(He,{children:[e.jsx(Be,{children:l("ui.hub.skills.publish_title")}),e.jsx(Ke,{children:I})]}),e.jsx(Ba,{scope:s,source:I,verifiedCas:R&&a&&t,enabled:R&&a&&t,heading:!1})]})})]})}const st={all:["org-teams"],list:s=>[...st.all,"list",s]},tt=({tenantId:s,enabled:t=!0})=>{const a=ce({queryKey:st.list(s??""),queryFn:async()=>(await da(s)).result??{teams:[]},enabled:t&&!!s,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1,retry:es});return{...a,teams:a.data?.teams??[]}},Ya=(s,t)=>{const a=s?.name?.trim()||t?.trim()||"Team",i=s?.renamed_from?.trim()||null;return s?.invalid_name===!0&&i?{level:"warning",message:`Pulled "${a}". The published name "${i}" is not usable locally, so the team was stored as "${a}".`}:i?{level:"success",message:`Pulled "${a}" (you already have a team called "${i}").`}:{level:"success",message:`Pulled team "${a}".`}},at=()=>{const s=ie();return je({mutationFn:async({teamId:t,tenantId:a})=>{if(!G.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ot.pullOrgTeamFromRadient(G.baseUrl,t,a)},onSuccess:(t,a)=>{const i=Ya(t.result,a.name);i.level==="warning"?At(i.message):Et(i.message),s.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Ga=/^v/i,it=s=>s.members.reduce((t,a)=>t+a.count,0),Ja=s=>s.count>1?`${s.role} ×${s.count}`:s.role,Xe=s=>s.members.map(Ja).join(", "),nt=s=>{const t=(s.version??"").trim().replace(Ga,"").trim();return t===""?null:t},lt=s=>{const t=s.account_metadata?.name?.trim();return t||null},Xa=s=>{const t=(s.description??"").trim();return t===""?null:t},Ze=240,Za=Ze/2,ei=(s,t)=>{if(t||s.length<=Ze)return s;const a=s.slice(0,Ze),i=a.lastIndexOf(" ");return`${(i>=Za?a.slice(0,i):a).trimEnd()}…`},Pe=s=>fa(s,"d MMM yyyy"),Te=s=>{if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t},Ls=(s,t,a)=>{const i=a-t.getTime();let n;return i<0?n=Pe(t):i<6e4?n="just now":n=`${Qt(t,new Date(a))} ago`,{label:s,when:n,iso:t.toISOString(),exact:Pe(t)}},si=(s,t=Date.now())=>{const a=Te(s.updated_at);if(a)return Ls("updated",a,t);const i=Te(s.created_date);return i?Ls("created",i,t):null},ti=s=>{const t=Te(s.created_date),a=Te(s.updated_at);return{created:t?Pe(t):null,updated:a?Pe(a):null}},ai=s=>s==="role"?"Role":s==="specialist"?"Specialist":s,ii=["refresh-hub","retry","sign-in"],ni=({tenantId:s,orgName:t})=>{const{teams:a,isLoading:i,isFetching:n,isError:u,error:m,refetch:O}=tt({tenantId:s}),p=Js(m),v=at(),[L,_]=r.useState(null),[b,h]=r.useState(null),E=r.useRef(new Map),f=r.useRef(null);r.useEffect(()=>{v.isPending||f.current===null||(E.current.get(f.current)?.focus(),f.current=null)},[v.isPending]);const[w,I]=r.useState(!1),[F,T]=r.useState(()=>new Set),g=(o,x)=>T(A=>{const z=new Set(A);return x?z.add(o):z.delete(o),z}),R=(o,x)=>{o.key!=="Escape"||!F.has(x)||(o.target instanceof Element?o.target:null)?.closest('[data-testid="org-team-pull-error"]')||(g(x,!1),o.currentTarget.querySelector("button[aria-expanded]")?.focus(),o.preventDefault())},k=r.useMemo(()=>{if(!Us(v.error))return null;const o=a.find(x=>x.id===L);return Bs({code:v.error.code,message:v.error.message,details:v.error.details},{name:o?.name??"this team",hubAgentId:null,surface:"pull"})},[v.error,L,a]),j=(o,x)=>{switch(o){case"refresh-hub":O();break;case"retry":y(x);break;case"sign-in":I(!0);break}},y=o=>{v.isPending||(f.current=o.id,_(null),h(o.id),v.mutate({teamId:o.id,tenantId:s,name:o.name},{onSettled:()=>h(null),onError:()=>_(o.id)}))};return e.jsxs("section",{className:"mb-6 max-w-4xl rounded-md bg-surface","aria-label":`Teams shared with ${t??"this organization"}`,"data-testid":"org-teams",children:[i&&e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col divide-y divide-hairline","data-testid":"org-teams-loading",children:[e.jsx(We,{}),e.jsx(We,{}),e.jsx(We,{})]}),!i&&u&&e.jsxs(be,{variant:p?"warning":"danger",className:"m-4 w-auto","data-testid":"org-teams-error",children:[e.jsx(pe,{children:p==="plan"?"That organization needs an active Team plan":p==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(ge,{children:p==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:p==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:ss("The teams shared with this organization could not be read.",m)}),p!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void O(),disabled:n,"aria-busy":n,children:n?"Trying…":"Try again"})})]}),!i&&!u&&a.length===0&&e.jsx("p",{className:"p-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:`Teams shared into ${t??"this organization"} appear here for its members.`}),!i&&!u&&a.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:a.map(o=>e.jsxs("li",{className:U(rt,"transition-colors duration-fast ease-out-quart hover:bg-elevated first:rounded-t-md last:rounded-b-md"),onKeyDown:x=>R(x,o.id),children:[e.jsx(Hs,{className:"min-w-0",open:F.has(o.id),onOpenChange:x=>g(o.id,x),summaryAlign:"firstLine",triggerClassName:"min-w-0",chevronClassName:"text-ink-dim mt-1",rowClassName:"py-0",summary:e.jsx(ci,{team:o,expanded:F.has(o.id)}),trailing:e.jsx("div",{className:"-mt-1 ml-3 shrink-0 self-start",children:e.jsx(P,{ref:x=>{x?E.current.set(o.id,x):E.current.delete(o.id)},variant:"secondary",size:"sm",onClick:()=>y(o),disabled:v.isPending,"aria-label":`Pull team ${ae(o.name)}`,children:b===o.id?"Pulling…":"Pull"})}),children:e.jsx(oi,{team:o})}),L===o.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1 pl-5","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:k?.body??v.error?.message??`"${ae(o.name)}" could not be pulled.`}),k?.actions.filter(x=>ii.includes(x)).map(x=>e.jsx(P,{variant:"primary",size:"sm",onClick:()=>j(x,o),children:Ks[x]},x)),w&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(Xs,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{I(!1),_(null),O()}})})]})]},o.id))})]})},rt="px-4 py-3",ct=()=>e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),e.jsx("span",{className:"sr-only",children:", "})]}),li=({team:s})=>{const t=s.manager?.trim(),a=it(s);return e.jsxs("span",{className:"block truncate text-meta",children:[t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:"Manager:"})," ",e.jsx("span",{className:"text-ink-muted",children:t})]}):null,t?e.jsx(ct,{}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:"No members"}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-ink-dim",children:[a," ",a===1?"member":"members",":"]})," ",e.jsx("span",{className:"text-ink-muted",children:Xe(s)})]})]})},ri=({team:s})=>{const t=s.project?.trim(),a=lt(s),i=si(s),n=[];return t&&n.push({key:"project",node:t}),a&&n.push({key:"author",node:a}),i&&n.push({key:"recency",node:e.jsxs(e.Fragment,{children:[i.label," ",e.jsx(le,{content:i.exact,children:e.jsx("time",{dateTime:i.iso,children:i.when})})]})}),n.length===0?null:e.jsx("span",{className:"block truncate text-ink-dim text-meta",children:n.map((u,m)=>e.jsxs("span",{children:[m>0?e.jsx(ct,{}):null,u.node]},u.key))})},ci=({team:s,expanded:t})=>{const a=Xa(s),i=nt(s);return e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsxs("span",{className:"flex min-w-0 items-baseline",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:ae(s.name)}),i?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",i]}):null]}),a?e.jsxs(e.Fragment,{children:[e.jsx("span",{...Se,"aria-hidden":"true",className:U("mt-1 select-text break-words text-body-sm text-ink-muted",t?"line-clamp-[12] whitespace-pre-line":"line-clamp-2"),children:a}),e.jsx("span",{className:"sr-only",children:ei(a,t)})]}):e.jsx("span",{className:"mt-1 text-body-sm text-ink-dim",children:"No description"}),e.jsxs("span",{className:"mt-1 flex min-w-0 flex-col",children:[e.jsx(li,{team:s}),e.jsx(ri,{team:s})]})]})},oi=({team:s})=>{const t=s.manager?.trim(),a=ti(s),i=[a.created?`Created ${a.created}`:null,a.updated?`Updated ${a.updated}`:null].filter(u=>u!==null),n=!!t||s.members.length>0;return e.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[n||i.length===0?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Members"}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t}),e.jsx("span",{className:"text-ink-dim text-meta",children:"Manager"})]}):null,s.members.map(u=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:u.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:ai(u.kind)}),u.count>1?e.jsxs("span",{className:"text-ink-dim text-meta tabular-nums",children:["×",u.count]}):null]},`${u.kind}:${u.role}`)),n?null:e.jsx("li",{className:"text-ink-dim text-meta",children:"No members"})]})]}):null,i.length>0?e.jsx("p",{className:"text-ink-dim text-meta",children:i.join(" · ")}):null]})},We=()=>e.jsxs("div",{className:U(rt,"pl-9"),"data-testid":"org-team-skeleton-row",children:[e.jsx("div",{className:"flex h-[1lh] items-center text-body",children:e.jsx(C,{className:"h-4.5 w-40"})}),e.jsxs("div",{className:"mt-1 flex h-[2lh] flex-col justify-evenly text-body-sm",children:[e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-2/3"})]}),e.jsx("div",{className:"mt-1 flex h-[1lh] items-center text-meta",children:e.jsx(C,{className:"h-3 w-64"})}),e.jsx("div",{className:"flex h-[1lh] items-center text-meta",children:e.jsx(C,{className:"h-3 w-48"})})]}),ot=(s,t)=>t instanceof Ys?t.message:ss(s,t),di=["refresh-hub","retry","sign-in"],ui=({signedIn:s,onOpenSettings:t})=>{const[a,i]=r.useState(1),[n,u]=r.useState(""),{teams:m,isLoading:O,isFetching:p,isError:v,error:L,refetch:_,pagination:b}=Zs({page:a,perPage:ls}),h=at(),[E,f]=r.useState(null),[w,I]=r.useState(null),F=r.useRef(new Map),T=r.useRef(null);r.useEffect(()=>{h.isPending||T.current===null||(F.current.get(T.current)?.focus(),T.current=null)},[h.isPending]);const g=Vt(n.trim()),R=r.useMemo(()=>g?m.filter(N=>ae(N.name).toLowerCase().includes(g)||(N.description??"").toLowerCase().includes(g)):m,[m,g]),k=N=>{h.isPending||(f(null),I(N.id),T.current=N.id,h.mutate({teamId:N.id,name:N.name},{onSettled:()=>I(null),onError:()=>f(N.id)}))},j=r.useMemo(()=>{if(!Us(h.error))return null;const N=m.find(D=>D.id===E);return Bs({code:h.error.code,message:h.error.message,details:h.error.details},{name:N?.name??"this team",hubAgentId:null,surface:"pull"})},[h.error,E,m]),y=j?.body??(vt(h.error)==="unauthorized"?"The team could not be pulled: this machine has no Radient sign-in for the hub. Sign in on the settings page, then pull again.":"The team could not be pulled."),[o,x]=r.useState(!1),A=(N,D)=>{switch(N){case"refresh-hub":_();break;case"retry":k(D);break;case"sign-in":x(!0);break}},z=O&&m.length===0,H=b?.totalRecords??m.length,M=r.useRef(null),q=N=>{const D=n!=="";u(N),D&&N===""&&M.current?.focus()};return e.jsxs("section",{"aria-label":"Public teams",className:"flex flex-col","data-testid":"agent-hub-public-teams",children:[e.jsx("h2",{className:"sr-only",children:"Public teams"}),e.jsx("p",{className:"mb-3 max-w-3xl text-body-sm text-ink-muted",children:"Public teams are published to the hub by anyone and can be read here without signing in. Pulling one copies it into this machine's local team registry."}),s?null:e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2","data-testid":"agent-hub-public-teams-signed-out",children:[e.jsx("span",{className:"text-meta text-ink-dim",children:"Sign in to Radient to pull a team into this machine."}),e.jsx(P,{variant:"secondary",size:"sm",onClick:t,children:"Open settings to sign in"})]}),e.jsx("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:e.jsxs("div",{className:U("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(qs,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ie,{ref:M,type:"search",value:n,onChange:N=>q(N.target.value),placeholder:"Search teams","aria-label":"Search teams",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-public-teams-search"})]})}),z&&e.jsxs("div",{"aria-hidden":"true",className:"flex max-w-4xl flex-col gap-3","data-testid":"agent-hub-public-teams-loading",children:[e.jsx(Ye,{}),e.jsx(Ye,{}),e.jsx(Ye,{})]}),!z&&v&&e.jsxs(be,{variant:"danger",className:"w-auto max-w-2xl","data-testid":"agent-hub-public-teams-error",children:[e.jsx(pe,{children:"Public teams could not be loaded"}),e.jsx(ge,{children:ot("The public team catalogue could not be read.",L)}),e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void _(),disabled:p,"aria-busy":p,children:p?"Trying…":"Try again"})})]}),!z&&!v&&m.length===0&&e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-empty",children:"No teams have been published to the public hub yet."}),!z&&!v&&m.length>0&&e.jsxs(e.Fragment,{children:[!g||R.length>0?e.jsxs("p",{className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-public-teams-status",children:[g?`${R.length} of ${m.length} teams on this page match "${n.trim()}"`:`${H} ${H===1?"team":"teams"} in the public hub`,g?e.jsxs("span",{className:"text-ink-dim",children:[" ","· search covers the teams loaded here"]}):null]}):null,R.length===0?e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-search-miss",children:`No team on this page matches "${n.trim()}".`}):e.jsx("ul",{className:"flex max-w-4xl flex-col gap-3",children:R.map(N=>e.jsx(mi,{team:N,pulling:w===N.id,pullPending:h.isPending,onPull:k,pullButtonRef:D=>{D?F.current.set(N.id,D):F.current.delete(N.id)},failed:E===N.id,failureBody:y,treatment:j,onTreatmentAction:A,reauthenticating:o,onReauthenticated:()=>{x(!1),f(null),_()}},N.id))}),!g&&b&&b.totalPages>1&&e.jsx(is,{count:b.totalPages,page:b.page,onChange:N=>{i(N),M.current?.scrollIntoView({block:"nearest"})}})]})]})},mi=({team:s,pulling:t,pullPending:a,onPull:i,failed:n,failureBody:u,treatment:m,onTreatmentAction:O,reauthenticating:p,onReauthenticated:v,pullButtonRef:L})=>{const[_,b]=r.useState(!1),h=Ea({teamId:_?s.id:void 0}),E=ae(s.name),f=nt(s),w=lt(s),I=s.manager?.trim(),F=it(s),T=(s.description??"").trim();return e.jsxs("li",{className:"rounded-md bg-surface p-4","data-testid":"agent-hub-public-team","data-team-name":s.name,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline",children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:E}),f?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",f]}):null]}),T?e.jsx("p",{...Se,className:"mt-1 line-clamp-3 max-w-3xl select-text text-body-sm text-ink-muted",children:T}):e.jsx("p",{className:"mt-1 text-body-sm text-ink-dim",children:"No description"}),e.jsxs("p",{className:"mt-2 flex flex-wrap items-baseline gap-x-2 text-meta",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:"Manager:"}),e.jsx("span",{className:"text-ink-muted",children:I})]}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:"No members"}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-ink-dim",children:[F," ",F===1?"member":"members",":"]}),e.jsx(le,{content:Xe(s),children:e.jsx("span",{className:"truncate text-ink-muted",children:Xe(s)})})]})]}),w?e.jsxs("p",{className:"mt-1 text-ink-dim text-meta",children:["Published by ",e.jsx("span",{className:"text-ink-muted",children:w})]}):null]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[e.jsx(P,{ref:L,variant:"secondary",size:"sm",onClick:()=>i(s),disabled:a,"aria-label":`Pull team ${E}`,children:t?"Pulling…":"Pull"}),n&&e.jsxs("div",{className:"flex max-w-56 flex-col items-end gap-1","data-testid":"agent-hub-public-team-pull-error",children:[e.jsx("output",{className:"text-right text-meta text-danger",children:u}),m?.actions.filter(g=>di.includes(g)).map(g=>e.jsx(P,{variant:"primary",size:"sm",onClick:()=>O(g,s),children:Ks[g]},g)),p&&e.jsx("div",{"data-testid":"agent-hub-public-team-pull-reauth",children:e.jsx(Xs,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:v})})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Hs,{summary:"Brief",open:_,onOpenChange:b,className:"w-full",triggerClassName:"w-full",triggerLabel:`View the brief for ${E}`,chevronClassName:"text-ink-dim",children:e.jsx(hi,{detail:h})})})]})},hi=({detail:s})=>{if(s.isLoading)return e.jsxs("div",{className:"flex flex-col gap-1","data-testid":"agent-hub-public-team-brief-loading",children:[e.jsx(C,{className:"h-[1lh] w-2/3"}),e.jsx(C,{className:"h-[2lh] w-full"})]});if(s.isError)return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx("output",{className:"text-meta text-danger",children:ot("This team's brief could not be read.",s.error)}),e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-busy":s.isFetching,children:s.isFetching?"Trying…":"Try again"})]});const t=s.team;if(!t)return null;const a=(t.instructions??"").trim(),i=(t.project??"").trim();return e.jsxs("div",{className:"flex max-w-3xl flex-col gap-3 text-body-sm","data-testid":"agent-hub-public-team-brief",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Collaboration brief"}),a?e.jsx("p",{...Se,className:"whitespace-pre-line select-text text-ink-muted",children:a}):e.jsx("p",{className:"text-ink-dim",children:"This team has no collaboration brief."})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Project brief"}),i?e.jsx("p",{...Se,className:"whitespace-pre-line select-text text-ink-muted",children:i}):e.jsx("p",{className:"text-ink-dim",children:"This team has no project brief."})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Roster"}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t.manager?.trim()?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t.manager.trim()}),e.jsx("span",{className:"text-ink-dim text-meta",children:"Manager"})]}):null,t.members.length===0?e.jsx("li",{className:"text-ink-dim",children:"No members"}):t.members.map(n=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:n.count>1?`${n.role} ×${n.count}`:n.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:n.kind})]},`${n.kind}:${n.role}`))]})]})]})},Ye=()=>e.jsxs("div",{className:"rounded-md bg-surface p-4",children:[e.jsx(C,{className:"h-[1lh] w-1/3"}),e.jsx(C,{className:"mt-1 flex h-[3lh] w-full"}),e.jsx(C,{className:"mt-2 h-[1lh] w-2/3"})]}),xi=(s,t)=>{const[a,i]=r.useState(s);return r.useEffect(()=>{const n=setTimeout(()=>i(s),t);return()=>clearTimeout(n)},[s,t]),a},we=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],bi=[{value:"name",label:"Name"},{value:"description",label:"Description"}],pi=300,K="public",Fs={agents:"agent-hub-view-agents",teams:"agent-hub-view-teams",skills:"agent-hub-view-skills"},$s="agent-hub-view-panel",gi=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-md bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(C,{className:"h-5.5 w-2/3"}),e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(C,{className:"h-5.5 w-24"}),e.jsx(C,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(C,{className:"h-5.5 w-24"})})]}),e.jsx(C,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(C,{className:"size-4"}),e.jsx(C,{className:"h-4 w-6"}),e.jsx(C,{className:"size-4"}),e.jsx(C,{className:"h-4 w-6"}),e.jsx(C,{className:"ml-auto h-7 w-16"})]})]}),Li=()=>{const s=zs(),{isAuthenticated:t}=ts(),[a,i]=r.useState(1),[n]=r.useState(12),[u,m]=r.useState(null),[O,p]=r.useState(""),[v,L]=r.useState("name"),[_,b]=r.useState(we[0].value),[h,E]=r.useState(K),[f,w]=r.useState("agents");ke();const[I,F]=r.useState([]),T=xi(O,pi),g=we.find(c=>c.value===_)??we[0],R=Ce(),k=!R.isError&&re(R.data,"hub_skills"),j=f==="skills"&&!k?"agents":f;r.useEffect(()=>{f==="skills"&&!k&&w("agents")},[f,k]);const y=Lt(),o=Nt(R.data,"radient_org"),x=t?ka(o,y??null):null,{memberships:A}=ua({enabled:Ve(o)}),z=r.useMemo(()=>ga(A),[A]),H=h===K||z.some(c=>c.tenant_id===h);r.useEffect(()=>{!H&&j!=="skills"&&E(K)},[H,j]);const M=h===K?null:z.find(c=>c.tenant_id===h)??null,q=M?.tenant_id,N=M?.tenant_name||null,D=u!==null||T!=="",se=tt({tenantId:q}),te=Zs({page:1,perPage:ls,enabled:h===K}),de=q&&se.isSuccess?se.teams.length:null,ye=te.isSuccess?te.pagination?.totalRecords??null:null,Q=D?null:h===K?ye:de,S=h===K?{visibility:"public",tenantId:null}:{visibility:"org",tenantId:h},ve=H&&(h===K||Ve(o)),ue=et(S,1,k&&ve&&(h===K||t)),ee=ue.isSuccess?ue.data.total:null,Ae=M?.role==="owner"||M?.role==="admin",me=r.useMemo(()=>new Map(A.map(c=>[c.tenant_id,c.tenant_name])),[A]),{data:ne,agents:Ee,isLoading:Oe,isFetching:V,error:J,refetch:he,pagination:B}=zt({page:a,perPage:n,categories:u?[u]:void 0,name:v==="name"&&T||void 0,description:v==="description"&&T||void 0,sort:g.sort,order:g.order,tenantId:q}),d=M?Js(J):null,$=Ee??[],X=V&&ne!==void 0,{statuses:xe,isKnown:Ne,isError:dt,isFetching:Le,refetch:ut}=Wt({agentIds:q?[]:$.map(c=>c.id)}),Fe=r.useRef(null),$e=r.useRef(null),[os,mt]=r.useState(0);r.useEffect(()=>{os!==0&&(Fe.current??$e.current)?.focus()},[os]);const ds=r.useRef(null),ze=r.useRef(!1),Me=r.useMemo(()=>[...new Set((ne?.records??[]).flatMap(c=>c.categories??[]))],[ne]);r.useEffect(()=>{F(c=>Me.every(Y=>c.includes(Y))?c:[...new Set([...c,...Me])])},[Me]);const ht=()=>{m(null),p(""),i(1),mt(c=>c+1)},W=(Oe||V)&&ne===void 0,us=!W&&!D&&(J!==null||$.length===0);r.useEffect(()=>{!ze.current||W||(ze.current=!1,J?ds.current?.focus():(Fe.current??$e.current)?.focus())},[W,J]);const ms=r.useRef(null),xt=c=>{i(c),ms.current?.scrollIntoView({block:"nearest"})},bt=c=>{m(c),i(1)},pt=c=>{p(c),i(1)},gt=c=>{E(c),i(1)},hs=r.useRef(new Map),ft=c=>{L(c),i(1)},kt=B&&!D?B.totalRecords:null,De=q?`shared with ${N??"this organization"}`:"in the public hub",xs=(c,Y)=>`${c} ${Y}${c===1?"":"s"} ${De}`;let Z;return j==="skills"?Z=" ":j==="teams"?q?se.isLoading?Z="Loading teams…":Q!==null?Z=xs(Q,"team"):Z=`Teams ${De}`:Z=" ":W?Z="Loading agents…":B?Z=xs(B.totalRecords,"agent"):Z=`Agents ${De}`,e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(wt,{title:"Agent Hub",subtitle:"Discover and download agents, teams and skills on Radient",icon:ma}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[x&&e.jsxs(be,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(pe,{children:"Organizations are unavailable"}),e.jsx(ge,{children:x})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2","data-testid":"agent-hub-browse-bar",children:[e.jsx(Pt,{value:j,onValueChange:c=>w(c),children:e.jsx(Tt,{"aria-label":"Browse the hub by type",children:["agents","teams",...k?["skills"]:[]].map(c=>{const Y=c==="agents"?kt:c==="teams"?Q:ee;return e.jsxs(Ct,{value:c,id:Fs[c],"aria-controls":j===c?$s:void 0,"data-testid":`agent-hub-view-${c}`,children:[c==="agents"?"Agents":c==="teams"?"Teams":l("ui.hub.skills.title"),Y!==null&&e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:Y})]},c)})})}),z.length>0&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0","data-testid":"agent-hub-scope",children:[e.jsx("legend",{className:"sr-only",children:"Show the hub of"}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:[{value:K,label:"Public hub",Icon:Ft},...z.map(c=>({value:c.tenant_id,label:c.tenant_name||"Organization",Icon:ja}))].map(({value:c,label:Y,Icon:jt})=>e.jsxs(P,{ref:bs=>{bs?hs.current.set(c,bs):hs.current.delete(c)},variant:"ghost",size:"sm","aria-pressed":h===c,onClick:()=>gt(c),title:Y,"data-testid":`agent-hub-scope-${c===K?"public":`org-${c}`}`,className:U("max-w-48",h===c&&"bg-surface text-ink hover:bg-surface"),children:[e.jsx(jt,{"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:Y})]},c))})]})]})]}),e.jsx(It,{id:$s,labelledBy:Fs[j],children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[j==="agents"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-glass-region":"panel","data-tour-tag":"agent-hub-sidebar-container",children:!us&&e.jsx(_a,{selectedCategory:u,onSelectCategory:bt,categories:I})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[j==="agents"&&!us&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:U("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ie,{ref:Fe,type:"search",value:O,onChange:c=>pt(c.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(gs,{value:v,onValueChange:ft,children:[e.jsx(fs,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ks,{})}),e.jsx(js,{children:bi.map(c=>e.jsx(ys,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs(gs,{value:_,onValueChange:b,children:[e.jsx(fs,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ks,{})}),e.jsx(js,{children:we.map(c=>e.jsx(ys,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("p",{ref:ms,"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[Z,j==="agents"&&X?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{"data-testid":"agent-hub-updating",children:"Updating…"})]}):null]}),j==="agents"&&e.jsxs(e.Fragment,{children:[t&&dt&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>void ut(),disabled:Le,"aria-busy":Le,children:Le?"Trying…":"Try again"})]}),W&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(c,Y)=>e.jsx(gi,{},Y))}),W&&B===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(C,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:U(!W&&J&&!d?"block":"sr-only"),children:!W&&J&&!d&&e.jsxs(be,{variant:"danger",className:"max-w-2xl","aria-busy":V,"data-testid":"agent-hub-error",children:[e.jsx(pe,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(ge,{children:t?ss("The agent list could not be loaded.",J):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(P,{ref:ds,variant:"outline",size:"sm",onClick:()=>{ze.current=!0,he()},disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]})}),!W&&d&&M&&e.jsxs(be,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(pe,{children:d==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(ge,{children:d==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${M.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${M.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),d==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void he(),disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]}),!W&&!J&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":X,children:$.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:U("col-span-full w-full flex flex-col items-center gap-2 rounded-md bg-surface px-6 py-10 text-center",!q&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:q?"This organization has no shared agents yet.":u?`No agents in ${Qs(u).label}.`:D?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:q?`Agents published into ${M?.tenant_name||"this organization"} appear here for its members.`:u?"Nothing in this category yet. Clear the filter to see the whole hub.":D?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:D?e.jsx(P,{variant:"secondary",onClick:ht,children:u?"Clear filter":"Clear search"}):q&&!Ae?null:e.jsx(P,{ref:$e,variant:"secondary",onClick:()=>s("/agents"),children:"Publish an agent"})})]}):$.map(c=>e.jsx(wa,{agent:c,status:t?xe[c.id]:void 0,viewerStateKnown:t&&Yt(Ne,xe,c.id),orgName:c.visibility==="org"?me.get(c.tenant_id)??null:null},c.id))}),!W&&B&&B.totalPages>1&&e.jsx(is,{count:B.totalPages,page:B.page,onChange:xt})]}),j==="skills"&&(k?e.jsx(Wa,{scope:h===K?{visibility:"public",tenantId:null,organization:null}:{visibility:"org",tenantId:h,organization:N},signedIn:t,accessible:H&&(h===K||Ve(o))},`skills:${h}`):e.jsx("p",{className:"text-body-sm text-warning",children:l("ui.hub.skills.unavailable")})),j==="teams"&&(M?e.jsx(ni,{tenantId:M.tenant_id,orgName:N}):e.jsx(ui,{signedIn:t,onOpenSettings:()=>s("/settings")}))]})]})})]})]})};export{Li as AgentHubPage};
6
+ */const ya=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],va=St("circle-ellipsis",ya),Na=({agent:s,isLiked:t,isFavourited:a,onLikeToggle:i,onFavouriteToggle:n,onDownload:u,isLikeActionLoading:m=!1,isFavouriteActionLoading:O=!1,isDownloading:p=!1,actionError:v=null,onRetryAction:E,showActions:_=!0,viewerStateKnown:b=!0,orgName:h=null})=>{const L=zs(),{isAuthenticated:f}=ts(),w=s.description??"",[I,F]=r.useState(!1),T=r.useRef(null),g=r.useCallback(A=>{if(T.current?.disconnect(),T.current=null,!A)return;const z=()=>F(A.scrollHeight-A.clientHeight>1);z();const H=new ResizeObserver(z);H.observe(A),T.current=H},[]),R=f?b?t?"Unlike agent":"Like agent":"Your likes could not be read, so this is not shown as unliked.":"Log in to Radient to like agents",k=f?b?a?"Unfavourite agent":"Favourite agent":"Your favourites could not be read, so this is not shown as unfavourited.":"Log in to Radient to favourite agents",j=b?t?"Unlike agent":"Like agent":"Like state unavailable",y=b?a?"Unfavourite agent":"Favourite agent":"Favourite state unavailable",o=s.visibility==="org",x=ae(s.name);return e.jsxs("div",{"data-glass-block":"",className:"flex h-full flex-col overflow-hidden rounded-md bg-surface transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("button",{type:"button",onClick:()=>L(`/agent-hub/${s.id}`),className:"flex min-h-0 flex-1 cursor-pointer flex-col gap-2 p-4 text-left","aria-label":`View details for ${x}`,children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:x}),o&&e.jsx(Mt,{orgName:h}),e.jsx(le,{content:I?w:"",children:e.jsx("span",{ref:g,className:"line-clamp-3 min-h-0 text-body-sm text-ink-muted",children:w})}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsx(Dt,{tags:s.tags,categories:s.categories}),e.jsxs("p",{className:"truncate text-ink-dim text-meta",children:[s.account_metadata?.name??"Unknown author",e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),"updated ",qt(new Date(s.updated_at))," ago"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-0.5","data-viewer-state":o?"org":f?b?"known":"unknown":"signed-out",children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx(le,{content:R,children:e.jsx("span",{children:e.jsxs(P,{variant:"ghost",size:"sm",onClick:f&&b?()=>i(s.id):void 0,disabled:m||!f||!b,"aria-label":j,className:U(t&&"text-danger"),children:[e.jsx(Gt,{fill:t?"currentColor":"none","data-testid":"agent-like-heart"}),e.jsx("span",{"data-testid":"agent-like-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.like_count??0})]})})}),e.jsx(le,{content:k,children:e.jsx("span",{children:e.jsxs(P,{variant:"ghost",size:"sm",onClick:f?()=>n(s.id):void 0,disabled:O||!f||!b,"aria-label":y,className:U(a&&"text-warning"),children:[e.jsx(Jt,{fill:a?"currentColor":"none","data-testid":"agent-favourite-star"}),e.jsx("span",{"data-testid":"agent-favourite-count",className:"inline-flex h-4 min-w-4 items-center font-mono text-mono-sm text-ink-muted",children:s.favourite_count??0})]})})})]}),e.jsx(le,{content:"Downloads",children:e.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 pr-1 text-ink-dim",children:[e.jsx(vs,{"aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"inline-flex h-4 min-w-6 items-center font-mono text-mono-sm",children:p?e.jsx(C,{className:"h-3 w-6"}):(s.download_count??0).toLocaleString()})]})})]}),_&&u&&e.jsx("div",{className:"ml-auto flex shrink-0 items-center",children:e.jsxs(P,{variant:"secondary",size:"sm",onClick:()=>u(s),disabled:p,"aria-label":`Download ${x}`,"data-tour-tag":"agent-hub-download-button",children:[e.jsx(vs,{"data-testid":"agent-download"}),"Get"]})})]}),v&&e.jsxs("output",{"data-testid":"agent-card-error",className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-hairline px-3 py-2 text-body-sm text-danger",children:[e.jsx("span",{className:"min-w-0 flex-1",children:v}),E&&e.jsx(P,{variant:"ghost",size:"sm",onClick:E,children:"Try again"})]})]})},wa=({agent:s,status:t,viewerStateKnown:a=!0,orgName:i=null})=>{const{isAuthenticated:n}=ts(),[u,m]=r.useState(null),O=t?.liked??!1,p=t?.favourited??!1,v=Ut(),E=Ht(),_=Bt(),b=()=>{!n||v.isPending||(m(null),v.mutate({agentId:s.id,isCurrentlyLiked:O},{onError:()=>m("like")}))},h=()=>{!n||E.isPending||(m(null),E.mutate({agentId:s.id,isCurrentlyFavourited:p},{onError:()=>m("favourite")}))},L=()=>{_.isPending||(m(null),_.mutate({agentId:s.id,agentName:s.name},{onError:()=>m("download")}))},f=u?u==="like"?{action:"like",error:v.error,retry:b}:u==="favourite"?{action:"favourite",error:E.error,retry:h}:{action:"download",error:_.error,retry:L}:null;return e.jsx(Na,{agent:s,isLiked:n&&O,isFavourited:n&&p,onLikeToggle:b,onFavouriteToggle:h,onDownload:L,isLikeActionLoading:v.isPending,isFavouriteActionLoading:E.isPending,isDownloading:_.isPending,viewerStateKnown:a,orgName:i,actionError:f?$t(f.action,f.error,ae(s.name)):null,onRetryAction:f?.retry})},Ss=({selected:s,onClick:t,children:a,...i})=>e.jsx("button",{type:"button",onClick:t,"aria-pressed":s,className:U("flex w-full cursor-pointer items-center gap-2.5 rounded-sm px-3 py-1.5 text-left","text-body-sm transition-colors duration-fast ease-out-quart",s?Xt:"text-ink hover:bg-row-hover"),...i,children:a}),_s=Object.keys(Kt),Sa=s=>[...s].sort((t,a)=>{const i=_s.indexOf(t),n=_s.indexOf(a);return i!==-1&&n!==-1?i-n:i!==-1?-1:n!==-1?1:t.localeCompare(a)}),_a=({selectedCategory:s,onSelectCategory:t,categories:a})=>{ke();const i=Sa(s&&!a.includes(s)?[...a,s]:a);return e.jsxs("div",{className:"flex h-full flex-col overflow-y-auto",children:[e.jsx("h2",{className:"mb-2 px-3 font-medium text-ink-dim text-meta",children:l("ui.hub.taxonomy.heading")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs(Ss,{selected:s===null,onClick:()=>t(null),"data-testid":"category-all",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.jsx(Zt,{size:16,"aria-hidden":"true"})}),l("ui.hub.taxonomy.all")]}),i.map(n=>{const u=Qs(n),m=n==="other"?e.jsx(va,{size:16}):u.icon;return e.jsxs(Ss,{selected:s===n,onClick:()=>t(n),"data-testid":`category-${n}`,children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:m}),u.label]},n)})]})]})},is=({page:s,count:t,onChange:a,ariaLabel:i="Agent pages"})=>{const n=r.useRef(null),u=r.useRef(null),m=r.useRef(null);return r.useEffect(()=>{const O=m.current;m.current=null,O==="previous"&&n.current?.focus(),O==="next"&&u.current?.focus()},[s]),t<=1?null:e.jsxs("nav",{"aria-label":i,className:"mt-6 flex min-h-13 items-center justify-between gap-3 border-t border-hairline","data-testid":"agent-hub-pager",children:[e.jsxs("span",{className:"select-none text-meta text-ink-dim",children:["Page ",s," of ",t]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(P,{variant:"secondary",size:"sm",ref:n,onClick:()=>{s-1<=1&&(m.current="next"),a(s-1)},disabled:s<=1,"aria-label":"Previous page",children:[e.jsx(Rt,{"aria-hidden":"true"}),"Previous"]}),e.jsxs(P,{variant:"secondary",size:"sm",ref:u,onClick:()=>{s+1>=t&&(m.current="previous"),a(s+1)},disabled:s>=t,"aria-label":"Next page",children:["Next",e.jsx(_t,{"aria-hidden":"true"})]})]})]})},Pa=/alias/i;function Ps(s){return s instanceof yt?s.code==="alias-occupied"?!0:s.code==="origin-conflict"&&Pa.test(s.message):!1}const Ta=/\/+$/;function ns(s){const t=s.replace(Ta,"");try{const{pathname:a}=new URL(t);return a===""||a==="/"?`${t}/v1`:t}catch{return`${t}/v1`}}const Ts=s=>s?.skills===1&&s.revision_cas===1;function Ca(s,t=1,a=20){const i=new URL(Vs(s,"skills"));return i.searchParams.set("page",String(t)),i.searchParams.set("per_page",String(a)),Ws(i.toString())}function Ia(s,t){return Ws(Vs(s,"skills",t))}function Ra(s){return Ds({operation:"org_skills.list",tenantId:s})}function Aa(s,t){return Ds({operation:"org_skill.get",tenantId:s,skillId:t})}const ls=12,_e={all:["public-teams"],list:(s,t)=>[..._e.all,"list",{page:s,perPage:t}],detail:s=>[..._e.all,"detail",s]},Re=(s,t)=>t instanceof Ys?t.status===null?!1:t.status>=500&&s<1:s<1,Xs=({page:s=1,perPage:t=ls,enabled:a=!0}={})=>{const i=ce({queryKey:_e.list(s,t),queryFn:()=>ea(G.radientBaseUrl,s,t),select:n=>n.result,enabled:a,retry:Re,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,placeholderData:n=>n});return{...i,teams:i.data?.records??[],isRefreshing:i.isFetching&&i.data!==void 0,pagination:i.data?{page:i.data.page,perPage:i.data.per_page,totalPages:i.data.total_pages,totalRecords:i.data.total_records}:void 0}},La=({teamId:s,enabled:t=!0})=>{const a=ce({queryKey:_e.detail(s??""),queryFn:()=>sa(G.radientBaseUrl,s),select:i=>i.result,enabled:t&&!!s,retry:Re,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1});return{...a,team:a.data}};function oe(s){if(s.getQueryState(ps.capabilities)?.status!=="success"||!re(s.getQueryData(ps.capabilities),"hub_skills"))throw new Error("This backend does not support the complete Hub Skills adapter.")}function et(s,t,a){const i=ie(),n=Ce();return ce({queryKey:["hub-skills",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:a&&!n.isError&&re(n.data,"hub_skills"),queryFn:async()=>{if(oe(i),s.visibility==="org"){const m=(await Ra(s.tenantId)).result;return{rows:m.skills,pages:1,total:m.skills.length,contract:m.sync_contract}}const u=(await Ca(G.radientBaseUrl,t,20)).result;return{rows:u.records,pages:u.total_pages,total:u.total_records,contract:u.sync_contract}},staleTime:3e4,retry:s.visibility==="org"?es:Re,retryOnMount:!1,refetchOnWindowFocus:!1})}function Oa(s,t,a){const i=ie(),n=Ce();return ce({queryKey:["hub-skill",G.radientBaseUrl,s.visibility,s.tenantId,t],enabled:a&&t!==null&&!n.isError&&re(n.data,"hub_skills"),queryFn:async()=>(oe(i),(s.visibility==="org"?await Aa(s.tenantId,t):await Ia(G.radientBaseUrl,t)).result),staleTime:3e4,retry:s.visibility==="org"?es:Re,retryOnMount:!1})}function rs(s,t){s.setQueryData(as,t.links)}function cs(s){s.invalidateQueries({queryKey:as}),s.invalidateQueries({queryKey:["desktop","skills"]})}function Ea(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillPull",requestId:t.requestId,hubId:t.remoteId,hubSource:ns(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias,subscribe:t.subscribe,autoPush:t.autoPush,confirmPublicEgress:t.consent})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function Fa(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillSubscribe",requestId:t.requestId,hubId:t.remoteId,hubSource:ns(G.radientBaseUrl),visibility:t.scope.visibility,tenantId:t.scope.tenantId,localAlias:t.alias})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function $a(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillUnpull",requestId:t.requestId,linkId:t.linkId})),onSuccess:t=>{rs(s,t)},onSettled:()=>{cs(s)}})}function za(){const s=ie();return je({mutationFn:t=>(oe(s),fe({op:"hub.skillPublish",requestId:t.requestId,...t.draft,dryRun:t.previewReceipt===void 0,...t.previewReceipt?{previewReceipt:t.previewReceipt,confirmPublish:!0}:{}})),onSuccess:t=>{t.local_link_receipt?.state==="complete"&&(s.invalidateQueries({queryKey:as}),s.invalidateQueries({queryKey:["desktop","skills"]}),s.invalidateQueries({queryKey:["hub-skills"]}))}})}const Ma=/\/+$/;function Cs(s){return s.replace(Ma,"")}function Da(s,t){return t.visibility==="public"?s.visibility==="public"&&!s.tenant_id:s.visibility==="org"&&s.tenant_id===t.tenantId}function Je(s){const t=s.id??s.hub_id??"",a=s.tenantId??s.tenant_id??"";return`${t}\0${s.visibility}\0${a}`}function qa(s,t){const a=Cs(t),i=new Map;for(const n of s??[])n.kind==="skill"&&Cs(n.hub_source)===a&&i.set(Je({hub_id:n.hub_id,visibility:n.visibility,tenantId:n.tenant_id}),n);return i}function Is(s,t,a=!0){if(!a)return{kind:"unknown"};if(!s)return{kind:"not-present"};const i=Ge(s);return i==="present"&&(s.pull.state==="available"||t?.state==="available"&&!t.error_class)?{kind:"update",link:s,automatic:t?.auto_will_apply===!0||s.auto_will_apply}:i==="absent"?s.policy.subscribe?{kind:"subscribed",link:s}:{kind:"detached",link:s}:s.policy.subscribe?{kind:"pulled",link:s}:{kind:"manual",link:s}}function Ua(s){return s?"policy":"create"}function Ha(s){return JSON.stringify({op:"pull",selected:s.selected,scope:s.scope,localAlias:s.localAlias,subscribe:s.subscribe,autoPush:s.autoPush,consent:s.consent})}function Ba({scope:s,source:t,verifiedCas:a,enabled:i=!0,heading:n=!0}){ke();const u=r.useId(),[m,O]=r.useState(""),[p,v]=r.useState(""),[E,_]=r.useState(ha),[b,h]=r.useState(null),[L,f]=r.useState(!1),w=za(),I=r.useRef(null),F=ce({queryKey:["desktop","skills","hub-publication"],queryFn:()=>fe({op:"skills.list"}),staleTime:3e4,retry:!1}),T=`${s.visibility}:${s.tenantId??""}`,g=r.useRef(T);r.useEffect(()=>{g.current!==T&&(g.current=T,_(y=>({...y,autoPush:!1,confirmPublicEgress:!1})),h(null),f(!0))},[T]);const R={sourceSkill:m,localAlias:p,visibility:s.visibility,tenantId:s.tenantId,...E},k=b?xa(b,R):!1;r.useEffect(()=>{if(!b)return;const y=setTimeout(()=>{h(null),f(!0)},Math.max(0,Math.min(Date.parse(b.expires_at)-Date.now(),2147483647)));return()=>clearTimeout(y)},[b]);const j=y=>{if(!i||w.isPending||!m||!p||y&&!k)return;const o=JSON.stringify({draft:R,receipt:y?b?.preview_receipt:null}),x=I.current&&I.current.tuple===o&&(y||w.error)?I.current:{tuple:o,id:crypto.randomUUID()};I.current=x,y||(h(null),f(!1)),w.mutate({requestId:x.id,draft:R,...y&&b?{previewReceipt:b.preview_receipt}:{}},{onSuccess:A=>{A.preview?(h(A.preview),f(!1)):ws(A)&&h(null)}})};return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skill-publication":!0,children:[n&&e.jsx("h3",{className:"text-heading text-ink",children:l("ui.hub.skills.publish_title")}),e.jsx("label",{htmlFor:`${u}-source`,className:"text-body-sm text-ink",children:l("ui.hub.skills.select_authored")}),e.jsxs("select",{id:`${u}-source`,"data-testid":"hub-skill-publish-source",value:m,disabled:w.isPending||!i,className:"rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink",onChange:y=>{O(y.target.value),v(y.target.value),h(null),_(o=>({...o,autoPush:!1,confirmPublicEgress:!1}))},children:[e.jsx("option",{value:"",children:l("ui.hub.skills.select_authored")}),F.data?.data.skills.map(y=>e.jsx("option",{value:y.name,children:y.name},y.name))]}),e.jsx("label",{htmlFor:`${u}-alias`,className:"text-body-sm text-ink",children:l("ui.hub.subscriptions.alias")}),e.jsx(Ie,{id:`${u}-alias`,"data-testid":"hub-skill-publish-alias",value:p,disabled:w.isPending||!i,onChange:y=>{v(y.target.value),_(o=>({...o,autoPush:!1,confirmPublicEgress:!1}))}}),e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.text_limits")}),e.jsx(ba,{value:E,onChange:_,source:t,item:m||p,visibility:s.visibility,organization:s.organization,destinationKey:`${T}:${m}`,canEnableAutoPush:a,disabled:w.isPending||!i}),F.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.loading")}),F.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:l("ui.hub.status.other_error")}),w.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:l("ui.hub.links.action_failed",{direction:l("ui.hub.links.direction_push"),item:m||p,source:t})}),(L||b&&!k&&b.can_confirm)&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.links.preview_changed")}),b&&b.visibility===s.visibility&&b.tenant_id===s.tenantId&&e.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[e.jsx("h4",{className:"text-body-sm text-ink",children:l("ui.hub.links.preview_payload",{source:t})}),e.jsx(Ms,{readOnly:!0,rows:12,"aria-label":l("ui.hub.links.preview_payload",{source:t}),value:JSON.stringify(b.proposal.fields,null,2),className:"max-h-96 bg-sunken text-mono-sm"}),b.warnings.map((y,o)=>e.jsx("p",{className:"break-words text-body-sm text-warning",children:y},`${o}-${y}`)),b.reason&&e.jsx("p",{className:"text-body-sm text-warning",children:ta(b.reason)})]}),w.data?.publication===null&&w.data.local_link_receipt?.state==="pending-reconciliation"&&e.jsx("output",{className:"text-body-sm text-warning","data-testid":"hub-skill-pending-reconcile",children:l("ui.hub.links.publication_pending")}),w.data?.publication&&e.jsx("output",{className:"text-body-sm text-ink","data-testid":"hub-skill-published",children:ws(w.data)?l("ui.hub.links.published",{item:w.data.link?.name??p,source:w.data.link?Gs(w.data.link):t}):l("ui.hub.skills.policy_pending")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline","data-testid":"hub-skill-publish-preview",disabled:!i||w.isPending||!m||!p,onClick:()=>j(!1),children:l("ui.hub.subscriptions.preview_publish")}),e.jsx(P,{"data-testid":"hub-skill-publish-confirm",disabled:!i||w.isPending||!k,onClick:()=>j(!0),children:l("ui.hub.links.confirm_publish")})]})]})}const Ka={available:"text-accent",applied:"text-success",failed:"text-danger",review:"text-warning",updating:"text-ink-muted"},Qa={available:"ui.hub.skills.update_available",applied:"ui.hub.skills.update_applied",failed:"ui.hub.skills.update_failed",review:"ui.hub.links.mark_review",updating:"ui.hub.links.mark_busy"},Va={"not-present":"ui.hub.skills.not_downloaded",subscribed:"ui.hub.skills.subscribed_absent",pulled:"ui.hub.skills.pulled",manual:"ui.hub.skills.manual",detached:"ui.hub.skills.detached"};function Rs(s,t,a){const i=t?ca(t):null;return i&&(s.kind==="update"||a&&(t?.state==="applied"||t?.state==="failed"||t?.error_class))?i:s.kind==="update"?{kind:"available",auto:s.automatic}:null}function As(s,t){return s.kind==="unknown"?t:s.kind!=="update"?l(Va[s.kind]):l(s.link.policy.subscribe?"ui.hub.skills.pulled":"ui.hub.skills.manual")}function Ls({mark:s}){return ke(),s?e.jsxs("span",{"data-hub-mark-state":s.kind,className:U("flex shrink-0 items-center gap-1 text-meta",Ka[s.kind]),children:[e.jsx(oa,{mark:s}),e.jsx("span",{children:l(Qa[s.kind])})]}):null}function Os(s,t){const a=s.publisher?.trim();return a?l("ui.hub.skills.published_by",{publisher:a}):s.visibility==="org"?t??l("ui.hub.links.source_unavailable"):l("ui.hub.skills.public_hub")}function Wa({scope:s,signedIn:t,accessible:a=!0}){ke();const i=r.useId(),[n,u]=r.useState(1),[m,O]=r.useState(""),[p,v]=r.useState(null),[E,_]=r.useState(!1),[b,h]=r.useState("unsubscribe"),[L,f]=r.useState(!1),w=r.useRef(null),I=s.visibility==="public"?l("ui.hub.links.source_public"):s.organization?l("ui.hub.links.source_private",{organization:s.organization}):l("ui.hub.links.source_unavailable"),F=Ce(),T=a&&re(F.data,"hub_updates"),g=et(s,n,a&&(s.visibility==="public"||t)),R=Ts(g.data?.contract),k=Oa(s,p,R&&a),j=Ea(),y=Fa(),o=$a(),x=aa(),A=ia(a&&re(F.data,"hub_links")),z=na(T),H=r.useMemo(()=>qa(A.data?.links,ns(G.radientBaseUrl)),[A.data]),M=r.useMemo(()=>la(z.data),[z.data]),q=j.data?.link?.link_id,N=!A.isLoading&&!A.error,D=A.error?l("ui.hub.skills.inventory_unknown"):l("ui.hub.links.loading"),se=k.data?.visibility===s.visibility&&(s.visibility==="public"?!k.data.tenant_id:k.data.tenant_id===s.tenantId),te=a&&!k.error&&!g.error&&se&&Ts(k.data?.sync_contract)&&!!k.data?.revision,de=(g.data?.rows??[]).filter(d=>Da(d,s)),ye=de.filter(d=>`${d.name} ${d.description}`.toLocaleLowerCase().includes(m.toLocaleLowerCase())),Q=de.find(d=>d.id===p),S=Q?H.get(Je({id:Q.id,visibility:Q.visibility,tenantId:Q.tenant_id??null})):void 0,ve=S?M.get(Ns("skill",S.name)):void 0,ue=Is(S,ve,N),ee=S?Ge(S)==="present":!1,Ae=d=>{const $=H.get(Je({id:d.id,visibility:d.visibility,tenantId:d.tenant_id??null})),Z=$?M.get(Ns("skill",$.name)):void 0;return{link:$,update:Z,state:Is($,Z,N)}},me=d=>(w.current?.tuple!==d&&(w.current={tuple:d,id:crypto.randomUUID()}),w.current.id),ne=d=>{if(!p||!te||!t)return;const $=d?.name??Q?.name??"";if(!$)return;const Z=d?d.policy.subscribe:!1,xe=d?.policy.auto_push??!1,Ne=!1;j.mutate({requestId:me(Ha({selected:p,scope:s,localAlias:$,subscribe:Z,autoPush:xe,consent:Ne})),remoteId:p,scope:s,alias:$,subscribe:Z,autoPush:xe,consent:Ne})},Le=()=>{if(!p||!te||!t)return;if(Ua(S)==="policy"&&S){if(S.policy.subscribe||x.isPending)return;h("subscribe"),x.mutate({link:S,patch:{subscribe:!0}});return}const d=Q?.name??"";d&&y.mutate({requestId:me(JSON.stringify({op:"subscribe",selected:p,scope:s,localAlias:d})),remoteId:p,scope:s,alias:d})},Oe=()=>{S&&o.mutate({requestId:me(JSON.stringify({op:"unpull",link:S.link_id})),linkId:S.link_id},{onSuccess:()=>{j.reset(),y.reset()}})},V=()=>{!S||S.policy.subscribe===!1||x.isPending||!x.canWrite||(h("unsubscribe"),x.mutate({link:S,patch:{subscribe:!1}}))},J=t&&R&&a&&!g.error,he=g.data?.total??de.length,B=g.error?null:g.isLoading?l("ui.hub.skills.loading"):s.organization?l("ui.hub.skills.count_shared",{count:he,organization:s.organization}):l("ui.hub.skills.count",{count:he});return e.jsxs("section",{className:"flex min-w-0 flex-col gap-4","data-hub-skills-library":!0,children:[s.visibility==="org"&&!t?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.no_credential")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:U("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(qs,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ie,{id:`${i}-search`,type:"search","data-testid":"hub-skill-search",value:m,placeholder:l("ui.hub.skills.search"),"aria-label":l("ui.hub.skills.search"),onChange:d=>O(d.target.value),className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none"})]}),J&&e.jsx(P,{variant:"secondary","data-testid":"hub-skill-publish-open",onClick:()=>f(!0),children:l("ui.hub.skills.publish_title")})]}),B!==null&&e.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-dim","data-testid":"hub-skill-status",children:s.organization||g.isLoading?e.jsx("span",{"data-testid":"hub-skill-source",children:B}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:B})," · ",e.jsx("span",{"data-testid":"hub-skill-source",children:l("ui.hub.skills.public_hub")})]})}),g.error&&e.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-body-sm text-warning",children:[e.jsx("p",{children:l("ui.hub.skills.catalogue_failed",{source:I})}),e.jsx(P,{variant:"outline",className:"self-start",disabled:g.isFetching,onClick:()=>void g.refetch(),children:l("ui.hub.links.retry")})]}),g.isSuccess&&!R&&e.jsx("p",{className:"text-body-sm text-warning",children:l("ui.hub.skills.unavailable")}),R&&e.jsxs(e.Fragment,{children:[ye.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:l(m?"ui.hub.skills.search_empty":"ui.hub.skills.remote_empty")}),e.jsx("ul",{className:"grid list-none grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6 p-0",children:ye.map(d=>{const $=Ae(d),Z=Rs($.state,$.update,$.link?Ge($.link)==="present":!1);return e.jsx("li",{className:"min-w-0",children:e.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p===d.id,"aria-label":l("ui.hub.skills.open_detail",{item:d.name}),"data-testid":"hub-skill-open","data-skill-id":d.id,"data-skill-state":$.state.kind,onClick:()=>{v(d.id),j.reset(),y.reset(),o.reset(),x.reset()},className:U("flex h-full w-full flex-col overflow-hidden rounded-md bg-surface text-left","transition-colors duration-fast ease-out-quart hover:bg-elevated","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-1"),children:[e.jsxs("span",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx("span",{className:"truncate font-medium text-heading text-ink",children:d.name}),d.description?e.jsx("span",{className:"line-clamp-3 text-body-sm text-ink-muted",children:d.description}):null,e.jsx("span",{className:"mt-auto truncate text-ink-dim text-meta",children:Os(d,s.organization)})]}),e.jsxs("span",{className:"flex items-center justify-between gap-2 border-t border-hairline px-4 py-2 text-meta",children:[e.jsx("span",{className:"truncate text-ink-muted",children:As($.state,D)}),e.jsx(Ls,{mark:Z})]})]})},d.id)})}),e.jsx(is,{page:n,count:g.data?.pages??1,onChange:u,ariaLabel:l("ui.hub.skills.title")})]})]}),!a&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.access_lost")}),e.jsx(qe,{open:!!p&&R,onOpenChange:d=>{d||v(null)},children:e.jsxs(Ue,{"data-hub-skill-detail":"",className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(He,{children:[e.jsx(Be,{"data-testid":"hub-skill-detail-name",children:k.data?.name??Q?.name??l("ui.hub.skills.title")}),e.jsx(Ke,{children:k.data&&se?Os(k.data,s.organization):I})]}),k.isLoading&&e.jsx("output",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.loading")}),k.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:l("ui.hub.status.other_error")}),k.data&&se&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-body-sm text-ink-muted",children:[As(ue,D),e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),l("ui.hub.skills.revision",{revision:String(k.data.content_revision)})]}),e.jsx(Ls,{mark:Rs(ue,ve,ee)})]}),e.jsx("p",{"data-testid":"hub-skill-description",className:"max-w-3xl select-text whitespace-pre-wrap break-words text-body-sm text-ink-muted",children:k.data.description}),S&&ee&&S.local_path&&e.jsx("p",{"data-testid":"hub-skill-local-path",className:"break-words font-mono text-meta text-ink-dim",children:l("ui.hub.skills.local_path",{path:`⁨${S.local_path}⁩`})}),e.jsx("h4",{className:"text-body-sm text-ink",children:l("ui.hub.skills.files")}),e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.file_count",{count:k.data.files.length})}),k.data.files.map(d=>e.jsxs("details",{className:"min-w-0",children:[e.jsx("summary",{className:"break-words text-mono-sm text-ink",children:d.path}),e.jsx(Ms,{readOnly:!0,rows:12,"aria-label":d.path,value:d.content,className:"max-h-96 bg-sunken text-mono-sm"})]},d.path)),S&&e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-3",children:[e.jsx(ra,{link:S}),S.policy.subscribe&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"sm","data-testid":"hub-skill-unsubscribe",disabled:x.isPending||!x.canWrite,onClick:V,children:l("ui.hub.skills.unsubscribe")}),e.jsx("span",{className:"text-meta text-ink-muted",children:l("ui.hub.skills.unsubscribe_help")})]}),x.error&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:l("ui.hub.subscriptions.save_failed",{setting:b==="subscribe"?l("ui.hub.subscriptions.subscribe"):l("ui.hub.skills.unsubscribe"),source:I})})]}),S&&ee&&e.jsx(pa,{kind:"skill",name:S.name,enabled:T}),j.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:l(Ps(j.error)?"ui.hub.skills.local_exists":"ui.hub.skills.pull_failed")}),j.data&&!j.data.reports?.some(d=>d.applied||d.outcome==="unchanged")&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-pull-failed",children:l("ui.hub.skills.pull_failed")}),j.data?.link&&j.data.reports?.some(d=>d.link_id===q&&d.direction==="pull"&&d.applied)&&e.jsx("output",{"data-testid":"hub-skill-installed",className:"text-body-sm text-ink",children:l("ui.hub.skills.installed_alias",{item:j.data.link.name,source:Gs(j.data.link)})}),o.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-unpull-failed",children:l("ui.hub.skills.unpull_failed")}),y.error&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger","data-testid":"hub-skill-subscribe-failed",children:l(Ps(y.error)?"ui.hub.skills.local_exists":"ui.hub.skills.subscribe_failed")}),!t&&e.jsx("p",{className:"text-meta text-ink-muted",children:l("ui.hub.status.no_credential")}),(!S||!ee)&&e.jsxs(Qe,{className:"flex-row flex-wrap justify-start gap-2",children:[e.jsx(P,{"data-testid":"hub-skill-download",disabled:!t||!te||j.isPending||!N,"aria-label":l("ui.hub.skills.pull_title",{item:k.data.name,source:I}),onClick:()=>ne(S),children:l("ui.hub.skills.download")}),!S?.policy.subscribe&&e.jsx(P,{variant:"outline","data-testid":"hub-skill-subscribe",disabled:!t||!te||!N||y.isPending||x.isPending||(S?!x.canWrite:!1),onClick:Le,children:l("ui.hub.subscriptions.subscribe")})]}),S&&ee&&e.jsx(Qe,{className:"flex-row flex-wrap justify-start gap-2",children:e.jsx(P,{variant:"outline","data-testid":"hub-skill-unpull",disabled:o.isPending,onClick:()=>{o.reset(),_(!0)},children:l("ui.hub.skills.unpull")})}),(!S||!ee)&&e.jsx("p",{className:"text-meta text-ink-muted",children:S?.policy.subscribe?l("ui.hub.skills.download_help"):l("ui.hub.skills.subscribe_help")})]})]})}),e.jsx(qe,{open:E,onOpenChange:d=>{d||_(!1)},children:e.jsxs(Ue,{className:"sm:max-w-md",children:[e.jsxs(He,{children:[e.jsx(Be,{children:l("ui.hub.skills.unpull_title",{item:k.data?.name??S?.name??""})}),e.jsx(Ke,{children:l("ui.hub.skills.unpull_body")})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"outline",onClick:()=>_(!1),children:l("ui.hub.subscriptions.cancel")}),e.jsx(P,{"data-testid":"hub-skill-unpull-confirm",disabled:o.isPending,onClick:()=>{Oe(),_(!1)},children:l("ui.hub.skills.unpull")})]})]})}),e.jsx(qe,{open:L,onOpenChange:f,children:e.jsxs(Ue,{className:"max-h-[85vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(He,{children:[e.jsx(Be,{children:l("ui.hub.skills.publish_title")}),e.jsx(Ke,{children:I})]}),e.jsx(Ba,{scope:s,source:I,verifiedCas:R&&a&&t,enabled:R&&a&&t,heading:!1})]})})]})}const st={all:["org-teams"],list:s=>[...st.all,"list",s]},tt=({tenantId:s,enabled:t=!0})=>{const a=ce({queryKey:st.list(s??""),queryFn:async()=>(await da(s)).result??{teams:[]},enabled:t&&!!s,staleTime:3e5,gcTime:6e5,refetchOnWindowFocus:!1,retryOnMount:!1,retry:es});return{...a,teams:a.data?.teams??[]}},Ya=(s,t)=>{const a=s?.name?.trim()||t?.trim()||"Team",i=s?.renamed_from?.trim()||null;return s?.invalid_name===!0&&i?{level:"warning",message:`Pulled "${a}". The published name "${i}" is not usable locally, so the team was stored as "${a}".`}:i?{level:"success",message:`Pulled "${a}" (you already have a team called "${i}").`}:{level:"success",message:`Pulled team "${a}".`}},at=()=>{const s=ie();return je({mutationFn:async({teamId:t,tenantId:a})=>{if(!G.baseUrl)throw new Error("Local Operator API URL is not configured.");return Ot.pullOrgTeamFromRadient(G.baseUrl,t,a)},onSuccess:(t,a)=>{const i=Ya(t.result,a.name);i.level==="warning"?At(i.message):Lt(i.message),s.invalidateQueries({queryKey:["desktop","teams"]})},onError:t=>{console.error("Pulling an organization team failed:",t)}})},Ga=/^v/i,it=s=>s.members.reduce((t,a)=>t+a.count,0),Ja=s=>s.count>1?`${s.role} ×${s.count}`:s.role,Ze=s=>s.members.map(Ja).join(", "),nt=s=>{const t=(s.version??"").trim().replace(Ga,"").trim();return t===""?null:t},lt=s=>{const t=s.account_metadata?.name?.trim();return t||null},Za=s=>{const t=(s.description??"").trim();return t===""?null:t},Xe=240,Xa=Xe/2,ei=(s,t)=>{if(t||s.length<=Xe)return s;const a=s.slice(0,Xe),i=a.lastIndexOf(" ");return`${(i>=Xa?a.slice(0,i):a).trimEnd()}…`},Pe=s=>fa(s,"d MMM yyyy"),Te=s=>{if(!s)return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t},Es=(s,t,a)=>{const i=a-t.getTime();let n;return i<0?n=Pe(t):i<6e4?n="just now":n=`${Qt(t,new Date(a))} ago`,{label:s,when:n,iso:t.toISOString(),exact:Pe(t)}},si=(s,t=Date.now())=>{const a=Te(s.updated_at);if(a)return Es("updated",a,t);const i=Te(s.created_date);return i?Es("created",i,t):null},ti=s=>{const t=Te(s.created_date),a=Te(s.updated_at);return{created:t?Pe(t):null,updated:a?Pe(a):null}},ai=s=>s==="role"?"Role":s==="specialist"?"Specialist":s,ii=["refresh-hub","retry","sign-in"],ni=({tenantId:s,orgName:t})=>{const{teams:a,isLoading:i,isFetching:n,isError:u,error:m,refetch:O}=tt({tenantId:s}),p=Js(m),v=at(),[E,_]=r.useState(null),[b,h]=r.useState(null),L=r.useRef(new Map),f=r.useRef(null);r.useEffect(()=>{v.isPending||f.current===null||(L.current.get(f.current)?.focus(),f.current=null)},[v.isPending]);const[w,I]=r.useState(!1),[F,T]=r.useState(()=>new Set),g=(o,x)=>T(A=>{const z=new Set(A);return x?z.add(o):z.delete(o),z}),R=(o,x)=>{o.key!=="Escape"||!F.has(x)||(o.target instanceof Element?o.target:null)?.closest('[data-testid="org-team-pull-error"]')||(g(x,!1),o.currentTarget.querySelector("button[aria-expanded]")?.focus(),o.preventDefault())},k=r.useMemo(()=>{if(!Us(v.error))return null;const o=a.find(x=>x.id===E);return Bs({code:v.error.code,message:v.error.message,details:v.error.details},{name:o?.name??"this team",hubAgentId:null,surface:"pull"})},[v.error,E,a]),j=(o,x)=>{switch(o){case"refresh-hub":O();break;case"retry":y(x);break;case"sign-in":I(!0);break}},y=o=>{v.isPending||(f.current=o.id,_(null),h(o.id),v.mutate({teamId:o.id,tenantId:s,name:o.name},{onSettled:()=>h(null),onError:()=>_(o.id)}))};return e.jsxs("section",{className:"mb-6 max-w-4xl rounded-md bg-surface","aria-label":`Teams shared with ${t??"this organization"}`,"data-testid":"org-teams",children:[i&&e.jsxs("div",{"aria-hidden":"true",className:"flex flex-col divide-y divide-hairline","data-testid":"org-teams-loading",children:[e.jsx(We,{}),e.jsx(We,{}),e.jsx(We,{})]}),!i&&u&&e.jsxs(be,{variant:p?"warning":"danger",className:"m-4 w-auto","data-testid":"org-teams-error",children:[e.jsx(pe,{children:p==="plan"?"That organization needs an active Team plan":p==="no_access"?"You do not have access to that organization":"Teams could not be loaded"}),e.jsx(ge,{children:p==="plan"?`Reading an organization's teams is part of the Team plan. An owner of ${t??"this organization"} can activate it in the Radient console, and then its teams will be listed here.`:p==="no_access"?`You are not a member of ${t??"that organization"}, so its teams are not listed here. An owner can invite you again.`:ss("The teams shared with this organization could not be read.",m)}),p!=="no_access"&&e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void O(),disabled:n,"aria-busy":n,children:n?"Trying…":"Try again"})})]}),!i&&!u&&a.length===0&&e.jsx("p",{className:"p-4 text-body-sm text-ink-muted","data-testid":"org-teams-empty",children:`Teams shared into ${t??"this organization"} appear here for its members.`}),!i&&!u&&a.length>0&&e.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:a.map(o=>e.jsxs("li",{className:U(rt,"transition-colors duration-fast ease-out-quart hover:bg-elevated first:rounded-t-md last:rounded-b-md"),onKeyDown:x=>R(x,o.id),children:[e.jsx(Hs,{className:"min-w-0",open:F.has(o.id),onOpenChange:x=>g(o.id,x),summaryAlign:"firstLine",triggerClassName:"min-w-0",chevronClassName:"text-ink-dim mt-1",rowClassName:"py-0",summary:e.jsx(ci,{team:o,expanded:F.has(o.id)}),trailing:e.jsx("div",{className:"-mt-1 ml-3 shrink-0 self-start",children:e.jsx(P,{ref:x=>{x?L.current.set(o.id,x):L.current.delete(o.id)},variant:"secondary",size:"sm",onClick:()=>y(o),disabled:v.isPending,"aria-label":`Pull team ${ae(o.name)}`,children:b===o.id?"Pulling…":"Pull"})}),children:e.jsx(oi,{team:o})}),E===o.id&&e.jsxs("div",{className:"mt-1 flex flex-col items-start gap-1 pl-5","data-testid":"org-team-pull-error",children:[e.jsx("output",{className:"text-meta text-danger",children:k?.body??v.error?.message??`"${ae(o.name)}" could not be pulled.`}),k?.actions.filter(x=>ii.includes(x)).map(x=>e.jsx(P,{variant:"primary",size:"sm",onClick:()=>j(x,o),children:Ks[x]},x)),w&&e.jsx("div",{className:"mt-1","data-testid":"org-team-pull-reauth",children:e.jsx(Zs,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{I(!1),_(null),O()}})})]})]},o.id))})]})},rt="px-4 py-3",ct=()=>e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:"mx-1.5",children:"·"}),e.jsx("span",{className:"sr-only",children:", "})]}),li=({team:s})=>{const t=s.manager?.trim(),a=it(s);return e.jsxs("span",{className:"block truncate text-meta",children:[t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:"Manager:"})," ",e.jsx("span",{className:"text-ink-muted",children:t})]}):null,t?e.jsx(ct,{}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:"No members"}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-ink-dim",children:[a," ",a===1?"member":"members",":"]})," ",e.jsx("span",{className:"text-ink-muted",children:Ze(s)})]})]})},ri=({team:s})=>{const t=s.project?.trim(),a=lt(s),i=si(s),n=[];return t&&n.push({key:"project",node:t}),a&&n.push({key:"author",node:a}),i&&n.push({key:"recency",node:e.jsxs(e.Fragment,{children:[i.label," ",e.jsx(le,{content:i.exact,children:e.jsx("time",{dateTime:i.iso,children:i.when})})]})}),n.length===0?null:e.jsx("span",{className:"block truncate text-ink-dim text-meta",children:n.map((u,m)=>e.jsxs("span",{children:[m>0?e.jsx(ct,{}):null,u.node]},u.key))})},ci=({team:s,expanded:t})=>{const a=Za(s),i=nt(s);return e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsxs("span",{className:"flex min-w-0 items-baseline",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:ae(s.name)}),i?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",i]}):null]}),a?e.jsxs(e.Fragment,{children:[e.jsx("span",{...Se,"aria-hidden":"true",className:U("mt-1 select-text break-words text-body-sm text-ink-muted",t?"line-clamp-[12] whitespace-pre-line":"line-clamp-2"),children:a}),e.jsx("span",{className:"sr-only",children:ei(a,t)})]}):e.jsx("span",{className:"mt-1 text-body-sm text-ink-dim",children:"No description"}),e.jsxs("span",{className:"mt-1 flex min-w-0 flex-col",children:[e.jsx(li,{team:s}),e.jsx(ri,{team:s})]})]})},oi=({team:s})=>{const t=s.manager?.trim(),a=ti(s),i=[a.created?`Created ${a.created}`:null,a.updated?`Updated ${a.updated}`:null].filter(u=>u!==null),n=!!t||s.members.length>0;return e.jsxs("div",{className:"mt-1 flex flex-col gap-2",children:[n||i.length===0?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Members"}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t}),e.jsx("span",{className:"text-ink-dim text-meta",children:"Manager"})]}):null,s.members.map(u=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:u.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:ai(u.kind)}),u.count>1?e.jsxs("span",{className:"text-ink-dim text-meta tabular-nums",children:["×",u.count]}):null]},`${u.kind}:${u.role}`)),n?null:e.jsx("li",{className:"text-ink-dim text-meta",children:"No members"})]})]}):null,i.length>0?e.jsx("p",{className:"text-ink-dim text-meta",children:i.join(" · ")}):null]})},We=()=>e.jsxs("div",{className:U(rt,"pl-9"),"data-testid":"org-team-skeleton-row",children:[e.jsx("div",{className:"flex h-[1lh] items-center text-body",children:e.jsx(C,{className:"h-4.5 w-40"})}),e.jsxs("div",{className:"mt-1 flex h-[2lh] flex-col justify-evenly text-body-sm",children:[e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-2/3"})]}),e.jsx("div",{className:"mt-1 flex h-[1lh] items-center text-meta",children:e.jsx(C,{className:"h-3 w-64"})}),e.jsx("div",{className:"flex h-[1lh] items-center text-meta",children:e.jsx(C,{className:"h-3 w-48"})})]}),ot=(s,t)=>t instanceof Ys?t.message:ss(s,t),di=["refresh-hub","retry","sign-in"],ui=({signedIn:s,onOpenSettings:t})=>{const[a,i]=r.useState(1),[n,u]=r.useState(""),{teams:m,isLoading:O,isFetching:p,isError:v,error:E,refetch:_,pagination:b}=Xs({page:a,perPage:ls}),h=at(),[L,f]=r.useState(null),[w,I]=r.useState(null),F=r.useRef(new Map),T=r.useRef(null);r.useEffect(()=>{h.isPending||T.current===null||(F.current.get(T.current)?.focus(),T.current=null)},[h.isPending]);const g=Vt(n.trim()),R=r.useMemo(()=>g?m.filter(N=>ae(N.name).toLowerCase().includes(g)||(N.description??"").toLowerCase().includes(g)):m,[m,g]),k=N=>{h.isPending||(f(null),I(N.id),T.current=N.id,h.mutate({teamId:N.id,name:N.name},{onSettled:()=>I(null),onError:()=>f(N.id)}))},j=r.useMemo(()=>{if(!Us(h.error))return null;const N=m.find(D=>D.id===L);return Bs({code:h.error.code,message:h.error.message,details:h.error.details},{name:N?.name??"this team",hubAgentId:null,surface:"pull"})},[h.error,L,m]),y=j?.body??(vt(h.error)==="unauthorized"?"The team could not be pulled: this machine has no Radient sign-in for the hub. Sign in on the settings page, then pull again.":"The team could not be pulled."),[o,x]=r.useState(!1),A=(N,D)=>{switch(N){case"refresh-hub":_();break;case"retry":k(D);break;case"sign-in":x(!0);break}},z=O&&m.length===0,H=b?.totalRecords??m.length,M=r.useRef(null),q=N=>{const D=n!=="";u(N),D&&N===""&&M.current?.focus()};return e.jsxs("section",{"aria-label":"Public teams",className:"flex flex-col","data-testid":"agent-hub-public-teams",children:[e.jsx("h2",{className:"sr-only",children:"Public teams"}),e.jsx("p",{className:"mb-3 max-w-3xl text-body-sm text-ink-muted",children:"Public teams are published to the hub by anyone and can be read here without signing in. Pulling one copies it into this machine's local team registry."}),s?null:e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2","data-testid":"agent-hub-public-teams-signed-out",children:[e.jsx("span",{className:"text-meta text-ink-dim",children:"Sign in to Radient to pull a team into this machine."}),e.jsx(P,{variant:"secondary",size:"sm",onClick:t,children:"Open settings to sign in"})]}),e.jsx("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:e.jsxs("div",{className:U("flex min-w-56 max-w-md flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(qs,{"aria-hidden":"true",className:"ml-2 shrink-0 text-ink-dim"}),e.jsx(Ie,{ref:M,type:"search",value:n,onChange:N=>q(N.target.value),placeholder:"Search teams","aria-label":"Search teams",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-public-teams-search"})]})}),z&&e.jsxs("div",{"aria-hidden":"true",className:"flex max-w-4xl flex-col gap-3","data-testid":"agent-hub-public-teams-loading",children:[e.jsx(Ye,{}),e.jsx(Ye,{}),e.jsx(Ye,{})]}),!z&&v&&e.jsxs(be,{variant:"danger",className:"w-auto max-w-2xl","data-testid":"agent-hub-public-teams-error",children:[e.jsx(pe,{children:"Public teams could not be loaded"}),e.jsx(ge,{children:ot("The public team catalogue could not be read.",E)}),e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void _(),disabled:p,"aria-busy":p,children:p?"Trying…":"Try again"})})]}),!z&&!v&&m.length===0&&e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-empty",children:"No teams have been published to the public hub yet."}),!z&&!v&&m.length>0&&e.jsxs(e.Fragment,{children:[!g||R.length>0?e.jsxs("p",{className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-public-teams-status",children:[g?`${R.length} of ${m.length} teams on this page match "${n.trim()}"`:`${H} ${H===1?"team":"teams"} in the public hub`,g?e.jsxs("span",{className:"text-ink-dim",children:[" ","· search covers the teams loaded here"]}):null]}):null,R.length===0?e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted","data-testid":"agent-hub-public-teams-search-miss",children:`No team on this page matches "${n.trim()}".`}):e.jsx("ul",{className:"flex max-w-4xl flex-col gap-3",children:R.map(N=>e.jsx(mi,{team:N,pulling:w===N.id,pullPending:h.isPending,onPull:k,pullButtonRef:D=>{D?F.current.set(N.id,D):F.current.delete(N.id)},failed:L===N.id,failureBody:y,treatment:j,onTreatmentAction:A,reauthenticating:o,onReauthenticated:()=>{x(!1),f(null),_()}},N.id))}),!g&&b&&b.totalPages>1&&e.jsx(is,{count:b.totalPages,page:b.page,onChange:N=>{i(N),M.current?.scrollIntoView({block:"nearest"})}})]})]})},mi=({team:s,pulling:t,pullPending:a,onPull:i,failed:n,failureBody:u,treatment:m,onTreatmentAction:O,reauthenticating:p,onReauthenticated:v,pullButtonRef:E})=>{const[_,b]=r.useState(!1),h=La({teamId:_?s.id:void 0}),L=ae(s.name),f=nt(s),w=lt(s),I=s.manager?.trim(),F=it(s),T=(s.description??"").trim();return e.jsxs("li",{className:"rounded-md bg-surface p-4","data-testid":"agent-hub-public-team","data-team-name":s.name,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline",children:[e.jsx("h3",{className:"truncate font-medium text-heading text-ink",children:L}),f?e.jsxs("span",{className:"ml-2 shrink-0 text-ink-dim text-meta",children:["v",f]}):null]}),T?e.jsx("p",{...Se,className:"mt-1 line-clamp-3 max-w-3xl select-text text-body-sm text-ink-muted",children:T}):e.jsx("p",{className:"mt-1 text-body-sm text-ink-dim",children:"No description"}),e.jsxs("p",{className:"mt-2 flex flex-wrap items-baseline gap-x-2 text-meta",children:[I?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-dim",children:"Manager:"}),e.jsx("span",{className:"text-ink-muted",children:I})]}):null,s.members.length===0?e.jsx("span",{className:"text-ink-dim",children:"No members"}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-ink-dim",children:[F," ",F===1?"member":"members",":"]}),e.jsx(le,{content:Ze(s),children:e.jsx("span",{className:"truncate text-ink-muted",children:Ze(s)})})]})]}),w?e.jsxs("p",{className:"mt-1 text-ink-dim text-meta",children:["Published by ",e.jsx("span",{className:"text-ink-muted",children:w})]}):null]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-2",children:[e.jsx(P,{ref:E,variant:"secondary",size:"sm",onClick:()=>i(s),disabled:a,"aria-label":`Pull team ${L}`,children:t?"Pulling…":"Pull"}),n&&e.jsxs("div",{className:"flex max-w-56 flex-col items-end gap-1","data-testid":"agent-hub-public-team-pull-error",children:[e.jsx("output",{className:"text-right text-meta text-danger",children:u}),m?.actions.filter(g=>di.includes(g)).map(g=>e.jsx(P,{variant:"primary",size:"sm",onClick:()=>O(g,s),children:Ks[g]},g)),p&&e.jsx("div",{"data-testid":"agent-hub-public-team-pull-reauth",children:e.jsx(Zs,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:v})})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Hs,{summary:"Brief",open:_,onOpenChange:b,className:"w-full",triggerClassName:"w-full",triggerLabel:`View the brief for ${L}`,chevronClassName:"text-ink-dim",children:e.jsx(hi,{detail:h})})})]})},hi=({detail:s})=>{if(s.isLoading)return e.jsxs("div",{className:"flex flex-col gap-1","data-testid":"agent-hub-public-team-brief-loading",children:[e.jsx(C,{className:"h-[1lh] w-2/3"}),e.jsx(C,{className:"h-[2lh] w-full"})]});if(s.isError)return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx("output",{className:"text-meta text-danger",children:ot("This team's brief could not be read.",s.error)}),e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void s.refetch(),disabled:s.isFetching,"aria-busy":s.isFetching,children:s.isFetching?"Trying…":"Try again"})]});const t=s.team;if(!t)return null;const a=(t.instructions??"").trim(),i=(t.project??"").trim();return e.jsxs("div",{className:"flex max-w-3xl flex-col gap-3 text-body-sm","data-testid":"agent-hub-public-team-brief",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Collaboration brief"}),a?e.jsx("p",{...Se,className:"whitespace-pre-line select-text text-ink-muted",children:a}):e.jsx("p",{className:"text-ink-dim",children:"This team has no collaboration brief."})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Project brief"}),i?e.jsx("p",{...Se,className:"whitespace-pre-line select-text text-ink-muted",children:i}):e.jsx("p",{className:"text-ink-dim",children:"This team has no project brief."})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-ink-dim text-meta",children:"Roster"}),e.jsxs("ul",{className:"flex flex-col gap-0.5",children:[t.manager?.trim()?e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:t.manager.trim()}),e.jsx("span",{className:"text-ink-dim text-meta",children:"Manager"})]}):null,t.members.length===0?e.jsx("li",{className:"text-ink-dim",children:"No members"}):t.members.map(n=>e.jsxs("li",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:n.count>1?`${n.role} ×${n.count}`:n.role}),e.jsx("span",{className:"text-ink-dim text-meta",children:n.kind})]},`${n.kind}:${n.role}`))]})]})]})},Ye=()=>e.jsxs("div",{className:"rounded-md bg-surface p-4",children:[e.jsx(C,{className:"h-[1lh] w-1/3"}),e.jsx(C,{className:"mt-1 flex h-[3lh] w-full"}),e.jsx(C,{className:"mt-2 h-[1lh] w-2/3"})]}),xi=(s,t)=>{const[a,i]=r.useState(s);return r.useEffect(()=>{const n=setTimeout(()=>i(s),t);return()=>clearTimeout(n)},[s,t]),a},we=[{value:"download_count:desc",label:"Most downloaded",sort:"download_count",order:"desc"},{value:"like_count:desc",label:"Most liked",sort:"like_count",order:"desc"},{value:"favourite_count:desc",label:"Most favourited",sort:"favourite_count",order:"desc"},{value:"created_at:desc",label:"Newest",sort:"created_at",order:"desc"},{value:"updated_at:desc",label:"Recently updated",sort:"updated_at",order:"desc"},{value:"name:asc",label:"Name (A to Z)",sort:"name",order:"asc"}],bi=[{value:"name",label:"Name"},{value:"description",label:"Description"}],pi=300,K="public",Fs={agents:"agent-hub-view-agents",teams:"agent-hub-view-teams",skills:"agent-hub-view-skills"},$s="agent-hub-view-panel",gi=()=>e.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-md bg-surface",children:[e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 p-4",children:[e.jsx(C,{className:"h-5.5 w-2/3"}),e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-full"}),e.jsx(C,{className:"h-3.5 w-1/2"}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(C,{className:"h-5.5 w-24"}),e.jsx(C,{className:"h-5.5 w-20"})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx(C,{className:"h-5.5 w-24"})})]}),e.jsx(C,{className:"h-4.5 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-t border-hairline px-3 py-2",children:[e.jsx(C,{className:"size-4"}),e.jsx(C,{className:"h-4 w-6"}),e.jsx(C,{className:"size-4"}),e.jsx(C,{className:"h-4 w-6"}),e.jsx(C,{className:"ml-auto h-7 w-16"})]})]}),Ei=()=>{const s=zs(),{isAuthenticated:t}=ts(),[a,i]=r.useState(1),[n]=r.useState(12),[u,m]=r.useState(null),[O,p]=r.useState(""),[v,E]=r.useState("name"),[_,b]=r.useState(we[0].value),[h,L]=r.useState(K),[f,w]=r.useState("agents");ke();const[I,F]=r.useState([]),T=xi(O,pi),g=we.find(c=>c.value===_)??we[0],R=Ce(),k=!R.isError&&re(R.data,"hub_skills"),j=f==="skills"&&!k?"agents":f;r.useEffect(()=>{f==="skills"&&!k&&w("agents")},[f,k]);const y=Et(),o=Nt(R.data,"radient_org"),x=t?ka(o,y??null):null,{memberships:A}=ua({enabled:Ve(o)}),z=r.useMemo(()=>ga(A),[A]),H=h===K||z.some(c=>c.tenant_id===h);r.useEffect(()=>{!H&&j!=="skills"&&L(K)},[H,j]);const M=h===K?null:z.find(c=>c.tenant_id===h)??null,q=M?.tenant_id,N=M?.tenant_name||null,D=u!==null||T!=="",se=tt({tenantId:q}),te=Xs({page:1,perPage:ls,enabled:h===K}),de=q&&se.isSuccess?se.teams.length:null,ye=te.isSuccess?te.pagination?.totalRecords??null:null,Q=D?null:h===K?ye:de,S=h===K?{visibility:"public",tenantId:null}:{visibility:"org",tenantId:h},ve=H&&(h===K||Ve(o)),ue=et(S,1,k&&ve&&(h===K||t)),ee=ue.isSuccess?ue.data.total:null,Ae=M?.role==="owner"||M?.role==="admin",me=r.useMemo(()=>new Map(A.map(c=>[c.tenant_id,c.tenant_name])),[A]),{data:ne,agents:Le,isLoading:Oe,isFetching:V,error:J,refetch:he,pagination:B}=zt({page:a,perPage:n,categories:u?[u]:void 0,name:v==="name"&&T||void 0,description:v==="description"&&T||void 0,sort:g.sort,order:g.order,tenantId:q}),d=M?Js(J):null,$=Le??[],Z=V&&ne!==void 0,{statuses:xe,isKnown:Ne,isError:dt,isFetching:Ee,refetch:ut}=Wt({agentIds:q?[]:$.map(c=>c.id)}),Fe=r.useRef(null),$e=r.useRef(null),[os,mt]=r.useState(0);r.useEffect(()=>{os!==0&&(Fe.current??$e.current)?.focus()},[os]);const ds=r.useRef(null),ze=r.useRef(!1),Me=r.useMemo(()=>[...new Set((ne?.records??[]).flatMap(c=>c.categories??[]))],[ne]);r.useEffect(()=>{F(c=>Me.every(Y=>c.includes(Y))?c:[...new Set([...c,...Me])])},[Me]);const ht=()=>{m(null),p(""),i(1),mt(c=>c+1)},W=(Oe||V)&&ne===void 0,us=!W&&!D&&(J!==null||$.length===0);r.useEffect(()=>{!ze.current||W||(ze.current=!1,J?ds.current?.focus():(Fe.current??$e.current)?.focus())},[W,J]);const ms=r.useRef(null),xt=c=>{i(c),ms.current?.scrollIntoView({block:"nearest"})},bt=c=>{m(c),i(1)},pt=c=>{p(c),i(1)},gt=c=>{L(c),i(1)},hs=r.useRef(new Map),ft=c=>{E(c),i(1)},kt=B&&!D?B.totalRecords:null,De=q?`shared with ${N??"this organization"}`:"in the public hub",xs=(c,Y)=>`${c} ${Y}${c===1?"":"s"} ${De}`;let X;return j==="skills"?X=" ":j==="teams"?q?se.isLoading?X="Loading teams…":Q!==null?X=xs(Q,"team"):X=`Teams ${De}`:X=" ":W?X="Loading agents…":B?X=xs(B.totalRecords,"agent"):X=`Agents ${De}`,e.jsxs("div",{className:"flex h-full flex-col gap-8 p-6",children:[e.jsx(wt,{title:"Agent Hub",subtitle:"Discover and download agents, teams and skills on Radient",icon:ma}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[x&&e.jsxs(be,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-unavailable",children:[e.jsx(pe,{children:"Organizations are unavailable"}),e.jsx(ge,{children:x})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2","data-testid":"agent-hub-browse-bar",children:[e.jsx(Pt,{value:j,onValueChange:c=>w(c),children:e.jsx(Tt,{"aria-label":"Browse the hub by type",children:["agents","teams",...k?["skills"]:[]].map(c=>{const Y=c==="agents"?kt:c==="teams"?Q:ee;return e.jsxs(Ct,{value:c,id:Fs[c],"aria-controls":j===c?$s:void 0,"data-testid":`agent-hub-view-${c}`,children:[c==="agents"?"Agents":c==="teams"?"Teams":l("ui.hub.skills.title"),Y!==null&&e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:Y})]},c)})})}),z.length>0&&e.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0","data-testid":"agent-hub-scope",children:[e.jsx("legend",{className:"sr-only",children:"Show the hub of"}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:[{value:K,label:"Public hub",Icon:Ft},...z.map(c=>({value:c.tenant_id,label:c.tenant_name||"Organization",Icon:ja}))].map(({value:c,label:Y,Icon:jt})=>e.jsxs(P,{ref:bs=>{bs?hs.current.set(c,bs):hs.current.delete(c)},variant:"ghost",size:"sm","aria-pressed":h===c,onClick:()=>gt(c),title:Y,"data-testid":`agent-hub-scope-${c===K?"public":`org-${c}`}`,className:U("max-w-48",h===c&&"bg-surface text-ink hover:bg-surface"),children:[e.jsx(jt,{"aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:Y})]},c))})]})]})]}),e.jsx(It,{id:$s,labelledBy:Fs[j],children:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-row overflow-hidden",children:[j==="agents"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"mr-6 hidden w-60 shrink-0 rounded-md bg-surface p-2 md:block","data-glass-region":"panel","data-tour-tag":"agent-hub-sidebar-container",children:!us&&e.jsx(_a,{selectedCategory:u,onSelectCategory:bt,categories:I})})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-y-auto",children:[j==="agents"&&!us&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:U("flex min-w-56 flex-1 items-center rounded-sm border border-control bg-surface","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[e.jsx(Ie,{ref:Fe,type:"search",value:O,onChange:c=>pt(c.target.value),placeholder:"Search agents","aria-label":"Search agents",className:"h-8 min-w-0 flex-1 border-0 bg-transparent outline-none","data-testid":"agent-hub-search"}),e.jsxs(gs,{value:v,onValueChange:ft,children:[e.jsx(fs,{className:"w-auto shrink-0 border-y-0 border-l border-hairline border-r-0 bg-transparent pl-2 outline-none","aria-label":"Search in","data-testid":"agent-hub-search-scope",children:e.jsx(ks,{})}),e.jsx(js,{children:bi.map(c=>e.jsx(ys,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs(gs,{value:_,onValueChange:b,children:[e.jsx(fs,{className:"w-48","aria-label":"Sort agents","data-testid":"agent-hub-sort",children:e.jsx(ks,{})}),e.jsx(js,{children:we.map(c=>e.jsx(ys,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("p",{ref:ms,"aria-live":"polite",className:"mb-3 text-meta text-ink-dim","data-testid":"agent-hub-status",children:[X,j==="agents"&&Z?e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{"data-testid":"agent-hub-updating",children:"Updating…"})]}):null]}),j==="agents"&&e.jsxs(e.Fragment,{children:[t&&dt&&e.jsxs("output",{className:"mb-3 flex flex-wrap items-center gap-2 text-meta text-warning","data-testid":"agent-hub-status-unknown",children:[e.jsx("span",{children:"Your likes and favourites could not be read, so no card shows a viewer state."}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>void ut(),disabled:Ee,"aria-busy":Ee,children:Ee?"Trying…":"Try again"})]}),W&&e.jsx("div",{"data-testid":"agent-hub-loading",className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6",children:Array.from({length:6},(c,Y)=>e.jsx(gi,{},Y))}),W&&B===void 0&&e.jsx("div",{"aria-hidden":"true",className:"mt-6 flex min-h-13 items-center justify-center","data-testid":"agent-hub-pager-placeholder",children:e.jsx(C,{className:"h-4 w-24"})}),e.jsx("output",{"aria-live":"polite","data-testid":"agent-hub-outage",className:U(!W&&J&&!d?"block":"sr-only"),children:!W&&J&&!d&&e.jsxs(be,{variant:"danger",className:"max-w-2xl","aria-busy":V,"data-testid":"agent-hub-error",children:[e.jsx(pe,{children:t?"The hub could not be loaded":"Sign in to use the hub"}),e.jsx(ge,{children:t?ss("The agent list could not be loaded.",J):"You are not signed in to Radient, so the hub has no credential to read the agent list with. Sign in on the settings page, then try again."}),e.jsx("div",{className:"mt-2",children:e.jsx(P,{ref:ds,variant:"outline",size:"sm",onClick:()=>{ze.current=!0,he()},disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]})}),!W&&d&&M&&e.jsxs(be,{variant:"warning",className:"max-w-2xl","data-testid":"agent-hub-org-no-access",children:[e.jsx(pe,{children:d==="plan"?"That organization needs an active Team plan":"You do not have access to that organization"}),e.jsx(ge,{children:d==="plan"?`Sharing agents inside an organization is part of the Team plan. An owner of ${M.tenant_name||"this organization"} can activate it in the Radient console, and then its agents will be listed here.`:`You are not a member of ${M.tenant_name||"that organization"}, so its agents are not listed here. An owner can invite you again.`}),d==="plan"&&e.jsx("div",{className:"mt-2",children:e.jsx(P,{variant:"primary",size:"sm",onClick:()=>void he(),disabled:V,"aria-busy":V,children:V?"Trying…":"Try again"})})]}),!W&&!J&&e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(17.5rem,1fr))] gap-6","aria-busy":Z,children:$.length===0?e.jsxs("div",{"data-testid":"agent-hub-empty",className:U("col-span-full w-full flex flex-col items-center gap-2 rounded-md bg-surface px-6 py-10 text-center",!q&&"max-w-2xl justify-self-center"),children:[e.jsx("p",{className:"text-heading text-ink",children:q?"This organization has no shared agents yet.":u?`No agents in ${Qs(u).label}.`:D?"No agents match that search.":"The hub is empty."}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:q?`Agents published into ${M?.tenant_name||"this organization"} appear here for its members.`:u?"Nothing in this category yet. Clear the filter to see the whole hub.":D?"No agent's name or description carries that. Clear it to see the whole hub.":"Nobody has published an agent yet. Yours could be the first."}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-2",children:D?e.jsx(P,{variant:"secondary",onClick:ht,children:u?"Clear filter":"Clear search"}):q&&!Ae?null:e.jsx(P,{ref:$e,variant:"secondary",onClick:()=>s("/agents"),children:"Publish an agent"})})]}):$.map(c=>e.jsx(wa,{agent:c,status:t?xe[c.id]:void 0,viewerStateKnown:t&&Yt(Ne,xe,c.id),orgName:c.visibility==="org"?me.get(c.tenant_id)??null:null},c.id))}),!W&&B&&B.totalPages>1&&e.jsx(is,{count:B.totalPages,page:B.page,onChange:xt})]}),j==="skills"&&(k?e.jsx(Wa,{scope:h===K?{visibility:"public",tenantId:null,organization:null}:{visibility:"org",tenantId:h,organization:N},signedIn:t,accessible:H&&(h===K||Ve(o))},`skills:${h}`):e.jsx("p",{className:"text-body-sm text-warning",children:l("ui.hub.skills.unavailable")})),j==="teams"&&(M?e.jsx(ni,{tenantId:M.tenant_id,orgName:N}):e.jsx(ui,{signedIn:t,onOpenSettings:()=>s("/settings")}))]})]})})]})]})};export{Ei as AgentHubPage};