@axiom-lattice/gateway 4.2.0 → 4.2.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 (103) hide show
  1. package/dist/{A2AAuthService-DK5X6VIL.mjs → A2AAuthService-7UGQ7GMW.mjs} +3 -2
  2. package/dist/{WechatChannelAdapter-WSDKR4OA.mjs → WechatChannelAdapter-7WHE5UGY.mjs} +2 -1
  3. package/dist/{WechatChannelAdapter-WSDKR4OA.mjs.map → WechatChannelAdapter-7WHE5UGY.mjs.map} +1 -1
  4. package/dist/{a2a-7N3WDAOP.mjs → a2a-FGYX2HH3.mjs} +71 -32
  5. package/dist/a2a-FGYX2HH3.mjs.map +1 -0
  6. package/dist/{a2a-standard-WC2BSOFV.mjs → a2a-standard-VEQBXBMM.mjs} +93 -115
  7. package/dist/a2a-standard-VEQBXBMM.mjs.map +1 -0
  8. package/dist/agentProvider-X4FVQPKW.mjs +88 -0
  9. package/dist/agentProvider-X4FVQPKW.mjs.map +1 -0
  10. package/dist/chunk-2POW27EI.mjs +27 -0
  11. package/dist/chunk-2POW27EI.mjs.map +1 -0
  12. package/dist/chunk-52SUWMOX.mjs +121 -0
  13. package/dist/chunk-52SUWMOX.mjs.map +1 -0
  14. package/dist/chunk-GF4GGTWJ.mjs +164 -0
  15. package/dist/chunk-GF4GGTWJ.mjs.map +1 -0
  16. package/dist/{chunk-2HOCF46L.mjs → chunk-GPHOYR3X.mjs} +33 -11
  17. package/dist/chunk-GPHOYR3X.mjs.map +1 -0
  18. package/dist/chunk-NFEGQTCC.mjs +27 -0
  19. package/dist/chunk-PWHUWFXL.mjs +173 -0
  20. package/dist/chunk-PWHUWFXL.mjs.map +1 -0
  21. package/dist/chunk-QUT2DS4R.mjs +50 -0
  22. package/dist/chunk-QUT2DS4R.mjs.map +1 -0
  23. package/dist/chunk-TJAUXMYJ.mjs +109 -0
  24. package/dist/chunk-TJAUXMYJ.mjs.map +1 -0
  25. package/dist/chunk-WKNZ7GBC.mjs +56 -0
  26. package/dist/chunk-WKNZ7GBC.mjs.map +1 -0
  27. package/dist/collection_service-RTRJEQFL.mjs +8 -0
  28. package/dist/embed/agent-chat-loader.js +1 -1
  29. package/dist/embed/{embed-page-AgentDetailSideApp-6CVXM3P3.js → embed-page-AgentDetailSideApp-DTDBMB2U.js} +1 -1
  30. package/dist/embed/{embed-page-AgentDetailSideApp-DRGKJ6C5.css → embed-page-AgentDetailSideApp-O6G4NJ7I.css} +1 -1
  31. package/dist/embed/{embed-page-AgentGovernanceWorkbench-4B3NJPCY.js → embed-page-AgentGovernanceWorkbench-JUP6SNBX.js} +1 -1
  32. package/dist/embed/embed-page-AgentGovernanceWorkbench-SFZNVMUH.css +1 -0
  33. package/dist/embed/embed-page-MessageGraph-H5S7SARE.js +6 -0
  34. package/dist/embed/{embed-page-ReactChart-OG5Z43H7.js → embed-page-ReactChart-FWXMXO7F.js} +1 -1
  35. package/dist/embed/{embed-page-SkillFlow-GS4OUCJJ.js → embed-page-SkillFlow-SFZ5HLMK.js} +1 -1
  36. package/dist/embed/{embed-page-TasksSideApp-I6Z7BOT2.js → embed-page-TasksSideApp-Q6HTW6S6.js} +1 -1
  37. package/dist/embed/{embed-page-TeamWorkspace-LSCUIJDA.js → embed-page-TeamWorkspace-6KFWCIKW.js} +4 -4
  38. package/dist/embed/{embed-page-TopologyRuntimeView-RY7NOUB7.js → embed-page-TopologyRuntimeView-MASWKWXA.js} +1 -1
  39. package/dist/embed/{embed-page-WorkflowAutomationView-RNKIKDUX.js → embed-page-WorkflowAutomationView-6UOT36GW.js} +1 -1
  40. package/dist/embed/{embed-page-chunk-4BIOW547.js → embed-page-chunk-2WCPJYBC.js} +1 -1
  41. package/dist/embed/{embed-page-chunk-7CFGO35V.js → embed-page-chunk-3EUETTEM.js} +1 -1
  42. package/dist/embed/{embed-page-chunk-4X5XHAMX.js → embed-page-chunk-74BPRLSV.js} +4 -4
  43. package/dist/embed/embed-page-chunk-7SO4HHS4.js +4084 -0
  44. package/dist/embed/{embed-page-chunk-DVHOG6AY.js → embed-page-chunk-AC6X2XRH.js} +1 -1
  45. package/dist/embed/{embed-page-chunk-SU5GXLKX.js → embed-page-chunk-AVZ7FKIO.js} +4 -4
  46. package/dist/embed/{embed-page-chunk-EPEKIAZP.js → embed-page-chunk-FJ3SFKJY.js} +1 -1
  47. package/dist/embed/{embed-page-chunk-Q32Y7CP2.js → embed-page-chunk-IV5C4DYL.js} +1 -1
  48. package/dist/embed/{embed-page-chunk-KGX7G7XQ.js → embed-page-chunk-KEL6XU6R.js} +1 -1
  49. package/dist/embed/{embed-page-chunk-BZI3YCE7.js → embed-page-chunk-N46WJ2FS.js} +1 -1
  50. package/dist/embed/embed-page-chunk-NFLB3VUZ.js +245 -0
  51. package/dist/embed/{embed-page-chunk-AYOVLRHX.js → embed-page-chunk-NHOWQIND.js} +182 -70
  52. package/dist/embed/{embed-page-chunk-KG5A66WX.js → embed-page-chunk-O4QK5LWZ.js} +83 -83
  53. package/dist/embed/{embed-page-chunk-JLWIJ4BP.js → embed-page-chunk-X4DK4JRG.js} +1 -1
  54. package/dist/embed/{embed-page-chunk-ESLOGPBN.js → embed-page-chunk-Z7USDLHI.js} +1 -1
  55. package/dist/embed/{embed-page-code-highlighter-TBT4ICNZ.js → embed-page-code-highlighter-Y6CQA4CN.js} +1 -1
  56. package/dist/embed/{embed-page-mermaid-TBO3M7GX.js → embed-page-mermaid-CW4QCAH3.js} +1 -1
  57. package/dist/embed/embed-page.css +1 -1
  58. package/dist/embed/embed-page.js +1 -1
  59. package/dist/index.js +2067 -585
  60. package/dist/index.js.map +1 -1
  61. package/dist/index.mjs +374 -348
  62. package/dist/index.mjs.map +1 -1
  63. package/dist/kbProvider-2D6DZ34N.mjs +50 -0
  64. package/dist/kbProvider-2D6DZ34N.mjs.map +1 -0
  65. package/dist/{mcp-configs-IIKQM5GM.mjs → mcp-configs-WCY5EXCW.mjs} +2 -1
  66. package/dist/mcp-configs-WCY5EXCW.mjs.map +1 -0
  67. package/dist/{mcpTransportRegistry-XMJ5Y2RG.mjs → mcpTransportRegistry-VXUVJKBC.mjs} +2 -1
  68. package/dist/mcpTransportRegistry-VXUVJKBC.mjs.map +1 -0
  69. package/dist/open-HH7RKGML.mjs +260 -0
  70. package/dist/open-HH7RKGML.mjs.map +1 -0
  71. package/dist/open-audit-UJ3NXCGW.mjs +32 -0
  72. package/dist/open-audit-UJ3NXCGW.mjs.map +1 -0
  73. package/dist/open-catalog-WYS2AENM.mjs +59 -0
  74. package/dist/open-catalog-WYS2AENM.mjs.map +1 -0
  75. package/dist/open-exposure-FK4G6O6L.mjs +67 -0
  76. package/dist/open-exposure-FK4G6O6L.mjs.map +1 -0
  77. package/dist/open-files-GVRMK5PL.mjs +146 -0
  78. package/dist/open-files-GVRMK5PL.mjs.map +1 -0
  79. package/dist/open-session-3VN65PRR.mjs +53 -0
  80. package/dist/open-session-3VN65PRR.mjs.map +1 -0
  81. package/dist/openLattice-GAAGQJST.mjs +16 -0
  82. package/dist/openLattice-GAAGQJST.mjs.map +1 -0
  83. package/dist/registerExposedPlugins-63EUF4VS.mjs +99 -0
  84. package/dist/registerExposedPlugins-63EUF4VS.mjs.map +1 -0
  85. package/dist/{resources-VA7LSDKN.mjs → resources-SRQRKW5G.mjs} +47 -4
  86. package/dist/resources-SRQRKW5G.mjs.map +1 -0
  87. package/dist/sandboxProvider-I3P66VXT.mjs +10 -0
  88. package/dist/sandboxProvider-I3P66VXT.mjs.map +1 -0
  89. package/dist/{sender-PX32VSHB.mjs → sender-PLDU5EZ3.mjs} +3 -1
  90. package/dist/{sender-PX32VSHB.mjs.map → sender-PLDU5EZ3.mjs.map} +1 -1
  91. package/package.json +7 -7
  92. package/dist/a2a-7N3WDAOP.mjs.map +0 -1
  93. package/dist/a2a-standard-WC2BSOFV.mjs.map +0 -1
  94. package/dist/chunk-2HOCF46L.mjs.map +0 -1
  95. package/dist/embed/embed-page-chunk-A2LQIHX4.js +0 -261
  96. package/dist/embed/embed-page-chunk-OWGBADV6.js +0 -3880
  97. package/dist/open-DCAOL5CG.mjs +0 -176
  98. package/dist/open-DCAOL5CG.mjs.map +0 -1
  99. package/dist/resources-VA7LSDKN.mjs.map +0 -1
  100. /package/dist/{A2AAuthService-DK5X6VIL.mjs.map → A2AAuthService-7UGQ7GMW.mjs.map} +0 -0
  101. /package/dist/{mcp-configs-IIKQM5GM.mjs.map → chunk-NFEGQTCC.mjs.map} +0 -0
  102. /package/dist/{mcpTransportRegistry-XMJ5Y2RG.mjs.map → collection_service-RTRJEQFL.mjs.map} +0 -0
  103. /package/dist/embed/{embed-page-AgentGovernanceWorkbench-SDS3GBCC.css → embed-page-MessageGraph-TYOOATYV.css} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as jr,d as zr}from"./embed-page-chunk-SU5GXLKX.js";import{Aa as xn,Fa as wn,G as Do,Ga as Nt,H as an,Ha as Cn,Ia as w,Ja as Sn,K as sn,Ka as Ie,L as ln,M as it,Ma as Jt,N as Fo,Na as et,Oa as $o,Pa as at,Qa as xe,Ra as Zt,S as cn,Sa as Rn,Ta as eo,U as Mt,V as dn,W as pn,X as mn,_a as Lo,a as Lr,aa as Yt,b as Or,c as Ze,d as Gt,ea as un,f as tn,ga as Xt,ha as gn,hb as kn,ib as Tn,j as At,kb as Pn,l as on,la as fn,ma as He,mb as Oo,o as rn,oa as jo,p as Qt,pa as yn,qa as hn,r as Et,va as zo,w as nn,wa as vn,za as bn}from"./embed-page-chunk-OWGBADV6.js";import{f as Fr,i as Ve,k as $r,m as _r,o as Wr,p as Te,q as me}from"./embed-page-chunk-4X5XHAMX.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{$ as Wt,$b as Vr,Ca as Br,Eb as Kt,Ec as Jr,Fa as wt,Gc as Zr,Ia as Ce,Ic as Ht,Ja as Le,Jc as Vt,La as E,Lc as en,Ma as Dr,Tb as Hr,V as It,Va as Mo,W as j,Y as Eo,Z as we,_ as Fe,aa as $e,bc as Gr,fc as Qr,ia as _e,la as Mr,mb as Ct,mc as qt,na as Nr,oa as ce,ob as Ur,pa as qe,qb as Kr,qc as ft,sb as No,ta as q,tb as qr,va as de,wa as ke,wc as Yr,xa as H,ya as pe,yb as Bo,yc as Xr}from"./embed-page-chunk-KG5A66WX.js";import{a as S}from"./embed-page-chunk-4BKXE5ON.js";import{e as n}from"./embed-page-chunk-6Y3UYJ6Z.js";var An=n(s()),Zi=w(({token:e,css:t})=>({button:t`
1
+ import{a as it,b as qt,c as Kn,d as Hn}from"./embed-page-chunk-AVZ7FKIO.js";import{a as Fr}from"./embed-page-chunk-X4DK4JRG.js";import{$ as Zt,$a as Dt,Ea as Ir,F as jo,Fa as Bt,G as ur,Ga as Ar,Ha as w,Ia as Er,J as gr,Ja as Ie,K as fr,L as at,La as to,M as $o,Ma as tt,Na as Oo,Oa as st,Pa as Se,Qa as oo,R as yr,Ra as Nr,Sa as no,T as kt,U as hr,V as vr,W as br,a as Vn,b as Gn,c as et,d as Xt,da as xr,f as cr,fa as eo,ga as wr,ib as Mr,j as Nt,ka as Cr,l as dr,la as Ve,mb as Br,na as Lo,o as pr,oa as Sr,ob as Dr,p as Jt,pa as kr,qb as Wo,r as Mt,ua as _o,va as Rr,w as mr,ya as Tr,za as Pr}from"./embed-page-chunk-7SO4HHS4.js";import{f as Un,i as Oe,k as qn,m as Qn,o as Yn,p as Ce,q as me}from"./embed-page-chunk-74BPRLSV.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{$ as Ht,$b as tr,Ac as ir,Ca as On,Eb as Vt,Fa as Ct,Gc as ar,Ia as ve,Ic as sr,Ja as _e,Kc as Qt,La as P,Lc as Yt,Ma as Wn,Nc as lr,Tb as er,V as Et,Va as Do,W as z,Y as Mo,Z as xe,_ as Ee,aa as ze,bc as or,fc as nr,ia as Le,la as _n,mb as St,mc as Gt,na as Bo,oa as ce,ob as Xn,pa as qe,qb as Jn,rc as ft,sb as Fo,ta as H,tb as Zn,va as ne,wa as Te,xa as q,ya as pe,yb as zo,yc as rr}from"./embed-page-chunk-O4QK5LWZ.js";import{a as C}from"./embed-page-chunk-4BKXE5ON.js";import{e as n}from"./embed-page-chunk-6Y3UYJ6Z.js";var zr=n(s()),da=w(({token:e,css:t})=>({button:t`
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -19,7 +19,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
19
19
  background: ${e.colorBgTextHover};
20
20
  border-color: ${e.colorBorderSecondary};
21
21
  }
22
- `})),St=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:a}=Zi();return(0,An.jsx)(j,{type:"text",size:"small",className:a.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var _o=n(s()),Wo=()=>{let{toolsVisible:e,toggleTools:t}=xe();return(0,_o.jsx)(St,{ariaLabel:"Toggle file directory",icon:(0,_o.jsx)(it,{size:16}),onClick:t,pressed:e})};var ye=n(S());var We=n(S());var to=n(S());function Uo(e){let[t,o]=(0,to.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,to.useEffect)(()=>{let r=window.matchMedia(e),a=i=>{o(i.matches)};return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}var Se=n(s()),yt=({main:e,detail:t,tools:o,logo:r,menu:a,header:i,mainStyle:d})=>{let{styles:c}=Zt(),{detailVisible:p,detailSize:g,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:h,contentAppSelectedCard:u,menuCollapsed:m,setMenuCollapsed:v,closeDetail:_,closeTools:L}=xe(),A=Uo("(max-width: 768px)"),Y=p||(m??A),ee=p&&!A,le=Y?"collapsed":"expanded",V=p||x,C=x&&(g||"large")==="large"?"middle":g||"large";return(0,Se.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[a&&(0,Se.jsxs)("div",{className:`${c.menu} ${le} ${ee?c.menuSnap:""}`,children:[r,a]}),(0,Se.jsxs)("div",{className:c.contentArea,children:[(i||A&&a)&&(0,Se.jsxs)("div",{className:c.header,children:[A&&a?(0,Se.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>v(!Y),"aria-label":"Toggle menu",children:(0,Se.jsx)(gn,{size:18})}):null,i]}),(0,Se.jsxs)("div",{className:c.columns,style:{gap:V?void 0:0},children:[(0,Se.jsx)("div",{className:`${c.mainContent} ${V?"open":""}`,children:(0,Se.jsx)("div",{className:`${c.chat} ${u?"full_content_width":""}`,style:d,children:e})}),(0,Se.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${C}`:""}`,children:[p&&A&&(0,Se.jsx)("button",{className:c.mobilePanelClose,onClick:_,"aria-label":"Close detail panel",children:(0,Se.jsx)(Nt,{size:20})}),p&&b&&t?(0,Se.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,Se.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&A&&(0,Se.jsx)("button",{className:c.mobilePanelClose,onClick:L,"aria-label":"Close tool panel",children:(0,Se.jsx)(Nt,{size:20})}),x&&o?(0,Se.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Pe=n(S());var M=n(s()),En={wrapper:{background:"transparent",borderRadius:"0 24px 24px 0"},content:{background:"rgba(255, 255, 255, 0.72)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)"},header:{background:"transparent",borderBottom:"1px solid rgba(0, 0, 0, 0.06)"},body:{padding:0}},ea=w(({token:e,css:t})=>({sidebar:t`
22
+ `})),Rt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:a}=da();return(0,zr.jsx)(z,{type:"text",size:"small",className:a.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Uo=n(s()),Ko=()=>{let{toolsVisible:e,toggleTools:t}=Se();return(0,Uo.jsx)(Rt,{ariaLabel:"Toggle file directory",icon:(0,Uo.jsx)(at,{size:16}),onClick:t,pressed:e})};var he=n(C());var Ue=n(C());var ro=n(C());function yt(e){let[t,o]=(0,ro.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,ro.useEffect)(()=>{let r=window.matchMedia(e),a=i=>{o(i.matches)};return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[e]),t}var ke=n(s()),ht=({main:e,detail:t,tools:o,logo:r,menu:a,header:i,mainStyle:d})=>{let{styles:c}=oo(),{detailVisible:p,detailSize:g,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:h,contentAppSelectedCard:u,menuCollapsed:m,setMenuCollapsed:v,closeDetail:O,closeTools:L}=Se(),E=yt("(max-width: 768px)"),Y=p||(m??E),ee=p&&!E,de=Y?"collapsed":"expanded",V=p||x,S=x&&(g||"large")==="large"?"middle":g||"large";return(0,ke.jsxs)("div",{className:`fina_chat ${c.layout}`,children:[a&&(0,ke.jsxs)("div",{className:`${c.menu} ${de} ${ee?c.menuSnap:""}`,children:[r,a]}),(0,ke.jsxs)("div",{className:c.contentArea,children:[(i||E&&a)&&(0,ke.jsxs)("div",{className:c.header,children:[E&&a?(0,ke.jsx)("button",{className:c.mobileMenuToggle,onClick:()=>v(!Y),"aria-label":"Toggle menu",children:(0,ke.jsx)(wr,{size:18})}):null,i]}),(0,ke.jsxs)("div",{className:c.columns,style:{gap:V?void 0:0},children:[(0,ke.jsx)("div",{className:`${c.mainContent} ${V?"open":""}`,children:(0,ke.jsx)("div",{className:`${c.chat} ${u?"full_content_width":""}`,style:d,children:e})}),(0,ke.jsxs)("div",{className:`${c.detailPanel} ${p?`open ${S}`:""}`,children:[p&&E&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:O,"aria-label":"Close detail panel",children:(0,ke.jsx)(Bt,{size:20})}),p&&b&&t?(0,ke.jsx)("div",{className:c.detailContent,children:t}):null]}),(0,ke.jsxs)("div",{className:`${c.toolPanel} ${x?"open":""}`,children:[x&&E&&(0,ke.jsx)("button",{className:c.mobilePanelClose,onClick:L,"aria-label":"Close tool panel",children:(0,ke.jsx)(Bt,{size:20})}),x&&o?(0,ke.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Pe=n(C());var N=n(s()),jr={wrapper:{background:"transparent",borderRadius:"0 24px 24px 0"},content:{background:"rgba(255, 255, 255, 0.72)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)"},header:{background:"transparent",borderBottom:"1px solid rgba(0, 0, 0, 0.06)"},body:{padding:0}},pa=w(({token:e,css:t})=>({sidebar:t`
23
23
  display: flex;
24
24
  flex-direction: column;
25
25
  height: 100%;
@@ -63,7 +63,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
63
63
  width: 22px;
64
64
  height: 22px;
65
65
  }
