@axiom-lattice/gateway 4.2.1 → 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 (22) hide show
  1. package/dist/embed/{embed-page-AgentDetailSideApp-KGYKTMZR.js → embed-page-AgentDetailSideApp-DTDBMB2U.js} +1 -1
  2. package/dist/embed/{embed-page-AgentGovernanceWorkbench-F42AJH77.js → embed-page-AgentGovernanceWorkbench-JUP6SNBX.js} +1 -1
  3. package/dist/embed/{embed-page-MessageGraph-ACHQORG7.js → embed-page-MessageGraph-H5S7SARE.js} +1 -1
  4. package/dist/embed/{embed-page-ReactChart-FGUHXBED.js → embed-page-ReactChart-FWXMXO7F.js} +1 -1
  5. package/dist/embed/{embed-page-TasksSideApp-4GY5YBTN.js → embed-page-TasksSideApp-Q6HTW6S6.js} +1 -1
  6. package/dist/embed/{embed-page-TeamWorkspace-YWE6ZTLB.js → embed-page-TeamWorkspace-6KFWCIKW.js} +1 -1
  7. package/dist/embed/{embed-page-TopologyRuntimeView-MKFPCHT3.js → embed-page-TopologyRuntimeView-MASWKWXA.js} +1 -1
  8. package/dist/embed/{embed-page-WorkflowAutomationView-WT6VH5HD.js → embed-page-WorkflowAutomationView-6UOT36GW.js} +1 -1
  9. package/dist/embed/{embed-page-chunk-FDID7LZP.js → embed-page-chunk-2WCPJYBC.js} +1 -1
  10. package/dist/embed/{embed-page-chunk-3PY2YGBU.js → embed-page-chunk-3EUETTEM.js} +1 -1
  11. package/dist/embed/{embed-page-chunk-42S7N5Y5.js → embed-page-chunk-7SO4HHS4.js} +4 -4
  12. package/dist/embed/{embed-page-chunk-67U2KZFL.js → embed-page-chunk-AVZ7FKIO.js} +1 -1
  13. package/dist/embed/{embed-page-chunk-HS5VQFWH.js → embed-page-chunk-FJ3SFKJY.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-3WXEO6CG.js → embed-page-chunk-NFLB3VUZ.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-MGZK7ELC.js → embed-page-chunk-NHOWQIND.js} +126 -39
  16. package/dist/embed/{embed-page-chunk-FU2KMTSK.js → embed-page-chunk-X4DK4JRG.js} +1 -1
  17. package/dist/embed/embed-page.js +1 -1
  18. package/dist/index.js +29 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +29 -2
  21. package/dist/index.mjs.map +1 -1
  22. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";import{a as Dr}from"./embed-page-chunk-FU2KMTSK.js";import{$ as Jt,$a as Bt,Ea as Pr,F as zo,Fa as Mt,G as mr,Ga as Ir,Ha as w,Ia as Ar,J as ur,Ja as Ie,K as gr,L as at,La as eo,M as jo,Ma as tt,Na as $o,Oa as st,Pa as Se,Qa as to,R as fr,Ra as Er,Sa as oo,T as St,U as yr,V as hr,W as vr,a as qn,b as Vn,c as et,d as Yt,da as br,f as lr,fa as Zt,ga as xr,ib as Nr,j as Et,ka as wr,l as cr,la as Ve,mb as Mr,na as Lo,o as dr,oa as Cr,ob as Br,p as Xt,pa as Sr,qb as Oo,r as Nt,ua as _o,va as kr,w as pr,ya as Rr,za as Tr}from"./embed-page-chunk-42S7N5Y5.js";import{f as Wn,i as We,k as Hn,m as Gn,o as Qn,p as Ce,q as me}from"./embed-page-chunk-74BPRLSV.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{$ as Kt,$b as er,Ac as rr,Ca as $n,Eb as qt,Fa as wt,Gc as ir,Ia as ve,Ic as ar,Ja as $e,Kc as Gt,La as P,Lc as Qt,Ma as On,Nc as sr,Tb as Zn,V as At,Va as Bo,W as z,Y as No,Z as xe,_ as Ee,aa as ze,bc as tr,fc as or,ia as _e,la as _n,mb as Ct,mc as Vt,na as Mo,oa as ce,ob as Yn,pa as qe,qb as Xn,rc as ft,sb as Do,ta as H,tb as Jn,va as ne,wa as Te,xa as q,ya as pe,yb as Fo,yc as nr}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 Fr=n(s()),la=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 it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
19
19
  background: ${e.colorBgTextHover};
20
20
  border-color: ${e.colorBorderSecondary};
21
21
  }
