(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{1510:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,9469,23)),Promise.resolve().then(r.bind(r,4314)),Promise.resolve().then(r.bind(r,8719))},4314:(e,t,r)=>{"use strict";r.d(t,{Sidebar:()=>i});var a=r(8111),n=r(5242);let s="/alfred",o=[{href:"".concat(s,"/chat/"),label:"Chat",icon:"\uD83D\uDCAC"},{href:"".concat(s,"/dashboard/"),label:"Dashboard",icon:"\uD83D\uDCCA"},{href:"".concat(s,"/settings/"),label:"Settings",icon:"⚙️"}];function i(){let e=window.location.pathname;return(0,a.jsxs)("aside",{className:"w-16 md:w-56 bg-[#111111] border-r border-[#1f1f1f] flex flex-col h-full",children:[(0,a.jsx)("div",{className:"p-4 border-b border-[#1f1f1f]",children:(0,a.jsxs)("a",{href:"".concat(s,"/"),className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xl font-bold text-blue-500 font-mono",children:"A"}),(0,a.jsx)("span",{className:"hidden md:inline text-sm font-semibold text-gray-200",children:"Alfred"})]})}),(0,a.jsx)("nav",{className:"flex-1 p-2 space-y-1",children:o.map(t=>{let{href:r,label:s,icon:o}=t;return(0,a.jsxs)("a",{href:r,className:(0,n.A)("flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-colors",e.startsWith(r.replace(/\/$/,""))?"bg-blue-500/10 text-blue-400":"text-gray-400 hover:bg-[#1a1a1a] hover:text-gray-200"),children:[(0,a.jsx)("span",{children:o}),(0,a.jsx)("span",{className:"hidden md:inline",children:s})]},r)})}),(0,a.jsx)("div",{className:"p-4 border-t border-[#1f1f1f]",children:(0,a.jsx)("a",{href:"https://github.com/madh99/alfred-ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-400 hidden md:block",children:"GitHub"})})]})}},5242:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});let a=function(){for(var e,t,r=0,a="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=function e(t){var r,a,n="";if("string"==typeof t||"number"==typeof t)n+=t;else if("object"==typeof t)if(Array.isArray(t)){var s=t.length;for(r=0;r<s;r++)t[r]&&(a=e(t[r]))&&(n&&(n+=" "),n+=a)}else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}(e))&&(a&&(a+=" "),a+=t);return a}},8719:(e,t,r)=>{"use strict";r.d(t,{ConfigProvider:()=>h,U:()=>d});var a,n=r(8111),s=r(5271);async function*o(e){var t,r;let a=null==(t=e.body)?void 0:t.getReader();if(!a)return;let n=new TextDecoder,s="",o="",i="";try{for(;;){let{done:e,value:t}=await a.read();if(e)break;let l=(s+=n.decode(t,{stream:!0})).split("\n");for(let e of(s=null!=(r=l.pop())?r:"",l))e.startsWith("event: ")?o=e.slice(7).trim():e.startsWith("data: ")?i+=(i?"\n":"")+e.slice(6):""===e&&(o&&i&&(yield{event:o,data:i}),o="",i="")}o&&i&&(yield{event:o,data:i})}finally{a.releaseLock()}}class i{updateConfig(e,t){this.baseUrl=e,this.token=t}streamMessage(e,t,r,a){let n=new AbortController;return(async()=>{var s,i,l,c,h,d;try{let d=await fetch("".concat(this.baseUrl,"/api/message"),{method:"POST",headers:{"Content-Type":"application/json",...this.token?{Authorization:"Bearer ".concat(this.token)}:{}},body:JSON.stringify({text:e,chatId:t,userId:r}),signal:n.signal});if(!d.ok)return void a.onError("HTTP ".concat(d.status,": ").concat(d.statusText));for await(let{event:e,data:t}of o(d))try{let r=JSON.parse(t);switch(e){case"status":a.onStatus(null!=(i=null!=(s=r.text)?s:r.status)?i:t);break;case"response":a.onResponse(null!=(l=r.text)?l:t);break;case"attachment":a.onAttachment(r);break;case"done":a.onDone();break;case"error":a.onError(null!=(h=null!=(c=r.error)?c:r.message)?h:t)}}catch(r){"response"===e?a.onResponse(t):"error"===e&&a.onError(t)}a.onDone()}catch(e){"AbortError"!==e.name&&a.onError(null!=(d=e.message)?d:"Connection failed")}})(),()=>n.abort()}async fetchDashboard(){let e=await fetch("".concat(this.baseUrl,"/api/dashboard"),{headers:this.token?{Authorization:"Bearer ".concat(this.token)}:{}});if(!e.ok)throw Error("Dashboard: HTTP ".concat(e.status));return e.json()}async fetchHealth(){let e=await fetch("".concat(this.baseUrl,"/api/health"),{headers:this.token?{Authorization:"Bearer ".concat(this.token)}:{}});if(!e.ok)throw Error("Health: HTTP ".concat(e.status));return e.json()}constructor(e,t){this.baseUrl=e,this.token=t}}let l={apiUrl:null!=(a=r(1756).env.NEXT_PUBLIC_ALFRED_API_URL)?a:"",apiToken:""},c=(0,s.createContext)(null);function h(e){let{children:t}=e,[r,a]=(0,s.useState)(l),[o]=(0,s.useState)(()=>new i(l.apiUrl,l.apiToken));return(0,s.useEffect)(()=>{try{let e=localStorage.getItem("alfred-config");if(e){let t=JSON.parse(e);a(t),o.updateConfig(t.apiUrl,t.apiToken)}}catch(e){}},[o]),(0,n.jsx)(c.Provider,{value:{config:r,setConfig:e=>{a(e),o.updateConfig(e.apiUrl,e.apiToken),localStorage.setItem("alfred-config",JSON.stringify(e))},client:o},children:t})}function d(){let e=(0,s.useContext)(c);if(!e)throw Error("useConfig must be used within ConfigProvider");return e}},9469:()=>{}},e=>{e.O(0,[506,814,743,358],()=>e(e.s=1510)),_N_E=e.O()}]);