66
- `})),ta=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((a,i)=>(a.order??0)-(i.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let a=o.items[0]?.order??0,i=r.items[0]?.order??0;return a-i})},oo=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:a="Menu",showBranding:i=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:g=!0,forceIconMode:b=!1,collapsed:x,onCollapsedChange:h,className:u,style:m,footer:v,getContextMenuItems:_})=>{let{styles:L}=ea(),{styles:A}=Zt(),Y=x!==void 0,[ee,le]=(0,Pe.useState)(!g),V=Y?x:ee;(0,Pe.useEffect)(()=>{Y||h?.(V)},[]);let[C,F]=(0,Pe.useState)({}),[J,Z]=(0,Pe.useState)(()=>{let R=new Set;return e.forEach(oe=>{oe.type==="drawer"&&oe.inline&&oe.inlineDefaultExpanded&&R.add(oe.id)}),R}),I=V||b,B=!!I,z=(0,Pe.useMemo)(()=>ta(e),[e]),ae=(0,Pe.useCallback)(R=>{t?.(R),R.type==="drawer"&&((R.inline??!1)&&!I?Z(D=>{let U=new Set(D);return U.has(R.id)?U.delete(R.id):U.add(R.id),U}):F(D=>({...D,[R.id]:!0})))},[t,I]),O=(0,Pe.useCallback)(R=>{F(oe=>({...oe,[R]:!1}))},[]),k=(0,Pe.useMemo)(()=>e.filter(R=>R.type==="drawer"&&C[R.id]).map(R=>R.id),[e,C]);(0,Pe.useEffect)(()=>{if(k.length===0)return;let R=oe=>{let D=oe.target;!D||typeof D.closest!="function"||k.forEach(U=>{D.closest(`.menu-drawer-${U}`)||O(U)})};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[k,O]);let P=(0,Pe.useCallback)(()=>{if(!b){let R=!V;Y?h?.(R):le(R)}},[b,V,Y,h]);return(0,M.jsxs)(M.Fragment,{children:[I?(0,M.jsxs)("div",{className:`${L.sidebar} ${A.iconMode} ${u||""}`,style:m,children:[i?(0,M.jsx)("div",{className:A.iconModeLogo,children:o||r||(0,M.jsx)(Do,{size:28,color:"#1677ff"})}):null,(0,M.jsx)("div",{className:A.iconModeContainer,children:z.map(({group:R,items:oe},D)=>(0,M.jsxs)(Pe.default.Fragment,{children:[D>0&&(0,M.jsx)("div",{className:A.iconModeDivider}),(0,M.jsx)("div",{className:A.iconModeGroup,children:oe.map(U=>{let Oe=_?.(U),Ue=U.badge!==void 0&&U.badge!==!1&&U.badge!==0,Je=(0,M.jsxs)("button",{className:A.iconModeButton,onClick:()=>ae(U),title:U.name,"aria-label":U.name,style:{position:"relative"},children:[(0,M.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:U.icon}),Ue&&(0,M.jsx)("span",{style:{position:"absolute",top:2,right:2,minWidth:typeof U.badge=="number"?16:8,height:typeof U.badge=="number"?16:8,borderRadius:typeof U.badge=="number"?8:4,background:"#ef4444",color:"#fff",fontSize:10,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof U.badge=="number"?"0 3px":0},children:typeof U.badge=="number"?U.badge>99?"99+":U.badge:null})]},U.id);return Oe?(0,M.jsx)(qe,{menu:{items:Oe},trigger:["contextMenu"],children:Je},U.id):Je})})]},R||`group-${D}`))}),d&&(0,M.jsx)("button",{className:A.iconModeButton,onClick:P,title:"Expand sidebar","aria-label":"Expand sidebar",style:{marginTop:"auto"},children:(0,M.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:(0,M.jsx)(Et,{size:22})})}),v&&(0,M.jsx)("div",{style:{marginTop:"auto",paddingTop:8},children:typeof v=="function"?v({isIconMode:I}):v})]}):(0,M.jsxs)("div",{className:`${L.sidebar} ${A.expandedMenu} ${u||""}`,style:m,children:[i?(0,M.jsxs)("div",{className:`${A.expandedMenuLogo} ${B?"collapsed":""}`,children:[(0,M.jsx)("div",{className:"logo-icon",children:o||r||(0,M.jsx)(Do,{size:28,color:"#1677ff"})}),(0,M.jsx)("span",{className:"logo-text",children:a}),d&&!b&&(0,M.jsx)("button",{className:A.collapseBtn,onClick:P,title:"Collapse sidebar","aria-label":"Collapse sidebar",children:(0,M.jsx)(Xt,{size:18})})]}):d&&!b?(0,M.jsx)("button",{className:A.collapseBtn,onClick:P,title:"Collapse sidebar","aria-label":"Collapse sidebar",style:{alignSelf:"flex-end",marginBottom:8},children:(0,M.jsx)(Xt,{size:18})}):null,c&&(0,M.jsxs)("button",{className:`${A.newAnalysisBtn} ${B?"collapsed":""}`,onClick:p,children:[(0,M.jsx)(yn,{size:18}),(0,M.jsx)("span",{className:"btn-text",children:"New Thread"})]}),(0,M.jsx)("div",{className:A.buttonContainerExpanded,children:z.map(({group:R,items:oe})=>(0,M.jsxs)("div",{className:A.menuGroup,children:[R&&(0,M.jsx)("div",{className:`${A.menuGroupTitle} ${B?"collapsed":""}`,children:R}),oe.map(D=>{let U=D.inline??!1,Oe=J.has(D.id),Ue=_?.(D),Je=D.badge!==void 0&&D.badge!==!1&&D.badge!==0,gt=(0,M.jsxs)("button",{className:`${A.menuItemExpanded} ${B?"collapsed":""} ${Oe?A.menuItemExpandedActive:""}`,onClick:()=>ae(D),title:B?D.name:void 0,"aria-label":D.name,"aria-expanded":Oe,children:[(0,M.jsx)("span",{className:"menu-icon",children:D.icon}),(0,M.jsx)("span",{className:"menu-label",children:D.name}),Je&&(0,M.jsx)("span",{style:{marginLeft:"auto",minWidth:typeof D.badge=="number"?18:8,height:typeof D.badge=="number"?18:8,borderRadius:typeof D.badge=="number"?9:4,background:"#ef4444",color:"#fff",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof D.badge=="number"?"0 4px":0},children:typeof D.badge=="number"?D.badge>99?"99+":D.badge:null}),U&&!B&&(0,M.jsx)("span",{className:A.inlineDrawerIndicator,children:Oe?(0,M.jsx)(Qt,{size:16}):(0,M.jsx)(Et,{size:16})})]}),ot=Ue?(0,M.jsx)(qe,{menu:{items:Ue},trigger:["contextMenu"],children:gt},D.id):(0,M.jsx)(Pe.default.Fragment,{children:gt},D.id);return(0,M.jsxs)(Pe.default.Fragment,{children:[ot,U&&Oe&&!B&&(0,M.jsx)("div",{className:A.inlineDrawerContainer,children:D.content})]},D.id)})]},R||"ungrouped"))}),v&&(0,M.jsx)("div",{style:{marginTop:"auto",paddingTop:16,borderTop:"1px solid rgba(0, 0, 0, 0.06)"},children:typeof v=="function"?v({isIconMode:I}):v})]}),e.filter(R=>R.type==="drawer").map(R=>(0,M.jsx)(Nr,{rootClassName:`menu-drawer-${R.id}`,title:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,M.jsx)("span",{style:{fontSize:16,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:R.title||R.name}),(0,M.jsx)("button",{onClick:()=>O(R.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.5)",cursor:"pointer"},children:(0,M.jsx)(Xt,{size:24})})]}),open:C[R.id]||!1,onClose:()=>O(R.id),placement:"left",width:R.width||600,styles:{...En,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...En.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:R.content},R.id))]})};var Mn=n(S());var Nn=n(s()),{TextArea:pl}=q;var Bn=n(s());var Rt=n(S());var Ko=class{apps=new Map;defaultId=void 0;register(t){if(!t.id)throw new Error("App must have an id");this.apps.set(t.id,t),this.defaultId===void 0&&(this.defaultId=t.id)}get(t){return this.apps.get(t)}list(){return Array.from(this.apps.values())}getDefaultId(){return this.defaultId}setDefault(t){if(!this.apps.has(t))throw new Error(`Cannot set default to unregistered app: ${t}`);this.defaultId=t}getCurrentId(){return this.currentId}setCurrent(t){if(!this.apps.has(t))throw new Error(`Cannot set current to unregistered app: ${t}`);this.currentId=t}resetCurrent(){this.currentId=void 0}currentId=void 0},oa=new Ko;var ra=n(s()),hl=(0,Rt.createContext)(null);var Fn=n(s()),wl=w(({token:e})=>({container:{display:"flex",flexDirection:"column",gap:e.padding,padding:e.padding},header:{fontSize:e.fontSizeHeading5,fontWeight:600,color:e.colorText,paddingBottom:e.paddingSM,borderBottom:`1px solid ${e.colorBorderSecondary}`},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:e.padding},card:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.paddingXS,padding:e.paddingLG,borderRadius:e.borderRadiusLG,border:`1px solid ${e.colorBorder}`,cursor:"pointer",transition:"all 0.2s",background:e.colorBgContainer,"&:hover":{borderColor:e.colorPrimary,background:e.colorPrimaryBg}},activeCard:{borderColor:e.colorPrimary,background:e.colorPrimaryBg},icon:{fontSize:28,lineHeight:1},name:{fontSize:e.fontSize,fontWeight:500,color:e.colorText,textAlign:"center"},activeName:{color:e.colorPrimary}}));var Ea=n(S());var lt=n(S());var na=n(s());var Tl=300*1e3,Pl=(0,lt.createContext)(null);var Xn=n(S());var qo=n(S());var ia=n(S());var aa=n(s());var jn=n(s()),$l=w(({token:e,css:t})=>({container:t`
66
+ `})),ma=e=>{let t=new Map;return e.forEach(o=>{let r=o.group||null;t.has(r)||t.set(r,[]),t.get(r).push(o)}),Array.from(t.entries()).map(([o,r])=>({group:o,items:r.sort((a,i)=>(a.order??0)-(i.order??0))})).sort((o,r)=>{if(o.group===null)return-1;if(r.group===null)return 1;let a=o.items[0]?.order??0,i=r.items[0]?.order??0;return a-i})},io=({items:e,onItemClick:t,logo:o,logoIcon:r,logoText:a="Menu",showBranding:i=!0,showToggle:d=!0,showNewAnalysis:c=!1,onNewAnalysis:p,defaultExpanded:g=!0,forceIconMode:b=!1,collapsed:x,onCollapsedChange:h,className:u,style:m,footer:v,getContextMenuItems:O})=>{let{styles:L}=pa(),{styles:E}=oo(),Y=x!==void 0,[ee,de]=(0,Pe.useState)(!g),V=Y?x:ee;(0,Pe.useEffect)(()=>{Y||h?.(V)},[]);let[S,F]=(0,Pe.useState)({}),[J,Z]=(0,Pe.useState)(()=>{let k=new Set;return e.forEach(oe=>{oe.type==="drawer"&&oe.inline&&oe.inlineDefaultExpanded&&k.add(oe.id)}),k}),A=V||b,B=!!A,j=(0,Pe.useMemo)(()=>ma(e),[e]),se=(0,Pe.useCallback)(k=>{t?.(k),k.type==="drawer"&&((k.inline??!1)&&!A?Z(D=>{let U=new Set(D);return U.has(k.id)?U.delete(k.id):U.add(k.id),U}):F(D=>({...D,[k.id]:!0})))},[t,A]),_=(0,Pe.useCallback)(k=>{F(oe=>({...oe,[k]:!1}))},[]),R=(0,Pe.useMemo)(()=>e.filter(k=>k.type==="drawer"&&S[k.id]).map(k=>k.id),[e,S]);(0,Pe.useEffect)(()=>{if(R.length===0)return;let k=oe=>{let D=oe.target;!D||typeof D.closest!="function"||R.forEach(U=>{D.closest(`.menu-drawer-${U}`)||_(U)})};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[R,_]);let I=(0,Pe.useCallback)(()=>{if(!b){let k=!V;Y?h?.(k):de(k)}},[b,V,Y,h]);return(0,N.jsxs)(N.Fragment,{children:[A?(0,N.jsxs)("div",{className:`${L.sidebar} ${E.iconMode} ${u||""}`,style:m,children:[i?(0,N.jsx)("div",{className:E.iconModeLogo,children:o||r||(0,N.jsx)(jo,{size:28,color:"#1677ff"})}):null,(0,N.jsx)("div",{className:E.iconModeContainer,children:j.map(({group:k,items:oe},D)=>(0,N.jsxs)(Pe.default.Fragment,{children:[D>0&&(0,N.jsx)("div",{className:E.iconModeDivider}),(0,N.jsx)("div",{className:E.iconModeGroup,children:oe.map(U=>{let We=O?.(U),Ke=U.badge!==void 0&&U.badge!==!1&&U.badge!==0,Ze=(0,N.jsxs)("button",{className:E.iconModeButton,onClick:()=>se(U),title:U.name,"aria-label":U.name,style:{position:"relative"},children:[(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:U.icon}),Ke&&(0,N.jsx)("span",{style:{position:"absolute",top:2,right:2,minWidth:typeof U.badge=="number"?16:8,height:typeof U.badge=="number"?16:8,borderRadius:typeof U.badge=="number"?8:4,background:"#ef4444",color:"#fff",fontSize:10,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof U.badge=="number"?"0 3px":0},children:typeof U.badge=="number"?U.badge>99?"99+":U.badge:null})]},U.id);return We?(0,N.jsx)(qe,{menu:{items:We},trigger:["contextMenu"],children:Ze},U.id):Ze})})]},k||`group-${D}`))}),d&&(0,N.jsx)("button",{className:E.iconModeButton,onClick:I,title:"Expand sidebar","aria-label":"Expand sidebar",style:{marginTop:"auto"},children:(0,N.jsx)("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%"},children:(0,N.jsx)(Mt,{size:22})})}),v&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:8},children:typeof v=="function"?v({isIconMode:A}):v})]}):(0,N.jsxs)("div",{className:`${L.sidebar} ${E.expandedMenu} ${u||""}`,style:m,children:[i?(0,N.jsxs)("div",{className:`${E.expandedMenuLogo} ${B?"collapsed":""}`,children:[(0,N.jsx)("div",{className:"logo-icon",children:o||r||(0,N.jsx)(jo,{size:28,color:"#1677ff"})}),(0,N.jsx)("span",{className:"logo-text",children:a}),d&&!b&&(0,N.jsx)("button",{className:E.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",children:(0,N.jsx)(eo,{size:18})})]}):d&&!b?(0,N.jsx)("button",{className:E.collapseBtn,onClick:I,title:"Collapse sidebar","aria-label":"Collapse sidebar",style:{alignSelf:"flex-end",marginBottom:8},children:(0,N.jsx)(eo,{size:18})}):null,c&&(0,N.jsxs)("button",{className:`${E.newAnalysisBtn} ${B?"collapsed":""}`,onClick:p,children:[(0,N.jsx)(Sr,{size:18}),(0,N.jsx)("span",{className:"btn-text",children:"New Thread"})]}),(0,N.jsx)("div",{className:E.buttonContainerExpanded,children:j.map(({group:k,items:oe})=>(0,N.jsxs)("div",{className:E.menuGroup,children:[k&&(0,N.jsx)("div",{className:`${E.menuGroupTitle} ${B?"collapsed":""}`,children:k}),oe.map(D=>{let U=D.inline??!1,We=J.has(D.id),Ke=O?.(D),Ze=D.badge!==void 0&&D.badge!==!1&&D.badge!==0,gt=(0,N.jsxs)("button",{className:`${E.menuItemExpanded} ${B?"collapsed":""} ${We?E.menuItemExpandedActive:""}`,onClick:()=>se(D),title:B?D.name:void 0,"aria-label":D.name,"aria-expanded":We,children:[(0,N.jsx)("span",{className:"menu-icon",children:D.icon}),(0,N.jsx)("span",{className:"menu-label",children:D.name}),Ze&&(0,N.jsx)("span",{style:{marginLeft:"auto",minWidth:typeof D.badge=="number"?18:8,height:typeof D.badge=="number"?18:8,borderRadius:typeof D.badge=="number"?9:4,background:"#ef4444",color:"#fff",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:typeof D.badge=="number"?"0 4px":0},children:typeof D.badge=="number"?D.badge>99?"99+":D.badge:null}),U&&!B&&(0,N.jsx)("span",{className:E.inlineDrawerIndicator,children:We?(0,N.jsx)(Jt,{size:16}):(0,N.jsx)(Mt,{size:16})})]}),nt=Ke?(0,N.jsx)(qe,{menu:{items:Ke},trigger:["contextMenu"],children:gt},D.id):(0,N.jsx)(Pe.default.Fragment,{children:gt},D.id);return(0,N.jsxs)(Pe.default.Fragment,{children:[nt,U&&We&&!B&&(0,N.jsx)("div",{className:E.inlineDrawerContainer,children:D.content})]},D.id)})]},k||"ungrouped"))}),v&&(0,N.jsx)("div",{style:{marginTop:"auto",paddingTop:16,borderTop:"1px solid rgba(0, 0, 0, 0.06)"},children:typeof v=="function"?v({isIconMode:A}):v})]}),e.filter(k=>k.type==="drawer").map(k=>(0,N.jsx)(Bo,{rootClassName:`menu-drawer-${k.id}`,title:(0,N.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,N.jsx)("span",{style:{fontSize:16,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:k.title||k.name}),(0,N.jsx)("button",{onClick:()=>_(k.id),style:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:8,border:"1px solid rgba(0, 0, 0, 0.1)",background:"rgba(255, 255, 255, 0.5)",cursor:"pointer"},children:(0,N.jsx)(eo,{size:24})})]}),open:S[k.id]||!1,onClose:()=>_(k.id),placement:"left",width:k.width||600,styles:{...jr,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...jr.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:k.content},k.id))]})};var $r=n(C());var Lr=n(s()),{TextArea:Sl}=H;var _r=n(s());var Tt=n(C());var Ho=class{apps=new Map;defaultId=void 0;register(t){if(!t.id)throw new Error("App must have an id");this.apps.set(t.id,t),this.defaultId===void 0&&(this.defaultId=t.id)}get(t){return this.apps.get(t)}list(){return Array.from(this.apps.values())}getDefaultId(){return this.defaultId}setDefault(t){if(!this.apps.has(t))throw new Error(`Cannot set default to unregistered app: ${t}`);this.defaultId=t}getCurrentId(){return this.currentId}setCurrent(t){if(!this.apps.has(t))throw new Error(`Cannot set current to unregistered app: ${t}`);this.currentId=t}resetCurrent(){this.currentId=void 0}currentId=void 0},ua=new Ho;var ga=n(s()),Al=(0,Tt.createContext)(null);var Wr=n(s()),Bl=w(({token:e})=>({container:{display:"flex",flexDirection:"column",gap:e.padding,padding:e.padding},header:{fontSize:e.fontSizeHeading5,fontWeight:600,color:e.colorText,paddingBottom:e.paddingSM,borderBottom:`1px solid ${e.colorBorderSecondary}`},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:e.padding},card:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.paddingXS,padding:e.paddingLG,borderRadius:e.borderRadiusLG,border:`1px solid ${e.colorBorder}`,cursor:"pointer",transition:"all 0.2s",background:e.colorBgContainer,"&:hover":{borderColor:e.colorPrimary,background:e.colorPrimaryBg}},activeCard:{borderColor:e.colorPrimary,background:e.colorPrimaryBg},icon:{fontSize:28,lineHeight:1},name:{fontSize:e.fontSize,fontWeight:500,color:e.colorText,textAlign:"center"},activeName:{color:e.colorPrimary}}));var li=n(C());var ba=n(C());var qo=n(s());var Ur=n(s());var lt=n(C());var wa=n(s());var Ql=300*1e3,Yl=(0,lt.createContext)(null);var an=n(C());var Vo=n(C());var Ca=n(C());var Sa=n(s());var Hr=n(s()),sc=w(({token:e,css:t})=>({container:t`
67
67
  display: flex;
68
68
  flex-direction: column;
69
69
  height: 100%;
@@ -133,6 +133,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
133
133
  flex: 1;
134
134
  min-width: 0;
135
135
  `,roomName:t`
136
+ display: block;
136
137
  font-size: 14px;
137
138
  font-weight: 500;
138
139
  color: ${e.colorText};
@@ -141,6 +142,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
141
142
  text-overflow: ellipsis;
142
143
  margin: 0;
143
144
  `,lastMessage:t`
145
+ display: block;
144
146
  font-size: 12px;
145
147
  color: ${e.colorTextSecondary};
146
148
  white-space: nowrap;
@@ -164,7 +166,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
164
166
  gap: 2px;
165
167
  `,emptyContainer:t`
166
168
  padding: 24px 16px;
167
- `}));var wa=n(S());var ct=n(S());var ca=n(s());var ic=(0,ct.createContext)(null);var jt=n(S());var Ae=n(S());var N=n(s()),da=w(({token:e,css:t})=>({container:t`
169
+ `}));var ja=n(C());var ct=n(C());var Ra=n(s());var Ic=(0,ct.createContext)(null);var Lt=n(C());var Ae=n(C());var M=n(s()),Ta=w(({token:e,css:t})=>({container:t`
168
170
  display: flex;
169
171
  flex-direction: column;
170
172
  height: 100%;
@@ -409,7 +411,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
409
411
  transform: translateY(0);
410
412
  }
411
413
  }
412
- `})),pa=({component_key:e,data:t})=>t?.component?(0,N.jsx)(N.Fragment,{children:t.component}):(0,N.jsxs)("div",{children:[(0,N.jsx)("p",{children:"Component view not found"}),(0,N.jsx)("pre",{children:JSON.stringify({component_key:e,data:t},null,2)})]}),ro=e=>(0,N.jsx)(Mo,{style:{fontSize:12,opacity:.6}}),no=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=da(),{sideAppSelectedCard:a,contentAppSelectedCard:i,closeSideApp:d,closeContentApp:c,openSideApp:p,openContentApp:g}=xe(),b=e==="side"?a:i,x=e==="side"?d:c,h=e==="side"?p:g,[u,m]=(0,Ae.useState)(JSON.stringify(b)),[v,_]=(0,Ae.useState)(null),[L,A]=(0,Ae.useState)([]),[Y,ee]=(0,Ae.useState)(!1),[le,V]=(0,Ae.useState)(!1),[C,F]=(0,Ae.useState)(!1),J=(0,Ae.useRef)(null),Z=(0,Ae.useCallback)(()=>{J.current&&(clearTimeout(J.current),J.current=null),V(!1),F(!1),ee(!0)},[]),I=(0,Ae.useCallback)(()=>{J.current=setTimeout(()=>{V(!0)},150)},[]),ie=(0,Ae.useCallback)(()=>{le&&(ee(!1),V(!1))},[le]),B=(T,se,R,oe)=>{let D=[...L,{label:se,children:R,key:T,componentKey:oe}];A(D),m(T)},z=T=>{let se=u,R=L.findIndex(D=>D.key===T),oe=L.filter(D=>D.key!==T);if(oe.length===0){x();return}se===T&&(R>0?se=L[R-1].key:se=oe[0].key),A(oe),m(se)},ae=T=>{m(T)};(0,Ae.useEffect)(()=>{if(!b)return;let T=JSON.stringify(b);if(L.find(R=>R.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let se=Oo(b?.component_key)?.side_app_view||pa;B(T,b?.message||b?.data?.message||"Unnamed",(0,N.jsx)(se,{component_key:b?.component_key||"",data:b?.data,context:b?.context}),b?.component_key),J.current&&clearTimeout(J.current),ee(!0),V(!1),F(!0),J.current=setTimeout(()=>{V(!0)},1500)},[b]);let O=L.find(T=>T.key===u),k=L.map(T=>({key:T.key,label:(0,N.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[ro(T.componentKey),(0,N.jsx)("span",{style:{flex:1},children:T.label}),(0,N.jsx)(Ct,{style:{fontSize:10,opacity:.5},onClick:se=>{se.stopPropagation(),z(T.key)}})]}),onClick:()=>ae(T.key)})),P=(0,Ae.useMemo)(()=>({openApp:h}),[h]);return(0,N.jsxs)("div",{className:r.container,children:[t&&L.length>0&&(0,N.jsx)("div",{className:r.compactWrapper,onMouseEnter:Z,onMouseLeave:I,children:Y?(0,N.jsxs)("div",{className:`${r.floatingHeader} ${C?r.floatingHeaderPeek:""} ${le?r.floatingHeaderLeaving:""}`,onAnimationEnd:ie,children:[(0,N.jsx)("div",{className:r.floatingTabsStrip,children:L.map(T=>(0,N.jsx)($e,{title:T.label,placement:"bottom",children:(0,N.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>ae(T.key),onMouseEnter:()=>_(T.key),onMouseLeave:()=>_(null),children:[ro(T.componentKey),(0,N.jsx)("span",{className:r.tabLabel,children:T.label}),(0,N.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:se=>{se.stopPropagation(),z(T.key)},children:(0,N.jsx)(Ct,{style:{fontSize:10}})})]})},T.key))}),L.length>1&&(0,N.jsx)(qe,{menu:{items:k},placement:"bottomRight",trigger:["click"],children:(0,N.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,N.jsx)(ft,{})})}),o&&(0,N.jsx)($e,{title:"Close",children:(0,N.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,N.jsx)(Ct,{})})})]}):O&&(0,N.jsxs)("div",{className:r.compactPill,children:[ro(O.componentKey),(0,N.jsx)("span",{className:r.compactPillLabel,children:O.label})]})}),!t&&(0,N.jsxs)("div",{className:r.header,children:[(0,N.jsx)("div",{className:r.tabsStrip,children:L.map(T=>(0,N.jsx)($e,{title:T.label,placement:"bottom",children:(0,N.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>ae(T.key),onMouseEnter:()=>_(T.key),onMouseLeave:()=>_(null),children:[ro(T.componentKey),(0,N.jsx)("span",{className:r.tabLabel,children:T.label}),(0,N.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:se=>{se.stopPropagation(),z(T.key)},children:(0,N.jsx)(Ct,{style:{fontSize:10}})})]})},T.key))}),(0,N.jsxs)("div",{className:r.actions,children:[L.length>0&&(0,N.jsx)("div",{className:r.tabCounter,children:L.length}),L.length>1&&(0,N.jsx)(qe,{menu:{items:k},placement:"bottomRight",trigger:["click"],children:(0,N.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,N.jsx)(ft,{})})}),o&&(0,N.jsx)($e,{title:"Close",children:(0,N.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,N.jsx)(Ct,{})})})]})]}),(0,N.jsx)("div",{className:r.content,style:t&&L.length>0?{paddingTop:10}:void 0,children:(0,N.jsx)(eo.Provider,{value:P,children:O?(0,N.jsx)("div",{className:r.contentWrapper,children:O.children},O.key):(0,N.jsxs)("div",{className:r.emptyState,children:[(0,N.jsx)(Mo,{className:"icon"}),(0,N.jsx)("span",{children:"Select an app to start"})]})})})]})};var io=n(S());var $n=n(s());var bc=w(({token:e,css:t})=>({content:t`
414
+ `})),Pa=({component_key:e,data:t})=>t?.component?(0,M.jsx)(M.Fragment,{children:t.component}):(0,M.jsxs)("div",{children:[(0,M.jsx)("p",{children:"Component view not found"}),(0,M.jsx)("pre",{children:JSON.stringify({component_key:e,data:t},null,2)})]}),ao=e=>(0,M.jsx)(Do,{style:{fontSize:12,opacity:.6}}),so=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=Ta(),{sideAppSelectedCard:a,contentAppSelectedCard:i,closeSideApp:d,closeContentApp:c,openSideApp:p,openContentApp:g}=Se(),b=e==="side"?a:i,x=e==="side"?d:c,h=e==="side"?p:g,[u,m]=(0,Ae.useState)(JSON.stringify(b)),[v,O]=(0,Ae.useState)(null),[L,E]=(0,Ae.useState)([]),[Y,ee]=(0,Ae.useState)(!1),[de,V]=(0,Ae.useState)(!1),[S,F]=(0,Ae.useState)(!1),J=(0,Ae.useRef)(null),Z=(0,Ae.useCallback)(()=>{J.current&&(clearTimeout(J.current),J.current=null),V(!1),F(!1),ee(!0)},[]),A=(0,Ae.useCallback)(()=>{J.current=setTimeout(()=>{V(!0)},150)},[]),ae=(0,Ae.useCallback)(()=>{de&&(ee(!1),V(!1))},[de]),B=(T,le,k,oe)=>{let D=[...L,{label:le,children:k,key:T,componentKey:oe}];E(D),m(T)},j=T=>{let le=u,k=L.findIndex(D=>D.key===T),oe=L.filter(D=>D.key!==T);if(oe.length===0){x();return}le===T&&(k>0?le=L[k-1].key:le=oe[0].key),E(oe),m(le)},se=T=>{m(T)};(0,Ae.useEffect)(()=>{if(!b)return;let T=JSON.stringify(b);if(L.find(k=>k.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let le=Wo(b?.component_key)?.side_app_view||Pa;B(T,b?.message||b?.data?.message||"Unnamed",(0,M.jsx)(le,{component_key:b?.component_key||"",data:b?.data,context:b?.context}),b?.component_key),J.current&&clearTimeout(J.current),ee(!0),V(!1),F(!0),J.current=setTimeout(()=>{V(!0)},1500)},[b]);let _=L.find(T=>T.key===u),R=L.map(T=>({key:T.key,label:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[ao(T.componentKey),(0,M.jsx)("span",{style:{flex:1},children:T.label}),(0,M.jsx)(St,{style:{fontSize:10,opacity:.5},onClick:le=>{le.stopPropagation(),j(T.key)}})]}),onClick:()=>se(T.key)})),I=(0,Ae.useMemo)(()=>({openApp:h}),[h]);return(0,M.jsxs)("div",{className:r.container,children:[t&&L.length>0&&(0,M.jsx)("div",{className:r.compactWrapper,onMouseEnter:Z,onMouseLeave:A,children:Y?(0,M.jsxs)("div",{className:`${r.floatingHeader} ${S?r.floatingHeaderPeek:""} ${de?r.floatingHeaderLeaving:""}`,onAnimationEnd:ae,children:[(0,M.jsx)("div",{className:r.floatingTabsStrip,children:L.map(T=>(0,M.jsx)(ze,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[ao(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),j(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),L.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(ft,{})})}),o&&(0,M.jsx)(ze,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]}):_&&(0,M.jsxs)("div",{className:r.compactPill,children:[ao(_.componentKey),(0,M.jsx)("span",{className:r.compactPillLabel,children:_.label})]})}),!t&&(0,M.jsxs)("div",{className:r.header,children:[(0,M.jsx)("div",{className:r.tabsStrip,children:L.map(T=>(0,M.jsx)(ze,{title:T.label,placement:"bottom",children:(0,M.jsxs)("div",{"data-tab-key":T.key,className:`${r.tab} ${T.key===u?"active":""}`,onClick:()=>se(T.key),onMouseEnter:()=>O(T.key),onMouseLeave:()=>O(null),children:[ao(T.componentKey),(0,M.jsx)("span",{className:r.tabLabel,children:T.label}),(0,M.jsx)("span",{className:`${r.closeIndicator} ${v===T.key||T.key===u?"always-visible":""}`,onClick:le=>{le.stopPropagation(),j(T.key)},children:(0,M.jsx)(St,{style:{fontSize:10}})})]})},T.key))}),(0,M.jsxs)("div",{className:r.actions,children:[L.length>0&&(0,M.jsx)("div",{className:r.tabCounter,children:L.length}),L.length>1&&(0,M.jsx)(qe,{menu:{items:R},placement:"bottomRight",trigger:["click"],children:(0,M.jsx)("button",{className:r.actionBtn,title:"All tabs",children:(0,M.jsx)(ft,{})})}),o&&(0,M.jsx)(ze,{title:"Close",children:(0,M.jsx)("button",{className:r.actionBtn,onClick:x,children:(0,M.jsx)(St,{})})})]})]}),(0,M.jsx)("div",{className:r.content,style:t&&L.length>0?{paddingTop:10}:void 0,children:(0,M.jsx)(no.Provider,{value:I,children:_?(0,M.jsx)("div",{className:r.contentWrapper,children:_.children},_.key):(0,M.jsxs)("div",{className:r.emptyState,children:[(0,M.jsx)(Do,{className:"icon"}),(0,M.jsx)("span",{children:"Select an app to start"})]})})})]})};var zt=n(C());var Go=n(C());var Qo=n(s());var Uc=w(({token:e,css:t})=>({content:t`
413
415
  display: flex;