22
- `})),kt=({ariaLabel:e,icon:t,onClick:o,pressed:r=!1})=>{let{styles:a}=la();return(0,Fr.jsx)(z,{type:"text",size:"small",className:a.button,icon:t,onClick:o,"aria-label":e,"aria-pressed":r})};var Wo=n(s()),Uo=()=>{let{toolsVisible:e,toggleTools:t}=Se();return(0,Wo.jsx)(kt,{ariaLabel:"Toggle file directory",icon:(0,Wo.jsx)(at,{size:16}),onClick:t,pressed:e})};var he=n(C());var Ue=n(C());var no=n(C());function Ko(e){let[t,o]=(0,no.useState)(()=>typeof window<"u"?window.matchMedia(e).matches:!1);return(0,no.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()),yt=({main:e,detail:t,tools:o,logo:r,menu:a,header:i,mainStyle:d})=>{let{styles:c}=to(),{detailVisible:p,detailSize:g,detailSelectedCard:b,toolsVisible:x,toolSelectedCard:h,contentAppSelectedCard:u,menuCollapsed:m,setMenuCollapsed:v,closeDetail:O,closeTools:_}=Se(),E=Ko("(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)(xr,{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)(Mt,{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:_,"aria-label":"Close tool panel",children:(0,ke.jsx)(Mt,{size:20})}),x&&o?(0,ke.jsx)("div",{className:c.detailContent,children:o}):null]})]})]})]})};var Pe=n(C());var N=n(s()),zr={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}},ca=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 it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
63
63
  width: 22px;
64
64
  height: 22px;
65
65
  }
66
- `})),da=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})},ro=({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:_}=ca(),{styles:E}=to(),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)(()=>da(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:`${_.sidebar} ${E.iconMode} ${u||""}`,style:m,children:[i?(0,N.jsx)("div",{className:E.iconModeLogo,children:o||r||(0,N.jsx)(zo,{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 Oe=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 Oe?(0,N.jsx)(qe,{menu:{items:Oe},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)(Nt,{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:`${_.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)(zo,{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)(Zt,{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)(Zt,{size:18})}):null,c&&(0,N.jsxs)("button",{className:`${E.newAnalysisBtn} ${B?"collapsed":""}`,onClick:p,children:[(0,N.jsx)(Cr,{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,Oe=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":""} ${Oe?E.menuItemExpandedActive:""}`,onClick:()=>se(D),title:B?D.name:void 0,"aria-label":D.name,"aria-expanded":Oe,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:Oe?(0,N.jsx)(Xt,{size:16}):(0,N.jsx)(Nt,{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&&Oe&&!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)(Mo,{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)(Zt,{size:24})})]}),open:S[k.id]||!1,onClose:()=>$(k.id),placement:"left",width:k.width||600,styles:{...zr,header:{padding:"16px 20px",borderBottom:"1px solid rgba(0, 0, 0, 0.04)"},content:{...zr.content,borderRadius:"0 24px 24px 0",overflow:"hidden"}},closable:!1,mask:!1,destroyOnClose:!0,children:k.content},k.id))]})};var jr=n(C());var Lr=n(s()),{TextArea:vl}=H;var _r=n(s());var Rt=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},pa=new Ho;var ma=n(s()),kl=(0,Rt.createContext)(null);var Or=n(s()),Il=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 lt=n(C());var ua=n(s());var Bl=300*1e3,Dl=(0,lt.createContext)(null);var rn=n(C());var qo=n(C());var ga=n(C());var fa=n(s());var Ur=n(s()),Hl=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%;
@@ -166,7 +166,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
166
166
  gap: 2px;
167
167
  `,emptyContainer:t`
168
168
  padding: 24px 16px;
169
- `}));var Aa=n(C());var ct=n(C());var ha=n(s());var mc=(0,ct.createContext)(null);var Lt=n(C());var Ae=n(C());var M=n(s()),va=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`
170
170
  display: flex;
171
171
  flex-direction: column;
172
172
  height: 100%;
@@ -411,7 +411,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
411
411
  transform: translateY(0);
412
412
  }
413
413
  }
414
- `})),ba=({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)})]}),io=e=>(0,M.jsx)(Bo,{style:{fontSize:12,opacity:.6}}),ao=({region:e="side",compact:t=!0,showCloseButton:o=!0})=>{let{styles:r}=va(),{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),[_,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=[..._,{label:le,children:k,key:T,componentKey:oe}];E(D),m(T)},j=T=>{let le=u,k=_.findIndex(D=>D.key===T),oe=_.filter(D=>D.key!==T);if(oe.length===0){x();return}le===T&&(k>0?le=_[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(_.find(k=>k.key===T)){m(T),setTimeout(()=>{document.querySelector(`[data-tab-key="${T}"]`)?.scrollIntoView({behavior:"smooth",inline:"center"})},100);return}let le=Oo(b?.component_key)?.side_app_view||ba;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 $=_.find(T=>T.key===u),R=_.map(T=>({key:T.key,label:(0,M.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 0"},children:[io(T.componentKey),(0,M.jsx)("span",{style:{flex:1},children:T.label}),(0,M.jsx)(Ct,{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&&_.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:_.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:[io(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)(Ct,{style:{fontSize:10}})})]})},T.key))}),_.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)(Ct,{})})})]}):$&&(0,M.jsxs)("div",{className:r.compactPill,children:[io($.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:_.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:[io(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)(Ct,{style:{fontSize:10}})})]})},T.key))}),(0,M.jsxs)("div",{className:r.actions,children:[_.length>0&&(0,M.jsx)("div",{className:r.tabCounter,children:_.length}),_.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)(Ct,{})})})]})]}),(0,M.jsx)("div",{className:r.content,style:t&&_.length>0?{paddingTop:10}:void 0,children:(0,M.jsx)(oo.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)(Bo,{className:"icon"}),(0,M.jsx)("span",{children:"Select an app to start"})]})})})]})};var Ft=n(C());var Vo=n(C());var Go=n(s());var Pc=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`
415
415
  display: flex;
416
416
  flex-direction: column;
417
417
  gap: 4px;
@@ -480,7 +480,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
480
480
  font-size: 12px;
481
481
  color: ${e.colorTextTertiary};
482
482
  }
483
- `}));var Hr=n(s()),Nc=w(({token:e,css:t})=>({root:t`
483
+ `}));var Vr=n(s()),Vc=w(({token:e,css:t})=>({root:t`
484
484
  display: flex;
485
485
  align-items: center;
486
486
  gap: 8px;
@@ -493,7 +493,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
493
493
  font-size: 12px;
494
494
  color: ${e.colorTextTertiary};
495
495
  }
496
- `}));var qr=n(s());var Wc=w(({token:e,css:t})=>({root:t`
496
+ `}));var Gr=n(s());var rd=w(({token:e,css:t})=>({root:t`
497
497
  flex: 1;
498
498
  min-height: 0;
499
499
  overflow-y: auto;
@@ -519,11 +519,11 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
519
519
  transform: translateX(-50%);
520
520
  `,list:t`
521
521
  padding: 0 12px;
522
- `}));var zt=n(C());var Vr=n(s()),md=w(({token:e,css:t})=>({root:t`
522
+ `}));var jt=n(C());var Qr=n(s()),Ad=w(({token:e,css:t})=>({root:t`
523
523
  flex-shrink: 0;
524
524
  border-top: 1px solid ${e.colorBorderSecondary};
525
525
  background: ${e.colorBgContainer};
526
- padding: 8px 12px;
526
+ padding: 8px 12px max(8px, env(safe-area-inset-bottom));
527
527
  `,reply:t`
528
528
  display: flex;
529
529
  align-items: center;
@@ -540,7 +540,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
540
540
  margin-top: 8px;
541
541
  font-size: 13px;
542
542
  color: ${e.colorErrorText};
543
- `}));var Gr=n(s());var yd=w(({token:e,css:t})=>({root:t`
543
+ `}));var Yr=n(s());var Bd=w(({token:e,css:t})=>({root:t`
544
544
  display: flex;
