1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1001],{101777:(e,t,r)=>{r.d(t,{U:()=>i});var s=r(695155),n=r(870460),a=r(212115);function i({className:e}){let[t,r]=(0,a.useState)(!1),{resolvedTheme:i,setTheme:d}=(0,n.D)();if((0,a.useEffect)(()=>{r(!0)},[]),!t)return(0,s.jsx)("button",{className:`p-2 rounded-lg bg-secondary ${e||""}`,"aria-label":"Toggle theme",children:(0,s.jsx)("div",{className:"w-5 h-5"})});let c="dark"===i;return(0,s.jsx)("button",{onClick:()=>d(c?"light":"dark"),className:`p-2 rounded-lg bg-secondary hover:bg-accent transition-colors ${e||""}`,"aria-label":`Switch to ${c?"light":"dark"} mode`,children:c?(0,s.jsx)(l,{className:"w-5 h-5 text-foreground"}):(0,s.jsx)(o,{className:"w-5 h-5 text-foreground"})})}function l({className:e}){return(0,s.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})}function o({className:e}){return(0,s.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}},102059:(e,t,r)=>{r.d(t,{E:()=>d,p:()=>o});var s=r(695155),n=r(212115),a=r(396429),i=r(476666);let l=(0,n.createContext)(void 0);function o({children:e}){let[t,r]=(0,n.useState)([]),{baseUrl:o}=(0,a.ed)(),{subscribe:d}=(0,i.M)();(0,n.useEffect)(()=>d("notification",e=>{r(t=>[...t,e])}),[d]);let c=(0,n.useCallback)(e=>{r(t=>t.filter(t=>t.id!==e))},[]),u=(0,n.useCallback)(async(e,t)=>{try{await fetch(`${o}/notifications/${e}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({data:t})})}catch(e){console.error("Failed to respond to notification:",e)}c(e)},[o,c]);return(0,s.jsx)(l.Provider,{value:{notifications:t,dismissNotification:c,respondToNotification:u},children:e})}function d(){let e=(0,n.useContext)(l);if(!e)throw Error("useNotifications must be used within a NotificationProvider");return e}},142270:(e,t,r)=>{r.d(t,{A:()=>a});var s=r(695155),n=r(821628);function a(){return(0,s.jsxs)("a",{"data-announcement-bar":!0,href:"https://www.relevancelab.com/newsroom/relevance-lab-accelerates-ai-enterprise-transformation-with-strategic-majority-investment-in-kaman-ai",target:"_blank",rel:"noopener noreferrer",className:"group fixed inset-x-0 top-0 z-50 flex h-[var(--announcement-bar-height)] items-center justify-center gap-2 sm:gap-3 bg-gradient-orange-pink px-4 text-white",children:[(0,s.jsx)("span",{className:"shrink-0 rounded-full bg-white/25 px-2.5 py-0.5 text-[10px] sm:text-[11px] font-semibold tracking-[0.15em]",children:"NEWS"}),(0,s.jsx)("span",{className:"min-w-0 line-clamp-2 sm:truncate text-xs sm:text-sm font-medium leading-4 sm:leading-normal",children:"Relevance Lab makes a strategic majority investment in kaman.ai"}),(0,s.jsxs)("span",{className:"shrink-0 inline-flex items-center gap-1 text-xs sm:text-sm font-semibold underline-offset-4 group-hover:underline",children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:"Learn more"}),(0,s.jsx)(n.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5","aria-hidden":!0})]})]})}},165065:(e,t,r)=>{r.d(t,{J:()=>d,v:()=>o});var s=r(695155),n=r(212115),a=r(378670),i=r(476666);let l=(0,n.createContext)({balance:null,freeTokenBalance:null,loading:!0,refreshBalance:async()=>{},multiplier:1e3});function o({children:e}){let{user:t,organization:r,isLoading:o}=(0,a.A)(),{subscribe:d}
1=(0,i.M)(),[c,u]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),[h,g]=(0,n.useState)(!0),[f,p]=(0,n.useState)(1e3);(0,n.useEffect)(()=>{fetch("/api/auth/auth/platform-config/credits-per-dollar").then(e=>e.json()).then(e=>{let t=e?.credits_per_dollar;t&&p(Number(t))}).catch(()=>{})},[]);let b=(0,n.useCallback)(e=>e*f,[f]),j=(0,n.useCallback)(e=>e?{allocated:e.allocated*f,used:e.used*f,remaining:e.remaining*f,period_start:e.period_start,period_end:e.period_end}:null,[f]),v=(0,n.useCallback)(async()=>{if(t?.id&&r?.id)try{let e=await fetch(`/api/auth/credits/${t.id}?organizationId=${r.id}&limit=1`);if(e.ok){let t=await e.json();u(b(t.data?.availableCredits??0)),t.data?.freeTokenBalance&&x(j(t.data.freeTokenBalance))}}catch(e){console.error("Failed to fetch credit balance:",e)}finally{g(!1)}},[t?.id,r?.id,b,j]);return(0,n.useEffect)(()=>{o||v()},[o,v]),(0,n.useEffect)(()=>d("credit_update",e=>{void 0!==e.balance&&u(b(e.balance)),e.freeTokenBalance&&x(j(e.freeTokenBalance)),void 0!==e.balance||e.freeTokenBalance||v()}),[d,v,b,j]),(0,s.jsx)(l.Provider,{value:{balance:c,freeTokenBalance:m,loading:h,refreshBalance:v,multiplier:f},children:e})}function d(){return(0,n.useContext)(l)}},241001:(e,t,r)=>{r.d(t,{A:()=>T});var s=r(695155),n=r(212115),a=r(573321),i=r(378670),l=r(668354),o=r(102059),d=r(284150),c=r(598500),u=r.n(c),m=r(779240),x=r(917647),h=r(101777),g=r(871275),f=r(93219),p=r(61767),b=r(829857),j=r(833210),v=r(566614),N=r(937595),y=r(976498),w=r(397810),k=r(742869),C=r(589363),S=r(341313),A=r(165065),E=r(318635),z=r(817894),$=r(142270),_=r(745222);function T({breadcrumbItems:e,showSidebar:t=!0,showRightSidebar:r=!1}={}){let[c,L]=(0,n.useState)(!1),[M,P]=(0,n.useState)(!1),F=(0,a.useRouter)();(0,a.usePathname)();let D=(0,n.useRef)(null),{isAuthenticated:W,isLoading:R,user:O,organization:B,logout:U,hasPermission:I}=(0,i.A)(),{isSidebarCollapsed:V,toggleSidebarVisibility:J,getSidebarWidth:H,isRightSidebarVisible:q,getRightSidebarWidth:K}=(0,l.gK)(),{notifications:G}=(0,o.E)(),{stats:X}=(0,_.z)(),{balance:Y,freeTokenBalance:Q,loading:Z}=(0,A.J)(),{showToast:ee}=(0,d.useToastContext)(),[et,er]=(0,n.useState)(!1),[es,en]=(0,n.useState)(!1),ea=(0,n.useRef)(null),ei=(0,n.useRef)(null),el=(0,n.useRef)(G.length);(0,n.useEffect)(()=>{if(G.length>el.current){let e=G[G.length-1];!1!==e.showToast&&ee({message:`${e.title}: ${e.message}`.slice(0,120),type:"error"===e.type?"error":"warning"===e.type?"warning":"info",duration:5e3})}el.current=G.length},[G,ee]),(0,n.useEffect)(()=>{let e=e=>{ea.current&&!ea.current.contains(e.target)&&er(!1)};return et&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[et]),(0,n.useEffect)(()=>{let e=e=>{ei.current&&!ei.current.contains(e.target)&&en(!1)};return es&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[es]);let eo=!t;(0,n.useEffect)(()=>{let e=e=>{D.current&&!D.current.contains(e.target)&&P(!1)};return M?document.addEventListener("mousedown",e):document.removeEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[M]);let ed=()=>{L(!c)},ec=()=>{L(!1)};return(0,s.jsxs)(s.Fragment,{children:[!t&&(0,s.jsx)($.A,{}),(0,s.jsxs)("header",{className:"fixed top-[var(--announcement-bar-height)] right-0 border-b border-border/10 z-50 transition-all duration-300 bg-background",children:[(0,s.jsxs)("div",{className:"px-4 sm:px-6 lg:px-8 flex justify-between items-center ",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[t&&(0,s.jsx)("button",{onClick:J,className:"lg:hidden p-2 text-foreground hover:text-primary rounded-lg transition-colors duration-200","aria-label":"Toggle sidebar menu",children:(0,s.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),(0,s.jsx)("div",{className:`flex items-center ${t?"lg:hidden":""}`,children:(0,s.jsx)(u(),{href:"/",className:"flex items-center",children:(0,s.jsx)(x.Logo,{className:"h-9 md:h-11 w-auto"})})}),e&&(0,s.jsx)("div",{className:"lg:flex-1 hidden lg:flex",children:(0,s.jsx)(m.Ay,{items:e})})]}),(0,s.jsxs)("div",{className:"flex justify-end items-center h-16",children:[(0,s.jsxs)("div",{className:"hidden lg:flex items-center space-x-4",children:[(0,s.jsx)(h.U,{}),W&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u(),{href:"/billing",className:"flex items-center space-x-1.5 px-3 py-1.5 rounded-lg bg-brand-50 dark:bg-brand-900/20 text-brand-700 dark:text-brand-300 hover:bg-brand-100 dark:hover:bg-brand-900/30 transition-colors text-sm font-medium",title:"Available credits â click to manage",children:[(0,s.jsx)(g.A,{size:15}),(0,s.jsx)("span",{children:Z?"...":`${Math.round(Y??0).toLocaleStr
1ing()} cr`}),Q&&Q.remaining>0&&(0,s.jsxs)("span",{className:"text-xs opacity-70",title:`Free credits: ${Math.round(Q.remaining).toLocaleString()} remaining`,children:["| ",Math.round(Q.remaining).toLocaleString()," free"]})]}),(0,s.jsxs)("div",{className:"relative",ref:ei,children:[(0,s.jsxs)("button",{onClick:()=>{en(!es),er(!1)},className:"relative p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg transition-all duration-200","aria-label":"Agent Runs",children:[(0,s.jsx)(f.A,{size:18}),X.running>0&&(0,s.jsx)("span",{className:"absolute -top-0.5 -right-0.5 min-w-[18px] h-[18px] flex items-center justify-center bg-blue-500 text-white text-[10px] font-bold rounded-full px-1 leading-none",children:X.running>99?"99+":X.running})]}),es&&(0,s.jsx)(z.A,{})]}),(0,s.jsxs)("div",{className:"relative",ref:ea,children:[(0,s.jsxs)("button",{onClick:()=>{er(!et),en(!1)},className:"relative p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg transition-all duration-200","aria-label":"Notifications",children:[(0,s.jsx)(p.A,{size:18}),G.length>0&&(0,s.jsx)("span",{className:"absolute -top-0.5 -right-0.5 min-w-[18px] h-[18px] flex items-center justify-center bg-red-500 text-white text-[10px] font-bold rounded-full px-1 leading-none",children:G.length>99?"99+":G.length})]}),et&&(0,s.jsx)(E.A,{})]})]}),(0,s.jsx)(u(),{href:"/integrations",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Integrations"}),(0,s.jsx)(u(),{href:"/pricing",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Pricing"}),(0,s.jsx)(u(),{href:"/marketplace",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Templates"}),(0,s.jsx)(u(),{href:"/blog",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Blog"}),(0,s.jsx)(u(),{href:"/whitepapers",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Papers"}),(0,s.jsx)("a",{href:"/docs",target:"_blank",className:"px-3 py-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-lg font-medium text-sm transition-all duration-200",children:"Docs"}),eo&&W&&(0,s.jsxs)("button",{onClick:()=>F.push("/home"),className:"inline-flex items-center px-6 py-3 bg-gradient-to-r from-brand-500 to-brand-secondary text-white rounded-lg font-semibold text-sm shadow-lg hover:from-brand-600 hover:to-brand-700 hover:shadow-xl transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2",children:[(0,s.jsx)("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),"Go to Dashboard"]}),!R&&(0,s.jsx)(s.Fragment,{children:W?(0,s.jsx)("div",{className:"flex items-center space-x-4",children:(0,s.jsxs)("div",{className:"relative",ref:D,children:[(0,s.jsxs)("button",{onClick:()=>{P(!M)},className:"flex items-center gap-2 px-2 py-2 rounded-xl hover:bg-accent transition-all duration-200 group border border-transparent hover:border-border",children:[(0,s.jsx)("div",{className:"w-9 h-9 min-w-[36px] min-h-[36px] bg-gradient-to-br from-brand-500 to-brand-secondary dark:from-gray-600 dark:to-gray-500 rounded-full flex items-center justify-center text-white dark:text-gray-900 text-sm font-bold shadow-md ring-2 ring-brand-100 dark:ring-gray-600 group-hover:ring-brand-200 dark:group-hover:ring-gray-500 transition-all duration-200",children:O?.name?.charAt(0)?.toUpperCase()||"U"}),(0,s.jsxs)("div",{className:"hidden lg:flex flex-col items-start min-w-0 max-w-[140px]",children:[(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground leading-tight truncate w-full",children:O?.name||"Account"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground leading-tight truncate w-full",children:B?.name||""})]}),(0,s.jsx)("svg",{className:`hidden lg:block w-4 h-4 min-w-[16px] text-muted-foreground transition-transform duration-300 ${M?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),M&&(0,s.jsxs)("div",{className:"absolute right-0 mt-3 w-72 bg-popover rounded-2xl shadow-2xl border border-border overflow-hidden z-50 animate-slideIn",children:[(0,s.jsx)("div",{className:"bg-gradient-to-br from-brand-50 via-brand-100 to-brand-100 dark:from-gray-800 dark:via-gray-700 dark:to-gray-700 px-5 py-4 border-b border-brand-200 dark:border-gray-600",children:(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-gradient-to-br from-brand-500 to-brand-secondary dark:from-gray-600 dark:to-gray-500 rounded-full flex items-center justify-center text-white dark:text-gray-900 font-bold text-lg shadow-lg ring-4 ring-white dark:ring-gray-700",children:O?.name?.charAt(0)?.toUpperCase()||"U"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("h3",{className:"text-sm font-bold text-foreground truncate",children:O?.name||"User Account"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground truncate bg-background/60 rounded-full px-2 py-0.5 mt-1 inline-block",children:B?.name||"Organization"})]})]})}),(0,s.jsx)("div",{className:"py-2",children:(0,s.jsxs)(u(),{href:"/profile",className:"flex items-center space-x-3 px-5 py-3 text-sm text-foreground hover:bg-accent transition-all duration-200 group",onClick:()=>P(!1),children:[(0,s.jsx)("div",{className:"w-9 h-9 bg-muted rounded-lg flex items-center justify-center group-hover:bg-primary/10 group-hover:scale-110 transition-all duration-200",children:(0,s.jsx)("svg",{className:"w-5 h-5 text-muted-foreground group-hover:text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:"My Profile"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"View and edit your profile"})]})]})}),(0,s.jsx)("div",{className:"border-t border-border pt-2 pb-2",children:(0,s.jsxs)("button",{onClick:()=>{U(),P(!1),F.push("/accounts/multi-org-login")},className:"flex items-center space-x-3 px-5 py-3 text-sm w-full hover:bg-red-50 transition-all duration-200 group",children:[(0,s.jsx)("div",{className:"w-9 h-9 bg-red-50 rounded-lg flex items-center justify-center group-hover:bg-red-100 group-hover:scale-110 transition-all duration-200",children:(0,s.jsx)("svg",{className:"w-5 h-5 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}),(0,s.jsxs)("div",{className:"flex-1 text-left",children:[(0,s.jsx)("span",{className:"font-medium text-red-600",children:"Sign Out"}),(0,s.jsx)("p",{className:"text-xs text-red-500",children:"Logout from your account"})]})]})})]})]})}):(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)(u(),{href:"/accounts/multi-org-login",className:"text-foreground hover:text-primary px-4 py-2 text-sm font-medium transition-colors duration-200",children:"Sign In"}),(0,s.jsx)(u(),{href:"/accounts/multi-org-login",className:"bg-gradient-orange-pink hover:opacity-90 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",children:"Get Started"})]})})]}),(0,s.jsx)("div",{className:"lg:hidden flex items-center gap-2",children:!R&&(0,s.jsx)(s.Fragment,{children:W?(0,s.jsx)("button",{onClick:ed,className:"p-1 rounded-lg transition-colors duration-200 relative z-50","aria-label":"Toggle mobile menu",children:(0,s.jsx)("div",{className:"w-8 h-8 bg-brand-500 rounded-full flex items-center justify-center text-white dark:text-gray-900 text-sm font-semibold shadow-md",children:O?.name?.charAt(0)?.toUpperCase()||"U"})}):(0,s.jsx)("button",{onClick:ed,className:"text-foreground hover:text-primary p-2 rounded-lg transition-colors duration-200 relative z-50","aria-label":"Open menu",children:(0,s.jsx)(b.A,{size:22})})})})]})]}),c&&(0,s.jsxs)("div",{className:"fixed inset-0 z-[100] lg:hidden",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm mobile-drawer-backdrop",onClick:ec}),(0,s.jsxs)("div",{className:"absolute top-0 right-0 bottom-0 w-[300px] max-w-[85vw] bg-background border-l border-border shadow-2xl flex flex-col mobile-drawer-panel",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[(0,s.jsx)(x.Logo,{className:"h-8 w-auto"}),(0,s.jsx)("button",{onClick:ec,className:"p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors","aria-label":"Close menu",children:(0,s.jsx)(j.A,{size:20})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[!R&&W&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-3 py-3 mb-4 rounded-xl bg-accent/50",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-gradient-to-br from-brand-500 to-brand-secondary dark:from-gray-600 dark:to-gray-500 rounded-full flex items-center justify-center text-white dark:text-gray-900 text-sm font-bold shadow-md",children:O?.name?.charAt(0)?.toUpperCase()||"U"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-sm font-semibold text-foreground truncate",children:O?.name||"User"}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:B?.name||"Organization"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[(0,s.jsxs)(u(),{href:"/billing",onClick:ec,className:"flex flex-col items-center gap-1 py-2.5 px-2 rounded-xl bg-accent/50 hover:bg-accent transition-colors",children:[(0,s.jsx)(g.A,{size:18,className:"text-brand-600 dark:text-brand-400"}),(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:Z?"...":`${Math.round(Y??0).toLocaleStr
1ing()} cr`})]}),(0,s.jsxs)("button",{onClick:()=>{ec(),F.push("/agent-hub")},className:"flex flex-col items-center gap-1 py-2.5 px-2 rounded-xl bg-accent/50 hover:bg-accent transition-colors relative",children:[(0,s.jsx)(f.A,{size:18,className:"text-blue-500"}),(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Runs"}),X.running>0&&(0,s.jsx)("span",{className:"absolute top-1.5 right-2 min-w-[16px] h-[16px] flex items-center justify-center bg-blue-500 text-white text-[9px] font-bold rounded-full px-0.5",children:X.running>99?"99+":X.running})]}),(0,s.jsxs)("button",{onClick:()=>{er(!et),ec()},className:"flex flex-col items-center gap-1 py-2.5 px-2 rounded-xl bg-accent/50 hover:bg-accent transition-colors relative",children:[(0,s.jsx)(p.A,{size:18,className:"text-amber-500"}),(0,s.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Alerts"}),G.length>0&&(0,s.jsx)("span",{className:"absolute top-1.5 right-2 min-w-[16px] h-[16px] flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full px-0.5",children:G.length>99?"99+":G.length})]})]}),eo&&(0,s.jsxs)("button",{onClick:()=>{F.push("/home"),ec()},className:"w-full flex items-center gap-3 px-4 py-3 mb-2 bg-gradient-to-r from-brand-500 to-brand-secondary text-white rounded-xl font-semibold text-sm shadow-md",children:[(0,s.jsx)(v.A,{size:18}),"Go to Dashboard"]}),(0,s.jsx)("hr",{className:"my-3 border-border"})]}),(0,s.jsx)("nav",{className:"space-y-1",children:[{label:"Integrations",href:"/integrations",icon:N.A},{label:"Pricing",href:"/pricing",icon:y.A},{label:"Templates",href:"/marketplace",icon:N.A},{label:"Blog",href:"/blog",icon:w.A},{label:"White Papers",href:"/whitepapers",icon:w.A},{label:"Docs",href:"/docs",icon:w.A}].map(e=>{let t=e.icon;return(0,s.jsxs)(u(),{href:e.href,onClick:ec,className:"flex items-center gap-3 px-4 py-3 rounded-xl text-foreground hover:bg-accent transition-colors",children:[(0,s.jsx)(t,{size:18,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:e.label})]},e.href)})}),W&&!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("hr",{className:"my-3 border-border"}),(0,s.jsx)("nav",{className:"space-y-1",children:(0,s.jsxs)(u(),{href:"/home",onClick:ec,className:"flex items-center gap-3 px-4 py-3 rounded-xl text-foreground hover:bg-accent transition-colors",children:[(0,s.jsx)(v.A,{size:18,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Go to Dashboard"})]})})]}),W&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("hr",{className:"my-3 border-border"}),(0,s.jsxs)("nav",{className:"space-y-1",children:[(0,s.jsxs)(u(),{href:"/profile",onClick:ec,className:"flex items-center gap-3 px-4 py-3 rounded-xl text-foreground hover:bg-accent transition-colors",children:[(0,s.jsx)(k.A,{size:18,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Profile"})]}),I("organization",30)&&(0,s.jsxs)(u(),{href:"/organization-management",onClick:ec,className:"flex items-center gap-3 px-4 py-3 rounded-xl text-foreground hover:bg-accent transition-colors",children:[(0,s.jsx)(C.A,{size:18,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Organization"})]})]})]})]}),(0,s.jsxs)("div",{className:"px-4 py-4 border-t border-border",children:[!R&&(0,s.jsx)(s.Fragment,{children:W?(0,s.jsxs)("button",{onClick:()=>{U(),ec()},className:"w-full flex items-center justify-center gap-2 px-4 py-3 text-red-600 hover:bg-red-50 dark:hover:bg-red-950/20 rounded-xl transition-colors text-sm font-medium",children:[(0,s.jsx)(S.A,{size:18}),"Sign Out"]}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(u(),{href:"/accounts/multi-org-login",onClick:ec,className:"block w-full text-center px-4 py-3 text-foreground hover:bg-accent rounded-xl text-sm font-medium transition-colors",children:"Sign In"}),(0,s.jsx)(u(),{href:"/accounts/multi-org-login",onClick:ec,className:"block w-full text-center px-4 py-3 bg-gradient-orange-pink text-white rounded-xl text-sm font-semibold shadow-md",children:"Get Started"})]})}),(0,s.jsx)("div",{className:"mt-3 flex justify-center",children:(0,s.jsx)(h.U,{})})]})]})]}),M&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 hidden lg:block",onClick:()=>P(!1)}),(0,s.jsx)("style",{dangerouslySetInnerHTML:{__html:` 2 header { 3 left: ${t?V?l.V4.COLLAPSED:l.V4.DESKTOP:"0"}; 4 right: ${r&&q?K():"0"}; 5 transition: left 0.3s ease-in-out, right 0s !important; 6 } 7 @media (max-width: 1023px) { 8 header { left: 0 !important; right: 0 !important; } 9 } 10 `}})]})]})}},284150:(e,t,r)=>{r.r(t),r.d(t,{ToastProvider:()=>o,useToastContext:()=>d});var s=r(695155),n=r(212115),a=r(925328),i=r(297513);let l=(0,n.createContext)(void 0);function o({children:e}){let t=(0,a.d)();return(0,s.jsxs)(l.Provider,{value:t,children:[e,(0,s.jsx)(i.A,{})]})}function d(){let e=(0,n.useContext)(l);if(void 0===e)throw Error("useToastContext must be used within a ToastProvider");return e}},297513:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(695155);r(212115);var n=r(477377),a=r(284150);function i(){let{toasts:e,hideToast:t}=(0,a.useToastContext)();return(0,s.jsx)("div",{className:"fixed top-4 right-4 z-50 flex flex-col space-y-2 w-full max-w-sm",children:e.map(e=>(0,s.jsx)(n.A,{toast:e,onClose:t},e.id))})}},318635:(e,t,r)=>{r.d(t,{A:()=>v});var s=r(695155),n=r(212115),a=r(668822),i=r(441585),l=r(413545),o=r(996035),d=r(833210),c=r(80723),u=r(755243),m=r(61767),x=r(589363),h=r(102059),g=r(396429);function f({field:e,value:t,onChange:r}){let n="w-full px-2 py-1.5 text-sm border border-border rounded bg-background text-foreground focus:outline-none focus:ring-1 focus:ring-primary";switch(e.type){case"select":return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-muted-foreground mb-0.5",children:e.label}),(0,s.jsxs)("select",{className:n,value:t,onChange:e=>
10r(e.target.value),required:e.required,children:[(0,s.jsx)("option",{value:"",children:"Select..."}),e.options?.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]})]});case"boolean":return(0,s.jsxs)("label",{className:"flex items-center gap-2 text-sm text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:!!t,onChange:e=>r(e.target.checked),className:"rounded border-border"}),e.label]});case"number":return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-muted-foreground mb-0.5",children:e.label}),(0,s.jsx)("input",{type:"number",className:n,value:t,onChange:e=>r(Number(e.target.value)),placeholder:e.placeholder,required:e.required})]});default:return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs text-muted-foreground mb-0.5",children:e.label}),(0,s.jsx)("input",{type:"text",className:n,value:t,onChange:e=>r(e.target.value),placeholder:e.placeholder,required:e.required})]})}}function p({notification:e}){let{dismissNotification:t,respondToNotification:r}
10=(0,h.E)(),[c,u]=(0,n.useState)(()=>{let t={};return e.formFields?.forEach(e=>{void 0!==e.defaultValue&&(t[e.name]=e.defaultValue)}),t}),[m,x]=(0,n.useState)(!1),g="action"===e.type,p=async t=>{t.preventDefault(),x(!0),await r(e.id,c)};return(0,s.jsx)("div",{className:"px-4 py-3 hover:bg-accent/50 transition-colors border-b border-border/50 last:border-0",children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:"mt-0.5 shrink-0",children:(()=>{switch(e.type){case"info":return(0,s.jsx)(a.A,{size:14,className:"text-blue-500"});case"warning":return(0,s.jsx)(i.A,{size:14,className:"text-yellow-500"});case"error":return(0,s.jsx)(l.A,{size:14,className:"text-red-500"});case"action":return(0,s.jsx)(o.A,{size:14,className:"text-purple-500"})}})()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-foreground truncate",children:e.title}),(0,s.jsx)("button",{onClick:()=>t(e.id),className:"text-muted-foreground hover:text-foreground p-0.5 rounded shrink-0",children:(0,s.jsx)(d.A,{size:12})})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 whitespace-pre-line",children:e.message}),g&&e.formFields&&(0,s.jsxs)("form",{onSubmit:p,className:"mt-2 space-y-2",children:[e.formFields.map(e=>(0,s.jsx)(f,{field:e,value:c[e.name]??"",onChange:t=>u(r=>({...r,[e.name]:t}))},e.name)),(0,s.jsx)("button",{type:"submit",disabled:m,className:"w-full px-3 py-1.5 text-xs font-medium text-white bg-primary hover:bg-primary/90 disabled:opacity-50 rounded transition-colors",children:m?"Sending...":"Submit"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.source}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:(()=>{let t=Math.floor((Date.now()-new Date(e.createdAt).getTime())/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;let r=Math.floor(t/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`})()})]})]})]})})}let b={agent:{label:"Agent Replies",description:"When an agent responds to a message on a channel"},channel:{label:"Channel Events",description:"Channel activation, deactivation, and errors"},"baileys-whatsapp":{label:"WhatsApp",description:"WhatsApp channel events and messages"},connector:{label:"Connector Messages",description:"Webhook and connector received messages"},datalake:{label:"Data Lake",description:"Data lake sync and update events"},workflow:{label:"Workflows",description:"Workflow execution completions and errors"},system:{label:"System",description:"System-level notifications and alerts"}};function j({onBack:e}){let{baseUrl:t}=(0,g.ed)(),[r,a]=(0,n.useState)({}
10),[i,l]=(0,n.useState)({}),[o,d]=(0,n.useState)(!0),[m,x]=(0,n.useState)(!1),[h,f]=(0,n.useState)(!1);(0,n.useEffect)(()=>{t&&fetch(`${t}/notification-preferences`,{credentials:"include"}).then(e=>e.json()).then(e=>{a(e.preferences||{}),l(e.defaults||{})}).catch(console.error).finally(()=>d(!1))},[t]);let p=async()=>{if(t){x(!0);try{await fetch(`${t}/notification-preferences`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({preferences:r})}),f(!0)}catch(e){console.error("Failed to save preferences:",e)}finally{x(!1)}}},j=Object.keys(b);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{onClick:e,className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",children:(0,s.jsx)(c.A,{size:14})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Notification Settings"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[h&&(0,s.jsx)("span",{className:"text-xs text-green-600",children:"Saved"}),(0,s.jsxs)("button",{onClick:p,disabled:m,className:"inline-flex items-center gap-1 px-2.5 py-1 bg-primary text-primary-foreground rounded text-xs font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors",children:[(0,s.jsx)(u.A,{size:12}),m?"...":"Save"]})]})]}),(0,s.jsx)("div",{className:"max-h-96 overflow-y-auto",children:o?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/30",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Source"}),(0,s.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Toast"})]})}),j.map(e=>{let t=b[e],n=r[e]?.toast??i[e]?.toast??!0;return(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border/50 last:border-0 hover:bg-accent/30 transition-colors",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-sm font-medium text-foreground",children:t.label}),(0,s.jsx)("div",{className:"text-[11px] text-muted-foreground",children:t.description})]}),(0,s.jsx)("button",{onClick:()=>{a(t=>({...t,[e]:{toast:!(t[e]?.toast??i[e]?.toast??!0)}})),f(!1)},className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${n?"bg-primary":"bg-muted-foreground/30"}`,children:(0,s.jsx)("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform ${n?"translate-x-4":"translate-x-0"}`})})]},e)})]})})]})}function v(){let{notifications:e,dismissNotification:t}=(0,h.E)(),[r,a]=(0,n.useState)(!1);return(0,s.jsx)("div",{className:"absolute right-0 mt-2 w-96 bg-popover rounded-xl shadow-2xl border border-border overflow-hidden z-50 animate-slideIn",children:r?(0,s.jsx)(j,{onBack:()=>a(!1)}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.A,{size:14,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Notifications"}),e.length>0&&(0,s.jsx)("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full font-medium",children:e.length})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[e.length>0&&(0,s.jsx)("button",{onClick:()=>e.forEach(e=>t(e.id)),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Clear all"}),(0,s.jsx)("button",{onClick:()=>a(!0),className:"text-muted-foreground hover:text-foreground p-1 rounded transition-colors",title:"Notification settings",children:(0,s.jsx)(x.A,{size:14})})]})]}),(0,s.jsx)("div",{className:"max-h-96 overflow-y-auto",children:0===e.length?(0,s.jsxs)("div",{className:"px-4 py-8 text-center",children:[(0,s.jsx)(m.A,{size:24,className:"mx-auto text-muted-foreground
10/40 mb-2"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No notifications"})]}):e.map(e=>(0,s.jsx)(p,{notification:e},e.id))})]})})}},396429:(e,t,r)=>{r.d(t,{ed:()=>l,g3:()=>i});var s=r(695155),n=r(212115);let a=n.createContext({agentBaseUrl:"",authBaseUrl:"",baseUrl:""}),i=({children:e,agentBaseUrl:t,authBaseUrl:r,baseUrl:n})=>(0,s.jsx)(a.Provider,{value:{agentBaseUrl:t,authBaseUrl:r,baseUrl:n},children:e}),l=()=>n.useContext(a)},476666:(e,t,r)=>{r.d(t,{M:()=>o,u:()=>l});var s=r(695155),n=r(212115),a=r(396429);let i=(0,n.createContext)(void 0);function l({children:e}){let{baseUrl:t}=(0,a.ed)(),r=(0,n.useRef)(null),l=(0,n.useRef)(new Map),o=(0,n.useCallback)((e,t)=>{let r,s=l.current.get(e);if(s&&0!==s.size){try{r=JSON.parse(t)}catch{r=t}s.forEach(t=>{try{t(r)}catch(t){console.error(`[EventStream] handler error for ${e}:`,t)}})}},[]),d=(0,n.useCallback)((e,t)=>(l.current.has(e)||l.current.set(e,new Set),l.current.get(e).add(t),()=>{l.current.get(e)?.delete(t)}),[]);return(0,n.useEffect)(()=>{let e;if(!t)return;let s=!1,n=0;async function a(){if(s)return;r.current&&(r.current.abort(),r.current=null);let i=new AbortController;r.current=i;try{let r=`${t}/events/stream`,l=await fetch(r,{credentials:"include",signal:i.signal,headers:{Accept:"text/event-stream"},cache:"no-store"});if(!l.ok)throw Error(`Stream HTTP ${l.status}`);n=0;let d=l.body.getReader(),c=new TextDecoder,u={event:"",data:""};for(;;){let{done:e,value:t}=await d.read();if(e)break;let r=c.decode(t,{stream:!0});for(let e of function(e,t){let r=[];for(let s of e.split("\n"))!s.startsWith(":")&&(s.startsWith("event: ")?t.event=s.slice(7).trim():s.startsWith("data: ")?t.data=s.slice(6):""===s&&t.data&&(r.push({event:t.event||"message",data:t.data}),t.event="",t.data=""));return r}(r,u))o(e.event,e.data)}s||(e=setTimeout(a,1e3))}catch(t){if(t?.name==="AbortError")return;if(r.current=null,!s){let t=Math.min(5e3*2**n,6e4);n++,e=setTimeout(a,t)}}}let i=setTimeout(a,500);return()=>{s=!0,clearTimeout(i),clearTimeout(e),r.current&&(r.current.abort(),r.current=null)}},[t,o]),(0,s.jsx)(i.Provider,{value:{subscribe:d},children:e})}function o(){let e=(0,n.useContext)(i);if(!e)throw Error("useEventStream must be used within an EventStreamProvider");return e}},477377:(e,t,r)=>{r.d(t,{A:()=>l});var s=r(695155),n=r(212115),a=r(447650),i=r(833210);function l({toast:e,onClose:t}){let[r,l]=(0,n.useState)(!1),[o,d]=(0,n.useState)(!1);if((0,n.useEffect)(()=>(d(!0),()=>d(!1)),[]),(0,n.useEffect)(()=>{if(!o)return;l(!0);let r=setTimeout(()=>{l(!1),setTimeout(()=>t(e.id),300)},e.duration);return()=>clearTimeout(r)},[e,t,o]),!o)return null;let c=(0,s.jsxs)("div",{className:` 11 fixed top-4 right-4 12 z-[9999] 13 flex items-center 14 px-4 py-3 15 rounded-lg 16 shadow-lg 17 text-white 18 transform transition-all duration-300 ease-in-out 19 ${(e=>{switch(e){case"success":return"bg-green-500";case"error":return"bg-red-500";case"warning":case"info":return"bg-brand-500";default:return"bg-gray-700"}})(e.type)} 20 ${r?"translate-x-0 opacity-100 scale-100":"translate-x-full opacity-0 scale-95"} 21 max-w-sm w-full 22 pointer-events-auto 23 `,children:[(0,s.jsx)("div",{className:"flex-1 text-sm font-medium",children:e.message}),(0,s.jsx)("button",{onClick:()=>{l(!1),setTimeout(()=>t(e.id),300)},className:"ml-4 text-white hover:text-gray-200 focus:outline-none focus:ring-2 focus:ring-white focus:ring-opacity-50 rounded p-1 transition-colors","aria-label":"Close notification",children:(0,s.jsx)(i.A,{size:16})})]});return(0,a.createPortal)(c,document.body)}},668354:(e,t,r)=>{r.d(t,{S1:()=>i,UY:()=>o,V4:()=>a,gK:()=>d});var s=r(695155),n=r(212115);let a={COLLAPSED:"56px",MOBILE:"280px",DESKTOP:"255px"},i={DEFAULT:320,MIN:200,MAX:600},l=(0,n.createContext)({isSidebarVisible:!1,isSidebarCollapsed:!1,toggleSidebarVisibility:()=>{},toggleSidebarCollapse:()=>{},setSidebarVisible:()=>{},setSidebarCollapsed:()=>{},isMobile:!1,getSidebarWidth:()=>a.DESKTOP,isRightSidebarVisible:!1,rightSidebarWidth:i.DEFAULT,toggleRightSidebarVisibility:()=>{},setRightSidebarVisible:()=>{},setRightSidebarWidth:()=>{},getRightSidebarWidth:()=>`${i.DEFAULT}px`}),o=({children:e})=>
23{let[t,r]=(0,n.useState)(!0),[o,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)(!1),[m,x]=(0,n.useState)(!1),[h,g]=(0,n.useState)(i.DEFAULT);return(0,n.useEffect)(()=>{let e=()=>{let e=window.innerWidth<1024;u(e),e?(r(!1),d(!1)):r(!0)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,s.jsx)(l.Provider,{value:{isSidebarVisible:t,isSidebarCollapsed:o,toggleSidebarVisibility:()=>{r(!t)},toggleSidebarCollapse:()=>{window.innerWidth<1024||d(e=>!e)},setSidebarVisible:e=>{r(e)},setSidebarCollapsed:e=>{window.innerWidth<1024?d(!1):d(e)},isMobile:c,getSidebarWidth:()=>o?a.COLLAPSED:c?a.MOBILE:a.DESKTOP,isRightSidebarVisible:m,rightSidebarWidth:h,toggleRightSidebarVisibility:()=>{x(!m)},setRightSidebarVisible:e=>{x(e)},setRightSidebarWidth:e=>{g(Math.max(i.MIN,Math.min(i.MAX,e)))},getRightSidebarWidth:()=>`${h}px`},children:e})},d=()=>(0,n.useContext)(l)},745222:(e,t,r)=>{r.d(t,{g:()=>d,z:()=>c});var s=r(695155),n=r(212115),a=r(396429),i=r(476666);let l="agent_run_visited",o=(0,n.createContext)(void 0);function d({children:e}){let[t,r]=(0,n.useState)([]),[d,c]=(0,n.useState)({total:0,running:0,completed:0,failed:0}),[u,m]=(0,n.useState)(!1),{baseUrl:x}=(0,a.ed)(),{subscribe:h}=(0,i.M)(),g=(0,n.useRef)(new Set((()=>{try{return JSON.parse(localStorage.getItem(l)||"[]")}catch{return[]}})())),f=(0,n.useCallback)(async e=>{if(x){m(!0);try{let t=new URLSearchParams;e?.status&&t.set("status",e.status),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let s=t.toString(),n=await fetch(`${x}/agent-runs${s?`?${s}`:""}`,{credentials:"include"});if(n.ok){let e=await n.json();r(e.runs||[])}}catch(e){console.error("Failed to fetch agent runs:",e)}finally{m(!1)}}},[x]),p=(0,n.useCallback)(async()=>{if(x)try{let e=await fetch(`${x}/agent-runs/stats`,{credentials:"include"});if(e.ok){let t=await e.json();c(t)}}catch(e){console.error("Failed to fetch agent run stats:",e)}},[x]),b=(0,n.useCallback)(async e=>{if(!x)return!1;try{if((await fetch(`${x}/agent-runs/${e}/cancel`,{method:"POST",credentials:"include"})).ok)return r(t=>t.map(t=>t.id===e?{...t,status:"cancelled",completed_at:new Date().toISOString()}:t)),!0;return!1}catch(e){return console.error("Failed to cancel run:",e),!1}},[x]),j=(0,n.useCallback)(async e=>{if(!x)return!1;try{if((await fetch(`${x}/agent-runs/${e}`,{method:"DELETE",credentials:"include"})).ok)return r(t=>t.filter(t=>t.id!==e)),!0;return!1}catch(e){return console.error("Failed to remove run:",e),!1}},[x]),v=(0,n.useCallback)(async()=>{if(!x)return!1;try{if((await fetch(`${x}/agent-runs`,{method:"DELETE",credentials:"include"})).ok)return r(e=>e.filter(e=>["running","waiting","pending"].includes(e.status))),p(),!0;return!1}catch(e){return console.error("Failed to clear completed runs:",e),!1}},[x,p]),N=(0,n.useCallback)(e=>{g.current.add(e);try{let e=Array.from(g.current);if(e.length>100){let t=e.slice(e.length-100);g.current=new Set(t),localStorage.setItem(l,JSON.stringify(t))}else localStorage.setItem(l,JSON.stringify(e))}catch{}r(t=>t.filter(t=>!(t.id===e&&["completed","failed","cancelled"].includes(t.status))))},[]);(0,n.useEffect)(()=>{if(!x)return;p(),f({limit:10});let e=setTimeout(()=>{p()},2e3);return()=>clearTimeout(e)},[x,p,f]);let y=(0,n.useRef)(p);return y.current=p,(0,n.useEffect)(()=>h("agent_run",e=>{let{type:t}=e,s=e.run,n=s?.id||e.runId;if(n)switch(t){case"run_created":r(e=>e.some(e=>e.id===n)?e:[s,...e]),c(e=>({...e,total:e.total+1,running:e.running+1}));break;case"run_status":r(t=>t.map(t=>t.id===n?{...t,status:e.status||t.status,progress:e.progress??t.progress,last_activity:e.last_activity||t.last_activity,result_summary:e.result_summary||t.result_summary,result_preview:e.result_preview||t.result_preview}:t));break;case"run_activity":r(t=>t.map(t=>t.id===n?{...t,activity_log:e.latestActivity?[...t.activity_log||[],e.latestActivity]:t.activity_log,last_activity:e.latestActivity?.ts||t.last_activity}:t));break;case"run_completed":case"run_failed":g.current.has(n)?r(e=>e.filter(e=>e.id!==n)):s&&r(e=>e.map(e=>e.id===n?{...e,...s}:e)),y.current();break;case"run_cancelled":r(e=>e.map(e=>e.id===n?{...e,status:"cancelled",completed_at:new Date().toISOString()}:e)),y.current()}}),[h]),(0,s.jsx)(o.Provider,{value:{runs:t,stats:d,loading:u,fetchRuns:f,fetchStats:p,cancelRun:b,removeRun:j,clearCompleted:v,markRunVisited:N},children:e})}function c(){let e=(0,n.useContext)(o);if(!e)throw Error("useAgentRuns must be used within an AgentRunProvider");return e}},779240:(e,t,r)=>{r.d(t,{Ay:()=>u});var s=r(695155),n=r(212115),a=r(598500),i=r.n(a),l=r(573321),o=r(521362),d=r(566614),c=r(760285);let u=({items:e,children:t,separator:r=(0,s.jsx)(o.A,{size:14,className:"text-muted-foreground sm:w-4 sm:h-4"}),showHome:a=!0,homeHref:u="/",homeLabel:m="Home",homeIcon:x=(0,s.jsx)(d.A,{size:14,className:"sm:w-4 sm:h-4"}),className:h="",itemClassName:g="",activeClassName:f="text-sm sm:text-lg font-semibold text-foreground",separatorClassName:p="mx-1 sm:mx-2",autoGenerate:b=!1,pathLabels:j={}})=>
23{let v=(0,l.usePathname)(),[N,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=()=>y(window.innerWidth<640);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let w=[];if(b){let e,t;e=(v??"").split("/").filter(Boolean),t=[],e.forEach((r,s)=>{let n="/"+e.slice(0,s+1).join("/"),a=s===e.length-1,i=j[n]||j[r]||r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");t.push({label:i,href:a?void 0:n,isActive:a})}),w=t}else e&&(w=e.map(e=>({...e,isActive:void 0!==e.isActive?e.isActive:e.href===v})));let k=(e=>{if(!N||e.length<=3)return e;let t=e[0],r=e[e.length-1],n=e.length>1?e[e.length-2]:null,a=[t];return e.length>3&&a.push({label:(0,s.jsx)(c.A,{size:14}),isActive:!1}),n&&e.length>2&&a.push(n),a.push(r),a})(w),C=()=>{let e=v===u,t=`inline-flex items-center gap-1 transition-colors duration-200 ${g}`,r=e?`${t} ${f}`:`${t} text-muted-foreground hover:text-foreground hover:underline`;return e?(0,s.jsxs)("span",{className:r,"aria-current":"page",children:[x&&(0,s.jsx)("span",{className:"flex-shrink-0",children:x}),(0,s.jsx)("span",{className:"hidden sm:inline",children:m})]}):(0,s.jsx)(i(),{href:u,className:r,children:x&&(0,s.jsx)("span",{className:"flex-shrink-0 mt-1",children:x})})},S=`flex items-center text-xs sm:text-sm overflow-x-auto scrollbar-hide ${h}`;return!t||e||b?(0,s.jsx)("nav",{"aria-label":"Breadcrumb",className:S,children:(0,s.jsxs)("ol",{className:"flex items-center space-x-1 min-w-max",children:[a&&k.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("li",{className:"flex-shrink-0",children:C()}),(0,s.jsx)("li",{className:`${p} flex-shrink-0`,children:r})]}),k.map((e,t)=>{let a,l,o,d;return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("li",{className:"flex-shrink-0",children:(a=e.isActive,l=`inline-flex items-center gap-1 transition-colors duration-200 ${g}`,o=a?`${l} ${f}`:`${l} text-muted-foreground hover:text-foreground`,d=(0,s.jsxs)(s.Fragment,{children:[e.icon&&(0,s.jsx)("span",{className:"flex-shrink-0",children:e.icon}),(0,s.jsx)("span",{className:"truncate max-w-[120px] sm:max-w-none text-sm font-medium",children:e.label})]}),a||!e.href?(0,s.jsx)("span",{className:o,"aria-current":"page",style:{},children:d},t):e.onClick?(0,s.jsx)("button",{onClick:e.onClick,className:`${o} cursor-pointer hover:underline`,children:d},t):(0,s.jsx)(i(),{href:e.href,className:`${o} hover:underline`,children:d},t))}),t<k.length-1&&(0,s.jsx)("li",{className:`${p} flex-shrink-0`,children:r})]},t)})]})}):(0,s.jsx)("nav",{"aria-label":"Breadcrumb",className:S,children:(0,s.jsxs)("ol",{className:"flex items-center space-x-1 min-w-max",children:[a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("li",{className:"flex-shrink-0",children:C()}),n.Children.count(t)>0&&(0,s.jsx)("li",{className:`${p} flex-shrink-0`,children:r})]}),n.Children.map(t,(e,a)=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("li",{className:"flex-shrink-0",children:e}),a<n.Children.count(t)-1&&(0,s.jsx)("li",{className:`${p} flex-shrink-0`,children:r})]},a))]})})}},817894:(e,t,r)=>{r.d(t,{A:()=>m});var s=r(695155);r(212115);var n=r(598500),a=r.n(n),i=r(22164),l=r(93219),o=r(124371),d=r(745222);let c={running:"bg-blue-500 animate-pulse",waiting:"bg-yellow-500",pending:"bg-gray-400",completed:"bg-green-500",failed:"bg-red-500",cancelled:"bg-muted-foreground"};function u({run:e,onVisit:t}){let r=["running","waiting","pending"].includes(e.status),n=e.activity_log?.[e.activity_log.length-1],l=function(e){if(!e.session_id||!e.expert_id)return null;let t=isNaN(Number(e.expert_id.split("_")[0]));return`/chat/${e.expert_id}?sessionId=${e.session_id}${t?"&source=internal":""}`}(e);return(0,s.jsx)("div",{className:"px-4 py-3 hover:bg-accent/50 transition-colors border-b border-border/50 last:border-0",children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:"mt-1 shrink-0",children:(0,s.jsx)("span",{className:`block w-2 h-2 rounded-full ${c[e.status]||c.cancelled}`})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-foreground truncate",children:e.agent_name||"Agent"}),l&&(0,s.jsx)(a(),{href:l,onClick:()=>t(e.id),className:"text-muted-foreground hover:text-foreground p-0.5 rounded shrink-0",title:"View conversation",children:(0,s.jsx)(i.A,{size:12})})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:n?.summary||e.task_description||e.status}),r&&e.progress>0&&(0,s.jsx)("div",{className:"mt-1.5 w-full h-1 bg-muted rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-blue-500 transition-all duration-500",style:{width:`${Math.max(e.progress,5)}%`}})}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground capitalize",children:e.trigger_type}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:function(e){if(!e)return"";let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}(r?e.started_at:e.completed_at||e.started_at)})]})]})]})})}function m(){let{runs:e,stats:t,clearCompleted:r,markRunVisited:n}=(0,d.z)(),i=e.slice(0,8),c=e.some(e=>!["running","waiting","pending"].includes(e.status));return(0,s.jsxs)("div",{className:"absolute right-0 mt-2 w-96 bg-popover rounded-xl shadow-2xl border border-border overflow-hidden z-50 animate-slideIn",children:[(0,s.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(l.A,{size:14,className:"text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Agent Runs"}),t.running>
230&&(0,s.jsxs)("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-1.5 py-0.5 rounded-full font-medium",children:[t.running," running"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[c&&(0,s.jsx)("button",{onClick:()=>r(),className:"text-xs text-muted-foreground hover:text-foreground px-1.5 py-0.5 rounded transition-colors",title:"Clear completed runs",children:"Clear"}),(0,s.jsx)(a(),{href:"/agent-hub",className:"text-muted-foreground hover:text-foreground p-1 rounded transition-colors",title:"Open Agent Hub",children:(0,s.jsx)(o.A,{size:14})})]})]}),(0,s.jsx)("div",{className:"max-h-96 overflow-y-auto",children:0===i.length?(0,s.jsxs)("div",{className:"px-4 py-8 text-center",children:[(0,s.jsx)(l.A,{size:24,className:"mx-auto text-muted-foreground/40 mb-2"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No agent runs"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Runs appear here when you chat with agents"})]}):i.map(e=>(0,s.jsx)(u,{run:e,onVisit:n},e.id))}),e.length>8&&(0,s.jsx)("div",{className:"px-4 py-2 border-t border-border text-center",children:(0,s.jsxs)(a(),{href:"/agent-hub",className:"text-xs text-primary hover:underline font-medium",children:["View all ",t.total," runs"]})})]})}},925328:(e,t,r)=>{r.d(t,{d:()=>n});var s=r(212115);function n(){let[e,t]=(0,s.useState)([]),r=(0,s.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]);return{toasts:e,showToast:(0,s.useCallback)(e=>{let s=Math.random().toString(36).substring(2,9),n={id:s,message:e.message,type:e.type,duration:e.duration||5e3};t(e=>[...e,n]),setTimeout(()=>{r(s)},n.duration)},[r]),hideToast:r}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.