414
416
  flex-direction: column;
415
417
  gap: 4px;
@@ -430,6 +432,36 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
430
432
  background: ${e.colorFillTertiary};
431
433
  color: ${e.colorPrimary};
432
434
  font-size: 12px;
435
+ `,quote:t`
436
+ display: flex;
437
+ flex-direction: column;
438
+ gap: 2px;
439
+ padding: 6px 10px;
440
+ margin-bottom: 6px;
441
+ border-left: 3px solid ${e.colorBorder};
442
+ background: ${e.colorFillQuaternary};
443
+ border-radius: 6px;
444
+ max-width: 100%;
445
+ `,quoteAuthor:t`
446
+ font-size: 12px;
447
+ font-weight: 600;
448
+ color: ${e.colorTextSecondary};
449
+ `,quoteText:t`
450
+ font-size: 13px;
451
+ color: ${e.colorTextTertiary};
452
+ white-space: nowrap;
453
+ overflow: hidden;
454
+ text-overflow: ellipsis;
455
+ `,dispatchNotice:t`
456
+ display: flex;
457
+ align-items: center;
458
+ gap: 8px;
459
+ margin-top: 4px;
460
+ padding: 4px 8px;
461
+ border-radius: 6px;
462
+ background: ${e.colorWarningBg};
463
+ color: ${e.colorWarningText};
464
+ font-size: 12px;
433
465
  `,actions:t`
434
466
  display: flex;
435
467
  align-items: center;
@@ -448,7 +480,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
448
480
  font-size: 12px;
449
481
  color: ${e.colorTextTertiary};
450
482
  }
451
- `}));var Ln=n(s()),Sc=w(({token:e,css:t})=>({root:t`
483
+ `}));var Vr=n(s()),Vc=w(({token:e,css:t})=>({root:t`
452
484
  display: flex;
453
485
  align-items: center;
454
486
  gap: 8px;
@@ -461,7 +493,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
461
493
  font-size: 12px;
462
494
  color: ${e.colorTextTertiary};
463
495
  }
464
- `}));var On=n(s());var Dc=w(({token:e,css:t})=>({root:t`
496
+ `}));var Gr=n(s());var rd=w(({token:e,css:t})=>({root:t`
465
497
  flex: 1;
466
498
  min-height: 0;
467
499
  overflow-y: auto;
@@ -487,11 +519,11 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
487
519
  transform: translateX(-50%);
488
520
  `,list:t`
489
521
  padding: 0 12px;
490
- `}));var Dt=n(S());var _n=n(s()),Xc=w(({token:e,css:t})=>({root:t`
522
+ `}));var jt=n(C());var Qr=n(s()),Ad=w(({token:e,css:t})=>({root:t`
491
523
  flex-shrink: 0;
492
524
  border-top: 1px solid ${e.colorBorderSecondary};
493
525
  background: ${e.colorBgContainer};
494
- padding: 8px 12px;
526
+ padding: 8px 12px max(8px, env(safe-area-inset-bottom));
495
527
  `,reply:t`
496
528
  display: flex;
497
529
  align-items: center;
@@ -508,7 +540,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
508
540
  margin-top: 8px;
509
541
  font-size: 13px;
510
542
  color: ${e.colorErrorText};
511
- `}));var Wn=n(s());var td=w(({token:e,css:t})=>({root:t`
543
+ `}));var Yr=n(s());var Bd=w(({token:e,css:t})=>({root:t`
512
544
  display: flex;
513
545
  align-items: center;
514
546
  justify-content: space-between;
@@ -542,7 +574,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
542
574
  font-size: 13px;
543
575
  color: ${e.colorTextSecondary};
544
576
  white-space: nowrap;
545
- `}));var Ho=n(S());var Vo=n(s());var sd=w(({token:e,css:t})=>({root:t`
577
+ `}));var Yo=n(C());var Xo=n(s());var Ld=w(({token:e,css:t})=>({root:t`
546
578
  display: flex;
547
579
  flex-direction: column;
548
580
  height: 100%;
@@ -626,7 +658,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
626
658
  opacity: 0.7;
627
659
  `,error:t`
628
660
  margin-bottom: 12px;
629
- `}));var so=n(S());var Un=n(s());var er=n(S());var re=n(S());var Go=e=>{if(!e)return"";let t=e.split("/").filter(Boolean);return t[t.length-1]??""},Kn=(e,t)=>{if(t==="name")return null;let o=t==="created"?e.created_at:e.modified_at;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function Ft(e,t="name",o="asc"){return[...e].sort((r,a)=>{if(!!r.is_dir!=!!a.is_dir)return r.is_dir?-1:1;if(t==="name"){let c=Go(r.path),p=Go(a.path);return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Kn(r,t),d=Kn(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}function qn(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>{let a=(r.path||"").toLowerCase(),i=Go(r.path).toLowerCase();return a.includes(o)||i.includes(o)}):e}function Hn(e){let t=[];return e.forEach(o=>{let r=(o.path||"").split("/").filter(Boolean);if(r.length===0)return;let a=t;r.forEach((i,d)=>{let c=d===r.length-1,p="/"+r.slice(0,d+1).join("/"),g=a.find(b=>b.path===p);g||(g=c?{...o,path:p,name:i}:{path:p,name:i,is_dir:!0,children:[]},a.push(g)),c||(a=g.children??(g.children=[]))})}),t}function Qo(e,t="name",o="asc"){return Ft(e,t,o).map(r=>r.children?{...r,children:Qo(r.children,t,o)}:r)}var y=n(s()),ua=w(({token:e,css:t})=>({container:t`
661
+ `}));var co=n(C());var Xr=n(s());var rn=n(C());var re=n(C());var Jo=e=>{if(!e)return"";let t=e.split("/").filter(Boolean);return t[t.length-1]??""},Jr=(e,t)=>{if(t==="name")return null;let o=t==="created"?e.created_at:e.modified_at;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function $t(e,t="name",o="asc"){return[...e].sort((r,a)=>{if(!!r.is_dir!=!!a.is_dir)return r.is_dir?-1:1;if(t==="name"){let c=Jo(r.path),p=Jo(a.path);return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Jr(r,t),d=Jr(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}function Zr(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>{let a=(r.path||"").toLowerCase(),i=Jo(r.path).toLowerCase();return a.includes(o)||i.includes(o)}):e}function ei(e){let t=[];return e.forEach(o=>{let r=(o.path||"").split("/").filter(Boolean);if(r.length===0)return;let a=t;r.forEach((i,d)=>{let c=d===r.length-1,p="/"+r.slice(0,d+1).join("/"),g=a.find(b=>b.path===p);g||(g=c?{...o,path:p,name:i}:{path:p,name:i,is_dir:!0,children:[]},a.push(g)),c||(a=g.children??(g.children=[]))})}),t}function Zo(e,t="name",o="asc"){return $t(e,t,o).map(r=>r.children?{...r,children:Zo(r.children,t,o)}:r)}var y=n(s()),Aa=w(({token:e,css:t})=>({container:t`
630
662
  height: 100%;
631
663
  overflow-y: auto;
632
664
  overflow-x: hidden;
@@ -815,7 +847,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
815
847
  width: 14px;
816
848
  height: 14px;
817
849
  }