545
545
  align-items: center;
546
546
  justify-content: space-between;
@@ -574,7 +574,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
574
574
  font-size: 13px;
575
575
  color: ${e.colorTextSecondary};
576
576
  white-space: nowrap;
577
- `}));var Qo=n(C());var Yo=n(s());var Cd=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`
578
578
  display: flex;
579
579
  flex-direction: column;
580
580
  height: 100%;
@@ -658,7 +658,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
658
658
  opacity: 0.7;
659
659
  `,error:t`
660
660
  margin-bottom: 12px;
661
- `}));var lo=n(C());var Qr=n(s());var nn=n(C());var re=n(C());var Xo=e=>{if(!e)return"";let t=e.split("/").filter(Boolean);return t[t.length-1]??""},Yr=(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 jt(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=Xo(r.path),p=Xo(a.path);return o==="asc"?c.localeCompare(p):p.localeCompare(c)}let i=Yr(r,t),d=Yr(a,t);return i===null&&d===null?0:i===null?1:d===null?-1:o==="asc"?i-d:d-i})}function Xr(e,t){let o=t.trim().toLowerCase();return o?e.filter(r=>{let a=(r.path||"").toLowerCase(),i=Xo(r.path).toLowerCase();return a.includes(o)||i.includes(o)}):e}function Jr(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 Jo(e,t="name",o="asc"){return jt(e,t,o).map(r=>r.children?{...r,children:Jo(r.children,t,o)}:r)}var y=n(s()),wa=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`
662
662
  height: 100%;
663
663
  overflow-y: auto;
664
664
  overflow-x: hidden;
@@ -847,7 +847,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
847
847
  width: 14px;
848
848
  height: 14px;
849
849
  }
