PageSourceSearch

https://uptick.ai/_next/static/chunks/6279-dca7b08fa09339aa.js

js uptick.ai collected 2026-10-05 14:04:10 UTC 62,413 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6279],{93207:function(e,t,n){n.d(t,{B:function(){return ActivityTimeline}});var r=n(24043);n(85893);var a=n(67294);function ActivityTimeline(e){e.processedEvents;var t=e.isLoading,n=(0,r._)((0,a.useState)(t),2),s=(n[0],n[1]),i=(0,a.useRef)(t);return(0,a.useEffect)(function(){i.current&&!t?s(!1):!i.current&&t&&s(!0),i.current=t},[t]),null}n(89508),n(89681),n(98486),n(36316),n(52566),n(8971),n(64998),n(86540)},99908:function(e,t,n){n.d(t,{M:function(){return InputForm}});var r=n(11010),a=n(24043),s=n(248),i=n(97582),o=n(85893),l=n(67294),c=n(72253),u=n(47702),d=n(13204),h=l.forwardRef(function(e,t){var n=e.className,r=(0,u._)(e,["className"]);return(0,o.jsx)("textarea",(0,c._)({className:(0,d.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},r))});h.displayName="Textarea";var f=n(75283),m=n(13766),x=n(9194),p=n(41352),g=n(84617),b=n(36316),v=n(42841),y=n(64712);function InputForm(e){var t,n=e.onSubmit,c=e.isLoading,u=e.context,d=void 0===u?"homepage":u,w=(0,a._)((0,l.useState)(""),2),j=w[0],N=w[1],_=(0,a._)((0,l.useState)(!1),2),S=(_[0],_[1]),k=(0,a._)((0,l.useState)([]),2),C=k[0],A=k[1],M=(0,l.useRef)(null),I=(0,l.useRef)(null);(0,l.useEffect)(function(){var e=M.current;e&&(e.style.height="auto",e.style.height="".concat(e.scrollHeight,"px"))},[j]),(0,l.useEffect)(function(){M.current&&"homepage"===d&&M.current.focus()},[d]);var E=(t=(0,r._)(function(e){var t,n,r,a,o,l,c,u,d,h,f;return(0,i.Jh)(this,function(i){switch(i.label){case 0:if(0===(t=Array.from(e.target.files||[])).length)return[2];if(C.length+t.length>5)return y.Am.error("Maximum ".concat(5," files allowed"),{description:"You can only upload ".concat(5," files at a time.")}),[2];n=[],r=!0,a=!1,o=void 0,i.label=1;case 1:i.trys.push([1,8,9,10]),l=t[Symbol.iterator](),i.label=2;case 2:if(r=(c=l.next()).done)return[3,7];if((u=c.value).size>10485760)return y.Am.error('File "'.concat(u.name,'" is too large'),{description:"Maximum file size is 10MB. This file is ".concat((u.size/1024/1024).toFixed(2),"MB.")}),[3,6];i.label=3;case 3:var m;return i.trys.push([3,5,,6]),[4,(m=u,new Promise(function(e,t){var n=new FileReader;n.readAsDataURL(m),n.onload=function(){e(n.result.split(",")[1])},n.onerror=function(e){return t(e)}}))];case 4:return d=i.sent(),n.push({name:u.name,type:u.type,size:u.size,data:d,mimeType:u.type}),[3,6];case 5:return h=i.sent(),console.error("Failed to process file ".concat(u.name,":"),h),y.Am.error('Failed to process "'.concat(u.name,'"'),{description:"There was an error reading the file."}),[3,6];case 6:return r=!0,[3,2];case 7:return[3,10];case 8:return f=i.sent(),a=!0,o=f,[3,10];case 9:try{r||null==l.return||l.return()}finally{if(a)throw o}return[7];case 10:return n.length>0&&(A((0,s._)(C).concat((0,s._)(n))),y.Am.success("".concat(n.length," file(s) attached"),{description:"Files ready to send with your message."})),I.current&&(I.current.value=""),[2]}})}),function(e){return t.apply(this,arguments)}),removeAttachment=function(e){A(C.filter(function(t,n){return n!==e}))},handleSubmit=function(e){e.preventDefault(),j.trim()&&!c&&(n(j.trim(),C.length>0?C:void 0),N(""),A([]))},F="chat"===d?"Add more details, ask questions, or request changes...":"What goal would you like to achieve? e.g., Build a mobile app, Plan a marketing campaign, Learn a new skill...";return(0,o.jsx)("div",{className:"w-full",children:(0,o.jsxs)("form",{onSubmit:handleSubmit,className:"relative",children:[C.length>0&&(0,o.jsx)("div",{className:"mb-2 flex flex-wrap gap-2",children:C.map(function(e,t){var n,r=(n=e.mimeType).startsWith("image/")?f.Z:"application/pdf"===n?m.Z:x.Z;return(0,o.jsxs)("div",{className:"flex items-center gap-2 bg-emerald-50 border border-emerald-200 rounded-lg px-3 py-2 text-sm",children:[(0,o.jsx)(r,{className:"h-4 w-4 text-emerald-600"}),(0,o.jsx)("span",{className:"text-slate-700 max-w-[200px] truncate",children:e.name}),(0,o.jsxs)("span",{className:"text-slate-500 text-xs",children:["(",(e.size/1024).toFixed(1),"KB)"]}
1),(0,o.jsx)("button",{type:"button",onClick:function(){return removeAttachment(t)},className:"ml-1 text-slate-500 hover:text-red-600 transition-colors",children:(0,o.jsx)(p.Z,{className:"h-3 w-3"})})]},t)})}),(0,o.jsxs)("div",{className:"rounded-xl flex items-center gap-4 transition-all duration-200 ease-in-out",style:"homepage"===d?{padding:"1.1rem 1rem",border:"1px solid rgba(255, 255, 255, 0.15)",background:"rgba(255, 255, 255, 0.02)"}:{padding:"1.25rem 1.25rem",background:"#343640"},children:[(0,o.jsx)("input",{ref:I,type:"file",multiple:!0,accept:"image/*,application/pdf,text/*,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",onChange:E,className:"hidden",disabled:c}),(0,o.jsxs)("button",{type:"button",onClick:function(){var e;return null===(e=I.current)||void 0===e?void 0:e.click()},disabled:c||C.length>=5,className:"text-white hover:text-[#6464a1] relative disabled:opacity-50 disabled:cursor-not-allowed",title:"Attach files (images, PDFs, documents)",style:"homepage"===d?{width:"1rem",he
1ight:"1rem"}:{},children:[(0,o.jsx)(g.Z,{className:"homepage"===d?"w-4 h-4":"w-5 h-5"}),C.length>0&&(0,o.jsx)("span",{className:"absolute -top-1 -right-1 bg-blue-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:C.length})]}),(0,o.jsx)(h,{ref:M,value:j,onChange:function(e){return N(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),handleSubmit(e))},onFocus:function(){return S(!0)},onBlur:function(){return S(!1)},placeholder:"homepage"===d?"Type a new question or select prompts.":F,rows:1,className:"flex-1 bg-transparent text-white placeholder:text-[rgba(255,255,255,0.5)] outline-none resize-none border-0 focus:ring-0 focus:outline-none focus:border-0 focus:shadow-none min-h-[24px] max-h-48 overflow-y-auto custom-scrollbar px-0 py-0",style:"homepage"===d?{fontSize:"0.875rem",fontWeight:500,fontFamily:"Proxima Nova, sans-serif",lineHeight:"1.5",border:"none",outline:"none",boxShadow:"none"}:{fontSize:"16px",fontWeight:600,lineHeight:"1.5",border:"none",outline:"none",boxShadow:"none"}}),(0,o.jsx)("button",{type:"submit",disabled:!j.trim()||c,className:"text-white hover:text-[#6464a1] disabled:opacity-50 disabled:cursor-not-allowed",style:"homepage"===d?{width:"1rem",he
1ight:"1rem"}:{},children:c?(0,o.jsx)(b.Z,{className:"homepage"===d?"w-4 h-4 animate-spin":"w-5 h-5 animate-spin"}):(0,o.jsx)(v.Z,{className:"homepage"===d?"w-4 h-4":"w-5 h-5"})})]})]})})}},20188:function(e,t,n){n.d(t,{Z:function(){return ChartRenderer_ChartRenderer}});var r=n(85893),a=n(67294),s=n(72253),i=n(5152),o=n.n(i),l=n(86540),c=o()(function(){return Promise.all([n.e(2960),n.e(8764),n.e(8660)]).then(n.bind(n,58660))},{loadableGenerated:{webpack:function(){return[58660]}},ssr:!1});function ChartRenderer(e){var t=e.chartData,n=e.className,a=t.data,i=t.layout,o=t.config,u=t.title,d=t.description;if(!a||!Array.isArray(a)||0===a.length)return(0,r.jsx)(l.Zb,{className:"bg-slate-800/50 border-slate-700 ".concat(n||""),children:(0,r.jsx)(l.aY,{children:(0,r.jsx)("p",{className:"text-red-400",children:"Error: Invalid chart data"})})});var h=(0,s._)({autosize:!0,margin:{l:50,r:50,t:50,b:50},paper_bgcolor:"rgba(0,0,0,0)",plot_bgcolor:"rgba(0,0,0,0)",font:{color:"#e2e8f0",family:"Inter, system-ui, sans-serif"},xaxis:{gridcolor:"rgba(148, 163, 184, 0.1)",zerolinecolor:"rgba(148, 163, 184, 0.2)"},yaxis:{gridcolor:"rgba(148, 163, 184, 0.1)",zerolinecolor:"rgba(148, 163, 184, 0.2)"}},i),f=(0,s._)({responsive:!0,displayModeBar:!0,displaylogo:!1,modeBarButtonsToRemove:["lasso2d","select2d"]},o);return(0,r.jsxs)(l.Zb,{className:"bg-slate-800/50 border-slate-700 ".concat(n||""),children:[(u||d)&&(0,r.jsxs)(l.Ol,{children:[u&&(0,r.jsx)(l.ll,{className:"text-lg",children:u}),d&&(0,r.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:d})]}),(0,r.jsx)(l.aY,{children:(0,r.jsx)("div",{className:"w-full h-[400px]",children:(0,r.jsx)(c,{data:a,layout:h,config:f,useResizeHandler:!0,style:{width:"100%",height:"100%"}})})})]})}var u=n(24043),d=n(74094),h=n(27060),f=n(84979),m=n(8971),x=n(34958);function DataTable(e){var t=e.tableData,n=e.className,s=t.columns,i=t.data,o=t.title,c=t.description,p=t.enableSorting,g=void 0===p||p,b=t.enableFiltering,v=t.enablePagination,y=void 0===v||v,w=t.pageSize,j=void 0===w?10:w,N=(0,u._)(a.useState([]),2),_=N[0],S=N[1],k=(0,u._)(a.useState([]),2),C=k[0],A=k[1],M=s.map(function(e){return{accessorKey:e.accessorKey,header:e.header,cell:e.cell?function(t){return e.cell(t.getValue())}:void 0}}),I=(0,d.b7)({data:i,columns:M,getCoreRowModel:(0,h.sC)(),getSortedRowModel:g?(0,h.tj)():void 0,getFilteredRowModel:void 0!==b&&b?(0,h.vL)():void 0,getPaginationRowModel:y?(0,h.G_)():void 0,onSortingChange:S,onColumnFiltersChange:A,state:{sorting:_,columnFilters:C},initialState:{pagination:{pageSize:j}}});return(0,r.jsxs)(l.Zb,{className:"bg-slate-800/50 border-slate-700 ".concat(n||""),children:[(o||c)&&(0,r.jsxs)(l.Ol,{children:[o&&(0,r.jsx)(l.ll,{className:"text-lg",children:o}),c&&(0,r.jsx)("p",{className:"text-sm text-slate-400 mt-1",children:c})]}),(0,r.jsxs)(l.aY,{children:[(0,r.jsx)("div",{className:"w-full overflow-auto",children:(0,r.jsxs)("table",{className:"w-full border-collapse",children:[(0,r.jsx)("thead",{children:I.getHeaderGroups().map(function(e){return(0,r.jsx)("tr",{className:"border-b border-slate-700",children:e.headers.map(function(e){return(0,r.jsx)("th",{className:"px-4 py-3 text-left text-sm font-semibold text-slate-200",children:e.isPlaceholder?null:(0,r.jsxs)("div",{className:"flex items-center gap-2 ".concat(e.column.getCanSort()?"cursor-pointer select-none":""),onClick:e.column.getToggleSortingHandler(),children:[(0,d.ie)(e.column.columnDef.header,e.getContext()),g&&e.column.getCanSort()&&(0,r.jsx)("span",{className:"text-slate-400",children:"asc"===e.column.getIsSorted()?(0,r.jsx)(f.Z,{className:"w-4 h-4"}):"desc"===e.column.getIsSorted()?(0,r.jsx)(m.Z,{className:"w-4 h-4"}):(0,r.jsx)(x.Z,{className:"w-4 h-4"})})]})},e.id)})},e.id)})}),(0,r.jsx)("tbody",{children:I.getRowModel().rows.map(function(e){return(0,r.jsx)("tr",{className:"border-b border-slate-700/50 hover:bg-slate-700/30 transition-colors",children:e.getVisibleCells().map(function(e){return(0,r.jsx)("td",{className:"px-4 py-3 text-sm text-slate-300",children:(0,d.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]})}),y&&i.length>j&&(0,r.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-slate-700",children:[(0,r.jsxs)("div",{className:"text-sm text-slate-400",children:["Showing ",I.getState().pagination.pageIndex*j+1," to"," ",Math.min((I.getState().pagination.pageIndex+1)*j,i.length)," ","of ",i.length," rows"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:function(){return I.previousPage()},disabled:!I.getCanPreviousPage(),className:"px-3 py-1 text-sm text-white bg-slate-700 hover:bg-slate-600 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors",children:"Previous"}),(0,r.jsxs)("span",{className:"text-sm text-slate-400",children:["Page ",I.getState().pagination.pageIndex+1," of"," ",I.getPageCount()]}),(0,r.jsx)("button",{onClick:function(){return I.nextPage()},disabled:!I.getCanNextPage(),className:"px-3 py-1 text-sm text-white bg-slate-700 hover:bg-slate-600 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors",children:"Next"})]})]})]})]})}function ChartRenderer_ChartRenderer(e){var t=e.content,n=e.messageId,a=function(e){for(var t,n=[],r=new Set,a=/```(?:json)?\s*(\{[\s\S]*?\})\s*```/g;null!==(t=a.exec(e));)try{var s=JSON.parse(t[1]),i=JSON.stringify(s);r.has(i)||(r.add(i),n.push(s))}catch(e){}return n}(t);if(0===a.length)return null;var s=a.map(function(e,t){var a="".concat(n||"viz","-").concat(t);return e&&"object"==typeof e&&("plotly_chart"===e.__type__||Array.isArray(e.data)&&e.data.length>
10)?(0,r.jsx)("div",{className:"my-4",children:(0,r.jsx)(ChartRenderer,{chartData:e})},a):e&&"object"==typeof e&&"data_table"===e.__type__&&Array.isArray(e.columns)&&Array.isArray(e.data)?(0,r.jsx)("div",{className:"my-4",children:(0,r.jsx)(DataTable,{tableData:e})},a):null}).filter(Boolean);return 0===s.length?null:(0,r.jsx)("div",{className:"visualizations-container",children:s})}},50121:function(e,t,n){n.d(t,{U:function(){return BackendHealthChecker}});var r=n(85893),a=n(5387),s=n(67294);function BackendHealthChecker(e){var t=e.onHealthStatusChange,n=e.children,i=(0,a.o)(),o=i.isBackendReady,l=i.isCheckingBackend,c=i.checkBackendHealth;return(s.useEffect(function(){t&&t(o,l)},[o,l,t]),l)?(0,r.jsx)(BackendLoadingScreen,{}):o?(0,r.jsx)(r.Fragment,{children:n}):(0,r.jsx)(BackendErrorScreen,{onRetry:c})}function BackendLoadingScreen(){return(0,r.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center p-4 overflow-hidden relative",children:(0,r.jsx)("div",{className:"w-full max-w-2xl z-10 bg-neutral-900/50 backdrop-blur-md p-8 rounded-2xl border border-neutral-700 shadow-2xl shadow-black/60",children:(0,r.jsxs)("div",{className:"text-center space-y-6",children:[(0,r.jsx)("h1",{className:"text-4xl font-bold text-white flex items-center justify-center gap-3",children:"✨ AI Goal Planning Assistant \uD83D\uDE80"}),(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"w-16 h-16 border-4 border-neutral-600 border-t-blue-500 rounded-full animate-spin"}),(0,r.jsx)("div",{className:"absolute inset-0 w-16 h-16 border-4 border-transparent border-r-purple-500 rounded-full animate-spin",style:{animationDirection:"reverse",animationDuration:"1.5s"}})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-xl text-neutral-300",children:"Waiting for backend to be ready..."}),(0,r.jsx)("p",{className:"text-sm text-neutral-400",children:"This may take a moment on first startup"})]}),(0,r.jsxs)("div",{className:"flex space-x-1",children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,r.jsx)("div",{className:"w-2 h-2 bg-purple-500 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,r.jsx)("div",{className:"w-2 h-2 bg-pink-500 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})]})]})})})}function BackendErrorScreen(e){var t=e.onRetry;return(0,r.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center p-4",children:(0,r.jsxs)("div",{className:"text-center space-y-4",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold text-red-400",children:"Backend Unavailable"}),(0,r.jsx)("p",{className:"text-neutral-300",children:"Unable to connect to backend services"}),(0,r.jsx)("button",{onClick:function(){t().catch(function(e){console.error("Retry failed:",e)})},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:"Retry"})]})})}},23411:function(e,t,n){n.d(t,{x:function(){return ChatInput}});var r=n(85893),a=n(99908),s=n(56017);function ChatInput(){var e=(0,s.m)(),t=e.handleSubmit,n=e.isLoading;return 0===e.messages.length?null:(0,r.jsx)("div",{className:"px-8 py-6 border-t border-[#343640]",children:(0,r.jsx)("div",{className:"w-full max-w-4xl mx-auto",children:(0,r.jsx)(a.M,{onSubmit:function(e,n){t(e,n)},isLoading:n,context:"chat"})})})}},56017:function(e,t,n){n.d(t,{a:function(){return ChatProvider},m:function(){return useChatContext}});var r=n(11010),a=n(72253),s=n(14932),i=n(24043),o=n(248),l=n(97582),c=n(85893),u=n(67294),d=n(87638);function _authHeader(){return(_authHeader=(0,r._)(function(){var e,t;return(0,l.Jh)(this,function(n){switch(n.label){case 0:return[4,null===(e=d.I8.currentUser)||void 0===e?void 0:e.getIdToken()];case 1:if(!(t=n.sent()))throw Error("Not signed in");return[2,{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"}]}})})).apply(this,arguments)}var h=n(57632),f=n(98484),m=n(5387);function chat_ChatProvider_authHeader(){return(chat_ChatProvider_authHeader=(0,r._)(function(){var e,t;return(0,l.Jh)(this,function(n){switch(n.label){case 0:return[4,null===(e=d.I8.currentUser)||void 0===e?void 0:e.getIdToken()];case 1:if(!(t=n.sent()))throw Error("Not signed in");return[2,{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"}]}})})).apply(this,arguments)}var x=(0,u.createContext)(null);function ChatProvider(e){var t,n,d,p,g,b,v,y,w,j,N,_,S,k,C,A,M,I,E,F,R,D,P,T,L,B,z,Z,H,U,J,W,q,O,G,V,Y,$,K,Q,X,ee,et,en,er,ea=e.children,es=e.userId;e.userName;var ei=(0,u.useRef)(null),eo=(0,u.useRef)(null),el=(0,u.useRef)([]),ec=(0,i._)((0,u.useState)(!1),2),eu=ec[0],ed=ec[1],eh=(n=(t=(0,i._)((0,u.useState)(""),2))[0],d=t[1],g=(p=(0,i._)((0,u.useState)(es||"default"),2))[0],b=p[1],v=(0,u.useCallback)(function(e){g&&e!==n&&d(e)},[g,n]),w=(0,u.useCallback)((y=(0,r._)(function(e){var t,n,r,a;return(0,l.Jh)(this,function(s){switch(s.label){case 0:if(t=function(){var e,t,s,i,o,c,u;return(0,l.Jh)(this,function(l){switch(l.label){case 0:return l.trys.push([0,7,,9]),[4,function(){return _authHeader.apply(this,arguments)}()];case 1:return t=l.sent(),[4,fetch("".concat("https://uptick-agent-tbdhxr4qba-uc.a.run.app","/api/agent/session"),{method:"POST",headers:t,body:JSON.stringify({})})];case 2:s=l.sent(),i=void 0,l.label=3;case 3:return l.trys.push([3,5,,6]),[4,s.json()];case 4:return i=l.sent(),[3,6];case 5:throw l.sent(),Error("Failed to parse response: ".concat(s.statusText));case 6:if(s.ok&&(null===(e=i.output)||void 0===e?void 0:e.id))return n=i.output.id,[2,"break"];if(429===s.status)throw console.error("⛔ 429 Rate Limit detected. Stopping retries to prevent abuse block."),Error("Rate Limit Exceeded: ".concat((null==i?void 0:i.detail)||"429"));throw console.warn("⚠️ Session creation failed (Attempt ".concat(r+1,"):"),(null==i?void 0:i.detail)||(null==i?void 0:i.error)),Error((null==i?void 0:i.detail)||(null==i?void 0:i.error)||"Unknown error");case 7:if(o=l.sent(),r++,c=o instanceof Error&&(o.message.includes("429")||o.message.includes("Rate Limit")),r>=a||c)throw console.error("❌ Session creation failed after max retries or critical error:",o),o;return u=Math.min(1e3*Math.pow(2,r-1),1e4),[4,new Promise(function(e){return setTimeout(e,u)})];case 8:return l.sent(),[3,9];case 9:return[2]}})},!e)throw Error("User ID is required to create a session");n="",r=0,a=5,s.label=1;case 1:if(!(r<a))return[3,3];return[5,(0,l.XA)(t())];case 2:if("break"===s.sent())return[3,3];return[3,1];case 3:return v(n),[2,n]}})}),function(e){return y.apply(this,arguments)}),[v]),{sessionId:n,userId:g,handleUserIdChange:(0,u.useCallback)(function(e){b(e)},[]),handleUserIdConfirm:(0,u.useCallback)(function(e){b(e),localStorage.setItem("agent-engine-user-id",e)},[]),handleSessionSwitch:v,handleCreateNewSession:w}),ef=eh.userId,em=eh.sessionId,ex=eh.handleUserIdChange,ep=eh.handleUserIdConfirm,eg=eh.handleCreateNewSession,eb=eh.handleSessionSwitch,ev=(N=(j=(0,i._)((0,u.useState)([]),2))[0],_=j[1],k=(S=(0,i._)((0,u.useState)(new Map),2))[0],C=S[1],M=(A=(0,i._)((0,u.useState)(0),2))[0],I=A[1],E=(0,u.useCallback)(function(e,t){return"chat_messages_".concat(e,"_").concat(t)},[]),F=(0,u.useCallback)(function(e,t){try{var n=localStorage.getItem(E(e,t));if(n)return JSON.parse(n).map(function(e){return(0,s._)((0,a._)({},e),{timestamp:new Date(e.timestamp)})});return[]}catch(e){return console.error("Error loading messages from storage:",e),[]}},[E]),R=(0,u.useCallback)(function(e,t,n){try{localStorage.setItem(E(e,t),JSON.stringify(n))}catch(e){console.error("Error saving messages to storage:",e)}},[E]),{messages:N,messageEvents:k,websiteCount:M,addMessage:(0,u.useCallback)(function(e){_(function(t){return(0,o._)(t).concat([e])})},[]),updateMessage:(0,u.useCallback)(function(e,t){_(function(n){return n.map(function(n){return n.id===e?(0,s._)((0,a._)({}
1,n),{content:t}):n})})},[]),clearMessages:(0,u.useCallback)(function(){_([])},[]),setMessages:(0,u.useCallback)(function(e){_(e)},[]),addMessageEvent:(0,u.useCallback)(function(e,t){C(function(n){var r=new Map(n),a=r.get(e)||[];return r.set(e,(0,o._)(a).concat([t])),r})},[]),clearMessageEvents:(0,u.useCallback)(function(){C(new Map)},[]),setMessageEvents:(0,u.useCallback)(function(e){C(e)},[]),updateWebsiteCount:(0,u.useCallback)(function(e){I(function(t){return Math.max(t,e)})},[]),saveMessagesToStorage:R,loadMessagesFromStorage:F}),ey=ev.messages,ew=ev.messageEvents,ej=ev.websiteCount,eN=ev.addMessage,e_=ev.setMessages,eS=ev.setMessageEvents,ek=ev.updateWebsiteCount,eC=(P=(D={userId:ef,sessionId:em,onMessageUpdate:function(e){e_(function(t){var n=t.find(function(t){return t.id===e.id});if(n)return t.map(function(t){return t.id===e.id?(0,a._)({},n,e):t});var r=(0,s._)((0,a._)({},e),{timestamp:e.timestamp||new Date});return(0,o._)(t).concat([r])})},onEventUpdate:function(e,t){eS(function(n){var r=new Map(n),i=r.get(e)||[];if(t.title.startsWith("\uD83E\uDD14")){var l=i.findIndex(function(e){return e.title===t.title});if(l>=0){var c=(0,o._)(i),u=c[l],d=u.data&&"object"==typeof u.data?u.data:{},h="content"in d?String(d.content):"",f=t.data&&"object"==typeof t.data&&"content"in t.data?String(t.data.content):"",m=h?"".concat(h,"\n\n").concat(f):f;c[l]=(0,s._)((0,a._)({},u),{data:(0,s._)((0,a._)({},d),{content:m})}),r.set(e,c)}else r.set(e,(0,o._)(i).concat([t]))}else i.some(function(e){return e.title===t.title})||r.set(e,(0,o._)(i).concat([t]));return r})},onWebsiteCountUpdate:ek}).userId,T=D.sessionId,L=D.onMessageUpdate,B=D.onEventUpdate,z=D.onWebsiteCountUpdate,Z=D.onLoadingChange,X=(H=(0,m.o)().retryWithBackoff,J=(U=(0,i._)((0,u.useState)(!1),2))[0],W=U[1],O=(q=(0,i._)((0,u.useState)(""),2))[0],G=q[1],V=(0,u.useRef)(""),Y=(0,u.useRef)(""),null===($=(0,u.useRef)(null)).current&&($.current=new f.f({retryFn:H,endpoint:"https://uptick-agent-tbdhxr4qba-uc.a.run.app/api/agent/stream"})),Q={isLoading:J,currentAgent:O,startStream:(0,u.useCallback)((K=(0,r._)(function(e,t,n,r){var a,s,i;return(0,l.Jh)(this,function(o){switch(o.label){case 0:if(!$.current)throw Error("Connection manager not initialized");return a=(0,h.Z)(),s={onMessageUpdate:t,onEventUpdate:n,onWebsiteCountUpdate:r},i={message:e.message,userId:e.userId,sessionId:e.sessionId,attachments:e.attachments},[4,$.current.submitMessage(i,s,V,Y,G,W,a)];case 1:return o.sent(),[2]}})}),function(e,t,n,r){return K.apply(this,arguments)}),[]),getEventTitle:(0,u.useCallback)(function(e){return"goal_planning_agent"===e||e.includes("plan")||e.includes("planning")?"\uD83C\uDFAF Planning Strategy":e.includes("research")||e.includes("search")?"\uD83D\uDD0D Researching Information":e.includes("analysis")||e.includes("evaluating")?"\uD83D\uDCCA Analyzing Content":e.includes("writing")||e.includes("report")?"✍️ Writing Response":"Processing (".concat(e||"AI Agent",")")},[])}).isLoading,ee=Q.currentAgent,et=Q.startStream,(0,u.useEffect)(function(){Z&&Z(X)},[X,Z]),{isLoading:X,currentAgent:ee,submitMessage:(0,u.useCallback)((en=(0,r._)(function(e,t,n){var r,a,s;return(0,l.Jh)(this,function(i){switch(i.label){case 0:if(r=n||T,!e.trim()||!P||!r)throw Error("Message, userId, and sessionId are required");a={message:e.trim(),userId:P,sessionId:r,attachments:t||void 0},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,et(a,L,B,z)];case 2:return i.sent(),[3,4];case 3:throw console.error("Streaming error:",s=i.sent()),s;case 4:return[2]}})}),function(e,t,n){return en.apply(this,arguments)}),[P,T,et,L,B,z])});(0,u.useEffect)(function(){if(ef&&em){var e;if(eo.current===em||"PENDING"===eo.current){el.current.length>0&&e_(function(e){return e.length>=el.current.length?e:(0,o._)(el.current)}),eo.current===em&&(eo.current=null,el.current=[]);return}eo.current=null,e_([]),eS(new Map),ek(0),ed(!0),(e=(0,r._)(function(){var e,t,n;return(0,l.Jh)(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,5,6]),[4,function(){return chat_ChatProvider_authHeader.apply(this,arguments)}()];case 1:return e=r.sent(),[4,fetch("".concat("https://uptick-agent-tbdhxr4qba-uc.a.run.app","/api/agent/session/").concat(encodeURIComponent(em),"/history"),{headers:e})];case 2:if(!(t=r.sent()).ok){if(404===t.status)return console.warn("Session not found or belongs to another user:",em),[2];throw Error("Failed to fetch history: ".concat(t.statusText))}return[4,t.json()];
1case 3:return(n=r.sent()).turns?(e_(n.turns.map(function(e,t){return{id:"history-".concat(e.timestamp,"-").concat(t),type:"user"===e.role?"human":"ai",content:e.text,timestamp:new Date(1e3*e.timestamp)}})),eS(new Map)):console.error("Failed to load history: Invalid format"),[3,6];case 4:return console.error("Error loading session history:",r.sent()),[3,6];case 5:return ed(!1),[7];case 6:return[2]}})}),function(){return e.apply(this,arguments)})()}else em||(e_([]),eS(new Map),ek(0),ed(!1))},[ef,em,e_,eS,ek]),(0,u.useEffect)(function(){if(ei.current){var e=ei.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[ey]);var eA=(0,u.useCallback)((er=(0,r._)(function(e,t,n,r){var a,s,i,o;return(0,l.Jh)(this,function(l){switch(l.label){case 0:if(!e.trim())return[2];if(!(a=n||ef))throw Error("User ID is required to send messages");eN(s={type:"human",content:e,id:"user-".concat(Date.now(),"-").concat(crypto.randomUUID().slice(0,8)),timestamp:new Date,attachments:t}),l.label=1;case 1:if(l.trys.push([1,5,,6]),i=r||em)return[3,3];return eo.current="PENDING",el.current=[s],[4,eg(a)];case 2:if(!(i=l.sent()))throw eo.current=null,Error("Failed to create a new session.");eo.current=i,l.label=3;case 3:return[4,eC.submitMessage(e,t,i)];case 4:return l.sent(),[3,6];case 5:throw console.error("Error submitting message:",o=l.sent()),o;case 6:return[2]}})}),function(e,t,n,r){return er.apply(this,arguments)}),[ef,em,eN,eC]),eM={userId:ef,sessionId:em,messages:ey,messageEvents:ew,websiteCount:ej,isLoading:eC.isLoading,isLoadingHistory:eu,currentAgent:eC.currentAgent,handleUserIdChange:ex,handleUserIdConfirm:ep,handleCreateNewSession:eg,handleSessionSwitch:eb,handleSubmit:eA,addMessage:eN,scrollAreaRef:ei};return(0,c.jsx)(x.Provider,{value:eM,children:ea})}function useChatContext(){var e=(0,u.useContext)(x);if(!e)throw Error("useChatContext must be used within a ChatProvider. Make sure your component is wrapped with <ChatProvider>.");return e}},27415:function(e,t,n){n.d(t,{u:function(){return EmptyState}});var r=n(11010),a=n(97582),s=n(85893),i=n(56017),o=n(19858),l=n(39455),c=n(31222),u=n(67369),d=n(63715),h=n(69062),f=n(99908),m=[{name:"Portfolio Management",icon:o.Z,prompts:["Rebalance sector exposure; target Sharpe > 1.5.","Stress-test for a 20% drop; propose hedges."]},{name:"Risk Management",icon:l.Z,prompts:["Compute VaR/CVaR @95%; list top risk drivers.","Show max drawdown vs S&P 500 (1y)."]},{name:"Asset Analysis",icon:c.Z,prompts:["Compare AAPL/MSFT/GOOGL: risk-adjusted returns & technicals.","Analyze TSLA: fundamentals, technicals, options flow."]},{name:"Options and Futures",icon:u.Z,prompts:["Build SPY iron condor (30–45 DTE) targeting ~2%/mo.","Design a delta-neutral hedge for 500 TSLA via puts."]},{name:"News and Social Media",icon:d.Z,prompts:["Bitcoin news (last 24h) + sentiment.","Top 3 market-moving headlines today; impact on tech."]},{name:"Technical Analysis",icon:h.Z,prompts:["AAPL bias from RSI, MACD, and MAs.","TSLA support/resistance via Fibonacci + volume profile."]}];function EmptyState(){var e,t=(0,i.m)(),n=t.handleSubmit,o=t.isLoading,l=(e=(0,r._)(function(e){return(0,a.Jh)(this,function(t){switch(t.label){case 0:return[4,n(e,[])];case 1:return t.sent(),[2]}})}),function(t){return e.apply(this,arguments)});return(0,s.jsx)("div",{className:"flex-1 flex flex-col bg-transparent relative overflow-y-auto h-full w-full custom-scrollbar",children:(0,s.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center px-4 py-12 min-h-full w-full",children:(0,s.jsxs)("div",{className:"flex flex-col items-center w-full max-w-5xl gap-10",children:[(0,s.jsxs)("div",{className:"text-center space-y-3",children:[(0,s.jsx)("h1",{className:"text-4xl md:text-5xl font-extrabold text-white tracking-tight",children:"Financial Intelligence Assistant"}),(0,s.jsx)("p",{className:"text-gray-400 text-sm md:text-base font-medium max-w-2xl mx-auto",children:"Ask complex questions, analyze portfolios, run risk simulations, or get the latest market insights."})]}),(0,s.jsx)("div",{className:"w-full max-w-3xl",children:(0,s.jsx)(f.M,{onSubmit:function(e,t){n(e,t)},isLoading:o,context:"homepage"})}),(0,s.jsx)("div",{className:"w-full mt-4",children:(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:m.map(function(e,t){var n=e.icon;return(0,s.jsxs)("div",{className:"flex flex-col bg-white/[0.02] border border-white/5 hover:border-white/10 hover:bg-white/[0.04] rounded-2xl p-5 transition-all duration-300 group shadow-lg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"p-2.5 rounded-xl bg-white/5 text-gray-300 transition-colors",children:(0,s.jsx)(n,{size:18,strokeWidth:2.5})}),(0,s.jsx)("h3",{className:"text-gray-200 font-bold text-sm tracking-wide",children:e.name})]}),(0,s.jsx)("div",{className:"flex flex-col gap-2 mt-auto",children:e.prompts.map(function(e,t){return(0,s.jsxs)("div",{onClick:function(){return l(e)},className:"text-[11px] leading-relaxed text-gray-400 bg-black/20 hover:bg-white/5 hover:text-white border border-transparent hover:border-white/10 px-3 py-2.5 rounded-lg cursor-pointer transition-all",children:['"',e,'"']},t)})})]},t)})})})]})})})}},54952:function(e,t,n){n.d(t,{Q:function(){return FollowUpQuestions}});var r=n(85893),a=n(75976),s=n(31012);function FollowUpQuestions(e){var t,n=e.content,i=e.onQuestionClick;if(!((t=n.toLowerCase()).includes("what would you like to do next")||t.includes("related")||t.includes("follow-up questions")||t.includes("next steps")))return null;var o=function(e){var t=[],n=new Set,r=-1,a=!0,s=!1,i=void 0;try{for(var o,l=["what would you like to do next","related","follow-up questions","next steps"][Symbol.iterator]();!(a=(o=l.next()).done);a=!0){var c=o.value,u=e.toLowerCase().indexOf(c);if(-1!==u){r=u;break}}}catch(e){s=!0,i=e}finally{try{a||null==l.return||l.return()}finally{if(s)throw i}}if(-1===r)return t;var d=e.substring(r).split("\n"),h=!1,f=!0,m=!1,x=void 0;try{for(var p,g=d[Symbol.iterator]();!(f=(p=g.next()).done);f=!0){var b=p.value.trim();if(b.toLowerCase().includes("what would you like to do next")){h=!0;continue}
1if(h){if(/\*\*?[A-Z]{2,5}:\*\*?\s*\$[\d,]+/.test(b)||b.toLowerCase().includes("total portfolio value"))continue;var v=b.match(/^[-*•]\s*(.+?)\s*\(e\.g\.,?\s*[""](.+?)[""]?\)$/);if(v){var y=v[2].trim(),w=y.toLowerCase();n.has(w)||(t.push(y),n.add(w));continue}var j=b.match(/^[-*•]\s*(.+)$/);if(j){var N=j[1].trim().replace(/\*\*/g,""),_=N.toLowerCase();!(N.length>15)||!(N.length<200)||/^\$[\d,]+\s*\([\d.]+%\)$/.test(N)||N.match(/^[A-Z]{2,5}:\s*\$/)||n.has(_)||(t.push(N),n.add(_))}}}}catch(e){m=!0,x=e}finally{try{f||null==g.return||g.return()}finally{if(m)throw x}}return t}(n);if(0===o.length)return null;var l=o.slice(0,5);return(0,r.jsxs)("div",{className:"mt-6 pt-4 border-t border-gray-700/50",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)(a.Z,{className:"h-4 w-4 text-gray-400"}),(0,r.jsx)("h4",{className:"text-sm font-semibold text-gray-300",children:"Related"})]}),(0,r.jsx)("div",{className:"space-y-0 border border-gray-700/50 rounded-lg overflow-hidden bg-black/20",children:l.map(function(e,t){return(0,r.jsxs)("button",{onClick:function(){return i(e)},className:" w-full flex items-center justify-between px-4 py-3 text-left text-sm text-white hover:bg-gray-700/30 transition-colors border-b border-gray-700/50 last:border-b-0 group ",children:[(0,r.jsx)("span",{className:"flex-1 pr-4",children:e}),(0,r.jsx)(s.Z,{className:"h-4 w-4 text-gray-400 group-hover:text-blue-400 flex-shrink-0 transition-colors"})]},t)})})]})}},31204:function(e,t,n){n.d(t,{$:function(){return MarkdownRenderer}});var r=n(72253),a=n(14932),s=n(47702),i=n(85893),o=n(98486),l=n(4958),c={h1:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h1",(0,a._)((0,r._)({className:"text-xl font-bold mb-3 text-white leading-tight"},n),{children:t}))},h2:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h2",(0,a._)((0,r._)({className:"text-lg font-semibold mb-2 text-white leading-tight"},n),{children:t}))},h3:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h3",(0,a._)((0,r._)({className:"text-base font-medium mb-2 text-gray-100 leading-tight"},n),{children:t}))},h4:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h4",(0,a._)((0,r._)({className:"text-sm font-medium mb-1 text-gray-200 leading-tight"},n),{children:t}))},h5:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h5",(0,a._)((0,r._)({className:"text-sm font-medium mb-1 text-gray-200 leading-tight"},n),{children:t}))},h6:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("h6",(0,a._)((0,r._)({className:"text-sm font-medium mb-1 text-gray-200 leading-tight"},n),{children:t}))},p:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("p",(0,a._)((0,r._)({className:"mb-2 leading-relaxed text-gray-200 last:mb-0"},n),{children:t}))},ul:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("ul",(0,a._)((0,r._)({className:"list-disc list-inside mb-2 space-y-1 text-gray-200 ml-4"},n),{children:t}))},ol:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("ol",(0,a._)((0,r._)({className:"list-decimal list-inside mb-2 space-y-1 text-gray-200 ml-4"},n),{children:t}))},li:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("li",(0,a._)((0,r._)({className:"leading-relaxed text-gray-200"},n),{children:t}))},blockquote:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("blockquote",(0,a._)((0,r._)({className:"border-l-4 border-blue-400 pl-4 py-2 mb-2 bg-blue-500/10 rounded-r italic text-gray-200"},n),{children:t}))},code:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("code",(0,a._)((0,r._)({className:"bg-gray-700 text-gray-100 px-1.5 py-0.5 rounded text-sm font-mono border border-gray-600"},n),{children:t}))},pre:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("pre",(0,a._)((0,r._)({className:"bg-gray-900/50 text-gray-100 p-3 rounded-lg mb-2 overflow-x-auto border border-gray-700"},n),{children:t}))},table:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("div",{className:"mb-3 overflow-x-auto rounded-lg border border-gray-700",children:(0,i.jsx)("table",(0,a._)((0,r._)({className:"min-w-full border-collapse text-gray-200"},n),{children:t}))})},th:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("th",(0,a._)((0,r._)({className:"border-b border-gray-700 bg-gray-900/50 px-4 py-2 text-left font-semibold text-white"}
1,n),{children:t}))},td:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("td",(0,a._)((0,r._)({className:"border-b border-gray-700/50 px-4 py-2 text-gray-200"},n),{children:t}))},a:function(e){var t=e.children,n=e.href,o=(0,s._)(e,["children","href"]);return(0,i.jsx)("a",(0,a._)((0,r._)({className:"text-blue-400 hover:text-blue-300 underline decoration-blue-400/50 transition-colors font-medium",href:n,target:"_blank",rel:"noopener noreferrer"},o),{children:t}))},strong:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("strong",(0,a._)((0,r._)({className:"font-semibold text-white"},n),{children:t}))},em:function(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)("em",(0,a._)((0,r._)({className:"italic text-gray-300"},n),{children:t}))}};function MarkdownRenderer(e){var t,n,r=e.content,a=e.className,s=e.components,u=r.replace(/```(?:json)?\s*\{[^`]*?"__type__":\s*"(?:plotly_chart|data_table)"[^`]*?\}\s*```/g,"");return u=-1===(n=(t=u).toLowerCase().indexOf("what would you like to do next"))?t:t.substring(0,n).trim(),(0,i.jsx)("div",{className:"markdown-content ".concat(void 0===a?"":a),children:(0,i.jsx)(o.UG,{components:void 0===s?c:s,remarkPlugins:[l.Z],children:u})})}},40795:function(e,t,n){n.d(t,{D:function(){return SessionHistory},p:function(){return SessionHistoryPlaceholder}});var r=n(85893),a=n(36316),s=n(73510),i=n(5097);function SessionHistory(e){var t=e.isLoadingHistory,n=e.sessionId,i=e.error;return t||i?t?(0,r.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 text-slate-400",children:[(0,r.jsx)(a.Z,{className:"h-5 w-5 animate-spin"}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Loading conversation history..."}),(0,r.jsxs)("span",{className:"text-xs opacity-70",children:["Fetching messages for session ",n.substring(0,8),"..."]})]})]})}):i?(0,r.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 text-red-400",children:[(0,r.jsx)(s.Z,{className:"h-5 w-5"}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"Failed to load conversation history"}),(0,r.jsx)("span",{className:"text-xs opacity-70",children:i})]})]})}):null:null}function SessionHistoryPlaceholder(e){var t=e.isLoadingHistory,n=e.hasMessages;return t||n?null:(0,r.jsx)("div",{className:"flex items-center justify-center py-8 text-slate-500",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(i.Z,{className:"h-5 w-5"}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:"No conversation history found"}),(0,r.jsx)("span",{className:"text-xs opacity-70",children:"This session is ready for new messages"})]})]})})}},68390:function(e,t,n){n.d(t,{f:function(){return LeftSidebar}});var r=n(11010),a=n(24043),s=n(97582),i=n(85893),o=n(67294),l=n(47737),c=n(56017),u=n(87638);function _authHeader(){return(_authHeader=(0,r._)(function(){var e,t;return(0,s.Jh)(this,function(n){switch(n.label){case 0:return[4,null===(e=u.I8.currentUser)||void 0===e?void 0:e.getIdToken()];case 1:if(!(t=n.sent()))throw Error("Not signed in");return[2,{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"}]}})})).apply(this,arguments)}function LeftSidebar(){var e,t=(0,c.m)(),n=t.userId,u=t.sessionId,d=t.handleSessionSwitch;t.handleCreateNewSession;var h=(0,a._)((0,o.useState)([]),2),f=h[0],m=h[1],x=(0,a._)((0,o.useState)(!0),2),p=x[0],g=x[1],b=(0,a._)((0,o.useState)(!1),2),v=b[0],y=b[1],w=(0,a._)((0,o.useState)(!1),2),j=w[0],N=w[1],_=(0,a._)((0,o.useState)(0),2),S=_[0];_[1];var k=(0,o.useRef)(null),C=(0,o.useCallback)((e=(0,r._)(function(e,t){var r,a,i;return(0,s.Jh)(this,function(e){switch(e.label){case 0:if(!n)return[2,[]];e.label=1;case 1:return e.trys.push([1,5,6,7]),t?y(!0):g(!0),[4,function(){return _authHeader.apply(this,arguments)}()];case 2:return r=e.sent(),[4,fetch("".concat("https://uptick-agent-tbdhxr4qba-uc.a.run.app","/api/agent/sessions"),{headers:r})];case 3:if(!(a=e.sent()).ok)throw Error("Failed to fetch sessions: ".concat(a.statusText));return[4,a.json()];case 4:return m(i=(e.sent().sessions||[]).map(function(e){return{id:e.session_id,last_update_time:e.updated_at?new Date(1e3*e.updated_at).toISOString():null,title:e.preview||null,hasMessages:""!==e.preview}}).filter(function(e){return e.hasMessages})),N(!1),[2,i];case 5:return console.error("Failed to load sessions:",e.sent()),[2,[]];case 6:return g(!1),y(!1),[7];case 7:return[2]}})}),function(t,n){return e.apply(this,arguments)}),[n]);(0,o.useEffect)(function(){C(0,!1)},[C]);var handleSelectSession=function(e){e!==u&&d(e)},formatDate=function(e){var t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/864e5);return 0===n?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):1===n?"Yesterday":n<7?"".concat(n,"d ago"):t.toLocaleDateString([],{month:"short",day:"numeric"})},isActive=function(e){return e===u};return(0,i.jsxs)("div",{className:"w-full h-full bg-transparent flex flex-col overflow-hidden",children:[(0,i.jsxs)("div",{className:"h-10 shrink-0 border-b border-white/10 flex items-center justify-between px-3 bg-[#051025]",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(l.Z,{size:12,className:"text-blue-400"}),(0,i.jsx)("span",{className:"font-semibold text-xs text-white",children:"Chat History"})]}),(0,i.jsx)("button",{onClick:function(){d("")},className:"text-[10px] bg-blue-600/20 text-blue-400 border border-blue-500/30 px-2 py-0.5 rounded hover:bg-blue-600/40 transition-colors font-medium",children:"+ New Chat"})]}),(0,i.jsx)("div",{className:"px-2 pt-2 pb-2 flex-1 flex flex-col min-h-0",children:p?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[(0,i.jsx)("div",{className:"w-5 h-5 rounded-full border-2 border-[#00FF87] border-t-transparent animate-spin"}),(0,i.jsx)("span",{className:"text-white/40 text-[10px]",children:"Loading chats..."})]}):0===f.length?(0,i.jsxs)("div",{className:"text-white/40 text-xs text-center py-8 italic",children:["No previous chats.",(0,i.jsx)("br",{}),"Start a new conversation!"]}):(0,i.jsxs)("div",{ref:k,className:"flex-1 overflow-y-auto pr-0.5 min-h-0 custom-scrollbar",children:[(0,i.jsx)("div",{className:"space-y-1 pr-1",children:f.map(function(e){return(0,i.jsxs)("div",{onClick:function(){return handleSelectSession(e.id)},title:e.title||"Chat ".concat(e.id.slice(0,8)),className:"rounded-lg px-3 py-2.5 cursor-pointer transition-all duration-150 group flex flex-col gap-1 border ".concat(isActive(e.id)?"bg-blue-500/10 border-blue-500/30":"bg-transparent border-transparent hover:bg-white/5"),children:[(0,i.jsx)("div",{className:"text-xs font-medium truncate leading-snug ".concat(isActive(e.id)?"text-blue-400":"text-gray-200 group-hover:text-white"),children:e.title||"Chat ".concat(e.id.slice(0,8))}),(0,i.jsx)("div",{className:"text-[10px] ".concat(isActive(e.id)?"text-blue-400/80":"text-gray-500"),children:e.last_update_time?formatDate(e.last_update_time):""})]},e.id)})}),j&&(0,i.jsx)("div",{className:"py-3 flex justify-center",children:(0,i.jsx)("button",{onClick:function(){!v&&j&&C(S,!0)},disabled:v,className:"text-[10px] text-[#00FF87]/70 hover:text-[#00FF87] border border-[#00FF87]/20 hover:border-[#00FF87]/40 px-4 py-1.5 rounded-md transition-all duration-200 disabled:opacity-40",children:v?(0,i.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,i.jsx)("span",{className:"w-3 h-3 rounded-full border border-[#00FF87] border-t-transparent animate-spin inline-block"}),"Loading..."]}):"Load older chats"})})]})})]})}},24373:function(e,t,n){n.d(t,{j:function(){return RightSidebar}});var r=n(11010),a=n(72253),s=n(14932),i=n(24043),o=n(248),l=n(97582),c=n(85893),u=n(40116),d=n(56989),h=n(63715),f=n(67294),m=n(11163),x=n(25617),p=n(23791),g=n(43059),b=n(66391),v=new g.Z;function RightSidebar(){var e,t=(0,m.useRouter)(),n=(0,i._)((0,f.useState)(!1),2),g=n[0],y=n[1],w=(0,x.v9)(function(e){return e.account}),j=w.access_token,N=w.user,_=(null==N?void 0:N.id)||"5CQlCMh3cYPncVmAP0Vm23tAmb42",S=(0,i._)((0,f.useState)([]),2),k=S[0],C=S[1],A=(0,i._)((0,f.useState)(null),2),M=A[0],I=A[1],E=(0,i._)((0,f.useState)(null),2),F=E[0],R=E[1],D=(0,i._)((0,f.useState)(null),2),P=D[0],T=D[1],L=(0,i._)((0,f.useState)(null),2),B=L[0],z=L[1],Z=(0,i._)((0,f.useState)([]),2),H=Z[0],U=Z[1],J=(0,i._)((0,f.useState)([]),2),W=J[0],q=J[1];(0,f.useEffect)(function(){y(!0)},[]),(0,f.useEffect)(function(){var e;(e=(0,r._)(function(){var e,t;return(0,l.Jh)(this,function(n){switch(n.label){case 0:if(!_||!j)return[2];n.label=1;case 1:return n.trys.push([1,5,,6]),[4,v.getPortfolioListV2(j,_)];case 2:if(!(e=n.sent()).ok)return[3,4];return[4,e.json()];case 3:C(t=n.sent()),t.length>0&&!M&&I(t[0].id),n.label=4;case 4:return[3,6];case 5:return console.error("Failed to fetch V2 portfolios",n.sent()),[3,6];case 6:return[2]}})}),function(){return e.apply(this,arguments)})()},[_,j,M]),(0,f.useEffect)(function(){if(M&&_&&j){var e,t,n,i;v.getPortfolioV2(M.toString(),j,_).then((e=(0,r._)(function(e){var t,n;return(0,l.Jh)(this,function(i){switch(i.label){case 0:if(!e.ok)return[3,2];return[4,e.json()];case 1:T(t=i.sent()),t.positions&&(n=t.positions.filter(function(e){return e.value>0&&"Cash"!==e.symbol}).sort(function(e,t){return t.value-e.value}).slice(0,3).map(function(e){return e.symbol})).length>0&&Promise.all(n.map(function(e){var t;return v.getNews(e,j,{limit:5}).then((t=(0,r._)(function(t){var n,r;return(0,l.Jh)(this,function(i){switch(i.label){case 0:if(!t.ok)return[2,[]];return[4,t.json()];case 1:return n=i.sent(),r=[],Array.isArray(n)?r=n:n.data&&Array.isArray(n.data)?r=n.data:n.articles&&Array.isArray(n.articles)?r=n.articles:n.news&&Array.isArray(n.news)&&(r=n.news),[2,r.map(function(t){return(0,s._)((0,a._)({},t),{_queriedSymbol:e})})]}})}),function(e){return t.apply(this,arguments)})).catch(function(){return[]})})).then(function(e){var t=e.flat();t.sort(function(e,t){var n=new Date(e.publishedAt||e.published_at||0).getTime();return new Date(t.publishedAt||t.published_at||0).getTime()-n}),q(t.slice(0,15))}),i.label=2;case 2:return[2]}})}),function(t){return e.apply(this,arguments)})).catch(function(e){return console.error(e)}),v.getPortfolioGainLossV2(M.toString(),j,_,"1y").then((t=(0,r._)(function(e){return(0,l.Jh)(this,function(t){switch(t.label){case 0:if(!e.ok)return[3,2];return[4,e.json()];case 1:R.apply(void 0,[t.sent()]),t.label=2;case 2:return[2]}})}),function(e){return t.apply(this,arguments)})).catch(function(e){return console.error(e)}),v.getPortfolioMetricsV2(M.toString(),j,_,"1y").then((n=(0,r._)(function(e){return(0,l.Jh)(this,function(t){switch(t.label){case 0:if(!e.ok)return[3,2];return[4,e.json()];case 1:z.apply(void 0,[t.sent()]),t.label=2;case 2:return[2]}})}),function(e){return n.apply(this,arguments)})).catch(function(e){return console.error(e)}),(i=(0,r._)(function(){return(0,l.Jh)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,(0,p.s)(M,_,{},j)];case 1:return U(e.sent().alerts||[]),[3,3];case 2:return console.error("Failed to fetch alerts:",e.sent()),[3,3];case 3:return[2]}})}),function(){return i.apply(this,arguments)})()}},[M,j,_]);var formatPrice=function(e){if(void 0===e||isNaN(e))return"N/A";var t=(0,i._)(e.toFixed(2).split("."),2),n=t[0],r=t[1];return"$".concat(n.replace(/\B(?=(\d{3})+(?!\d))/g,","),".").concat(r)},O=formatPrice(null==F?void 0:F.current_value),G=(null==F?void 0:F.selected_period_change_prec)!==void 0?"".concat(F.selected_period_change_prec>0?"+":"").concat(F.selected_period_change_prec.toFixed(2),"%"):"N/A",V=(null==F?void 0:F.selected_period_change)!==void 0?"".concat(F.selected_period_change>0?"+":"").concat(formatPrice(Math.abs(F.selected_period_change))):"N/A",Y=[{name:"Sharpe Ratio",value:(null==B?void 0:B.sharpe_ratio)!==void 0?B.sharpe_ratio.toFixed(2):"...",color:((null==B?void 0:B.sharpe_ratio)||0)>1?"text-[#00c853]":"text-white"},{name:"Max Drawdown",value:(null==B?void 0:B.max_drawdown)!==void 0?"-".concat(Math.abs(100*B.max_drawdown).toFixed(1),"%"):"...",color:"text-[#ff5252]"},{name:"Beta",value:(null==B?void 0:B.portfolio_beta)!==void 0?B.portfolio_beta.toFixed(2):"...",color:"text-white"},{name:"Volatility",value:(null==B?void 0:B.annual_volatility)!==void 0?"".concat((100*B.annual_volatility).toFixed(1),"%"):"...",color:"text-white"},{name:"VaR (95%)",value:(null==B?void 0:B.annual_cvar)!==void 0?"".concat((100*B.annual_cvar).toFixed(1),"%"):"...",color:"text-white"}],$=[];if(null==P?void 0:P.positions){var K=P.positions_value||0;if(K>0){var Q=["#00FF87","#40FFA0","#20D070","#10A050","#087040","#555555"];$=(0,o._)(P.positions).filter(function(e){return e.value>0&&"Cash"!==e.symbol}).sort(function(e,t){return t.value-e.value}).slice(0,6).map(function(e,t){return{name:e.symbol,percentage:Math.round(e.value/K*100),color:Q[t%Q.length]}})}}0===$.length&&($=[{name:"N/A",percentage:100,color:"#555555"}]);var X=H.map(function(e){var t;return{id:e.alert_id,text:(null===(t=e.narrative)||void 0===t?void 0:t.t
1itle_short)||"New Insight",icon:"sparkles"}});return 0===X.length&&X.push({id:"",text:"Loading insights...",icon:"sparkles"},{id:"",text:"Analyzing portfolio...",icon:"sparkles"}),(0,c.jsxs)("div",{className:"w-full h-full bg-transparent flex flex-col overflow-hidden",children:[(0,c.jsx)("div",{className:"h-10 shrink-0 border-b border-white/10 flex items-center px-3 bg-[#0c1424]",children:(0,c.jsx)(b.Z,{portfolios:k,selectedId:M,onSelect:I,selectStyle:{background:"transparent",border:"none",padding:"0",fontSize:"13px",fontWeight:600,minWidth:"auto"}})}),(0,c.jsxs)("div",{className:"flex-1 flex flex-col p-3 gap-3 overflow-y-auto min-h-0 custom-scrollbar",children:[(0,c.jsx)("div",{className:"flex flex-col justify-center",children:(0,c.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,c.jsx)("span",{className:"text-white text-lg font-bold",children:O}),(0,c.jsx)("span",{className:(null==F?void 0:F.selected_period_change_prec)>=0?"text-green-400 text-sm font-semibold":"text-red-400 text-sm font-semibold",children:G}),(0,c.jsx)("span",{className:"text-xs text-white/50",children:"|"}),(0,c.jsx)("span",{className:(null==F?void 0:F.selected_period_change)>=0?"text-green-400 text-sm font-semibold whitespace-nowrap":"text-red-400 text-sm font-semibold whitespace-nowrap",children:V})]})}),(0,c.jsx)("div",{className:"h-[200px] shrink-0 rounded-xl flex items-center justify-center relative",style:{background:"rgba(255, 255, 255, 0.02)",border:"1px solid rgba(255, 255, 255, 0.05)"},children:g?(0,c.jsxs)("svg",{width:"100%",height:"100%",viewBox:"0 0 200 200",className:"max-h-full",children:[(0,c.jsx)("defs",{children:(0,c.jsxs)("filter",{id:"glow",children:[(0,c.jsx)("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),(0,c.jsxs)("feMerge",{children:[(0,c.jsx)("feMergeNode",{in:"coloredBlur"}),(0,c.jsx)("feMergeNode",{in:"SourceGraphic"})]})]})}),(e=-90,$.map(function(t,n){var r=t.percentage/100*360||0;if(0===r)return null;var a=e,s=e+r;e=s;var i=a*Math.PI/180,o=s*Math.PI/180,l=(a+r/2)*Math.PI/180,u=Number((100+85*Math.cos(i)).toFixed(2)),d=Number((100+85*Math.sin(i)).toFixed(2)),h=Number((100+85*Math.cos(o)).toFixed(2)),f=Number((100+85*Math.sin(o)).toFixed(2)),m=Number((100+55.25*Math.cos(l)).toFixed(2)),x=Number((100+55.25*Math.sin(l)).toFixed(2));return 360===r?(0,c.jsxs)("g",{children:[(0,c.jsx)("circle",{cx:"100",cy:"100",r:85,fill:t.color,opacity:"0.85",filter:"url(#glow)"}),(0,c.jsx)("text",{x:m,y:x-5,textAnchor:"middle",fill:"white",fontSize:"13",fontWeight:"bold",dominantBaseline:"middle",children:t.name}),(0,c.jsxs)("text",{x:m,y:x+8,textAnchor:"middle",fill:"rgba(255,255,255,0.9)",fontSize:"11",fontWeight:"600",dominantBaseline:"middle",children:[t.percentage,"%"]})]},n):(0,c.jsxs)("g",{children:[(0,c.jsx)("path",{d:"M 100 100 L ".concat(u," ").concat(d," A ").concat(85," ").concat(85," 0 ").concat(r>180?1:0," 1 ").concat(h," ").concat(f," Z"),fill:t.color,opacity:"0.85",filter:"url(#glow)"}),(0,c.jsx)("text",{x:m,y:x-5,textAnchor:"middle",fill:"white",fontSize:"13",fontWeight:"bold",dominantBaseline:"middle",children:t.name}),(0,c.jsxs)("text",{x:m,y:x+8,textAnchor:"middle",fill:"rgba(255,255,255,0.9)",fontSize:"11",fontWeight:"600",dominantBaseline:"middle",children:[t.percentage,"%"]})]},n)}))]}):(0,c.jsx)("div",{className:"text-white text-sm",children:"Loading..."})}),(0,c.jsxs)("div",{className:"flex flex-col gap-2 shrink-0 mt-1",children:[(0,c.jsxs)("div",{className:"flex items-center gap-1.5 text-blue-300 font-bold text-[10px]",children:[(0,c.jsx)(u.Z,{size:10})," RISK METRICS"]}),(0,c.jsx)("div",{className:"grid grid-cols-2 2xl:grid-cols-3 gap-1.5",children:Y.map(function(e,t){return(0,c.jsxs)("div",{className:"rounded p-2 flex flex-col justify-center border border-white/5",style:{background:"#1A1A1A"},children:[(0,c.jsx)("span",{className:"text-gray-400 text-[9px] mb-0.5 whitespace-nowrap overflow-hidden text-ellipsis",children:e.name}),(0,c.jsx)("span",{className:"text-xs font-semibold ".concat(e.color||"text-white"),children:e.value})]},t)})})]}),(0,c.jsxs)("div",{className:"flex flex-col gap-2 shrink-0",children:[(0,c.jsxs)("div",{className:"flex items-center gap-1.5 text-blue-300 font-bold text-[10px]",children:[(0,c.jsx)(d.Z,{size:10})," AI INSIGHTS"]}),(0,c.jsx)("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[160px] pr-1 custom-scrollbar",children:X.map(function(e,t){return(0,c.jsxs)("a",{href:e.id?"/alerts?id=".concat(e.id):"#",className:"rounded p-2.5 flex items-start gap-2 border border-white/5 hover:border-white/20 transition-colors cursor-pointer shrink-0",style:{background:"rgba(255, 255, 255, 0.02)"},children:[(0,c.jsx)("div",{className:"w-1 h-1 rounded-full bg-blue-400 mt-1.5 flex-shrink-0"}),(0,c.jsx)("span",{className:"text-gray-300 text-[10px] leading-snug break-words",children:e.text})]},t)})})]}),W.length>0&&(0,c.jsxs)("div",{className:"flex flex-col gap-2 shrink-0 pb-4",children:[(0,c.jsxs)("div",{className:"flex items-center gap-1.5 text-blue-300 font-bold text-[10px]",children:[(0,c.jsx)(h.Z,{size:10})," LATEST PORTFOLIO NEWS"]}),(0,c.jsx)("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[260px] pr-1 custom-scrollbar",children:W.map(function(e,n){var r,a,s,i=e.symbol||(null===(r=e.symbols)||void 0===r?void 0:r[0])||(null===(s=e.Tickers)||void 0===s?void 0:null===(a=s.split(","))||void 0===a?void 0:a[0])||e._queriedSymbol||"NEWS",o=e._id||e.ArticleId||e.id;return(0,c.jsxs)("div",{onClick:function(n){if(n.preventDefault(),!o){e.url&&window.open(e.url,"_blank");return}t.push({pathname:"/news",query:{articleId:o,token:i}},"/news")},className:"rounded p-2.5 flex flex-col gap-1 border border-white/5 hover:border-white/20 transition-colors shrink-0 cursor-pointer",style:{background:"rgba(255, 255, 255, 0.02)"},children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsx)("span",{className:"text-[9px] font-bold text-gray-400 px-1.5 py-0.5 rounded bg-white/5",children:i}),(0,c.jsx)("span",{className:"text-[9px] text-gray-500",children:e.publishedAt||e.published_at?new Date(e.publishedAt||e.published_at).toLocaleDateString():"Today"})]}),(0,c.jsx)("span",{className:"text-gray-300 text-[11px] leading-snug font-semibold mt-1",children:e.title})]},n)})})]})]})]})}},54911:function(e,t,n){n.d(t,{f:function(){return ThemeProvider}});var r=n(72253),a=n(14932),s=n(47702),i=n(85893);n(67294);var o=n(1571);function ThemeProvider(e){var t=e.children,n=(0,s._)(e,["children"]);return(0,i.jsx)(o.f,(0,a._)((0,r._)({}
1,n),{children:t}))}},86540:function(e,t,n){n.d(t,{Ol:function(){return c},Zb:function(){return l},aY:function(){return d},ll:function(){return u}});var r=n(72253),a=n(47702),s=n(85893),i=n(67294),o=n(13204),l=i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("rounded-xl border bg-card text-card-foreground shadow",n)},i))});l.displayName="Card";var c=i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("flex flex-col space-y-1.5 p-6",n)},i))});c.displayName="CardHeader";var u=i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("font-semibold leading-none tracking-tight",n)},i))});u.displayName="CardTitle",i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("text-sm text-muted-foreground",n)},i))}).displayName="CardDescription";var d=i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("p-6 pt-0",n)},i))});d.displayName="CardContent",i.forwardRef(function(e,t){var n=e.className,i=(0,a._)(e,["className"]);return(0,s.jsx)("div",(0,r._)({ref:t,className:(0,o.cn)("flex items-center p-6 pt-0",n)},i))}).displayName="CardFooter"},5387:function(e,t,n){n.d(t,{o:function(){return useBackendHealth}});var r=n(11010),a=n(24043),s=n(88421),i=n(97582),o=n(67294);function useBackendHealth(){var e,t=(0,a._)((0,o.useState)(!1),2),n=t[0],l=t[1],c=(0,a._)((0,o.useState)(!0),2),u=c[0],d=c[1],h=(0,a._)((0,o.useState)(null),2),f=h[0],m=h[1],x=(0,o.useCallback)((e=(0,r._)(function(e){var t,n,r,a,o,l,c,u=arguments;return(0,i.Jh)(this,function(d){switch(d.label){case 0:t=function(t){var n,s;return(0,i.Jh)(this,function(i){switch(i.label){case 0:if(Date.now()-a>r)throw Error("Retry timeout after ".concat(r,"ms"));i.label=1;case 1:return i.trys.push([1,3,,5]),n={},[4,e()];case 2:return[2,(n.v=i.sent(),n)];case 3:return o=i.sent(),s=Math.min(1e3*Math.pow(2,t),5e3),[4,new Promise(function(e){return setTimeout(e,s)})];case 4:return i.sent(),[3,5];case 5:return[2]}})},n=u.length>1&&void 0!==u[1]?u[1]:10,r=u.length>2&&void 0!==u[2]?u[2]:12e4,a=Date.now(),l=0,d.label=1;case 1:if(!(l<n))return[3,4];return[5,(0,i.XA)(t(l))];case 2:if(c=d.sent(),"object"===(0,s._)(c))return[2,c.v];d.label=3;case 3:return l++,[3,1];case 4:throw o}})}),function(t){return e.apply(this,arguments)}),[]),p=(0,o.useCallback)((0,r._)(function(){var e;return(0,i.Jh)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,fetch("https://uptick-agent-tbdhxr4qba-uc.a.run.app/health",{method:"GET",headers:{"Content-Type":"application/json"}})];case 1:return e=t.sent(),m(new Date),[2,e.ok];case 2:return t.sent(),m(new Date),[2,!1];case 3:return[2]}})}),[]),g=(0,o.useCallback)(function(){var e;(e=(0,r._)(function(){var e,t;return(0,i.Jh)(this,function(n){switch(n.label){case 0:d(!0),e=60,t=0,n.label=1;case 1:if(!(t<e))return[3,4];return[4,p()];case 2:if(n.sent())return l(!0),d(!1),[2];return t++,[4,new Promise(function(e){return setTimeout(e,2e3)})];case 3:return n.sent(),[3,1];case 4:return d(!1),console.error("Backend failed to start within 2 minutes"),[2]}})}),function(){return e.apply(this,arguments)})()},[p]);return(0,o.useEffect)(function(){g()},[g]),{isBackendReady:n,isCheckingBackend:u,lastChecked:f,checkBackendHealth:p,startHealthMonitoring:g,retryWithBackoff:x}}},13204:function(e,t,n){n.d(t,{cn:function(){return cn}});var r=n(90512),a=n(98388);function cn(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,a.m6)((0,r.W)(t))}},66391:function(e,t,n){var r=n(72253),a=n(24043),s=n(85893),i=n(67294);t.Z=function(e){var t=e.portfolios,n=e.selectedId,o=e.onSelect,l=e.className,c=e.style,u=e.selectStyle,d=(0,a._)((0,i.useState)(!1),2),h=d[0],f=d[1],m=(0,i.useRef)(null);(0,i.useEffect)(function(){var handler=function(e){m.current&&!m.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",handler),function(){return document.removeEventListener("mousedown",handler)}},[]);var x=t.find(function(e){return e.id===n}),p=x?x.name||x.portfolio_name||"Portfolio ".concat(x.id):"Select a Portfolio";return(0,s.jsxs)("div",{className:l,style:(0,r._)({position:"relative",display:"inline-block"},c),ref:m,children:[(0,s.jsxs)("button",{onClick:function(){return f(!h)},style:(0,r._)({padding:"6px 12px",minWidth:"180px",fontSize:"13px",background:"#1A1A1A",border:"1px solid #333",borderRadius:"8px",color:"#fff",cursor:"pointer",outline:"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},u),children:[(0,s.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,s.jsx)("span",{style:{fontSize:"8px",opacity:.6,flexShrink:0},children:"▼"})]}),h&&(0,s.jsx)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",minWidth:"180px",background:"#141414",border:"1px solid #333",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.6)",zIndex:50,overflow:"hidden",maxHeight:"200px",overflowY:"auto"},className:"[&::-webkit-scrollbar]:hidden",children:0===t.length?(0,s.jsx)("div",{style:{padding:"8px 12px",fontSize:"11px",color:"#666"},children:"No portfolios"}):t.map(function(e){var t=e.name||e.portfolio_name||"Portfolio ".concat(e.id),r=e.id===n;return(0,s.jsx)("div",{onClick:function(){o(e.id),f(!1)},style:{padding:"6px 12px",fontSize:"11px",color:r?"#60a5fa":"#ddd",background:r?"rgba(96,165,250,0.1)":"transparent",curs
1or:"pointer",transition:"background 0.15s"},onMouseEnter:function(e){r||(e.target.style.background="rgba(255,255,255,0.06)")},onMouseLeave:function(e){r||(e.target.style.background="transparent")},children:t},e.id)})})]})}},23791:function(e,t,n){n.d(t,{N:function(){return c},s:function(){return l}});var r,a,s=n(11010),i=n(97582),o=n(79445),l=(r=(0,s._)(function(e,t,n,r){var a,s,l;return(0,i.Jh)(this,function(i){switch(i.label){case 0:return a=new URLSearchParams({user_id:t}),(null==n?void 0:n.severity)&&a.set("severity",n.severity),(null==n?void 0:n.alert_class)&&a.set("alert_class",n.alert_class),(null==n?void 0:n.subtype)&&a.set("subtype",n.subtype),(null==n?void 0:n.include_dismissed)&&a.set("include_dismissed","true"),(null==n?void 0:n.limit)&&a.set("limit",String(n.limit)),s="".concat(o.dR,"/v2/portfolios/").concat(e,"/alerts?").concat(a.toString()),[4,fetch(s,{method:"GET",headers:(0,o.wU)(r)})];case 1:if(!(l=i.sent()).ok)throw Error("Failed to fetch alerts: ".concat(l.status));return[2,l.json()]}})}),function(e,t,n,a){return r.apply(this,arguments)}),c=(a=(0,s._)(function(e,t,n,r,a){var s,l;return(0,i.Jh)(this,function(i){switch(i.label){case 0:return s="".concat(o.dR,"/v2/portfolios/").concat(e,"/alerts/").concat(t,"?user_id=").concat(n),[4,fetch(s,{method:"PATCH",headers:(0,o.wU)(a),body:JSON.stringify(r)})];case 1:if(!(l=i.sent()).ok)throw Error("Failed to patch alert: ".concat(l.status));return[2,l.json()]}})}),function(e,t,n,r,s){return a.apply(this,arguments)})}}]);

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.