@amd-gaia/agent-ui 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/gaia-ui.mjs CHANGED
@@ -207,7 +207,7 @@ function installBackend() {
207
207
  // Step 3: Install pinned amd-gaia[ui] into the venv
208
208
  console.log(`Installing ${pipPackage}...`);
209
209
 
210
- const pipArgs = ["pip", "install", pipPackage, "--python", join(GAIA_VENV, IS_WINDOWS ? "Scripts/python.exe" : "bin/python")];
210
+ const pipArgs = ["pip", "install", pipPackage, "--refresh", "--python", join(GAIA_VENV, IS_WINDOWS ? "Scripts/python.exe" : "bin/python")];
211
211
 
212
212
  // Linux: use CPU-only PyTorch to avoid large CUDA packages
213
213
  if (!IS_WINDOWS) {
@@ -369,9 +369,8 @@ function openBrowser(url) {
369
369
  function startBackend(gaiaBin, port) {
370
370
  console.log(`Starting GAIA backend on port ${port}...`);
371
371
 
372
- const child = spawn(gaiaBin, ["chat", "--ui", "--ui-port", String(port)], {
372
+ const child = spawn(gaiaBin, ["chat", "--ui", "--ui-port", String(port), "--ui-dist", join(ROOT_DIR, "dist")], {
373
373
  stdio: ["ignore", "pipe", "pipe"],
374
- env: { ...process.env },
375
374
  detached: false,
376
375
  });
377
376
 
@@ -375,7 +375,7 @@ Error generating stack: `+s.message+`
375
375
  * LICENSE file in the root directory of this source tree.
376
376
  */var Ju=S,Ly=Iy;function Dy(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ry=typeof Object.is=="function"?Object.is:Dy,Oy=Ly.useSyncExternalStore,Py=Ju.useRef,My=Ju.useEffect,Fy=Ju.useMemo,By=Ju.useDebugValue;Qp.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var s=Py(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=Fy(function(){function l(m){if(!d){if(d=!0,h=m,m=r(m),i!==void 0&&a.hasValue){var T=a.value;if(i(T,m))return f=T}return f=m}if(T=f,Ry(h,m))return T;var x=r(m);return i!==void 0&&i(T,x)?(h=m,T):(h=m,f=x)}var d=!1,h,f,p=n===void 0?null:n;return[function(){return l(t())},p===null?void 0:function(){return l(p())}]},[t,n,r,i]);var u=Oy(e,s[0],s[1]);return My(function(){a.hasValue=!0,a.value=u},[u]),By(u),u};qp.exports=Qp;var jy=qp.exports;const Uy=Ou(jy),Xp={},{useDebugValue:Hy}=As,{useSyncExternalStoreWithSelector:zy}=Uy;let rh=!1;const $y=e=>e;function Yy(e,t=$y,n){(Xp?"production":void 0)!=="production"&&n&&!rh&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),rh=!0);const r=zy(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hy(r),r}const ih=e=>{(Xp?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?by(e):e,n=(r,i)=>Yy(t,r,i);return Object.assign(n,t),n},Jp=e=>e?ih(e):ih,we=Jp((e,t)=>({sessions:[],currentSessionId:null,pendingDeleteIds:[],setSessions:n=>e(r=>({sessions:n.filter(i=>!r.pendingDeleteIds.includes(i.id))})),setCurrentSession:n=>e({currentSessionId:n}),addSession:n=>e(r=>({sessions:[n,...r.sessions]})),removeSession:n=>e(r=>({sessions:r.sessions.filter(i=>i.id!==n),currentSessionId:r.currentSessionId===n?null:r.currentSessionId,messages:r.currentSessionId===n?[]:r.messages})),updateSessionInList:(n,r)=>e(i=>({sessions:i.sessions.map(s=>s.id===n?{...s,...r}:s)})),addPendingDelete:n=>e(r=>({pendingDeleteIds:[...r.pendingDeleteIds,n]})),removePendingDelete:n=>e(r=>({pendingDeleteIds:r.pendingDeleteIds.filter(i=>i!==n)})),messages:[],setMessages:n=>e({messages:n}),addMessage:n=>e(r=>({messages:[...r.messages,n]})),removeMessage:n=>e(r=>({messages:r.messages.filter(i=>i.id!==n)})),removeMessagesFrom:n=>e(r=>{const i=r.messages.findIndex(s=>s.id===n);return i===-1?r:{messages:r.messages.slice(0,i)}}),isStreaming:!1,streamingContent:"",setStreaming:n=>e({isStreaming:n}),appendStreamContent:n=>e(r=>({streamingContent:r.streamingContent+n})),setStreamContent:n=>e({streamingContent:n}),clearStreamContent:()=>e({streamingContent:""}),agentSteps:[],addAgentStep:n=>e(r=>({agentSteps:[...r.agentSteps.map(i=>({...i,active:!1})),n]})),updateLastAgentStep:n=>e(r=>{if(r.agentSteps.length===0)return r;const i=[...r.agentSteps];return i[i.length-1]={...i[i.length-1],...n},{agentSteps:i}}),appendThinkingContent:n=>e(r=>{if(r.agentSteps.length===0)return r;const i=[...r.agentSteps],s=i[i.length-1];return s.type!=="thinking"?r:(i[i.length-1]={...s,detail:(s.detail?s.detail+`
377
377
  `:"")+n,active:!0},{agentSteps:i})}),updateLastToolStep:n=>e(r=>{if(r.agentSteps.length===0)return r;const i=[...r.agentSteps];for(let s=i.length-1;s>=0;s--)if(i[s].type==="tool")return i[s]={...i[s],...n},{agentSteps:i};return r}),clearAgentSteps:()=>e({agentSteps:[]}),documents:[],setDocuments:n=>e({documents:n}),systemStatus:null,backendConnected:!0,setSystemStatus:n=>e({systemStatus:n}),setBackendConnected:n=>e({backendConnected:n}),theme:(()=>{try{return localStorage.getItem("gaia-chat-theme")||"dark"}catch{return"dark"}})(),showDocLibrary:!1,showFileBrowser:!1,showSettings:!1,toggleTheme:()=>e(n=>{const r=n.theme==="dark"?"light":"dark";try{localStorage.setItem("gaia-chat-theme",r)}catch{}return document.documentElement.setAttribute("data-theme",r),{theme:r}}),sidebarOpen:typeof window<"u"?window.innerWidth>768:!0,sidebarCollapsed:(()=>{try{return typeof window<"u"&&localStorage.getItem("gaia-chat-sidebar-collapsed")==="true"}catch{return!1}})(),sidebarWidth:(()=>{try{return typeof window<"u"?parseInt(localStorage.getItem("gaia-chat-sidebar-width")||"300",10):300}catch{return 300}})(),isLoadingMessages:!1,pendingPrompt:null,setShowDocLibrary:n=>e({showDocLibrary:n}),setShowFileBrowser:n=>e({showFileBrowser:n}),setShowSettings:n=>e({showSettings:n}),toggleSidebar:()=>e(n=>({sidebarOpen:!n.sidebarOpen})),setSidebarOpen:n=>e({sidebarOpen:n}),toggleSidebarCollapsed:()=>e(n=>{const r=!n.sidebarCollapsed;try{localStorage.setItem("gaia-chat-sidebar-collapsed",String(r))}catch{}return{sidebarCollapsed:r}}),setSidebarCollapsed:n=>{try{localStorage.setItem("gaia-chat-sidebar-collapsed",String(n))}catch{}e({sidebarCollapsed:n})},setSidebarWidth:n=>{const r=Math.max(200,Math.min(500,n));try{localStorage.setItem("gaia-chat-sidebar-width",String(r))}catch{}e({sidebarWidth:r})},setLoadingMessages:n=>e({isLoadingMessages:n}),setPendingPrompt:n=>e({pendingPrompt:n})})),Vy={api:"#4fc3f7",store:"#ce93d8",chat:"#81c784",stream:"#ffb74d",ui:"#90a4ae",doc:"#a1887f",system:"#e57373",nav:"#fff176"},Wy={api:"fetch",store:"state",chat:"chat",stream:"stream",ui:"ui",doc:"docs",system:"sys",nav:"nav"},Va=(()=>{try{if(localStorage.getItem("gaia-debug")==="true")return!0;if(typeof location<"u"){const e=new URLSearchParams(location.search);if(e.has("debug")||e.has("verbose"))return!0}}catch{}return!1})();function Ji(){const e=new Date;return e.toLocaleTimeString("en-US",{hour12:!1})+"."+String(e.getMilliseconds()).padStart(3,"0")}function Jn(e){const t=Vy[e]||"#ccc",r=`%c[${Wy[e]||e}]`,i=`color: ${t}; font-weight: bold;`,s="color: #888; font-weight: normal;";return{info:(a,...u)=>{if(!Va)return;const l=Ji();u.length>0?console.log(`${r} %c${l} %c${a}`,i,s,"color: inherit;",...u):console.log(`${r} %c${l} %c${a}`,i,s,"color: inherit;")},warn:(a,...u)=>{const l=Ji();console.warn(`${r} %c${l} %c${a}`,i,s,"color: inherit;",...u)},error:(a,...u)=>{const l=Ji();console.error(`${r} %c${l} %c${a}`,i,s,"color: inherit;",...u)},debug:(a,...u)=>{if(!Va)return;const l=Ji();console.debug(`${r} %c${l} %c${a}`,i,s,"color: #999;",...u)},timed:(a,u,...l)=>{if(!Va)return;const d=Math.round(performance.now()-u),h=Ji(),f=d>2e3?"color: #e57373;":d>500?"color: #ffb74d;":"color: #81c784;";l.length>0?console.log(`${r} %c${h} %c${a} %c(${d}ms)`,i,s,"color: inherit;",f,...l):console.log(`${r} %c${h} %c${a} %c(${d}ms)`,i,s,"color: inherit;",f)},time:()=>performance.now()}}const D={api:Jn("api"),store:Jn("store"),chat:Jn("chat"),stream:Jn("stream"),ui:Jn("ui"),doc:Jn("doc"),system:Jn("system"),nav:Jn("nav")};function qy(e){console.log("%c GAIA Agent UI %c v"+e+" %c Local AI Desktop","background: #E23C40; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px 0 0 4px;","background: #333; color: #fff; padding: 4px 8px;","background: #1a1a1a; color: #888; padding: 4px 8px; border-radius: 0 4px 4px 0;"),console.log(Va?"%cVerbose logging enabled. Categories: [fetch] [state] [chat] [stream] [ui] [docs] [sys] [nav]":'%cVerbose logging: add ?debug to URL or run localStorage.setItem("gaia-debug","true")',"color: #666; font-style: italic;")}const fd="/api";function Qy(e,t){switch(e){case 403:return"Access denied. This location is outside your home directory.";case 404:return"Not found. The file or folder may have been moved or deleted.";case 413:return"File too large to process.";case 500:return"Server error. Please try again.";case 502:case 503:return"Service unavailable. Is the backend running?";default:return t||`Request failed (HTTP ${e})`}}async function Pe(e,t,n){const r=`${fd}${t}`,i=D.api.time();D.api.info(`${e} ${r}`,n!==void 0?{body:n}:"");const s={method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0};let a;try{a=await fetch(r,s)}catch(d){throw D.api.error(`${e} ${r} - network error`,d),d}if(!a.ok){const d=await a.text().catch(()=>"");D.api.error(`${e} ${r} - HTTP ${a.status}`,{errorText:d});let h=d;try{h=JSON.parse(d).detail||d}catch{}throw new Error(Qy(a.status,h))}if(!(a.headers.get("content-type")||"").includes("application/json")){D.api.timed(`${e} ${r} -> ${a.status} (no body)`,i);return}const l=await a.json();return D.api.timed(`${e} ${r} -> ${a.status}`,i,l),l}async function hd(){return Pe("GET","/system/status")}async function Gy(e,t){return Pe("POST","/system/load-model",{model_name:e,ctx_size:t})}async function Ky(e,t=!1){return Pe("POST","/system/download-model",{model_name:e,force:t})}async function Xy(){return Pe("GET","/sessions")}async function Zp(e={}){return Pe("POST","/sessions",e)}async function sh(e,t){return Pe("PUT",`/sessions/${e}`,t)}async function e1(e){return Pe("DELETE",`/sessions/${e}`)}async function us(e){return Pe("GET",`/sessions/${e}/messages`)}async function Jy(e){return Pe("GET",`/sessions/${e}/export?format=markdown`)}async function Zy(e,t){return Pe("DELETE",`/sessions/${e}/messages/${t}`)}async function eb(e,t){return Pe("DELETE",`/sessions/${e}/messages/${t}/and-below`)}const tb=new Set(["status","step","thinking","plan","tool_start","tool_end","tool_result","tool_args","tool_confirm","agent_error","permission_request"]);function nb(e,t,n,r,i){let s;typeof n=="function"?s={onChunk:n,onAgentEvent:()=>{},onDone:()=>{},onError:f=>{D.stream.error("Unhandled stream error",f)}}:s=n;const a=new AbortController,u=D.stream.time();let l=0,d=0,h=0;return D.stream.info(`Starting SSE stream for session=${e}`,{messageLength:t.length}),fetch(`${fd}/chat/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:e,message:t,stream:!0}),signal:a.signal}).then(async f=>{var I;if(D.stream.info(`SSE connection opened -> HTTP ${f.status}`),!f.ok){const g=await f.text().catch(()=>"");D.stream.error(`SSE connection failed: HTTP ${f.status}`,g),s.onError(new Error(`HTTP ${f.status}: ${g}`));return}const p=(I=f.body)==null?void 0:I.getReader();if(!p){D.stream.error("No response body reader available"),s.onError(new Error("No response body"));return}const m=new TextDecoder;let T="",x=!1;try{for(;;){const{done:g,value:E}=await p.read();if(g){D.stream.debug("SSE reader done (stream ended)");break}T+=m.decode(E,{stream:!0});const y=T.split(`
378
- `);T=y.pop()||"";for(const v of y)if(v.startsWith("data: ")){const O=v.slice(6).trim();if(!O)continue;try{const A=JSON.parse(O);A.type==="chunk"?(l++,d+=(A.content||"").length,(l<=3||l%50===0)&&D.stream.debug(`Chunk #${l} (+${(A.content||"").length} chars)`),s.onChunk(A)):A.type==="answer"?s.onChunk(A):A.type==="done"?(x=!0,D.stream.timed(`Stream complete: ${l} chunks, ${d} chars, ${h} agent events`,u),s.onDone(A)):A.type==="error"?(D.stream.error("Stream error event:",A.content),s.onError(new Error(A.content||"Unknown error"))):tb.has(A.type)?(h++,D.stream.debug(`Agent event: ${A.type}`,A),s.onAgentEvent(A)):D.stream.warn(`Unknown SSE event type: ${A.type}`,A)}catch{D.stream.warn("Malformed SSE data, skipping",{raw:O.slice(0,100)})}}}}finally{p.releaseLock()}x||(D.stream.timed(`SSE connection closed without done event: ${l} chunks, ${h} agent events`,u),s.onDone({type:"done"}))}).catch(f=>{f.name==="AbortError"?D.stream.warn(`Stream aborted by user after ${l} chunks`):(D.stream.error("Stream fetch error",f),s.onError(f))}),a}async function rb(e,t,n,r){return Pe("POST","/chat/confirm",{session_id:e,confirm_id:t,action:n,remember:r})}async function t1(e,t){return Pe("POST","/chat/confirm-tool",{session_id:e,approved:t})}async function ei(){return Pe("GET","/documents")}async function md(e){return Pe("POST","/documents/upload-path",{filepath:e})}async function ib(e){return Pe("DELETE",`/documents/${e}`)}async function sb(e){return Pe("GET",`/documents/${e}/status`)}async function ab(e){return Pe("POST",`/documents/${e}/cancel`)}async function Su(e,t){return Pe("POST",`/sessions/${e}/documents`,{document_id:t})}async function ub(e,t){return Pe("DELETE",`/sessions/${e}/documents/${t}`)}async function lb(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return Pe("GET",`/files/browse${t}`)}async function ob(e,t=!0){return Pe("POST","/documents/index-folder",{folder_path:e,recursive:t})}async function pd(e,t=!0){return Pe("POST","/files/open",{path:e,reveal:t})}async function ah(e){const t=`${fd}/files/upload`,n=D.api.time();D.api.info(`POST ${t}`,{fileName:e.name,size:e.size});const r=new FormData;r.append("file",e);const i=await fetch(t,{method:"POST",body:r});if(!i.ok){const a=await i.text().catch(()=>"Upload failed");throw D.api.error(`POST ${t} - HTTP ${i.status}`,{errorText:a}),new Error(`Upload failed: ${a}`)}const s=await i.json();return D.api.timed(`POST ${t} -> ${i.status}`,n,s),s}async function cb(e,t,n){const r=new URLSearchParams({query:e});return t&&r.set("file_types",t),r.set("max_results",String(n)),Pe("GET",`/files/search?${r}`)}async function db(e,t){const n=new URLSearchParams({path:e});return Pe("GET",`/files/preview?${n}`)}async function fb(){return Pe("POST","/tunnel/start")}async function hb(){return Pe("POST","/tunnel/stop")}async function n1(){return Pe("GET","/tunnel/status")}async function mb(){return Pe("GET","/mcp/status")}function mn(e){return e.replace(/-/g,"").slice(0,7)}function pb(e,t){const n=t.replace(/^#/,"").toLowerCase();if(!n||n.length<4)return null;const r=e.find(i=>i.id.replace(/-/g,"").toLowerCase().startsWith(n));return r?r.id:null}const r1=""+new URL("gaia-robot-NKaQnEIp.png",import.meta.url).href;function gb(e,t){e.stopPropagation(),e.preventDefault();const n=mn(t),r=`${window.location.origin}${window.location.pathname}#${n}`;navigator.clipboard.writeText(r).then(()=>{D.ui.info(`Copied session link: ${r}`)}).catch(()=>{D.ui.warn("Clipboard write failed")})}function uh({session:e,isActive:t,isPendingDelete:n,isDeleting:r,onSelect:i,onKeyDown:s,onDelete:a,formatTime:u}){const[l,d]=S.useState(!1),h=S.useCallback(f=>{gb(f,e.id),d(!0),setTimeout(()=>d(!1),1500)},[e.id]);return c.jsxs("div",{className:`session-item ${t?"active":""} ${r?"session-deleting":""}`,onClick:()=>i(e.id),onKeyDown:f=>s(f,e.id),role:"button",tabIndex:0,"aria-label":`Open task: ${e.title}`,"aria-current":t?"true":void 0,children:[c.jsx("span",{className:"session-title",children:e.title}),c.jsxs("a",{className:`session-hash ${l?"copied":""}`,href:`#${mn(e.id)}`,onClick:h,title:l?"Copied!":`Copy link #${mn(e.id)}`,"aria-label":`Copy link for session ${mn(e.id)}`,children:["#",mn(e.id)]}),c.jsx("span",{className:"session-time",children:u(e.updated_at)}),n?c.jsxs("button",{className:"session-delete confirm",onClick:f=>a(f,e.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&a(f,e.id)},title:"Click to confirm delete","aria-label":`Confirm delete: ${e.title}`,children:[c.jsx(_u,{size:12}),c.jsx("span",{className:"confirm-label",children:"Delete?"})]}):c.jsx("button",{className:"session-delete",onClick:f=>a(f,e.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&a(f,e.id)},title:"Delete","aria-label":`Delete: ${e.title}`,children:c.jsx(_u,{size:13})})]})}function Eb({onNewTask:e,tunnelActive:t,tunnelLoading:n,onMobileToggle:r}){const{sessions:i,currentSessionId:s,setCurrentSession:a,removeSession:u,addSession:l,setMessages:d,theme:h,toggleTheme:f,setShowSettings:p,sidebarOpen:m,setSidebarOpen:T,setLoadingMessages:x,sidebarCollapsed:I,toggleSidebarCollapsed:g,sidebarWidth:E,setSidebarWidth:y,addPendingDelete:v,removePendingDelete:O}=we(),[A,F]=S.useState(""),[H,K]=S.useState(null),[w,Y]=S.useState(null),[te,ce]=S.useState(!1),[le,ue]=S.useState(null),j=S.useRef(null),z=S.useRef(null),P=S.useRef(null);S.useEffect(()=>{const R=()=>{var W;I?(g(),requestAnimationFrame(()=>{var de;return(de=z.current)==null?void 0:de.focus()})):(W=z.current)==null||W.focus()};return window.addEventListener("gaia:focus-search",R),()=>window.removeEventListener("gaia:focus-search",R)},[I,g]);const G=A?i.filter(R=>R.title.toLowerCase().includes(A.toLowerCase())):i,_=S.useMemo(()=>{if(A)return null;const R=new Date,W=new Date(R.getFullYear(),R.getMonth(),R.getDate()).getTime(),de=W-864e5,Ae=W-7*864e5,be=[{label:"Today",sessions:[]},{label:"Yesterday",sessions:[]},{label:"Previous 7 Days",sessions:[]},{label:"Older",sessions:[]}];for(const Re of G){const ze=new Date(Re.updated_at).getTime();ze>=W?be[0].sessions.push(Re):ze>=de?be[1].sessions.push(Re):ze>=Ae?be[2].sessions.push(Re):be[3].sessions.push(Re)}return be.filter(Re=>Re.sessions.length>0)},[G,A]),Z=S.useCallback(async R=>{var de;if(R===s)return;const W=((de=i.find(Ae=>Ae.id===R))==null?void 0:de.title)||"?";D.nav.info(`Selecting session: "${W}" (${R})`),a(R),d([]),x(!0),window.innerWidth<=768&&T(!1);try{const Ae=await us(R);if(!(we.getState().currentSessionId===R)){D.nav.debug(`Discarding stale message load for session=${R} (user switched away)`);return}d(Ae.messages||[]),D.nav.info(`Loaded ${(Ae.messages||[]).length} message(s) for "${W}"`)}catch(Ae){D.nav.error(`Failed to load messages for session ${R}`,Ae),d([])}finally{x(!1)}},[s,i,a,d,T,x]),fe=S.useCallback(async(R,W)=>{R.stopPropagation(),R.preventDefault();const de=i.find(be=>be.id===W),Ae=(de==null?void 0:de.title)||"?";if(H===W){D.chat.info(`Deleting session: "${Ae}" (${W})`),K(null),Y(W),v(W),e1(W).then(()=>{D.chat.info(`Session deleted from backend: "${Ae}"`),O(W)}).catch(Re=>{D.chat.warn(`Backend delete failed for "${Ae}"`,Re),O(W)}),le!=null&&le.timer&&clearTimeout(le.timer);const be=setTimeout(()=>{ue(null)},5e3);de&&ue({session:de,timer:be}),setTimeout(()=>{u(W),Y(null)},250);return}D.chat.debug(`Delete pending confirmation for: "${Ae}" (${W})`),K(W),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>K(be=>be===W?null:be),3e3)},[H,i,u,le,v,O]),N=S.useCallback(()=>{if(!le)return;clearTimeout(le.timer);const{session:R}=le;D.chat.info(`Undo delete: re-creating "${R.title}"`),O(R.id),Zp({title:R.title}).then(W=>{l(W),D.chat.info(`Undo delete: re-created "${W.title}" (new id=${W.id})`)}).catch(W=>{D.chat.warn(`Undo delete failed for "${R.title}"`,W)}),ue(null)},[le,l,O]);S.useEffect(()=>{if(!H)return;const R=()=>K(null);return window.addEventListener("click",R,{once:!0}),()=>window.removeEventListener("click",R)},[H]);const Ne=S.useCallback((R,W)=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),Z(W))},[Z]),re=S.useRef(null),me=S.useCallback(R=>{R.preventDefault(),ce(!0),D.ui.debug("Sidebar resize started");const W=R.clientX,de=E,Ae=Re=>{const ze=Re.clientX-W;y(de+ze)},be=()=>{ce(!1),document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",be),document.body.style.cursor="",document.body.style.userSelect="",re.current=null,D.ui.debug("Sidebar resize ended")};re.current=be,document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",be)},[E,y]);S.useEffect(()=>()=>{re.current&&re.current(),P.current&&clearTimeout(P.current)},[]);const ve=R=>{const W=new Date(R),Ae=new Date().getTime()-W.getTime(),be=Math.floor(Ae/6e4);if(be<1)return"now";if(be<60)return`${be}m`;const Re=Math.floor(be/60);if(Re<24)return`${Re}h`;const ze=Math.floor(Re/24);return ze<7?`${ze}d`:W.toLocaleDateString(void 0,{month:"short",day:"numeric"})},He=typeof window<"u"&&window.innerWidth<=768?void 0:{width:I?56:E,minWidth:I?56:E};return c.jsxs("aside",{ref:j,className:`sidebar ${m?"open":""} ${I?"collapsed":""} ${te?"resizing":""}`,style:He,role:"complementary","aria-label":"Task sidebar",children:[c.jsxs("div",{className:"sidebar-top",children:[c.jsxs("div",{className:"sidebar-brand",children:[c.jsx("div",{className:"brand-icon","aria-hidden":"true",children:c.jsx("img",{src:r1,alt:"",width:28,height:28})}),c.jsxs("div",{className:"brand-text",children:[c.jsx("span",{className:"brand-name",children:"GAIA"}),c.jsxs("span",{className:"brand-version",children:["v","0.17.0"]}),c.jsx("span",{className:"beta-badge",children:"BETA"})]})]}),c.jsxs("div",{className:"sidebar-top-actions",children:[c.jsx("button",{className:"new-task-btn",onClick:e,title:"New Task","aria-label":"New Task",children:c.jsx(oy,{size:18})}),c.jsx("button",{className:"collapse-btn",onClick:g,title:I?"Expand sidebar":"Collapse sidebar","aria-label":I?"Expand sidebar":"Collapse sidebar",children:I?c.jsx(ay,{size:18}):c.jsx(sy,{size:18})})]})]}),c.jsxs("div",{className:"sidebar-search",children:[c.jsx(Pr,{size:14,className:"search-icon","aria-hidden":"true"}),c.jsx("input",{ref:z,type:"text",placeholder:"Search... (Ctrl+K)",value:A,onChange:R=>F(R.target.value),"aria-label":"Search tasks"})]}),c.jsxs("nav",{className:"session-list","aria-label":"Task sessions",children:[G.length===0&&c.jsx("div",{className:"empty-hint",children:A?"No results":"No tasks yet"}),_?_.map(R=>c.jsxs("div",{children:[c.jsx("div",{className:"session-group-label",children:R.label}),R.sessions.map(W=>c.jsx(uh,{session:W,isActive:W.id===s,isPendingDelete:H===W.id,isDeleting:w===W.id,onSelect:Z,onKeyDown:Ne,onDelete:fe,formatTime:ve},W.id))]},R.label)):G.map(R=>c.jsx(uh,{session:R,isActive:R.id===s,isPendingDelete:H===R.id,isDeleting:w===R.id,onSelect:Z,onKeyDown:Ne,onDelete:fe,formatTime:ve},R.id))]}),c.jsxs("div",{className:"sidebar-bottom",children:[c.jsxs("div",{className:"privacy-badge",children:[c.jsx("span",{className:"privacy-dot","aria-hidden":"true"}),c.jsx("span",{children:"100% Local"}),c.jsxs("span",{className:"version-badge",children:["v","0.17.0"]})]}),c.jsxs("div",{className:"sidebar-actions",children:[r&&c.jsx("button",{className:`btn-icon mobile-toggle-btn ${t?"active":""} ${n?"loading":""}`,onClick:r,disabled:n,title:t?"Stop mobile access":"Enable mobile access","aria-label":t?"Stop mobile access":"Enable mobile access",children:c.jsx(Vp,{size:17})}),c.jsx("button",{className:"btn-icon",onClick:()=>p(!0),title:"Settings","aria-label":"Settings",children:c.jsx(fy,{size:17})}),c.jsx("button",{className:"btn-icon",onClick:f,title:"Toggle theme","aria-label":`Switch to ${h==="dark"?"light":"dark"} theme`,children:h==="dark"?c.jsx(py,{size:17}):c.jsx(iy,{size:17})})]})]}),!I&&c.jsx("div",{className:"sidebar-resize-handle",onMouseDown:me,title:"Drag to resize sidebar","aria-hidden":"true"}),le&&c.jsxs("div",{className:"toast toast-undo",role:"status",children:["Deleted “",le.session.title,"”",c.jsx("span",{className:"toast-action",onClick:N,children:"Undo"})]})]})}function lh(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,s=!1;for(;!s;){r===-1&&(r=n.length,s=!0);const a=n.slice(i,r).trim();(a||!s)&&t.push(a),i=r+1,r=n.indexOf(",",i)}return t}function i1(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Tb=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yb=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bb={};function oh(e,t){return(bb.jsx?yb:Tb).test(e)}const xb=/[ \t\n\f\r]/g;function _b(e){return typeof e=="object"?e.type==="text"?ch(e.value):!1:ch(e)}function ch(e){return e.replace(xb,"")===""}class na{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}na.prototype.normal={};na.prototype.property={};na.prototype.space=void 0;function s1(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new na(n,r,t)}function Vs(e){return e.toLowerCase()}class Ut{constructor(t,n){this.attribute=n,this.property=t}}Ut.prototype.attribute="";Ut.prototype.booleanish=!1;Ut.prototype.boolean=!1;Ut.prototype.commaOrSpaceSeparated=!1;Ut.prototype.commaSeparated=!1;Ut.prototype.defined=!1;Ut.prototype.mustUseProperty=!1;Ut.prototype.number=!1;Ut.prototype.overloadedBoolean=!1;Ut.prototype.property="";Ut.prototype.spaceSeparated=!1;Ut.prototype.space=void 0;let kb=0;const pe=Qr(),tt=Qr(),Jo=Qr(),Q=Qr(),je=Qr(),_i=Qr(),$t=Qr();function Qr(){return 2**++kb}const Zo=Object.freeze(Object.defineProperty({__proto__:null,boolean:pe,booleanish:tt,commaOrSpaceSeparated:$t,commaSeparated:_i,number:Q,overloadedBoolean:Jo,spaceSeparated:je},Symbol.toStringTag,{value:"Module"})),jl=Object.keys(Zo);class gd extends Ut{constructor(t,n,r,i){let s=-1;if(super(t,n),dh(this,"space",i),typeof r=="number")for(;++s<jl.length;){const a=jl[s];dh(this,jl[s],(r&Zo[a])===Zo[a])}}}gd.prototype.defined=!0;function dh(e,t,n){n&&(e[t]=n)}function Bi(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new gd(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Vs(r)]=r,n[Vs(s.attribute)]=r}return new na(t,n,e.space)}const a1=Bi({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:je,ariaCurrent:null,ariaDescribedBy:je,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:je,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:je,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:je,ariaLevel:Q,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:je,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:je,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:tt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function u1(e,t){return t in e?e[t]:t}function l1(e,t){return u1(e,t.toLowerCase())}const Sb=Bi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_i,acceptCharset:je,accessKey:je,action:null,allow:null,allowFullScreen:pe,allowPaymentRequest:pe,allowUserMedia:pe,alt:null,as:null,async:pe,autoCapitalize:null,autoComplete:je,autoFocus:pe,autoPlay:pe,blocking:je,capture:null,charSet:null,checked:pe,cite:null,className:je,cols:Q,colSpan:null,content:null,contentEditable:tt,controls:pe,controlsList:je,coords:Q|_i,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pe,defer:pe,dir:null,dirName:null,disabled:pe,download:Jo,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pe,formTarget:null,headers:je,height:Q,hidden:Jo,high:Q,href:null,hrefLang:null,htmlFor:je,httpEquiv:je,id:null,imageSizes:null,imageSrcSet:null,inert:pe,inputMode:null,integrity:null,is:null,isMap:pe,itemId:null,itemProp:je,itemRef:je,itemScope:pe,itemType:je,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pe,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:pe,muted:pe,name:null,nonce:null,noModule:pe,noValidate:pe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:pe,optimum:Q,pattern:null,ping:je,placeholder:null,playsInline:pe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pe,referrerPolicy:null,rel:je,required:pe,reversed:pe,rows:Q,rowSpan:Q,sandbox:je,scope:null,scoped:pe,seamless:pe,selected:pe,shadowRootClonable:pe,shadowRootDelegatesFocus:pe,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:pe,useMap:null,value:tt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:je,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pe,declare:pe,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:pe,noHref:pe,noShade:pe,noWrap:pe,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:pe,disableRemotePlayback:pe,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:l1}),Cb=Bi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:$t,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:je,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:pe,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_i,g2:_i,glyphName:_i,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:$t,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:je,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$t,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$t,rev:$t,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$t,requiredFeatures:$t,requiredFonts:$t,requiredFormats:$t,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:$t,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$t,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$t,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:u1}),o1=Bi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),c1=Bi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:l1}),d1=Bi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Nb={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ab=/[A-Z]/g,fh=/-[a-z]/g,wb=/^data[-\w.:]+$/i;function Zu(e,t){const n=Vs(t);let r=t,i=Ut;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&wb.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(fh,Ib);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!fh.test(s)){let a=s.replace(Ab,vb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=gd}return new i(r,t)}function vb(e){return"-"+e.toLowerCase()}function Ib(e){return e.charAt(1).toUpperCase()}const ra=s1([a1,Sb,o1,c1,d1],"html"),Sr=s1([a1,Cb,o1,c1,d1],"svg");function hh(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function f1(e){return e.join(" ").trim()}var Ed={},mh=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Lb=/\n/g,Db=/^\s*/,Rb=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Ob=/^:\s*/,Pb=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Mb=/^[;\s]*/,Fb=/^\s+|\s+$/g,Bb=`
378
+ `);T=y.pop()||"";for(const v of y)if(v.startsWith("data: ")){const O=v.slice(6).trim();if(!O)continue;try{const A=JSON.parse(O);A.type==="chunk"?(l++,d+=(A.content||"").length,(l<=3||l%50===0)&&D.stream.debug(`Chunk #${l} (+${(A.content||"").length} chars)`),s.onChunk(A)):A.type==="answer"?s.onChunk(A):A.type==="done"?(x=!0,D.stream.timed(`Stream complete: ${l} chunks, ${d} chars, ${h} agent events`,u),s.onDone(A)):A.type==="error"?(D.stream.error("Stream error event:",A.content),s.onError(new Error(A.content||"Unknown error"))):tb.has(A.type)?(h++,D.stream.debug(`Agent event: ${A.type}`,A),s.onAgentEvent(A)):D.stream.warn(`Unknown SSE event type: ${A.type}`,A)}catch{D.stream.warn("Malformed SSE data, skipping",{raw:O.slice(0,100)})}}}}finally{p.releaseLock()}x||(D.stream.timed(`SSE connection closed without done event: ${l} chunks, ${h} agent events`,u),s.onDone({type:"done"}))}).catch(f=>{f.name==="AbortError"?D.stream.warn(`Stream aborted by user after ${l} chunks`):(D.stream.error("Stream fetch error",f),s.onError(f))}),a}async function rb(e,t,n,r){return Pe("POST","/chat/confirm",{session_id:e,confirm_id:t,action:n,remember:r})}async function t1(e,t){return Pe("POST","/chat/confirm-tool",{session_id:e,approved:t})}async function ei(){return Pe("GET","/documents")}async function md(e){return Pe("POST","/documents/upload-path",{filepath:e})}async function ib(e){return Pe("DELETE",`/documents/${e}`)}async function sb(e){return Pe("GET",`/documents/${e}/status`)}async function ab(e){return Pe("POST",`/documents/${e}/cancel`)}async function Su(e,t){return Pe("POST",`/sessions/${e}/documents`,{document_id:t})}async function ub(e,t){return Pe("DELETE",`/sessions/${e}/documents/${t}`)}async function lb(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return Pe("GET",`/files/browse${t}`)}async function ob(e,t=!0){return Pe("POST","/documents/index-folder",{folder_path:e,recursive:t})}async function pd(e,t=!0){return Pe("POST","/files/open",{path:e,reveal:t})}async function ah(e){const t=`${fd}/files/upload`,n=D.api.time();D.api.info(`POST ${t}`,{fileName:e.name,size:e.size});const r=new FormData;r.append("file",e);const i=await fetch(t,{method:"POST",body:r});if(!i.ok){const a=await i.text().catch(()=>"Upload failed");throw D.api.error(`POST ${t} - HTTP ${i.status}`,{errorText:a}),new Error(`Upload failed: ${a}`)}const s=await i.json();return D.api.timed(`POST ${t} -> ${i.status}`,n,s),s}async function cb(e,t,n){const r=new URLSearchParams({query:e});return t&&r.set("file_types",t),r.set("max_results",String(n)),Pe("GET",`/files/search?${r}`)}async function db(e,t){const n=new URLSearchParams({path:e});return Pe("GET",`/files/preview?${n}`)}async function fb(){return Pe("POST","/tunnel/start")}async function hb(){return Pe("POST","/tunnel/stop")}async function n1(){return Pe("GET","/tunnel/status")}async function mb(){return Pe("GET","/mcp/status")}function mn(e){return e.replace(/-/g,"").slice(0,7)}function pb(e,t){const n=t.replace(/^#/,"").toLowerCase();if(!n||n.length<4)return null;const r=e.find(i=>i.id.replace(/-/g,"").toLowerCase().startsWith(n));return r?r.id:null}const r1=""+new URL("gaia-robot-NKaQnEIp.png",import.meta.url).href;function gb(e,t){e.stopPropagation(),e.preventDefault();const n=mn(t),r=`${window.location.origin}${window.location.pathname}#${n}`;navigator.clipboard.writeText(r).then(()=>{D.ui.info(`Copied session link: ${r}`)}).catch(()=>{D.ui.warn("Clipboard write failed")})}function uh({session:e,isActive:t,isPendingDelete:n,isDeleting:r,onSelect:i,onKeyDown:s,onDelete:a,formatTime:u}){const[l,d]=S.useState(!1),h=S.useCallback(f=>{gb(f,e.id),d(!0),setTimeout(()=>d(!1),1500)},[e.id]);return c.jsxs("div",{className:`session-item ${t?"active":""} ${r?"session-deleting":""}`,onClick:()=>i(e.id),onKeyDown:f=>s(f,e.id),role:"button",tabIndex:0,"aria-label":`Open task: ${e.title}`,"aria-current":t?"true":void 0,children:[c.jsx("span",{className:"session-title",children:e.title}),c.jsxs("a",{className:`session-hash ${l?"copied":""}`,href:`#${mn(e.id)}`,onClick:h,title:l?"Copied!":`Copy link #${mn(e.id)}`,"aria-label":`Copy link for session ${mn(e.id)}`,children:["#",mn(e.id)]}),c.jsx("span",{className:"session-time",children:u(e.updated_at)}),n?c.jsxs("button",{className:"session-delete confirm",onClick:f=>a(f,e.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&a(f,e.id)},title:"Click to confirm delete","aria-label":`Confirm delete: ${e.title}`,children:[c.jsx(_u,{size:12}),c.jsx("span",{className:"confirm-label",children:"Delete?"})]}):c.jsx("button",{className:"session-delete",onClick:f=>a(f,e.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&a(f,e.id)},title:"Delete","aria-label":`Delete: ${e.title}`,children:c.jsx(_u,{size:13})})]})}function Eb({onNewTask:e,tunnelActive:t,tunnelLoading:n,onMobileToggle:r}){const{sessions:i,currentSessionId:s,setCurrentSession:a,removeSession:u,addSession:l,setMessages:d,theme:h,toggleTheme:f,setShowSettings:p,sidebarOpen:m,setSidebarOpen:T,setLoadingMessages:x,sidebarCollapsed:I,toggleSidebarCollapsed:g,sidebarWidth:E,setSidebarWidth:y,addPendingDelete:v,removePendingDelete:O}=we(),[A,F]=S.useState(""),[H,K]=S.useState(null),[w,Y]=S.useState(null),[te,ce]=S.useState(!1),[le,ue]=S.useState(null),j=S.useRef(null),z=S.useRef(null),P=S.useRef(null);S.useEffect(()=>{const R=()=>{var W;I?(g(),requestAnimationFrame(()=>{var de;return(de=z.current)==null?void 0:de.focus()})):(W=z.current)==null||W.focus()};return window.addEventListener("gaia:focus-search",R),()=>window.removeEventListener("gaia:focus-search",R)},[I,g]);const G=A?i.filter(R=>R.title.toLowerCase().includes(A.toLowerCase())):i,_=S.useMemo(()=>{if(A)return null;const R=new Date,W=new Date(R.getFullYear(),R.getMonth(),R.getDate()).getTime(),de=W-864e5,Ae=W-7*864e5,be=[{label:"Today",sessions:[]},{label:"Yesterday",sessions:[]},{label:"Previous 7 Days",sessions:[]},{label:"Older",sessions:[]}];for(const Re of G){const ze=new Date(Re.updated_at).getTime();ze>=W?be[0].sessions.push(Re):ze>=de?be[1].sessions.push(Re):ze>=Ae?be[2].sessions.push(Re):be[3].sessions.push(Re)}return be.filter(Re=>Re.sessions.length>0)},[G,A]),Z=S.useCallback(async R=>{var de;if(R===s)return;const W=((de=i.find(Ae=>Ae.id===R))==null?void 0:de.title)||"?";D.nav.info(`Selecting session: "${W}" (${R})`),a(R),d([]),x(!0),window.innerWidth<=768&&T(!1);try{const Ae=await us(R);if(!(we.getState().currentSessionId===R)){D.nav.debug(`Discarding stale message load for session=${R} (user switched away)`);return}d(Ae.messages||[]),D.nav.info(`Loaded ${(Ae.messages||[]).length} message(s) for "${W}"`)}catch(Ae){D.nav.error(`Failed to load messages for session ${R}`,Ae),d([])}finally{x(!1)}},[s,i,a,d,T,x]),fe=S.useCallback(async(R,W)=>{R.stopPropagation(),R.preventDefault();const de=i.find(be=>be.id===W),Ae=(de==null?void 0:de.title)||"?";if(H===W){D.chat.info(`Deleting session: "${Ae}" (${W})`),K(null),Y(W),v(W),e1(W).then(()=>{D.chat.info(`Session deleted from backend: "${Ae}"`),O(W)}).catch(Re=>{D.chat.warn(`Backend delete failed for "${Ae}"`,Re),O(W)}),le!=null&&le.timer&&clearTimeout(le.timer);const be=setTimeout(()=>{ue(null)},5e3);de&&ue({session:de,timer:be}),setTimeout(()=>{u(W),Y(null)},250);return}D.chat.debug(`Delete pending confirmation for: "${Ae}" (${W})`),K(W),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>K(be=>be===W?null:be),3e3)},[H,i,u,le,v,O]),N=S.useCallback(()=>{if(!le)return;clearTimeout(le.timer);const{session:R}=le;D.chat.info(`Undo delete: re-creating "${R.title}"`),O(R.id),Zp({title:R.title}).then(W=>{l(W),D.chat.info(`Undo delete: re-created "${W.title}" (new id=${W.id})`)}).catch(W=>{D.chat.warn(`Undo delete failed for "${R.title}"`,W)}),ue(null)},[le,l,O]);S.useEffect(()=>{if(!H)return;const R=()=>K(null);return window.addEventListener("click",R,{once:!0}),()=>window.removeEventListener("click",R)},[H]);const Ne=S.useCallback((R,W)=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),Z(W))},[Z]),re=S.useRef(null),me=S.useCallback(R=>{R.preventDefault(),ce(!0),D.ui.debug("Sidebar resize started");const W=R.clientX,de=E,Ae=Re=>{const ze=Re.clientX-W;y(de+ze)},be=()=>{ce(!1),document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",be),document.body.style.cursor="",document.body.style.userSelect="",re.current=null,D.ui.debug("Sidebar resize ended")};re.current=be,document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",be)},[E,y]);S.useEffect(()=>()=>{re.current&&re.current(),P.current&&clearTimeout(P.current)},[]);const ve=R=>{const W=new Date(R),Ae=new Date().getTime()-W.getTime(),be=Math.floor(Ae/6e4);if(be<1)return"now";if(be<60)return`${be}m`;const Re=Math.floor(be/60);if(Re<24)return`${Re}h`;const ze=Math.floor(Re/24);return ze<7?`${ze}d`:W.toLocaleDateString(void 0,{month:"short",day:"numeric"})},He=typeof window<"u"&&window.innerWidth<=768?void 0:{width:I?56:E,minWidth:I?56:E};return c.jsxs("aside",{ref:j,className:`sidebar ${m?"open":""} ${I?"collapsed":""} ${te?"resizing":""}`,style:He,role:"complementary","aria-label":"Task sidebar",children:[c.jsxs("div",{className:"sidebar-top",children:[c.jsxs("div",{className:"sidebar-brand",children:[c.jsx("div",{className:"brand-icon","aria-hidden":"true",children:c.jsx("img",{src:r1,alt:"",width:28,height:28})}),c.jsxs("div",{className:"brand-text",children:[c.jsx("span",{className:"brand-name",children:"GAIA"}),c.jsxs("span",{className:"brand-version",children:["v","0.17.1"]}),c.jsx("span",{className:"beta-badge",children:"BETA"})]})]}),c.jsxs("div",{className:"sidebar-top-actions",children:[c.jsx("button",{className:"new-task-btn",onClick:e,title:"New Task","aria-label":"New Task",children:c.jsx(oy,{size:18})}),c.jsx("button",{className:"collapse-btn",onClick:g,title:I?"Expand sidebar":"Collapse sidebar","aria-label":I?"Expand sidebar":"Collapse sidebar",children:I?c.jsx(ay,{size:18}):c.jsx(sy,{size:18})})]})]}),c.jsxs("div",{className:"sidebar-search",children:[c.jsx(Pr,{size:14,className:"search-icon","aria-hidden":"true"}),c.jsx("input",{ref:z,type:"text",placeholder:"Search... (Ctrl+K)",value:A,onChange:R=>F(R.target.value),"aria-label":"Search tasks"})]}),c.jsxs("nav",{className:"session-list","aria-label":"Task sessions",children:[G.length===0&&c.jsx("div",{className:"empty-hint",children:A?"No results":"No tasks yet"}),_?_.map(R=>c.jsxs("div",{children:[c.jsx("div",{className:"session-group-label",children:R.label}),R.sessions.map(W=>c.jsx(uh,{session:W,isActive:W.id===s,isPendingDelete:H===W.id,isDeleting:w===W.id,onSelect:Z,onKeyDown:Ne,onDelete:fe,formatTime:ve},W.id))]},R.label)):G.map(R=>c.jsx(uh,{session:R,isActive:R.id===s,isPendingDelete:H===R.id,isDeleting:w===R.id,onSelect:Z,onKeyDown:Ne,onDelete:fe,formatTime:ve},R.id))]}),c.jsxs("div",{className:"sidebar-bottom",children:[c.jsxs("div",{className:"privacy-badge",children:[c.jsx("span",{className:"privacy-dot","aria-hidden":"true"}),c.jsx("span",{children:"100% Local"}),c.jsxs("span",{className:"version-badge",children:["v","0.17.1"]})]}),c.jsxs("div",{className:"sidebar-actions",children:[r&&c.jsx("button",{className:`btn-icon mobile-toggle-btn ${t?"active":""} ${n?"loading":""}`,onClick:r,disabled:n,title:t?"Stop mobile access":"Enable mobile access","aria-label":t?"Stop mobile access":"Enable mobile access",children:c.jsx(Vp,{size:17})}),c.jsx("button",{className:"btn-icon",onClick:()=>p(!0),title:"Settings","aria-label":"Settings",children:c.jsx(fy,{size:17})}),c.jsx("button",{className:"btn-icon",onClick:f,title:"Toggle theme","aria-label":`Switch to ${h==="dark"?"light":"dark"} theme`,children:h==="dark"?c.jsx(py,{size:17}):c.jsx(iy,{size:17})})]})]}),!I&&c.jsx("div",{className:"sidebar-resize-handle",onMouseDown:me,title:"Drag to resize sidebar","aria-hidden":"true"}),le&&c.jsxs("div",{className:"toast toast-undo",role:"status",children:["Deleted “",le.session.title,"”",c.jsx("span",{className:"toast-action",onClick:N,children:"Undo"})]})]})}function lh(e){const t=[],n=String(e||"");let r=n.indexOf(","),i=0,s=!1;for(;!s;){r===-1&&(r=n.length,s=!0);const a=n.slice(i,r).trim();(a||!s)&&t.push(a),i=r+1,r=n.indexOf(",",i)}return t}function i1(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Tb=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yb=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bb={};function oh(e,t){return(bb.jsx?yb:Tb).test(e)}const xb=/[ \t\n\f\r]/g;function _b(e){return typeof e=="object"?e.type==="text"?ch(e.value):!1:ch(e)}function ch(e){return e.replace(xb,"")===""}class na{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}na.prototype.normal={};na.prototype.property={};na.prototype.space=void 0;function s1(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new na(n,r,t)}function Vs(e){return e.toLowerCase()}class Ut{constructor(t,n){this.attribute=n,this.property=t}}Ut.prototype.attribute="";Ut.prototype.booleanish=!1;Ut.prototype.boolean=!1;Ut.prototype.commaOrSpaceSeparated=!1;Ut.prototype.commaSeparated=!1;Ut.prototype.defined=!1;Ut.prototype.mustUseProperty=!1;Ut.prototype.number=!1;Ut.prototype.overloadedBoolean=!1;Ut.prototype.property="";Ut.prototype.spaceSeparated=!1;Ut.prototype.space=void 0;let kb=0;const pe=Qr(),tt=Qr(),Jo=Qr(),Q=Qr(),je=Qr(),_i=Qr(),$t=Qr();function Qr(){return 2**++kb}const Zo=Object.freeze(Object.defineProperty({__proto__:null,boolean:pe,booleanish:tt,commaOrSpaceSeparated:$t,commaSeparated:_i,number:Q,overloadedBoolean:Jo,spaceSeparated:je},Symbol.toStringTag,{value:"Module"})),jl=Object.keys(Zo);class gd extends Ut{constructor(t,n,r,i){let s=-1;if(super(t,n),dh(this,"space",i),typeof r=="number")for(;++s<jl.length;){const a=jl[s];dh(this,jl[s],(r&Zo[a])===Zo[a])}}}gd.prototype.defined=!0;function dh(e,t,n){n&&(e[t]=n)}function Bi(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new gd(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Vs(r)]=r,n[Vs(s.attribute)]=r}return new na(t,n,e.space)}const a1=Bi({properties:{ariaActiveDescendant:null,ariaAtomic:tt,ariaAutoComplete:null,ariaBusy:tt,ariaChecked:tt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:je,ariaCurrent:null,ariaDescribedBy:je,ariaDetails:null,ariaDisabled:tt,ariaDropEffect:je,ariaErrorMessage:null,ariaExpanded:tt,ariaFlowTo:je,ariaGrabbed:tt,ariaHasPopup:null,ariaHidden:tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:je,ariaLevel:Q,ariaLive:null,ariaModal:tt,ariaMultiLine:tt,ariaMultiSelectable:tt,ariaOrientation:null,ariaOwns:je,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:tt,ariaReadOnly:tt,ariaRelevant:null,ariaRequired:tt,ariaRoleDescription:je,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:tt,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function u1(e,t){return t in e?e[t]:t}function l1(e,t){return u1(e,t.toLowerCase())}const Sb=Bi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_i,acceptCharset:je,accessKey:je,action:null,allow:null,allowFullScreen:pe,allowPaymentRequest:pe,allowUserMedia:pe,alt:null,as:null,async:pe,autoCapitalize:null,autoComplete:je,autoFocus:pe,autoPlay:pe,blocking:je,capture:null,charSet:null,checked:pe,cite:null,className:je,cols:Q,colSpan:null,content:null,contentEditable:tt,controls:pe,controlsList:je,coords:Q|_i,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pe,defer:pe,dir:null,dirName:null,disabled:pe,download:Jo,draggable:tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pe,formTarget:null,headers:je,height:Q,hidden:Jo,high:Q,href:null,hrefLang:null,htmlFor:je,httpEquiv:je,id:null,imageSizes:null,imageSrcSet:null,inert:pe,inputMode:null,integrity:null,is:null,isMap:pe,itemId:null,itemProp:je,itemRef:je,itemScope:pe,itemType:je,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pe,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:pe,muted:pe,name:null,nonce:null,noModule:pe,noValidate:pe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:pe,optimum:Q,pattern:null,ping:je,placeholder:null,playsInline:pe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pe,referrerPolicy:null,rel:je,required:pe,reversed:pe,rows:Q,rowSpan:Q,sandbox:je,scope:null,scoped:pe,seamless:pe,selected:pe,shadowRootClonable:pe,shadowRootDelegatesFocus:pe,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:pe,useMap:null,value:tt,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:je,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pe,declare:pe,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:pe,noHref:pe,noShade:pe,noWrap:pe,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:tt,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:pe,disableRemotePlayback:pe,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:l1}),Cb=Bi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:$t,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:je,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:pe,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_i,g2:_i,glyphName:_i,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:$t,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:je,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$t,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$t,rev:$t,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$t,requiredFeatures:$t,requiredFonts:$t,requiredFormats:$t,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:$t,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$t,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$t,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:u1}),o1=Bi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),c1=Bi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:l1}),d1=Bi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Nb={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ab=/[A-Z]/g,fh=/-[a-z]/g,wb=/^data[-\w.:]+$/i;function Zu(e,t){const n=Vs(t);let r=t,i=Ut;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&wb.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(fh,Ib);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!fh.test(s)){let a=s.replace(Ab,vb);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=gd}return new i(r,t)}function vb(e){return"-"+e.toLowerCase()}function Ib(e){return e.charAt(1).toUpperCase()}const ra=s1([a1,Sb,o1,c1,d1],"html"),Sr=s1([a1,Cb,o1,c1,d1],"svg");function hh(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function f1(e){return e.join(" ").trim()}var Ed={},mh=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Lb=/\n/g,Db=/^\s*/,Rb=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Ob=/^:\s*/,Pb=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Mb=/^[;\s]*/,Fb=/^\s+|\s+$/g,Bb=`
379
379
  `,ph="/",gh="*",Lr="",jb="comment",Ub="declaration";function Hb(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(T){var x=T.match(Lb);x&&(n+=x.length);var I=T.lastIndexOf(Bb);r=~I?T.length-I:r+T.length}function s(){var T={line:n,column:r};return function(x){return x.position=new a(T),d(),x}}function a(T){this.start=T,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function u(T){var x=new Error(t.source+":"+n+":"+r+": "+T);if(x.reason=T,x.filename=t.source,x.line=n,x.column=r,x.source=e,!t.silent)throw x}function l(T){var x=T.exec(e);if(x){var I=x[0];return i(I),e=e.slice(I.length),x}}function d(){l(Db)}function h(T){var x;for(T=T||[];x=f();)x!==!1&&T.push(x);return T}function f(){var T=s();if(!(ph!=e.charAt(0)||gh!=e.charAt(1))){for(var x=2;Lr!=e.charAt(x)&&(gh!=e.charAt(x)||ph!=e.charAt(x+1));)++x;if(x+=2,Lr===e.charAt(x-1))return u("End of comment missing");var I=e.slice(2,x-2);return r+=2,i(I),e=e.slice(x),r+=2,T({type:jb,comment:I})}}function p(){var T=s(),x=l(Rb);if(x){if(f(),!l(Ob))return u("property missing ':'");var I=l(Pb),g=T({type:Ub,property:Eh(x[0].replace(mh,Lr)),value:I?Eh(I[0].replace(mh,Lr)):Lr});return l(Mb),g}}function m(){var T=[];h(T);for(var x;x=p();)x!==!1&&(T.push(x),h(T));return T}return d(),m()}function Eh(e){return e?e.replace(Fb,Lr):Lr}var zb=Hb,$b=Ka&&Ka.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ed,"__esModule",{value:!0});Ed.default=Vb;const Yb=$b(zb);function Vb(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Yb.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:a,value:u}=s;i?t(a,u,s):u&&(n=n||{},n[a]=u)}),n}var el={};Object.defineProperty(el,"__esModule",{value:!0});el.camelCase=void 0;var Wb=/^--[a-zA-Z0-9_-]+$/,qb=/-([a-z])/g,Qb=/^[^-]+$/,Gb=/^-(webkit|moz|ms|o|khtml)-/,Kb=/^-(ms)-/,Xb=function(e){return!e||Qb.test(e)||Wb.test(e)},Jb=function(e,t){return t.toUpperCase()},Th=function(e,t){return"".concat(t,"-")},Zb=function(e,t){return t===void 0&&(t={}),Xb(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Kb,Th):e=e.replace(Gb,Th),e.replace(qb,Jb))};el.camelCase=Zb;var ex=Ka&&Ka.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},tx=ex(Ed),nx=el;function ec(e,t){var n={};return!e||typeof e!="string"||(0,tx.default)(e,function(r,i){r&&i&&(n[(0,nx.camelCase)(r,t)]=i)}),n}ec.default=ec;var rx=ec;const ix=Ou(rx),tl=h1("end"),Ln=h1("start");function h1(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function sx(e){const t=Ln(e),n=tl(e);if(t&&n)return{start:t,end:n}}function Ts(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?yh(e.position):"start"in e||"end"in e?yh(e):"line"in e||"column"in e?tc(e):""}function tc(e){return bh(e&&e.line)+":"+bh(e&&e.column)}function yh(e){return tc(e&&e.start)+"-"+tc(e&&e.end)}function bh(e){return e&&typeof e=="number"?e:1}class xt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},a=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const u=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=Ts(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}xt.prototype.file="";xt.prototype.name="";xt.prototype.reason="";xt.prototype.message="";xt.prototype.stack="";xt.prototype.column=void 0;xt.prototype.line=void 0;xt.prototype.ancestors=void 0;xt.prototype.cause=void 0;xt.prototype.fatal=void 0;xt.prototype.place=void 0;xt.prototype.ruleId=void 0;xt.prototype.source=void 0;const Td={}.hasOwnProperty,ax=new Map,ux=/[A-Z]/g,lx=new Set(["table","tbody","thead","tfoot","tr"]),ox=new Set(["td","th"]),m1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cx(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Tx(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Ex(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Sr:ra,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=p1(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function p1(e,t,n){if(t.type==="element")return dx(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return fx(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return mx(e,t,n);if(t.type==="mdxjsEsm")return hx(e,t);if(t.type==="root")return px(e,t,n);if(t.type==="text")return gx(e,t)}function dx(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Sr,e.schema=i),e.ancestors.push(t);const s=E1(e,t.tagName,!1),a=yx(e,t);let u=bd(e,t);return lx.has(t.tagName)&&(u=u.filter(function(l){return typeof l=="string"?!_b(l):!0})),g1(e,a,s,t),yd(a,u),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function fx(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Ws(e,t.position)}function hx(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ws(e,t.position)}function mx(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Sr,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:E1(e,t.name,!0),a=bx(e,t),u=bd(e,t);return g1(e,a,s,t),yd(a,u),e.ancestors.pop(),e.schema=r,e.create(t,s,a,n)}function px(e,t,n){const r={};return yd(r,bd(e,t)),e.create(t,e.Fragment,r,n)}function gx(e,t){return t.value}function g1(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Ex(e,t,n){return r;function r(i,s,a,u){const d=Array.isArray(a.children)?n:t;return u?d(s,a,u):d(s,a)}}function Tx(e,t){return n;function n(r,i,s,a){const u=Array.isArray(s.children),l=Ln(r);return t(i,s,a,u,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function yx(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Td.call(t.properties,i)){const s=xx(e,i,t.properties[i]);if(s){const[a,u]=s;e.tableCellAlignToStyle&&a==="align"&&typeof u=="string"&&ox.has(t.tagName)?r=u:n[a]=u}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function bx(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const a=s.expression;a.type;const u=a.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else Ws(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const u=r.value.data.estree.body[0];u.type,s=e.evaluater.evaluateExpression(u.expression)}else Ws(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function bd(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:ax;for(;++r<t.children.length;){const s=t.children[r];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const d=i.get(l)||0;a=l+"-"+d,i.set(l,d+1)}}const u=p1(e,s,a);u!==void 0&&n.push(u)}return n}function xx(e,t,n){const r=Zu(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?i1(n):f1(n)),r.property==="style"){let i=typeof n=="object"?n:_x(e,String(n));return e.stylePropertyNameCase==="css"&&(i=kx(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Nb[r.property]||r.property:r.attribute,n]}}function _x(e,t){try{return ix(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new xt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=m1+"#cannot-parse-style-attribute",i}}function E1(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const u=oh(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:u,computed:!!(s&&u.type==="Literal"),optional:!1}:u}r=a}else r=oh(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Td.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ws(e)}function Ws(e,t){const n=new xt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=m1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function kx(e){const t={};let n;for(n in e)Td.call(e,n)&&(t[Sx(n)]=e[n]);return t}function Sx(e){let t=e.replace(ux,Cx);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Cx(e){return"-"+e.toLowerCase()}const Ul={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Nx={};function xd(e,t){const n=Nx,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return T1(e,r,i)}function T1(e,t,n){if(Ax(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return xh(e.children,t,n)}return Array.isArray(e)?xh(e,t,n):""}function xh(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=T1(e[i],t,n);return r.join("")}function Ax(e){return!!(e&&typeof e=="object")}const _h=document.createElement("i");function _d(e){const t="&"+e+";";_h.innerHTML=t;const n=_h.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function qt(e,t,n,r){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);s<r.length;)a=r.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function en(e,t){return e.length>0?(qt(e,e.length,0,t),e):t}const kh={}.hasOwnProperty;function y1(e){const t={};let n=-1;for(;++n<e.length;)wx(t,e[n]);return t}function wx(e,t){let n;for(n in t){const i=(kh.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let a;if(s)for(a in s){kh.call(i,a)||(i[a]=[]);const u=s[a];vx(i[a],Array.isArray(u)?u:u?[u]:[])}}}function vx(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);qt(e,0,0,r)}function b1(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function En(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const At=Cr(/[A-Za-z]/),yt=Cr(/[\dA-Za-z]/),Ix=Cr(/[#-'*+\--9=?A-Z^-~]/);function Cu(e){return e!==null&&(e<32||e===127)}const nc=Cr(/\d/),Lx=Cr(/[\dA-Fa-f]/),Dx=Cr(/[!-/:-@[-`{-~]/);function oe(e){return e!==null&&e<-2}function Be(e){return e!==null&&(e<0||e===32)}function Te(e){return e===-2||e===-1||e===32}const nl=Cr(new RegExp("\\p{P}|\\p{S}","u")),Vr=Cr(/\s/);function Cr(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ji(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let a="";if(s===37&&yt(e.charCodeAt(n+1))&&yt(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const u=e.charCodeAt(n+1);s<56320&&u>56319&&u<57344?(a=String.fromCharCode(s,u),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ke(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Te(l)?(e.enter(n),u(l)):t(l)}function u(l){return Te(l)&&s++<i?(e.consume(l),u):(e.exit(n),t(l))}}const Rx={tokenize:Ox};function Ox(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),ke(e,t,"linePrefix")}function i(u){return e.enter("paragraph"),s(u)}function s(u){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(u)}function a(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return oe(u)?(e.consume(u),e.exit("chunkText"),s):(e.consume(u),a)}}const Px={tokenize:Mx},Sh={tokenize:Fx};function Mx(e){const t=this,n=[];let r=0,i,s,a;return u;function u(y){if(r<n.length){const v=n[r];return t.containerState=v[1],e.attempt(v[0].continuation,l,d)(y)}return d(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&E();const v=t.events.length;let O=v,A;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){A=t.events[O][1].end;break}g(r);let F=v;for(;F<t.events.length;)t.events[F][1].end={...A},F++;return qt(t.events,O+1,0,t.events.slice(v)),t.events.length=F,d(y)}return u(y)}function d(y){if(r===n.length){if(!i)return p(y);if(i.currentConstruct&&i.currentConstruct.concrete)return T(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sh,h,f)(y)}function h(y){return i&&E(),g(r),p(y)}function f(y){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,T(y)}function p(y){return t.containerState={},e.attempt(Sh,m,T)(y)}function m(y){return r++,n.push([t.currentConstruct,t.containerState]),p(y)}function T(y){if(y===null){i&&E(),g(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(y)}function x(y){if(y===null){I(e.exit("chunkFlow"),!0),g(0),e.consume(y);return}return oe(y)?(e.consume(y),I(e.exit("chunkFlow")),r=0,t.interrupt=void 0,u):(e.consume(y),x)}function I(y,v){const O=t.sliceStream(y);if(v&&O.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(O),t.parser.lazy[y.start.line]){let A=i.events.length;for(;A--;)if(i.events[A][1].start.offset<a&&(!i.events[A][1].end||i.events[A][1].end.offset>a))return;const F=t.events.length;let H=F,K,w;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(K){w=t.events[H][1].end;break}K=!0}for(g(r),A=F;A<t.events.length;)t.events[A][1].end={...w},A++;qt(t.events,H+1,0,t.events.slice(F)),t.events.length=A}}function g(y){let v=n.length;for(;v-- >y;){const O=n[v];t.containerState=O[1],O[0].exit.call(t,e)}n.length=y}function E(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Fx(e,t,n){return ke(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Di(e){if(e===null||Be(e)||Vr(e))return 1;if(nl(e))return 2}function rl(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const rc={name:"attention",resolveAll:Bx,tokenize:jx};function Bx(e,t){let n=-1,r,i,s,a,u,l,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};Ch(f,-l),Ch(p,l),a={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},u={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...a.start},end:{...u.end}},e[r][1].end={...a.start},e[n][1].start={...u.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=en(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=en(d,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),d=en(d,rl(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=en(d,[["exit",s,t],["enter",u,t],["exit",u,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=en(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,qt(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function jx(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Di(r);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),u(l)}function u(l){if(l===s)return e.consume(l),u;const d=e.exit("attentionSequence"),h=Di(l),f=!h||h===2&&i||n.includes(l),p=!i||i===2&&h||n.includes(r);return d._open=!!(s===42?f:f&&(i||!p)),d._close=!!(s===42?p:p&&(h||!f)),t(l)}}function Ch(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ux={name:"autolink",tokenize:Hx};function Hx(e,t,n){let r=0;return i;function i(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(m){return At(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||yt(m)?(r=1,u(m)):d(m)}function u(m){return m===58?(e.consume(m),r=0,l):(m===43||m===45||m===46||yt(m))&&r++<32?(e.consume(m),u):(r=0,d(m))}function l(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||Cu(m)?n(m):(e.consume(m),l)}function d(m){return m===64?(e.consume(m),h):Ix(m)?(e.consume(m),d):n(m)}function h(m){return yt(m)?f(m):n(m)}function f(m){return m===46?(e.consume(m),r=0,h):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||yt(m))&&r++<63){const T=m===45?p:f;return e.consume(m),T}return n(m)}}const ia={partial:!0,tokenize:zx};function zx(e,t,n){return r;function r(s){return Te(s)?ke(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||oe(s)?t(s):n(s)}}const x1={continuation:{tokenize:Yx},exit:Vx,name:"blockQuote",tokenize:$x};function $x(e,t,n){const r=this;return i;function i(a){if(a===62){const u=r.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return n(a)}function s(a){return Te(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Yx(e,t,n){const r=this;return i;function i(a){return Te(a)?ke(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(x1,t,n)(a)}}function Vx(e){e.exit("blockQuote")}const _1={name:"characterEscape",tokenize:Wx};function Wx(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Dx(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const k1={name:"characterReference",tokenize:qx};function qx(e,t,n){const r=this;let i=0,s,a;return u;function u(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),s=31,a=yt,h(f))}function d(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Lx,h):(e.enter("characterReferenceValue"),s=7,a=nc,h(f))}function h(f){if(f===59&&i){const p=e.exit("characterReferenceValue");return a===yt&&!_d(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&i++<s?(e.consume(f),h):n(f)}}const Nh={partial:!0,tokenize:Gx},Ah={concrete:!0,name:"codeFenced",tokenize:Qx};function Qx(e,t,n){const r=this,i={partial:!0,tokenize:O};let s=0,a=0,u;return l;function l(A){return d(A)}function d(A){const F=r.events[r.events.length-1];return s=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,u=A,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(A)}function h(A){return A===u?(a++,e.consume(A),h):a<3?n(A):(e.exit("codeFencedFenceSequence"),Te(A)?ke(e,f,"whitespace")(A):f(A))}function f(A){return A===null||oe(A)?(e.exit("codeFencedFence"),r.interrupt?t(A):e.check(Nh,x,v)(A)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(A))}function p(A){return A===null||oe(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(A)):Te(A)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ke(e,m,"whitespace")(A)):A===96&&A===u?n(A):(e.consume(A),p)}function m(A){return A===null||oe(A)?f(A):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),T(A))}function T(A){return A===null||oe(A)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(A)):A===96&&A===u?n(A):(e.consume(A),T)}function x(A){return e.attempt(i,v,I)(A)}function I(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),g}function g(A){return s>0&&Te(A)?ke(e,E,"linePrefix",s+1)(A):E(A)}function E(A){return A===null||oe(A)?e.check(Nh,x,v)(A):(e.enter("codeFlowValue"),y(A))}function y(A){return A===null||oe(A)?(e.exit("codeFlowValue"),E(A)):(e.consume(A),y)}function v(A){return e.exit("codeFenced"),t(A)}function O(A,F,H){let K=0;return w;function w(ue){return A.enter("lineEnding"),A.consume(ue),A.exit("lineEnding"),Y}function Y(ue){return A.enter("codeFencedFence"),Te(ue)?ke(A,te,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ue):te(ue)}function te(ue){return ue===u?(A.enter("codeFencedFenceSequence"),ce(ue)):H(ue)}function ce(ue){return ue===u?(K++,A.consume(ue),ce):K>=a?(A.exit("codeFencedFenceSequence"),Te(ue)?ke(A,le,"whitespace")(ue):le(ue)):H(ue)}function le(ue){return ue===null||oe(ue)?(A.exit("codeFencedFence"),F(ue)):H(ue)}}}function Gx(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Hl={name:"codeIndented",tokenize:Xx},Kx={partial:!0,tokenize:Jx};function Xx(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),ke(e,s,"linePrefix",5)(d)}function s(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?l(d):oe(d)?e.attempt(Kx,a,l)(d):(e.enter("codeFlowValue"),u(d))}function u(d){return d===null||oe(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),u)}function l(d){return e.exit("codeIndented"),t(d)}}function Jx(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):oe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):ke(e,s,"linePrefix",5)(a)}function s(a){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(a):oe(a)?i(a):n(a)}}const Zx={name:"codeText",previous:t_,resolve:e_,tokenize:n_};function e_(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function t_(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function n_(e,t,n){let r=0,i,s;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),u(f)}function u(f){return f===96?(e.consume(f),r++,u):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,h(f)):oe(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||oe(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),d)}function h(f){return f===96?(e.consume(f),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",d(f))}}class r_{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Zi(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Zi(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Zi(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Zi(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Zi(this.left,n.reverse())}}}function Zi(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function S1(e){const t={};let n=-1,r,i,s,a,u,l,d;const h=new r_(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,i_(h,n)),n=t[n],d=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(a=h.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},u=h.slice(i,n),u.unshift(r),h.splice(i,n-i+1,u))}}return qt(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function i_(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const u=a.events,l=[],d={};let h,f,p=-1,m=n,T=0,x=0;const I=[x];for(;m;){for(;e.get(++i)[1]!==m;);s.push(i),m._tokenizer||(h=r.sliceStream(m),m.next||h.push(null),f&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=n;++p<u.length;)u[p][0]==="exit"&&u[p-1][0]==="enter"&&u[p][1].type===u[p-1][1].type&&u[p][1].start.line!==u[p][1].end.line&&(x=p+1,I.push(x),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):I.pop(),p=I.length;p--;){const g=u.slice(I[p],I[p+1]),E=s.pop();l.push([E,E+g.length-1]),e.splice(E,2,g)}for(l.reverse(),p=-1;++p<l.length;)d[T+l[p][0]]=T+l[p][1],T+=l[p][1]-l[p][0]-1;return d}const s_={resolve:u_,tokenize:l_},a_={partial:!0,tokenize:o_};function u_(e){return S1(e),e}function l_(e,t){let n;return r;function r(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(u)}function i(u){return u===null?s(u):oe(u)?e.check(a_,a,s)(u):(e.consume(u),i)}function s(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function a(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function o_(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ke(e,s,"linePrefix")}function s(a){if(a===null||oe(a))return n(a);const u=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function C1(e,t,n,r,i,s,a,u,l){const d=l||Number.POSITIVE_INFINITY;let h=0;return f;function f(g){return g===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(g),e.exit(s),p):g===null||g===32||g===41||Cu(g)?n(g):(e.enter(r),e.enter(a),e.enter(u),e.enter("chunkString",{contentType:"string"}),x(g))}function p(g){return g===62?(e.enter(s),e.consume(g),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===62?(e.exit("chunkString"),e.exit(u),p(g)):g===null||g===60||oe(g)?n(g):(e.consume(g),g===92?T:m)}function T(g){return g===60||g===62||g===92?(e.consume(g),m):m(g)}function x(g){return!h&&(g===null||g===41||Be(g))?(e.exit("chunkString"),e.exit(u),e.exit(a),e.exit(r),t(g)):h<d&&g===40?(e.consume(g),h++,x):g===41?(e.consume(g),h--,x):g===null||g===32||g===40||Cu(g)?n(g):(e.consume(g),g===92?I:x)}function I(g){return g===40||g===41||g===92?(e.consume(g),x):x(g)}}function N1(e,t,n,r,i,s){const a=this;let u=0,l;return d;function d(m){return e.enter(r),e.enter(i),e.consume(m),e.exit(i),e.enter(s),h}function h(m){return u>999||m===null||m===91||m===93&&!l||m===94&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(s),e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):oe(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||oe(m)||u++>999?(e.exit("chunkString"),h(m)):(e.consume(m),l||(l=!Te(m)),m===92?p:f)}function p(m){return m===91||m===92||m===93?(e.consume(m),u++,f):f(m)}}function A1(e,t,n,r,i,s){let a;return u;function u(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),a=p===40?41:p,l):n(p)}function l(p){return p===a?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(s),d(p))}function d(p){return p===a?(e.exit(s),l(a)):p===null?n(p):oe(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),ke(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===a||p===null||oe(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?f:h)}function f(p){return p===a||p===92?(e.consume(p),h):h(p)}}function ys(e,t){let n;return r;function r(i){return oe(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Te(i)?ke(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const c_={name:"definition",tokenize:f_},d_={partial:!0,tokenize:h_};function f_(e,t,n){const r=this;let i;return s;function s(m){return e.enter("definition"),a(m)}function a(m){return N1.call(r,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function u(m){return i=En(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),l):n(m)}function l(m){return Be(m)?ys(e,d)(m):d(m)}function d(m){return C1(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function h(m){return e.attempt(d_,f,f)(m)}function f(m){return Te(m)?ke(e,p,"whitespace")(m):p(m)}function p(m){return m===null||oe(m)?(e.exit("definition"),r.parser.defined.push(i),t(m)):n(m)}}function h_(e,t,n){return r;function r(u){return Be(u)?ys(e,i)(u):n(u)}function i(u){return A1(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function s(u){return Te(u)?ke(e,a,"whitespace")(u):a(u)}function a(u){return u===null||oe(u)?t(u):n(u)}}const m_={name:"hardBreakEscape",tokenize:p_};function p_(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return oe(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const g_={name:"headingAtx",resolve:E_,tokenize:T_};function E_(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},qt(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function T_(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),s(h)}function s(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||Be(h)?(e.exit("atxHeadingSequence"),u(h)):n(h)}function u(h){return h===35?(e.enter("atxHeadingSequence"),l(h)):h===null||oe(h)?(e.exit("atxHeading"),t(h)):Te(h)?ke(e,u,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function l(h){return h===35?(e.consume(h),l):(e.exit("atxHeadingSequence"),u(h))}function d(h){return h===null||h===35||Be(h)?(e.exit("atxHeadingText"),u(h)):(e.consume(h),d)}}const y_=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],wh=["pre","script","style","textarea"],b_={concrete:!0,name:"htmlFlow",resolveTo:k_,tokenize:S_},x_={partial:!0,tokenize:N_},__={partial:!0,tokenize:C_};function k_(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function S_(e,t,n){const r=this;let i,s,a,u,l;return d;function d(N){return h(N)}function h(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),f}function f(N){return N===33?(e.consume(N),p):N===47?(e.consume(N),s=!0,x):N===63?(e.consume(N),i=3,r.interrupt?t:_):At(N)?(e.consume(N),a=String.fromCharCode(N),I):n(N)}function p(N){return N===45?(e.consume(N),i=2,m):N===91?(e.consume(N),i=5,u=0,T):At(N)?(e.consume(N),i=4,r.interrupt?t:_):n(N)}function m(N){return N===45?(e.consume(N),r.interrupt?t:_):n(N)}function T(N){const Ne="CDATA[";return N===Ne.charCodeAt(u++)?(e.consume(N),u===Ne.length?r.interrupt?t:te:T):n(N)}function x(N){return At(N)?(e.consume(N),a=String.fromCharCode(N),I):n(N)}function I(N){if(N===null||N===47||N===62||Be(N)){const Ne=N===47,re=a.toLowerCase();return!Ne&&!s&&wh.includes(re)?(i=1,r.interrupt?t(N):te(N)):y_.includes(a.toLowerCase())?(i=6,Ne?(e.consume(N),g):r.interrupt?t(N):te(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):s?E(N):y(N))}return N===45||yt(N)?(e.consume(N),a+=String.fromCharCode(N),I):n(N)}function g(N){return N===62?(e.consume(N),r.interrupt?t:te):n(N)}function E(N){return Te(N)?(e.consume(N),E):w(N)}function y(N){return N===47?(e.consume(N),w):N===58||N===95||At(N)?(e.consume(N),v):Te(N)?(e.consume(N),y):w(N)}function v(N){return N===45||N===46||N===58||N===95||yt(N)?(e.consume(N),v):O(N)}function O(N){return N===61?(e.consume(N),A):Te(N)?(e.consume(N),O):y(N)}function A(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),l=N,F):Te(N)?(e.consume(N),A):H(N)}function F(N){return N===l?(e.consume(N),l=null,K):N===null||oe(N)?n(N):(e.consume(N),F)}function H(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||Be(N)?O(N):(e.consume(N),H)}function K(N){return N===47||N===62||Te(N)?y(N):n(N)}function w(N){return N===62?(e.consume(N),Y):n(N)}function Y(N){return N===null||oe(N)?te(N):Te(N)?(e.consume(N),Y):n(N)}function te(N){return N===45&&i===2?(e.consume(N),j):N===60&&i===1?(e.consume(N),z):N===62&&i===4?(e.consume(N),Z):N===63&&i===3?(e.consume(N),_):N===93&&i===5?(e.consume(N),G):oe(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(x_,fe,ce)(N)):N===null||oe(N)?(e.exit("htmlFlowData"),ce(N)):(e.consume(N),te)}function ce(N){return e.check(__,le,fe)(N)}function le(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),ue}function ue(N){return N===null||oe(N)?ce(N):(e.enter("htmlFlowData"),te(N))}function j(N){return N===45?(e.consume(N),_):te(N)}function z(N){return N===47?(e.consume(N),a="",P):te(N)}function P(N){if(N===62){const Ne=a.toLowerCase();return wh.includes(Ne)?(e.consume(N),Z):te(N)}return At(N)&&a.length<8?(e.consume(N),a+=String.fromCharCode(N),P):te(N)}function G(N){return N===93?(e.consume(N),_):te(N)}function _(N){return N===62?(e.consume(N),Z):N===45&&i===2?(e.consume(N),_):te(N)}function Z(N){return N===null||oe(N)?(e.exit("htmlFlowData"),fe(N)):(e.consume(N),Z)}function fe(N){return e.exit("htmlFlow"),t(N)}}function C_(e,t,n){const r=this;return i;function i(a){return oe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):n(a)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function N_(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ia,t,n)}}const A_={name:"htmlText",tokenize:w_};function w_(e,t,n){const r=this;let i,s,a;return u;function u(_){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(_),l}function l(_){return _===33?(e.consume(_),d):_===47?(e.consume(_),O):_===63?(e.consume(_),y):At(_)?(e.consume(_),H):n(_)}function d(_){return _===45?(e.consume(_),h):_===91?(e.consume(_),s=0,T):At(_)?(e.consume(_),E):n(_)}function h(_){return _===45?(e.consume(_),m):n(_)}function f(_){return _===null?n(_):_===45?(e.consume(_),p):oe(_)?(a=f,z(_)):(e.consume(_),f)}function p(_){return _===45?(e.consume(_),m):f(_)}function m(_){return _===62?j(_):_===45?p(_):f(_)}function T(_){const Z="CDATA[";return _===Z.charCodeAt(s++)?(e.consume(_),s===Z.length?x:T):n(_)}function x(_){return _===null?n(_):_===93?(e.consume(_),I):oe(_)?(a=x,z(_)):(e.consume(_),x)}function I(_){return _===93?(e.consume(_),g):x(_)}function g(_){return _===62?j(_):_===93?(e.consume(_),g):x(_)}function E(_){return _===null||_===62?j(_):oe(_)?(a=E,z(_)):(e.consume(_),E)}function y(_){return _===null?n(_):_===63?(e.consume(_),v):oe(_)?(a=y,z(_)):(e.consume(_),y)}function v(_){return _===62?j(_):y(_)}function O(_){return At(_)?(e.consume(_),A):n(_)}function A(_){return _===45||yt(_)?(e.consume(_),A):F(_)}function F(_){return oe(_)?(a=F,z(_)):Te(_)?(e.consume(_),F):j(_)}function H(_){return _===45||yt(_)?(e.consume(_),H):_===47||_===62||Be(_)?K(_):n(_)}function K(_){return _===47?(e.consume(_),j):_===58||_===95||At(_)?(e.consume(_),w):oe(_)?(a=K,z(_)):Te(_)?(e.consume(_),K):j(_)}function w(_){return _===45||_===46||_===58||_===95||yt(_)?(e.consume(_),w):Y(_)}function Y(_){return _===61?(e.consume(_),te):oe(_)?(a=Y,z(_)):Te(_)?(e.consume(_),Y):K(_)}function te(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),i=_,ce):oe(_)?(a=te,z(_)):Te(_)?(e.consume(_),te):(e.consume(_),le)}function ce(_){return _===i?(e.consume(_),i=void 0,ue):_===null?n(_):oe(_)?(a=ce,z(_)):(e.consume(_),ce)}function le(_){return _===null||_===34||_===39||_===60||_===61||_===96?n(_):_===47||_===62||Be(_)?K(_):(e.consume(_),le)}function ue(_){return _===47||_===62||Be(_)?K(_):n(_)}function j(_){return _===62?(e.consume(_),e.exit("htmlTextData"),e.exit("htmlText"),t):n(_)}function z(_){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),P}function P(_){return Te(_)?ke(e,G,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):G(_)}function G(_){return e.enter("htmlTextData"),a(_)}}const kd={name:"labelEnd",resolveAll:D_,resolveTo:R_,tokenize:O_},v_={tokenize:P_},I_={tokenize:M_},L_={tokenize:F_};function D_(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&qt(e,0,e.length,n),e}function R_(e,t){let n=e.length,r=0,i,s,a,u;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[s][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[a-2][1].start}};return u=[["enter",l,t],["enter",d,t]],u=en(u,e.slice(s+1,s+r+3)),u=en(u,[["enter",h,t]]),u=en(u,rl(t.parser.constructs.insideSpan.null,e.slice(s+r+4,a-3),t)),u=en(u,[["exit",h,t],e[a-2],e[a-1],["exit",d,t]]),u=en(u,e.slice(a+1)),u=en(u,[["exit",l,t]]),qt(e,s,e.length,u),e}function O_(e,t,n){const r=this;let i=r.events.length,s,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return u;function u(p){return s?s._inactive?f(p):(a=r.parser.defined.includes(En(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),l):n(p)}function l(p){return p===40?e.attempt(v_,h,a?h:f)(p):p===91?e.attempt(I_,h,a?d:f)(p):a?h(p):f(p)}function d(p){return e.attempt(L_,h,f)(p)}function h(p){return t(p)}function f(p){return s._balanced=!0,n(p)}}function P_(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return Be(f)?ys(e,s)(f):s(f)}function s(f){return f===41?h(f):C1(e,a,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Be(f)?ys(e,l)(f):h(f)}function u(f){return n(f)}function l(f){return f===34||f===39||f===40?A1(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):h(f)}function d(f){return Be(f)?ys(e,h)(f):h(f)}function h(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function M_(e,t,n){const r=this;return i;function i(u){return N1.call(r,e,s,a,"reference","referenceMarker","referenceString")(u)}function s(u){return r.parser.defined.includes(En(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function a(u){return n(u)}}function F_(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const B_={name:"labelStartImage",resolveAll:kd.resolveAll,tokenize:j_};function j_(e,t,n){const r=this;return i;function i(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),s}function s(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),a):n(u)}function a(u){return u===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(u):t(u)}}const U_={name:"labelStartLink",resolveAll:kd.resolveAll,tokenize:H_};function H_(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const zl={name:"lineEnding",tokenize:z_};function z_(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ke(e,t,"linePrefix")}}const Wa={name:"thematicBreak",tokenize:$_};function $_(e,t,n){let r=0,i;return s;function s(d){return e.enter("thematicBreak"),a(d)}function a(d){return i=d,u(d)}function u(d){return d===i?(e.enter("thematicBreakSequence"),l(d)):r>=3&&(d===null||oe(d))?(e.exit("thematicBreak"),t(d)):n(d)}function l(d){return d===i?(e.consume(d),r++,l):(e.exit("thematicBreakSequence"),Te(d)?ke(e,u,"whitespace")(d):u(d))}}const Rt={continuation:{tokenize:q_},exit:G_,name:"list",tokenize:W_},Y_={partial:!0,tokenize:K_},V_={partial:!0,tokenize:Q_};function W_(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return u;function u(m){const T=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(T==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:nc(m)){if(r.containerState.type||(r.containerState.type=T,e.enter(T,{_container:!0})),T==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(Wa,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(m)}return n(m)}function l(m){return nc(m)&&++a<10?(e.consume(m),l):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(ia,r.interrupt?n:h,e.attempt(Y_,p,f))}function h(m){return r.containerState.initialBlankLine=!0,s++,p(m)}function f(m){return Te(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function q_(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ia,i,s);function i(u){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ke(e,t,"listItemIndent",r.containerState.size+1)(u)}function s(u){return r.containerState.furtherBlankLines||!Te(u)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(u)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(V_,t,a)(u))}function a(u){return r.containerState._closeFlow=!0,r.interrupt=void 0,ke(e,e.attempt(Rt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function Q_(e,t,n){const r=this;return ke(e,i,"listItemIndent",r.containerState.size+1);function i(s){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(s):n(s)}}function G_(e){e.exit(this.containerState.type)}function K_(e,t,n){const r=this;return ke(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=r.events[r.events.length-1];return!Te(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const vh={name:"setextUnderline",resolveTo:X_,tokenize:J_};function X_(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function J_(e,t,n){const r=this;let i;return s;function s(d){let h=r.events.length,f;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){f=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),u(d)}function u(d){return d===i?(e.consume(d),u):(e.exit("setextHeadingLineSequence"),Te(d)?ke(e,l,"lineSuffix")(d):l(d))}function l(d){return d===null||oe(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const Z_={tokenize:ek};function ek(e){const t=this,n=e.attempt(ia,r,e.attempt(this.parser.constructs.flowInitial,i,ke(e,e.attempt(this.parser.constructs.flow,i,e.attempt(s_,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const tk={resolveAll:v1()},nk=w1("string"),rk=w1("text");function w1(e){return{resolveAll:v1(e==="text"?ik:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,a,u);return a;function a(h){return d(h)?s(h):u(h)}function u(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),l}function l(h){return d(h)?(n.exit("data"),s(h)):(n.consume(h),l)}function d(h){if(h===null)return!0;const f=i[h];let p=-1;if(f)for(;++p<f.length;){const m=f[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function v1(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function ik(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,a=-1,u=0,l;for(;s--;){const d=i[s];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)u++,a--;if(a)break;a=-1}else if(d===-2)l=!0,u++;else if(d!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const d={type:n===e.length||l||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:r.start._bufferIndex+a,_index:r.start._index+s,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const sk={42:Rt,43:Rt,45:Rt,48:Rt,49:Rt,50:Rt,51:Rt,52:Rt,53:Rt,54:Rt,55:Rt,56:Rt,57:Rt,62:x1},ak={91:c_},uk={[-2]:Hl,[-1]:Hl,32:Hl},lk={35:g_,42:Wa,45:[vh,Wa],60:b_,61:vh,95:Wa,96:Ah,126:Ah},ok={38:k1,92:_1},ck={[-5]:zl,[-4]:zl,[-3]:zl,33:B_,38:k1,42:rc,60:[Ux,A_],91:U_,92:[m_,_1],93:kd,95:rc,96:Zx},dk={null:[rc,tk]},fk={null:[42,95]},hk={null:[]},mk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:fk,contentInitial:ak,disable:hk,document:sk,flow:lk,flowInitial:uk,insideSpan:dk,string:ok,text:ck},Symbol.toStringTag,{value:"Module"}));function pk(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let a=[],u=[];const l={attempt:F(O),check:F(A),consume:E,enter:y,exit:v,interrupt:F(A,{interrupt:!0})},d={code:null,containerState:{},defineSkip:x,events:[],now:T,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:f};let h=t.tokenize.call(d,l);return t.resolveAll&&s.push(t),d;function f(Y){return a=en(a,Y),I(),a[a.length-1]!==null?[]:(H(t,0),d.events=rl(s,d.events,d),d.events)}function p(Y,te){return Ek(m(Y),te)}function m(Y){return gk(a,Y)}function T(){const{_bufferIndex:Y,_index:te,line:ce,column:le,offset:ue}=r;return{_bufferIndex:Y,_index:te,line:ce,column:le,offset:ue}}function x(Y){i[Y.line]=Y.column,w()}function I(){let Y;for(;r._index<a.length;){const te=a[r._index];if(typeof te=="string")for(Y=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===Y&&r._bufferIndex<te.length;)g(te.charCodeAt(r._bufferIndex));else g(te)}}function g(Y){h=h(Y)}function E(Y){oe(Y)?(r.line++,r.column=1,r.offset+=Y===-3?2:1,w()):Y!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=Y}function y(Y,te){const ce=te||{};return ce.type=Y,ce.start=T(),d.events.push(["enter",ce,d]),u.push(ce),ce}function v(Y){const te=u.pop();return te.end=T(),d.events.push(["exit",te,d]),te}function O(Y,te){H(Y,te.from)}function A(Y,te){te.restore()}function F(Y,te){return ce;function ce(le,ue,j){let z,P,G,_;return Array.isArray(le)?fe(le):"tokenize"in le?fe([le]):Z(le);function Z(me){return ve;function ve(De){const He=De!==null&&me[De],R=De!==null&&me.null,W=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(R)?R:R?[R]:[]];return fe(W)(De)}}function fe(me){return z=me,P=0,me.length===0?j:N(me[P])}function N(me){return ve;function ve(De){return _=K(),G=me,me.partial||(d.currentConstruct=me),me.name&&d.parser.constructs.disable.null.includes(me.name)?re():me.tokenize.call(te?Object.assign(Object.create(d),te):d,l,Ne,re)(De)}}function Ne(me){return Y(G,_),ue}function re(me){return _.restore(),++P<z.length?N(z[P]):j}}}function H(Y,te){Y.resolveAll&&!s.includes(Y)&&s.push(Y),Y.resolve&&qt(d.events,te,d.events.length-te,Y.resolve(d.events.slice(te),d)),Y.resolveTo&&(d.events=Y.resolveTo(d.events,d))}function K(){const Y=T(),te=d.previous,ce=d.currentConstruct,le=d.events.length,ue=Array.from(u);return{from:le,restore:j};function j(){r=Y,d.previous=te,d.currentConstruct=ce,d.events.length=le,u=ue,w()}}function w(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function gk(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,s)];else{if(a=e.slice(n,i),r>-1){const u=a[0];typeof u=="string"?a[0]=u.slice(r):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function Ek(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
380
380
  `;break}case-3:{a=`\r
381
381
  `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,r.push(a)}return r.join("")}function Tk(e){const r={constructs:y1([mk,...(e||{}).extensions||[]]),content:i(Rx),defined:[],document:i(Px),flow:i(Z_),lazy:{},string:i(nk),text:i(rk)};return r;function i(s){return a;function a(u){return pk(r,s,u)}}}function yk(e){for(;!S1(e););return e}const Ih=/[\0\t\n\r]/g;function bk(){let e=1,t="",n=!0,r;return i;function i(s,a,u){const l=[];let d,h,f,p,m;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(Ih.lastIndex=f,d=Ih.exec(s),p=d&&d.index!==void 0?d.index:s.length,m=s.charCodeAt(p),!d){t=s.slice(f);break}if(m===10&&f===p&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<p&&(l.push(s.slice(f,p)),e+=p-f),m){case 0:{l.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,l.push(-2);e++<h;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return u&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const xk=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function _k(e){return e.replace(xk,kk)}function kk(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return b1(n.slice(s?2:1),s?16:10)}return _d(n)||e}const I1={}.hasOwnProperty;function Sk(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Ck(n)(yk(Tk(n).document().write(bk()(e,t,!0))))}function Ck(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(kt),autolinkProtocol:K,autolinkEmail:K,atxHeading:s(Re),blockQuote:s(R),characterEscape:K,characterReference:K,codeFenced:s(W),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(W,a),codeText:s(de,a),codeTextData:K,data:K,codeFlowValue:K,definition:s(Ae),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(be),hardBreakEscape:s(ze),hardBreakTrailing:s(ze),htmlFlow:s(Gn,a),htmlFlowData:K,htmlText:s(Gn,a),htmlTextData:K,image:s(Nr),label:a,link:s(kt),listItem:s(Ve),listItemValue:p,listOrdered:s(Se,f),listUnordered:s(Se),paragraph:s(St),reference:N,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(Re),strong:s(bn),thematicBreak:s(ct)},exit:{atxHeading:l(),atxHeadingSequence:O,autolink:l(),autolinkEmail:He,autolinkProtocol:De,blockQuote:l(),characterEscapeValue:w,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:me,characterReference:ve,codeFenced:l(I),codeFencedFence:x,codeFencedFenceInfo:m,codeFencedFenceMeta:T,codeFlowValue:w,codeIndented:l(g),codeText:l(ue),codeTextData:w,data:w,definition:l(),definitionDestinationString:v,definitionLabelString:E,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(te),hardBreakTrailing:l(te),htmlFlow:l(ce),htmlFlowData:w,htmlText:l(le),htmlTextData:w,image:l(z),label:G,labelText:P,lineEnding:Y,link:l(j),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:Ne,resourceDestinationString:_,resourceTitleString:Z,resource:fe,setextHeading:l(H),setextHeadingLineSequence:F,setextHeadingText:A,strong:l(),thematicBreak:l()}};L1(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let X={type:"root",children:[]};const he={stack:[X],tokenStack:[],config:t,enter:u,exit:d,buffer:a,resume:h,data:n},ge=[];let Ie=-1;for(;++Ie<U.length;)if(U[Ie][1].type==="listOrdered"||U[Ie][1].type==="listUnordered")if(U[Ie][0]==="enter")ge.push(Ie);else{const st=ge.pop();Ie=i(U,st,Ie)}for(Ie=-1;++Ie<U.length;){const st=t[U[Ie][0]];I1.call(st,U[Ie][1].type)&&st[U[Ie][1].type].call(Object.assign({sliceSerialize:U[Ie][2].sliceSerialize},he),U[Ie][1])}if(he.tokenStack.length>0){const st=he.tokenStack[he.tokenStack.length-1];(st[1]||Lh).call(he,void 0,st[0])}for(X.position={start:Zn(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Zn(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Ie=-1;++Ie<t.transforms.length;)X=t.transforms[Ie](X)||X;return X}function i(U,X,he){let ge=X-1,Ie=-1,st=!1,Rn,un,On,Ar;for(;++ge<=he;){const Ct=U[ge];switch(Ct[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ct[0]==="enter"?Ie++:Ie--,Ar=void 0;break}case"lineEndingBlank":{Ct[0]==="enter"&&(Rn&&!Ar&&!Ie&&!On&&(On=ge),Ar=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ar=void 0}if(!Ie&&Ct[0]==="enter"&&Ct[1].type==="listItemPrefix"||Ie===-1&&Ct[0]==="exit"&&(Ct[1].type==="listUnordered"||Ct[1].type==="listOrdered")){if(Rn){let Kn=ge;for(un=void 0;Kn--;){const ln=U[Kn];if(ln[1].type==="lineEnding"||ln[1].type==="lineEndingBlank"){if(ln[0]==="exit")continue;un&&(U[un][1].type="lineEndingBlank",st=!0),ln[1].type="lineEnding",un=Kn}else if(!(ln[1].type==="linePrefix"||ln[1].type==="blockQuotePrefix"||ln[1].type==="blockQuotePrefixWhitespace"||ln[1].type==="blockQuoteMarker"||ln[1].type==="listItemIndent"))break}On&&(!un||On<un)&&(Rn._spread=!0),Rn.end=Object.assign({},un?U[un][1].start:Ct[1].end),U.splice(un||ge,0,["exit",Rn,Ct[2]]),ge++,he++}if(Ct[1].type==="listItemPrefix"){const Kn={type:"listItem",_spread:!1,start:Object.assign({},Ct[1].start),end:void 0};Rn=Kn,U.splice(ge,0,["enter",Kn,Ct[2]]),ge++,he++,On=void 0,Ar=!0}}}return U[X][1]._spread=st,he}function s(U,X){return he;function he(ge){u.call(this,U(ge),ge),X&&X.call(this,ge)}}function a(){this.stack.push({type:"fragment",children:[]})}function u(U,X,he){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([X,he||void 0]),U.position={start:Zn(X.start),end:void 0}}function l(U){return X;function X(he){U&&U.call(this,he),d.call(this,he)}}function d(U,X){const he=this.stack.pop(),ge=this.tokenStack.pop();if(ge)ge[0].type!==U.type&&(X?X.call(this,U,ge[0]):(ge[1]||Lh).call(this,U,ge[0]));else throw new Error("Cannot close `"+U.type+"` ("+Ts({start:U.start,end:U.end})+"): it’s not open");he.position.end=Zn(U.end)}function h(){return xd(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(U){if(this.data.expectingFirstListItemValue){const X=this.stack[this.stack.length-2];X.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function m(){const U=this.resume(),X=this.stack[this.stack.length-1];X.lang=U}function T(){const U=this.resume(),X=this.stack[this.stack.length-1];X.meta=U}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function I(){const U=this.resume(),X=this.stack[this.stack.length-1];X.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const U=this.resume(),X=this.stack[this.stack.length-1];X.value=U.replace(/(\r?\n|\r)$/g,"")}function E(U){const X=this.resume(),he=this.stack[this.stack.length-1];he.label=X,he.identifier=En(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),X=this.stack[this.stack.length-1];X.title=U}function v(){const U=this.resume(),X=this.stack[this.stack.length-1];X.url=U}function O(U){const X=this.stack[this.stack.length-1];if(!X.depth){const he=this.sliceSerialize(U).length;X.depth=he}}function A(){this.data.setextHeadingSlurpLineEnding=!0}function F(U){const X=this.stack[this.stack.length-1];X.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function K(U){const he=this.stack[this.stack.length-1].children;let ge=he[he.length-1];(!ge||ge.type!=="text")&&(ge=Ht(),ge.position={start:Zn(U.start),end:void 0},he.push(ge)),this.stack.push(ge)}function w(U){const X=this.stack.pop();X.value+=this.sliceSerialize(U),X.position.end=Zn(U.end)}function Y(U){const X=this.stack[this.stack.length-1];if(this.data.atHardBreak){const he=X.children[X.children.length-1];he.position.end=Zn(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(X.type)&&(K.call(this,U),w.call(this,U))}function te(){this.data.atHardBreak=!0}function ce(){const U=this.resume(),X=this.stack[this.stack.length-1];X.value=U}function le(){const U=this.resume(),X=this.stack[this.stack.length-1];X.value=U}function ue(){const U=this.resume(),X=this.stack[this.stack.length-1];X.value=U}function j(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=X,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function z(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=X,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function P(U){const X=this.sliceSerialize(U),he=this.stack[this.stack.length-2];he.label=_k(X),he.identifier=En(X).toLowerCase()}function G(){const U=this.stack[this.stack.length-1],X=this.resume(),he=this.stack[this.stack.length-1];if(this.data.inReference=!0,he.type==="link"){const ge=U.children;he.children=ge}else he.alt=X}function _(){const U=this.resume(),X=this.stack[this.stack.length-1];X.url=U}function Z(){const U=this.resume(),X=this.stack[this.stack.length-1];X.title=U}function fe(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function Ne(U){const X=this.resume(),he=this.stack[this.stack.length-1];he.label=X,he.identifier=En(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function re(U){this.data.characterReferenceType=U.type}function me(U){const X=this.sliceSerialize(U),he=this.data.characterReferenceType;let ge;he?(ge=b1(X,he==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ge=_d(X);const Ie=this.stack[this.stack.length-1];Ie.value+=ge}function ve(U){const X=this.stack.pop();X.position.end=Zn(U.end)}function De(U){w.call(this,U);const X=this.stack[this.stack.length-1];X.url=this.sliceSerialize(U)}function He(U){w.call(this,U);const X=this.stack[this.stack.length-1];X.url="mailto:"+this.sliceSerialize(U)}function R(){return{type:"blockquote",children:[]}}function W(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function Ae(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function be(){return{type:"emphasis",children:[]}}function Re(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function Gn(){return{type:"html",value:""}}function Nr(){return{type:"image",title:null,url:"",alt:null}}function kt(){return{type:"link",title:null,url:"",children:[]}}function Se(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ve(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function St(){return{type:"paragraph",children:[]}}function bn(){return{type:"strong",children:[]}}function Ht(){return{type:"text",value:""}}function ct(){return{type:"thematicBreak"}}}function Zn(e){return{line:e.line,column:e.column,offset:e.offset}}function L1(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?L1(e,r):Nk(e,r)}}function Nk(e,t){let n;for(n in t)if(I1.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Lh(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ts({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ts({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ts({start:t.start,end:t.end})+") is still open")}function Ak(e){const t=this;t.parser=n;function n(r){return Sk(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function wk(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function vk(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -408,7 +408,7 @@ Error generating stack: `+s.message+`
408
408
  `)?e.split(`
409
409
  `).filter(Boolean):e.split(", ").filter(Boolean);return t.length<=1?c.jsx("span",{className:"arg-value",children:e}):c.jsx("div",{className:"args-grid",children:t.map((n,r)=>{const i=n.indexOf(":");if(i>0&&i<30){const s=n.slice(0,i).trim(),a=n.slice(i+1).trim();return c.jsxs("div",{className:"arg-row",children:[c.jsx("span",{className:"arg-key",children:s}),c.jsx("span",{className:"arg-value",children:a})]},r)}return c.jsx("div",{className:"arg-row",children:c.jsx("span",{className:"arg-value",children:n})},r)})})}function Iv({active:e}){const t="Thinking...",[n,r]=S.useState(0),[i,s]=S.useState("typing"),a=S.useRef(e);return S.useEffect(()=>{if(i!=="typing")return;if(n>=t.length){s("idle");return}const u=setTimeout(()=>r(l=>l+1),30);return()=>clearTimeout(u)},[i,n]),S.useEffect(()=>{a.current&&!e&&s("erasing"),a.current=e},[e]),S.useEffect(()=>{if(i!=="erasing")return;if(n<=0){s("done");return}const u=setTimeout(()=>r(l=>l-1),20);return()=>clearTimeout(u)},[i,n]),S.useEffect(()=>{e&&i==="done"&&(r(0),s("typing"))},[e,i]),i==="done"?null:c.jsxs("span",{className:"thinking-indicator",children:[c.jsx("span",{className:"thinking-indicator-text",children:t.slice(0,n)}),e&&c.jsx("span",{className:"cursor"})]})}function Lv(e){if(!e)return!1;const t=e.toLowerCase();return t.startsWith("error:")||t.startsWith("error -")||t.includes("traceback (most recent")||t.includes("object has no attribute")||t.includes("is lemonade server running")||t.includes("connection refused")||t.includes("failed to fetch")}const Dv=/\s*\{\s*"?tool"?\s*:\s*"[^"]+"\s*,\s*"?tool_args"?\s*:\s*\{[^}]*\}\s*\}/g;function Rv(e){const t=['"thought"','"answer"','"tool"'];let n="",r=0;for(;r<e.length;){const i=e.indexOf("{",r);if(i===-1){n+=e.slice(r);break}const s=e.slice(i,i+50);if(!t.some(h=>s.includes(h))){n+=e.slice(r,i+1),r=i+1;continue}n+=e.slice(r,i);let u=0,l=i;for(;l<e.length;l++)if(e[l]==="{")u++;else if(e[l]==="}"&&(u--,u===0))break;if(u!==0)break;const d=e.slice(i,l+1);try{const h=JSON.parse(d);h.answer&&(n+=h.answer)}catch{const h=d.indexOf('"answer"');if(h!==-1){const f=d.indexOf(":",h+8);if(f!==-1){let p=f+1;for(;p<d.length&&/\s/.test(d[p]);)p++;if(p<d.length&&d[p]==='"'){let m=d.slice(p+1);m.endsWith('"}')?m=m.slice(0,-2):m.endsWith('"')&&(m=m.slice(0,-1)),n+=m.replace(/\\"/g,'"').replace(/\\n/g,`
410
410
  `).replace(/\\\\/g,"\\")}}}}r=l+1}return n}const Ov=new Set(["python","py","javascript","js","typescript","ts","java","c","cpp","csharp","cs","go","rust","ruby","rb","php","swift","kotlin","scala","r","perl","lua","bash","sh","zsh","powershell","ps1","sql","html","css","scss","sass","less","xml","json","yaml","yml","toml","ini","csv","markdown","md","dockerfile","docker","makefile","cmake","nginx","apache","graphql","proto","protobuf","jsx","tsx","vue","svelte","dart","elixir","ex","erlang","haskell","hs","ocaml","ml","fsharp","fs","clojure","clj","lisp","scheme","racket","zig","nim","crystal","julia","matlab","octave","fortran","cobol","pascal","delphi","ada","assembly","asm","nasm","wasm","solidity","sol","verilog","vhdl","text","txt","plaintext","diff","patch","log"]);function Pv(e){return e.replace(/```(\w*)[ \t]*\n([\s\S]*?)```/g,(t,n,r)=>{const i=n.toLowerCase();return i&&Ov.has(i)?t:r.trim()})}function Mv(e){if(!e)return e;let t=e;t=t.replace(Dv,""),t=Rv(t),t=t.replace(/<think>[\s\S]*?<\/think>/g,"");const n=(t.match(/\\n/g)||[]).length,r=(t.match(/\n/g)||[]).length;return n>2&&n>r*2&&(t=t.replace(/\\n/g,`
411
- `),t=t.replace(/\\"/g,'"')),t=Pv(t).trim(),t}function Fv(e){if(!e)return"";const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Bv(e){return e?new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0}):""}function jv(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function S0({message:e,isStreaming:t,showTerminalCursor:n,agentSteps:r,agentStepsActive:i,onDelete:s,onResend:a,latencyMs:u}){var y,v,O;const l=e.role==="assistant"&&Lv(e.content),d=S.useMemo(()=>Mv(e.content),[e.content]),[h,f]=S.useState(!1),[p,m]=S.useState(!1),T=S.useRef(null),x=S.useRef(null);S.useEffect(()=>()=>{T.current&&clearTimeout(T.current),x.current&&clearTimeout(x.current)},[]);const I=S.useCallback(()=>{var A;if((A=navigator.clipboard)!=null&&A.writeText)navigator.clipboard.writeText(e.content).catch(()=>{});else{const F=document.createElement("textarea");F.value=e.content,F.style.position="fixed",F.style.opacity="0",document.body.appendChild(F),F.select(),document.execCommand("copy"),document.body.removeChild(F)}f(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>f(!1),2e3)},[e.content]),g=S.useCallback(()=>{if(!p){m(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>m(!1),3e3);return}m(!1),x.current&&clearTimeout(x.current),s==null||s(e.id)},[p,e.id,s]),E=S.useCallback(()=>{a==null||a(e)},[e,a]);return c.jsx("div",{className:`msg msg-${e.role} ${l?"msg-error":""}`,children:c.jsxs("div",{className:"msg-inner",children:[c.jsxs("div",{className:"msg-header",children:[c.jsxs("div",{className:"msg-header-left",children:[e.role==="assistant"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"msg-avatar msg-avatar-assistant","aria-hidden":"true",children:c.jsx("img",{src:r1,alt:""})}),c.jsx("div",{className:"msg-role role-assistant",children:"GAIA"})]}),e.created_at&&c.jsx("span",{className:"msg-timestamp",children:Fv(e.created_at)}),e.role==="assistant"&&t&&c.jsx(Iv,{active:!!i||!d})]}),!t&&c.jsxs("div",{className:"msg-actions",children:[e.role==="user"&&a&&c.jsx("button",{className:"msg-action-btn",onClick:E,title:"Resend message","aria-label":"Resend message",children:c.jsx(cy,{size:12})}),c.jsx("button",{className:`msg-copy ${h?"copied":""}`,onClick:I,title:h?"Copied!":"Copy message","aria-label":h?"Copied to clipboard":"Copy message",children:h?c.jsx(ea,{size:12}):c.jsx(Xu,{size:12})}),s&&c.jsx("button",{className:`msg-action-btn msg-delete ${p?"confirm":""}`,onClick:g,title:p?"Click again to confirm":"Delete message","aria-label":p?"Confirm delete message":"Delete message",children:c.jsx(_u,{size:12})})]})]}),c.jsxs("div",{className:"msg-body",children:[r&&r.length>0&&c.jsx(yv,{steps:r,isActive:i??!1,variant:i?"inline":"summary"}),l&&c.jsxs("div",{className:"error-banner",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"Something went wrong"})]}),c.jsx(Vv,{content:d,showCursor:(t||n)&&!!d&&!i}),e.role==="assistant"&&!t&&(e.stats||u!=null||e.created_at)&&c.jsxs("div",{className:"msg-stats","aria-label":"Message performance stats",children:[e.created_at&&c.jsx("span",{className:"msg-stats-ts",title:"Message timestamp",children:Bv(e.created_at)}),u!=null&&u>0&&c.jsx("span",{title:"Total response time",children:jv(u)}),((y=e.stats)==null?void 0:y.tokens_per_second)!=null&&e.stats.tokens_per_second>0&&c.jsxs("span",{title:"Tokens per second",children:[e.stats.tokens_per_second," tok/s"]}),((v=e.stats)==null?void 0:v.time_to_first_token)!=null&&e.stats.time_to_first_token>0&&c.jsxs("span",{title:"Time to first token",children:[(e.stats.time_to_first_token*1e3).toFixed(0),"ms TTFT"]}),((O=e.stats)==null?void 0:O.output_tokens)!=null&&e.stats.output_tokens>0&&c.jsxs("span",{title:"Input → output tokens",children:[(e.stats.input_tokens??0).toLocaleString()," → ",e.stats.output_tokens.toLocaleString()," tokens"]})]})]})]})})}function Uv({lang:e,code:t}){const[n,r]=S.useState(!1),i=S.useRef(null);S.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const s=S.useCallback(()=>{var a;if((a=navigator.clipboard)!=null&&a.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{const u=document.createElement("textarea");u.value=t,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}r(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),2e3)},[t]);return c.jsxs("div",{className:"code-block",children:[c.jsxs("div",{className:"code-header",children:[c.jsx("span",{className:"code-lang",children:e||"code"}),c.jsxs("button",{className:`code-copy ${n?"copied":""}`,onClick:s,title:n?"Copied!":"Copy","aria-label":n?"Copied to clipboard":"Copy code",children:[n?c.jsx(ea,{size:13}):c.jsx(Xu,{size:13}),c.jsx("span",{children:n?"Copied":"Copy"})]})]}),c.jsx("pre",{children:c.jsx("code",{children:t})})]})}const Hv=/[A-Z]:[\\\/](?:[^\s*?"<>|,;)}\]]+[\\\/])*[^\s*?"<>|,;)}\]]*\.\w{1,5}/gi,zv=/[A-Z]:[\\\/](?:[^\s*?"<>|,;)}\]]+[\\\/])+/gi;function $v({path:e}){const t=n=>{n.preventDefault(),pd(e).catch(r=>{D.ui.error("Failed to open path",r)})};return c.jsxs("span",{className:"file-path-link",onClick:t,title:`Open in file explorer: ${e}`,role:"button",tabIndex:0,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t(n))},children:[c.jsx(Hn,{size:12,className:"file-path-icon"}),e]})}function Yv(e){const t=new RegExp(`(${Hv.source}|${zv.source})`,"gi"),n=[];let r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push(e.slice(r,i.index)),n.push(c.jsx($v,{path:i[0]},i.index)),r=t.lastIndex;return n.length===0?e:(r<e.length&&n.push(e.slice(r)),c.jsx(c.Fragment,{children:n}))}function er(e){return As.Children.map(e,t=>typeof t=="string"?Yv(t):t)}function Vv({content:e,showCursor:t}){return!e&&!t?null:!e&&t?c.jsx("span",{className:"cursor"}):c.jsxs("div",{className:"md-content",children:[c.jsx(VS,{remarkPlugins:[gv],rehypePlugins:[uA],components:{code({className:n,children:r,...i}){return c.jsx("code",{className:"inline-code",...i,children:r})},pre({children:n}){var i,s;const r=As.Children.toArray(n)[0];if(As.isValidElement(r)&&(r.type==="code"||((i=r.props)==null?void 0:i.className)!==void 0||typeof((s=r.props)==null?void 0:s.children)=="string")){const a=r.props,u=(a==null?void 0:a.className)||"",l=/language-(\w+)/.exec(u),d=String((a==null?void 0:a.children)||"").replace(/\n$/,"");return c.jsx(Uv,{lang:(l==null?void 0:l[1])||"",code:d})}return c.jsx("pre",{children:n})},table({children:n}){return c.jsx("div",{className:"md-table-wrap",children:c.jsx("table",{className:"md-table",children:n})})},a({href:n,children:r}){return c.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"md-link",children:r})},p({children:n}){return c.jsx("p",{className:"md-p",children:er(n)})},h1({children:n}){return c.jsx("h2",{className:"md-h2",children:er(n)})},h2({children:n}){return c.jsx("h3",{className:"md-h3",children:er(n)})},h3({children:n}){return c.jsx("h4",{className:"md-h4",children:er(n)})},ul({children:n}){return c.jsx("ul",{className:"md-ul",children:n})},ol({children:n}){return c.jsx("ol",{className:"md-ol",children:n})},li({children:n}){return c.jsx("li",{className:"md-li",children:er(n)})},blockquote({children:n}){return c.jsx("blockquote",{className:"md-blockquote",children:er(n)})},hr(){return c.jsx("hr",{className:"md-hr"})},td({children:n}){return c.jsx("td",{children:er(n)})},th({children:n}){return c.jsx("th",{children:er(n)})}},children:e}),t&&c.jsx("span",{className:"cursor"})]})}const Wv=500,Lu="gaia_always_allow_tools",Du=Jp((e,t)=>({notifications:[],showPanel:!1,typeFilter:null,addNotification:n=>e(r=>({notifications:[n,...r.notifications].slice(0,Wv)})),dismiss:n=>e(r=>({notifications:r.notifications.map(i=>i.id===n?{...i,dismissed:!0}:i)})),markRead:n=>e(r=>({notifications:r.notifications.map(i=>i.id===n?{...i,read:!0}:i)})),markAllRead:()=>e(n=>({notifications:n.notifications.map(r=>({...r,read:!0}))})),clearAll:()=>e({notifications:[]}),setShowPanel:n=>e({showPanel:n}),setTypeFilter:n=>e({typeFilter:n}),respondToPermission:async(n,r,i)=>{var l;const s=t().notifications.find(d=>d.id===n),a=s==null?void 0:s.agentId,u=window.gaiaAPI;if((l=u==null?void 0:u.notification)!=null&&l.respondPermission)try{await u.notification.respondPermission(n,r,i)}catch(d){console.error("[notificationStore] Failed to send permission response via IPC:",d);return}else if(a)try{await t1(a,r==="allow")}catch(d){console.error("[notificationStore] Failed to send permission response via REST:",d);return}if(r==="allow"&&i&&s!=null&&s.tool){const d=JSON.parse(localStorage.getItem(Lu)||"[]");d.includes(s.tool)||(d.push(s.tool),localStorage.setItem(Lu,JSON.stringify(d)))}e(d=>({notifications:d.notifications.map(h=>h.id===n?{...h,response:r,respondedAt:Date.now(),read:!0}:h)}))}})),qv=e=>e.notifications.find(t=>t.type==="permission_request"&&!t.response&&!t.dismissed)??null,Wg="https://github.com/amd/gaia/issues/new",Qv=[{label:"Image",extensions:new Set([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".webp",".ico",".heic",".heif"]),message:"Image files cannot be indexed for text search.",alternatives:["Index PDFs that contain images — text is extracted automatically","Paste image descriptions or OCR text directly into the chat","Use GAIA's VLM agent for image analysis: gaia vlm"],featureTitle:"Support image file indexing and OCR"},{label:"Video",extensions:new Set([".mp4",".avi",".mkv",".mov",".wmv",".flv",".webm",".m4v"]),message:"Video files are not supported for indexing.",alternatives:["Extract subtitles or transcripts from videos and index those","Use GAIA's voice/talk mode for audio: gaia talk"],featureTitle:"Support video file indexing"},{label:"Audio",extensions:new Set([".mp3",".wav",".flac",".aac",".ogg",".wma",".m4a",".opus"]),message:"Audio files are not supported for indexing.",alternatives:["Use GAIA's voice mode for speech interaction: gaia talk","Transcribe audio to text first, then index the transcript"],featureTitle:"Support audio file transcription and indexing"},{label:"Archive",extensions:new Set([".zip",".rar",".7z",".tar",".gz",".bz2",".xz",".tgz"]),message:"Archive files must be extracted before indexing.",alternatives:["Extract the archive contents to a folder","Then index the folder or individual files from the Document Library"],featureTitle:"Support automatic archive extraction for indexing"},{label:"Executable",extensions:new Set([".exe",".msi",".dll",".so",".app",".dmg",".bin",".com"]),message:"Executable and binary files cannot be indexed.",alternatives:["Index source code files (.py, .js, .ts, .java, etc.) instead","Index documentation or README files from the project"],featureTitle:"Support binary file analysis"},{label:"Database",extensions:new Set([".sqlite",".db",".mdb",".accdb",".dbf"]),message:"Database files are not supported for direct indexing.",alternatives:["Export data to CSV or JSON format, then index those files","Use SQL queries to extract relevant data to a text file"],featureTitle:"Support database file indexing"}];function Ru(e){const t=e.toLowerCase().startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;for(const n of Qv)if(n.extensions.has(t))return n;return null}const Gv=new Set([".pdf",".txt",".md",".csv",".json",".doc",".docx",".ppt",".pptx",".xls",".xlsx",".html",".htm",".xml",".svg",".yaml",".yml",".py",".js",".ts",".java",".c",".cpp",".h",".rs",".go",".rb",".sh",".bat",".ps1",".log",".cfg",".ini",".toml"]);function mc(e){const t=e.toLowerCase().startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;return Gv.has(t)}function qg(){const e="0.17.0",t=navigator.userAgent,n=navigator.platform||"unknown";return`**Environment:**
411
+ `),t=t.replace(/\\"/g,'"')),t=Pv(t).trim(),t}function Fv(e){if(!e)return"";const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Bv(e){return e?new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0}):""}function jv(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function S0({message:e,isStreaming:t,showTerminalCursor:n,agentSteps:r,agentStepsActive:i,onDelete:s,onResend:a,latencyMs:u}){var y,v,O;const l=e.role==="assistant"&&Lv(e.content),d=S.useMemo(()=>Mv(e.content),[e.content]),[h,f]=S.useState(!1),[p,m]=S.useState(!1),T=S.useRef(null),x=S.useRef(null);S.useEffect(()=>()=>{T.current&&clearTimeout(T.current),x.current&&clearTimeout(x.current)},[]);const I=S.useCallback(()=>{var A;if((A=navigator.clipboard)!=null&&A.writeText)navigator.clipboard.writeText(e.content).catch(()=>{});else{const F=document.createElement("textarea");F.value=e.content,F.style.position="fixed",F.style.opacity="0",document.body.appendChild(F),F.select(),document.execCommand("copy"),document.body.removeChild(F)}f(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>f(!1),2e3)},[e.content]),g=S.useCallback(()=>{if(!p){m(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>m(!1),3e3);return}m(!1),x.current&&clearTimeout(x.current),s==null||s(e.id)},[p,e.id,s]),E=S.useCallback(()=>{a==null||a(e)},[e,a]);return c.jsx("div",{className:`msg msg-${e.role} ${l?"msg-error":""}`,children:c.jsxs("div",{className:"msg-inner",children:[c.jsxs("div",{className:"msg-header",children:[c.jsxs("div",{className:"msg-header-left",children:[e.role==="assistant"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"msg-avatar msg-avatar-assistant","aria-hidden":"true",children:c.jsx("img",{src:r1,alt:""})}),c.jsx("div",{className:"msg-role role-assistant",children:"GAIA"})]}),e.created_at&&c.jsx("span",{className:"msg-timestamp",children:Fv(e.created_at)}),e.role==="assistant"&&t&&c.jsx(Iv,{active:!!i||!d})]}),!t&&c.jsxs("div",{className:"msg-actions",children:[e.role==="user"&&a&&c.jsx("button",{className:"msg-action-btn",onClick:E,title:"Resend message","aria-label":"Resend message",children:c.jsx(cy,{size:12})}),c.jsx("button",{className:`msg-copy ${h?"copied":""}`,onClick:I,title:h?"Copied!":"Copy message","aria-label":h?"Copied to clipboard":"Copy message",children:h?c.jsx(ea,{size:12}):c.jsx(Xu,{size:12})}),s&&c.jsx("button",{className:`msg-action-btn msg-delete ${p?"confirm":""}`,onClick:g,title:p?"Click again to confirm":"Delete message","aria-label":p?"Confirm delete message":"Delete message",children:c.jsx(_u,{size:12})})]})]}),c.jsxs("div",{className:"msg-body",children:[r&&r.length>0&&c.jsx(yv,{steps:r,isActive:i??!1,variant:i?"inline":"summary"}),l&&c.jsxs("div",{className:"error-banner",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"Something went wrong"})]}),c.jsx(Vv,{content:d,showCursor:(t||n)&&!!d&&!i}),e.role==="assistant"&&!t&&(e.stats||u!=null||e.created_at)&&c.jsxs("div",{className:"msg-stats","aria-label":"Message performance stats",children:[e.created_at&&c.jsx("span",{className:"msg-stats-ts",title:"Message timestamp",children:Bv(e.created_at)}),u!=null&&u>0&&c.jsx("span",{title:"Total response time",children:jv(u)}),((y=e.stats)==null?void 0:y.tokens_per_second)!=null&&e.stats.tokens_per_second>0&&c.jsxs("span",{title:"Tokens per second",children:[e.stats.tokens_per_second," tok/s"]}),((v=e.stats)==null?void 0:v.time_to_first_token)!=null&&e.stats.time_to_first_token>0&&c.jsxs("span",{title:"Time to first token",children:[(e.stats.time_to_first_token*1e3).toFixed(0),"ms TTFT"]}),((O=e.stats)==null?void 0:O.output_tokens)!=null&&e.stats.output_tokens>0&&c.jsxs("span",{title:"Input → output tokens",children:[(e.stats.input_tokens??0).toLocaleString()," → ",e.stats.output_tokens.toLocaleString()," tokens"]})]})]})]})})}function Uv({lang:e,code:t}){const[n,r]=S.useState(!1),i=S.useRef(null);S.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const s=S.useCallback(()=>{var a;if((a=navigator.clipboard)!=null&&a.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{const u=document.createElement("textarea");u.value=t,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}r(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),2e3)},[t]);return c.jsxs("div",{className:"code-block",children:[c.jsxs("div",{className:"code-header",children:[c.jsx("span",{className:"code-lang",children:e||"code"}),c.jsxs("button",{className:`code-copy ${n?"copied":""}`,onClick:s,title:n?"Copied!":"Copy","aria-label":n?"Copied to clipboard":"Copy code",children:[n?c.jsx(ea,{size:13}):c.jsx(Xu,{size:13}),c.jsx("span",{children:n?"Copied":"Copy"})]})]}),c.jsx("pre",{children:c.jsx("code",{children:t})})]})}const Hv=/[A-Z]:[\\\/](?:[^\s*?"<>|,;)}\]]+[\\\/])*[^\s*?"<>|,;)}\]]*\.\w{1,5}/gi,zv=/[A-Z]:[\\\/](?:[^\s*?"<>|,;)}\]]+[\\\/])+/gi;function $v({path:e}){const t=n=>{n.preventDefault(),pd(e).catch(r=>{D.ui.error("Failed to open path",r)})};return c.jsxs("span",{className:"file-path-link",onClick:t,title:`Open in file explorer: ${e}`,role:"button",tabIndex:0,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),t(n))},children:[c.jsx(Hn,{size:12,className:"file-path-icon"}),e]})}function Yv(e){const t=new RegExp(`(${Hv.source}|${zv.source})`,"gi"),n=[];let r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push(e.slice(r,i.index)),n.push(c.jsx($v,{path:i[0]},i.index)),r=t.lastIndex;return n.length===0?e:(r<e.length&&n.push(e.slice(r)),c.jsx(c.Fragment,{children:n}))}function er(e){return As.Children.map(e,t=>typeof t=="string"?Yv(t):t)}function Vv({content:e,showCursor:t}){return!e&&!t?null:!e&&t?c.jsx("span",{className:"cursor"}):c.jsxs("div",{className:"md-content",children:[c.jsx(VS,{remarkPlugins:[gv],rehypePlugins:[uA],components:{code({className:n,children:r,...i}){return c.jsx("code",{className:"inline-code",...i,children:r})},pre({children:n}){var i,s;const r=As.Children.toArray(n)[0];if(As.isValidElement(r)&&(r.type==="code"||((i=r.props)==null?void 0:i.className)!==void 0||typeof((s=r.props)==null?void 0:s.children)=="string")){const a=r.props,u=(a==null?void 0:a.className)||"",l=/language-(\w+)/.exec(u),d=String((a==null?void 0:a.children)||"").replace(/\n$/,"");return c.jsx(Uv,{lang:(l==null?void 0:l[1])||"",code:d})}return c.jsx("pre",{children:n})},table({children:n}){return c.jsx("div",{className:"md-table-wrap",children:c.jsx("table",{className:"md-table",children:n})})},a({href:n,children:r}){return c.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"md-link",children:r})},p({children:n}){return c.jsx("p",{className:"md-p",children:er(n)})},h1({children:n}){return c.jsx("h2",{className:"md-h2",children:er(n)})},h2({children:n}){return c.jsx("h3",{className:"md-h3",children:er(n)})},h3({children:n}){return c.jsx("h4",{className:"md-h4",children:er(n)})},ul({children:n}){return c.jsx("ul",{className:"md-ul",children:n})},ol({children:n}){return c.jsx("ol",{className:"md-ol",children:n})},li({children:n}){return c.jsx("li",{className:"md-li",children:er(n)})},blockquote({children:n}){return c.jsx("blockquote",{className:"md-blockquote",children:er(n)})},hr(){return c.jsx("hr",{className:"md-hr"})},td({children:n}){return c.jsx("td",{children:er(n)})},th({children:n}){return c.jsx("th",{children:er(n)})}},children:e}),t&&c.jsx("span",{className:"cursor"})]})}const Wv=500,Lu="gaia_always_allow_tools",Du=Jp((e,t)=>({notifications:[],showPanel:!1,typeFilter:null,addNotification:n=>e(r=>({notifications:[n,...r.notifications].slice(0,Wv)})),dismiss:n=>e(r=>({notifications:r.notifications.map(i=>i.id===n?{...i,dismissed:!0}:i)})),markRead:n=>e(r=>({notifications:r.notifications.map(i=>i.id===n?{...i,read:!0}:i)})),markAllRead:()=>e(n=>({notifications:n.notifications.map(r=>({...r,read:!0}))})),clearAll:()=>e({notifications:[]}),setShowPanel:n=>e({showPanel:n}),setTypeFilter:n=>e({typeFilter:n}),respondToPermission:async(n,r,i)=>{var l;const s=t().notifications.find(d=>d.id===n),a=s==null?void 0:s.agentId,u=window.gaiaAPI;if((l=u==null?void 0:u.notification)!=null&&l.respondPermission)try{await u.notification.respondPermission(n,r,i)}catch(d){console.error("[notificationStore] Failed to send permission response via IPC:",d);return}else if(a)try{await t1(a,r==="allow")}catch(d){console.error("[notificationStore] Failed to send permission response via REST:",d);return}if(r==="allow"&&i&&s!=null&&s.tool){const d=JSON.parse(localStorage.getItem(Lu)||"[]");d.includes(s.tool)||(d.push(s.tool),localStorage.setItem(Lu,JSON.stringify(d)))}e(d=>({notifications:d.notifications.map(h=>h.id===n?{...h,response:r,respondedAt:Date.now(),read:!0}:h)}))}})),qv=e=>e.notifications.find(t=>t.type==="permission_request"&&!t.response&&!t.dismissed)??null,Wg="https://github.com/amd/gaia/issues/new",Qv=[{label:"Image",extensions:new Set([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".webp",".ico",".heic",".heif"]),message:"Image files cannot be indexed for text search.",alternatives:["Index PDFs that contain images — text is extracted automatically","Paste image descriptions or OCR text directly into the chat","Use GAIA's VLM agent for image analysis: gaia vlm"],featureTitle:"Support image file indexing and OCR"},{label:"Video",extensions:new Set([".mp4",".avi",".mkv",".mov",".wmv",".flv",".webm",".m4v"]),message:"Video files are not supported for indexing.",alternatives:["Extract subtitles or transcripts from videos and index those","Use GAIA's voice/talk mode for audio: gaia talk"],featureTitle:"Support video file indexing"},{label:"Audio",extensions:new Set([".mp3",".wav",".flac",".aac",".ogg",".wma",".m4a",".opus"]),message:"Audio files are not supported for indexing.",alternatives:["Use GAIA's voice mode for speech interaction: gaia talk","Transcribe audio to text first, then index the transcript"],featureTitle:"Support audio file transcription and indexing"},{label:"Archive",extensions:new Set([".zip",".rar",".7z",".tar",".gz",".bz2",".xz",".tgz"]),message:"Archive files must be extracted before indexing.",alternatives:["Extract the archive contents to a folder","Then index the folder or individual files from the Document Library"],featureTitle:"Support automatic archive extraction for indexing"},{label:"Executable",extensions:new Set([".exe",".msi",".dll",".so",".app",".dmg",".bin",".com"]),message:"Executable and binary files cannot be indexed.",alternatives:["Index source code files (.py, .js, .ts, .java, etc.) instead","Index documentation or README files from the project"],featureTitle:"Support binary file analysis"},{label:"Database",extensions:new Set([".sqlite",".db",".mdb",".accdb",".dbf"]),message:"Database files are not supported for direct indexing.",alternatives:["Export data to CSV or JSON format, then index those files","Use SQL queries to extract relevant data to a text file"],featureTitle:"Support database file indexing"}];function Ru(e){const t=e.toLowerCase().startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;for(const n of Qv)if(n.extensions.has(t))return n;return null}const Gv=new Set([".pdf",".txt",".md",".csv",".json",".doc",".docx",".ppt",".pptx",".xls",".xlsx",".html",".htm",".xml",".svg",".yaml",".yml",".py",".js",".ts",".java",".c",".cpp",".h",".rs",".go",".rb",".sh",".bat",".ps1",".log",".cfg",".ini",".toml"]);function mc(e){const t=e.toLowerCase().startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`;return Gv.has(t)}function qg(){const e="0.17.1",t=navigator.userAgent,n=navigator.platform||"unknown";return`**Environment:**
412
412
  - GAIA Version: ${e}
413
413
  - Platform: ${n}
414
414
  - User Agent: ${t}
@@ -425,8 +425,8 @@ ${J}`:J}D.chat.info(`Sending message to session=${e}`,{length:ee.length,preview:
425
425
  ---
426
426
  *Unexpected error?* [Report it on GitHub](${pc(Me.slice(0,80))})`;Me.includes("Lemonade")||Me.includes("LLM")||Me.includes("Could not get response")?_e="Could not reach the LLM server. Make sure Lemonade Server is running:\n\n```\nlemonade-server serve\n```\n\nThen try sending your message again."+Je:J instanceof TypeError||Me.includes("fetch")||Me.includes("Failed to fetch")||Me.includes("NetworkError")?_e="Cannot connect to the GAIA Agent UI server. Make sure the backend is running:\n\n```\ngaia chat --ui\n```"+Je:Me.includes("500")?_e="The server encountered an error. This usually means Lemonade Server is not running or the model failed to load.\n\nStart Lemonade Server with:\n```\nlemonade-server serve\n```"+Je:Me.includes("timed out")||Me.includes("timeout")||Me.includes("Timeout")?_e=`The request timed out. The query may be too complex — try breaking it into simpler questions.
427
427
 
428
- If Lemonade Server is running but responses are slow, the model may need more resources.`+Je:_e=`Error: ${Me}`+Je;const zt={id:Date.now()+2,session_id:e,role:"assistant",content:_e,created_at:new Date().toISOString(),rag_sources:null};i(zt),h(!1),p(),E()}});Se.current=Xt},[le,me,l,e,Y,i,r,h,ge,p,u,T,x,I,g,E]);bn.current=Kr,S.useEffect(()=>{!l&&kt.current&&kt.current.focus()},[l]);const Xg=S.useCallback(async M=>{l||(D.chat.info(`Deleting message ${M} from session=${e}`),W(M),setTimeout(async()=>{s(M),W(null);try{await Zy(e,M)}catch(ne){D.chat.error(`Failed to delete message ${M}`,ne),us(e).then(ae=>{we.getState().currentSessionId===e&&r(ae.messages||[])}).catch(()=>{})}},250))},[e,l,s,r]),Jg=S.useCallback(async M=>{if(l||M.role!=="user")return;const ne=M.content;D.chat.info(`Resending message ${M.id} from session=${e}`,{preview:ne.slice(0,80)}),a(M.id);try{await eb(e,M.id)}catch(ae){D.chat.error(`Failed to delete messages from ${M.id}`,ae),us(e).then(ee=>{we.getState().currentSessionId===e&&r(ee.messages||[])}).catch(()=>{});return}Kr(ne)},[e,l,a,r,Kr]),Zg=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),Kr())},[jd,Ud]=S.useState(!1),eE=S.useCallback(M=>{M.preventDefault();const ne=mn(e),ae=`${window.location.origin}${window.location.pathname}#${ne}`;navigator.clipboard.writeText(ae).then(()=>{D.ui.info(`Copied session link: ${ae}`),Ud(!0),setTimeout(()=>Ud(!1),1500)}).catch(()=>{D.ui.warn("Clipboard write failed")})},[e]),tE=()=>{G((Y==null?void 0:Y.title)||""),z(!0)},Hd=async()=>{P.trim()&&P!==(Y==null?void 0:Y.title)&&(await sh(e,{title:P.trim()}),u(e,{title:P.trim()})),z(!1)},nE=async()=>{try{const M=await Jy(e),ne=new Blob([M.content],{type:"text/markdown"}),ae=URL.createObjectURL(ne),ee=document.createElement("a");ee.href=ae;const xe=((Y==null?void 0:Y.title)||"chat").replace(/[/\\:*?"<>|]/g,"_").slice(0,100);ee.download=`${xe}.md`,ee.click(),URL.revokeObjectURL(ae)}catch(M){D.chat.error("Export failed",M)}},rE=S.useCallback(async(M,ne)=>{M.stopPropagation();const ae=y.find(ee=>ee.id===ne);D.doc.info(`Detaching document from session: ${(ae==null?void 0:ae.filename)||ne}`);try{await ub(e,ne);const ee=we.getState().sessions.find(Le=>Le.id===e),xe=((ee==null?void 0:ee.document_ids)??[]).filter(Le=>Le!==ne);u(e,{document_ids:xe}),xe.length<=3&&He(!1),D.doc.info(`Detached document from session: ${(ae==null?void 0:ae.filename)||ne}`)}catch(ee){D.doc.error(`Failed to detach document: ${(ae==null?void 0:ae.filename)||ne}`,ee)}},[y,e,u]),iE=S.useCallback(async M=>{if(M.preventDefault(),M.stopPropagation(),Z(!1),M.dataTransfer.files.length>0){O(!0);for(const ne of Array.from(M.dataTransfer.files)){const ae=ne.path||ne.name;try{const ee=await md(ae);if(e&&(ee!=null&&ee.id))try{await Su(e,ee.id);const xe=we.getState().sessions.find(pt=>pt.id===e),Le=(xe==null?void 0:xe.document_ids)??[];Le.includes(ee.id)||u(e,{document_ids:[...Le,ee.id]})}catch(xe){D.doc.warn(`Could not attach dropped document to session: ${xe}`)}}catch(ee){D.doc.error(`Upload failed: ${ae}`,ee)}}}},[e,u,O]),sE=M=>{M.preventDefault(),M.stopPropagation(),Z(!0)},aE=M=>{M.preventDefault(),M.stopPropagation(),Z(!1)},uE=M=>{ue(M),Kr(M)},lE=!F&&n.length===0&&!l,oE=S.useMemo(()=>{const M=new Map;let ne;for(const ae of n)if(ae.role==="user"&&ae.created_at)ne=new Date(ae.created_at).getTime();else if(ae.role==="assistant"&&ae.created_at&&ne!==void 0){const ee=new Date(ae.created_at).getTime();ee>ne&&M.set(ae.id,ee-ne),ne=void 0}return M},[n]);return c.jsxs("main",{className:`chat-view ${_?"drag-active":""}`,onDrop:iE,onDragOver:sE,onDragLeave:aE,children:[c.jsxs("header",{className:"chat-header",children:[c.jsx("div",{className:"chat-header-left",children:j?c.jsx("input",{className:"title-edit",value:P,onChange:M=>G(M.target.value),onBlur:Hd,onKeyDown:M=>M.key==="Enter"&&Hd(),autoFocus:!0,"aria-label":"Edit chat title"}):c.jsxs(c.Fragment,{children:[c.jsx("h3",{className:"chat-title",children:(Y==null?void 0:Y.title)||"Chat"}),c.jsx("button",{className:"btn-icon-sm",onClick:tE,title:"Rename","aria-label":"Rename chat",children:c.jsx(ly,{size:13})})]})}),c.jsxs("div",{className:"chat-header-right",children:[c.jsxs("a",{className:`session-hash-badge ${jd?"copied":""}`,href:`#${mn(e)}`,onClick:eE,title:jd?"Copied!":`Copy session link #${mn(e)}`,"aria-label":`Copy link for session ${mn(e)}`,children:[c.jsx(JT,{size:10}),c.jsxs("span",{children:["#",mn(e)]})]}),c.jsx("span",{className:`model-badge ${K!=null&&K.model_loaded?"":"no-model"}`,children:(K==null?void 0:K.model_loaded)||"No model loaded"}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>O(!0),title:"Documents","aria-label":"Attach documents",children:c.jsx(uy,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>A(!0),title:"Browse files","aria-label":"Browse files",children:c.jsx(eh,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:nE,title:"Export","aria-label":"Export chat",children:c.jsx(dd,{size:15})})]})]}),ce.length>0&&(()=>{const M=[...ce].sort((ee,xe)=>{const Le=ee.last_accessed_at||ee.indexed_at||"";return(xe.last_accessed_at||xe.indexed_at||"").localeCompare(Le)}),ne=De?M:M.slice(0,3),ae=M.length-3;return c.jsxs("div",{className:`doc-context-bar${De?" doc-context-expanded":""}`,"aria-label":`${ce.length} indexed document${ce.length!==1?"s":""}`,children:[c.jsx(cd,{size:12,className:"doc-context-icon"}),c.jsxs("span",{className:"doc-context-label",onClick:()=>O(!0),title:"Click to manage documents",role:"button",tabIndex:0,children:[ce.length," indexed"]}),c.jsxs("div",{className:`doc-context-pills${De?" doc-context-pills-expanded":""}`,children:[ne.map(ee=>c.jsxs("span",{className:"doc-pill",title:ee.filepath||ee.filename,children:[c.jsx(wn,{size:9,className:"doc-pill-icon"}),c.jsx("span",{className:"doc-pill-name",children:ee.filename}),c.jsx("button",{className:"doc-pill-remove",onClick:xe=>rE(xe,ee.id),title:`Remove ${ee.filename} from this session`,"aria-label":`Remove ${ee.filename} from this session`,children:c.jsx(Mt,{size:10})})]},ee.id)),!De&&ae>0&&c.jsxs("button",{className:"doc-pill-more",onClick:ee=>{ee.stopPropagation(),He(!0)},title:"Show all indexed files","aria-label":`Show ${ae} more files`,children:["+",ae," more"]}),De&&ae>0&&c.jsx("button",{className:"doc-pill-collapse",onClick:ee=>{ee.stopPropagation(),He(!1)},title:"Show fewer files","aria-label":"Collapse file list",children:"show less"})]})]})})(),c.jsxs("div",{className:"messages-scroll",ref:Nr,onScroll:Rn,children:[F&&c.jsx("div",{className:"skeleton-messages","aria-label":"Loading messages",children:[0,1,2].map(M=>c.jsxs("div",{className:"skeleton-msg",children:[c.jsxs("div",{className:"skeleton-header",children:[c.jsx("div",{className:"skeleton-avatar"}),c.jsx("div",{className:"skeleton-role"})]}),c.jsxs("div",{className:"skeleton-lines",children:[c.jsx("div",{className:"skeleton-line"}),c.jsx("div",{className:"skeleton-line"}),M!==2&&c.jsx("div",{className:"skeleton-line"})]})]},M))}),lE&&c.jsxs("div",{className:"empty-chat",children:[c.jsx("div",{className:"empty-chat-icon",children:c.jsx(ny,{size:36,strokeWidth:1.2})}),c.jsx("h4",{className:"empty-chat-title",children:"What can I help you with?"}),c.jsx("p",{className:"empty-chat-desc",children:"Ask about your documents, search files, or analyze data — powered by local AI."}),c.jsx("div",{className:"empty-chat-suggestions",children:Kv.map(M=>c.jsx("button",{className:"empty-chat-chip",onClick:()=>uE(M),children:M},M))})]}),n.map((M,ne)=>{const ae=!l&&!de&&M.role==="assistant"&&n.slice(ne+1).every(Le=>Le.role!=="assistant");if(de&&M.role==="assistant"&&ne===n.length-1)return null;const xe=oE.get(M.id);return c.jsx("div",{className:R===M.id?"msg-deleting":void 0,children:c.jsx(S0,{message:M,showTerminalCursor:ae,agentSteps:M.role==="assistant"?M.agentSteps:void 0,onDelete:l?void 0:Xg,onResend:!l&&M.role==="user"?Jg:void 0,latencyMs:xe})},M.id)}),(l||de)&&c.jsx("div",{className:`streaming-bubble ${de?"stream-ending":"stream-active"}`,children:c.jsx(S0,{message:{id:-1,session_id:e,role:"assistant",content:(l?d:be.current)||"",created_at:"",rag_sources:null},isStreaming:l,showTerminalCursor:de,agentSteps:l?m:Re.current,agentStepsActive:l&&m.some(M=>M.active)})}),c.jsx("div",{ref:Gn})]}),fe&&c.jsx("button",{className:"scroll-bottom-btn",onClick:un,title:"Scroll to bottom","aria-label":"Scroll to bottom",children:c.jsx(BT,{size:16})}),_&&c.jsxs("div",{className:"drag-overlay",children:[c.jsx(ku,{size:32,strokeWidth:1.5}),c.jsx("span",{children:"Drop files to index"})]}),c.jsxs("div",{className:"input-area",children:[c.jsxs("div",{className:`input-box ${me.length>0?"has-attachments":""}`,onDrop:Kn,onDragOver:M=>{M.preventDefault(),M.stopPropagation()},children:[c.jsxs("div",{className:"input-content",children:[me.length>0&&c.jsx("div",{className:"attachment-strip",children:me.map(M=>c.jsxs("div",{className:`attachment-preview ${M.error?"attachment-error":""}`,children:[M.isImage&&M.url?c.jsx("img",{src:M.url,alt:M.name,className:"attachment-thumb"}):c.jsx("div",{className:"attachment-file-icon",children:c.jsx(wn,{size:16})}),c.jsx("span",{className:"attachment-name",title:M.name,children:M.name.length>20?M.name.slice(0,17)+"...":M.name}),M.uploading&&c.jsx("span",{className:"attachment-spinner"}),M.error&&c.jsx("span",{className:"attachment-error-text",children:M.error}),c.jsx("button",{className:"attachment-remove",onClick:()=>ln(M.id),title:"Remove","aria-label":`Remove ${M.name}`,children:c.jsx(Mt,{size:12})})]},M.id))}),c.jsx("textarea",{ref:kt,className:"msg-input",value:le,onChange:Ar,onKeyDown:Zg,onPaste:Ct,placeholder:"Type a message or paste an image... (Shift+Enter for new line)",rows:1,disabled:l,"aria-label":"Message input"})]}),!l&&c.jsx("span",{className:"input-cursor","aria-hidden":"true"}),c.jsxs("div",{className:"input-btns",children:[c.jsx("button",{className:"btn-icon-sm",onClick:()=>O(!0),title:"Upload document","aria-label":"Upload document",children:c.jsx(ku,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>A(!0),title:"Browse files","aria-label":"Browse files",children:c.jsx(eh,{size:15})}),l?c.jsx("button",{className:"stop-btn",onClick:On,title:"Stop generating","aria-label":"Stop generating",children:c.jsx(my,{size:14})}):c.jsx("button",{className:"send-btn",onClick:()=>Kr(),disabled:!le.trim()&&!me.some(M=>M.uploaded),title:"Send (Enter)","aria-label":"Send message",children:c.jsx(dy,{size:16})})]})]}),c.jsxs("div",{className:"input-footer",children:[c.jsxs("span",{className:"input-footer-item",children:[c.jsx(Yp,{size:10}),c.jsx("span",{children:"100% local & private"})]}),c.jsx("span",{className:"input-footer-sep"}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Enter"}),c.jsx("span",{children:"send"})]}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Shift+Enter"}),c.jsx("span",{children:"new line"})]}),l&&c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Esc"}),c.jsx("span",{children:"stop"})]}),c.jsx("span",{className:"input-footer-sep"}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Ctrl+K"}),c.jsx("span",{children:"search"})]}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Ctrl+V"}),c.jsx("span",{children:"paste image"})]})]})]})]})}const N0="GAIA Agent UI",Ia="Your private AI assistant, running 100% locally on AMD Ryzen AI",e6=65,t6=350;function Gg(e,t){return t===","||t==="."?60+Math.random()*50:t===" "?15+Math.random()*25:Math.random()<.35?8+Math.random()*12:Math.random()<.06?45+Math.random()*35:18+Math.random()*22}const n6=["Scan my Downloads and tell me what I should clean up","Index a folder of documents so I can chat about them","What have I been working on lately? Show my recent files","What hardware is in my PC? Tell me about my CPU and GPU"];function r6({onNewTask:e,onSendPrompt:t}){const{systemStatus:n}=we(),[r,i]=S.useState(""),[s,a]=S.useState(!1),[u,l]=S.useState(""),[d,h]=S.useState(!1),[f,p]=S.useState("title"),[m,T]=S.useState(!1),x=n!==null&&!n.initialized,I=n!==null&&n.lemonade_running&&!n.model_loaded;return S.useEffect(()=>{let g=0;const E=setInterval(()=>{g++,g<=N0.length?i(N0.slice(0,g)):(clearInterval(E),a(!0))},e6);return()=>clearInterval(E)},[]),S.useEffect(()=>{if(!s)return;let g=!1;const E=setTimeout(()=>{if(g)return;p("subtitle");let v=0;const O=()=>{if(!g)if(v++,v<=Ia.length){l(Ia.slice(0,v));const A=Ia[v-1],F=v>1?Ia[v-2]:"",H=Gg(A,F);y.current=setTimeout(O,H)}else h(!0),p("done")};O()},t6),y={current:null};return()=>{g=!0,clearTimeout(E),y.current&&clearTimeout(y.current)}},[s]),S.useEffect(()=>{if(!d)return;const g=setTimeout(()=>T(!0),200);return()=>clearTimeout(g)},[d]),c.jsx("main",{className:"welcome",children:c.jsxs("div",{className:`welcome-inner ${m?"content-revealed":""}`,children:[c.jsxs("h1",{className:`welcome-title${s?" typing-done":""}`,children:[r.length>=4?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"gaia-glow",children:r.slice(0,4)}),c.jsx("span",{children:r.slice(4)})]}):r,f==="title"&&c.jsx("span",{className:`terminal-cursor${s?" blink":""}`})]}),c.jsx("p",{className:"welcome-sub",children:c.jsxs("span",{className:"typewriter-text",children:[u,(f==="subtitle"||f==="done")&&c.jsx("span",{className:`terminal-cursor terminal-cursor-sub${f==="done"?" blink":""}`})]})}),c.jsxs("span",{className:"welcome-version",children:["v","0.17.0"," ",c.jsx("span",{className:"beta-badge",children:"BETA"})]}),c.jsxs("div",{className:"features",children:[c.jsx(La,{icon:c.jsx(Yp,{size:22}),title:"Private",desc:"Data stays on your device",codeHint:"> encrypt --local",expandedDesc:"All processing happens on-device. No cloud, no tracking, complete data privacy."}),c.jsx(La,{icon:c.jsx(Wp,{size:22}),title:"Fast",desc:"NPU acceleration",codeHint:"> npu.accelerate()",expandedDesc:"Hardware-accelerated with AMD Ryzen AI NPU for real-time local inference."}),c.jsx(La,{icon:c.jsx(wn,{size:22}),title:"Smart",desc:"Document Q&A",codeHint:'> rag.query("...")',expandedDesc:"RAG-powered document Q&A — index files and chat with their contents."}),c.jsx(La,{icon:c.jsx(VT,{size:22}),title:"Free",desc:"No subscriptions",codeHint:"> license: MIT",expandedDesc:"No API keys, no subscriptions, no hidden costs. Fully open-source."})]}),x&&c.jsxs("div",{className:"welcome-setup-hint",children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:[c.jsx("strong",{children:"First time?"})," Run ",c.jsx("code",{children:"gaia init --profile chat"})," in a terminal to install Lemonade Server and download the required AI models (~25 GB)."]})]}),!x&&I&&c.jsxs("div",{className:"welcome-setup-hint",children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:["No model loaded. Run ",c.jsx("code",{children:"gaia init --profile chat"})," to download models (~25 GB)."]})]}),c.jsx("button",{className:"btn-primary start-btn",onClick:e,children:"Start a New Task"}),c.jsxs("div",{className:"suggestions",children:[c.jsx("span",{className:"suggestions-label",children:"Try asking:"}),c.jsx("div",{className:"suggestion-chips",children:n6.map(g=>c.jsx("button",{className:"chip",onClick:()=>t(g),children:g},g))})]}),c.jsx("p",{className:"welcome-copyright",children:"© 2025–2026 Advanced Micro Devices, Inc. All rights reserved."})]})})}function La({icon:e,title:t,desc:n,expandedDesc:r,codeHint:i}){const[s,a]=S.useState("idle"),[u,l]=S.useState(i),[d,h]=S.useState(""),f=S.useRef(null),p=()=>{a("erasing"),h("");let x=i.length;const I=()=>{if(x--,x>=0)l(i.slice(0,x)),f.current=setTimeout(I,15+Math.random()*20);else{a("typing"),l("");let g=0;const E=()=>{if(g++,g<=r.length){h(r.slice(0,g));const y=r[g-1],v=g>1?r[g-2]:"";f.current=setTimeout(E,Gg(y,v))}else a("done")};E()}};I()},m=()=>{f.current&&clearTimeout(f.current),a("idle"),l(i),h("")};S.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const T=s!=="idle";return c.jsxs("div",{className:`feature-card ${T?"feature-hovered":""}`,onMouseEnter:p,onMouseLeave:m,children:[c.jsx("div",{className:"feature-icon",children:e}),c.jsx("h3",{children:t}),c.jsx("p",{children:n}),c.jsxs("div",{className:"feature-terminal",children:[s==="idle"&&c.jsx("span",{className:"feature-code-hint",children:i}),s==="erasing"&&c.jsxs("span",{className:"feature-inline",children:[c.jsx("span",{className:"feature-code-hint feature-code-erasing",children:u}),c.jsx("span",{className:"terminal-cursor terminal-cursor-sm"})]}),(s==="typing"||s==="done")&&c.jsxs("span",{className:"feature-inline",children:[c.jsx("span",{className:"feature-expanded-text",children:d}),c.jsx("span",{className:`terminal-cursor terminal-cursor-sm${s==="done"?" blink":""}`})]})]})]})}function i6(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return`${n}m ${r}s`}function s6(e){try{const t=new Date(e);if(isNaN(t.getTime()))return"";const r=new Date().getTime()-t.getTime(),i=Math.floor(r/1e3),s=Math.floor(i/60),a=Math.floor(s/60),u=Math.floor(a/24);return i<60?"just now":s<60?`${s}m ago`:a<24?`${a}h ago`:u===1?"yesterday":u<7?`${u}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return""}}function a6(e){try{const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}catch{return""}}function u6(){const{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:r,currentSessionId:i,sessions:s,updateSessionInList:a}=we(),u=s.find(j=>j.id===i)??null,[l,d]=S.useState(!1),[h,f]=S.useState(!1),[p,m]=S.useState(""),[T,x]=S.useState(""),[I,g]=S.useState(null),E=S.useRef(new Map),[,y]=S.useState(0);S.useEffect(()=>{D.doc.info("Loading document library...");const j=D.doc.time();ei().then(z=>{const P=z.documents||[];t(P),D.doc.timed(`Loaded ${P.length} document(s), ${z.total_chunks||0} chunks, ${z.total_size_bytes||0} bytes total`,j)}).catch(z=>{D.doc.error("Failed to load documents",z),t([])})},[t]);const v=e.some(j=>j.indexing_status==="indexing"||j.indexing_status==="pending");S.useEffect(()=>{if(!v)return;const j=we.getState().documents;for(const G of j)(G.indexing_status==="indexing"||G.indexing_status==="pending")&&!E.current.has(G.id)&&E.current.set(G.id,Date.now());let z=!1;const P=setInterval(async()=>{if(y(G=>G+1),!z){z=!0;try{const _=we.getState().documents.filter(Z=>Z.indexing_status==="indexing"||Z.indexing_status==="pending");for(const Z of _)try{const fe=await sb(Z.id);if(fe.indexing_status!=="indexing"&&fe.indexing_status!=="pending"){E.current.delete(Z.id);const N=await ei();t(N.documents||[]);break}}catch{}}finally{z=!1}}},2e3);return()=>clearInterval(P)},[v,t]),S.useEffect(()=>{const j=new Set(e.filter(z=>z.indexing_status==="indexing"||z.indexing_status==="pending").map(z=>z.id));for(const z of E.current.keys())j.has(z)||E.current.delete(z)},[e]),S.useEffect(()=>{const j=setInterval(async()=>{try{const P=(await ei()).documents||[],G=we.getState().documents;(P.length!==G.length||P.some((Z,fe)=>{const N=G.find(Ne=>Ne.id===Z.id);return!N||N.indexing_status!==Z.indexing_status||N.indexed_at!==Z.indexed_at||N.chunk_count!==Z.chunk_count}))&&(t(P),D.doc.debug("Document list refreshed (server-side changes detected)"))}catch{}},15e3);return()=>clearInterval(j)},[t]);const O=e.reduce((j,z)=>j+z.file_size,0),A=e.reduce((j,z)=>j+z.chunk_count,0),F=j=>{if(j<=0)return"0 B";const z=1024,P=["B","KB","MB","GB"],G=Math.min(Math.floor(Math.log(j)/Math.log(z)),P.length-1);return parseFloat((j/Math.pow(z,G)).toFixed(1))+" "+P[G]},H=S.useCallback(async(j,z)=>{var _;const P=z.includes(".")?"."+((_=z.split(".").pop())==null?void 0:_.toLowerCase()):"";if(P&&!mc(P)){const Z=Ru(P),fe=Z?Z.message:`The file type "${P}" is not supported for indexing.`;D.doc.warn(`Unsupported file type: ${z} (${P})`),g({filename:z,error:fe});return}D.doc.info(`Indexing document: ${z} (${j})`);const G=D.doc.time();f(!0),m(`Indexing ${z}...`),g(null);try{const Z=await md(j);if(D.doc.timed(`Indexed "${z}": ${(Z==null?void 0:Z.chunk_count)||"?"} chunks`,G),i&&(Z!=null&&Z.id))try{await Su(i,Z.id);const N=we.getState().sessions.find(re=>re.id===i),Ne=(N==null?void 0:N.document_ids)??[];Ne.includes(Z.id)||a(i,{document_ids:[...Ne,Z.id]}),D.doc.info(`Auto-attached "${z}" to session ${i}`)}catch(N){D.doc.warn(`Could not attach document to session: ${N}`)}const fe=await ei();t(fe.documents||[]),m("")}catch(Z){D.doc.error(`Failed to index "${z}"`,Z);const fe=Z instanceof Error?Z.message:"Upload failed";g({filename:z,error:fe}),m("")}finally{f(!1)}},[i,a,t]),K=S.useCallback(async j=>{j.preventDefault(),d(!1);const z=Array.from(j.dataTransfer.files);D.doc.info(`Dropped ${z.length} file(s) into Document Library`);for(const P of z){const G=P.path||P.name;await H(G,P.name)}},[H]),w=S.useCallback(async j=>{const z=e.find(P=>P.id===j);D.doc.info(`Deleting document: ${(z==null?void 0:z.filename)||j}`);try{await ib(j),E.current.delete(j),t(e.filter(P=>P.id!==j)),D.doc.info(`Deleted document: ${(z==null?void 0:z.filename)||j}`)}catch(P){D.doc.error(`Failed to delete document: ${(z==null?void 0:z.filename)||j}`,P)}},[e,t]),Y=S.useCallback(async(j,z)=>{D.doc.info(`Opening folder for: ${j}`);try{await pd(j,!0)}catch(P){D.doc.error(`Failed to open folder for: ${z}`,P)}},[]),te=S.useCallback(async j=>{const z=e.find(P=>P.id===j);D.doc.info(`Cancelling indexing for: ${(z==null?void 0:z.filename)||j}`);try{await ab(j),E.current.delete(j);const P=await ei();t(P.documents||[]),D.doc.info(`Cancelled indexing for: ${(z==null?void 0:z.filename)||j}`)}catch(P){D.doc.error(`Failed to cancel indexing: ${(z==null?void 0:z.filename)||j}`,P)}},[e,t]),ce=S.useCallback(async j=>{if(!i)return;const z=e.find(P=>P.id===j);D.doc.info(`Attaching document to session: ${(z==null?void 0:z.filename)||j}`);try{await Su(i,j);const P=we.getState().sessions.find(_=>_.id===i),G=(P==null?void 0:P.document_ids)??[];G.includes(j)||a(i,{document_ids:[...G,j]}),D.doc.info(`Attached "${(z==null?void 0:z.filename)||j}" to session ${i}`)}catch(P){D.doc.error(`Failed to attach document to session: ${(z==null?void 0:z.filename)||j}`,P)}},[i,e,a]),le=S.useCallback(async j=>{j.preventDefault(),T.trim()&&(D.doc.info(`Indexing from path input: ${T.trim()}`),await H(T.trim(),T.trim().split(/[\\/]/).pop()||"file"),x(""))},[T,H]),ue=j=>{const z=j.indexing_status||"complete",P=E.current.get(j.id),G=j.indexed_at?s6(j.indexed_at):"",_=j.indexed_at?a6(j.indexed_at):"";switch(z){case"indexing":case"pending":return c.jsxs("div",{className:"doc-indexing-status",children:[c.jsxs("div",{className:"doc-indexing-bar",children:[c.jsx("div",{className:"doc-indexing-bar-track",children:c.jsx("div",{className:"doc-indexing-bar-fill"})}),c.jsxs("span",{className:"doc-indexing-label",children:[c.jsx(ey,{size:12,className:"doc-spin"}),"Indexing",P?` (${i6(P)})`:"..."]})]}),c.jsxs("button",{className:"btn-cancel",onClick:Z=>{Z.stopPropagation(),te(j.id)},title:"Cancel indexing","aria-label":`Cancel indexing ${j.filename}`,children:[c.jsx(th,{size:14}),"Cancel"]})]});case"failed":return c.jsxs("span",{className:"doc-status-badge doc-status-failed",children:[c.jsx(br,{size:12})," Failed"]});case"cancelled":return c.jsxs("span",{className:"doc-status-badge doc-status-cancelled",children:[c.jsx(th,{size:12})," Cancelled"]});case"missing":return c.jsxs("span",{className:"doc-status-badge doc-status-missing",children:[c.jsx(br,{size:12})," File missing"]});default:return c.jsxs("span",{className:"doc-meta",children:[F(j.file_size)," · ",j.chunk_count," chunks",G&&c.jsxs("span",{className:"doc-timestamp",title:`Indexed: ${_}`,children:[c.jsx(Hp,{size:10}),G]})]})}};return c.jsx("div",{className:"modal-overlay",onClick:()=>n(!1),role:"dialog","aria-modal":"true","aria-label":"Document Library",children:c.jsxs("div",{className:"modal-panel doc-modal",onClick:j=>j.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsx("h3",{children:"Document Library"}),c.jsx("button",{className:"btn-icon",onClick:()=>n(!1),"aria-label":"Close document library",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body",children:[c.jsx("div",{className:`drop-zone ${l?"drag-over":""} ${h?"uploading":""}`,onDragOver:j=>{j.preventDefault(),d(!0)},onDragLeave:()=>d(!1),onDrop:K,children:h?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"upload-spinner"}),c.jsx("p",{children:p})]}):c.jsxs(c.Fragment,{children:[c.jsx(ku,{size:32,strokeWidth:1.5}),c.jsx("p",{children:"Drop files here to index"}),c.jsx("span",{className:"drop-hint",children:"PDF, TXT, MD, code files, and 50+ formats"})]})}),c.jsxs("form",{className:"path-input-form",onSubmit:le,children:[c.jsx(Hn,{size:16,className:"path-icon"}),c.jsx("input",{type:"text",className:"path-input",value:T,onChange:j=>x(j.target.value),placeholder:"Or enter file path: C:\\docs\\manual.pdf","aria-label":"File path to index"}),c.jsx("button",{type:"submit",className:"btn-secondary",disabled:!T.trim()||h,children:"Index"}),c.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>{n(!1),r(!0)},title:"Browse files on this computer",children:[c.jsx(Pr,{size:14}),"Browse Files"]})]}),I&&c.jsx(Qg,{filename:I.filename,error:I.error,onDismiss:()=>g(null)}),e.length>0&&c.jsxs("div",{className:"doc-stats",children:[c.jsxs("span",{children:[e.length," document",e.length!==1?"s":""]}),c.jsx("span",{children:"·"}),c.jsxs("span",{children:[A," chunks"]}),c.jsx("span",{children:"·"}),c.jsx("span",{children:F(O)})]}),c.jsxs("div",{className:"doc-list",children:[e.length===0&&!h&&c.jsxs("div",{className:"empty-docs",children:[c.jsx(wn,{size:32,strokeWidth:1}),c.jsx("p",{children:"No documents indexed yet"}),c.jsx("span",{children:"Drop files above or enter a file path"})]}),e.map(j=>{var z;return c.jsxs("div",{className:`doc-row ${j.indexing_status==="indexing"?"doc-row-indexing":""}`,children:[c.jsxs("div",{className:"doc-info",children:[c.jsx("span",{className:"doc-name",children:j.filename}),ue(j)]}),c.jsxs("div",{className:"doc-row-actions",children:[j.filepath&&c.jsx("button",{className:"btn-icon-sm doc-open-folder",onClick:()=>Y(j.filepath,j.filename),title:`Open folder: ${j.filepath}`,"aria-label":`Open containing folder for ${j.filename}`,children:c.jsx(Hn,{size:14})}),i&&j.indexing_status==="complete"&&!((z=u==null?void 0:u.document_ids)!=null&&z.includes(j.id))&&c.jsx("button",{className:"btn-icon-sm doc-attach",onClick:()=>ce(j.id),title:"Use in current session","aria-label":`Attach ${j.filename} to current session`,children:c.jsx(XT,{size:14})}),j.indexing_status!=="indexing"&&j.indexing_status!=="pending"&&c.jsx("button",{className:"btn-icon-sm doc-delete",onClick:()=>w(j.id),title:"Remove","aria-label":`Remove ${j.filename}`,children:c.jsx(_u,{size:14})})]})]},j.id)})]})]})]})})}function l6(e){if(e.type==="folder")return c.jsx($p,{size:16});const t=(e.extension||"").toLowerCase();return[".csv",".xlsx",".xls",".tsv"].includes(t)?c.jsx(gy,{size:16}):[".py",".js",".ts",".java",".c",".cpp",".go",".rs"].includes(t)?c.jsx($T,{size:16}):[".pdf",".doc",".docx",".txt",".md"].includes(t)?c.jsx(wn,{size:16}):c.jsx(zp,{size:16})}function o6(e){if(e<=0)return"";const t=1024,n=["B","KB","MB","GB"],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/Math.pow(t,r)).toFixed(1))+" "+n[r]}function c6(e){if(!e)return"";const t=new Date(e),n=new Date,r=n.getTime()-t.getTime(),i=Math.floor(r/36e5);if(i<1)return"Just now";if(i<24)return`${i}h ago`;const s=Math.floor(i/24);return s<7?`${s}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==n.getFullYear()?"numeric":void 0})}function d6(e){switch(e){case"home":return c.jsx(GT,{size:14});case"desktop":return c.jsx(ry,{size:14});case"documents":return c.jsx(wn,{size:14});case"download":return c.jsx(dd,{size:14});default:return c.jsx($p,{size:14})}}const f6=[{label:"All Files",value:""},{label:"Documents",value:"pdf,doc,docx,txt,md"},{label:"Spreadsheets",value:"csv,xlsx,xls,tsv"},{label:"Code",value:"py,js,ts,java,c,cpp,go,rs,rb,sh"},{label:"Data",value:"json,xml,yaml,yml,csv,tsv"}];function h6(){const{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n}=we(),[r,i]=S.useState(""),[s,a]=S.useState(null),[u,l]=S.useState([]),[d,h]=S.useState([]),[f,p]=S.useState(!1),[m,T]=S.useState(null),[x,I]=S.useState(""),[g,E]=S.useState(null),[y,v]=S.useState(!1),[O,A]=S.useState(""),[F,H]=S.useState(new Set),[K,w]=S.useState(null),[Y,te]=S.useState(!1),[ce,le]=S.useState(new Set),[ue,j]=S.useState(null),z=S.useRef(null),[P,G]=S.useState(null),_=S.useCallback(async R=>{p(!0),T(null),E(null),I("");try{const W=await lb(R);i(W.current_path),a(W.parent_path),l(W.entries),W.quick_links.length>0&&h(W.quick_links),D.ui.info(`Browsing: ${W.current_path} (${W.entries.length} items)`)}catch(W){const de=W instanceof Error?W.message:"Failed to load directory";T(de),D.ui.error("Browse failed",W)}finally{p(!1)}},[]);S.useEffect(()=>{_()},[_]),S.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]);const Z=S.useCallback(async()=>{if(!x.trim()){E(null);return}v(!0),T(null);try{const R=await cb(x.trim(),O||void 0,30);E(R.results),D.ui.info(`Search "${x}": ${R.total} results`)}catch(R){const W=R instanceof Error?R.message:"Search failed";T(W),D.ui.error("Search failed",R)}finally{v(!1)}},[x,O]),fe=R=>{R.key==="Enter"&&Z()},N=S.useCallback(R=>{R.type==="folder"&&(_(R.path),H(new Set),w(null))},[_]),Ne=S.useCallback(async R=>{te(!0);try{const W=await db(R);w(W)}catch(W){D.ui.error("Preview failed",W)}finally{te(!1)}},[]),re=S.useCallback(async()=>{var Nr,kt;if(F.size===0)return;const R=Array.from(F);G(null);const W=[],de=[];for(const Se of R){const Ve=Se.includes(".")?"."+((Nr=Se.split(".").pop())==null?void 0:Nr.toLowerCase()):"";Ve&&!mc(Ve)?de.push(Se):W.push(Se)}if(de.length>0&&W.length===0){const Se=de[0],Ve="."+((kt=Se.split(".").pop())==null?void 0:kt.toLowerCase()),St=Ru(Ve);G({filename:de.length===1?Se.split(/[\\/]/).pop()||Se:`${de.length} files`,error:St?St.message:`File type "${Ve}" is not supported for indexing.`});return}if(de.length>0&&(D.doc.warn(`Skipping ${de.length} unsupported file(s)`),j(`Skipping ${de.length} unsupported file(s)...`)),W.length===0)return;le(new Set(W)),j(`Indexing ${W.length} file(s)...`);let Ae=0,be=0,Re="";const ze=[],Gn=new Set(u.filter(Se=>Se.type==="folder").map(Se=>Se.path));for(const Se of W)try{if(Gn.has(Se))(await ob(Se)).documents.forEach(St=>{St.id&&ze.push(St.id)});else{const Ve=await md(Se);Ve!=null&&Ve.id&&ze.push(Ve.id)}Ae++,j(`Indexed ${Ae}/${W.length}...`)}catch(Ve){be++,Re=Ve instanceof Error?Ve.message:"Unknown error"}if(t&&ze.length>0){for(const bn of ze)try{await Su(t,bn)}catch(Ht){D.doc.warn(`Could not attach document to session: ${Ht}`)}const Se=we.getState().sessions.find(bn=>bn.id===t),Ve=(Se==null?void 0:Se.document_ids)??[],St=ze.filter(bn=>!Ve.includes(bn));St.length>0&&n(t,{document_ids:[...Ve,...St]})}if(le(new Set),be>0)j(`Done: ${Ae} indexed, ${be} failed`),G({filename:`${be} file(s)`,error:Re||"Indexing failed for some files"});else{const Se=de.length>0?` (${de.length} skipped — unsupported type)`:"";j(`Successfully indexed ${Ae} file(s)${Se}`)}z.current&&clearTimeout(z.current),z.current=setTimeout(()=>j(null),5e3),H(new Set)},[F,t,n]),me=S.useCallback(()=>{if(F.size===0)return;const R=Array.from(F);e(!1);const W=R.length===1?`Analyze this file for me: ${R[0]}`:`Analyze these files for me:
428
+ If Lemonade Server is running but responses are slow, the model may need more resources.`+Je:_e=`Error: ${Me}`+Je;const zt={id:Date.now()+2,session_id:e,role:"assistant",content:_e,created_at:new Date().toISOString(),rag_sources:null};i(zt),h(!1),p(),E()}});Se.current=Xt},[le,me,l,e,Y,i,r,h,ge,p,u,T,x,I,g,E]);bn.current=Kr,S.useEffect(()=>{!l&&kt.current&&kt.current.focus()},[l]);const Xg=S.useCallback(async M=>{l||(D.chat.info(`Deleting message ${M} from session=${e}`),W(M),setTimeout(async()=>{s(M),W(null);try{await Zy(e,M)}catch(ne){D.chat.error(`Failed to delete message ${M}`,ne),us(e).then(ae=>{we.getState().currentSessionId===e&&r(ae.messages||[])}).catch(()=>{})}},250))},[e,l,s,r]),Jg=S.useCallback(async M=>{if(l||M.role!=="user")return;const ne=M.content;D.chat.info(`Resending message ${M.id} from session=${e}`,{preview:ne.slice(0,80)}),a(M.id);try{await eb(e,M.id)}catch(ae){D.chat.error(`Failed to delete messages from ${M.id}`,ae),us(e).then(ee=>{we.getState().currentSessionId===e&&r(ee.messages||[])}).catch(()=>{});return}Kr(ne)},[e,l,a,r,Kr]),Zg=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),Kr())},[jd,Ud]=S.useState(!1),eE=S.useCallback(M=>{M.preventDefault();const ne=mn(e),ae=`${window.location.origin}${window.location.pathname}#${ne}`;navigator.clipboard.writeText(ae).then(()=>{D.ui.info(`Copied session link: ${ae}`),Ud(!0),setTimeout(()=>Ud(!1),1500)}).catch(()=>{D.ui.warn("Clipboard write failed")})},[e]),tE=()=>{G((Y==null?void 0:Y.title)||""),z(!0)},Hd=async()=>{P.trim()&&P!==(Y==null?void 0:Y.title)&&(await sh(e,{title:P.trim()}),u(e,{title:P.trim()})),z(!1)},nE=async()=>{try{const M=await Jy(e),ne=new Blob([M.content],{type:"text/markdown"}),ae=URL.createObjectURL(ne),ee=document.createElement("a");ee.href=ae;const xe=((Y==null?void 0:Y.title)||"chat").replace(/[/\\:*?"<>|]/g,"_").slice(0,100);ee.download=`${xe}.md`,ee.click(),URL.revokeObjectURL(ae)}catch(M){D.chat.error("Export failed",M)}},rE=S.useCallback(async(M,ne)=>{M.stopPropagation();const ae=y.find(ee=>ee.id===ne);D.doc.info(`Detaching document from session: ${(ae==null?void 0:ae.filename)||ne}`);try{await ub(e,ne);const ee=we.getState().sessions.find(Le=>Le.id===e),xe=((ee==null?void 0:ee.document_ids)??[]).filter(Le=>Le!==ne);u(e,{document_ids:xe}),xe.length<=3&&He(!1),D.doc.info(`Detached document from session: ${(ae==null?void 0:ae.filename)||ne}`)}catch(ee){D.doc.error(`Failed to detach document: ${(ae==null?void 0:ae.filename)||ne}`,ee)}},[y,e,u]),iE=S.useCallback(async M=>{if(M.preventDefault(),M.stopPropagation(),Z(!1),M.dataTransfer.files.length>0){O(!0);for(const ne of Array.from(M.dataTransfer.files)){const ae=ne.path||ne.name;try{const ee=await md(ae);if(e&&(ee!=null&&ee.id))try{await Su(e,ee.id);const xe=we.getState().sessions.find(pt=>pt.id===e),Le=(xe==null?void 0:xe.document_ids)??[];Le.includes(ee.id)||u(e,{document_ids:[...Le,ee.id]})}catch(xe){D.doc.warn(`Could not attach dropped document to session: ${xe}`)}}catch(ee){D.doc.error(`Upload failed: ${ae}`,ee)}}}},[e,u,O]),sE=M=>{M.preventDefault(),M.stopPropagation(),Z(!0)},aE=M=>{M.preventDefault(),M.stopPropagation(),Z(!1)},uE=M=>{ue(M),Kr(M)},lE=!F&&n.length===0&&!l,oE=S.useMemo(()=>{const M=new Map;let ne;for(const ae of n)if(ae.role==="user"&&ae.created_at)ne=new Date(ae.created_at).getTime();else if(ae.role==="assistant"&&ae.created_at&&ne!==void 0){const ee=new Date(ae.created_at).getTime();ee>ne&&M.set(ae.id,ee-ne),ne=void 0}return M},[n]);return c.jsxs("main",{className:`chat-view ${_?"drag-active":""}`,onDrop:iE,onDragOver:sE,onDragLeave:aE,children:[c.jsxs("header",{className:"chat-header",children:[c.jsx("div",{className:"chat-header-left",children:j?c.jsx("input",{className:"title-edit",value:P,onChange:M=>G(M.target.value),onBlur:Hd,onKeyDown:M=>M.key==="Enter"&&Hd(),autoFocus:!0,"aria-label":"Edit chat title"}):c.jsxs(c.Fragment,{children:[c.jsx("h3",{className:"chat-title",children:(Y==null?void 0:Y.title)||"Chat"}),c.jsx("button",{className:"btn-icon-sm",onClick:tE,title:"Rename","aria-label":"Rename chat",children:c.jsx(ly,{size:13})})]})}),c.jsxs("div",{className:"chat-header-right",children:[c.jsxs("a",{className:`session-hash-badge ${jd?"copied":""}`,href:`#${mn(e)}`,onClick:eE,title:jd?"Copied!":`Copy session link #${mn(e)}`,"aria-label":`Copy link for session ${mn(e)}`,children:[c.jsx(JT,{size:10}),c.jsxs("span",{children:["#",mn(e)]})]}),c.jsx("span",{className:`model-badge ${K!=null&&K.model_loaded?"":"no-model"}`,children:(K==null?void 0:K.model_loaded)||"No model loaded"}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>O(!0),title:"Documents","aria-label":"Attach documents",children:c.jsx(uy,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>A(!0),title:"Browse files","aria-label":"Browse files",children:c.jsx(eh,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:nE,title:"Export","aria-label":"Export chat",children:c.jsx(dd,{size:15})})]})]}),ce.length>0&&(()=>{const M=[...ce].sort((ee,xe)=>{const Le=ee.last_accessed_at||ee.indexed_at||"";return(xe.last_accessed_at||xe.indexed_at||"").localeCompare(Le)}),ne=De?M:M.slice(0,3),ae=M.length-3;return c.jsxs("div",{className:`doc-context-bar${De?" doc-context-expanded":""}`,"aria-label":`${ce.length} indexed document${ce.length!==1?"s":""}`,children:[c.jsx(cd,{size:12,className:"doc-context-icon"}),c.jsxs("span",{className:"doc-context-label",onClick:()=>O(!0),title:"Click to manage documents",role:"button",tabIndex:0,children:[ce.length," indexed"]}),c.jsxs("div",{className:`doc-context-pills${De?" doc-context-pills-expanded":""}`,children:[ne.map(ee=>c.jsxs("span",{className:"doc-pill",title:ee.filepath||ee.filename,children:[c.jsx(wn,{size:9,className:"doc-pill-icon"}),c.jsx("span",{className:"doc-pill-name",children:ee.filename}),c.jsx("button",{className:"doc-pill-remove",onClick:xe=>rE(xe,ee.id),title:`Remove ${ee.filename} from this session`,"aria-label":`Remove ${ee.filename} from this session`,children:c.jsx(Mt,{size:10})})]},ee.id)),!De&&ae>0&&c.jsxs("button",{className:"doc-pill-more",onClick:ee=>{ee.stopPropagation(),He(!0)},title:"Show all indexed files","aria-label":`Show ${ae} more files`,children:["+",ae," more"]}),De&&ae>0&&c.jsx("button",{className:"doc-pill-collapse",onClick:ee=>{ee.stopPropagation(),He(!1)},title:"Show fewer files","aria-label":"Collapse file list",children:"show less"})]})]})})(),c.jsxs("div",{className:"messages-scroll",ref:Nr,onScroll:Rn,children:[F&&c.jsx("div",{className:"skeleton-messages","aria-label":"Loading messages",children:[0,1,2].map(M=>c.jsxs("div",{className:"skeleton-msg",children:[c.jsxs("div",{className:"skeleton-header",children:[c.jsx("div",{className:"skeleton-avatar"}),c.jsx("div",{className:"skeleton-role"})]}),c.jsxs("div",{className:"skeleton-lines",children:[c.jsx("div",{className:"skeleton-line"}),c.jsx("div",{className:"skeleton-line"}),M!==2&&c.jsx("div",{className:"skeleton-line"})]})]},M))}),lE&&c.jsxs("div",{className:"empty-chat",children:[c.jsx("div",{className:"empty-chat-icon",children:c.jsx(ny,{size:36,strokeWidth:1.2})}),c.jsx("h4",{className:"empty-chat-title",children:"What can I help you with?"}),c.jsx("p",{className:"empty-chat-desc",children:"Ask about your documents, search files, or analyze data — powered by local AI."}),c.jsx("div",{className:"empty-chat-suggestions",children:Kv.map(M=>c.jsx("button",{className:"empty-chat-chip",onClick:()=>uE(M),children:M},M))})]}),n.map((M,ne)=>{const ae=!l&&!de&&M.role==="assistant"&&n.slice(ne+1).every(Le=>Le.role!=="assistant");if(de&&M.role==="assistant"&&ne===n.length-1)return null;const xe=oE.get(M.id);return c.jsx("div",{className:R===M.id?"msg-deleting":void 0,children:c.jsx(S0,{message:M,showTerminalCursor:ae,agentSteps:M.role==="assistant"?M.agentSteps:void 0,onDelete:l?void 0:Xg,onResend:!l&&M.role==="user"?Jg:void 0,latencyMs:xe})},M.id)}),(l||de)&&c.jsx("div",{className:`streaming-bubble ${de?"stream-ending":"stream-active"}`,children:c.jsx(S0,{message:{id:-1,session_id:e,role:"assistant",content:(l?d:be.current)||"",created_at:"",rag_sources:null},isStreaming:l,showTerminalCursor:de,agentSteps:l?m:Re.current,agentStepsActive:l&&m.some(M=>M.active)})}),c.jsx("div",{ref:Gn})]}),fe&&c.jsx("button",{className:"scroll-bottom-btn",onClick:un,title:"Scroll to bottom","aria-label":"Scroll to bottom",children:c.jsx(BT,{size:16})}),_&&c.jsxs("div",{className:"drag-overlay",children:[c.jsx(ku,{size:32,strokeWidth:1.5}),c.jsx("span",{children:"Drop files to index"})]}),c.jsxs("div",{className:"input-area",children:[c.jsxs("div",{className:`input-box ${me.length>0?"has-attachments":""}`,onDrop:Kn,onDragOver:M=>{M.preventDefault(),M.stopPropagation()},children:[c.jsxs("div",{className:"input-content",children:[me.length>0&&c.jsx("div",{className:"attachment-strip",children:me.map(M=>c.jsxs("div",{className:`attachment-preview ${M.error?"attachment-error":""}`,children:[M.isImage&&M.url?c.jsx("img",{src:M.url,alt:M.name,className:"attachment-thumb"}):c.jsx("div",{className:"attachment-file-icon",children:c.jsx(wn,{size:16})}),c.jsx("span",{className:"attachment-name",title:M.name,children:M.name.length>20?M.name.slice(0,17)+"...":M.name}),M.uploading&&c.jsx("span",{className:"attachment-spinner"}),M.error&&c.jsx("span",{className:"attachment-error-text",children:M.error}),c.jsx("button",{className:"attachment-remove",onClick:()=>ln(M.id),title:"Remove","aria-label":`Remove ${M.name}`,children:c.jsx(Mt,{size:12})})]},M.id))}),c.jsx("textarea",{ref:kt,className:"msg-input",value:le,onChange:Ar,onKeyDown:Zg,onPaste:Ct,placeholder:"Type a message or paste an image... (Shift+Enter for new line)",rows:1,disabled:l,"aria-label":"Message input"})]}),!l&&c.jsx("span",{className:"input-cursor","aria-hidden":"true"}),c.jsxs("div",{className:"input-btns",children:[c.jsx("button",{className:"btn-icon-sm",onClick:()=>O(!0),title:"Upload document","aria-label":"Upload document",children:c.jsx(ku,{size:15})}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>A(!0),title:"Browse files","aria-label":"Browse files",children:c.jsx(eh,{size:15})}),l?c.jsx("button",{className:"stop-btn",onClick:On,title:"Stop generating","aria-label":"Stop generating",children:c.jsx(my,{size:14})}):c.jsx("button",{className:"send-btn",onClick:()=>Kr(),disabled:!le.trim()&&!me.some(M=>M.uploaded),title:"Send (Enter)","aria-label":"Send message",children:c.jsx(dy,{size:16})})]})]}),c.jsxs("div",{className:"input-footer",children:[c.jsxs("span",{className:"input-footer-item",children:[c.jsx(Yp,{size:10}),c.jsx("span",{children:"100% local & private"})]}),c.jsx("span",{className:"input-footer-sep"}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Enter"}),c.jsx("span",{children:"send"})]}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Shift+Enter"}),c.jsx("span",{children:"new line"})]}),l&&c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Esc"}),c.jsx("span",{children:"stop"})]}),c.jsx("span",{className:"input-footer-sep"}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Ctrl+K"}),c.jsx("span",{children:"search"})]}),c.jsxs("span",{className:"input-footer-item",children:[c.jsx("kbd",{className:"kbd-hint",children:"Ctrl+V"}),c.jsx("span",{children:"paste image"})]})]})]})]})}const N0="GAIA Agent UI",Ia="Your private AI assistant, running 100% locally on AMD Ryzen AI",e6=65,t6=350;function Gg(e,t){return t===","||t==="."?60+Math.random()*50:t===" "?15+Math.random()*25:Math.random()<.35?8+Math.random()*12:Math.random()<.06?45+Math.random()*35:18+Math.random()*22}const n6=["Scan my Downloads and tell me what I should clean up","Index a folder of documents so I can chat about them","What have I been working on lately? Show my recent files","What hardware is in my PC? Tell me about my CPU and GPU"];function r6({onNewTask:e,onSendPrompt:t}){const{systemStatus:n}=we(),[r,i]=S.useState(""),[s,a]=S.useState(!1),[u,l]=S.useState(""),[d,h]=S.useState(!1),[f,p]=S.useState("title"),[m,T]=S.useState(!1),x=n!==null&&!n.initialized,I=n!==null&&n.lemonade_running&&!n.model_loaded;return S.useEffect(()=>{let g=0;const E=setInterval(()=>{g++,g<=N0.length?i(N0.slice(0,g)):(clearInterval(E),a(!0))},e6);return()=>clearInterval(E)},[]),S.useEffect(()=>{if(!s)return;let g=!1;const E=setTimeout(()=>{if(g)return;p("subtitle");let v=0;const O=()=>{if(!g)if(v++,v<=Ia.length){l(Ia.slice(0,v));const A=Ia[v-1],F=v>1?Ia[v-2]:"",H=Gg(A,F);y.current=setTimeout(O,H)}else h(!0),p("done")};O()},t6),y={current:null};return()=>{g=!0,clearTimeout(E),y.current&&clearTimeout(y.current)}},[s]),S.useEffect(()=>{if(!d)return;const g=setTimeout(()=>T(!0),200);return()=>clearTimeout(g)},[d]),c.jsx("main",{className:"welcome",children:c.jsxs("div",{className:`welcome-inner ${m?"content-revealed":""}`,children:[c.jsxs("h1",{className:`welcome-title${s?" typing-done":""}`,children:[r.length>=4?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"gaia-glow",children:r.slice(0,4)}),c.jsx("span",{children:r.slice(4)})]}):r,f==="title"&&c.jsx("span",{className:`terminal-cursor${s?" blink":""}`})]}),c.jsx("p",{className:"welcome-sub",children:c.jsxs("span",{className:"typewriter-text",children:[u,(f==="subtitle"||f==="done")&&c.jsx("span",{className:`terminal-cursor terminal-cursor-sub${f==="done"?" blink":""}`})]})}),c.jsxs("span",{className:"welcome-version",children:["v","0.17.1"," ",c.jsx("span",{className:"beta-badge",children:"BETA"})]}),c.jsxs("div",{className:"features",children:[c.jsx(La,{icon:c.jsx(Yp,{size:22}),title:"Private",desc:"Data stays on your device",codeHint:"> encrypt --local",expandedDesc:"All processing happens on-device. No cloud, no tracking, complete data privacy."}),c.jsx(La,{icon:c.jsx(Wp,{size:22}),title:"Fast",desc:"NPU acceleration",codeHint:"> npu.accelerate()",expandedDesc:"Hardware-accelerated with AMD Ryzen AI NPU for real-time local inference."}),c.jsx(La,{icon:c.jsx(wn,{size:22}),title:"Smart",desc:"Document Q&A",codeHint:'> rag.query("...")',expandedDesc:"RAG-powered document Q&A — index files and chat with their contents."}),c.jsx(La,{icon:c.jsx(VT,{size:22}),title:"Free",desc:"No subscriptions",codeHint:"> license: MIT",expandedDesc:"No API keys, no subscriptions, no hidden costs. Fully open-source."})]}),x&&c.jsxs("div",{className:"welcome-setup-hint",children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:[c.jsx("strong",{children:"First time?"})," Run ",c.jsx("code",{children:"gaia init --profile chat"})," in a terminal to install Lemonade Server and download the required AI models (~25 GB)."]})]}),!x&&I&&c.jsxs("div",{className:"welcome-setup-hint",children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:["No model loaded. Run ",c.jsx("code",{children:"gaia init --profile chat"})," to download models (~25 GB)."]})]}),c.jsx("button",{className:"btn-primary start-btn",onClick:e,children:"Start a New Task"}),c.jsxs("div",{className:"suggestions",children:[c.jsx("span",{className:"suggestions-label",children:"Try asking:"}),c.jsx("div",{className:"suggestion-chips",children:n6.map(g=>c.jsx("button",{className:"chip",onClick:()=>t(g),children:g},g))})]}),c.jsx("p",{className:"welcome-copyright",children:"© 2025–2026 Advanced Micro Devices, Inc. All rights reserved."})]})})}function La({icon:e,title:t,desc:n,expandedDesc:r,codeHint:i}){const[s,a]=S.useState("idle"),[u,l]=S.useState(i),[d,h]=S.useState(""),f=S.useRef(null),p=()=>{a("erasing"),h("");let x=i.length;const I=()=>{if(x--,x>=0)l(i.slice(0,x)),f.current=setTimeout(I,15+Math.random()*20);else{a("typing"),l("");let g=0;const E=()=>{if(g++,g<=r.length){h(r.slice(0,g));const y=r[g-1],v=g>1?r[g-2]:"";f.current=setTimeout(E,Gg(y,v))}else a("done")};E()}};I()},m=()=>{f.current&&clearTimeout(f.current),a("idle"),l(i),h("")};S.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const T=s!=="idle";return c.jsxs("div",{className:`feature-card ${T?"feature-hovered":""}`,onMouseEnter:p,onMouseLeave:m,children:[c.jsx("div",{className:"feature-icon",children:e}),c.jsx("h3",{children:t}),c.jsx("p",{children:n}),c.jsxs("div",{className:"feature-terminal",children:[s==="idle"&&c.jsx("span",{className:"feature-code-hint",children:i}),s==="erasing"&&c.jsxs("span",{className:"feature-inline",children:[c.jsx("span",{className:"feature-code-hint feature-code-erasing",children:u}),c.jsx("span",{className:"terminal-cursor terminal-cursor-sm"})]}),(s==="typing"||s==="done")&&c.jsxs("span",{className:"feature-inline",children:[c.jsx("span",{className:"feature-expanded-text",children:d}),c.jsx("span",{className:`terminal-cursor terminal-cursor-sm${s==="done"?" blink":""}`})]})]})]})}function i6(e){const t=Math.floor((Date.now()-e)/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return`${n}m ${r}s`}function s6(e){try{const t=new Date(e);if(isNaN(t.getTime()))return"";const r=new Date().getTime()-t.getTime(),i=Math.floor(r/1e3),s=Math.floor(i/60),a=Math.floor(s/60),u=Math.floor(a/24);return i<60?"just now":s<60?`${s}m ago`:a<24?`${a}h ago`:u===1?"yesterday":u<7?`${u}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return""}}function a6(e){try{const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"})}catch{return""}}function u6(){const{documents:e,setDocuments:t,setShowDocLibrary:n,setShowFileBrowser:r,currentSessionId:i,sessions:s,updateSessionInList:a}=we(),u=s.find(j=>j.id===i)??null,[l,d]=S.useState(!1),[h,f]=S.useState(!1),[p,m]=S.useState(""),[T,x]=S.useState(""),[I,g]=S.useState(null),E=S.useRef(new Map),[,y]=S.useState(0);S.useEffect(()=>{D.doc.info("Loading document library...");const j=D.doc.time();ei().then(z=>{const P=z.documents||[];t(P),D.doc.timed(`Loaded ${P.length} document(s), ${z.total_chunks||0} chunks, ${z.total_size_bytes||0} bytes total`,j)}).catch(z=>{D.doc.error("Failed to load documents",z),t([])})},[t]);const v=e.some(j=>j.indexing_status==="indexing"||j.indexing_status==="pending");S.useEffect(()=>{if(!v)return;const j=we.getState().documents;for(const G of j)(G.indexing_status==="indexing"||G.indexing_status==="pending")&&!E.current.has(G.id)&&E.current.set(G.id,Date.now());let z=!1;const P=setInterval(async()=>{if(y(G=>G+1),!z){z=!0;try{const _=we.getState().documents.filter(Z=>Z.indexing_status==="indexing"||Z.indexing_status==="pending");for(const Z of _)try{const fe=await sb(Z.id);if(fe.indexing_status!=="indexing"&&fe.indexing_status!=="pending"){E.current.delete(Z.id);const N=await ei();t(N.documents||[]);break}}catch{}}finally{z=!1}}},2e3);return()=>clearInterval(P)},[v,t]),S.useEffect(()=>{const j=new Set(e.filter(z=>z.indexing_status==="indexing"||z.indexing_status==="pending").map(z=>z.id));for(const z of E.current.keys())j.has(z)||E.current.delete(z)},[e]),S.useEffect(()=>{const j=setInterval(async()=>{try{const P=(await ei()).documents||[],G=we.getState().documents;(P.length!==G.length||P.some((Z,fe)=>{const N=G.find(Ne=>Ne.id===Z.id);return!N||N.indexing_status!==Z.indexing_status||N.indexed_at!==Z.indexed_at||N.chunk_count!==Z.chunk_count}))&&(t(P),D.doc.debug("Document list refreshed (server-side changes detected)"))}catch{}},15e3);return()=>clearInterval(j)},[t]);const O=e.reduce((j,z)=>j+z.file_size,0),A=e.reduce((j,z)=>j+z.chunk_count,0),F=j=>{if(j<=0)return"0 B";const z=1024,P=["B","KB","MB","GB"],G=Math.min(Math.floor(Math.log(j)/Math.log(z)),P.length-1);return parseFloat((j/Math.pow(z,G)).toFixed(1))+" "+P[G]},H=S.useCallback(async(j,z)=>{var _;const P=z.includes(".")?"."+((_=z.split(".").pop())==null?void 0:_.toLowerCase()):"";if(P&&!mc(P)){const Z=Ru(P),fe=Z?Z.message:`The file type "${P}" is not supported for indexing.`;D.doc.warn(`Unsupported file type: ${z} (${P})`),g({filename:z,error:fe});return}D.doc.info(`Indexing document: ${z} (${j})`);const G=D.doc.time();f(!0),m(`Indexing ${z}...`),g(null);try{const Z=await md(j);if(D.doc.timed(`Indexed "${z}": ${(Z==null?void 0:Z.chunk_count)||"?"} chunks`,G),i&&(Z!=null&&Z.id))try{await Su(i,Z.id);const N=we.getState().sessions.find(re=>re.id===i),Ne=(N==null?void 0:N.document_ids)??[];Ne.includes(Z.id)||a(i,{document_ids:[...Ne,Z.id]}),D.doc.info(`Auto-attached "${z}" to session ${i}`)}catch(N){D.doc.warn(`Could not attach document to session: ${N}`)}const fe=await ei();t(fe.documents||[]),m("")}catch(Z){D.doc.error(`Failed to index "${z}"`,Z);const fe=Z instanceof Error?Z.message:"Upload failed";g({filename:z,error:fe}),m("")}finally{f(!1)}},[i,a,t]),K=S.useCallback(async j=>{j.preventDefault(),d(!1);const z=Array.from(j.dataTransfer.files);D.doc.info(`Dropped ${z.length} file(s) into Document Library`);for(const P of z){const G=P.path||P.name;await H(G,P.name)}},[H]),w=S.useCallback(async j=>{const z=e.find(P=>P.id===j);D.doc.info(`Deleting document: ${(z==null?void 0:z.filename)||j}`);try{await ib(j),E.current.delete(j),t(e.filter(P=>P.id!==j)),D.doc.info(`Deleted document: ${(z==null?void 0:z.filename)||j}`)}catch(P){D.doc.error(`Failed to delete document: ${(z==null?void 0:z.filename)||j}`,P)}},[e,t]),Y=S.useCallback(async(j,z)=>{D.doc.info(`Opening folder for: ${j}`);try{await pd(j,!0)}catch(P){D.doc.error(`Failed to open folder for: ${z}`,P)}},[]),te=S.useCallback(async j=>{const z=e.find(P=>P.id===j);D.doc.info(`Cancelling indexing for: ${(z==null?void 0:z.filename)||j}`);try{await ab(j),E.current.delete(j);const P=await ei();t(P.documents||[]),D.doc.info(`Cancelled indexing for: ${(z==null?void 0:z.filename)||j}`)}catch(P){D.doc.error(`Failed to cancel indexing: ${(z==null?void 0:z.filename)||j}`,P)}},[e,t]),ce=S.useCallback(async j=>{if(!i)return;const z=e.find(P=>P.id===j);D.doc.info(`Attaching document to session: ${(z==null?void 0:z.filename)||j}`);try{await Su(i,j);const P=we.getState().sessions.find(_=>_.id===i),G=(P==null?void 0:P.document_ids)??[];G.includes(j)||a(i,{document_ids:[...G,j]}),D.doc.info(`Attached "${(z==null?void 0:z.filename)||j}" to session ${i}`)}catch(P){D.doc.error(`Failed to attach document to session: ${(z==null?void 0:z.filename)||j}`,P)}},[i,e,a]),le=S.useCallback(async j=>{j.preventDefault(),T.trim()&&(D.doc.info(`Indexing from path input: ${T.trim()}`),await H(T.trim(),T.trim().split(/[\\/]/).pop()||"file"),x(""))},[T,H]),ue=j=>{const z=j.indexing_status||"complete",P=E.current.get(j.id),G=j.indexed_at?s6(j.indexed_at):"",_=j.indexed_at?a6(j.indexed_at):"";switch(z){case"indexing":case"pending":return c.jsxs("div",{className:"doc-indexing-status",children:[c.jsxs("div",{className:"doc-indexing-bar",children:[c.jsx("div",{className:"doc-indexing-bar-track",children:c.jsx("div",{className:"doc-indexing-bar-fill"})}),c.jsxs("span",{className:"doc-indexing-label",children:[c.jsx(ey,{size:12,className:"doc-spin"}),"Indexing",P?` (${i6(P)})`:"..."]})]}),c.jsxs("button",{className:"btn-cancel",onClick:Z=>{Z.stopPropagation(),te(j.id)},title:"Cancel indexing","aria-label":`Cancel indexing ${j.filename}`,children:[c.jsx(th,{size:14}),"Cancel"]})]});case"failed":return c.jsxs("span",{className:"doc-status-badge doc-status-failed",children:[c.jsx(br,{size:12})," Failed"]});case"cancelled":return c.jsxs("span",{className:"doc-status-badge doc-status-cancelled",children:[c.jsx(th,{size:12})," Cancelled"]});case"missing":return c.jsxs("span",{className:"doc-status-badge doc-status-missing",children:[c.jsx(br,{size:12})," File missing"]});default:return c.jsxs("span",{className:"doc-meta",children:[F(j.file_size)," · ",j.chunk_count," chunks",G&&c.jsxs("span",{className:"doc-timestamp",title:`Indexed: ${_}`,children:[c.jsx(Hp,{size:10}),G]})]})}};return c.jsx("div",{className:"modal-overlay",onClick:()=>n(!1),role:"dialog","aria-modal":"true","aria-label":"Document Library",children:c.jsxs("div",{className:"modal-panel doc-modal",onClick:j=>j.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsx("h3",{children:"Document Library"}),c.jsx("button",{className:"btn-icon",onClick:()=>n(!1),"aria-label":"Close document library",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body",children:[c.jsx("div",{className:`drop-zone ${l?"drag-over":""} ${h?"uploading":""}`,onDragOver:j=>{j.preventDefault(),d(!0)},onDragLeave:()=>d(!1),onDrop:K,children:h?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"upload-spinner"}),c.jsx("p",{children:p})]}):c.jsxs(c.Fragment,{children:[c.jsx(ku,{size:32,strokeWidth:1.5}),c.jsx("p",{children:"Drop files here to index"}),c.jsx("span",{className:"drop-hint",children:"PDF, TXT, MD, code files, and 50+ formats"})]})}),c.jsxs("form",{className:"path-input-form",onSubmit:le,children:[c.jsx(Hn,{size:16,className:"path-icon"}),c.jsx("input",{type:"text",className:"path-input",value:T,onChange:j=>x(j.target.value),placeholder:"Or enter file path: C:\\docs\\manual.pdf","aria-label":"File path to index"}),c.jsx("button",{type:"submit",className:"btn-secondary",disabled:!T.trim()||h,children:"Index"}),c.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>{n(!1),r(!0)},title:"Browse files on this computer",children:[c.jsx(Pr,{size:14}),"Browse Files"]})]}),I&&c.jsx(Qg,{filename:I.filename,error:I.error,onDismiss:()=>g(null)}),e.length>0&&c.jsxs("div",{className:"doc-stats",children:[c.jsxs("span",{children:[e.length," document",e.length!==1?"s":""]}),c.jsx("span",{children:"·"}),c.jsxs("span",{children:[A," chunks"]}),c.jsx("span",{children:"·"}),c.jsx("span",{children:F(O)})]}),c.jsxs("div",{className:"doc-list",children:[e.length===0&&!h&&c.jsxs("div",{className:"empty-docs",children:[c.jsx(wn,{size:32,strokeWidth:1}),c.jsx("p",{children:"No documents indexed yet"}),c.jsx("span",{children:"Drop files above or enter a file path"})]}),e.map(j=>{var z;return c.jsxs("div",{className:`doc-row ${j.indexing_status==="indexing"?"doc-row-indexing":""}`,children:[c.jsxs("div",{className:"doc-info",children:[c.jsx("span",{className:"doc-name",children:j.filename}),ue(j)]}),c.jsxs("div",{className:"doc-row-actions",children:[j.filepath&&c.jsx("button",{className:"btn-icon-sm doc-open-folder",onClick:()=>Y(j.filepath,j.filename),title:`Open folder: ${j.filepath}`,"aria-label":`Open containing folder for ${j.filename}`,children:c.jsx(Hn,{size:14})}),i&&j.indexing_status==="complete"&&!((z=u==null?void 0:u.document_ids)!=null&&z.includes(j.id))&&c.jsx("button",{className:"btn-icon-sm doc-attach",onClick:()=>ce(j.id),title:"Use in current session","aria-label":`Attach ${j.filename} to current session`,children:c.jsx(XT,{size:14})}),j.indexing_status!=="indexing"&&j.indexing_status!=="pending"&&c.jsx("button",{className:"btn-icon-sm doc-delete",onClick:()=>w(j.id),title:"Remove","aria-label":`Remove ${j.filename}`,children:c.jsx(_u,{size:14})})]})]},j.id)})]})]})]})})}function l6(e){if(e.type==="folder")return c.jsx($p,{size:16});const t=(e.extension||"").toLowerCase();return[".csv",".xlsx",".xls",".tsv"].includes(t)?c.jsx(gy,{size:16}):[".py",".js",".ts",".java",".c",".cpp",".go",".rs"].includes(t)?c.jsx($T,{size:16}):[".pdf",".doc",".docx",".txt",".md"].includes(t)?c.jsx(wn,{size:16}):c.jsx(zp,{size:16})}function o6(e){if(e<=0)return"";const t=1024,n=["B","KB","MB","GB"],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/Math.pow(t,r)).toFixed(1))+" "+n[r]}function c6(e){if(!e)return"";const t=new Date(e),n=new Date,r=n.getTime()-t.getTime(),i=Math.floor(r/36e5);if(i<1)return"Just now";if(i<24)return`${i}h ago`;const s=Math.floor(i/24);return s<7?`${s}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==n.getFullYear()?"numeric":void 0})}function d6(e){switch(e){case"home":return c.jsx(GT,{size:14});case"desktop":return c.jsx(ry,{size:14});case"documents":return c.jsx(wn,{size:14});case"download":return c.jsx(dd,{size:14});default:return c.jsx($p,{size:14})}}const f6=[{label:"All Files",value:""},{label:"Documents",value:"pdf,doc,docx,txt,md"},{label:"Spreadsheets",value:"csv,xlsx,xls,tsv"},{label:"Code",value:"py,js,ts,java,c,cpp,go,rs,rb,sh"},{label:"Data",value:"json,xml,yaml,yml,csv,tsv"}];function h6(){const{setShowFileBrowser:e,currentSessionId:t,updateSessionInList:n}=we(),[r,i]=S.useState(""),[s,a]=S.useState(null),[u,l]=S.useState([]),[d,h]=S.useState([]),[f,p]=S.useState(!1),[m,T]=S.useState(null),[x,I]=S.useState(""),[g,E]=S.useState(null),[y,v]=S.useState(!1),[O,A]=S.useState(""),[F,H]=S.useState(new Set),[K,w]=S.useState(null),[Y,te]=S.useState(!1),[ce,le]=S.useState(new Set),[ue,j]=S.useState(null),z=S.useRef(null),[P,G]=S.useState(null),_=S.useCallback(async R=>{p(!0),T(null),E(null),I("");try{const W=await lb(R);i(W.current_path),a(W.parent_path),l(W.entries),W.quick_links.length>0&&h(W.quick_links),D.ui.info(`Browsing: ${W.current_path} (${W.entries.length} items)`)}catch(W){const de=W instanceof Error?W.message:"Failed to load directory";T(de),D.ui.error("Browse failed",W)}finally{p(!1)}},[]);S.useEffect(()=>{_()},[_]),S.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]);const Z=S.useCallback(async()=>{if(!x.trim()){E(null);return}v(!0),T(null);try{const R=await cb(x.trim(),O||void 0,30);E(R.results),D.ui.info(`Search "${x}": ${R.total} results`)}catch(R){const W=R instanceof Error?R.message:"Search failed";T(W),D.ui.error("Search failed",R)}finally{v(!1)}},[x,O]),fe=R=>{R.key==="Enter"&&Z()},N=S.useCallback(R=>{R.type==="folder"&&(_(R.path),H(new Set),w(null))},[_]),Ne=S.useCallback(async R=>{te(!0);try{const W=await db(R);w(W)}catch(W){D.ui.error("Preview failed",W)}finally{te(!1)}},[]),re=S.useCallback(async()=>{var Nr,kt;if(F.size===0)return;const R=Array.from(F);G(null);const W=[],de=[];for(const Se of R){const Ve=Se.includes(".")?"."+((Nr=Se.split(".").pop())==null?void 0:Nr.toLowerCase()):"";Ve&&!mc(Ve)?de.push(Se):W.push(Se)}if(de.length>0&&W.length===0){const Se=de[0],Ve="."+((kt=Se.split(".").pop())==null?void 0:kt.toLowerCase()),St=Ru(Ve);G({filename:de.length===1?Se.split(/[\\/]/).pop()||Se:`${de.length} files`,error:St?St.message:`File type "${Ve}" is not supported for indexing.`});return}if(de.length>0&&(D.doc.warn(`Skipping ${de.length} unsupported file(s)`),j(`Skipping ${de.length} unsupported file(s)...`)),W.length===0)return;le(new Set(W)),j(`Indexing ${W.length} file(s)...`);let Ae=0,be=0,Re="";const ze=[],Gn=new Set(u.filter(Se=>Se.type==="folder").map(Se=>Se.path));for(const Se of W)try{if(Gn.has(Se))(await ob(Se)).documents.forEach(St=>{St.id&&ze.push(St.id)});else{const Ve=await md(Se);Ve!=null&&Ve.id&&ze.push(Ve.id)}Ae++,j(`Indexed ${Ae}/${W.length}...`)}catch(Ve){be++,Re=Ve instanceof Error?Ve.message:"Unknown error"}if(t&&ze.length>0){for(const bn of ze)try{await Su(t,bn)}catch(Ht){D.doc.warn(`Could not attach document to session: ${Ht}`)}const Se=we.getState().sessions.find(bn=>bn.id===t),Ve=(Se==null?void 0:Se.document_ids)??[],St=ze.filter(bn=>!Ve.includes(bn));St.length>0&&n(t,{document_ids:[...Ve,...St]})}if(le(new Set),be>0)j(`Done: ${Ae} indexed, ${be} failed`),G({filename:`${be} file(s)`,error:Re||"Indexing failed for some files"});else{const Se=de.length>0?` (${de.length} skipped — unsupported type)`:"";j(`Successfully indexed ${Ae} file(s)${Se}`)}z.current&&clearTimeout(z.current),z.current=setTimeout(()=>j(null),5e3),H(new Set)},[F,t,n]),me=S.useCallback(()=>{if(F.size===0)return;const R=Array.from(F);e(!1);const W=R.length===1?`Analyze this file for me: ${R[0]}`:`Analyze these files for me:
429
429
  ${R.map(de=>`- ${de}`).join(`
430
430
  `)}`;setTimeout(()=>{window.dispatchEvent(new CustomEvent("gaia:send-prompt",{detail:{prompt:W}}))},100)},[F,e]),ve=r?r.replace(/\\/g,"/").split("/").filter(Boolean):[],De=ve.map((R,W)=>({label:R,path:ve.slice(0,W+1).join("/")+(W===0&&R.includes(":")?"/":"")})),He=g?g.map(R=>({name:R.name,path:R.path,type:"file",size:R.size,extension:R.extension||"",modified:R.modified||""})):u;return c.jsx("div",{className:"modal-overlay",onClick:()=>e(!1),role:"dialog","aria-modal":"true","aria-label":"File Browser",children:c.jsxs("div",{className:`modal-panel file-browser-modal ${K?"has-preview":""}`,onClick:R=>R.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsxs("h3",{children:[c.jsx(Hn,{size:18})," File Browser"]}),c.jsx("button",{className:"btn-icon",onClick:()=>e(!1),"aria-label":"Close",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"file-browser-body",children:[c.jsx("div",{className:"fb-quick-links",children:d.map(R=>c.jsxs("button",{className:"fb-quick-link",onClick:()=>_(R.path),title:R.path,children:[d6(R.icon),c.jsx("span",{children:R.name})]},R.path))}),c.jsxs("div",{className:"fb-search-bar",children:[c.jsxs("div",{className:"fb-search-input-wrap",children:[c.jsx(Pr,{size:14,className:"fb-search-icon"}),c.jsx("input",{type:"text",className:"fb-search-input",placeholder:"Search files on your PC...",value:x,onChange:R=>I(R.target.value),onKeyDown:fe,"aria-label":"Search files"}),x&&c.jsx("button",{className:"fb-search-clear",onClick:()=>{I(""),E(null)},"aria-label":"Clear search",children:c.jsx(Mt,{size:12})})]}),c.jsx("select",{className:"fb-type-filter",value:O,onChange:R=>A(R.target.value),"aria-label":"File type filter",children:f6.map(R=>c.jsx("option",{value:R.value,children:R.label},R.value))}),c.jsx("button",{className:"fb-search-btn",onClick:Z,disabled:!x.trim()||y,children:y?"Searching...":"Search"})]}),!g&&c.jsxs("div",{className:"fb-breadcrumb",children:[c.jsx("button",{className:"fb-crumb",onClick:()=>_("/"),children:c.jsx(QT,{size:12})}),De.map((R,W)=>c.jsxs("span",{className:"fb-crumb-item",children:[c.jsx(ta,{size:12,className:"fb-crumb-sep"}),c.jsx("button",{className:"fb-crumb",onClick:()=>_(R.path),children:R.label})]},W)),s&&c.jsx("button",{className:"fb-up-btn",onClick:()=>_(s),title:"Go up",children:c.jsx(jT,{size:14})})]}),g&&c.jsxs("div",{className:"fb-search-header",children:[c.jsxs("span",{children:["Found ",g.length,' result(s) for "',x,'"']}),c.jsx("button",{className:"fb-back-btn",onClick:()=>{E(null),I("")},children:"Back to browsing"})]}),m&&c.jsx("div",{className:"fb-error",children:m}),c.jsxs("div",{className:"fb-content",children:[c.jsxs("div",{className:"fb-file-list",children:[f&&c.jsx("div",{className:"fb-loading",children:"Loading..."}),!f&&He.length===0&&c.jsx("div",{className:"fb-empty",children:g?"No files found":"This folder is empty"}),!f&&He.map(R=>{var be;const W=R.extension||(R.name.includes(".")?"."+((be=R.name.split(".").pop())==null?void 0:be.toLowerCase()):""),de=R.type==="file"&&W&&!mc(W),Ae=de?Ru(W):null;return c.jsxs("div",{className:`fb-entry ${R.type} ${F.has(R.path)?"selected":""} ${de?"unsupported":""}`,onClick:()=>R.type==="folder"?N(R):Ne(R.path),onDoubleClick:()=>R.type==="folder"?N(R):void 0,title:de?`${(Ae==null?void 0:Ae.label)||"This"} file type cannot be indexed`:R.path,children:[c.jsx("input",{type:"checkbox",className:"fb-entry-checkbox",checked:F.has(R.path),onChange:()=>{H(Re=>{const ze=new Set(Re);return ze.has(R.path)?ze.delete(R.path):ze.add(R.path),ze})},onClick:Re=>Re.stopPropagation(),"aria-label":`Select ${R.name}`}),c.jsx("span",{className:"fb-entry-icon",children:l6(R)}),c.jsx("span",{className:"fb-entry-name",title:R.path,children:R.name}),de&&c.jsx("span",{className:"fb-unsupported-badge",children:"Not indexable"}),c.jsx("span",{className:"fb-entry-size",children:R.type==="file"?o6(R.size):""}),c.jsx("span",{className:"fb-entry-date",children:c6(R.modified)})]},R.path)})]}),K&&c.jsxs("div",{className:"fb-preview",children:[c.jsxs("div",{className:"fb-preview-header",children:[c.jsx("span",{className:"fb-preview-name",children:K.name}),c.jsx("button",{className:"btn-icon-sm",onClick:()=>w(null),"aria-label":"Close preview",children:c.jsx(Mt,{size:14})})]}),c.jsxs("div",{className:"fb-preview-meta",children:[c.jsx("span",{children:K.size_display}),K.total_lines&&c.jsxs("span",{children:[K.total_lines," lines"]}),K.columns&&c.jsxs("span",{children:[K.columns.length," columns"]}),K.row_count!==null&&c.jsxs("span",{children:[K.row_count," rows"]})]}),K.columns&&c.jsxs("div",{className:"fb-preview-columns",children:[c.jsx("strong",{children:"Columns:"})," ",K.columns.join(", ")]}),Y?c.jsx("div",{className:"fb-preview-loading",children:"Loading preview..."}):K.is_text&&K.preview_lines.length>0?c.jsx("pre",{className:"fb-preview-content",children:K.preview_lines.slice(0,30).join(`
431
- `)}):c.jsx("div",{className:"fb-preview-binary",children:"Binary file - no preview available"})]})]}),P&&c.jsx(Qg,{filename:P.filename,error:P.error,onDismiss:()=>G(null)}),c.jsxs("div",{className:"fb-actions",children:[c.jsx("div",{className:"fb-selection-info",children:F.size>0?`${F.size} item(s) selected`:"Select files to index or analyze"}),ue&&c.jsx("span",{className:"fb-index-status",children:ue}),c.jsxs("div",{className:"fb-action-btns",children:[c.jsxs("button",{className:"fb-action-btn secondary",onClick:re,disabled:F.size===0||ce.size>0,title:"Index selected files for RAG search",children:[c.jsx(ku,{size:14}),"Index Selected"]}),c.jsxs("button",{className:"fb-action-btn primary",onClick:me,disabled:F.size===0,title:"Send selected files to the chat agent for analysis",children:[c.jsx(UT,{size:14}),"Ask Agent"]})]})]})]})]})})}const Ns=32768,Bd="Qwen3.5-35B-A3B-GGUF",m6=3e5,p6=18e5,g6=1e4;function Kg(e){const[t,n]=S.useState(!1),[r,i]=S.useState(!1),s=S.useRef(null),a=S.useRef(null),u=S.useRef(null),l=S.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),a.current&&(clearTimeout(a.current),a.current=null),u.current&&(clearInterval(u.current),u.current=null)},[]);S.useEffect(()=>l,[l]);const d=S.useCallback((m,T)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{var x,I;try{const g=await hd();T==="load"?((x=g.model_loaded)==null?void 0:x.toLowerCase())===m.toLowerCase()&&(n(!1),s.current&&(clearTimeout(s.current),s.current=null),u.current&&(clearInterval(u.current),u.current=null)):(g.model_downloaded===!0||((I=g.model_loaded)==null?void 0:I.toLowerCase())===m.toLowerCase())&&(i(!1),a.current&&(clearTimeout(a.current),a.current=null),u.current&&(clearInterval(u.current),u.current=null))}catch{}},g6)},[]),h=e??Bd,f=S.useCallback(async m=>{const T=m??h;n(!0);try{await Gy(T,Ns),D.system.info(`Load model triggered: ${T}`),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),m6),d(T,"load")}catch(x){D.system.error("Failed to trigger model load",x),n(!1)}},[h,d]),p=S.useCallback(async(m=!1,T)=>{const x=T??h;i(!0);try{await Ky(x,m),D.system.info(`Download model triggered: ${x} (force=${m})`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),p6),d(x,"download")}catch(I){D.system.error("Failed to trigger model download",I),i(!1)}},[h,d]);return{isLoadingModel:t,isDownloadingModel:r,loadModel:f,downloadModel:p}}function E6(){const{setShowSettings:e,sessions:t,removeSession:n}=we(),[r,i]=S.useState(null),[s,a]=S.useState(!0),[u,l]=S.useState([]);S.useEffect(()=>{D.system.info("Checking system status...");const F=D.system.time();hd().then(H=>{i(H),D.system.timed("System status received",F,{lemonade:H.lemonade_running?"running":"stopped",model:H.model_loaded||"none",embedding:H.embedding_model_loaded?"yes":"no",disk:`${H.disk_space_gb}GB free`,memory:`${H.memory_available_gb}GB available`}),H.lemonade_running||D.system.warn("Lemonade Server is NOT running.")}).catch(H=>{D.system.error("Failed to get system status",H),i(null)}).finally(()=>a(!1)),mb().then(H=>l(H.servers)).catch(()=>{})},[]);const d=(r==null?void 0:r.default_model_name)??Bd,{isLoadingModel:h,isDownloadingModel:f,loadModel:p,downloadModel:m}=Kg(d),[T,x]=S.useState(!1),I=S.useRef(null);S.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]);const g=S.useCallback(async()=>{if(!T){x(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>x(!1),4e3);return}x(!1),I.current&&clearTimeout(I.current),D.system.warn(`Clearing ALL data: ${t.length} session(s)`);const F=D.system.time();let H=0;for(const K of t)try{await e1(K.id),n(K.id),H++}catch(w){D.system.error(`Failed to delete session ${K.id}`,w)}D.system.timed(`Cleared ${H}/${t.length} session(s)`,F),e(!1)},[T,t,n,e]),E="0.17.0",y=!!(r!=null&&r.lemonade_running&&r.model_loaded&&r.expected_model_loaded===!1),v=!!(r!=null&&r.lemonade_running&&r.model_loaded&&r.context_size_sufficient===!1),O=!!(r!=null&&r.lemonade_running&&!r.model_loaded&&r.model_downloaded===!1),A=y||v;return c.jsx("div",{className:"modal-overlay",onClick:()=>e(!1),role:"dialog","aria-modal":"true","aria-label":"Settings",children:c.jsxs("div",{className:"modal-panel settings-modal",onClick:F=>F.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsx("h3",{children:"Settings"}),c.jsx("button",{className:"btn-icon",onClick:()=>e(!1),"aria-label":"Close settings",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body",children:[c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"System Status"}),s?c.jsx("p",{className:"loading-text",children:"Checking system..."}):r?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"status-grid",children:[c.jsx(cn,{label:"Lemonade Server",value:r.lemonade_running?`Running${r.lemonade_version?` v${r.lemonade_version}`:""}`:"Not Running",ok:r.lemonade_running,hint:r.lemonade_running?void 0:r.initialized?"Run: lemonade-server serve":"Run: gaia init --profile chat"}),c.jsx(cn,{label:"Model",value:r.model_loaded||"None loaded",ok:!!r.model_loaded&&r.expected_model_loaded!==!1,hint:r.model_loaded?r.expected_model_loaded===!1?`Expected: ${d}`:void 0:"Run: gaia init --profile chat"}),r.model_size_gb!=null&&c.jsx(cn,{label:"Model Size",value:`${r.model_size_gb} GB`,ok:!0}),r.model_device&&c.jsx(cn,{label:"Device",value:r.model_device.toUpperCase(),ok:r.model_device!=="cpu"}),r.model_context_size!=null&&c.jsx(cn,{label:"Context Window",value:`${(r.model_context_size/1024).toFixed(0)}K tokens`,ok:r.context_size_sufficient}),r.model_labels&&r.model_labels.length>0&&c.jsx(cn,{label:"Capabilities",value:r.model_labels.join(", "),ok:!0}),c.jsx(cn,{label:"Embedding Model",value:r.embedding_model_loaded?"Available":"Not loaded",ok:r.embedding_model_loaded}),r.gpu_name&&c.jsx(cn,{label:"GPU",value:`${r.gpu_name}${r.gpu_vram_gb?` (${r.gpu_vram_gb} GB)`:""}`,ok:!0}),c.jsx(cn,{label:"Disk Space",value:`${r.disk_space_gb} GB free`,ok:r.disk_space_gb>5,hint:!r.model_loaded&&r.disk_space_gb<30?`Models require ~25 GB — only ${r.disk_space_gb} GB available`:void 0}),c.jsx(cn,{label:"Memory",value:`${r.memory_available_gb} GB available`,ok:r.memory_available_gb>2}),r.processor_name&&c.jsx(cn,{label:"Processor",value:r.processor_name,ok:r.device_supported!==!1})]}),O&&c.jsxs("div",{className:"model-action-row model-action-row--download",children:[c.jsxs("div",{className:"model-action-info",children:[c.jsx("span",{className:"model-action-label",children:"Model not downloaded."}),c.jsxs("span",{className:"model-action-desc",children:[c.jsx("strong",{children:d})," is required for GAIA Chat (~25 GB)."]})]}),c.jsx("button",{className:"btn-model-action btn-model-action--download",onClick:()=>m(!1),disabled:f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:13,className:"btn-spinner"})," Downloading…"]}):"Download"})]}),A&&c.jsxs("div",{className:"model-action-row model-action-row--load",children:[c.jsxs("div",{className:"model-action-info",children:[c.jsx("span",{className:"model-action-label",children:y?"Wrong model loaded.":"Context window too small."}),c.jsxs("span",{className:"model-action-desc",children:["Load ",c.jsx("strong",{children:d})," with ",(Ns/1024).toFixed(0),"K token context."]})]}),c.jsx("button",{className:"btn-model-action btn-model-action--load",onClick:()=>p(),disabled:h,children:h?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:13,className:"btn-spinner"})," Loading…"]}):"Load Model"})]}),r.lemonade_running&&c.jsxs("div",{className:"force-redownload-row",children:[c.jsx("span",{className:"force-redownload-label",children:"If the model file is corrupted:"}),c.jsx("button",{className:"btn-force-redownload",onClick:()=>m(!0),disabled:f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:12,className:"btn-spinner"})," Downloading…"]}):"Force Re-download"})]})]}):c.jsxs("div",{className:"status-error",children:[c.jsx("p",{children:"Could not connect to server"}),c.jsx("code",{children:"gaia chat --ui"})]})]}),u.length>0&&c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"MCP Servers"}),c.jsx("div",{className:"status-grid",children:u.map(F=>c.jsxs("div",{className:"status-row",children:[c.jsx("span",{className:"status-label",children:F.name}),c.jsx("div",{className:"status-value-wrap",children:F.connected?c.jsxs("span",{className:"status-value ok mcp-status-connected",children:[c.jsx(cd,{size:12}),F.tool_count," tool",F.tool_count!==1?"s":""]}):c.jsxs("span",{className:"status-value warn mcp-status-failed",title:F.error??void 0,children:[c.jsx(br,{size:12}),"Failed"]})})]},F.name))})]}),c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"About"}),c.jsxs("div",{className:"about-info",children:[c.jsxs("p",{children:["GAIA Agent UI v",E," ",c.jsx("span",{className:"beta-badge",children:"BETA"})]}),c.jsx("p",{className:"about-sub",children:"Privacy-first AI chat for AMD Ryzen AI PCs."})]})]}),c.jsxs("section",{className:"settings-section danger-zone",children:[c.jsx("h4",{children:"Privacy & Data"}),c.jsxs("div",{className:"setting-row",children:[c.jsx("span",{children:"Data location"}),c.jsx("code",{className:"setting-path",children:"~/.gaia/chat/"})]}),c.jsx("div",{className:"danger-divider"}),c.jsxs("div",{className:"setting-actions",children:[c.jsx("p",{className:"danger-warning",children:"This will permanently delete all sessions, messages, and documents."}),c.jsx("button",{className:"btn-danger",onClick:g,children:T?"Click again to confirm":"Clear All Data"})]})]})]})]})})}function cn({label:e,value:t,ok:n,hint:r}){return c.jsxs("div",{className:`status-row${r?" status-row--has-hint":""}`,children:[c.jsx("span",{className:"status-label",children:e}),c.jsxs("div",{className:"status-value-wrap",children:[c.jsx("span",{className:`status-value ${n?"ok":"warn"}`,children:t}),r&&c.jsx("span",{className:"status-hint",children:c.jsx("code",{children:r})})]})]})}const T6="modulepreload",y6=function(e,t){return new URL(e,t).href},A0={},b6=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const a=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),l=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));i=Promise.allSettled(n.map(d=>{if(d=y6(d,r),d in A0)return;A0[d]=!0;const h=d.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!r)for(let T=a.length-1;T>=0;T--){const x=a[T];if(x.href===d&&(!h||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${f}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":T6,h||(m.as="script"),m.crossOrigin="",m.href=d,l&&m.setAttribute("nonce",l),document.head.appendChild(m),h)return new Promise((T,x)=>{m.addEventListener("load",T),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return i.then(a=>{for(const u of a||[])u.status==="rejected"&&s(u.reason);return t().catch(s)})};let ro=null;function x6({isOpen:e,onClose:t,error:n}){const[r,i]=S.useState(null),[s,a]=S.useState(!1),u=S.useRef(null),l=S.useCallback(async()=>{try{const p=await n1();return i(p),p}catch(p){return D.system.error("Failed to fetch tunnel status",p),null}},[]);S.useEffect(()=>{if(!e||n)return;l();const p=setInterval(async()=>{const m=await l();m!=null&&m.active&&(m!=null&&m.url)&&clearInterval(p)},2e3);return()=>clearInterval(p)},[e,n,l]),S.useEffect(()=>{if(!(r!=null&&r.active)||!r.url||!r.token||!u.current)return;const p=`${r.url}/?token=${r.token}`;D.system.info(`Generating QR code for: ${p}`),(async()=>{if(!ro)try{const x=await b6(()=>import("./browser-CTB2jwNe.js").then(I=>I.b),[],import.meta.url);ro=x.default||x}catch{D.system.error("QR code library not available - install with: npm install qrcode");return}const T=document.documentElement.getAttribute("data-theme")==="dark";try{await ro.toCanvas(u.current,p,{width:200,margin:2,color:{dark:T?"#e6edf3":"#111827",light:T?"#0d0d0d":"#ffffff"}})}catch(x){D.system.error("QR code generation failed",x)}})()},[r==null?void 0:r.active,r==null?void 0:r.url,r==null?void 0:r.token]);const d=S.useRef(null),h=S.useCallback(()=>{if(!(r!=null&&r.url)||!(r!=null&&r.token))return;const p=`${r.url}/?token=${r.token}`;navigator.clipboard.writeText(p).then(()=>{a(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(!1),2e3)})},[r]);if(S.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),!e)return null;const f=r!=null&&r.active&&(r!=null&&r.url)&&(r!=null&&r.token)?`${r.url}/?token=${r.token}`:"";return c.jsx("div",{className:"modal-overlay",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Mobile Access",children:c.jsxs("div",{className:"modal-panel mobile-modal",onClick:p=>p.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsxs("h3",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[c.jsx(Vp,{size:18}),"Mobile Access"]}),c.jsx("button",{className:"btn-icon",onClick:t,"aria-label":"Close",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body mobile-modal-body",children:[c.jsxs("div",{className:"tunnel-status",children:[c.jsx("span",{className:`status-dot ${r!=null&&r.active?"active":n?"error":"starting"}`}),c.jsx("span",{children:r!=null&&r.active?"Tunnel active":n?"Connection failed":"Starting tunnel..."}),!(r!=null&&r.active)&&!n&&c.jsx("span",{className:"tunnel-spinner"})]}),n&&c.jsx("div",{className:"tunnel-error",children:n}),c.jsx("div",{className:"qr-code-area",children:r!=null&&r.active?c.jsx("canvas",{ref:u}):n?c.jsx("div",{className:"qr-placeholder error",children:"Failed to connect"}):c.jsxs("div",{className:"qr-placeholder",children:[c.jsx("div",{className:"placeholder-spinner"}),c.jsx("span",{children:"Connecting..."})]})}),(r==null?void 0:r.active)&&f&&c.jsxs("div",{className:"tunnel-url-area",children:[c.jsx("label",{children:"Mobile URL"}),c.jsxs("div",{className:"tunnel-url-row",children:[c.jsx("input",{type:"text",readOnly:!0,value:f}),c.jsxs("button",{className:`copy-url-btn ${s?"copied":""}`,onClick:h,title:"Copy URL",children:[s?c.jsx(ea,{size:13}):c.jsx(Xu,{size:13}),s?"Copied":"Copy"]})]})]}),(r==null?void 0:r.active)&&(r==null?void 0:r.publicIp)&&(r==null?void 0:r.url)&&!r.url.includes("ngrok-free.app")&&c.jsxs("div",{className:"tunnel-password-hint",children:[c.jsx("label",{children:"Tunnel Password"}),c.jsx("div",{className:"tunnel-password-value",children:r.publicIp}),c.jsx("span",{className:"tunnel-password-note",children:"Enter this when the tunnel page asks for a password"})]}),c.jsx("div",{className:"mobile-instructions",children:c.jsxs("ol",{children:[c.jsx("li",{children:"Scan the QR code with your phone's camera"}),(r==null?void 0:r.url)&&!r.url.includes("ngrok-free.app")&&c.jsx("li",{children:"Enter the tunnel password shown above when prompted"}),c.jsx("li",{children:"Chat with GAIA from your mobile device"}),c.jsx("li",{children:"Your data stays secure via encrypted tunnel"})]})}),c.jsx("div",{className:"mobile-access-actions",children:c.jsx("button",{className:"btn-secondary",onClick:t,children:"Close"})})]})]})})}function _6({onRetry:e}){const{backendConnected:t,systemStatus:n,currentSessionId:r,messages:i}=we(),[s,a]=S.useState(!1),u=!!r&&i.length>0,l=(n==null?void 0:n.default_model_name)??Bd,{isLoadingModel:d,isDownloadingModel:h,loadModel:f,downloadModel:p}=Kg(l),m=S.useRef(n==null?void 0:n.lemonade_running),T=S.useRef(n==null?void 0:n.model_downloaded),x=S.useRef(n==null?void 0:n.context_size_sufficient),I=S.useRef(n==null?void 0:n.expected_model_loaded);if(S.useEffect(()=>{if(u)return;const g=n==null?void 0:n.lemonade_running,E=n==null?void 0:n.model_downloaded,y=n==null?void 0:n.context_size_sufficient,v=n==null?void 0:n.expected_model_loaded;let O=!1;m.current!==g&&(m.current=g,g===!1&&(O=!0)),T.current!==E&&(T.current=E,E===!1&&(O=!0)),x.current!==y&&(x.current=y,y===!1&&(O=!0)),I.current!==v&&(I.current=v,v===!1&&(O=!0)),O&&a(!1)},[n,u]),s||u)return null;if(!t)return c.jsxs("div",{className:"connection-banner connection-banner--error",role:"alert",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(Ey,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Cannot connect to GAIA Agent UI server."," ",c.jsxs("span",{className:"connection-banner__hint",children:["Start it with: ",c.jsx("code",{children:"gaia chat --ui"})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Retry"})]});if(n&&!n.lemonade_running)return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(Ii,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["LLM server is not responding — it may be busy or not running."," ",c.jsxs("span",{className:"connection-banner__hint",children:["If not started, run: ",c.jsx("code",{children:"lemonade-server serve"})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Check again"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]});if(n&&n.lemonade_running&&!n.model_loaded&&n.model_downloaded===!1)return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(dd,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Required model ",c.jsx("strong",{children:l})," is not downloaded (~25 GB)."]}),h?c.jsxs("span",{className:"connection-banner__loading",children:[c.jsx(xi,{size:13,className:"connection-banner__spinner"}),"Downloading…"]}):c.jsx("button",{className:"connection-banner__retry",onClick:()=>p(!1),children:"Download"}),e&&!h&&c.jsx("button",{className:"connection-banner__retry connection-banner__retry--secondary",onClick:e,children:"Recheck"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]});if(n&&n.lemonade_running&&n.model_loaded&&n.expected_model_loaded===!1&&!n.embedding_model_loaded){const g=n.model_loaded,E=n.context_size_sufficient===!1;return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(YT,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Wrong model loaded: ",c.jsx("strong",{children:g}),"."," ","GAIA Chat requires ",c.jsx("strong",{children:l}),".",E&&c.jsxs(c.Fragment,{children:[" ","Context window is also too small."]})]}),d?c.jsxs("span",{className:"connection-banner__loading",children:[c.jsx(xi,{size:13,className:"connection-banner__spinner"}),"Loading…"]}):c.jsx("button",{className:"connection-banner__retry",onClick:()=>f(),children:"Load Now"}),e&&!d&&c.jsx("button",{className:"connection-banner__retry connection-banner__retry--secondary",onClick:e,children:"Recheck"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]})}if(n&&n.lemonade_running&&n.model_loaded&&n.context_size_sufficient===!1){const g=n.model_context_size??0,E=n.lemonade_url??"http://localhost:8000";return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(KT,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["LLM context window is too small (",g.toLocaleString()," tokens;"," ",Ns.toLocaleString()," required)."," ",c.jsxs("span",{className:"connection-banner__hint",children:["In"," ",c.jsx("a",{className:"connection-banner__link",href:E,target:"_blank",rel:"noreferrer",children:"Lemonade"}),", set ctx‑size to ",Ns.toLocaleString(),", or restart with:"," ",c.jsxs("code",{children:["lemonade-server serve --ctx-size ",Ns]})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Check again"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]})}return null}function k6(){const e=Du(qv),t=Du(n=>n.respondToPermission);return e?c.jsx("div",{className:"permission-overlay",role:"dialog","aria-modal":"true","aria-label":"Permission Request",children:c.jsx(S6,{notification:e,onRespond:t},e.id)}):null}function S6({notification:e,onRespond:t}){const n=e.timeoutSeconds!=null&&e.timeoutSeconds>0,[r,i]=S.useState(n?e.timeoutSeconds:null),s=S.useRef(null),[a,u]=S.useState(!1),[l,d]=S.useState(!1),h=S.useRef(!1),f=S.useRef(t);f.current=t,S.useEffect(()=>{if(n)return s.current=setInterval(()=>{i(I=>I===null||I<=1?(s.current&&clearInterval(s.current),0):I-1)},1e3),()=>{s.current&&clearInterval(s.current)}},[n]),S.useEffect(()=>{if(r===0){if(h.current)return;h.current=!0,u(!0),f.current(e.id,"deny",!1)}},[r,e.id]);const p=S.useCallback(async()=>{if(!h.current){h.current=!0,u(!0),s.current&&clearInterval(s.current);try{await t(e.id,"allow",l)}finally{h.current=!1,u(!1)}}},[e.id,t,l]),m=S.useCallback(async()=>{if(!h.current){h.current=!0,u(!0),s.current&&clearInterval(s.current);try{await t(e.id,"deny",!1)}finally{h.current=!1,u(!1)}}},[e.id,t]);S.useEffect(()=>{const I=g=>{g.key==="Enter"&&!g.shiftKey?(g.preventDefault(),p()):g.key==="Escape"&&(g.preventDefault(),m())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[p,m]);const T=e.toolArgs,x=T&&Object.keys(T).length>0;return c.jsxs("div",{className:"permission-prompt",children:[c.jsxs("div",{className:"permission-header",children:[c.jsx("div",{className:"permission-header-icon",children:c.jsx(hy,{size:24})}),c.jsxs("div",{className:"permission-header-text",children:[c.jsx("h2",{className:"permission-title",children:"Permission Request"}),c.jsx("span",{className:"permission-agent",children:e.agentName})]}),r!==null&&r>0&&c.jsxs("div",{className:"permission-countdown",title:"Auto-deny on timeout",children:[c.jsx(Hp,{size:14}),c.jsxs("span",{children:[r,"s"]})]})]}),c.jsxs("div",{className:"permission-body",children:[c.jsx("p",{className:"permission-message",children:e.message}),e.tool&&c.jsxs("div",{className:"permission-tool-info",children:[c.jsxs("div",{className:"permission-tool-header",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"Tool Invocation"})]}),c.jsx("div",{className:"permission-tool-name",children:c.jsx("code",{children:e.tool})}),x&&c.jsx("div",{className:"permission-tool-args",children:c.jsx("pre",{children:JSON.stringify(T,null,2)})})]}),e.priority==="critical"&&c.jsxs("div",{className:"permission-critical-banner",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"This is a critical-tier operation"})]}),c.jsxs("label",{className:"permission-remember",children:[c.jsx("input",{type:"checkbox",checked:l,onChange:I=>d(I.target.checked),disabled:a}),c.jsx("span",{children:"Always allow this tool"})]})]}),c.jsxs("div",{className:"permission-actions",children:[c.jsxs("button",{className:"permission-btn permission-btn-deny",onClick:m,disabled:a,title:"Deny (Esc)",children:[c.jsx(Mt,{size:16}),"Deny"]}),c.jsxs("button",{className:"permission-btn permission-btn-allow",onClick:p,disabled:a,title:"Allow (Enter)",children:[c.jsx(ea,{size:16}),"Allow"]})]}),c.jsxs("div",{className:"permission-hints",children:[c.jsxs("span",{children:[c.jsx("kbd",{children:"Enter"})," Allow"]}),c.jsxs("span",{children:[c.jsx("kbd",{children:"Esc"})," Deny"]})]})]})}function Da({show:e,children:t,duration:n=250}){const[r,i]=S.useState(!1),[s,a]=S.useState("idle");return S.useEffect(()=>{if(e)i(!0),requestAnimationFrame(()=>a("entering"));else if(r){a("exiting");const u=setTimeout(()=>{i(!1),a("idle")},n);return()=>clearTimeout(u)}},[e,r,n]),r?c.jsx("div",{className:`animated-presence ${s}`,"data-duration":n,children:t}):null}function C6(){const{currentSessionId:e,setSessions:t,setCurrentSession:n,addSession:r,removeSession:i,updateSessionInList:s,setMessages:a,showDocLibrary:u,showFileBrowser:l,showSettings:d,sidebarOpen:h,toggleSidebar:f,setSidebarOpen:p,setSystemStatus:m,setBackendConnected:T}=we(),[x,I]=S.useState(!1),[g,E]=S.useState(!1),[y,v]=S.useState(!1),[O,A]=S.useState(null),F=S.useRef(null),H=S.useRef(0),K=3,w=S.useCallback(async()=>{try{const re=await hd();if(T(!0),re.lemonade_running)H.current=0,m(re);else if(H.current+=1,D.system.warn(`Lemonade health check failed (${H.current}/${K})`),H.current>=K)m(re);else{const me=we.getState().systemStatus;me&&me.lemonade_running?m({...me,disk_space_gb:re.disk_space_gb,memory_available_gb:re.memory_available_gb}):m(re)}D.system.info("System status:",{lemonade:re.lemonade_running,model:re.model_loaded,failCount:H.current})}catch(re){D.system.warn("System status check failed",re),T(!1),m(null)}},[m,T]);S.useEffect(()=>(w(),F.current=setInterval(w,15e3),()=>{F.current&&clearInterval(F.current)}),[w]);const Y=S.useRef(null),te=S.useRef("");S.useEffect(()=>{qy("0.17.0"),D.system.info("App mounting, loading sessions...");const re=D.system.time(),me=De=>De.map(He=>`${He.id}|${He.updated_at}|${He.title}`).join(`
431
+ `)}):c.jsx("div",{className:"fb-preview-binary",children:"Binary file - no preview available"})]})]}),P&&c.jsx(Qg,{filename:P.filename,error:P.error,onDismiss:()=>G(null)}),c.jsxs("div",{className:"fb-actions",children:[c.jsx("div",{className:"fb-selection-info",children:F.size>0?`${F.size} item(s) selected`:"Select files to index or analyze"}),ue&&c.jsx("span",{className:"fb-index-status",children:ue}),c.jsxs("div",{className:"fb-action-btns",children:[c.jsxs("button",{className:"fb-action-btn secondary",onClick:re,disabled:F.size===0||ce.size>0,title:"Index selected files for RAG search",children:[c.jsx(ku,{size:14}),"Index Selected"]}),c.jsxs("button",{className:"fb-action-btn primary",onClick:me,disabled:F.size===0,title:"Send selected files to the chat agent for analysis",children:[c.jsx(UT,{size:14}),"Ask Agent"]})]})]})]})]})})}const Ns=32768,Bd="Qwen3.5-35B-A3B-GGUF",m6=3e5,p6=18e5,g6=1e4;function Kg(e){const[t,n]=S.useState(!1),[r,i]=S.useState(!1),s=S.useRef(null),a=S.useRef(null),u=S.useRef(null),l=S.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),a.current&&(clearTimeout(a.current),a.current=null),u.current&&(clearInterval(u.current),u.current=null)},[]);S.useEffect(()=>l,[l]);const d=S.useCallback((m,T)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{var x,I;try{const g=await hd();T==="load"?((x=g.model_loaded)==null?void 0:x.toLowerCase())===m.toLowerCase()&&(n(!1),s.current&&(clearTimeout(s.current),s.current=null),u.current&&(clearInterval(u.current),u.current=null)):(g.model_downloaded===!0||((I=g.model_loaded)==null?void 0:I.toLowerCase())===m.toLowerCase())&&(i(!1),a.current&&(clearTimeout(a.current),a.current=null),u.current&&(clearInterval(u.current),u.current=null))}catch{}},g6)},[]),h=e??Bd,f=S.useCallback(async m=>{const T=m??h;n(!0);try{await Gy(T,Ns),D.system.info(`Load model triggered: ${T}`),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>n(!1),m6),d(T,"load")}catch(x){D.system.error("Failed to trigger model load",x),n(!1)}},[h,d]),p=S.useCallback(async(m=!1,T)=>{const x=T??h;i(!0);try{await Ky(x,m),D.system.info(`Download model triggered: ${x} (force=${m})`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),p6),d(x,"download")}catch(I){D.system.error("Failed to trigger model download",I),i(!1)}},[h,d]);return{isLoadingModel:t,isDownloadingModel:r,loadModel:f,downloadModel:p}}function E6(){const{setShowSettings:e,sessions:t,removeSession:n}=we(),[r,i]=S.useState(null),[s,a]=S.useState(!0),[u,l]=S.useState([]);S.useEffect(()=>{D.system.info("Checking system status...");const F=D.system.time();hd().then(H=>{i(H),D.system.timed("System status received",F,{lemonade:H.lemonade_running?"running":"stopped",model:H.model_loaded||"none",embedding:H.embedding_model_loaded?"yes":"no",disk:`${H.disk_space_gb}GB free`,memory:`${H.memory_available_gb}GB available`}),H.lemonade_running||D.system.warn("Lemonade Server is NOT running.")}).catch(H=>{D.system.error("Failed to get system status",H),i(null)}).finally(()=>a(!1)),mb().then(H=>l(H.servers)).catch(()=>{})},[]);const d=(r==null?void 0:r.default_model_name)??Bd,{isLoadingModel:h,isDownloadingModel:f,loadModel:p,downloadModel:m}=Kg(d),[T,x]=S.useState(!1),I=S.useRef(null);S.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]);const g=S.useCallback(async()=>{if(!T){x(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>x(!1),4e3);return}x(!1),I.current&&clearTimeout(I.current),D.system.warn(`Clearing ALL data: ${t.length} session(s)`);const F=D.system.time();let H=0;for(const K of t)try{await e1(K.id),n(K.id),H++}catch(w){D.system.error(`Failed to delete session ${K.id}`,w)}D.system.timed(`Cleared ${H}/${t.length} session(s)`,F),e(!1)},[T,t,n,e]),E="0.17.1",y=!!(r!=null&&r.lemonade_running&&r.model_loaded&&r.expected_model_loaded===!1),v=!!(r!=null&&r.lemonade_running&&r.model_loaded&&r.context_size_sufficient===!1),O=!!(r!=null&&r.lemonade_running&&!r.model_loaded&&r.model_downloaded===!1),A=y||v;return c.jsx("div",{className:"modal-overlay",onClick:()=>e(!1),role:"dialog","aria-modal":"true","aria-label":"Settings",children:c.jsxs("div",{className:"modal-panel settings-modal",onClick:F=>F.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsx("h3",{children:"Settings"}),c.jsx("button",{className:"btn-icon",onClick:()=>e(!1),"aria-label":"Close settings",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body",children:[c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"System Status"}),s?c.jsx("p",{className:"loading-text",children:"Checking system..."}):r?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"status-grid",children:[c.jsx(cn,{label:"Lemonade Server",value:r.lemonade_running?`Running${r.lemonade_version?` v${r.lemonade_version}`:""}`:"Not Running",ok:r.lemonade_running,hint:r.lemonade_running?void 0:r.initialized?"Run: lemonade-server serve":"Run: gaia init --profile chat"}),c.jsx(cn,{label:"Model",value:r.model_loaded||"None loaded",ok:!!r.model_loaded&&r.expected_model_loaded!==!1,hint:r.model_loaded?r.expected_model_loaded===!1?`Expected: ${d}`:void 0:"Run: gaia init --profile chat"}),r.model_size_gb!=null&&c.jsx(cn,{label:"Model Size",value:`${r.model_size_gb} GB`,ok:!0}),r.model_device&&c.jsx(cn,{label:"Device",value:r.model_device.toUpperCase(),ok:r.model_device!=="cpu"}),r.model_context_size!=null&&c.jsx(cn,{label:"Context Window",value:`${(r.model_context_size/1024).toFixed(0)}K tokens`,ok:r.context_size_sufficient}),r.model_labels&&r.model_labels.length>0&&c.jsx(cn,{label:"Capabilities",value:r.model_labels.join(", "),ok:!0}),c.jsx(cn,{label:"Embedding Model",value:r.embedding_model_loaded?"Available":"Not loaded",ok:r.embedding_model_loaded}),r.gpu_name&&c.jsx(cn,{label:"GPU",value:`${r.gpu_name}${r.gpu_vram_gb?` (${r.gpu_vram_gb} GB)`:""}`,ok:!0}),c.jsx(cn,{label:"Disk Space",value:`${r.disk_space_gb} GB free`,ok:r.disk_space_gb>5,hint:!r.model_loaded&&r.disk_space_gb<30?`Models require ~25 GB — only ${r.disk_space_gb} GB available`:void 0}),c.jsx(cn,{label:"Memory",value:`${r.memory_available_gb} GB available`,ok:r.memory_available_gb>2}),r.processor_name&&c.jsx(cn,{label:"Processor",value:r.processor_name,ok:r.device_supported!==!1})]}),O&&c.jsxs("div",{className:"model-action-row model-action-row--download",children:[c.jsxs("div",{className:"model-action-info",children:[c.jsx("span",{className:"model-action-label",children:"Model not downloaded."}),c.jsxs("span",{className:"model-action-desc",children:[c.jsx("strong",{children:d})," is required for GAIA Chat (~25 GB)."]})]}),c.jsx("button",{className:"btn-model-action btn-model-action--download",onClick:()=>m(!1),disabled:f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:13,className:"btn-spinner"})," Downloading…"]}):"Download"})]}),A&&c.jsxs("div",{className:"model-action-row model-action-row--load",children:[c.jsxs("div",{className:"model-action-info",children:[c.jsx("span",{className:"model-action-label",children:y?"Wrong model loaded.":"Context window too small."}),c.jsxs("span",{className:"model-action-desc",children:["Load ",c.jsx("strong",{children:d})," with ",(Ns/1024).toFixed(0),"K token context."]})]}),c.jsx("button",{className:"btn-model-action btn-model-action--load",onClick:()=>p(),disabled:h,children:h?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:13,className:"btn-spinner"})," Loading…"]}):"Load Model"})]}),r.lemonade_running&&c.jsxs("div",{className:"force-redownload-row",children:[c.jsx("span",{className:"force-redownload-label",children:"If the model file is corrupted:"}),c.jsx("button",{className:"btn-force-redownload",onClick:()=>m(!0),disabled:f,children:f?c.jsxs(c.Fragment,{children:[c.jsx(xi,{size:12,className:"btn-spinner"})," Downloading…"]}):"Force Re-download"})]})]}):c.jsxs("div",{className:"status-error",children:[c.jsx("p",{children:"Could not connect to server"}),c.jsx("code",{children:"gaia chat --ui"})]})]}),u.length>0&&c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"MCP Servers"}),c.jsx("div",{className:"status-grid",children:u.map(F=>c.jsxs("div",{className:"status-row",children:[c.jsx("span",{className:"status-label",children:F.name}),c.jsx("div",{className:"status-value-wrap",children:F.connected?c.jsxs("span",{className:"status-value ok mcp-status-connected",children:[c.jsx(cd,{size:12}),F.tool_count," tool",F.tool_count!==1?"s":""]}):c.jsxs("span",{className:"status-value warn mcp-status-failed",title:F.error??void 0,children:[c.jsx(br,{size:12}),"Failed"]})})]},F.name))})]}),c.jsxs("section",{className:"settings-section",children:[c.jsx("h4",{children:"About"}),c.jsxs("div",{className:"about-info",children:[c.jsxs("p",{children:["GAIA Agent UI v",E," ",c.jsx("span",{className:"beta-badge",children:"BETA"})]}),c.jsx("p",{className:"about-sub",children:"Privacy-first AI chat for AMD Ryzen AI PCs."})]})]}),c.jsxs("section",{className:"settings-section danger-zone",children:[c.jsx("h4",{children:"Privacy & Data"}),c.jsxs("div",{className:"setting-row",children:[c.jsx("span",{children:"Data location"}),c.jsx("code",{className:"setting-path",children:"~/.gaia/chat/"})]}),c.jsx("div",{className:"danger-divider"}),c.jsxs("div",{className:"setting-actions",children:[c.jsx("p",{className:"danger-warning",children:"This will permanently delete all sessions, messages, and documents."}),c.jsx("button",{className:"btn-danger",onClick:g,children:T?"Click again to confirm":"Clear All Data"})]})]})]})]})})}function cn({label:e,value:t,ok:n,hint:r}){return c.jsxs("div",{className:`status-row${r?" status-row--has-hint":""}`,children:[c.jsx("span",{className:"status-label",children:e}),c.jsxs("div",{className:"status-value-wrap",children:[c.jsx("span",{className:`status-value ${n?"ok":"warn"}`,children:t}),r&&c.jsx("span",{className:"status-hint",children:c.jsx("code",{children:r})})]})]})}const T6="modulepreload",y6=function(e,t){return new URL(e,t).href},A0={},b6=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const a=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),l=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));i=Promise.allSettled(n.map(d=>{if(d=y6(d,r),d in A0)return;A0[d]=!0;const h=d.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!r)for(let T=a.length-1;T>=0;T--){const x=a[T];if(x.href===d&&(!h||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${f}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":T6,h||(m.as="script"),m.crossOrigin="",m.href=d,l&&m.setAttribute("nonce",l),document.head.appendChild(m),h)return new Promise((T,x)=>{m.addEventListener("load",T),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return i.then(a=>{for(const u of a||[])u.status==="rejected"&&s(u.reason);return t().catch(s)})};let ro=null;function x6({isOpen:e,onClose:t,error:n}){const[r,i]=S.useState(null),[s,a]=S.useState(!1),u=S.useRef(null),l=S.useCallback(async()=>{try{const p=await n1();return i(p),p}catch(p){return D.system.error("Failed to fetch tunnel status",p),null}},[]);S.useEffect(()=>{if(!e||n)return;l();const p=setInterval(async()=>{const m=await l();m!=null&&m.active&&(m!=null&&m.url)&&clearInterval(p)},2e3);return()=>clearInterval(p)},[e,n,l]),S.useEffect(()=>{if(!(r!=null&&r.active)||!r.url||!r.token||!u.current)return;const p=`${r.url}/?token=${r.token}`;D.system.info(`Generating QR code for: ${p}`),(async()=>{if(!ro)try{const x=await b6(()=>import("./browser-CTB2jwNe.js").then(I=>I.b),[],import.meta.url);ro=x.default||x}catch{D.system.error("QR code library not available - install with: npm install qrcode");return}const T=document.documentElement.getAttribute("data-theme")==="dark";try{await ro.toCanvas(u.current,p,{width:200,margin:2,color:{dark:T?"#e6edf3":"#111827",light:T?"#0d0d0d":"#ffffff"}})}catch(x){D.system.error("QR code generation failed",x)}})()},[r==null?void 0:r.active,r==null?void 0:r.url,r==null?void 0:r.token]);const d=S.useRef(null),h=S.useCallback(()=>{if(!(r!=null&&r.url)||!(r!=null&&r.token))return;const p=`${r.url}/?token=${r.token}`;navigator.clipboard.writeText(p).then(()=>{a(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(!1),2e3)})},[r]);if(S.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),!e)return null;const f=r!=null&&r.active&&(r!=null&&r.url)&&(r!=null&&r.token)?`${r.url}/?token=${r.token}`:"";return c.jsx("div",{className:"modal-overlay",onClick:t,role:"dialog","aria-modal":"true","aria-label":"Mobile Access",children:c.jsxs("div",{className:"modal-panel mobile-modal",onClick:p=>p.stopPropagation(),children:[c.jsxs("div",{className:"modal-header",children:[c.jsxs("h3",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[c.jsx(Vp,{size:18}),"Mobile Access"]}),c.jsx("button",{className:"btn-icon",onClick:t,"aria-label":"Close",children:c.jsx(Mt,{size:18})})]}),c.jsxs("div",{className:"modal-body mobile-modal-body",children:[c.jsxs("div",{className:"tunnel-status",children:[c.jsx("span",{className:`status-dot ${r!=null&&r.active?"active":n?"error":"starting"}`}),c.jsx("span",{children:r!=null&&r.active?"Tunnel active":n?"Connection failed":"Starting tunnel..."}),!(r!=null&&r.active)&&!n&&c.jsx("span",{className:"tunnel-spinner"})]}),n&&c.jsx("div",{className:"tunnel-error",children:n}),c.jsx("div",{className:"qr-code-area",children:r!=null&&r.active?c.jsx("canvas",{ref:u}):n?c.jsx("div",{className:"qr-placeholder error",children:"Failed to connect"}):c.jsxs("div",{className:"qr-placeholder",children:[c.jsx("div",{className:"placeholder-spinner"}),c.jsx("span",{children:"Connecting..."})]})}),(r==null?void 0:r.active)&&f&&c.jsxs("div",{className:"tunnel-url-area",children:[c.jsx("label",{children:"Mobile URL"}),c.jsxs("div",{className:"tunnel-url-row",children:[c.jsx("input",{type:"text",readOnly:!0,value:f}),c.jsxs("button",{className:`copy-url-btn ${s?"copied":""}`,onClick:h,title:"Copy URL",children:[s?c.jsx(ea,{size:13}):c.jsx(Xu,{size:13}),s?"Copied":"Copy"]})]})]}),(r==null?void 0:r.active)&&(r==null?void 0:r.publicIp)&&(r==null?void 0:r.url)&&!r.url.includes("ngrok-free.app")&&c.jsxs("div",{className:"tunnel-password-hint",children:[c.jsx("label",{children:"Tunnel Password"}),c.jsx("div",{className:"tunnel-password-value",children:r.publicIp}),c.jsx("span",{className:"tunnel-password-note",children:"Enter this when the tunnel page asks for a password"})]}),c.jsx("div",{className:"mobile-instructions",children:c.jsxs("ol",{children:[c.jsx("li",{children:"Scan the QR code with your phone's camera"}),(r==null?void 0:r.url)&&!r.url.includes("ngrok-free.app")&&c.jsx("li",{children:"Enter the tunnel password shown above when prompted"}),c.jsx("li",{children:"Chat with GAIA from your mobile device"}),c.jsx("li",{children:"Your data stays secure via encrypted tunnel"})]})}),c.jsx("div",{className:"mobile-access-actions",children:c.jsx("button",{className:"btn-secondary",onClick:t,children:"Close"})})]})]})})}function _6({onRetry:e}){const{backendConnected:t,systemStatus:n,currentSessionId:r,messages:i}=we(),[s,a]=S.useState(!1),u=!!r&&i.length>0,l=(n==null?void 0:n.default_model_name)??Bd,{isLoadingModel:d,isDownloadingModel:h,loadModel:f,downloadModel:p}=Kg(l),m=S.useRef(n==null?void 0:n.lemonade_running),T=S.useRef(n==null?void 0:n.model_downloaded),x=S.useRef(n==null?void 0:n.context_size_sufficient),I=S.useRef(n==null?void 0:n.expected_model_loaded);if(S.useEffect(()=>{if(u)return;const g=n==null?void 0:n.lemonade_running,E=n==null?void 0:n.model_downloaded,y=n==null?void 0:n.context_size_sufficient,v=n==null?void 0:n.expected_model_loaded;let O=!1;m.current!==g&&(m.current=g,g===!1&&(O=!0)),T.current!==E&&(T.current=E,E===!1&&(O=!0)),x.current!==y&&(x.current=y,y===!1&&(O=!0)),I.current!==v&&(I.current=v,v===!1&&(O=!0)),O&&a(!1)},[n,u]),s||u)return null;if(!t)return c.jsxs("div",{className:"connection-banner connection-banner--error",role:"alert",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(Ey,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Cannot connect to GAIA Agent UI server."," ",c.jsxs("span",{className:"connection-banner__hint",children:["Start it with: ",c.jsx("code",{children:"gaia chat --ui"})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Retry"})]});if(n&&!n.lemonade_running)return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(Ii,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["LLM server is not responding — it may be busy or not running."," ",c.jsxs("span",{className:"connection-banner__hint",children:["If not started, run: ",c.jsx("code",{children:"lemonade-server serve"})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Check again"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]});if(n&&n.lemonade_running&&!n.model_loaded&&n.model_downloaded===!1)return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(dd,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Required model ",c.jsx("strong",{children:l})," is not downloaded (~25 GB)."]}),h?c.jsxs("span",{className:"connection-banner__loading",children:[c.jsx(xi,{size:13,className:"connection-banner__spinner"}),"Downloading…"]}):c.jsx("button",{className:"connection-banner__retry",onClick:()=>p(!1),children:"Download"}),e&&!h&&c.jsx("button",{className:"connection-banner__retry connection-banner__retry--secondary",onClick:e,children:"Recheck"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]});if(n&&n.lemonade_running&&n.model_loaded&&n.expected_model_loaded===!1&&!n.embedding_model_loaded){const g=n.model_loaded,E=n.context_size_sufficient===!1;return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(YT,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["Wrong model loaded: ",c.jsx("strong",{children:g}),"."," ","GAIA Chat requires ",c.jsx("strong",{children:l}),".",E&&c.jsxs(c.Fragment,{children:[" ","Context window is also too small."]})]}),d?c.jsxs("span",{className:"connection-banner__loading",children:[c.jsx(xi,{size:13,className:"connection-banner__spinner"}),"Loading…"]}):c.jsx("button",{className:"connection-banner__retry",onClick:()=>f(),children:"Load Now"}),e&&!d&&c.jsx("button",{className:"connection-banner__retry connection-banner__retry--secondary",onClick:e,children:"Recheck"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]})}if(n&&n.lemonade_running&&n.model_loaded&&n.context_size_sufficient===!1){const g=n.model_context_size??0,E=n.lemonade_url??"http://localhost:8000";return c.jsxs("div",{className:"connection-banner connection-banner--warning",role:"status",children:[c.jsx("div",{className:"connection-banner__icon",children:c.jsx(KT,{size:16})}),c.jsxs("div",{className:"connection-banner__text",children:["LLM context window is too small (",g.toLocaleString()," tokens;"," ",Ns.toLocaleString()," required)."," ",c.jsxs("span",{className:"connection-banner__hint",children:["In"," ",c.jsx("a",{className:"connection-banner__link",href:E,target:"_blank",rel:"noreferrer",children:"Lemonade"}),", set ctx‑size to ",Ns.toLocaleString(),", or restart with:"," ",c.jsxs("code",{children:["lemonade-server serve --ctx-size ",Ns]})]})]}),e&&c.jsx("button",{className:"connection-banner__retry",onClick:e,children:"Check again"}),c.jsx("button",{className:"connection-banner__dismiss",onClick:()=>a(!0),"aria-label":"Dismiss",children:c.jsx(Mt,{size:14})})]})}return null}function k6(){const e=Du(qv),t=Du(n=>n.respondToPermission);return e?c.jsx("div",{className:"permission-overlay",role:"dialog","aria-modal":"true","aria-label":"Permission Request",children:c.jsx(S6,{notification:e,onRespond:t},e.id)}):null}function S6({notification:e,onRespond:t}){const n=e.timeoutSeconds!=null&&e.timeoutSeconds>0,[r,i]=S.useState(n?e.timeoutSeconds:null),s=S.useRef(null),[a,u]=S.useState(!1),[l,d]=S.useState(!1),h=S.useRef(!1),f=S.useRef(t);f.current=t,S.useEffect(()=>{if(n)return s.current=setInterval(()=>{i(I=>I===null||I<=1?(s.current&&clearInterval(s.current),0):I-1)},1e3),()=>{s.current&&clearInterval(s.current)}},[n]),S.useEffect(()=>{if(r===0){if(h.current)return;h.current=!0,u(!0),f.current(e.id,"deny",!1)}},[r,e.id]);const p=S.useCallback(async()=>{if(!h.current){h.current=!0,u(!0),s.current&&clearInterval(s.current);try{await t(e.id,"allow",l)}finally{h.current=!1,u(!1)}}},[e.id,t,l]),m=S.useCallback(async()=>{if(!h.current){h.current=!0,u(!0),s.current&&clearInterval(s.current);try{await t(e.id,"deny",!1)}finally{h.current=!1,u(!1)}}},[e.id,t]);S.useEffect(()=>{const I=g=>{g.key==="Enter"&&!g.shiftKey?(g.preventDefault(),p()):g.key==="Escape"&&(g.preventDefault(),m())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[p,m]);const T=e.toolArgs,x=T&&Object.keys(T).length>0;return c.jsxs("div",{className:"permission-prompt",children:[c.jsxs("div",{className:"permission-header",children:[c.jsx("div",{className:"permission-header-icon",children:c.jsx(hy,{size:24})}),c.jsxs("div",{className:"permission-header-text",children:[c.jsx("h2",{className:"permission-title",children:"Permission Request"}),c.jsx("span",{className:"permission-agent",children:e.agentName})]}),r!==null&&r>0&&c.jsxs("div",{className:"permission-countdown",title:"Auto-deny on timeout",children:[c.jsx(Hp,{size:14}),c.jsxs("span",{children:[r,"s"]})]})]}),c.jsxs("div",{className:"permission-body",children:[c.jsx("p",{className:"permission-message",children:e.message}),e.tool&&c.jsxs("div",{className:"permission-tool-info",children:[c.jsxs("div",{className:"permission-tool-header",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"Tool Invocation"})]}),c.jsx("div",{className:"permission-tool-name",children:c.jsx("code",{children:e.tool})}),x&&c.jsx("div",{className:"permission-tool-args",children:c.jsx("pre",{children:JSON.stringify(T,null,2)})})]}),e.priority==="critical"&&c.jsxs("div",{className:"permission-critical-banner",children:[c.jsx(Ii,{size:14}),c.jsx("span",{children:"This is a critical-tier operation"})]}),c.jsxs("label",{className:"permission-remember",children:[c.jsx("input",{type:"checkbox",checked:l,onChange:I=>d(I.target.checked),disabled:a}),c.jsx("span",{children:"Always allow this tool"})]})]}),c.jsxs("div",{className:"permission-actions",children:[c.jsxs("button",{className:"permission-btn permission-btn-deny",onClick:m,disabled:a,title:"Deny (Esc)",children:[c.jsx(Mt,{size:16}),"Deny"]}),c.jsxs("button",{className:"permission-btn permission-btn-allow",onClick:p,disabled:a,title:"Allow (Enter)",children:[c.jsx(ea,{size:16}),"Allow"]})]}),c.jsxs("div",{className:"permission-hints",children:[c.jsxs("span",{children:[c.jsx("kbd",{children:"Enter"})," Allow"]}),c.jsxs("span",{children:[c.jsx("kbd",{children:"Esc"})," Deny"]})]})]})}function Da({show:e,children:t,duration:n=250}){const[r,i]=S.useState(!1),[s,a]=S.useState("idle");return S.useEffect(()=>{if(e)i(!0),requestAnimationFrame(()=>a("entering"));else if(r){a("exiting");const u=setTimeout(()=>{i(!1),a("idle")},n);return()=>clearTimeout(u)}},[e,r,n]),r?c.jsx("div",{className:`animated-presence ${s}`,"data-duration":n,children:t}):null}function C6(){const{currentSessionId:e,setSessions:t,setCurrentSession:n,addSession:r,removeSession:i,updateSessionInList:s,setMessages:a,showDocLibrary:u,showFileBrowser:l,showSettings:d,sidebarOpen:h,toggleSidebar:f,setSidebarOpen:p,setSystemStatus:m,setBackendConnected:T}=we(),[x,I]=S.useState(!1),[g,E]=S.useState(!1),[y,v]=S.useState(!1),[O,A]=S.useState(null),F=S.useRef(null),H=S.useRef(0),K=3,w=S.useCallback(async()=>{try{const re=await hd();if(T(!0),re.lemonade_running)H.current=0,m(re);else if(H.current+=1,D.system.warn(`Lemonade health check failed (${H.current}/${K})`),H.current>=K)m(re);else{const me=we.getState().systemStatus;me&&me.lemonade_running?m({...me,disk_space_gb:re.disk_space_gb,memory_available_gb:re.memory_available_gb}):m(re)}D.system.info("System status:",{lemonade:re.lemonade_running,model:re.model_loaded,failCount:H.current})}catch(re){D.system.warn("System status check failed",re),T(!1),m(null)}},[m,T]);S.useEffect(()=>(w(),F.current=setInterval(w,15e3),()=>{F.current&&clearInterval(F.current)}),[w]);const Y=S.useRef(null),te=S.useRef("");S.useEffect(()=>{qy("0.17.1"),D.system.info("App mounting, loading sessions...");const re=D.system.time(),me=De=>De.map(He=>`${He.id}|${He.updated_at}|${He.title}`).join(`
432
432
  `),ve=(De=!1)=>{Xy().then(He=>{const R=He.sessions||[];if(De){t(R),T(!0),te.current=me(R),D.system.timed(`Loaded ${R.length} session(s)`,re);return}const W=we.getState().sessions;if(R.length===0&&W.length>0){D.system.warn(`Session poll returned 0 sessions but sidebar has ${W.length} — skipping update to prevent data loss`);return}const de=me(R);de!==te.current&&(D.system.info(`Session list changed (${W.length} → ${R.length} sessions)`),t(R),te.current=de)}).catch(He=>{De&&(D.system.error("Failed to load sessions from backend",He),D.system.warn("Is the Python backend running? Start it with: gaia chat --ui"))})};return ve(!0),Y.current=setInterval(()=>ve(!1),5e3),()=>{Y.current&&clearInterval(Y.current)}},[t,r,i,s,T]),S.useEffect(()=>{if(e)return;const me=new URLSearchParams(window.location.search).get("session"),ve=window.location.hash.replace(/^#/,""),De=me||ve;if(!De)return;D.nav.info(`URL session parameter: ${De}`);const He=setTimeout(()=>{const{sessions:R}=we.getState();let W=R.some(de=>de.id===De)?De:pb(R,De);W?(n(W),a([])):D.nav.warn(`Session ${De} not found in loaded sessions`)},500);return()=>clearTimeout(He)},[e,n,a]),S.useEffect(()=>{if(e){const re=mn(e);window.location.hash!==`#${re}`&&window.history.replaceState(null,"",`#${re}`)}else window.location.hash&&window.history.replaceState(null,"",window.location.pathname+window.location.search)},[e]),S.useEffect(()=>{n1().then(re=>{E(re.active===!0)}).catch(()=>{})},[]),S.useEffect(()=>{const re=()=>{window.innerWidth>768&&p(!0)};return window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[p]);const[ce,le]=S.useState(null),ue=S.useCallback(async()=>{D.chat.info("Creating new task session..."),le(null);try{const re=await Zp({title:"New Task"});D.chat.info(`Session created: id=${re.id}, title="${re.title}"`),r(re),n(re.id),a([]),window.innerWidth<=768&&p(!1)}catch(re){D.chat.error("Failed to create session",re),w(),le("Failed to create task. Is the server running?"),setTimeout(()=>le(null),6e3)}},[r,n,a,p,w]),{setPendingPrompt:j}=we(),z=S.useCallback(async re=>{D.chat.info(`New task with prompt: "${re.slice(0,60)}..."`),j(re),await ue()},[ue,j]),P=S.useCallback(async()=>{if(g){D.system.info("Stopping mobile access tunnel...");try{await hb()}catch{}E(!1),I(!1)}else{D.system.info("Starting mobile access tunnel..."),I(!0),v(!0),A(null);try{const re=await fb();re.error?(D.system.error("Tunnel failed to start:",re.error),E(!1),A(re.error)):(E(!0),D.system.info("Tunnel started successfully"))}catch(re){D.system.error("Tunnel start error:",re),E(!1),A(re instanceof Error?re.message:"Failed to connect")}finally{v(!1)}}},[g]);S.useEffect(()=>{e?D.nav.info(`Viewing session: ${e}`):D.nav.info("Viewing welcome screen (no session selected)")},[e]),S.useEffect(()=>{u&&D.ui.info("Document Library opened")},[u]),S.useEffect(()=>{d&&D.ui.info("Settings modal opened")},[d]);const[G,_]=S.useState(typeof window<"u"&&window.innerWidth<=768);S.useEffect(()=>{const re=()=>_(window.innerWidth<=768);return window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]);const[Z,fe]=S.useState(!1),[N,Ne]=S.useState(null);return S.useEffect(()=>{if(e!==N){fe(!0);const re=setTimeout(()=>{Ne(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{fe(!1)})})},220);return()=>clearTimeout(re)}},[e,N]),c.jsxs("div",{className:"app",children:[c.jsx("button",{className:"sidebar-toggle",onClick:f,"aria-label":h?"Close sidebar":"Open sidebar",children:c.jsx(ty,{size:18})}),c.jsx("div",{className:`sidebar-overlay ${h?"visible":""}`,onClick:()=>p(!1),"aria-hidden":"true"}),c.jsx(Eb,{onNewTask:ue,tunnelActive:g,tunnelLoading:y,onMobileToggle:P}),c.jsxs("div",{className:"main-content",children:[c.jsx(_6,{onRetry:w}),c.jsx("div",{className:`view-container ${Z?"view-transitioning":""}`,children:N?c.jsx(Zv,{sessionId:N},N):c.jsx(r6,{onNewTask:ue,onSendPrompt:z})})]}),c.jsx(Da,{show:u,children:c.jsx(u6,{})}),c.jsx(Da,{show:l,children:c.jsx(h6,{})}),c.jsx(Da,{show:d,children:c.jsx(E6,{})}),!G&&c.jsx(Da,{show:x,children:c.jsx(x6,{isOpen:x,onClose:()=>I(!1),error:O})}),c.jsx(k6,{}),ce&&c.jsx("div",{className:"toast",role:"alert",children:ce})]})}const N6=localStorage.getItem("gaia-chat-theme");N6!=="light"&&document.documentElement.setAttribute("data-theme","dark");io.createRoot(document.getElementById("root")).render(c.jsx(As.StrictMode,{children:c.jsx(C6,{})}));
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/png" href="./favicon.png" />
7
7
  <title>GAIA Agent UI</title>
8
- <script type="module" crossorigin src="./assets/index-C7oO2M6Q.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-DFaWywBV.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="./assets/index-TyWv9Ej0.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amd-gaia/agent-ui",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "productName": "GAIA Agent UI",
6
6
  "description": "Privacy-first agentic AI interface with document Q&A - runs 100% locally on AMD Ryzen AI",