850
- `})),Zr=e=>{if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()},Ca=e=>{if(!e)return"";let t=e.split(/[/\\]/);return t[t.length-1]},Zo=e=>Ca(e.name||e.path),Sa=e=>(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{style:{fontWeight:600},children:Zo(e)}),e.created_at?(0,y.jsxs)("div",{children:["Created: ",Zr(e.created_at)]}):null,e.modified_at?(0,y.jsxs)("div",{children:["Modified: ",Zr(e.modified_at)]}):null]}),ka={display:"flex",flexDirection:"column",gap:12},en=({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}=wa(),{message:m}=No.useApp(),{currentAssistant:v}=et(),{getFileDownloadUrl:O,downloadFolder:_,getDirectFileUrl:E,listPathByFolder:Y}=Ie(),{openSideApp:ee}=Se(),{currentTenant:de}=We(),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}=co(),$=tn(),[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)(""),[Oe,Ke]=(0,re.useState)(""),[Ze,gt]=(0,re.useState)(!1),[nt,W]=(0,re.useState)(""),[fe,rt]=(0,re.useState)("name"),[Qe,na]=(0,re.useState)("asc"),[Ot,Po]=(0,re.useState)(null),[ra,Io]=(0,re.useState)(!1);(0,re.useEffect)(()=>{k&&on(se).then(f=>{I(Array.from(new Set([...$,...f])).sort())})},[k]),(0,re.useEffect)(()=>{let f=nt.trim();if(!f){Po(null),Io(!1);return}let X=!1;return Io(!0),Mr(Y,o.map(K=>K.name),v?.id).then(K=>{X||Po(Xr(K,f))}).catch(()=>{X||Po([])}).finally(()=>{X||Io(!1)}),()=>{X=!0}},[nt,Y,o,v?.id]);let Ao=(0,re.useMemo)(()=>Ot?Jo(Jr(Ot),fe,Qe):null,[Ot,fe,Qe]),Wt=(0,re.useCallback)((f,X)=>{if(!X||!j)return;le(L=>L[f]?L:{...L,[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:L=>L.resourcePath===f};A(K).then(L=>{le(He=>({...He,[f]:{...L,loading:!1}}))}).catch(()=>{le(L=>({...L,[f]:{isPinned:!1,pinnedId:null,loading:!1}}))})},[j,A,v?.id]),ia=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:Oe.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)}},Ut=(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(L=>({...L,[f]:{...L[f],loading:!1}}))}},[B,m]),jn=(0,re.useCallback)(async f=>{Z(f);try{let X=await _(f,v?.id),K=URL.createObjectURL(X),L=document.createElement("a");L.href=K;let He=f.replace(/\/$/,"").split("/").pop()||"folder";L.download=`${He}.zip`,L.click(),window.setTimeout(()=>URL.revokeObjectURL(K),0)}catch(X){m.error(X instanceof Error?X.message:"Failed to download folder")}finally{Z(null)}},[_,v?.id,m]),Eo=re.default.useCallback((f,X)=>{let K=Zo(f);if(f.is_dir){let L=c[f.path]||!1,He=i[f.path]||[],aa=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,sa)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${sa}`)),(0,y.jsx)("button",{type:"button",className:u.treeToggle,"aria-label":`${L?"collapse":"expand"} ${K}`,onClick:()=>void x(f.path),children:(0,y.jsx)(Nt,{size:14,style:{transform:L?"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=>Wt(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&&Ut(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)(qt,{}),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)(Vt,{}),label:"Share",onClick:()=>F(f.path)},{key:"download-folder",icon:(0,y.jsx)(Fo,{}),label:"Download",disabled:J===f.path,onClick:()=>{jn(f.path)}}]},children:(0,y.jsx)(z,{type:"text",size:"small",icon:(0,y.jsx)(ft,{})})})]}),L?aa?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):He.length>0?jt(He,fe,Qe).map(Ye=>Eo(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((L,He)=>(0,y.jsx)("span",{className:u.treeIndent},`${f.path}-indent-${He}`)),(0,y.jsx)("span",{className:u.treeSpacer}),(0,y.jsx)(ze,{title:Sa(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:Nr(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:L=>Wt(f.path,L),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let L=T[f.path];L?.pinnedId&&Ut(f.path,L.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)(qt,{}),label:"Preview",onClick:()=>h(f)},{key:"download",icon:(0,y.jsx)(Fo,{}),label:"Download",onClick:()=>{let L=O(f.path,v?.id);window.open(L,"_blank")}},{key:"share",icon:(0,y.jsx)(Vt,{}),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,_,v?.id,j,T,Wt,Ut,J,jn,fe,Qe]),Ln=(f,X)=>{if(!f.is_dir)return Eo(f,X);let K=Zo(f);return(0,y.jsxs)("div",{className:u.treeChildren,children:[(0,y.jsxs)("div",{className:u.treeRow,children:[Array.from({length:X}).map((L,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:L=>Wt(f.path,L),menu:{items:[...j?T[f.path]?.isPinned?[{key:"unpin",icon:(0,y.jsx)(Ve,{size:14}),label:"Unpin from Menu",onClick:()=>{let L=T[f.path];L?.pinnedId&&Ut(f.path,L.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)(qt,{}),label:"Preview",onClick:()=>{let L=E(f.path);L&&ee({component_key:"attachments",data:{file_id:f.path,url:L},message:K})}},{key:"share",icon:(0,y.jsx)(Vt,{}),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?jt(f.children,fe,Qe).map(L=>Ln(L,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)(Gt,{}):(0,y.jsx)(Qt,{}),onClick:()=>na(f=>f==="asc"?"desc":"asc"),title:Qe==="asc"?"Ascending":"Descending"})]})]}),Ot!==null?(0,y.jsx)("div",{className:u.assetList,children:ra?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):Ao&&Ao.length>0?Ao.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,L=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:L})]}),K?(0,y.jsx)("div",{className:u.loading,children:(0,y.jsx)(ne,{size:"small"})}):(0,y.jsxs)("div",{className:u.assetList,children:[jt(X,fe,Qe).map(He=>Eo(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)(Tr,{size:14}),(0,y.jsx)("span",{children:"Upload"})]})}):null]})]},f.name)}),S&&(0,y.jsx)(Er,{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:ia,onCancel:()=>oe(null),confirmLoading:Ze,okText:"Pin",children:(0,y.jsxs)("div",{style:ka,children:[(0,y.jsx)(H,{placeholder:"Menu name (required)",value:D,onChange:f=>U(f.target.value)}),(0,y.jsx)(Kt,{placeholder:"Group (optional, select or type new)",value:Oe,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 ei=n(s());var ep=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`
851
851
  display: flex;
852
852
  flex-direction: column;
853
853
  height: 100%;
@@ -872,7 +872,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
872
872
  flex: 1;
873
873
  min-height: 0;
874
874
  overflow: hidden;
875
- `}));var Ra=n(C());var ti=n(s());var ap=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`
876
876
  display: flex;
877
877
  flex-direction: column;
878
878
  height: 100%;
@@ -953,7 +953,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
953
953
  height: 32px;
954
954
  opacity: 0.5;
955
955
  }
956
- `}));var oi=n(s());var Ep=w(({token:e,css:t})=>({root:t`
956
+ `}));var ri=n(s());var Vp=w(({token:e,css:t})=>({root:t`
957
957
  display: flex;
958
958
  flex-direction: column;
959
959
  height: 100%;
@@ -980,11 +980,11 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
980
980
  flex: 1;
981
981
  min-height: 0;
982
982
  min-width: 0;
983
- `}));var Ea=n(s()),Lp=w(({css:e})=>({wrapper:e`
983
+ `}));var $a=n(s()),tm=w(({css:e})=>({wrapper:e`
984
984
  height: 100%;
985
985
  width: 100%;
986
986
  overflow: hidden;
987
- `}));var ni=n(s()),Vp=w(({token:e,css:t})=>({menuList:t`
987
+ `}));var sn=n(s()),pm=w(({token:e,css:t})=>({menuList:t`
988
988
  height: 100%;
989
989
  overflow-y: auto;
990
990
  `,header:t`
@@ -1009,7 +1009,34 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1009
1009
  color: ${e.colorTextSecondary};
1010
1010
  font-size: 14px;
1011
1011
  gap: 8px;
1012
- `}));var ai=n(C());var an=n(C());var ri=n(s()),em=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`
1013
1040
  display: flex;
1014
1041
  flex-direction: column;
1015
1042
  height: 100%;
@@ -1096,7 +1123,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1096
1123
  color: ${e.colorPrimary};
1097
1124
  `,emptyContainer:t`
1098
1125
  padding: 24px 16px;
1099
- `}));var ii=n(s()),nm=w(({token:e,css:t})=>({container:t`
1126
+ `}));var ai=n(s()),wm=w(({token:e,css:t})=>({container:t`
1100
1127
  display: flex;
1101
1128
  flex-direction: column;
1102
1129
  height: 100%;
@@ -1189,7 +1216,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1189
1216
  display: flex;
1190
1217
  flex-direction: column;
1191
1218
  gap: 12px;
1192
- `}));var si=n(s()),um=w(({token:e,css:t})=>({menuList:t`
1219
+ `}));var cn=n(s()),Mm=w(({token:e,css:t})=>({menuList:t`
1193
1220
  height: 100%;
1194
1221
  overflow-y: auto;
1195
1222
  `,header:t`
@@ -1214,7 +1241,34 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1214
1241
  color: ${e.colorTextSecondary};
1215
1242
  font-size: 14px;
1216
1243
  gap: 8px;
1217
- `}));var ci=n(s()),Cm=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`
1218
1272
  display: flex;
1219
1273
  flex-direction: column;
1220
1274
  align-items: center;
@@ -1257,7 +1311,40 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1257
1311
  height: 100%;
1258
1312
  width: 100%;
1259
1313
  overflow: hidden;
1260
- `}));var _a=n(s());var _t=n(C());var po=18,Fm={agent:_t.default.createElement(Et,{size:po}),html:_t.default.createElement(fr,{size:po}),custom:_t.default.createElement(Sr,{size:po}),file:_t.default.createElement(ur,{size:po})};var Ja=n(C());var $a=n(C());var di=n(s());var Xa=n(C());var mo=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||Gn).filter(b=>!p.has(b.type)),[o]),isLoading:a,isFallback:d}}var mi=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`
1261
1348
  width: clamp(180px, 20vw, 240px);
1262
1349
  flex-shrink: 0;
1263
1350
  border-right: 1px solid ${e.colorBorderSecondary};
@@ -1371,7 +1458,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1371
1458
  height: 6px;
1372
1459
  border-radius: 9999px;
1373
1460
  flex-shrink: 0;
1374
- `}));var ui=n(s()),{Text:Vm}=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)(_e,{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,sn=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`
1375
1462
  display: flex;
1376
1463
  align-items: center;
1377
1464
  gap: 16px;
@@ -1440,7 +1527,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1440
1527
  grid-template-columns: repeat(2, minmax(0, 1fr));
1441
1528
  gap: 12px 16px;
1442
1529
  padding: 8px 0;
1443
- `})),uo=({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)(ir,{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})]})},Oa=({text:e,className:t})=>(0,l.jsx)(ze,{title:e,placement:"topLeft",children:(0,l.jsx)("div",{className:t,children:e})}),Wa=({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)(Bt,{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)(Oa,{text:c.description,className:a.toolDesc}),renderHeaderActions:()=>(0,l.jsx)(_e,{checked:p,onClick:g=>g.stopPropagation(),onChange:()=>d(c.name)})},c.id)})})]})},Ua=({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)(uo,{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)(_e,{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)}})})},Ka=({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)(uo,{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)(_e,{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)}})})},Ha=({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)(uo,{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)(_e,{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)}})})},qa=({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)(uo,{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)(_e,{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)}})})},Va=({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)(Jn,{}),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)(nr,{}),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)(rr,{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)(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)(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)(tr,{style:{color:t.colorPrimary}});case"sql":return(0,l.jsx)(Do,{style:{color:t.colorWarning}});case"skill":return(0,l.jsx)(sr,{style:{color:t.colorSuccess}});case"filesystem":return(0,l.jsx)(er,{style:{color:t.colorInfo}});case"code_eval":return(0,l.jsx)(Yn,{style:{color:t.colorError}});case"metrics":return(0,l.jsx)(Yt,{size:20,style:{color:t.colorWarning}});case"topology":return(0,l.jsx)(ar,{style:{color:t.colorPrimary}});case"document-parser":return(0,l.jsx)(Zn,{style:{color:t.colorSuccess}});case"collection":return(0,l.jsx)(Do,{style:{color:t.colorInfo}});default:return(0,l.jsx)(or,{style:{color:t.colorWarning}})}},Ga=({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}),_=()=>(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)(wt,{"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:_()})]}),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)(Wa,{tools:E,selectedToolNames:ee,allToolNames:Y,onChange:a,styles:g})]})]})},Qa=e=>{let{token:t}=$e.useToken(),{styles:o}=sn();return(0,l.jsx)(Ga,{...e,token:t,styles:o,renderListSubSection:(a,i,d,c,p)=>{switch(i.widget){case"skillSelect":return(0,l.jsx)(Ua,{value:d,onChange:c,token:t,styles:o},a);case"databaseSelect":return(0,l.jsx)(Ka,{value:d,onChange:c,token:t,styles:o},a);case"metricsSelect":return(0,l.jsx)(Ha,{value:d,onChange:c,token:t,styles:o},a);case"collectionSelect":return(0,l.jsx)(qa,{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)(Va,{value:d,onChange:c,token:t,styles:o},a);default:return null}}})};var vi=n(s()),{Text:fu}=P,yu=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`
1444
1531
  width: 100%;
1445
1532
  background: ${t.colorFillQuaternary};
1446
1533
  border-color: ${t.colorBorderSecondary};
@@ -1451,7 +1538,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1451
1538
  `,toolName:e`
1452
1539
  font-weight: 600;
1453
1540
  font-size: 13px;
1454
- `}));var bi=n(s()),{Text:xu}=P,wu=w(({css:e,token:t})=>({diagram:e`
1541
+ `}));var bi=n(s()),{Text:Ku}=P,Hu=w(({css:e,token:t})=>({diagram:e`
1455
1542
  display: flex;
1456
1543
  flex-direction: column;
1457
1544
  gap: 0;
@@ -1486,7 +1573,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1486
1573
  font-size: 12px;
1487
1574
  line-height: 1.5;
1488
1575
  color: ${t.colorTextSecondary};
1489
- `}));var xi=n(s()),{Text:zu,Title:ju}=P,Lu=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`
1490
1577
  display: flex;
1491
1578
  height: 100%;
1492
1579
  gap: 20px;
@@ -1519,7 +1606,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1519
1606
  font-size: 13px;
1520
1607
  font-weight: 600;
1521
1608
  padding: 2px 8px;
1522
- `}));var ln=n(s());var Za=n(s());var wi=n(C());var cn=n(s()),{Text:ag}=P,{TextArea:sg}=H,{useToken:lg}=$e;var Ci=n(C());var pn=n(s()),{Text:fg}=P,{TextArea:yg}=H,hg=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`
1523
1610
  height: 100%;
1524
1611
  display: flex;
1525
1612
  flex-direction: column;
@@ -1568,14 +1655,14 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1568
1655
  font-size: 13px;
1569
1656
  color: ${e.colorTextSecondary};
1570
1657
  margin-top: 8px;
1571
- `}));var fo=n(C());var Si=n(C());var mn=n(s()),{Text:kg}=P,Rg=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`
1572
1659
  margin-bottom: 16px;
1573
1660
  `,fieldLabel:e`
1574
1661
  display: block;
1575
1662
  margin-bottom: 6px;
1576
1663
  font-weight: 500;
1577
1664
  font-size: 13px;
1578
- `}));var ts=n(s()),{Text:Dg}=P;var Ri=n(C());var os=n(C());var ki=n(s());var un=n(s()),{Text:Hg}=P,{TextArea:qg}=H,{useToken:Vg}=$e,{Panel:Gg}=At;var bt=n(C());var gn=n(s()),of=(0,bt.lazy)(()=>import("./embed-page-SkillFlow-SFZ5HLMK.js")),{Text:nf}=P,{TextArea:rf}=H;var Ti=n(C());var yn=n(C());var hn=n(s()),{Text:uf,Paragraph:gf}=P,ff=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`
1579
1666
  height: 100%;
1580
1667
  display: flex;
1581
1668
  flex-direction: column;
@@ -1649,7 +1736,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1649
1736
  background: ${e.colorPrimaryBg} !important;
1650
1737
  transition: background 0.25s;
1651
1738
  }
1652
- `}));var bn=n(s()),{Text:kf}=P,Rf=w(({token:e,css:t})=>({container:t`
1739
+ `}));var Cn=n(s()),{Text:Gf}=P,Qf=w(({token:e,css:t})=>({container:t`
1653
1740
  padding: ${e.paddingLG}px;
1654
1741
  height: 100%;
1655
1742
  overflow-y: auto;
@@ -1663,7 +1750,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1663
1750
  gap: ${e.marginSM}px;
1664
1751
  margin-bottom: ${e.marginSM}px;
1665
1752
  align-items: center;
1666
- `}));var xn=n(C());var Pi=n(s());var Ii=n(C());var Ai=n(s()),{Text:Ff,Title:zf}=P;var ho=n(C());var yo=n(C());var Ei=n(C());var Ni=n(s()),{Text:Hf}=P;var Mi=n(s()),{Text:ey}=P;var wn=n(C());var Cn=n(s()),{Text:dy,Paragraph:py}=P;var Sn=n(s()),{Text:Cy}=P;var kn=n(C());var Bi=n(s()),{Text:Py}=P;var Rn=n(C());var vo=n(C());var Di=n(C());var Fi=n(s()),{Text:Ly}=P;var Tn=n(s()),{Text:Gy}=P;var xo=n(C());var bo=n(C());var Tt=n(s()),rs=(0,bo.lazy)(()=>import("./embed-page-TasksSideApp-4GY5YBTN.js").then(e=>({default:e.TasksSideApp}))),Pn=()=>{let{openSideApp:e,sideAppVisible:t,sideAppSelectedCard:o}=Se(),r=t&&o?.component_key==="tasks_side_app_pin";return(0,Tt.jsx)(kt,{ariaLabel:"Open tasks",icon:(0,Tt.jsx)(Jt,{size:16}),onClick:()=>{r||e({component_key:"tasks_side_app_pin",message:"Tasks",data:{component:(0,Tt.jsx)(bo.Suspense,{fallback:(0,Tt.jsx)(ne,{style:{display:"block",margin:"auto"}}),children:(0,Tt.jsx)(rs,{showProjectFilter:!1})})}})}})};var $t=n(C());var In=n(s()),{Text:lh}=P;var ch=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`
1667
1754
  display: flex;
1668
1755
  height: 460px;
1669
1756
  `,leftPanel:e`
@@ -1822,7 +1909,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1822
1909
  padding: 12px 24px;
1823
1910
  border-top: 1px solid ${t.colorBorderSecondary};
1824
1911
  flex-shrink: 0;
1825
- `}));var An=n(s()),{Title:Th,Text:Ph,Paragraph:Ih}=P,Ah=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`
1826
1913
  width: 56px; height: 56px; border-radius: ${t.borderRadiusLG}px;
1827
1914
  background: linear-gradient(135deg, ${t.colorPrimary}, ${t.colorPrimaryActive});
1828
1915
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 12px;
@@ -1837,7 +1924,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1837
1924
  `,chatRoot:e` display: flex; flex-direction: column; height: 100%; min-height: 0; `,chatBar:e`
1838
1925
  display: flex; align-items: center; justify-content: space-between;
1839
1926
  padding: 8px 16px; border-bottom: 1px solid ${t.colorBorderSecondary}; flex-shrink: 0;
1840
- `,chatFill:e` flex: 1; min-height: 0; `}));var $i=n(C());var Nn=n(C());var be=n(C());function Li(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 _i(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()),is=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`
1841
1928
  padding: 4px;
1842
1929
  font-size: 13px;
1843
1930
  background: transparent;
@@ -1964,7 +2051,7 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
1964
2051
  text-align: center;
1965
2052
  color: ${e.colorTextSecondary};
1966
2053
  font-size: 12px;
1967
- `})),En=()=>{let{styles:e}=is(),{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),[_,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(()=>_i(Li(t,_),Y,de),[t,_,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:_,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)(Gt,{}):(0,G.jsx)(Qt,{}),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:_.trim()?`No conversations match "${_.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)(br,{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)(dr,{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)(Mt,{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)(wr,{size:12})}),(0,G.jsx)("button",{className:e.actionBtn,onClick:I=>J(I,R.id),title:"Delete conversation",children:(0,G.jsx)(Rr,{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 Mn=n(s());var Oi=n(s());var Wi=n(C());var Ui=n(s()),{Text:vv}=P;var fs=n(C());var Bn=n(C());var Ki=n(s()),{Text:kv}=P;var gs=n(C());var us=n(C());var Dn=n(s());var Fn=n(s()),{Dragger:Bv}=On,{Text:Dv,Title:Fv}=P;var Hi=n(s()),{Title:Uv,Text:Kv}=P;var ye=n(s()),qi=[{id:"personal_assistant",type:"route",name:"Personal Assistant",icon:(0,ye.jsx)(Et,{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)(Yt,{size:20}),order:10,group:"DataSource"},{id:"database",builtin:"database",type:"route",name:"Database",icon:(0,ye.jsx)(mr,{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)(St,{size:20}),order:26,group:"Process"},{id:"topology-inbox",type:"route",name:"Inbox",icon:(0,ye.jsx)(yr,{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)(lr,{size:20}),order:56,group:"Settings"},{id:"eval",type:"route",name:"Eval",icon:(0,ye.jsx)(gr,{size:20}),order:28,group:"Process"},{id:"assistants",builtin:"assistants",type:"route",name:"Assistants",icon:(0,ye.jsx)(Et,{size:20}),order:30,group:"Settings"},{id:"skills",builtin:"skills",type:"route",name:"Skills",icon:(0,ye.jsx)(Ir,{size:20}),order:35,group:"Settings"},{id:"collections",type:"route",name:"Collections",icon:(0,ye.jsx)(vr,{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)(hr,{size:20}),order:45,group:"Settings"},{id:"open-audit",type:"route",name:"Audit Log",icon:(0,ye.jsx)(St,{size:20}),order:47,group:"Settings"},{id:"capability-bundles",type:"route",name:"Runtime Profiles",icon:(0,ye.jsx)(kr,{size:20}),order:46,group:"Settings"},{id:"tools",builtin:"tools",type:"route",name:"Tools",icon:(0,ye.jsx)(Pr,{size:20}),order:50,group:"Settings"},{id:"tasks",type:"route",name:"Tasks",icon:(0,ye.jsx)(Jt,{size:20}),order:100}];var lx=(0,Ue.lazy)(()=>import("./embed-page-AgentGovernanceWorkbench-F42AJH77.js").then(e=>({default:e.AgentGovernanceWorkbench}))),cx=(0,Ue.lazy)(()=>import("./embed-page-TopologyRuntimeView-MKFPCHT3.js").then(e=>({default:e.TopologyRuntimeView}))),dx=(0,Ue.lazy)(()=>import("./embed-page-WorkflowAutomationView-WT6VH5HD.js").then(e=>({default:e.WorkflowAutomationView}))),px=(0,Ue.lazy)(()=>import("./embed-page-TasksSideApp-4GY5YBTN.js").then(e=>({default:e.TasksSideApp}))),mx=(0,Ue.lazy)(()=>import("./embed-page-AgentDetailSideApp-KGYKTMZR.js").then(e=>({default:e.AgentDetailSideApp})));var Ne=n(s());function ys(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 hs(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 vs(e,t){let{contentType:o,name:r,group:a}=t,i=ys(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 bs(e,t){let o=await e(`/api/menu-items/${t}`);if(!o.success)throw new Error(o.message||"Failed to unpin")}function co(){let e=he.default.useContext(Ar),{config:t}=Ce(),{post:o,get:r,del:a}=me(),i=t.enableCustomMenu??!1,d=(0,he.useCallback)(async g=>hs(r,g,i),[r,i]),c=(0,he.useCallback)(async g=>vs(o,{...g,workspaceId:e?.workspaceId,projectId:e?.projectId}),[o,e]),p=(0,he.useCallback)(async g=>bs(a,g),[a]);return{check:d,pin:c,unpin:p,enableCustomMenu:i,get:r}}function Vi(e){let t=new Set;for(let o of e)o.group?.trim()&&t.add(o.group.trim());return Array.from(t).sort()}function tn(){let{config:e}=Ce(),t=he.default.useMemo(()=>Vi(qi),[]),o=he.default.useMemo(()=>Vi(e.workspaceMenuItems??[]),[e.workspaceMenuItems]);return he.default.useMemo(()=>Array.from(new Set([...t,...o])).sort(),[t,o])}async function on(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 xs={display:"flex",flexDirection:"column",gap:12},vn=({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}=co(),[h,u]=(0,he.useState)(!1),[m,v]=(0,he.useState)(""),[O,_]=(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=tn(),[A,ae]=(0,he.useState)(Z);(0,he.useEffect)(()=>{ae(Z)},[Z]),(0,he.useEffect)(()=>{h&&on(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(""),_(""),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:xs,children:[(0,Ne.jsx)(H,{placeholder:"Menu name (required)",value:O,onChange:I=>_(I.target.value)}),(0,Ne.jsx)(Kt,{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()),zn=50,ws=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`
1968
2055
  position: relative;
1969
2056
  `,projectTrigger:t`
1970
2057
  display: flex;
@@ -2163,11 +2250,11 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
2163
2250
  display: flex;
2164
2251
  justify-content: flex-end;
2165
2252
  gap: 8px;
2166
- `})),wo=({disableDropdown:e=!0,showWorkspace:t=!0,value:o,onChange:r,kind:a})=>{let{styles:i}=ws(),{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),_=(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>zn?`Name must be ${zn} 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]),Oe=(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:_,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)(cr,{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)(jo,{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)(Xt,{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)(jo,{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:Oe,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:Oe,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:zn+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 Qi=n(s()),Gi=()=>{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,_]=(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})),_(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{_(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,Qi.jsx)(en,{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 Co=n(C());var Ge=n(s()),{Text:Cs,Paragraph:Ss}=P,Yi={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 ks(e){if(!e)return"";let t=e.message?.match(/Minified React error #(\d+)/);return t&&Yi[t[1]]?`${e.name}: Minified React error #${t[1]} \u2014 ${Yi[t[1]]}`:`${e.name}: ${e.message}`}var ut=class extends Co.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(`
2167
2254
 
2168
- `);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)($n,{status:"error",title:`Failed to render ${r}`,subTitle:(0,Ge.jsxs)(ce,{direction:"vertical",size:"small",style:{textAlign:"left"},children:[(0,Ge.jsx)(Cs,{type:"danger",strong:!0,children:ks(t)}),(t?.stack||o?.componentStack)&&(0,Ge.jsx)(At,{size:"small",ghost:!0,items:[{key:"details",label:"Error details",children:(0,Ge.jsxs)(Ss,{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?`
2169
2256
 
2170
- `:"",o?.componentStack||""]})}]})]}),extra:[(0,Ge.jsx)(z,{icon:(0,Ge.jsx)(Xn,{}),onClick:this.handleCopyError,children:"Copy Details"},"copy"),(0,Ge.jsx)(z,{type:"primary",onClick:this.handleRetry,children:"Retry"},"retry")]})}return(0,Ge.jsx)(Co.default.Fragment,{children:this.props.children},this.state.retryKey)}};var te=n(s()),Rs=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`
2171
2258
  display: flex;
2172
2259
  flex-direction: column;
2173
2260
  width: 100%;
@@ -2188,5 +2275,5 @@ import{a as it,b as Ht,c as Un,d as Kn}from"./embed-page-chunk-67U2KZFL.js";impo
2188
2275
  align-items: center;
2189
2276
  justify-content: flex-end;
2190
2277
  flex-shrink: 0;
2191
- `})),Ts=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}=Rs(),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)(wo,{}):null)}),(0,te.jsx)("div",{className:x.headerRight,children:i!==void 0?i:(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(vn,{assistantId:t}),(0,te.jsx)(Pn,{}),(0,te.jsx)(Uo,{})]})})]});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)(Br,{...g}):p??(0,te.jsx)("div",{children:"Please create a conversation first"})}),detail:(0,te.jsx)(ut,{name:"Detail panel",children:(0,te.jsx)(ao,{})}),tools:(0,te.jsx)(ut,{name:"Tools panel",children:(0,te.jsx)(Gi,{})})})]})},So=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)(oo.Provider,{value:null,children:(0,te.jsx)(st,{children:(0,te.jsx)(Ts,{...e})})})})});var ot=n(s()),Ps=({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)(So,{thread_id:c,name:t??i?.name,description:o??i?.description,headerSelector:r??(0,ot.jsx)(wo,{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)(Dr,{defaultWorkspaceId:e,defaultProjectId:t,children:(0,ot.jsx)(Vn,{autoLoad:!0,initialAssistantId:o,children:(0,ot.jsx)(eo,{children:(0,ot.jsx)(Ps,{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 xt(){return new Be("STREAM_FAILED","Stream failed",!0)}var Is=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 Pt(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 As(e){return Pt(e)&&Je(e,["code","message","retryable"])&&typeof e.code=="string"&&Is.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function Es(e){if(!Pt(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||Pt(e.data))}var Ns=new Set([it.HUMAN,it.AI,it.TOOL,it.INTERRUPT,it.MESSAGE_COMPLETED,it.MESSAGE_FAILED,it.THREAD_IDLE]);function Ms(e,t){let o;try{o=JSON.parse(e)}catch{throw xt()}if(!Pt(o)||typeof o.type!="string")throw xt();if(Ns.has(o.type)||o.type==="error"&&Pt(o.data)&&!Pt(o.error)){let r=Kn(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"])&&Es(o.interrupt))return[o];break;case"genui.render":if(Je(o,["type","block"])&&Ht(o.block))return[o];break;case"error":if(Je(o,["type","error"])&&As(o.error))return[o];break;case"stream.completed":if(Je(o,["type"]))return[o];break}throw xt()}function Bs(e){return e instanceof Error&&e.name==="AbortError"}async function Xi(e,t){let o=Un({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(Bs(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 Ms(x.join(`
2192
- `),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 Ds=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 Le(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 ko(e){if(!De(e)||!Le(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 Ji(e){if(!De(e)||e.success!==!1||!De(e.error))return!1;let t=e.error;return Le(e,["success","error"])&&Le(t,["code","message","retryable"])&&typeof t.code=="string"&&Ds.has(t.code)&&typeof t.message=="string"&&typeof t.retryable=="boolean"}function Fs(e){if(!De(e))return!1;let t=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return Le(e,t,["files"])&&t.every(o=>typeof e[o]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function zs(e){return De(e)&&Le(e,[],["title","welcomeMessage","primaryColor"])&&Object.values(e).every(ge)}function js(e){if(!De(e)||!Le(e,["webApp","projects","models"],["thread"])||!De(e.webApp))return;let t=e.webApp;if(!Le(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)||!Le(t.assistant,["id","name"],["description"])||!ge(t.assistant.id)||!ge(t.assistant.name)||t.assistant.description!==void 0&&!ge(t.assistant.description)||!Fs(t.features)||!zs(t.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>De(r)&&Le(r,["id","name"])&&ge(r.id)&&ge(r.name))||!Array.isArray(e.models)||!e.models.every(r=>De(r)&&Le(r,["key","label"])&&ge(r.key)&&ge(r.label)))return;let o=e.thread===void 0?void 0:ko(e.thread);if(!(e.thread!==void 0&&!o))return{...e,...o?{thread:o}:{}}}function Ls(e){if(!De(e)||!Le(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let t=e.records.map(ko);return t.every(o=>o!==void 0)?{records:t,total:e.total}:void 0}function _s(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=>Ht(t)!==void 0))}function $s(e){return De(e)&&Le(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(_s)?e:void 0}function Os(e){return De(e)&&Le(e,["ref","name","mimeType","size"])&&ge(e.ref)&&ge(e.name)&&ge(e.mimeType)&&typeof e.size=="number"?e:void 0}function Zi(e,t){return o=>De(o)&&Le(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",js,{query:t,signal:o})}async listThreads(t={},o){return this.request("threads",Ls,{query:t,signal:o})}async createThread(t={},o){return this.request("threads",ko,{method:"POST",body:t,signal:o})}async updateThread(t,o,r){return this.request(`threads/${encodeURIComponent(t)}`,ko,{method:"PATCH",body:o,signal:r})}async deleteThread(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}`,Zi(["id"],a=>ge(a.id)),{method:"DELETE",query:o,signal:r})}async getMessages(t,o={},r){return this.request(`threads/${encodeURIComponent(t)}/messages`,$s,{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 ea(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 Xi(i.body,r)}async abort(t,o={},r){await this.request(`threads/${encodeURIComponent(t)}/abort`,Zi(["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`,Os,{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 ea(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(Ji(i))throw new Be(i.error.code,i.error.message,i.error.retryable,a.status);if(!a.ok||!De(i)||!Le(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 Ji(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 ea(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var To=n(C());var It=n(s());function ta(){let{createThread:e}=tt(),{menuCollapsed:t,setMenuCollapsed:o}=Se();(0,To.useEffect)(()=>{t===void 0&&o(!0)},[t,o]);let r=(0,To.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,It.jsx)(pr,{size:20}),order:0},...a?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,It.jsx)(St,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,It.jsx)(St,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,It.jsx)(En,{})}]];return(0,It.jsx)(ro,{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 oa(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 Ws(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 Us(e){return e instanceof Be?e:new Be("INTERNAL_ERROR","Request failed",!0)}function Ks(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function zw(e){Ws(e);let t=`${e.gatewayUrl}\0${e.webAppId}\0${Ks(e.identity)}`;return(0,Re.jsx)(Hs,{...e},t)}function Hs({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 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 Be("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...d?{fetch:d}:{}})),(0,Fe.useEffect)(()=>oa({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=Us(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)(Vs,{className:c,gatewayUrl:e,webAppId:t,identity:o,bootstrap:p.bootstrap,onChatReady:a,onChatMessage:i})}function qs(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 Vs({gatewayUrl:e,webAppId:t,identity:o,bootstrap:r,onChatReady:a,onChatMessage:i,className:d}){let c=(0,Fe.useMemo)(()=>qs(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 Wn({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)(Hn,{config:{baseURL:b.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:g,children:(0,Re.jsx)(Qn,{initialConfig:b,persistToLocalStorage:!1,children:(0,Re.jsx)(qn.Provider,{value:x,children:(0,Re.jsx)(eo,{children:(0,Re.jsx)(Gs,{className:d,onChatReady:a,onChatMessage:i})})})})})}function Gs({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)(So,{thread_id:i,assistant_id:a.id,name:a.name,description:a.description,menu:(0,Re.jsx)(ta,{}),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{Ko as a,pi as b,mi as c,Oa as d,Qa as e,wo as f,zi as g,zw 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};