818
- `})),Vn=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},ga=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},Yo=e=>ga(e.name||e.path),fa=e=>(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{style:{fontWeight:600},children:Yo(e)}),e.created_at?(0,y.jsxs)("div",{children:["Created: ",Vn(e.created_at)]}):null,e.modified_at?(0,y.jsxs)("div",{children:["Modified: ",Vn(e.modified_at)]}):null]}),ya={display:"flex",flexDirection:"column",gap:12},Xo=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:a,directoryChildren:i,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:g,onUploadFolder:b,onToggleDirectory:x,onAssetClick:h})=>{let{styles:u}=ua(),{message:m}=Eo.useApp(),{currentAssistant:v}=Ze(),{getFileDownloadUrl:_,downloadFolder:L,getDirectFileUrl:A,listPathByFolder:Y}=Ie(),{openSideApp:ee}=xe(),{currentTenant:le}=Ve(),V=le?.id||"",[C,F]=(0,re.useState)(null),[J,Z]=(0,re.useState)(null),{check:I,pin:ie,unpin:B,enableCustomMenu:z,get:ae}=lo(),O=Jo(),[k,P]=(0,re.useState)(O);(0,re.useEffect)(()=>{P(O)},[O]);let[T,se]=(0,re.useState)({}),[R,oe]=(0,re.useState)(null),[D,U]=(0,re.useState)(""),[Oe,Ue]=(0,re.useState)(""),[Je,gt]=(0,re.useState)(!1),[ot,W]=(0,re.useState)(""),[fe,rt]=(0,re.useState)("name"),[Qe,Gi]=(0,re.useState)("asc"),[Lt,To]=(0,re.useState)(null),[Qi,Po]=(0,re.useState)(!1);(0,re.useEffect)(()=>{R&&Zo(ae).then(f=>{P(Array.from(new Set([...O,...f])).sort())})},[R]),(0,re.useEffect)(()=>{let f=ot.trim();if(!f){To(null),Po(!1);return}let X=!1;return Po(!0),Tn(Y,o.map(K=>K.name),v?.id).then(K=>{X||To(qn(K,f))}).catch(()=>{X||To([])}).finally(()=>{X||Po(!1)}),()=>{X=!0}},[ot,Y,o,v?.id]);let Io=(0,re.useMemo)(()=>Lt?Qo(Hn(Lt),fe,Qe):null,[Lt,fe,Qe]),Ot=(0,re.useCallback)((f,X)=>{if(!X||!z)return;se($=>$[f]?$:{...$,[f]:{isPinned:!1,pinnedId:null,loading:!0}});let K={contentType:"file",contentConfig:{resourcePath:f,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f.split("/").pop()||f},isMatch:$=>$.resourcePath===f};I(K).then($=>{se(Ke=>({...Ke,[f]:{...$,loading:!1}}))}).catch(()=>{se($=>({...$,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[z,I,v?.id]),Yi=async()=>{if(!R||!D.trim()){m.warning("Please enter a menu name");return}gt(!0);try{let f=R.split("/").pop()||R;await ie({contentType:"file",name:D.trim(),group:Oe.trim()||void 0,contentConfig:{resourcePath:R,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f},isMatch:X=>X.resourcePath===R}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),oe(null),U(""),Ue(""),se(X=>{let K={...X};return delete K[R],K})}catch(f){m.error(f.message||"Failed to pin")}finally{gt(!1)}},_t=(0,re.useCallback)(async(f,X)=>{se(K=>({...K,[f]:{...K[f],loading:!0}}));try{await B(X),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),se(K=>({...K,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(K){m.error(K.message||"Failed to unpin"),se($=>({...$,[f]:{...$[f],loading:!1}}))}},[B,m]),Ar=(0,re.useCallback)(async f=>{Z(f);try{let X=await L(f,v?.id),K=URL.createObjectURL(X),$=document.createElement("a");$.href=K;let Ke=f.replace(/\/$/,"").split("/").pop()||"folder";$.download=`${Ke}.zip`,$.click(),window.setTimeout(()=>URL.revokeObjectURL(K),0)}catch(X){m.error(X instanceof Error?X.message:"Failed to download folder")}finally{Z(null)}},[L,v?.id,m]),Ao=re.default.useCallback((f,X)=>{let K=Yo(f);if(f.is_dir){let $=c[f.path]||!1,Ke=i[f.path]||[],Xi=d[f.path]||!1;return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((Ye,Ji)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${Ji}`)),(0,y.jsx)("button",{type:"button",className:u.treeToggle,"aria-label":`${$?"collapse":"expand"} ${K}`,onClick:()=>void x(f.path),children:(0,y.jsx)(Et,{size:14,style:{transform:$?"rotate(90deg)":void 0}})}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,"aria-label":`toggle ${K}`,onClick:()=>void x(f.path),title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(it,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:Ye=>Ot(f.path,Ye),menu:{items:[...z?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(He,{size:14}),label:"Unpin from Menu",onClick:()=>{let Ye=T[f.path];Ye?.pinnedId&&_t(f.path,Ye.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(He,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ue("")}}]:[],{key:"preview",icon:(0,y.jsx)(Kt,{}),label:"Preview",onClick:()=>{let Ye=A(f.path);Ye&&ee({component_key:"attachments",data:{file_id:f.path,url:Ye},message:K})}},{key:"share",icon:(0,y.jsx)(qt,{}),label:"Share",onClick:()=>F(f.path)},{key:"download-folder",icon:(0,y.jsx)(Bo,{}),label:"Download",disabled:J===f.path,onClick:()=>{Ar(f.path)}}]},children:(0,y.jsx)(j,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),$?Xi?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(de,{size:"small"})}):Ke.length>0?Ft(Ke,fe,Qe).map(Ye=>Ao(Ye,X+1)):(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null]},f.path)}return(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map(($,Ke)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${Ke}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsx)($e,{title:fa(f),placement:"rightTop",children:(0,y.jsxs)("button",{type:"button",className:u.assetItem,onClick:()=>h(f),"aria-label":`open ${K}`,children:[(0,y.jsx)("div",{className:u.assetIcon,children:kn(K)}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]})}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:$=>Ot(f.path,$),menu:{items:[...z?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(He,{size:14}),label:"Unpin from Menu",onClick:()=>{let $=T[f.path];$?.pinnedId&&_t(f.path,$.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(He,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(""),Ue("")}}]:[],{key:"preview",icon:(0,y.jsx)(Kt,{}),label:"Preview",onClick:()=>h(f)},{key:"download",icon:(0,y.jsx)(Bo,{}),label:"Download",onClick:()=>{let $=_(f.path,v?.id);window.open($,"_blank")}},{key:"share",icon:(0,y.jsx)(qt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(j,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]},f.path)},[i,c,d,h,x,u,_,L,v?.id,z,T,Ot,_t,J,Ar,fe,Qe]),Er=(f,X)=>{if(!f.is_dir)return Ao(f,X);let K=Yo(f);return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map(($,Ke)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${Ke}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(it,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:$=>Ot(f.path,$),menu:{items:[...z?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(He,{size:14}),label:"Unpin from Menu",onClick:()=>{let $=T[f.path];$?.pinnedId&&_t(f.path,$.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(He,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ue("")}}]:[],{key:"preview",icon:(0,y.jsx)(Kt,{}),label:"Preview",onClick:()=>{let $=A(f.path);$&&ee({component_key:"attachments",data:{file_id:f.path,url:$},message:K})}},{key:"share",icon:(0,y.jsx)(qt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(j,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),f.children&&f.children.length>0?Ft(f.children,fe,Qe).map($=>Er($,X+1)):null]},f.path)};return t?(0,y.jsxs)("div",{className:u.container,children:[(0,y.jsxs)("h3",{className:u.header,children:[(0,y.jsx)(it,{size:16}),(0,y.jsx)("span",{children:"Files"})]}),(0,y.jsxs)("div",{className:u.toolbar,children:[(0,y.jsx)(q,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:ot,onChange:f=>W(f.target.value)}),(0,y.jsxs)("div",{className:u.toolbarRow,children:[(0,y.jsx)(Fe,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:f=>rt(f),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,y.jsx)(j,{size:"small",icon:Qe==="asc"?(0,y.jsx)(Ht,{}):(0,y.jsx)(Vt,{}),onClick:()=>Gi(f=>f==="asc"?"desc":"asc"),title:Qe==="asc"?"Ascending":"Descending"})]})]}),Lt!==null?(0,y.jsx)("div",{className:u.assetList,children:Qi?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(de,{size:"small"})}):Io&&Io.length>0?Io.map(f=>Er(f,0)):(0,y.jsxs)("div",{className:u.emptyState,children:['No files match "',ot.trim(),'"']})}):o.map(f=>{let X=r[f.name]||[],K=a[f.name]||!1,$=X.length;return(0,y.jsxs)("div",{className:u.section,children:[(0,y.jsxs)("div",{className:u.sectionHeader,children:[(0,y.jsx)("span",{className:u.sectionTitle,onClick:()=>void g(f),title:"Click to refresh",children:f.displayName||f.name}),(0,y.jsx)("span",{className:u.badge,children:$})]}),K?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(de,{size:"small"})}):(0,y.jsxs)("div",{className:u.assetList,children:[Ft(X,fe,Qe).map(Ke=>Ao(Ke,0)),X.length===0?(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null,f.allowUpload?(0,y.jsx)("button",{type:"button",className:u.uploadBtn,onClick:()=>void b(f.name),disabled:!e||!t||p===f.name,children:p===f.name?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(de,{size:"small"}),(0,y.jsx)("span",{children:"Uploading..."})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(xn,{size:14}),(0,y.jsx)("span",{children:"Upload"})]})}):null]})]},f.name)}),C&&(0,y.jsx)(Rn,{open:!!C,filePath:C,assistantId:v?.id,fileName:C.split("/").pop(),onClose:()=>F(null)}),(0,y.jsx)(pe,{title:"Pin to Menu",open:!!R,onOk:Yi,onCancel:()=>oe(null),confirmLoading:Je,okText:"Pin",children:(0,y.jsxs)("div",{style:ya,children:[(0,y.jsx)(q,{placeholder:"Menu name (required)",value:D,onChange:f=>U(f.target.value)}),(0,y.jsx)(Wt,{placeholder:"Group (optional, select or type new)",value:Oe,options:k.map(f=>({value:f})),onChange:f=>Ue(f),filterOption:(f,X)=>X?.value?.toUpperCase().includes(f.toUpperCase())??!1})]})})]}):(0,y.jsx)("div",{className:u.emptyState,children:"Please select a project to browse files"})};var Gn=n(s());var Ld=w(({token:e,css:t})=>({root:t`
850
+ `})),ti=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},Ea=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},en=e=>Ea(e.name||e.path),Na=e=>(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{style:{fontWeight:600},children:en(e)}),e.created_at?(0,y.jsxs)("div",{children:["Created: ",ti(e.created_at)]}):null,e.modified_at?(0,y.jsxs)("div",{children:["Modified: ",ti(e.modified_at)]}):null]}),Ma={display:"flex",flexDirection:"column",gap:12},tn=({workspaceId:e,projectId:t,resourceFolders:o,folderEntries:r,folderLoading:a,directoryChildren:i,directoryLoading:d,directoryExpanded:c,uploadingFolder:p,onRefreshFolder:g,onUploadFolder:b,onToggleDirectory:x,onAssetClick:h})=>{let{styles:u}=Aa(),{message:m}=Mo.useApp(),{currentAssistant:v}=et(),{getFileDownloadUrl:O,downloadFolder:L,getDirectFileUrl:E,listPathByFolder:Y}=Ie(),{openSideApp:ee}=Se(),{currentTenant:de}=Oe(),V=de?.id||"",[S,F]=(0,re.useState)(null),[J,Z]=(0,re.useState)(null),{check:A,pin:ae,unpin:B,enableCustomMenu:j,get:se}=po(),_=on(),[R,I]=(0,re.useState)(_);(0,re.useEffect)(()=>{I(_)},[_]);let[T,le]=(0,re.useState)({}),[k,oe]=(0,re.useState)(null),[D,U]=(0,re.useState)(""),[We,Ke]=(0,re.useState)(""),[Ze,gt]=(0,re.useState)(!1),[nt,W]=(0,re.useState)(""),[fe,rt]=(0,re.useState)("name"),[Qe,ia]=(0,re.useState)("asc"),[Wt,Io]=(0,re.useState)(null),[aa,Ao]=(0,re.useState)(!1);(0,re.useEffect)(()=>{k&&nn(se).then(f=>{I(Array.from(new Set([..._,...f])).sort())})},[k]),(0,re.useEffect)(()=>{let f=nt.trim();if(!f){Io(null),Ao(!1);return}let X=!1;return Ao(!0),Br(Y,o.map(K=>K.name),v?.id).then(K=>{X||Io(Zr(K,f))}).catch(()=>{X||Io([])}).finally(()=>{X||Ao(!1)}),()=>{X=!0}},[nt,Y,o,v?.id]);let Eo=(0,re.useMemo)(()=>Wt?Zo(ei(Wt),fe,Qe):null,[Wt,fe,Qe]),Ut=(0,re.useCallback)((f,X)=>{if(!X||!j)return;le($=>$[f]?$:{...$,[f]:{isPinned:!1,pinnedId:null,loading:!0}});let K={contentType:"file",contentConfig:{resourcePath:f,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f.split("/").pop()||f},isMatch:$=>$.resourcePath===f};A(K).then($=>{le(He=>({...He,[f]:{...$,loading:!1}}))}).catch(()=>{le($=>({...$,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[j,A,v?.id]),sa=async()=>{if(!k||!D.trim()){m.warning("Please enter a menu name");return}gt(!0);try{let f=k.split("/").pop()||k;await ae({contentType:"file",name:D.trim(),group:We.trim()||void 0,contentConfig:{resourcePath:k,tenantId:V,workspaceId:e||"",projectId:t||"",assistantId:v?.id||"",fileName:f},isMatch:X=>X.resourcePath===k}),m.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),oe(null),U(""),Ke(""),le(X=>{let K={...X};return delete K[k],K})}catch(f){m.error(f.message||"Failed to pin")}finally{gt(!1)}},Kt=(0,re.useCallback)(async(f,X)=>{le(K=>({...K,[f]:{...K[f],loading:!0}}));try{await B(X),m.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),le(K=>({...K,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))}catch(K){m.error(K.message||"Failed to unpin"),le($=>({...$,[f]:{...$[f],loading:!1}}))}},[B,m]),$n=(0,re.useCallback)(async f=>{Z(f);try{let X=await L(f,v?.id),K=URL.createObjectURL(X),$=document.createElement("a");$.href=K;let He=f.replace(/\/$/,"").split("/").pop()||"folder";$.download=`${He}.zip`,$.click(),window.setTimeout(()=>URL.revokeObjectURL(K),0)}catch(X){m.error(X instanceof Error?X.message:"Failed to download folder")}finally{Z(null)}},[L,v?.id,m]),No=re.default.useCallback((f,X)=>{let K=en(f);if(f.is_dir){let $=c[f.path]||!1,He=i[f.path]||[],la=d[f.path]||!1;return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((Ye,ca)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${ca}`)),(0,y.jsx)("button",{type:"button",className:u.treeToggle,"aria-label":`${$?"collapse":"expand"} ${K}`,onClick:()=>void x(f.path),children:(0,y.jsx)(Mt,{size:14,style:{transform:$?"rotate(90deg)":void 0}})}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,"aria-label":`toggle ${K}`,onClick:()=>void x(f.path),title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:Ye=>Ut(f.path,Ye),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let Ye=T[f.path];Ye?.pinnedId&&Kt(f.path,Ye.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Vt,{}),label:"Preview",onClick:()=>{let Ye=E(f.path);Ye&&ee({component_key:"attachments",data:{file_id:f.path,url:Ye},message:K})}},{key:"share",icon:(0,y.jsx)(Gt,{}),label:"Share",onClick:()=>F(f.path)},{key:"download-folder",icon:(0,y.jsx)(zo,{}),label:"Download",disabled:J===f.path,onClick:()=>{$n(f.path)}}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),$?la?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):He.length>0?$t(He,fe,Qe).map(Ye=>No(Ye,X+1)):(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null]},f.path)}return(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map(($,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsx)(ze,{title:Na(f),placement:"rightTop",children:(0,y.jsxs)("button",{type:"button",className:u.assetItem,onClick:()=>h(f),"aria-label":`open ${K}`,children:[(0,y.jsx)("div",{className:u.assetIcon,children:Mr(K)}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]})}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:$=>Ut(f.path,$),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let $=T[f.path];$?.pinnedId&&Kt(f.path,$.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(""),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Vt,{}),label:"Preview",onClick:()=>h(f)},{key:"download",icon:(0,y.jsx)(zo,{}),label:"Download",onClick:()=>{let $=O(f.path,v?.id);window.open($,"_blank")}},{key:"share",icon:(0,y.jsx)(Gt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]},f.path)},[i,c,d,h,x,u,O,L,v?.id,j,T,Ut,Kt,J,$n,fe,Qe]),Ln=(f,X)=>{if(!f.is_dir)return No(f,X);let K=en(f);return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map(($,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsxs)("button",{type:"button",className:u.assetItem,title:K,children:[(0,y.jsx)("div",{className:u.assetIcon,children:(0,y.jsx)(at,{size:14})}),(0,y.jsx)("div",{className:u.assetInfo,children:(0,y.jsx)("div",{className:u.assetName,children:K})})]}),(0,y.jsx)(qe,{trigger:["click"],onOpenChange:$=>Ut(f.path,$),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let $=T[f.path];$?.pinnedId&&Kt(f.path,$.pinnedId)}}]:[{key:"pin",icon:(0,y.jsx)(Ve,{size:14}),label:"Pin to Menu",onClick:()=>{oe(f.path),U(K),Ke("")}}]:[],{key:"preview",icon:(0,y.jsx)(Vt,{}),label:"Preview",onClick:()=>{let $=E(f.path);$&&ee({component_key:"attachments",data:{file_id:f.path,url:$},message:K})}},{key:"share",icon:(0,y.jsx)(Gt,{}),label:"Share",onClick:()=>F(f.path)}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),f.children&&f.children.length>0?$t(f.children,fe,Qe).map($=>Ln($,X+1)):null]},f.path)};return t?(0,y.jsxs)("div",{className:u.container,children:[(0,y.jsxs)("h3",{className:u.header,children:[(0,y.jsx)(at,{size:16}),(0,y.jsx)("span",{children:"Files"})]}),(0,y.jsxs)("div",{className:u.toolbar,children:[(0,y.jsx)(H,{size:"small",placeholder:"Search files\u2026",allowClear:!0,value:nt,onChange:f=>W(f.target.value)}),(0,y.jsxs)("div",{className:u.toolbarRow,children:[(0,y.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:fe,onChange:f=>rt(f),options:[{value:"name",label:"Name"},{value:"created",label:"Created"},{value:"modified",label:"Modified"}]}),(0,y.jsx)(z,{size:"small",icon:Qe==="asc"?(0,y.jsx)(Qt,{}):(0,y.jsx)(Yt,{}),onClick:()=>ia(f=>f==="asc"?"desc":"asc"),title:Qe==="asc"?"Ascending":"Descending"})]})]}),Wt!==null?(0,y.jsx)("div",{className:u.assetList,children:aa?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):Eo&&Eo.length>0?Eo.map(f=>Ln(f,0)):(0,y.jsxs)("div",{className:u.emptyState,children:['No files match "',nt.trim(),'"']})}):o.map(f=>{let X=r[f.name]||[],K=a[f.name]||!1,$=X.length;return(0,y.jsxs)("div",{className:u.section,children:[(0,y.jsxs)("div",{className:u.sectionHeader,children:[(0,y.jsx)("span",{className:u.sectionTitle,onClick:()=>void g(f),title:"Click to refresh",children:f.displayName||f.name}),(0,y.jsx)("span",{className:u.badge,children:$})]}),K?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):(0,y.jsxs)("div",{className:u.assetList,children:[$t(X,fe,Qe).map(He=>No(He,0)),X.length===0?(0,y.jsx)("div",{className:u.emptyState,children:"No files in this folder"}):null,f.allowUpload?(0,y.jsx)("button",{type:"button",className:u.uploadBtn,onClick:()=>void b(f.name),disabled:!e||!t||p===f.name,children:p===f.name?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ne,{size:"small"}),(0,y.jsx)("span",{children:"Uploading..."})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pr,{size:14}),(0,y.jsx)("span",{children:"Upload"})]})}):null]})]},f.name)}),S&&(0,y.jsx)(Nr,{open:!!S,filePath:S,assistantId:v?.id,fileName:S.split("/").pop(),onClose:()=>F(null)}),(0,y.jsx)(pe,{title:"Pin to Menu",open:!!k,onOk:sa,onCancel:()=>oe(null),confirmLoading:Ze,okText:"Pin",children:(0,y.jsxs)("div",{style:Ma,children:[(0,y.jsx)(H,{placeholder:"Menu name (required)",value:D,onChange:f=>U(f.target.value)}),(0,y.jsx)(Ht,{placeholder:"Group (optional, select or type new)",value:We,options:R.map(f=>({value:f})),onChange:f=>Ke(f),filterOption:(f,X)=>X?.value?.toUpperCase().includes(f.toUpperCase())??!1})]})})]}):(0,y.jsx)("div",{className:u.emptyState,children:"Please select a project to browse files"})};var oi=n(s());var hp=w(({token:e,css:t})=>({root:t`
819
851
  display: flex;
820
852
  flex-direction: column;
821
853
  height: 100%;
@@ -840,7 +872,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
840
872
  flex: 1;
841
873
  min-height: 0;
842
874
  overflow: hidden;
843
- `}));var ha=n(S());var Qn=n(s());var qd=w(({token:e,css:t})=>({root:t`
875
+ `}));var Ba=n(C());var ni=n(s());var Sp=w(({token:e,css:t})=>({root:t`
844
876
  display: flex;
845
877
  flex-direction: column;
846
878
  height: 100%;
@@ -921,7 +953,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
921
953
  height: 32px;
922
954
  opacity: 0.5;
923
955
  }
924
- `}));var Yn=n(s());var fp=w(({token:e,css:t})=>({root:t`
956
+ `}));var ri=n(s());var Vp=w(({token:e,css:t})=>({root:t`
925
957
  display: flex;
926
958
  flex-direction: column;
927
959
  height: 100%;
@@ -948,11 +980,11 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
948
980
  flex: 1;
949
981
  min-height: 0;
950
982
  min-width: 0;
951
- `}));var Ca=n(s()),Sp=w(({css:e})=>({wrapper:e`
983
+ `}));var $a=n(s()),tm=w(({css:e})=>({wrapper:e`
952
984
  height: 100%;
953
985
  width: 100%;
954
986
  overflow: hidden;
955
- `}));var Jn=n(s()),Mp=w(({token:e,css:t})=>({menuList:t`
987
+ `}));var sn=n(s()),pm=w(({token:e,css:t})=>({menuList:t`
956
988
  height: 100%;
957
989
  overflow-y: auto;
958
990
  `,header:t`
@@ -977,7 +1009,34 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
977
1009
  color: ${e.colorTextSecondary};
978
1010
  font-size: 14px;
979
1011
  gap: 8px;
980
- `}));var ei=n(S());var tr=n(S());var Zn=n(s()),$p=w(({token:e,css:t})=>({container:t`
1012
+ `,mobileRoot:t`
1013
+ display: flex;
1014
+ flex-direction: column;
1015
+ height: 100%;
1016
+ overflow: hidden;
1017
+ `,mobileHeader:t`
1018
+ display: flex;
1019
+ align-items: center;
1020
+ gap: 4px;
1021
+ flex-shrink: 0;
1022
+ min-height: 48px;
1023
+ padding: 0 8px;
1024
+ border-bottom: 1px solid ${e.colorBorderSecondary};
1025
+ `,backButton:t`
1026
+ width: 44px;
1027
+ height: 44px;
1028
+ display: flex;
1029
+ align-items: center;
1030
+ justify-content: center;
1031
+ border: none;
1032
+ background: transparent;
1033
+ color: ${e.colorText};
1034
+ cursor: pointer;
1035
+ `,mobileBody:t`
1036
+ flex: 1;
1037
+ min-height: 0;
1038
+ overflow: hidden;
1039
+ `}));var si=n(C());var ln=n(C());var ii=n(s()),vm=w(({token:e,css:t})=>({container:t`
981
1040
  display: flex;
982
1041
  flex-direction: column;
983
1042
  height: 100%;
@@ -1064,7 +1123,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1064
1123
  color: ${e.colorPrimary};
1065
1124
  `,emptyContainer:t`
1066
1125
  padding: 24px 16px;
1067
- `}));var or=n(s()),_p=w(({token:e,css:t})=>({container:t`
1126
+ `}));var ai=n(s()),wm=w(({token:e,css:t})=>({container:t`
1068
1127
  display: flex;
1069
1128
  flex-direction: column;
1070
1129
  height: 100%;
@@ -1073,7 +1132,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1073
1132
  display: flex;
1074
1133
  align-items: flex-start;
1075
1134
  justify-content: space-between;
1076
- padding: 20px 24px;
1135
+ padding: 24px;
1077
1136
  border-bottom: 1px solid ${e.colorBorderSecondary};
1078
1137
  `,headerInfo:t`
1079
1138
  display: flex;
@@ -1096,16 +1155,33 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1096
1155
  `,headerText:t`
1097
1156
  display: flex;
1098
1157
  flex-direction: column;
1099
- gap: 4px;
1158
+ gap: 6px;
1100
1159
  `,name:t`
1101
1160
  margin: 0;
1102
1161
  font-size: 20px;
1103
1162
  font-weight: 600;
1104
1163
  color: ${e.colorText};
1105
- `,type:t`
1164
+ `,subtitle:t`
1106
1165
  margin: 0;
1107
1166
  font-size: 14px;
1108
1167
  color: ${e.colorTextSecondary};
1168
+ `,description:t`
1169
+ margin: 4px 0 0 0;
1170
+ font-size: 13px;
1171
+ color: ${e.colorTextSecondary};
1172
+ max-width: 420px;
1173
+ `,statusActive:t`
1174
+ background: ${e.colorSuccessBg};
1175
+ color: ${e.colorSuccess};
1176
+ border-color: ${e.colorSuccess};
1177
+ `,statusPaused:t`
1178
+ background: ${e.colorWarningBg};
1179
+ color: ${e.colorWarning};
1180
+ border-color: ${e.colorWarning};
1181
+ `,statusRemoved:t`
1182
+ background: ${e.colorErrorBg};
1183
+ color: ${e.colorError};
1184
+ border-color: ${e.colorError};
1109
1185
  `,closeButton:t`
1110
1186
  padding: 8px;
1111
1187
  border: none;
@@ -1116,7 +1192,6 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1116
1192
  display: flex;
1117
1193
  align-items: center;
1118
1194
  justify-content: center;
1119
-
1120
1195
  &:hover {
1121
1196
  background: ${e.colorFillQuaternary};
1122
1197
  color: ${e.colorText};
@@ -1125,8 +1200,9 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1125
1200
  flex: 1;
1126
1201
  padding: 24px;
1127
1202
  overflow-y: auto;
1128
- `,section:t`
1129
- margin-bottom: 24px;
1203
+ display: flex;
1204
+ flex-direction: column;
1205
+ gap: 24px;
1130
1206
  `,sectionTitle:t`
1131
1207
  font-size: 13px;
1132
1208
  font-weight: 600;
@@ -1137,34 +1213,10 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1137
1213
  `,footer:t`
1138
1214
  padding: 16px 24px;
1139
1215
  border-top: 1px solid ${e.colorBorderSecondary};
1140
- display: flex;
1141
- gap: 12px;
1142
- `,roleTag:t`
1143
- display: inline-flex;
1144
- align-items: center;
1145
- gap: 4px;
1146
- `,statusActive:t`
1147
- background: ${e.colorSuccessBg};
1148
- color: ${e.colorSuccess};
1149
- border-color: ${e.colorSuccess};
1150
- `,statusPaused:t`
1151
- background: ${e.colorWarningBg};
1152
- color: ${e.colorWarning};
1153
- border-color: ${e.colorWarning};
1154
- `,statusRemoved:t`
1155
- background: ${e.colorErrorBg};
1156
- color: ${e.colorError};
1157
- border-color: ${e.colorError};
1158
- `,emptyState:t`
1159
1216
  display: flex;
1160
1217
  flex-direction: column;
1161
- align-items: center;
1162
- justify-content: center;
1163
- height: 100%;
1164
- color: ${e.colorTextSecondary};
1165
- font-size: 14px;
1166
- gap: 8px;
1167
- `}));var ti=n(s()),Qp=w(({token:e,css:t})=>({menuList:t`
1218
+ gap: 12px;
1219
+ `}));var cn=n(s()),Mm=w(({token:e,css:t})=>({menuList:t`
1168
1220
  height: 100%;
1169
1221
  overflow-y: auto;
1170
1222
  `,header:t`
@@ -1189,7 +1241,34 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1189
1241
  color: ${e.colorTextSecondary};
1190
1242
  font-size: 14px;
1191
1243
  gap: 8px;
1192
- `}));var oi=n(s()),nm=w(({token:e,css:t})=>({iconNav:t`
1244
+ `,mobileRoot:t`
1245
+ display: flex;
1246
+ flex-direction: column;
1247
+ height: 100%;
1248
+ overflow: hidden;
1249
+ `,mobileHeader:t`
1250
+ display: flex;
1251
+ align-items: center;
1252
+ gap: 4px;
1253
+ flex-shrink: 0;
1254
+ min-height: 48px;
1255
+ padding: 0 8px;
1256
+ border-bottom: 1px solid ${e.colorBorderSecondary};
1257
+ `,backButton:t`
1258
+ width: 44px;
1259
+ height: 44px;
1260
+ display: flex;
1261
+ align-items: center;
1262
+ justify-content: center;
1263
+ border: none;
1264
+ background: transparent;
1265
+ color: ${e.colorText};
1266
+ cursor: pointer;
1267
+ `,mobileBody:t`
1268
+ flex: 1;
1269
+ min-height: 0;
1270
+ overflow: hidden;
1271
+ `}));var ci=n(s()),qm=w(({token:e,css:t})=>({iconNav:t`
1193
1272
  display: flex;
1194
1273
  flex-direction: column;
1195
1274
  align-items: center;
@@ -1232,7 +1311,40 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1232
1311
  height: 100%;
1233
1312
  width: 100%;
1234
1313
  overflow: hidden;
1235
- `}));var Na=n(s());var zt=n(S());var co=18,hm={agent:zt.default.createElement(At,{size:co}),html:zt.default.createElement(cn,{size:co}),custom:zt.default.createElement(hn,{size:co}),file:zt.default.createElement(sn,{size:co})};var qa=n(S());var Ba=n(S());var ri=n(s());var Ka=n(S());var po=n(S());var dt=n(S());function ni(e){let{get:t}=me(),[o,r]=(0,dt.useState)(null),[a,i]=(0,dt.useState)(!0),[d,c]=(0,dt.useState)(!1);(0,dt.useEffect)(()=>{let b=!0,x=e||"/api/middleware-types";return i(!0),c(!1),r(null),t(x).then(h=>{if(!b)return;if(!Array.isArray(h)||h.length===0){c(!0);return}let u=h.map(m=>({type:m.type,name:m.name,description:m.description,icon:m.icon,tools:Array.isArray(m.tools)?m.tools.map(v=>({id:v.name,name:v.name,description:v.description})):[],schema:m.configSchema,defaultConfig:m.defaultConfig||{},category:m.category,capabilityBundleEligible:m.capabilityBundleEligible===!0,connectionSchema:m.connectionSchema?{fields:m.connectionSchema.fields,hasTest:m.connectionSchema.hasTest,hasDiscover:m.connectionSchema.hasDiscover,resourceLabel:m.connectionSchema.resourceLabel}:void 0}));r(u)}).catch(()=>{b&&c(!0)}).finally(()=>{b&&i(!1)}),()=>{b=!1}},[e,t]);let p=new Set(["topology"]);return{middlewareTypes:(0,dt.useMemo)(()=>(o||_r).filter(b=>!p.has(b.type)),[o]),isLoading:a,isFallback:d}}var ii=w(({token:e,css:t})=>({nav:t`
1314
+ `,mobileRoot:t`
1315
+ display: flex;
1316
+ flex-direction: column;
1317
+ height: 100%;
1318
+ width: 100%;
1319
+ overflow: hidden;
1320
+ `,mobilePage:t`
1321
+ flex: 1;
1322
+ min-height: 0;
1323
+ overflow: hidden;
1324
+ `,tabBar:t`
1325
+ display: flex;
1326
+ flex-shrink: 0;
1327
+ border-top: 1px solid ${e.colorBorderSecondary};
1328
+ background: ${e.colorBgContainer};
1329
+ padding-bottom: env(safe-area-inset-bottom);
1330
+ `,tabButton:t`
1331
+ flex: 1;
1332
+ min-height: 48px;
1333
+ display: flex;
1334
+ flex-direction: column;
1335
+ align-items: center;
1336
+ justify-content: center;
1337
+ gap: 2px;
1338
+ border: none;
1339
+ background: transparent;
1340
+ cursor: pointer;
1341
+ color: ${e.colorTextSecondary};
1342
+ font-size: 11px;
1343
+
1344
+ &.active {
1345
+ color: ${e.colorPrimary};
1346
+ }
1347
+ `}));var Ga=n(s());var _t=n(C());var mo=18,iu={agent:_t.default.createElement(Nt,{size:mo}),html:_t.default.createElement(yr,{size:mo}),custom:_t.default.createElement(kr,{size:mo}),file:_t.default.createElement(gr,{size:mo})};var ss=n(C());var Qa=n(C());var di=n(s());var as=n(C());var uo=n(C());var dt=n(C());function pi(e){let{get:t}=me(),[o,r]=(0,dt.useState)(null),[a,i]=(0,dt.useState)(!0),[d,c]=(0,dt.useState)(!1);(0,dt.useEffect)(()=>{let b=!0,x=e||"/api/middleware-types";return i(!0),c(!1),r(null),t(x).then(h=>{if(!b)return;if(!Array.isArray(h)||h.length===0){c(!0);return}let u=h.map(m=>({type:m.type,name:m.name,description:m.description,icon:m.icon,tools:Array.isArray(m.tools)?m.tools.map(v=>({id:v.name,name:v.name,description:v.description})):[],schema:m.configSchema,defaultConfig:m.defaultConfig||{},category:m.category,capabilityBundleEligible:m.capabilityBundleEligible===!0,connectionSchema:m.connectionSchema?{fields:m.connectionSchema.fields,hasTest:m.connectionSchema.hasTest,hasDiscover:m.connectionSchema.hasDiscover,resourceLabel:m.connectionSchema.resourceLabel}:void 0}));r(u)}).catch(()=>{b&&c(!0)}).finally(()=>{b&&i(!1)}),()=>{b=!1}},[e,t]);let p=new Set(["topology"]);return{middlewareTypes:(0,dt.useMemo)(()=>(o||Qn).filter(b=>!p.has(b.type)),[o]),isLoading:a,isFallback:d}}var mi=w(({token:e,css:t})=>({nav:t`
1236
1348
  width: clamp(180px, 20vw, 240px);
1237
1349
  flex-shrink: 0;
1238
1350
  border-right: 1px solid ${e.colorBorderSecondary};
@@ -1346,7 +1458,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1346
1458
  height: 6px;
1347
1459
  border-radius: 9999px;
1348
1460
  flex-shrink: 0;
1349
- `}));var ai=n(s()),{Text:Am}=E;var ue=n(S());var pt=n(S());var je=n(s()),{Text:si}=E,li=({connectionType:e,value:t=[],onChange:o})=>{let{token:r}=Le.useToken(),{get:a}=me(),[i,d]=(0,pt.useState)([]),[c,p]=(0,pt.useState)(!0),g=(0,pt.useRef)(e),b=(0,pt.useRef)(o);b.current=o,(0,pt.useEffect)(()=>{let h=!0;return g.current!==e&&(g.current=e,b.current([])),d([]),p(!0),a(`/api/connections?type=${encodeURIComponent(e)}`).then(u=>{h&&(Array.isArray(u)?d(u):u?.data?.records&&d(u.data.records))}).catch(()=>{h&&d([])}).finally(()=>{h&&p(!1)}),()=>{h=!1}},[e,a]);let x=new Set(t);return c?(0,je.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,je.jsx)(de,{size:"small"})}):i.length===0?(0,je.jsx)(we,{description:`No "${e}" connections`,image:we.PRESENTED_IMAGE_SIMPLE}):(0,je.jsxs)("div",{children:[(0,je.jsxs)(ce,{style:{marginBottom:8},children:[(0,je.jsx)(j,{size:"small",onClick:()=>o(i.map(h=>h.key)),children:"Select All"}),(0,je.jsx)(j,{size:"small",onClick:()=>o([]),children:"Deselect All"})]}),(0,je.jsx)(ke,{size:"small",style:{maxHeight:"30vh",overflowY:"auto"},children:i.map(h=>(0,je.jsx)(ke.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:r.borderRadius,backgroundColor:x.has(h.key)?r.colorPrimaryBg:"transparent",border:`1px solid ${x.has(h.key)?r.colorPrimary:"transparent"}`,marginBottom:4},onClick:()=>{x.has(h.key)?o(t.filter(u=>u!==h.key)):o([...t,h.key])},children:(0,je.jsx)(ke.Item.Meta,{avatar:(0,je.jsx)(_e,{checked:x.has(h.key)}),title:(0,je.jsx)(si,{style:{fontSize:12},children:h.name}),description:h.description?(0,je.jsx)(si,{type:"secondary",style:{fontSize:10},children:h.description}):void 0})},h.key))})]})};var l=n(s()),{Text:be}=E,rr=w(({token:e,css:t})=>({pageHeader:t`
1461
+ `}));var ui=n(s()),{Text:hu}=P;var ue=n(C());var pt=n(C());var je=n(s()),{Text:gi}=P,fi=({connectionType:e,value:t=[],onChange:o})=>{let{token:r}=_e.useToken(),{get:a}=me(),[i,d]=(0,pt.useState)([]),[c,p]=(0,pt.useState)(!0),g=(0,pt.useRef)(e),b=(0,pt.useRef)(o);b.current=o,(0,pt.useEffect)(()=>{let h=!0;return g.current!==e&&(g.current=e,b.current([])),d([]),p(!0),a(`/api/connections?type=${encodeURIComponent(e)}`).then(u=>{h&&(Array.isArray(u)?d(u):u?.data?.records&&d(u.data.records))}).catch(()=>{h&&d([])}).finally(()=>{h&&p(!1)}),()=>{h=!1}},[e,a]);let x=new Set(t);return c?(0,je.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,je.jsx)(ne,{size:"small"})}):i.length===0?(0,je.jsx)(xe,{description:`No "${e}" connections`,image:xe.PRESENTED_IMAGE_SIMPLE}):(0,je.jsxs)("div",{children:[(0,je.jsxs)(ce,{style:{marginBottom:8},children:[(0,je.jsx)(z,{size:"small",onClick:()=>o(i.map(h=>h.key)),children:"Select All"}),(0,je.jsx)(z,{size:"small",onClick:()=>o([]),children:"Deselect All"})]}),(0,je.jsx)(Te,{size:"small",style:{maxHeight:"30vh",overflowY:"auto"},children:i.map(h=>(0,je.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:r.borderRadius,backgroundColor:x.has(h.key)?r.colorPrimaryBg:"transparent",border:`1px solid ${x.has(h.key)?r.colorPrimary:"transparent"}`,marginBottom:4},onClick:()=>{x.has(h.key)?o(t.filter(u=>u!==h.key)):o([...t,h.key])},children:(0,je.jsx)(Te.Item.Meta,{avatar:(0,je.jsx)(Le,{checked:x.has(h.key)}),title:(0,je.jsx)(gi,{style:{fontSize:12},children:h.name}),description:h.description?(0,je.jsx)(gi,{type:"secondary",style:{fontSize:10},children:h.description}):void 0})},h.key))})]})};var l=n(s()),{Text:we}=P,dn=w(({token:e,css:t})=>({pageHeader:t`
1350
1462
  display: flex;
1351
1463
  align-items: center;
1352
1464
  gap: 16px;
@@ -1415,7 +1527,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1415
1527
  grid-template-columns: repeat(2, minmax(0, 1fr));
1416
1528
  gap: 12px 16px;
1417
1529
  padding: 8px 0;
1418
- `})),mo=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:a,onSearchChange:i,onSelectAll:d,onClearAll:c,children:p,styles:g})=>{let b=o>0&&t===o;return(0,l.jsxs)("div",{className:g.dataSection,children:[(0,l.jsxs)("div",{className:g.dataSectionHeader,children:[(0,l.jsxs)(be,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(be,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(j,{type:"link",size:"small",onClick:b?c:d,children:b?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(q,{size:"small",allowClear:!0,prefix:(0,l.jsx)(Jr,{style:{fontSize:12}}),placeholder:r,value:a,onChange:x=>i(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:g.dataList,children:p})]})},Da=({text:e,className:t})=>(0,l.jsx)($e,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),Fa=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:a})=>{let i=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(g=>g!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(g=>p.includes(g))?void 0:p)}};return(0,l.jsxs)("div",{className:a.dataSection,children:[(0,l.jsxs)("div",{className:a.dataSectionHeader,children:[(0,l.jsxs)(be,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(be,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(j,{type:"link",size:"small",onClick:()=>r(i?[]:void 0),children:i?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:a.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Lo,{item:c,dense:!0,className:p?a.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(Da,{text:c.description,className:a.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(_e,{checked:p,onClick:g=>g.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},ja=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/skills");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch skills:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(mo,{title:"Skill Library",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(de,{size:"small"})}):u.length===0?(0,l.jsx)(we,{description:"No skills available",image:we.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(ke,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.id);return(0,l.jsx)(ke.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(_=>_!==m.id):[...h,m.id]),children:(0,l.jsx)(ke.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(be,{strong:v,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(be,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},za=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/database-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch database configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(mo,{title:"Databases",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(de,{size:"small"})}):u.length===0?(0,l.jsx)(we,{description:"No databases available",image:we.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(ke,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(ke.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(_=>_!==m.key):[...h,m.key]),children:(0,l.jsx)(ke.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(be,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(be,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},$a=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/metrics-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch metrics configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(mo,{title:"Metrics Servers",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(de,{size:"small"})}):u.length===0?(0,l.jsx)(we,{description:"No servers available",image:we.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(ke,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(ke.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(_=>_!==m.key):[...h,m.key]),children:(0,l.jsx)(ke.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(be,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(be,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},La=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{x.current||(x.current=!0,c(!0),b("/api/collections").then(m=>{m.success&&i(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(mo,{title:"Collections",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(de,{size:"small"})}):u.length===0?(0,l.jsx)(we,{description:"No collections available",image:we.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(ke,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.name);return(0,l.jsx)(ke.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(_=>_!==m.name):[...h,m.name]),children:(0,l.jsx)(ke.Item.Meta,{avatar:(0,l.jsx)(_e,{checked:v}),title:(0,l.jsx)(be,{strong:v,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(be,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},Oa=({value:e,onChange:t,token:o,styles:r})=>{let a=Array.isArray(e)?e:[],[i,d]=(0,ue.useState)({from:"",to:"",purpose:""}),c=()=>{!i.from.trim()||!i.to.trim()||!i.purpose.trim()||(t([...a,{...i}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(be,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(be,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[a.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:a.length===0?(0,l.jsx)(we,{description:"No dependencies defined yet",image:we.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):a.map((p,g)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(Ce,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(be,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(Ce,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(be,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(j,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(qr,{}),onClick:()=>t(a.filter((b,x)=>x!==g))})]},g))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(be,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(ce,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(q,{size:"small",placeholder:"Source Agent ID",value:i.from,onChange:p=>d({...i,from:p.target.value})}),(0,l.jsx)(q,{size:"small",placeholder:"Target Agent ID",value:i.to,onChange:p=>d({...i,to:p.target.value})}),(0,l.jsx)(q,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:i.purpose,onChange:p=>d({...i,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(j,{type:"dashed",size:"small",icon:(0,l.jsx)(Yr,{}),onClick:c,disabled:!i.from.trim()||!i.to.trim()||!i.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},ci=(e,t,o,r,a)=>{let i=t.title||e,d=t.description?(0,l.jsx)($e,{title:t.description,children:(0,l.jsx)(Xr,{style:{color:a.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(be,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(wt,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let g=t.enum?.map(b=>({value:b,label:{global:"Global",agent:"Agent",project:"Project"}[b]||b}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(be,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(Mr,{size:"small",value:o,onChange:r,options:g})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[i,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(q,{size:"small",type:"number",value:o,onChange:g=>r(parseFloat(g.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let g=t.enumLabels,b=g?Object.entries(g).map(([x,h])=>({value:x,label:h})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Fe,{size:"small",value:o,onChange:r,options:b,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(q.TextArea,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(q,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(be,{style:{fontSize:12,color:a.colorTextSecondary},children:c}),p]},e)}},di=({type:e})=>{let{token:t}=Le.useToken();switch(e){case"browser":return(0,l.jsx)(Gr,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(No,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(en,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(Vr,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(Ur,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Gt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(Zr,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(Hr,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(No,{style:{color:t.colorInfo}});default:return(0,l.jsx)(Qr,{style:{color:t.colorWarning}})}},_a=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:a,enabledAriaLabel:i,sectionTitles:d,headerActions:c,token:p,styles:g,renderListSubSection:b})=>{let x=t?.schema?.properties??{},h=Object.keys(x),u=h.filter(C=>{let F=x[C];return F.widget==="skillSelect"||F.widget==="databaseSelect"||F.widget==="metricsSelect"||F.widget==="collectionSelect"||F.widget==="connectionSelect"||F.widget==="topologyEdgeBuilder"}),m=h.filter(C=>{let F=x[C];return u.includes(C)?!1:F.widget==="switch"||F.widget==="segmented"}),v=h.filter(C=>!(u.includes(C)||m.includes(C)||C==="vmIsolation")),_=u.filter(C=>{let F=x[C];return C==="skills"&&e.config.readAll===!0||C==="serverKeys"&&e.config.connectAll===!0||C==="collectionKeys"&&e.config.connectAll===!0||C==="connections"&&e.config.connectAll===!0?!1:!!F.widget}),L=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(C=>{let F=x[C],{row:J}=ci(C,F,e.config[C]??F.default,Z=>r({[C]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},C)}),v.length>0&&(0,l.jsx)("div",{className:g.configGrid,children:v.map(C=>{let F=x[C],{gridItem:J}=ci(C,F,e.config[C]??F.default,Z=>r({[C]:Z}),p);return J})})]}),A=t?.tools,Y=A?.map(C=>C.name)??[],ee=e.allowedTools??Y,le=A&&A.length>0,V=m.length>0||v.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:g.pageHeader,children:[(0,l.jsx)("div",{className:g.pageIcon,children:(0,l.jsx)(di,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:g.pageName,children:e.name}),(0,l.jsx)("p",{className:g.pageDesc,children:e.description})]}),(0,l.jsxs)(ce,{size:10,children:[c,(0,l.jsx)(Ce,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(wt,{"aria-label":i,checked:e.enabled,onChange:C=>{if(o(),C){let F=t;F?.defaultConfig&&!e.config&&r(F.defaultConfig)}}})]})]}),V&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:g.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:L()})]}),_.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),_.map(C=>{let F=x[C],J=e.config[C]??F.default??[];return b(C,F,J,Z=>r({[C]:Z}),e.type)})]}),le&&A&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(Fa,{tools:A,selectedToolNames:ee,allToolNames:Y,onChange:a,styles:g})]})]})},Wa=e=>{let{token:t}=Le.useToken(),{styles:o}=rr();return(0,l.jsx)(_a,{...e,token:t,styles:o,renderListSubSection:(a,i,d,c,p)=>{switch(i.widget){case"skillSelect":return(0,l.jsx)(ja,{value:d,onChange:c,token:t,styles:o},a);case"databaseSelect":return(0,l.jsx)(za,{value:d,onChange:c,token:t,styles:o},a);case"metricsSelect":return(0,l.jsx)($a,{value:d,onChange:c,token:t,styles:o},a);case"collectionSelect":return(0,l.jsx)(La,{value:d,onChange:c,token:t,styles:o},a);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(be,{strong:!0,style:{fontSize:13},children:i.title||"Connections"})}),(0,l.jsx)(li,{connectionType:i.connectionType??(a==="connections"?p:""),value:d||[],onChange:c})]},a);case"topologyEdgeBuilder":return(0,l.jsx)(Oa,{value:d,onChange:c,token:t,styles:o},a);default:return null}}})};var pi=n(s()),{Text:Xm}=E,Jm=w(({css:e,token:t})=>({toolRow:e`
1530
+ `})),go=({title:e,selectedCount:t,totalCount:o,searchPlaceholder:r,searchText:a,onSearchChange:i,onSelectAll:d,onClearAll:c,children:p,styles:g})=>{let b=o>0&&t===o;return(0,l.jsxs)("div",{className:g.dataSection,children:[(0,l.jsxs)("div",{className:g.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:[e,(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t," / ",o," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:b?c:d,children:b?"Clear":"Select All"})})]}),(0,l.jsx)("div",{style:{marginBottom:10},children:(0,l.jsx)(H,{size:"small",allowClear:!0,prefix:(0,l.jsx)(ar,{style:{fontSize:12}}),placeholder:r,value:a,onChange:x=>i(x.target.value),style:{width:"100%"}})}),(0,l.jsx)("div",{className:g.dataList,children:p})]})},Ya=({text:e,className:t})=>(0,l.jsx)(ze,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),Xa=({tools:e,selectedToolNames:t,allToolNames:o,onChange:r,styles:a})=>{let i=e.length>0&&t.length===o.length,d=c=>{if(t.includes(c)){let p=t.filter(g=>g!==c);r(p.length===0?void 0:p)}else{let p=[...t,c];r(p.length===o.length&&o.every(g=>p.includes(g))?void 0:p)}};return(0,l.jsxs)("div",{className:a.dataSection,children:[(0,l.jsxs)("div",{className:a.dataSectionHeader,children:[(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Tools",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[t.length," / ",o.length," selected"]})]}),(0,l.jsx)(ce,{size:4,children:(0,l.jsx)(z,{type:"link",size:"small",onClick:()=>r(i?[]:void 0),children:i?"Clear":"Select All"})})]}),(0,l.jsx)("div",{className:a.toolsGrid,children:e.map(c=>{let p=t.includes(c.name);return(0,l.jsx)(Dt,{item:c,dense:!0,className:p?a.selectedCard:void 0,onClick:()=>d(c.name),renderIcon:()=>(0,l.jsx)("span",{style:{fontSize:14,fontWeight:600},children:c.name.charAt(0).toUpperCase()}),renderPrimary:()=>c.name,renderDetails:()=>(0,l.jsx)(Ya,{text:c.description,className:a.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(Le,{checked:p,onClick:g=>g.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},Ja=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/skills");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch skills:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>m.name.toLowerCase().includes(p.toLowerCase())||m.description.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Skill Library",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search skills\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.id)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No skills available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.id);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.id):[...h,m.id]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description})})},m.id)}})})},Za=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/database-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch database configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Databases",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search databases\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No databases available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},es=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{if(x.current)return;x.current=!0,(async()=>{c(!0);try{let v=await b("/api/metrics-configs");v.success&&v.data&&Array.isArray(v.data.records)&&i(v.data.records)}catch(v){console.error("Failed to fetch metrics configs:",v)}finally{c(!1)}})()},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.name||m.key).toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Metrics Servers",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search servers\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.key)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No servers available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.key);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.key):[...h,m.key]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.name||m.key}),description:m.description?(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.description}):void 0})},m.key)}})})},ts=({value:e,onChange:t,token:o,styles:r})=>{let[a,i]=(0,ue.useState)([]),[d,c]=(0,ue.useState)(!1),[p,g]=(0,ue.useState)(""),{get:b}=me(),x=(0,ue.useRef)(!1);(0,ue.useEffect)(()=>{x.current||(x.current=!0,c(!0),b("/api/collections").then(m=>{m.success&&i(m.data.records)}).catch(()=>{}).finally(()=>c(!1)))},[b]);let h=Array.isArray(e)?e:[],u=a.filter(m=>(m.label||m.name).toLowerCase().includes(p.toLowerCase())||m.name.toLowerCase().includes(p.toLowerCase()));return(0,l.jsx)(go,{title:"Collections",selectedCount:h.length,totalCount:a.length,searchPlaceholder:"Search collections\u2026",searchText:p,onSearchChange:g,onSelectAll:()=>t(a.map(m=>m.name)),onClearAll:()=>t([]),styles:r,children:d?(0,l.jsx)("div",{style:{textAlign:"center",padding:20},children:(0,l.jsx)(ne,{size:"small"})}):u.length===0?(0,l.jsx)(xe,{description:"No collections available",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):(0,l.jsx)(Te,{dataSource:u,split:!1,size:"small",renderItem:m=>{let v=h.includes(m.name);return(0,l.jsx)(Te.Item,{style:{padding:"6px 8px",cursor:"pointer",borderRadius:o.borderRadius,backgroundColor:v?o.colorSuccessBg:"transparent",border:`1px solid ${v?o.colorSuccess:"transparent"}`,marginBottom:4,transition:"all 0.15s ease"},onClick:()=>t(v?h.filter(O=>O!==m.name):[...h,m.name]),children:(0,l.jsx)(Te.Item.Meta,{avatar:(0,l.jsx)(Le,{checked:v}),title:(0,l.jsx)(we,{strong:v,style:{fontSize:13},children:m.label||m.name}),description:(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},ellipsis:!0,children:m.name})})},m.name)}})})},os=({value:e,onChange:t,token:o,styles:r})=>{let a=Array.isArray(e)?e:[],[i,d]=(0,ue.useState)({from:"",to:"",purpose:""}),c=()=>{!i.from.trim()||!i.to.trim()||!i.purpose.trim()||(t([...a,{...i}]),d({from:"",to:"",purpose:""}))};return(0,l.jsxs)("div",{className:r.dataSection,children:[(0,l.jsx)("div",{className:r.dataSectionHeader,children:(0,l.jsxs)(we,{strong:!0,style:{fontSize:13},children:["Dependencies",(0,l.jsxs)(we,{type:"secondary",style:{fontSize:12,marginLeft:8},children:[a.length," edges"]})]})}),(0,l.jsx)("div",{className:r.dataList,children:a.length===0?(0,l.jsx)(xe,{description:"No dependencies defined yet",image:xe.PRESENTED_IMAGE_SIMPLE,style:{padding:12}}):a.map((p,g)=>(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",marginBottom:4,borderRadius:o.borderRadius,backgroundColor:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`},children:[(0,l.jsx)(ve,{color:"blue",style:{margin:0,fontSize:11},children:p.from}),(0,l.jsx)(we,{type:"secondary",style:{fontSize:12},children:"\u2192"}),(0,l.jsx)(ve,{color:"green",style:{margin:0,fontSize:11},children:p.to}),(0,l.jsx)(we,{style:{fontSize:12,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.purpose}),(0,l.jsx)(z,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(Zn,{}),onClick:()=>t(a.filter((b,x)=>x!==g))})]},g))}),(0,l.jsxs)("div",{style:{borderTop:`1px solid ${o.colorBorderSecondary}`,paddingTop:12,marginTop:12},children:[(0,l.jsx)(we,{strong:!0,style:{fontSize:13,display:"block",marginBottom:8},children:"Add Dependency"}),(0,l.jsxs)(ce,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,l.jsx)(H,{size:"small",placeholder:"Source Agent ID",value:i.from,onChange:p=>d({...i,from:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Target Agent ID",value:i.to,onChange:p=>d({...i,to:p.target.value})}),(0,l.jsx)(H,{size:"small",placeholder:"Purpose (e.g. classify invoice fields)",value:i.purpose,onChange:p=>d({...i,purpose:p.target.value}),onPressEnter:c}),(0,l.jsx)(z,{type:"dashed",size:"small",icon:(0,l.jsx)(rr,{}),onClick:c,disabled:!i.from.trim()||!i.to.trim()||!i.purpose.trim(),block:!0,children:"Add Edge"})]})]})]})},yi=(e,t,o,r,a)=>{let i=t.title||e,d=t.description?(0,l.jsx)(ze,{title:t.description,children:(0,l.jsx)(ir,{style:{color:a.colorTextSecondary,cursor:"pointer"}})}):null;if(t.widget==="switch"||!t.widget&&t.type==="boolean")return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(Ct,{size:"small",checked:o,onChange:r})]},e),gridItem:null};if(t.widget==="segmented"){let g=t.enum?.map(b=>({value:b,label:{global:"Global",agent:"Agent",project:"Project"}[b]||b}))||[];return{row:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 0"},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,l.jsx)(we,{style:{fontSize:13},children:i}),d]}),(0,l.jsx)(_n,{size:"small",value:o,onChange:r,options:g})]},e),gridItem:null}}let c=(0,l.jsxs)("span",{children:[i,d&&(0,l.jsxs)(l.Fragment,{children:["\xA0",d]})]}),p;if(t.type==="number"||t.type==="integer")p=(0,l.jsx)(H,{size:"small",type:"number",value:o,onChange:g=>r(parseFloat(g.target.value)||t.default),min:t.minimum,max:t.maximum,style:{width:"100%"}});else if(t.widget==="select"||t.enum&&!t.widget){let g=t.enumLabels,b=g?Object.entries(g).map(([x,h])=>({value:x,label:h})):t.enum?.map(x=>({value:x,label:x}))||[];p=(0,l.jsx)(Ee,{size:"small",value:o,onChange:r,options:b,style:{width:"100%"}})}else t.widget==="textarea"?p=(0,l.jsx)(H.TextArea,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default,autoSize:{minRows:2,maxRows:4}}):p=(0,l.jsx)(H,{size:"small",value:o,onChange:g=>r(g.target.value),placeholder:t.default});return{row:null,gridItem:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,l.jsx)(we,{style:{fontSize:12,color:a.colorTextSecondary},children:c}),p]},e)}},hi=({type:e})=>{let{token:t}=_e.useToken();switch(e){case"browser":return(0,l.jsx)(or,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(Fo,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(lr,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(tr,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(Xn,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Xt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(sr,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(er,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(Fo,{style:{color:t.colorInfo}});default:return(0,l.jsx)(nr,{style:{color:t.colorWarning}})}},ns=({middleware:e,middlewareType:t,onToggle:o,onConfigChange:r,onAllowedToolsChange:a,enabledAriaLabel:i,sectionTitles:d,headerActions:c,token:p,styles:g,renderListSubSection:b})=>{let x=t?.schema?.properties??{},h=Object.keys(x),u=h.filter(S=>{let F=x[S];return F.widget==="skillSelect"||F.widget==="databaseSelect"||F.widget==="metricsSelect"||F.widget==="collectionSelect"||F.widget==="connectionSelect"||F.widget==="topologyEdgeBuilder"}),m=h.filter(S=>{let F=x[S];return u.includes(S)?!1:F.widget==="switch"||F.widget==="segmented"}),v=h.filter(S=>!(u.includes(S)||m.includes(S)||S==="vmIsolation")),O=u.filter(S=>{let F=x[S];return S==="skills"&&e.config.readAll===!0||S==="serverKeys"&&e.config.connectAll===!0||S==="collectionKeys"&&e.config.connectAll===!0||S==="connections"&&e.config.connectAll===!0?!1:!!F.widget}),L=()=>(0,l.jsxs)(l.Fragment,{children:[m.map(S=>{let F=x[S],{row:J}=yi(S,F,e.config[S]??F.default,Z=>r({[S]:Z}),p);return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:J},S)}),v.length>0&&(0,l.jsx)("div",{className:g.configGrid,children:v.map(S=>{let F=x[S],{gridItem:J}=yi(S,F,e.config[S]??F.default,Z=>r({[S]:Z}),p);return J})})]}),E=t?.tools,Y=E?.map(S=>S.name)??[],ee=e.allowedTools??Y,de=E&&E.length>0,V=m.length>0||v.length>0;return(0,l.jsxs)("div",{style:{maxWidth:960},children:[(0,l.jsxs)("div",{className:g.pageHeader,children:[(0,l.jsx)("div",{className:g.pageIcon,children:(0,l.jsx)(hi,{type:e.type})}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsx)("h2",{className:g.pageName,children:e.name}),(0,l.jsx)("p",{className:g.pageDesc,children:e.description})]}),(0,l.jsxs)(ce,{size:10,children:[c,(0,l.jsx)(ve,{color:e.enabled?"success":"default",style:{margin:0,fontSize:11},children:e.enabled?"Enabled":"Disabled"}),(0,l.jsx)(Ct,{"aria-label":i,checked:e.enabled,onChange:S=>{if(o(),S){let F=t;F?.defaultConfig&&!e.config&&r(F.defaultConfig)}}})]})]}),V&&(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:g.blockTitle,children:d?.config??"Config"}),(0,l.jsx)("div",{style:{marginTop:12},children:L()})]}),O.length>0&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.resources??"Resources Permission"}),O.map(S=>{let F=x[S],J=e.config[S]??F.default??[];return b(S,F,J,Z=>r({[S]:Z}),e.type)})]}),de&&E&&(0,l.jsxs)("div",{style:{marginTop:24},children:[(0,l.jsx)("h3",{className:g.blockTitle,style:{marginBottom:4},children:d?.tools??"Tools Permission"}),(0,l.jsx)(Xa,{tools:E,selectedToolNames:ee,allToolNames:Y,onChange:a,styles:g})]})]})},rs=e=>{let{token:t}=_e.useToken(),{styles:o}=dn();return(0,l.jsx)(ns,{...e,token:t,styles:o,renderListSubSection:(a,i,d,c,p)=>{switch(i.widget){case"skillSelect":return(0,l.jsx)(Ja,{value:d,onChange:c,token:t,styles:o},a);case"databaseSelect":return(0,l.jsx)(Za,{value:d,onChange:c,token:t,styles:o},a);case"metricsSelect":return(0,l.jsx)(es,{value:d,onChange:c,token:t,styles:o},a);case"collectionSelect":return(0,l.jsx)(ts,{value:d,onChange:c,token:t,styles:o},a);case"connectionSelect":return(0,l.jsxs)("div",{className:o.dataSection,children:[(0,l.jsx)("div",{className:o.dataSectionHeader,children:(0,l.jsx)(we,{strong:!0,style:{fontSize:13},children:i.title||"Connections"})}),(0,l.jsx)(fi,{connectionType:i.connectionType??(a==="connections"?p:""),value:d||[],onChange:c})]},a);case"topologyEdgeBuilder":return(0,l.jsx)(os,{value:d,onChange:c,token:t,styles:o},a);default:return null}}})};var vi=n(s()),{Text:Lu}=P,_u=w(({css:e,token:t})=>({toolRow:e`
1419
1531
  width: 100%;
1420
1532
  background: ${t.colorFillQuaternary};
1421
1533
  border-color: ${t.colorBorderSecondary};
@@ -1426,7 +1538,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1426
1538
  `,toolName:e`
1427
1539
  font-weight: 600;
1428
1540
  font-size: 13px;
1429
- `}));var mi=n(s()),{Text:ou}=E,ru=w(({css:e,token:t})=>({diagram:e`
1541
+ `}));var bi=n(s()),{Text:Ku}=P,Hu=w(({css:e,token:t})=>({diagram:e`
1430
1542
  display: flex;
1431
1543
  flex-direction: column;
1432
1544
  gap: 0;
@@ -1461,7 +1573,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1461
1573
  font-size: 12px;
1462
1574
  line-height: 1.5;
1463
1575
  color: ${t.colorTextSecondary};
1464
- `}));var ui=n(s()),{Text:vu,Title:bu}=E,xu=w(({css:e,token:t})=>({layout:e`
1576
+ `}));var xi=n(s()),{Text:ag,Title:sg}=P,lg=w(({css:e,token:t})=>({layout:e`
1465
1577
  display: flex;
1466
1578
  height: 100%;
1467
1579
  gap: 20px;
@@ -1494,7 +1606,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1494
1606
  font-size: 13px;
1495
1607
  font-weight: 600;
1496
1608
  padding: 2px 8px;
1497
- `}));var nr=n(s());var Ha=n(s());var gi=n(S());var ir=n(s()),{Text:Wu}=E,{TextArea:Uu}=q,{useToken:Ku}=Le;var fi=n(S());var sr=n(s()),{Text:Xu}=E,{TextArea:Ju}=q,Zu=w(({token:e,css:t})=>({container:t`
1609
+ `}));var pn=n(s());var ls=n(s());var wi=n(C());var mn=n(s()),{Text:Eg}=P,{TextArea:Ng}=H,{useToken:Mg}=_e;var Ci=n(C());var gn=n(s()),{Text:Lg}=P,{TextArea:_g}=H,Og=w(({token:e,css:t})=>({container:t`
1498
1610
  height: 100%;
1499
1611
  display: flex;
1500
1612
  flex-direction: column;
@@ -1543,14 +1655,14 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1543
1655
  font-size: 13px;
1544
1656
  color: ${e.colorTextSecondary};
1545
1657
  margin-top: 8px;
1546
- `}));var go=n(S());var yi=n(S());var lr=n(s()),{Text:ag}=E,sg=w(({css:e})=>({formField:e`
1658
+ `}));var yo=n(C());var Si=n(C());var fn=n(s()),{Text:Gg}=P,Qg=w(({css:e})=>({formField:e`
1547
1659
  margin-bottom: 16px;
1548
1660
  `,fieldLabel:e`
1549
1661
  display: block;
1550
1662
  margin-bottom: 6px;
1551
1663
  font-weight: 500;
1552
1664
  font-size: 13px;
1553
- `}));var Ga=n(s()),{Text:yg}=E;var vi=n(S());var Qa=n(S());var hi=n(s());var cr=n(s()),{Text:Pg}=E,{TextArea:Ig}=q,{useToken:Ag}=Le,{Panel:Eg}=It;var bt=n(S());var dr=n(s()),$g=(0,bt.lazy)(()=>import("./embed-page-SkillFlow-GS4OUCJJ.js")),{Text:Lg}=E,{TextArea:Og}=q;var xi=n(S());var pr=n(S());var mr=n(s()),{Text:Gg,Paragraph:Qg}=E,Yg=w(({token:e,css:t})=>({root:t`
1665
+ `}));var ds=n(s()),{Text:rf}=P;var Ri=n(C());var ps=n(C());var ki=n(s());var yn=n(s()),{Text:yf}=P,{TextArea:hf}=H,{useToken:vf}=_e,{Panel:bf}=Et;var xt=n(C());var hn=n(s()),Pf=(0,xt.lazy)(()=>import("./embed-page-SkillFlow-SFZ5HLMK.js")),{Text:If}=P,{TextArea:Af}=H;var Ti=n(C());var bn=n(C());var xn=n(s()),{Text:jf,Paragraph:$f}=P,Lf=w(({token:e,css:t})=>({root:t`
1554
1666
  height: 100%;
1555
1667
  display: flex;
1556
1668
  flex-direction: column;
@@ -1624,7 +1736,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1624
1736
  background: ${e.colorPrimaryBg} !important;
1625
1737
  transition: background 0.25s;
1626
1738
  }
1627
- `}));var gr=n(s()),{Text:af}=E,sf=w(({token:e,css:t})=>({container:t`
1739
+ `}));var Cn=n(s()),{Text:Gf}=P,Qf=w(({token:e,css:t})=>({container:t`
1628
1740
  padding: ${e.paddingLG}px;
1629
1741
  height: 100%;
1630
1742
  overflow-y: auto;
@@ -1638,7 +1750,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1638
1750
  gap: ${e.marginSM}px;
1639
1751
  margin-bottom: ${e.marginSM}px;
1640
1752
  align-items: center;
1641
- `}));var fr=n(S());var wi=n(s());var Ci=n(S());var Si=n(s()),{Text:hf,Title:vf}=E;var yo=n(S());var fo=n(S());var Ri=n(s()),{Text:kf}=E;var yr=n(s()),{Text:Df}=E;var hr=n(S());var ho=n(S());var ki=n(S());var Ti=n(s()),{Text:qf}=E;var vr=n(s()),{Text:ty}=E;var bo=n(S());var vo=n(S());var kt=n(s()),Xa=(0,vo.lazy)(()=>import("./embed-page-TasksSideApp-I6Z7BOT2.js").then(e=>({default:e.TasksSideApp}))),br=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=xe(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,kt.jsx)(St,{ariaLabel:"Open tasks",icon:(0,kt.jsx)(Yt,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,kt.jsx)(vo.Suspense,{fallback:(0,kt.jsx)(de,{style:{display:"block",margin:"auto"}}),children:(0,kt.jsx)(Xa,{showProjectFilter:!1})})}})}})};var $t=n(S());var xr=n(s()),{Text:fy}=E;var yy=w(({css:e,token:t})=>({body:e`
1753
+ `}));var Sn=n(C());var Pi=n(s());var Ii=n(C());var Ai=n(s()),{Text:iy,Title:ay}=P;var vo=n(C());var ho=n(C());var Ei=n(C());var Ni=n(s()),{Text:fy}=P;var Mi=n(s()),{Text:ky}=P;var kn=n(C());var Rn=n(s()),{Text:Dy,Paragraph:Fy}=P;var Tn=n(s()),{Text:qy}=P;var Pn=n(C());var Bi=n(s()),{Text:Xy}=P;var In=n(C());var bo=n(C());var Di=n(C());var Fi=n(s()),{Text:lh}=P;var An=n(s()),{Text:vh}=P;var wo=n(C());var xo=n(C());var Pt=n(s()),us=(0,xo.lazy)(()=>import("./embed-page-TasksSideApp-Q6HTW6S6.js").then(e=>({default:e.TasksSideApp}))),En=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=Se(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,Pt.jsx)(Rt,{ariaLabel:"Open tasks",icon:(0,Pt.jsx)(Zt,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,Pt.jsx)(xo.Suspense,{fallback:(0,Pt.jsx)(ne,{style:{display:"block",margin:"auto"}}),children:(0,Pt.jsx)(us,{showProjectFilter:!1})})}})}})};var Ot=n(C());var Nn=n(s()),{Text:Mh}=P;var Bh=w(({css:e,token:t})=>({body:e`
1642
1754
  display: flex;
1643
1755
  height: 460px;
1644
1756
  `,leftPanel:e`
@@ -1797,7 +1909,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1797
1909
  padding: 12px 24px;
1798
1910
  border-top: 1px solid ${t.colorBorderSecondary};
1799
1911
  flex-shrink: 0;
1800
- `}));var wr=n(s()),{Title:By,Text:Dy,Paragraph:Fy}=E,jy=w(({css:e,token:t})=>({container:e` display: flex; flex-direction: column; height: 100%; padding: 24px; overflow-y: auto; `,setupWrap:e` max-width: 520px; margin: 30px auto 0; `,card:e` border-radius: ${t.borderRadiusLG}px; `,statusCard:e` max-width: 560px; margin: 40px auto 0; border-radius: ${t.borderRadiusLG}px; `,loadingWrap:e` display: flex; align-items: center; justify-content: center; height: 100%; `,avatar:e`
1912
+ `}));var Mn=n(s()),{Title:Yh,Text:Xh,Paragraph:Jh}=P,Zh=w(({css:e,token:t})=>({container:e` display: flex; flex-direction: column; height: 100%; padding: 24px; overflow-y: auto; `,setupWrap:e` max-width: 520px; margin: 30px auto 0; `,card:e` border-radius: ${t.borderRadiusLG}px; `,statusCard:e` max-width: 560px; margin: 40px auto 0; border-radius: ${t.borderRadiusLG}px; `,loadingWrap:e` display: flex; align-items: center; justify-content: center; height: 100%; `,avatar:e`
1801
1913
  width: 56px; height: 56px; border-radius: ${t.borderRadiusLG}px;
1802
1914
  background: linear-gradient(135deg, ${t.colorPrimary}, ${t.colorPrimaryActive});
1803
1915
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 12px;
@@ -1812,7 +1924,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1812
1924
  `,chatRoot:e` display: flex; flex-direction: column; height: 100%; min-height: 0; `,chatBar:e`
1813
1925
  display: flex; align-items: center; justify-content: space-between;
1814
1926
  padding: 8px 16px; border-bottom: 1px solid ${t.colorBorderSecondary}; flex-shrink: 0;
1815
- `,chatFill:e` flex: 1; min-height: 0; `}));var Mi=n(S());var Sr=n(S());var he=n(S());function Ai(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>(r.label||"").toLowerCase().includes(o)):e}var Ii=(e,t)=>{let o=t==="created"?e.createdAt:e.updatedAt;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function Ei(e,t="updated",o="desc"){return[...e].sort((r,a)=>{if(t==="name"){let c=r.label||"",p=a.label||"";return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Ii(r,t),d=Ii(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}var G=n(s()),Ja=w(({token:e,css:t})=>({container:t`
1927
+ `,chatFill:e` flex: 1; min-height: 0; `}));var Wi=n(C());var _i=n(C());var be=n(C());function $i(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>(r.label||"").toLowerCase().includes(o)):e}var ji=(e,t)=>{let o=t==="created"?e.createdAt:e.updatedAt;if(!o)return null;let r=Date.parse(o);return Number.isNaN(r)?null:r};function Li(e,t="updated",o="desc"){return[...e].sort((r,a)=>{if(t==="name"){let c=r.label||"",p=a.label||"";return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=ji(r,t),d=ji(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}var G=n(s()),gs=w(({token:e,css:t})=>({container:t`
1816
1928
  padding: 4px;
1817
1929
  font-size: 13px;
1818
1930
  background: transparent;
@@ -1939,7 +2051,7 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
1939
2051
  text-align: center;
1940
2052
  color: ${e.colorTextSecondary};
1941
2053
  font-size: 12px;
1942
- `})),Cr=()=>{let{styles:e}=Ja(),{threads:t,threadId:o,selectThread:r,deleteThread:a,updateThread:i,isLoading:d}=et(),[c,p]=(0,he.useState)(null),[g,b]=(0,he.useState)(!1),[x,h]=(0,he.useState)(null),[u,m]=(0,he.useState)(""),[v,_]=(0,he.useState)(!1),[L,A]=(0,he.useState)(""),[Y,ee]=(0,he.useState)("updated"),[le,V]=(0,he.useState)("desc"),C=(0,he.useRef)(!1),F=(0,he.useRef)(!1),J=(0,he.useCallback)((k,P)=>{k.stopPropagation(),p(P)},[]),Z=(0,he.useCallback)(async()=>{if(c){b(!0);try{await a(c),H.success("Conversation deleted"),p(null)}catch{H.error("Failed to delete conversation")}finally{b(!1)}}},[c,a]),I=(0,he.useCallback)((k,P)=>{k.stopPropagation(),h(P.id),m(P.label)},[]),ie=(0,he.useCallback)(async k=>{if(F.current)return;let P=u.trim();if(!P||P===k.label){h(null);return}F.current=!0,_(!0);try{await i({...k,label:P}),H.success("Conversation renamed")}catch{H.error("Failed to rename conversation")}finally{F.current=!1,_(!1),h(null)}},[u,i]),B=(0,he.useCallback)(()=>{C.current=!0,h(null)},[]),z=(0,he.useCallback)(k=>{k.key==="Enter"?(k.preventDefault(),k.currentTarget.blur()):k.key==="Escape"&&(k.preventDefault(),B())},[B]),ae=(0,he.useCallback)(k=>{if(C.current){C.current=!1;return}ie(k)},[ie]),O=he.default.useMemo(()=>Ei(Ai(t,L),Y,le),[t,L,Y,le]);return(0,G.jsxs)("div",{className:e.container,children:[(0,G.jsxs)("div",{className:e.toolbar,children:[(0,G.jsx)(q,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:L,onChange:k=>A(k.target.value)}),(0,G.jsxs)("div",{className:e.toolbarRow,children:[(0,G.jsx)(Fe,{size:"small",style:{flex:1,minWidth:0},value:Y,onChange:k=>ee(k),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,G.jsx)(j,{size:"small",icon:le==="asc"?(0,G.jsx)(Ht,{}):(0,G.jsx)(Vt,{}),onClick:()=>V(k=>k==="asc"?"desc":"asc"),title:le==="asc"?"Ascending":"Descending"})]})]}),d?(0,G.jsx)("div",{className:e.loading,children:"Loading conversations..."}):O.length===0?(0,G.jsx)("div",{className:e.emptyState,children:L.trim()?`No conversations match "${L.trim()}"`:"No conversations yet"}):(0,G.jsx)("div",{className:e.threadList,children:O.map(k=>(0,G.jsxs)("div",{className:`${e.threadItem} ${k.id===o?"active":""}`,onClick:()=>r(k.id),title:k.label,children:[(0,G.jsx)("div",{className:e.threadIcon,children:(0,G.jsx)(un,{size:14})}),x===k.id?(0,G.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:u,autoFocus:!0,disabled:v,onClick:P=>P.stopPropagation(),onFocus:P=>P.target.select(),onChange:P=>m(P.target.value),onKeyDown:P=>z(P),onBlur:()=>ae(k)}):(0,G.jsx)("div",{className:k.id===o?e.threadNameActive:e.threadName,children:k.label}),x===k.id?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:v,onMouseDown:P=>P.preventDefault(),onClick:P=>{P.stopPropagation(),ie(k)},children:(0,G.jsx)(rn,{size:12})}),(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:v,onMouseDown:P=>P.preventDefault(),onClick:P=>{P.stopPropagation(),B()},children:(0,G.jsx)(Nt,{size:12})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:e.actionBtn,onClick:P=>I(P,k),title:"Rename conversation",children:(0,G.jsx)(fn,{size:12})}),(0,G.jsx)("button",{className:e.actionBtn,onClick:P=>J(P,k.id),title:"Delete conversation",children:(0,G.jsx)(bn,{size:12})})]})]},k.id))}),(0,G.jsx)(pe,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:g},cancelText:"Cancel",children:(0,G.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Rr=n(s());var Ni=n(s());var Bi=n(S());var Di=n(s()),{Text:kh}=E;var ls=n(S());var kr=n(S());var Fi=n(s()),{Text:Mh}=E;var ss=n(S());var as=n(S());var Tr=n(s());var Pr=n(s()),{Dragger:Oh}=Dr,{Text:_h,Title:Wh}=E;var ji=n(s()),{Title:Yh,Text:Xh}=E;var ve=n(s()),zi=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ve.jsx)(At,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ve.jsx)(it,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ve.jsx)(Gt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ve.jsx)(an,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ve.jsx)(jo,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ve.jsx)(Mt,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ve.jsx)(dn,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ve.jsx)(zo,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ve.jsx)(zo,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ve.jsx)(tn,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ve.jsx)(ln,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ve.jsx)(At,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ve.jsx)(Cn,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ve.jsx)(mn,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ve.jsx)(jo,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"A2A Keys",icon:(0,ve.jsx)(pn,{size:20}),order:45,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ve.jsx)(vn,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ve.jsx)(wn,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ve.jsx)(Yt,{size:20}),order:100}];var ub=(0,We.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-4B3NJPCY.js").then(e=>({default:e.AgentGovernanceWorkbench}))),gb=(0,We.lazy)(()=>import("./embed-page-TopologyRuntimeView-RY7NOUB7.js").then(e=>({default:e.TopologyRuntimeView}))),fb=(0,We.lazy)(()=>import("./embed-page-WorkflowAutomationView-RNKIKDUX.js").then(e=>({default:e.WorkflowAutomationView}))),yb=(0,We.lazy)(()=>import("./embed-page-TasksSideApp-I6Z7BOT2.js").then(e=>({default:e.TasksSideApp}))),hb=(0,We.lazy)(()=>import("./embed-page-AgentDetailSideApp-6CVXM3P3.js").then(e=>({default:e.AgentDetailSideApp})));var Ee=n(s());function cs(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:a,projectId:i}=e;return t==="agent"?{agentId:o,workspaceId:a||void 0,projectId:i||void 0}:{...r,workspaceId:a||void 0,projectId:i||void 0}}async function ds(e,t,o){let{contentType:r,assistantId:a,contentConfig:i,isMatch:d}=t;if(!(r==="agent"?!!a:!!i)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let g=d??(x=>r==="agent"&&x.agentId===a),b=p.data.records.find(x=>x.contentType===r&&g(x.contentConfig));if(b)return{isPinned:!0,pinnedId:b.id}}return{isPinned:!1,pinnedId:null}}async function ps(e,t){let{contentType:o,name:r,group:a}=t,i=cs(t),d={menuTarget:"workspace",contentType:o,contentConfig:i,group:a?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function ms(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function lo(){let e=ye.default.useContext(Sn),{config:t}=Te(),{post:o,get:r,del:a}=me(),i=t.enableCustomMenu??!1,d=(0,ye.useCallback)(async g=>ds(r,g,i),[r,i]),c=(0,ye.useCallback)(async g=>ps(o,{...g,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,ye.useCallback)(async g=>ms(a,g),[a]);return{check:d,pin:c,unpin:p,enableCustomMenu:i,get:r}}function $i(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function Jo(){let{config:e}=Te(),t=ye.default.useMemo(()=>$i(zi),[]),o=ye.default.useMemo(()=>$i(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return ye.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function Zo(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var us={display:"flex",flexDirection:"column",gap:12},ur=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:a="small",label:i,block:d})=>{let{check:c,pin:p,unpin:g,enableCustomMenu:b,get:x}=lo(),[h,u]=(0,ye.useState)(!1),[m,v]=(0,ye.useState)(""),[_,L]=(0,ye.useState)(""),[A,Y]=(0,ye.useState)(!1),[ee,le]=(0,ye.useState)(!1),[V,C]=(0,ye.useState)(null),[F,J]=(0,ye.useState)(!0),Z=Jo(),[I,ie]=(0,ye.useState)(Z);(0,ye.useEffect)(()=>{ie(Z)},[Z]),(0,ye.useEffect)(()=>{h&&Zo(x).then(P=>{ie(Array.from(new Set([...Z,...P])).sort())})},[h]);let B=t==="agent"?!!e:!!o,z=(0,ye.useCallback)(async()=>{if(!B||!b){J(!1);return}J(!0);try{let P=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});le(P.isPinned),C(P.pinnedId)}catch{}finally{J(!1)}},[B,b,c,t,e,o,r]);if((0,ye.useEffect)(()=>{z()},[z]),!B||!b)return null;let ae=async()=>{if(!_.trim()){H.warning("Please enter a menu name");return}Y(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:_.trim(),group:m.trim()||void 0}),H.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),u(!1),v(""),L(""),z()}catch(P){H.error(P.message||"Failed to pin to menu")}finally{Y(!1)}},O=async()=>{if(V){Y(!0);try{await g(V),H.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),le(!1),C(null)}catch(P){H.error(P.message||"Failed to unpin from menu")}finally{Y(!1)}}},k=()=>{ee?O():u(!0)};return(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)($e,{title:ee?"Unpin from Menu":"Pin to Menu",children:i?(0,Ee.jsx)(j,{type:"text",size:a,block:d,icon:ee?(0,Ee.jsx)(He,{size:14,fill:"currentColor"}):(0,Ee.jsx)(He,{size:14}),onClick:k,loading:F||A&&ee,children:i}):(0,Ee.jsx)(j,{type:"text",size:a,block:d,icon:ee?(0,Ee.jsx)(He,{size:14,fill:"currentColor"}):(0,Ee.jsx)(He,{size:14}),onClick:k,loading:F||A&&ee})}),(0,Ee.jsx)(pe,{title:"Pin to Menu",open:h,onOk:ae,onCancel:()=>u(!1),confirmLoading:A,okText:"Pin",children:(0,Ee.jsxs)("div",{style:us,children:[(0,Ee.jsx)(q,{placeholder:"Menu name (required)",value:_,onChange:P=>L(P.target.value)}),(0,Ee.jsx)(Wt,{placeholder:"Group (optional, select or type new)",value:m,options:I.map(P=>({value:P})),onChange:P=>v(P),filterOption:(P,T)=>T?.value?.toUpperCase().includes(P.toUpperCase())??!1})]})})]})};var ne=n(S());var Q=n(s()),Ir=50,gs=w(({token:e,css:t})=>({container:t`
2054
+ `})),Bn=()=>{let{styles:e}=gs(),{threads:t,threadId:o,selectThread:r,deleteThread:a,updateThread:i,isLoading:d}=tt(),[c,p]=(0,be.useState)(null),[g,b]=(0,be.useState)(!1),[x,h]=(0,be.useState)(null),[u,m]=(0,be.useState)(""),[v,O]=(0,be.useState)(!1),[L,E]=(0,be.useState)(""),[Y,ee]=(0,be.useState)("updated"),[de,V]=(0,be.useState)("desc"),S=(0,be.useRef)(!1),F=(0,be.useRef)(!1),J=(0,be.useCallback)((R,I)=>{R.stopPropagation(),p(I)},[]),Z=(0,be.useCallback)(async()=>{if(c){b(!0);try{await a(c),q.success("Conversation deleted"),p(null)}catch{q.error("Failed to delete conversation")}finally{b(!1)}}},[c,a]),A=(0,be.useCallback)((R,I)=>{R.stopPropagation(),h(I.id),m(I.label)},[]),ae=(0,be.useCallback)(async R=>{if(F.current)return;let I=u.trim();if(!I||I===R.label){h(null);return}F.current=!0,O(!0);try{await i({...R,label:I}),q.success("Conversation renamed")}catch{q.error("Failed to rename conversation")}finally{F.current=!1,O(!1),h(null)}},[u,i]),B=(0,be.useCallback)(()=>{S.current=!0,h(null)},[]),j=(0,be.useCallback)(R=>{R.key==="Enter"?(R.preventDefault(),R.currentTarget.blur()):R.key==="Escape"&&(R.preventDefault(),B())},[B]),se=(0,be.useCallback)(R=>{if(S.current){S.current=!1;return}ae(R)},[ae]),_=be.default.useMemo(()=>Li($i(t,L),Y,de),[t,L,Y,de]);return(0,G.jsxs)("div",{className:e.container,children:[(0,G.jsxs)("div",{className:e.toolbar,children:[(0,G.jsx)(H,{size:"small",placeholder:"Search conversations\u2026",allowClear:!0,value:L,onChange:R=>E(R.target.value)}),(0,G.jsxs)("div",{className:e.toolbarRow,children:[(0,G.jsx)(Ee,{size:"small",style:{flex:1,minWidth:0},value:Y,onChange:R=>ee(R),options:[{value:"name",label:"Name"},{value:"updated",label:"Updated"},{value:"created",label:"Created"}]}),(0,G.jsx)(z,{size:"small",icon:de==="asc"?(0,G.jsx)(Qt,{}):(0,G.jsx)(Yt,{}),onClick:()=>V(R=>R==="asc"?"desc":"asc"),title:de==="asc"?"Ascending":"Descending"})]})]}),d?(0,G.jsx)("div",{className:e.loading,children:"Loading conversations..."}):_.length===0?(0,G.jsx)("div",{className:e.emptyState,children:L.trim()?`No conversations match "${L.trim()}"`:"No conversations yet"}):(0,G.jsx)("div",{className:e.threadList,children:_.map(R=>(0,G.jsxs)("div",{className:`${e.threadItem} ${R.id===o?"active":""}`,onClick:()=>r(R.id),title:R.label,children:[(0,G.jsx)("div",{className:e.threadIcon,children:(0,G.jsx)(xr,{size:14})}),x===R.id?(0,G.jsx)("input",{className:e.renameInput,"aria-label":"Conversation name",value:u,autoFocus:!0,disabled:v,onClick:I=>I.stopPropagation(),onFocus:I=>I.target.select(),onChange:I=>m(I.target.value),onKeyDown:I=>j(I),onBlur:()=>se(R)}):(0,G.jsx)("div",{className:R.id===o?e.threadNameActive:e.threadName,children:R.label}),x===R.id?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Save name",disabled:v,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),ae(R)},children:(0,G.jsx)(pr,{size:12})}),(0,G.jsx)("button",{className:`${e.actionBtn} ${e.actionBtnVisible}`,title:"Cancel rename",disabled:v,onMouseDown:I=>I.preventDefault(),onClick:I=>{I.stopPropagation(),B()},children:(0,G.jsx)(Bt,{size:12})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)("button",{className:e.actionBtn,onClick:I=>A(I,R),title:"Rename conversation",children:(0,G.jsx)(Cr,{size:12})}),(0,G.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,G.jsx)(Tr,{size:12})})]})]},R.id))}),(0,G.jsx)(pe,{title:"Delete Conversation",open:c!==null,onCancel:()=>p(null),onOk:Z,okText:"Delete",okButtonProps:{danger:!0,loading:g},cancelText:"Cancel",children:(0,G.jsx)("p",{children:"Are you sure you want to delete this conversation? This action cannot be undone."})})]})};var Oi=n(s());var Ui=n(s());var Ki=n(C());var Hi=n(s()),{Text:jv}=P;var xs=n(C());var Dn=n(C());var qi=n(s()),{Text:Uv}=P;var bs=n(C());var vs=n(C());var Fn=n(s());var zn=n(s()),{Dragger:Jv}=Wn,{Text:Zv,Title:eb}=P;var Vi=n(s()),{Title:lb,Text:cb}=P;var ye=n(s()),Gi=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Nt,{size:20}),order:-10},{id:"workspace_projects",type:"route",name:"Projects",icon:(0,ye.jsx)(at,{size:20}),order:0},{id:"metrics",builtin:"metrics",type:"route",name:"Metrics",icon:(0,ye.jsx)(Xt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(ur,{size:20}),order:20,group:"DataSource"},{id:"connections",builtin:"connections",type:"route",name:"Plugins",icon:(0,ye.jsx)(Lo,{size:20}),order:21},{id:"topology-runtimes",type:"route",name:"Runtime",icon:(0,ye.jsx)(kt,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(hr,{size:20}),order:27,group:"Process"},{id:"workflows",type:"route",name:"Automations",icon:(0,ye.jsx)(_o,{size:20}),order:25,group:"Process"},{id:"shares",type:"route",name:"Shares",icon:(0,ye.jsx)(_o,{size:20}),order:55,group:"Settings"},{id:"workspace_migration",type:"route",name:"Migration",icon:(0,ye.jsx)(cr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(fr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Nt,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Ar,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(br,{size:20}),order:29,group:"Knowledge"},{id:"mcp",builtin:"mcp",type:"route",name:"MCP",icon:(0,ye.jsx)(Lo,{size:20}),order:40,group:"Settings"},{id:"a2a-keys",type:"route",name:"API Keys",icon:(0,ye.jsx)(vr,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(kt,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(Rr,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Ir,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(Zt,{size:20}),order:100}];var Px=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-JUP6SNBX.js").then(e=>({default:e.AgentGovernanceWorkbench}))),Ix=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-MASWKWXA.js").then(e=>({default:e.TopologyRuntimeView}))),Ax=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-6UOT36GW.js").then(e=>({default:e.WorkflowAutomationView}))),Ex=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-Q6HTW6S6.js").then(e=>({default:e.TasksSideApp}))),Nx=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-DTDBMB2U.js").then(e=>({default:e.AgentDetailSideApp})));var Ne=n(s());function ws(e){let{contentType:t,assistantId:o,contentConfig:r,workspaceId:a,projectId:i}=e;return t==="agent"?{agentId:o,workspaceId:a||void 0,projectId:i||void 0}:{...r,workspaceId:a||void 0,projectId:i||void 0}}async function Cs(e,t,o){let{contentType:r,assistantId:a,contentConfig:i,isMatch:d}=t;if(!(r==="agent"?!!a:!!i)||!o)return{isPinned:!1,pinnedId:null};let p=await e("/api/menu-items?menuTarget=workspace");if(p.success&&p.data?.records){let g=d??(x=>r==="agent"&&x.agentId===a),b=p.data.records.find(x=>x.contentType===r&&g(x.contentConfig));if(b)return{isPinned:!0,pinnedId:b.id}}return{isPinned:!1,pinnedId:null}}async function Ss(e,t){let{contentType:o,name:r,group:a}=t,i=ws(t),d={menuTarget:"workspace",contentType:o,contentConfig:i,group:a?.trim()||void 0,name:r.trim(),sortOrder:0},c=await e("/api/menu-items",d);if(!c.success)throw new Error(c.message||"Failed to pin");return{id:c.data.id}}async function ks(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function po(){let e=he.default.useContext(Er),{config:t}=Ce(),{post:o,get:r,del:a}=me(),i=t.enableCustomMenu??!1,d=(0,he.useCallback)(async g=>Cs(r,g,i),[r,i]),c=(0,he.useCallback)(async g=>Ss(o,{...g,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async g=>ks(a,g),[a]);return{check:d,pin:c,unpin:p,enableCustomMenu:i,get:r}}function Qi(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function on(){let{config:e}=Ce(),t=he.default.useMemo(()=>Qi(Gi),[]),o=he.default.useMemo(()=>Qi(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function nn(e){let t=await e("/api/menu-items?menuTarget=workspace");if(t.success&&t.data?.records){let o=new Set;for(let r of t.data.records)r.group?.trim()&&o.add(r.group.trim());return Array.from(o).sort()}return[]}var Rs={display:"flex",flexDirection:"column",gap:12},wn=({assistantId:e,contentType:t="agent",contentConfig:o,isMatch:r,size:a="small",label:i,block:d})=>{let{check:c,pin:p,unpin:g,enableCustomMenu:b,get:x}=po(),[h,u]=(0,he.useState)(!1),[m,v]=(0,he.useState)(""),[O,L]=(0,he.useState)(""),[E,Y]=(0,he.useState)(!1),[ee,de]=(0,he.useState)(!1),[V,S]=(0,he.useState)(null),[F,J]=(0,he.useState)(!0),Z=on(),[A,ae]=(0,he.useState)(Z);(0,he.useEffect)(()=>{ae(Z)},[Z]),(0,he.useEffect)(()=>{h&&nn(x).then(I=>{ae(Array.from(new Set([...Z,...I])).sort())})},[h]);let B=t==="agent"?!!e:!!o,j=(0,he.useCallback)(async()=>{if(!B||!b){J(!1);return}J(!0);try{let I=await c({contentType:t,assistantId:e,contentConfig:o,isMatch:r});de(I.isPinned),S(I.pinnedId)}catch{}finally{J(!1)}},[B,b,c,t,e,o,r]);if((0,he.useEffect)(()=>{j()},[j]),!B||!b)return null;let se=async()=>{if(!O.trim()){q.warning("Please enter a menu name");return}Y(!0);try{await p({contentType:t,assistantId:e,contentConfig:o,isMatch:r,name:O.trim(),group:m.trim()||void 0}),q.success("Pinned to menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),u(!1),v(""),L(""),j()}catch(I){q.error(I.message||"Failed to pin to menu")}finally{Y(!1)}},_=async()=>{if(V){Y(!0);try{await g(V),q.success("Unpinned from menu"),window.dispatchEvent(new CustomEvent("menu:refresh")),de(!1),S(null)}catch(I){q.error(I.message||"Failed to unpin from menu")}finally{Y(!1)}}},R=()=>{ee?_():u(!0)};return(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(ze,{title:ee?"Unpin from Menu":"Pin to Menu",children:i?(0,Ne.jsx)(z,{type:"text",size:a,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:F||E&&ee,children:i}):(0,Ne.jsx)(z,{type:"text",size:a,block:d,icon:ee?(0,Ne.jsx)(Ve,{size:14,fill:"currentColor"}):(0,Ne.jsx)(Ve,{size:14}),onClick:R,loading:F||E&&ee})}),(0,Ne.jsx)(pe,{title:"Pin to Menu",open:h,onOk:se,onCancel:()=>u(!1),confirmLoading:E,okText:"Pin",children:(0,Ne.jsxs)("div",{style:Rs,children:[(0,Ne.jsx)(H,{placeholder:"Menu name (required)",value:O,onChange:I=>L(I.target.value)}),(0,Ne.jsx)(Ht,{placeholder:"Group (optional, select or type new)",value:m,options:A.map(I=>({value:I})),onChange:I=>v(I),filterOption:(I,T)=>T?.value?.toUpperCase().includes(I.toUpperCase())??!1})]})})]})};var ie=n(C());var Q=n(s()),jn=50,Ts=w(({token:e,css:t})=>({container:t`
1943
2055
  position: relative;
1944
2056
  `,projectTrigger:t`
1945
2057
  display: flex;
@@ -2138,11 +2250,11 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
2138
2250
  display: flex;
2139
2251
  justify-content: flex-end;
2140
2252
  gap: 8px;
2141
- `})),xo=({disableDropdown:e=!0,showWorkspace:t=!0,value:o,onChange:r,kind:a})=>{let{styles:i}=gs(),{workspaceId:d,workspaces:c,projectId:p,projects:g,trainingProjects:b=[],personalProjects:x=[],setWorkspace:h,setProject:u,createProject:m}=Ie(),[v,_]=(0,ne.useState)(!1),L=(0,ne.useRef)(null),A=(0,ne.useRef)(null),[Y,ee]=(0,ne.useState)(!1),[le,V]=(0,ne.useState)(!1),[C,F]=(0,ne.useState)(""),[J,Z]=(0,ne.useState)(null),[I,ie]=(0,ne.useState)(!1),B=(0,ne.useRef)(null),z=o!==void 0,ae=z?o:p,O=(0,ne.useMemo)(()=>{if(a==="business")return g;if(a==="training")return b;if(a==="personal")return x;let W=new Map;for(let fe of[...g,...b,...x])W.has(fe.id)||W.set(fe.id,fe);return Array.from(W.values())},[a,g,b,x]);(0,ne.useEffect)(()=>{let W=fe=>{A.current&&!A.current.contains(fe.target)&&(ee(!1),_(!1))};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[]);let k=(0,ne.useMemo)(()=>O.find(W=>W.id===ae),[O,ae]),P=(0,ne.useMemo)(()=>c.find(W=>W.id===d),[c,d]),T=(0,ne.useCallback)(W=>{z?r?.(W):u(W),ee(!1)},[z,r,u]),se=(0,ne.useCallback)(()=>{z?r?.(null):u(null)},[z,r,u]),R=(0,ne.useCallback)(()=>{ee(W=>!W)},[]),oe=(0,ne.useCallback)(()=>{_(W=>!W)},[]),D=(0,ne.useCallback)(W=>{let fe=W.trim();return fe?fe.length>Ir?`Name must be ${Ir} characters or less`:null:"Project name is required"},[]),U=(0,ne.useCallback)(W=>{if(W.stopPropagation(),!d){H.warning("Please select a workspace first");return}F(""),Z(null),V(!0),setTimeout(()=>B.current?.input?.focus(),100)},[d]),Oe=(0,ne.useCallback)(()=>{V(!1),F(""),Z(null)},[]),Ue=W=>{let fe=W.target.value;F(fe),Z(D(fe))},Je=(0,ne.useCallback)(async()=>{if(!d)return;let W=C.trim(),fe=D(W);if(fe){Z(fe);return}ie(!0),Z(null);try{let rt=await m(d,{name:W});V(!1),F(""),Z(null),z?r?.(rt.id):u(rt.id),H.success(`Project "${rt.name}" created`)}catch(rt){let Qe=rt instanceof Error?rt.message:"Failed to create project";Z(Qe)}finally{ie(!1)}},[d,C,D,m,u,z,r]),gt=W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),D(C.trim())||Je())},ot=!D(C.trim());return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{className:i.container,ref:A,children:(0,Q.jsxs)("div",{className:i.selectorWrapper,children:[t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{style:{position:"relative"},ref:L,children:(0,Q.jsx)("button",{className:i.workspaceButton,onClick:se,title:P?.name||"Select Workspace",children:(0,Q.jsx)("div",{className:i.workspaceButtonIcon,children:(0,Q.jsx)(on,{size:16})})})}),(0,Q.jsx)("span",{className:i.divider,children:"/"})]}),(0,Q.jsxs)("div",{className:i.projectTrigger,onClick:e?void 0:R,style:{cursor:e?"default":"pointer"},children:[(0,Q.jsx)("div",{className:i.projectTriggerIcon,children:(0,Q.jsx)(Fo,{size:16})}),(0,Q.jsx)("div",{className:i.projectTriggerInfo,children:(0,Q.jsx)("div",{className:i.projectTriggerName,children:k?.name||"Select Project"})}),!e&&(0,Q.jsx)("div",{className:`${i.projectTriggerArrow} ${Y?"expanded":""}`,children:(0,Q.jsx)(Qt,{size:14})})]}),!e&&Y&&(0,Q.jsxs)("div",{className:i.projectDropdown,children:[O.map(W=>(0,Q.jsxs)("div",{className:`${i.projectDropdownItem} ${W.id===ae?"active":""}`,onClick:()=>T(W.id),children:[(0,Q.jsx)("div",{className:i.projectDropdownItemIcon,children:(0,Q.jsx)(Fo,{size:14})}),(0,Q.jsx)("div",{className:W.id===ae?i.projectDropdownItemNameActive:i.projectDropdownItemName,children:W.name})]},W.id)),O.length===0&&(0,Q.jsx)("div",{className:i.emptyState,children:"No projects"})]})]})}),(0,Q.jsxs)(pe,{title:"Create New Project",open:le,onCancel:Oe,wrapClassName:i.modalWrap,centered:!0,destroyOnClose:!0,maskClosable:!I,keyboard:!0,closable:!0,footer:(0,Q.jsxs)("div",{className:i.modalFooter,children:[(0,Q.jsx)(j,{onClick:Oe,disabled:I,children:"Cancel"}),(0,Q.jsx)(j,{type:"primary",onClick:Je,loading:I,disabled:!ot,children:"Create"})]}),children:[(0,Q.jsx)(q,{ref:B,value:C,onChange:Ue,onKeyDown:gt,placeholder:"Enter project name",maxLength:Ir+10,status:J?"error":void 0}),J&&(0,Q.jsx)("div",{style:{color:"#ff4d4f",fontSize:"12px",marginTop:"4px"},children:J})]})]})};var Me=n(S());var Oi=n(s()),Li=()=>{let{config:e}=Te(),{openSideApp:t}=xe(),{workspaceId:o,projectId:r,listPath:a,listPathByFolder:i,getFileViewUrl:d,getFileDownloadUrl:c,uploadFileToFolder:p}=Ie(),{currentAssistant:g}=Ze(),[b,x]=(0,Me.useState)({}),[h,u]=(0,Me.useState)({}),[m,v]=(0,Me.useState)({}),[_,L]=(0,Me.useState)({}),[A,Y]=(0,Me.useState)({}),[ee,le]=(0,Me.useState)(null),V=(0,Me.useMemo)(()=>e.resourceFolders&&e.resourceFolders.length>0?e.resourceFolders:[{name:"/",displayName:"Project Assets",allowUpload:!0}],[e.resourceFolders]),C=(0,Me.useCallback)(async(I,ie=!0)=>{if(!o||!r){x(B=>({...B,[I.name]:[]}));return}u(B=>({...B,[I.name]:!0}));try{let B=await i(I.name,g?.id);if(x(z=>({...z,[I.name]:B})),ie){let z=I.name==="/"?"/":I.name.replace(/\/$/,"");v(ae=>{let O={...ae};return Object.keys(O).forEach(k=>{(k===z||k.startsWith(`${z}/`))&&delete O[k]}),O}),Y(ae=>{let O={...ae};return Object.keys(O).forEach(k=>{(k===z||k.startsWith(`${z}/`))&&delete O[k]}),O})}}catch(B){console.error(`Failed to load assets for folder ${I.name}:`,B),x(z=>({...z,[I.name]:[]}))}finally{u(B=>({...B,[I.name]:!1}))}},[o,r,i,g?.id]),F=(0,Me.useCallback)(async I=>{if(A[I]||!1){Y(B=>({...B,[I]:!1}));return}Y(B=>({...B,[I]:!0})),L(B=>({...B,[I]:!0}));try{let B=await a(I,g?.id);v(z=>({...z,[I]:B}))}catch(B){console.error(`Failed to load directory ${I}:`,B),v(z=>({...z,[I]:[]}))}finally{L(B=>({...B,[I]:!1}))}},[A,a,g?.id]);(0,Me.useEffect)(()=>{V.forEach(I=>{C(I,!1)})},[V,C]);let J=(0,Me.useCallback)(I=>{let ie=d(I.path,g?.id),B=c(I.path,g?.id);if(!ie||!B){H.warning("Please select a workspace and project first.");return}t({component_key:"attachments",data:{file_id:I.path,message:`Preview: ${I.name||I.path}`,full_url:ie,download_url:B},message:`Preview: ${I.name||I.path}`})},[d,c,t,g?.id]),Z=(0,Me.useCallback)(async I=>{if(!o||!r){H.warning("Please select a workspace and project before uploading.");return}let ie=document.createElement("input");ie.type="file",ie.onchange=async B=>{let ae=B.target?.files?.[0];if(ae){le(I);try{await p(I,ae,g?.id),H.success(`Uploaded "${ae.name}" successfully`);let O=V.find(k=>k.name===I);O&&await C(O)}catch(O){let k=O instanceof Error?O.message:"Failed to upload file";H.error(k)}finally{le(null),ie.remove()}}},ie.click()},[o,r,p,V,C,g?.id]);return(0,Oi.jsx)(Xo,{workspaceId:o,projectId:r,resourceFolders:V,folderEntries:b,folderLoading:h,directoryChildren:m,directoryLoading:_,directoryExpanded:A,uploadingFolder:ee,onRefreshFolder:C,onUploadFolder:Z,onToggleDirectory:F,onAssetClick:J})};var wo=n(S());var Ge=n(s()),{Text:fs,Paragraph:ys}=E,_i={185:"Maximum update depth exceeded \u2014 likely an infinite re-render loop",31:"Objects are not valid as a React child",130:"Element type is invalid \u2014 check render method",152:"Too many re-renders \u2014 React limits renders to prevent an infinite loop",301:"Rendered fewer hooks than expected",306:"Rendered more hooks than during the previous render",310:"Rendered more hooks than during the previous render",321:"Invalid hook call \u2014 hooks can only be called inside function components",418:"Hydration failed because the server rendered content didn't match the client",423:"Hydration error \u2014 server/client mismatch in suspense boundary",424:"Could not find recovery element for hydrated instance",425:"Text content doesn't match server-rendered HTML"};function hs(e){if(!e)return"";let t=e.message?.match(/Minified React error #(\d+)/);return t&&_i[t[1]]?`${e.name}: Minified React error #${t[1]} \u2014 ${_i[t[1]]}`:`${e.name}: ${e.message}`}var ut=class extends wo.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null,retryKey:0}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){let r=this.props.name||"ChatErrorBoundary";console.error(`[${r}] Caught rendering error:`,t,o),this.setState({errorInfo:o}),this.props.onError?.(t,o)}handleRetry=()=>{this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryKey:t.retryKey+1}))};handleCopyError=()=>{let{error:t,errorInfo:o}=this.state,a=[`[${this.props.name||"ChatErrorBoundary"}]`,`Error: ${t?.name}: ${t?.message}`,`Stack: ${t?.stack}`,`Component Stack: ${o?.componentStack}`].join(`
2253
+ `})),Co=({disableDropdown:e=!0,showWorkspace:t=!0,value:o,onChange:r,kind:a})=>{let{styles:i}=Ts(),{workspaceId:d,workspaces:c,projectId:p,projects:g,trainingProjects:b=[],personalProjects:x=[],setWorkspace:h,setProject:u,createProject:m}=Ie(),[v,O]=(0,ie.useState)(!1),L=(0,ie.useRef)(null),E=(0,ie.useRef)(null),[Y,ee]=(0,ie.useState)(!1),[de,V]=(0,ie.useState)(!1),[S,F]=(0,ie.useState)(""),[J,Z]=(0,ie.useState)(null),[A,ae]=(0,ie.useState)(!1),B=(0,ie.useRef)(null),j=o!==void 0,se=j?o:p,_=(0,ie.useMemo)(()=>{if(a==="business")return g;if(a==="training")return b;if(a==="personal")return x;let W=new Map;for(let fe of[...g,...b,...x])W.has(fe.id)||W.set(fe.id,fe);return Array.from(W.values())},[a,g,b,x]);(0,ie.useEffect)(()=>{let W=fe=>{E.current&&!E.current.contains(fe.target)&&(ee(!1),O(!1))};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[]);let R=(0,ie.useMemo)(()=>_.find(W=>W.id===se),[_,se]),I=(0,ie.useMemo)(()=>c.find(W=>W.id===d),[c,d]),T=(0,ie.useCallback)(W=>{j?r?.(W):u(W),ee(!1)},[j,r,u]),le=(0,ie.useCallback)(()=>{j?r?.(null):u(null)},[j,r,u]),k=(0,ie.useCallback)(()=>{ee(W=>!W)},[]),oe=(0,ie.useCallback)(()=>{O(W=>!W)},[]),D=(0,ie.useCallback)(W=>{let fe=W.trim();return fe?fe.length>jn?`Name must be ${jn} characters or less`:null:"Project name is required"},[]),U=(0,ie.useCallback)(W=>{if(W.stopPropagation(),!d){q.warning("Please select a workspace first");return}F(""),Z(null),V(!0),setTimeout(()=>B.current?.input?.focus(),100)},[d]),We=(0,ie.useCallback)(()=>{V(!1),F(""),Z(null)},[]),Ke=W=>{let fe=W.target.value;F(fe),Z(D(fe))},Ze=(0,ie.useCallback)(async()=>{if(!d)return;let W=S.trim(),fe=D(W);if(fe){Z(fe);return}ae(!0),Z(null);try{let rt=await m(d,{name:W});V(!1),F(""),Z(null),j?r?.(rt.id):u(rt.id),q.success(`Project "${rt.name}" created`)}catch(rt){let Qe=rt instanceof Error?rt.message:"Failed to create project";Z(Qe)}finally{ae(!1)}},[d,S,D,m,u,j,r]),gt=W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),D(S.trim())||Ze())},nt=!D(S.trim());return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{className:i.container,ref:E,children:(0,Q.jsxs)("div",{className:i.selectorWrapper,children:[t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("div",{style:{position:"relative"},ref:L,children:(0,Q.jsx)("button",{className:i.workspaceButton,onClick:le,title:I?.name||"Select Workspace",children:(0,Q.jsx)("div",{className:i.workspaceButtonIcon,children:(0,Q.jsx)(dr,{size:16})})})}),(0,Q.jsx)("span",{className:i.divider,children:"/"})]}),(0,Q.jsxs)("div",{className:i.projectTrigger,onClick:e?void 0:k,style:{cursor:e?"default":"pointer"},children:[(0,Q.jsx)("div",{className:i.projectTriggerIcon,children:(0,Q.jsx)($o,{size:16})}),(0,Q.jsx)("div",{className:i.projectTriggerInfo,children:(0,Q.jsx)("div",{className:i.projectTriggerName,children:R?.name||"Select Project"})}),!e&&(0,Q.jsx)("div",{className:`${i.projectTriggerArrow} ${Y?"expanded":""}`,children:(0,Q.jsx)(Jt,{size:14})})]}),!e&&Y&&(0,Q.jsxs)("div",{className:i.projectDropdown,children:[_.map(W=>(0,Q.jsxs)("div",{className:`${i.projectDropdownItem} ${W.id===se?"active":""}`,onClick:()=>T(W.id),children:[(0,Q.jsx)("div",{className:i.projectDropdownItemIcon,children:(0,Q.jsx)($o,{size:14})}),(0,Q.jsx)("div",{className:W.id===se?i.projectDropdownItemNameActive:i.projectDropdownItemName,children:W.name})]},W.id)),_.length===0&&(0,Q.jsx)("div",{className:i.emptyState,children:"No projects"})]})]})}),(0,Q.jsxs)(pe,{title:"Create New Project",open:de,onCancel:We,wrapClassName:i.modalWrap,centered:!0,destroyOnClose:!0,maskClosable:!A,keyboard:!0,closable:!0,footer:(0,Q.jsxs)("div",{className:i.modalFooter,children:[(0,Q.jsx)(z,{onClick:We,disabled:A,children:"Cancel"}),(0,Q.jsx)(z,{type:"primary",onClick:Ze,loading:A,disabled:!nt,children:"Create"})]}),children:[(0,Q.jsx)(H,{ref:B,value:S,onChange:Ke,onKeyDown:gt,placeholder:"Enter project name",maxLength:jn+10,status:J?"error":void 0}),J&&(0,Q.jsx)("div",{style:{color:"#ff4d4f",fontSize:"12px",marginTop:"4px"},children:J})]})]})};var Me=n(C());var Xi=n(s()),Yi=()=>{let{config:e}=Ce(),{openSideApp:t}=Se(),{workspaceId:o,projectId:r,listPath:a,listPathByFolder:i,getFileViewUrl:d,getFileDownloadUrl:c,uploadFileToFolder:p}=Ie(),{currentAssistant:g}=et(),[b,x]=(0,Me.useState)({}),[h,u]=(0,Me.useState)({}),[m,v]=(0,Me.useState)({}),[O,L]=(0,Me.useState)({}),[E,Y]=(0,Me.useState)({}),[ee,de]=(0,Me.useState)(null),V=(0,Me.useMemo)(()=>e.resourceFolders&&e.resourceFolders.length>0?e.resourceFolders:[{name:"/",displayName:"Project Assets",allowUpload:!0}],[e.resourceFolders]),S=(0,Me.useCallback)(async(A,ae=!0)=>{if(!o||!r){x(B=>({...B,[A.name]:[]}));return}u(B=>({...B,[A.name]:!0}));try{let B=await i(A.name,g?.id);if(x(j=>({...j,[A.name]:B})),ae){let j=A.name==="/"?"/":A.name.replace(/\/$/,"");v(se=>{let _={...se};return Object.keys(_).forEach(R=>{(R===j||R.startsWith(`${j}/`))&&delete _[R]}),_}),Y(se=>{let _={...se};return Object.keys(_).forEach(R=>{(R===j||R.startsWith(`${j}/`))&&delete _[R]}),_})}}catch(B){console.error(`Failed to load assets for folder ${A.name}:`,B),x(j=>({...j,[A.name]:[]}))}finally{u(B=>({...B,[A.name]:!1}))}},[o,r,i,g?.id]),F=(0,Me.useCallback)(async A=>{if(E[A]||!1){Y(B=>({...B,[A]:!1}));return}Y(B=>({...B,[A]:!0})),L(B=>({...B,[A]:!0}));try{let B=await a(A,g?.id);v(j=>({...j,[A]:B}))}catch(B){console.error(`Failed to load directory ${A}:`,B),v(j=>({...j,[A]:[]}))}finally{L(B=>({...B,[A]:!1}))}},[E,a,g?.id]);(0,Me.useEffect)(()=>{V.forEach(A=>{S(A,!1)})},[V,S]);let J=(0,Me.useCallback)(A=>{let ae=d(A.path,g?.id),B=c(A.path,g?.id);if(!ae||!B){q.warning("Please select a workspace and project first.");return}t({component_key:"attachments",data:{file_id:A.path,message:`Preview: ${A.name||A.path}`,full_url:ae,download_url:B},message:`Preview: ${A.name||A.path}`})},[d,c,t,g?.id]),Z=(0,Me.useCallback)(async A=>{if(!o||!r){q.warning("Please select a workspace and project before uploading.");return}let ae=document.createElement("input");ae.type="file",ae.onchange=async B=>{let se=B.target?.files?.[0];if(se){de(A);try{await p(A,se,g?.id),q.success(`Uploaded "${se.name}" successfully`);let _=V.find(R=>R.name===A);_&&await S(_)}catch(_){let R=_ instanceof Error?_.message:"Failed to upload file";q.error(R)}finally{de(null),ae.remove()}}},ae.click()},[o,r,p,V,S,g?.id]);return(0,Xi.jsx)(tn,{workspaceId:o,projectId:r,resourceFolders:V,folderEntries:b,folderLoading:h,directoryChildren:m,directoryLoading:O,directoryExpanded:E,uploadingFolder:ee,onRefreshFolder:S,onUploadFolder:Z,onToggleDirectory:F,onAssetClick:J})};var So=n(C());var Ge=n(s()),{Text:Ps,Paragraph:Is}=P,Ji={185:"Maximum update depth exceeded \u2014 likely an infinite re-render loop",31:"Objects are not valid as a React child",130:"Element type is invalid \u2014 check render method",152:"Too many re-renders \u2014 React limits renders to prevent an infinite loop",301:"Rendered fewer hooks than expected",306:"Rendered more hooks than during the previous render",310:"Rendered more hooks than during the previous render",321:"Invalid hook call \u2014 hooks can only be called inside function components",418:"Hydration failed because the server rendered content didn't match the client",423:"Hydration error \u2014 server/client mismatch in suspense boundary",424:"Could not find recovery element for hydrated instance",425:"Text content doesn't match server-rendered HTML"};function As(e){if(!e)return"";let t=e.message?.match(/Minified React error #(\d+)/);return t&&Ji[t[1]]?`${e.name}: Minified React error #${t[1]} \u2014 ${Ji[t[1]]}`:`${e.name}: ${e.message}`}var ut=class extends So.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null,retryKey:0}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){let r=this.props.name||"ChatErrorBoundary";console.error(`[${r}] Caught rendering error:`,t,o),this.setState({errorInfo:o}),this.props.onError?.(t,o)}handleRetry=()=>{this.setState(t=>({hasError:!1,error:null,errorInfo:null,retryKey:t.retryKey+1}))};handleCopyError=()=>{let{error:t,errorInfo:o}=this.state,a=[`[${this.props.name||"ChatErrorBoundary"}]`,`Error: ${t?.name}: ${t?.message}`,`Stack: ${t?.stack}`,`Component Stack: ${o?.componentStack}`].join(`
2142
2254
 
2143
- `);navigator.clipboard.writeText(a).then(()=>{H.success("Error details copied")}).catch(()=>{H.error("Failed to copy")})};render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;let{error:t,errorInfo:o}=this.state,r=this.props.name||"this section";return(0,Ge.jsx)(Br,{status:"error",title:`Failed to render ${r}`,subTitle:(0,Ge.jsxs)(ce,{direction:"vertical",size:"small",style:{textAlign:"left"},children:[(0,Ge.jsx)(fs,{type:"danger",strong:!0,children:hs(t)}),(t?.stack||o?.componentStack)&&(0,Ge.jsx)(It,{size:"small",ghost:!0,items:[{key:"details",label:"Error details",children:(0,Ge.jsxs)(ys,{code:!0,style:{maxHeight:200,overflow:"auto",whiteSpace:"pre-wrap",fontSize:12},children:[t?.stack||"",t?.stack&&o?.componentStack?`
2255
+ `);navigator.clipboard.writeText(a).then(()=>{q.success("Error details copied")}).catch(()=>{q.error("Failed to copy")})};render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;let{error:t,errorInfo:o}=this.state,r=this.props.name||"this section";return(0,Ge.jsx)(On,{status:"error",title:`Failed to render ${r}`,subTitle:(0,Ge.jsxs)(ce,{direction:"vertical",size:"small",style:{textAlign:"left"},children:[(0,Ge.jsx)(Ps,{type:"danger",strong:!0,children:As(t)}),(t?.stack||o?.componentStack)&&(0,Ge.jsx)(Et,{size:"small",ghost:!0,items:[{key:"details",label:"Error details",children:(0,Ge.jsxs)(Is,{code:!0,style:{maxHeight:200,overflow:"auto",whiteSpace:"pre-wrap",fontSize:12},children:[t?.stack||"",t?.stack&&o?.componentStack?`
2144
2256
 
2145
- `:"",o?.componentStack||""]})}]})]}),extra:[(0,Ge.jsx)(j,{icon:(0,Ge.jsx)(Kr,{}),onClick:this.handleCopyError,children:"Copy Details"},"copy"),(0,Ge.jsx)(j,{type:"primary",onClick:this.handleRetry,children:"Retry"},"retry")]})}return(0,Ge.jsx)(wo.default.Fragment,{children:this.props.children},this.state.retryKey)}};var te=n(s()),vs=w(({css:e})=>({wrapper:e`
2257
+ `:"",o?.componentStack||""]})}]})]}),extra:[(0,Ge.jsx)(z,{icon:(0,Ge.jsx)(Jn,{}),onClick:this.handleCopyError,children:"Copy Details"},"copy"),(0,Ge.jsx)(z,{type:"primary",onClick:this.handleRetry,children:"Retry"},"retry")]})}return(0,Ge.jsx)(So.default.Fragment,{children:this.props.children},this.state.retryKey)}};var te=n(s()),Es=w(({css:e})=>({wrapper:e`
2146
2258
  display: flex;
2147
2259
  flex-direction: column;
2148
2260
  width: 100%;
@@ -2163,5 +2275,5 @@ import{a as In}from"./embed-page-chunk-JLWIJ4BP.js";import{a as nt,b as Ut,c as
2163
2275
  align-items: center;
2164
2276
  justify-content: flex-end;
2165
2277
  flex-shrink: 0;
2166
- `})),bs=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:a,headerRight:i,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...g}=e,{config:b}=Te(),{styles:x}=vs(),h=d??b.enableWorkspace,u=(0,te.jsxs)("div",{className:x.headerBar,children:[(0,te.jsx)("div",{className:x.headerLeft,children:c??(h?(0,te.jsx)(xo,{}):null)}),(0,te.jsx)("div",{className:x.headerRight,children:i!==void 0?i:(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(ur,{assistantId:t}),(0,te.jsx)(br,{}),(0,te.jsx)(Wo,{})]})})]});return(0,te.jsxs)("div",{className:x.wrapper,children:[a,(0,te.jsx)(yt,{menu:r?(0,te.jsx)(ut,{name:"Sidebar",children:r}):void 0,header:u,main:(0,te.jsx)(ut,{name:"Chat panel",children:o?(0,te.jsx)(Pn,{...g}):p??(0,te.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,te.jsx)(ut,{name:"Detail panel",children:(0,te.jsx)(no,{})}),tools:(0,te.jsx)(ut,{name:"Tools panel",children:(0,te.jsx)(Li,{})})})]})},Co=e=>(0,te.jsx)(ut,{name:"Thread",children:(0,te.jsx)($o,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,te.jsx)(eo.Provider,{value:null,children:(0,te.jsx)(at,{children:(0,te.jsx)(bs,{...e})})})})});var tt=n(s()),xs=({thread_id:e,name:t,description:o,headerSelector:r,...a})=>{let{currentAssistant:i}=Ze(),{thread:d}=et(),c=e??d?.id??"";return c?(0,tt.jsx)(Co,{thread_id:c,name:t??i?.name,description:o??i?.description,headerSelector:r??(0,tt.jsx)(xo,{showWorkspace:!1,disableDropdown:!1}),...a}):(0,tt.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,tt.jsx)(de,{tip:"Creating conversation..."})})},Pi=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,tt.jsx)(In,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,tt.jsx)(Or,{autoLoad:!0,initialAssistantId:o,children:(0,tt.jsx)(Jt,{children:(0,tt.jsx)(xs,{assistant_id:o,...r})})})});var De=n(S());var Ne=class extends Error{code;retryable;status;constructor(t,o,r,a){super(o),this.name="AgentWebAppRuntimeClientError",this.code=t,this.retryable=r,this.status=a}};function xt(){return new Ne("STREAM_FAILED","Stream failed",!0)}var ws=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function Tt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xe(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e)}function Cs(e){return Tt(e)&&Xe(e,["code","message","retryable"])&&typeof e.code=="string"&&ws.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Ss(e){if(!Tt(e))return!1;let t=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return Xe(e,t)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||Tt(e.data))}var Rs=new Set([nt.HUMAN,nt.AI,nt.TOOL,nt.INTERRUPT,nt.MESSAGE_COMPLETED,nt.MESSAGE_FAILED,nt.THREAD_IDLE]);function ks(e,t){let o;try{o=JSON.parse(e)}catch{throw xt()}if(!Tt(o)||typeof o.type!="string")throw xt();if(Rs.has(o.type)||o.type==="error"&&Tt(o.data)&&!Tt(o.error)){let r=zr(o,t);return r.length===0?[]:r}switch(o.type){case"message.delta":if(Xe(o,["type","text"])&&typeof o.text=="string")return[o];break;case"message.completed":if(Xe(o,["type","messageId"])&&typeof o.messageId=="string")return[o];break;case"tool.started":if(Xe(o,["type","id","name"])&&typeof o.id=="string"&&typeof o.name=="string")return[o];break;case"tool.completed":if(Xe(o,["type","id"])&&typeof o.id=="string")return[o];break;case"interrupt.created":if(Xe(o,["type","interrupt"])&&Ss(o.interrupt))return[o];break;case"genui.render":if(Xe(o,["type","block"])&&Ut(o.block))return[o];break;case"error":if(Xe(o,["type","error"])&&Cs(o.error))return[o];break;case"stream.completed":if(Xe(o,["type"]))return[o];break}throw xt()}function Ts(e){return e instanceof Error&&e.name==="AbortError"}async function Wi(e,t){let o=jr({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),a=new TextDecoder,i="",d=!1,c=!1;try{for(;!d;){let p;try{p=await r.read()}catch(b){if(Ts(b))return;throw xt()}p.done&&(c=!0);try{i+=a.decode(p.value,{stream:!p.done})}catch{throw xt()}let g=i.split(/\r?\n\r?\n/);i=p.done?"":g.pop()??"";for(let b of g){let x=b.split(/\r?\n/).filter(h=>h==="data"||h.startsWith("data:")).map(h=>h==="data"?"":h.slice(5).replace(/^ /,""));if(x.length!==0){for(let h of ks(x.join(`
2167
- `),o))if(await t(h),d=h.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw xt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Ps=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function Be(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ze(e,t,o=[]){let r=Object.keys(e);return t.every(a=>a in e)&&r.every(a=>t.includes(a)||o.includes(a))}function ge(e){return typeof e=="string"}function So(e){if(!Be(e)||!ze(e,["id","projectId","createdAt","updatedAt"],["label"])||!ge(e.id)||!ge(e.projectId)||e.label!==void 0&&!ge(e.label)||!ge(e.createdAt)||!ge(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function Ui(e){if(!Be(e)||e.success!==!1||!Be(e.error))return!1;let t=e.error;return ze(e,["success","error"])&&ze(t,["code","message","retryable"])&&typeof t.code=="string"&&Ps.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Is(e){if(!Be(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return ze(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function As(e){return Be(e)&&ze(e,[],["title","welcomeMessage","primaryColor"])&&Object.values(e).every(ge)}function Es(e){if(!Be(e)||!ze(e,["webApp","projects","models"],["thread"])||!Be(e.webApp))return;let t=e.webApp;if(!ze(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!ge(t.id)||!ge(t.name)||!ge(t.defaultProjectId)||t.description!==void 0&&!ge(t.description)||t.defaultModelKey!==void 0&&!ge(t.defaultModelKey)||t.identityAssurance!=="unverified"||!Be(t.assistant)||!ze(t.assistant,["id","name"],["description"])||!ge(t.assistant.id)||!ge(t.assistant.name)||t.assistant.description!==void 0&&!ge(t.assistant.description)||!Is(t.features)||!As(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>Be(r)&&ze(r,["id","name"])&&ge(r.id)&&ge(r.name))||!Array.isArray(e.models)||!e.models.every(r=>Be(r)&&ze(r,["key","label"])&&ge(r.key)&&ge(r.label)))return;let o=e.thread===void 0?void 0:So(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function Ms(e){if(!Be(e)||!ze(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(So);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function Ns(e){return Be(e)&&ge(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||ge(e.content)||Array.isArray(e.content)&&e.content.every(t=>Ut(t)!==void 0))}function Bs(e){return Be(e)&&ze(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Ns)?e:void 0}function Ds(e){return Be(e)&&ze(e,["ref","name","mimeType","size"])&&ge(e.ref)&&ge(e.name)&&ge(e.mimeType)&&typeof e.size=="number"?e:void 0}function Ki(e,t){return o=>Be(o)&&ze(o,e)&&t(o)?o:void 0}var Ro=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",Es,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",Ms,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",So,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,So,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,Ki(["id"],a=>ge(a.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,Bs,{query:o,signal:r})}async streamMessage(t,o,r,a){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,a)}async resumeInterrupt(t,o,r,a,i){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,a,i)}async streamRequest(t,o,r,a){let i;try{i=await this.fetchRequest(t,{method:"POST",body:o,signal:a})}catch(d){throw qi(d)||d instanceof Ne?d:new Ne("STREAM_FAILED","Stream failed",!0)}if(i.ok||await this.throwResponseError(i),!i.body||!i.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(i.body)try{await i.body.cancel()}catch{}throw new Ne("STREAM_FAILED","Stream failed",!0,i.status)}await Wi(i.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,Ki(["aborted"],a=>typeof a.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},a){let i=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return i.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,Ds,{method:"POST",query:r,body:i,signal:a})}async request(t,o,r={}){let a;try{a=await this.fetchRequest(t,r)}catch(c){throw qi(c)||c instanceof Ne?c:new Ne("INTERNAL_ERROR","Request failed",!0)}let i;try{i=await a.json()}catch{throw this.internalError(a.status)}if(Ui(i))throw new Ne(i.error.code,i.error.message,i.error.retryable,a.status);if(!a.ok||!Be(i)||!ze(i,["success","data"])||i.success!==!0)throw this.internalError(a.status);let d=o(i.data);if(d===void 0)throw this.internalError(a.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),a=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&a.searchParams.set(c,p);let i=new Headers;r.bearerToken!==void 0?i.set("Authorization",`Bearer ${r.bearerToken}`):i.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(i.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(a,{method:o.method??"GET",headers:i,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw Ui(o)?new Ne(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Ne("INTERNAL_ERROR","Invalid server response",!1,t)}};function qi(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var ko=n(S());var Pt=n(s());function Hi(){let{createThread:e}=et(),{menuCollapsed:t,setMenuCollapsed:o}=xe();(0,ko.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,ko.useCallback)(async()=>{try{await e("New Thread")}catch(g){console.error("Failed to create new thread:",g)}},[e]),a=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,Pt.jsx)(nn,{size:20}),order:0},...a?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,Pt.jsx)(Mt,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,Pt.jsx)(Mt,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,Pt.jsx)(Cr,{})}]];return(0,Pt.jsx)(oo,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!a,collapsed:a,onCollapsedChange:o,onNewAnalysis:r,onItemClick:g=>{g.type==="action"&&g.builtin==="new-analysis"?r():g.type==="action"&&g.id==="thread-history-toggle"&&o(!1)}},a?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function Vi(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,a=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){a.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=a.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(s());function Fs(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function js(e){return e instanceof Ne?e:new Ne("INTERNAL_ERROR","Request failed",!0)}function zs(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function _x(e){Fs(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${zs(e.identity)}`;return(0,Re.jsx)($s,{...e},t)}function $s({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:a,onChatMessage:i,fetch:d,className:c}){let[p,g]=(0,De.useState)({status:"loading"}),b=(0,De.useRef)(o);b.current=o;let x=(0,De.useRef)(r);x.current=r;let h=(0,De.useRef)();return h.current||(h.current=new Ro({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let u=b.current;if(u.mode!=="verified")return{externalUserId:u.userId};try{return{bearerToken:await u.tokenProvider()}}catch{throw new Ne("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,De.useEffect)(()=>Vi({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,De.useEffect)(()=>{let u=!1,m=h.current;return(async()=>{try{let v=await m.bootstrap({});if(u)return;g({status:"ready",bootstrap:v})}catch(v){if(u)return;let _=js(v);g({status:"error",error:_}),x.current?.(_)}})(),()=>{u=!0}},[]),p.status==="loading"?(0,Re.jsx)("div",{className:c}):p.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:p.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>g({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(Os,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:p.bootstrap,onChatReady:a,onChatMessage:i})}function Ls(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function Os({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:a,onChatMessage:i,className:d}){let c=(0,De.useMemo)(()=>Ls(r.webApp.assistant),[r.webApp.assistant]),p=(0,De.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),g=(0,De.useCallback)(h=>new Fr({gatewayUrl:e,webAppId:t,identity:p,assistantId:h.assistantId,transport:h.transport,...h.timeout!==void 0?{timeout:h.timeout}:{},...h.headers!==void 0?{headers:h.headers}:{}}),[e,t,p]),b=(0,De.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,t]),x=(0,De.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,Re.jsx)($r,{config:{baseURL:b.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:g,children:(0,Re.jsx)(Wr,{initialConfig:b,persistToLocalStorage:!1,children:(0,Re.jsx)(Lr.Provider,{value:x,children:(0,Re.jsx)(Jt,{children:(0,Re.jsx)(_s,{className:d,onChatReady:a,onChatMessage:i})})})})})}function _s({className:e,onChatReady:t,onChatMessage:o}){let{threadId:r}=et(),{currentAssistant:a}=Ze();if(!a)return null;let i=r??"";return i?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(Co,{thread_id:i,assistant_id:a.id,name:a.name,description:a.description,menu:(0,Re.jsx)(Hi,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(de,{tip:"Creating conversation..."})})}export{Uo as a,ni as b,ii as c,Da as d,Wa as e,xo as f,Pi as g,_x as h};
2278
+ `})),Ns=e=>{let{assistant_id:t,thread_id:o="",menu:r,header:a,headerRight:i,showProjectSelector:d,headerSelector:c,emptyPlaceholder:p,...g}=e,{config:b}=Ce(),{styles:x}=Es(),h=d??b.enableWorkspace,u=(0,te.jsxs)("div",{className:x.headerBar,children:[(0,te.jsx)("div",{className:x.headerLeft,children:c??(h?(0,te.jsx)(Co,{}):null)}),(0,te.jsx)("div",{className:x.headerRight,children:i!==void 0?i:(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(wn,{assistantId:t}),(0,te.jsx)(En,{}),(0,te.jsx)(Ko,{})]})})]});return(0,te.jsxs)("div",{className:x.wrapper,children:[a,(0,te.jsx)(ht,{menu:r?(0,te.jsx)(ut,{name:"Sidebar",children:r}):void 0,header:u,main:(0,te.jsx)(ut,{name:"Chat panel",children:o?(0,te.jsx)(Dr,{...g}):p??(0,te.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,te.jsx)(ut,{name:"Detail panel",children:(0,te.jsx)(so,{})}),tools:(0,te.jsx)(ut,{name:"Tools panel",children:(0,te.jsx)(Yi,{})})})]})},ko=e=>(0,te.jsx)(ut,{name:"Thread",children:(0,te.jsx)(Oo,{assistantId:e.assistant_id,threadId:e.thread_id||"",options:{streaming:!0,enableReturnStateWhenStreamCompleted:!0,enableResumeStream:!0},children:(0,te.jsx)(no.Provider,{value:null,children:(0,te.jsx)(st,{children:(0,te.jsx)(Ns,{...e})})})})});var ot=n(s()),Ms=({thread_id:e,name:t,description:o,headerSelector:r,...a})=>{let{currentAssistant:i}=et(),{thread:d}=tt(),c=e??d?.id??"";return c?(0,ot.jsx)(ko,{thread_id:c,name:t??i?.name,description:o??i?.description,headerSelector:r??(0,ot.jsx)(Co,{showWorkspace:!1,disableDropdown:!1}),...a}):(0,ot.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,ot.jsx)(ne,{tip:"Creating conversation..."})})},zi=({defaultWorkspaceId:e,defaultProjectId:t,assistant_id:o,...r})=>(0,ot.jsx)(Fr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,ot.jsx)(Gn,{autoLoad:!0,initialAssistantId:o,children:(0,ot.jsx)(to,{children:(0,ot.jsx)(Ms,{assistant_id:o,...r})})})});var Fe=n(C());var Be=class extends Error{code;retryable;status;constructor(t,o,r,a){super(o),this.name="AgentWebAppRuntimeClientError",this.code=t,this.retryable=r,this.status=a}};function wt(){return new Be("STREAM_FAILED","Stream failed",!0)}var Bs=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function It(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Je(e,t){return Object.keys(e).length===t.length&&t.every(r=>r in e)}function Ds(e){return It(e)&&Je(e,["code","message","retryable"])&&typeof e.code=="string"&&Bs.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Fs(e){if(!It(e))return!1;let t=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return Je(e,t)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||It(e.data))}var zs=new Set([it.HUMAN,it.AI,it.TOOL,it.INTERRUPT,it.MESSAGE_COMPLETED,it.MESSAGE_FAILED,it.THREAD_IDLE]);function js(e,t){let o;try{o=JSON.parse(e)}catch{throw wt()}if(!It(o)||typeof o.type!="string")throw wt();if(zs.has(o.type)||o.type==="error"&&It(o.data)&&!It(o.error)){let r=Hn(o,t);return r.length===0?[]:r}switch(o.type){case"message.delta":if(Je(o,["type","text"])&&typeof o.text=="string")return[o];break;case"message.completed":if(Je(o,["type","messageId"])&&typeof o.messageId=="string")return[o];break;case"tool.started":if(Je(o,["type","id","name"])&&typeof o.id=="string"&&typeof o.name=="string")return[o];break;case"tool.completed":if(Je(o,["type","id"])&&typeof o.id=="string")return[o];break;case"interrupt.created":if(Je(o,["type","interrupt"])&&Fs(o.interrupt))return[o];break;case"genui.render":if(Je(o,["type","block"])&&qt(o.block))return[o];break;case"error":if(Je(o,["type","error"])&&Ds(o.error))return[o];break;case"stream.completed":if(Je(o,["type"]))return[o];break}throw wt()}function $s(e){return e instanceof Error&&e.name==="AbortError"}async function Zi(e,t){let o=Kn({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),a=new TextDecoder,i="",d=!1,c=!1;try{for(;!d;){let p;try{p=await r.read()}catch(b){if($s(b))return;throw wt()}p.done&&(c=!0);try{i+=a.decode(p.value,{stream:!p.done})}catch{throw wt()}let g=i.split(/\r?\n\r?\n/);i=p.done?"":g.pop()??"";for(let b of g){let x=b.split(/\r?\n/).filter(h=>h==="data"||h.startsWith("data:")).map(h=>h==="data"?"":h.slice(5).replace(/^ /,""));if(x.length!==0){for(let h of js(x.join(`
2279
+ `),o))if(await t(h),d=h.type==="stream.completed",d)break;if(d)break}}if(p.done)break}if(!d)throw wt()}finally{if(!c)try{await r.cancel()}catch{}r.releaseLock()}}var Ls=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $e(e,t,o=[]){let r=Object.keys(e);return t.every(a=>a in e)&&r.every(a=>t.includes(a)||o.includes(a))}function ge(e){return typeof e=="string"}function Ro(e){if(!De(e)||!$e(e,["id","projectId","createdAt","updatedAt"],["label"])||!ge(e.id)||!ge(e.projectId)||e.label!==void 0&&!ge(e.label)||!ge(e.createdAt)||!ge(e.updatedAt))return;let t=new Date(e.createdAt),o=new Date(e.updatedAt);if(!(Number.isNaN(t.getTime())||Number.isNaN(o.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:t,updatedAt:o}}function ea(e){if(!De(e)||e.success!==!1||!De(e.error))return!1;let t=e.error;return $e(e,["success","error"])&&$e(t,["code","message","retryable"])&&typeof t.code=="string"&&Ls.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function _s(e){if(!De(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return $e(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function Os(e){return De(e)&&$e(e,[],["title","welcomeMessage","primaryColor"])&&Object.values(e).every(ge)}function Ws(e){if(!De(e)||!$e(e,["webApp","projects","models"],["thread"])||!De(e.webApp))return;let t=e.webApp;if(!$e(t,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!ge(t.id)||!ge(t.name)||!ge(t.defaultProjectId)||t.description!==void 0&&!ge(t.description)||t.defaultModelKey!==void 0&&!ge(t.defaultModelKey)||t.identityAssurance!=="unverified"||!De(t.assistant)||!$e(t.assistant,["id","name"],["description"])||!ge(t.assistant.id)||!ge(t.assistant.name)||t.assistant.description!==void 0&&!ge(t.assistant.description)||!_s(t.features)||!Os(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>De(r)&&$e(r,["id","name"])&&ge(r.id)&&ge(r.name))||!Array.isArray(e.models)||!e.models.every(r=>De(r)&&$e(r,["key","label"])&&ge(r.key)&&ge(r.label)))return;let o=e.thread===void 0?void 0:Ro(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function Us(e){if(!De(e)||!$e(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(Ro);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function Ks(e){return De(e)&&ge(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||ge(e.content)||Array.isArray(e.content)&&e.content.every(t=>qt(t)!==void 0))}function Hs(e){return De(e)&&$e(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Ks)?e:void 0}function qs(e){return De(e)&&$e(e,["ref","name","mimeType","size"])&&ge(e.ref)&&ge(e.name)&&ge(e.mimeType)&&typeof e.size=="number"?e:void 0}function ta(e,t){return o=>De(o)&&$e(o,e)&&t(o)?o:void 0}var To=class{constructor(t){this.options=t;this.baseUrl=`${t.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(t.webAppId)}/runtime`,this.fetchImplementation=t.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(t={},o){return this.request("bootstrap",Ws,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",Us,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",Ro,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,Ro,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,ta(["id"],a=>ge(a.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,Hs,{query:o,signal:r})}async streamMessage(t,o,r,a){return this.streamRequest(`threads/${encodeURIComponent(t)}/messages/stream`,o,r,a)}async resumeInterrupt(t,o,r,a,i){return this.streamRequest(`threads/${encodeURIComponent(t)}/interrupts/${encodeURIComponent(o)}/resume`,r,a,i)}async streamRequest(t,o,r,a){let i;try{i=await this.fetchRequest(t,{method:"POST",body:o,signal:a})}catch(d){throw oa(d)||d instanceof Be?d:new Be("STREAM_FAILED","Stream failed",!0)}if(i.ok||await this.throwResponseError(i),!i.body||!i.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(i.body)try{await i.body.cancel()}catch{}throw new Be("STREAM_FAILED","Stream failed",!0,i.status)}await Zi(i.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,ta(["aborted"],a=>typeof a.aborted=="boolean"),{method:"POST",query:o,signal:r})}async uploadAttachment(t,o,r={},a){let i=new FormData,d=typeof File<"u"&&o instanceof File?o.name:"attachment";return i.append("file",o,d),this.request(`threads/${encodeURIComponent(t)}/attachments`,qs,{method:"POST",query:r,body:i,signal:a})}async request(t,o,r={}){let a;try{a=await this.fetchRequest(t,r)}catch(c){throw oa(c)||c instanceof Be?c:new Be("INTERNAL_ERROR","Request failed",!0)}let i;try{i=await a.json()}catch{throw this.internalError(a.status)}if(ea(i))throw new Be(i.error.code,i.error.message,i.error.retryable,a.status);if(!a.ok||!De(i)||!$e(i,["success","data"])||i.success!==!0)throw this.internalError(a.status);let d=o(i.data);if(d===void 0)throw this.internalError(a.status);return d}async fetchRequest(t,o){let r=await this.options.identityProvider.getIdentity(o.signal),a=new URL(`${this.baseUrl}/${t}`);for(let[c,p]of Object.entries(o.query??{}))p!==void 0&&a.searchParams.set(c,p);let i=new Headers;r.bearerToken!==void 0?i.set("Authorization",`Bearer ${r.bearerToken}`):i.set("X-Axiom-External-User-Id",r.externalUserId??"");let d;return o.body instanceof FormData?d=o.body:o.body!==void 0&&(i.set("Content-Type","application/json"),d=JSON.stringify(o.body)),this.fetchImplementation(a,{method:o.method??"GET",headers:i,body:d,signal:o.signal,credentials:"omit"})}async throwResponseError(t){let o;try{o=await t.json()}catch{throw this.internalError(t.status)}throw ea(o)?new Be(o.error.code,o.error.message,o.error.retryable,t.status):this.internalError(t.status)}internalError(t){return new Be("INTERNAL_ERROR","Invalid server response",!1,t)}};function oa(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var Po=n(C());var At=n(s());function na(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=Se();(0,Po.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,Po.useCallback)(async()=>{try{await e("New Thread")}catch(g){console.error("Failed to create new thread:",g)}},[e]),a=t??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,At.jsx)(mr,{size:20}),order:0},...a?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,At.jsx)(kt,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,At.jsx)(Bn,{})}]];return(0,At.jsx)(io,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!a,collapsed:a,onCollapsedChange:o,onNewAnalysis:r,onItemClick:g=>{g.type==="action"&&g.builtin==="new-analysis"?r():g.type==="action"&&g.id==="thread-history-toggle"&&o(!1)}},a?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ra(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let t=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,o=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,a=new WeakMap;return XMLHttpRequest.prototype.open=function(d,c){a.set(this,String(c)),o.call(this,d,c,!0)},XMLHttpRequest.prototype.send=function(d){let c=a.get(this)??"";if(!c.startsWith(t)||!/\/sandbox\/uploadfile$/.test(c)){r.call(this,d);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,d);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,d)}).catch(()=>{r.call(this,d)})},()=>{XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=r}}var Re=n(s());function Vs(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Gs(e){return e instanceof Be?e:new Be("INTERNAL_ERROR","Request failed",!0)}function Qs(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function tC(e){Vs(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${Qs(e.identity)}`;return(0,Re.jsx)(Ys,{...e},t)}function Ys({gatewayUrl:e,webAppId:t,identity:o,onError:r,onChatReady:a,onChatMessage:i,fetch:d,className:c}){let[p,g]=(0,Fe.useState)({status:"loading"}),b=(0,Fe.useRef)(o);b.current=o;let x=(0,Fe.useRef)(r);x.current=r;let h=(0,Fe.useRef)();return h.current||(h.current=new To({gatewayUrl:e,webAppId:t,identityProvider:{getIdentity:async()=>{let u=b.current;if(u.mode!=="verified")return{externalUserId:u.userId};try{return{bearerToken:await u.tokenProvider()}}catch{throw new Be("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,Fe.useEffect)(()=>ra({gatewayUrl:e,webAppId:t,identity:o}),[e,t,o]),(0,Fe.useEffect)(()=>{let u=!1,m=h.current;return(async()=>{try{let v=await m.bootstrap({});if(u)return;g({status:"ready",bootstrap:v})}catch(v){if(u)return;let O=Gs(v);g({status:"error",error:O}),x.current?.(O)}})(),()=>{u=!0}},[]),p.status==="loading"?(0,Re.jsx)("div",{className:c}):p.status==="error"?(0,Re.jsxs)("div",{className:c,role:"alert",children:[(0,Re.jsx)("strong",{children:"Unable to load the assistant"}),(0,Re.jsx)("div",{children:p.error.code}),(0,Re.jsx)("button",{type:"button",onClick:()=>g({status:"loading"}),children:"Retry"})]}):(0,Re.jsx)(Js,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:p.bootstrap,onChatReady:a,onChatMessage:i})}function Xs(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function Js({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:a,onChatMessage:i,className:d}){let c=(0,Fe.useMemo)(()=>Xs(r.webApp.assistant),[r.webApp.assistant]),p=(0,Fe.useMemo)(()=>o.mode==="unverified"?{mode:"unverified",userId:o.userId}:{mode:"verified",tokenProvider:o.tokenProvider},[o]),g=(0,Fe.useCallback)(h=>new Un({gatewayUrl:e,webAppId:t,identity:p,assistantId:h.assistantId,transport:h.transport,...h.timeout!==void 0?{timeout:h.timeout}:{},...h.headers!==void 0?{headers:h.headers}:{}}),[e,t,p]),b=(0,Fe.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${t}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,t]),x=(0,Fe.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,Re.jsx)(qn,{config:{baseURL:b.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:g,children:(0,Re.jsx)(Yn,{initialConfig:b,persistToLocalStorage:!1,children:(0,Re.jsx)(Vn.Provider,{value:x,children:(0,Re.jsx)(to,{children:(0,Re.jsx)(Zs,{className:d,onChatReady:a,onChatMessage:i})})})})})}function Zs({className:e,onChatReady:t,onChatMessage:o}){let{threadId:r}=tt(),{currentAssistant:a}=et();if(!a)return null;let i=r??"";return i?(0,Re.jsx)("div",{className:e,children:(0,Re.jsx)(ko,{thread_id:i,assistant_id:a.id,name:a.name,description:a.description,menu:(0,Re.jsx)(na,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,onChatReady:t,onChatMessage:o})}):(0,Re.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,Re.jsx)(ne,{tip:"Creating conversation..."})})}export{yt as a,pi as b,mi as c,Ya as d,rs as e,Co as f,zi as g,tC as h};