llmxray 0.4.0 → 0.4.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/README.md +265 -244
- package/dist/assets/{AITrainingPage-Ck1bDWWB.js → AITrainingPage-VU-Nu5i0.js} +1 -1
- package/dist/assets/{BenchmarkPage-VzMNGUEy.js → BenchmarkPage-CQUTAU0c.js} +1 -1
- package/dist/assets/{ComparisonPage-BBliPm7K.js → ComparisonPage-DSO_-JZF.js} +1 -1
- package/dist/assets/CostDashboardPage-BLzCE-bT.js +1 -0
- package/dist/assets/DashboardPage-lqAFJvOo.js +116 -0
- package/dist/assets/{EmbeddingsPage-BIHHeJq6.js → EmbeddingsPage-DDBfFe8z.js} +1 -1
- package/dist/assets/{GoogleCallbackPage-2gGq0Swg.js → GoogleCallbackPage-H8X6YDz9.js} +1 -1
- package/dist/assets/{JsonTreeNode-CDR0az7J.js → JsonTreeNode-DQ_R5Euc.js} +1 -1
- package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-DkuvrY_5.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CV939MUZ.js} +1 -1
- package/dist/assets/{RAGPage-BdXerRDW.js → RAGPage-DbZxWHmi.js} +1 -1
- package/dist/assets/SessionPage-DvtFE4GS.js +15 -0
- package/dist/assets/{SettingsPage-B1wm-L6T.js → SettingsPage-fmgr8zF9.js} +1 -1
- package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-J8rYaobd.js → StatusBadge.vue_vue_type_script_setup_true_lang-BbHpA7hy.js} +1 -1
- package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-Begwajgo.js → StorageGauge.vue_vue_type_style_index_0_lang-Dd3BsCg6.js} +1 -1
- package/dist/assets/{SystemPage-DDZrsYds.js → SystemPage-Bd3SBsWI.js} +2 -2
- package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-DVCeD1qL.js → TabBar.vue_vue_type_script_setup_true_lang-DlSEPHs6.js} +1 -1
- package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-rJpx5sU7.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-P-I0kJTd.js} +1 -1
- package/dist/assets/{ToolWorkshopPage-DnHp32vX.js → ToolWorkshopPage-D9doB8PF.js} +1 -1
- package/dist/assets/{agent-store-BWO6HamI.js → agent-store-CuCtjbhV.js} +1 -1
- package/dist/assets/{canvas-ai-db-anWOo2F0.js → canvas-ai-db-DBUT-nyD.js} +1 -1
- package/dist/assets/{download-BqPPd3_X.js → download-C3s6K1NW.js} +1 -1
- package/dist/assets/{generate-service-C3Z8NZaT.js → generate-service-DrRYe_-5.js} +1 -1
- package/dist/assets/{google-auth-store-CgUWvtRU.js → google-auth-store-B0WvuFWG.js} +1 -1
- package/dist/assets/index-Bawj8X2v.css +1 -0
- package/dist/assets/{index-KhnkHbiC.js → index-CUNpOQX9.js} +1 -1
- package/dist/assets/index-DYHBy1xj.js +8 -0
- package/dist/assets/{index-B7GdQF1S.js → index-DoMyvAkM.js} +1 -1
- package/dist/assets/info-D-oZIv7P.js +1 -0
- package/dist/assets/{metrics-store-BMhkZ9B4.js → metrics-store-DRErjO4D.js} +1 -1
- package/dist/assets/{papaparse.min-z5sNvmdo.js → papaparse.min-DJzuA_ek.js} +1 -1
- package/dist/assets/{pencil-Csf0-tn3.js → pencil-MO2uWQbW.js} +1 -1
- package/dist/assets/{rag-store-Ch0N5LTe.js → rag-store-CBWvD3Va.js} +3 -3
- package/dist/assets/{share-2-DIi3V2dc.js → share-2-CnM5sBDm.js} +1 -1
- package/dist/assets/{storage-store-uPTARmbg.js → storage-store-cx_2Hb_J.js} +1 -1
- package/dist/assets/{stream-handler-BuwD741F.js → stream-handler-CXdBM2li.js} +1 -1
- package/dist/assets/{tool-workshop-store-koPpdoxb.js → tool-workshop-store-Cb4eb3e4.js} +1 -1
- package/dist/assets/{toolcall-store-JKmpIFj3.js → toolcall-store-xQEQUq5f.js} +1 -1
- package/dist/assets/{trash-2-aeVGvgIz.js → trash-2-Cj-NOsVZ.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/DashboardPage-CH15t_MS.js +0 -116
- package/dist/assets/SessionPage-B39x2A8D.js +0 -15
- package/dist/assets/index-ClE7gpZb.js +0 -8
- package/dist/assets/index-Dr1ztyT3.css +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import{u as it}from"./metrics-store-DRErjO4D.js";import{c as Pe,_ as Es,o as De,n as be,r as A,d as Ot,w as te,a as B,b as se,e as g,f as r,g as E,t as d,h as Te,i as N,j as h,F as U,k as Q,l as Is,u as x,m as Ps,p as D,q as Ee,T as Ds,s as qt,v as He,X as Je,x as Ut,y as js,z as Vt,A as lt,B as Ht,E as Bs,C as W,D as X,G as tt,H as Gt,I as Wt,S as Ls,J as Fs}from"./index-DYHBy1xj.js";import{f as Ce,a as Ge,b as st,c as Zt,d as Os}from"./format-BqVZ9rwM.js";import{u as Xe,a as qs}from"./toolcall-store-xQEQUq5f.js";import{a as Us,s as Vs,C as Hs}from"./generate-service-DrRYe_-5.js";import{u as Gs,a as Ws,_ as Zs,b as Ue}from"./StatusBadge.vue_vue_type_script_setup_true_lang-BbHpA7hy.js";import{u as ct}from"./tool-workshop-store-Cb4eb3e4.js";import{u as Ks,a as Kt,b as Qs}from"./agent-store-CuCtjbhV.js";import{e as Js}from"./stream-handler-CXdBM2li.js";import{d as Xs,p as Ys,u as Qt}from"./rag-store-CBWvD3Va.js";import{messageMemoryDB as Jt}from"./message-memory-db-C3Ifhs2B.js";import{_ as Tt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CV939MUZ.js";import{P as Mt}from"./pencil-MO2uWQbW.js";import{D as en}from"./download-C3s6K1NW.js";import"./vector-db-ChAzHl5A.js";const tn=Pe("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);const Xt=Pe("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const sn=Pe("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]);const nn=Pe("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const on=Pe("slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);async function an(t,e){const s=performance.now();try{let o;return t.implementation.mode==="code"?o=await rn(t.implementation.code,e):o=await ln(t.implementation.blocks,e),{success:!0,result:o,durationMs:performance.now()-s}}catch(o){return{success:!1,result:null,durationMs:performance.now()-s,error:o instanceof Error?o.message:String(o)}}}async function rn(t,e){if(!t.trim())throw new Error("Tool has no implementation code");const s=Object.getPrototypeOf(async function(){}).constructor;return await new s("args","fetch","getGoogleToken",t)(e,fetch.bind(globalThis),hn)}async function ln(t,e){if(t.length===0)throw new Error("Tool has no action blocks");const s=new Map;for(const[i,a]of Object.entries(e))s.set(i,a);const o=[...t].sort((i,a)=>i.order-a.order);let n=null;for(const i of o)switch(i.type){case"http_request":await cn(i.config,s);break;case"extract_field":un(i.config,s);break;case"template":dn(i.config,s);break;case"return_value":n=pn(i.config,s);break}return n}async function cn(t,e){const s=Ie(t.url,e),o=t.body?Ie(t.body,e):void 0,n={};for(const[l,p]of Object.entries(t.headers))n[l]=Ie(p,e);const i=await fetch(s,{method:t.method,headers:n,body:t.method!=="GET"?o:void 0});let a;(i.headers.get("content-type")??"").includes("application/json")?a=await i.json():a=await i.text(),e.set(t.outputVariable||"response",a)}function un(t,e){const s=e.get(t.input);if(s==null){e.set(t.outputVariable||"value",null);return}const o=t.fieldPath.split(".");let n=s;for(const i of o){if(n==null||typeof n!="object"){n=null;break}n=n[i]}e.set(t.outputVariable||"value",n)}function dn(t,e){const s=Ie(t.template,e);e.set(t.outputVariable||"text",s)}function pn(t,e){const s=t.expression.trim();return e.has(s)?e.get(s):Ie(s,e)}async function hn(){const{getAccessToken:t,isConnected:e}=await Es(async()=>{const{getAccessToken:s,isConnected:o}=await import("./google-auth-CfEcVMA7.js");return{getAccessToken:s,isConnected:o}},[]);if(!e())throw new Error("Google account not connected. Go to Settings to connect your Google account.");return t()}function Ie(t,e){return t.replace(/\{\{(\w+(?:\.\w+)*)\}\}/g,(s,o)=>{const n=o.split(".");let i=e.get(n[0]??"");for(let a=1;a<n.length;a++){if(i==null||typeof i!="object")return"";i=i[n[a]??""]}return i==null?"":typeof i=="object"?JSON.stringify(i):String(i)})}const mn=5;async function gn(t){const e=Xe(),s=Gs(),o=t.messages.map(c=>`[${c.role}] ${c.content}`).join(`
|
|
2
|
+
`),n=e.createSession({mode:"chat",model:t.model,prompt:o,messages:t.messages,options:t.options});e.setActiveSession(n);const i=Us(n,t.messages);s.setAnatomy(n,i);const a=new AbortController;return fn(n,t.model,[...t.messages],t.tools,t.options,a.signal).catch(c=>{a.signal.aborted||e.setSessionError(n,c instanceof Error?c.message:"Chat failed")}),{sessionId:n,abort:()=>{a.abort(),e.cancelSession(n)}}}async function fn(t,e,s,o,n,i){const a=qs(),c=ct(),l=Ks();let p=0,u=0;for(;p<mn;){if(i.aborted)return;const m=await De.streamChat({model:e,messages:s,tools:o,options:n,logprobs:!0},i),y=await Js(t,m,i);if(y.toolCalls.length===0)return;s.push({role:"assistant",content:"",tool_calls:y.toolCalls});for(const C of y.toolCalls){const k=c.findByFunctionName(C.function.name),b=a.getToolCalls(t).find(V=>V.functionName===C.function.name&&V.status==="pending");if(!k){const V=`Tool "${C.function.name}" has no implementation`;l.addNode(t,{id:be(),type:"error",label:`No impl: ${C.function.name}`,sessionId:t,stepIndex:u++,state:{tool:C.function.name,error:V},timestamp:Date.now()}),b&&a.updateToolCall(t,b.id,{status:"failed",error:V,completedAt:Date.now()}),s.push({role:"tool",content:JSON.stringify({error:V})});continue}b&&a.updateToolCall(t,b.id,{status:"executing"});const I=await an(k,C.function.arguments);l.addNode(t,{id:be(),type:I.success?"output":"error",label:I.success?`Tool Result: ${C.function.name}`:`Tool Failed: ${C.function.name}`,sessionId:t,stepIndex:u++,state:{tool:C.function.name,success:I.success,durationMs:I.durationMs},timestamp:Date.now()}),b&&a.updateToolCall(t,b.id,{status:I.success?"completed":"failed",result:I.result,error:I.error,completedAt:Date.now(),durationMs:I.durationMs});const H=I.success?typeof I.result=="string"?I.result:JSON.stringify(I.result):JSON.stringify({error:I.error});s.push({role:"tool",content:H})}l.addNode(t,{id:be(),type:"llm_call",label:`LLM Round ${p+2} (with tool results)`,sessionId:t,stepIndex:u++,state:{round:p+1},timestamp:Date.now()}),p++}}function xn(){const t=A(!1),e=A(null),s=A(null);let o=null;async function n(c,l,p,u){t.value=!0,e.value=null;try{const m=await Vs({model:c,prompt:l,system:u,options:p});return s.value=m.sessionId,o=m.abort,m.sessionId}catch(m){throw e.value=m instanceof Error?m.message:"Failed to start generation",t.value=!1,m}}async function i(c,l,p,u){t.value=!0,e.value=null;try{const m=await gn({model:c,messages:l,tools:u,options:p});return s.value=m.sessionId,o=m.abort,m.sessionId}catch(m){throw e.value=m instanceof Error?m.message:"Failed to start chat",t.value=!1,m}}function a(){o&&(o(),o=null),t.value=!1}return{isStreaming:t,error:e,currentSessionId:s,startGenerate:n,startChatStream:i,cancel:a}}const We=[{name:"help",description:"Show all available commands",usage:"/help",category:"chat",execute(t,e){const s=Yt(),o=[`Available commands:
|
|
3
|
+
`];for(const[n,i]of Object.entries(s)){o.push(`**${n}**`);for(const a of i)o.push(` ${a.usage} — ${a.description}`);o.push("")}e.showNotification(o.join(`
|
|
4
|
+
`))}},{name:"clear",description:"Clear current conversation",usage:"/clear",category:"chat",execute(t,e){e.clearConversation(),e.showNotification("Conversation cleared.")}},{name:"new",description:"Start a new chat session",usage:"/new",category:"chat",execute(t,e){e.newChat(),e.showNotification("New chat started.")}},{name:"summarize",description:"Ask the model to summarize the conversation",usage:"/summarize",category:"chat",execute(t,e){if(e.messages.length===0){e.showNotification("Nothing to summarize — conversation is empty.");return}e.sendAsUser("Please summarize our conversation so far in a concise way.")}},{name:"save",description:"Export conversation as JSON or text",usage:"/save [json|text]",category:"chat",execute(t,e){const s=t.trim()==="text"?"text":"json";e.exportConversation(s),e.showNotification(`Conversation exported as ${s}.`)}},{name:"copy",description:"Copy last assistant response to clipboard",usage:"/copy",category:"chat",execute(t,e){e.copyLastResponse()}},{name:"history",description:"Show recent conversations",usage:"/history",category:"chat",execute(t,e){e.showNotification("Scroll down to the recent chats section, or start a /new chat.")}},{name:"model",description:"Switch model or list available models",usage:"/model [name]",category:"settings",execute(t,e){const s=t.trim();if(!s){const n=e.availableModels.join(", ");e.showNotification(`Available models: ${n}
|
|
5
|
+
Current: ${e.currentModel}`);return}const o=e.availableModels.find(n=>n===s||n.startsWith(s));o?(e.switchModel(o),e.showNotification(`Switched to ${o}.`)):e.showNotification(`Model "${s}" not found. Available: ${e.availableModels.join(", ")}`)}},{name:"system",description:"Set the system prompt",usage:"/system <prompt>",category:"settings",execute(t,e){const s=t.trim();if(!s){const o=e.chatSettings.value.systemPrompt||"(none)";e.showNotification(`Current system prompt: ${o}`);return}e.setSystemPrompt(s),e.showNotification("System prompt updated.")}},{name:"temperature",description:"Set temperature (0-2)",usage:"/temperature <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<0||s>2){e.showNotification(`Current: ${e.chatSettings.value.options.temperature??.7}. Usage: /temperature 0.0-2.0`);return}e.setOption("temperature",s),e.showNotification(`Temperature set to ${s}.`)}},{name:"top_p",description:"Set top-p / nucleus sampling (0-1)",usage:"/top_p <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<0||s>1){e.showNotification(`Current: ${e.chatSettings.value.options.top_p??.9}. Usage: /top_p 0.0-1.0`);return}e.setOption("top_p",s),e.showNotification(`Top-p set to ${s}.`)}},{name:"top_k",description:"Set top-k sampling (1-100)",usage:"/top_k <value>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(isNaN(s)||s<1||s>100){e.showNotification(`Current: ${e.chatSettings.value.options.top_k??40}. Usage: /top_k 1-100`);return}e.setOption("top_k",s),e.showNotification(`Top-k set to ${s}.`)}},{name:"context",description:"Set context window size",usage:"/context <size>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10),o=[2048,4096,8192,16384,32768,65536,131072];if(isNaN(s)||!o.includes(s)){e.showNotification(`Current: ${Ce(e.chatSettings.value.options.num_ctx??4096)}. Valid sizes: ${o.join(", ")}`);return}e.setOption("num_ctx",s),e.showNotification(`Context window set to ${Ce(s)}.`)}},{name:"repeat_penalty",description:"Set repeat penalty (1.0-2.0)",usage:"/repeat_penalty <value>",category:"settings",execute(t,e){const s=parseFloat(t.trim());if(isNaN(s)||s<1||s>2){e.showNotification(`Current: ${e.chatSettings.value.options.repeat_penalty??1.1}. Usage: /repeat_penalty 1.0-2.0`);return}e.setOption("repeat_penalty",s),e.showNotification(`Repeat penalty set to ${s}.`)}},{name:"seed",description:"Set seed for reproducibility (-1 for random)",usage:"/seed <value>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(isNaN(s)){e.showNotification(`Current: ${e.chatSettings.value.options.seed??-1}. Usage: /seed <number>`);return}e.setOption("seed",s===-1?void 0:s),e.showNotification(s===-1?"Seed set to random.":`Seed set to ${s}.`)}},{name:"stop",description:"Set stop sequences (comma-separated)",usage:"/stop <sequences>",category:"settings",execute(t,e){const s=t.trim();if(!s){const n=e.chatSettings.value.options.stop?.join(", ")||"(none)";e.showNotification(`Current stop sequences: ${n}`);return}const o=s.split(",").map(n=>n.trim()).filter(Boolean);e.setOption("stop",o.length>0?o:void 0),e.showNotification(`Stop sequences set: ${o.join(", ")}`)}},{name:"mirostat",description:"Set mirostat mode (0=off, 1=v1, 2=v2)",usage:"/mirostat <0|1|2>",category:"settings",execute(t,e){const s=parseInt(t.trim(),10);if(![0,1,2].includes(s)){e.showNotification(`Current: ${e.chatSettings.value.options.mirostat??0}. Usage: /mirostat 0|1|2`);return}e.setOption("mirostat",s),e.showNotification(s===0?"Mirostat disabled.":`Mirostat v${s} enabled.`)}},{name:"format",description:"Toggle JSON output format",usage:"/format [json]",category:"settings",execute(t,e){const s=t.trim().toLowerCase()==="json";e.setJsonFormat(s),e.showNotification(s?"JSON format enabled.":"JSON format disabled.")}},{name:"reset",description:"Reset all settings to defaults",usage:"/reset",category:"settings",execute(t,e){e.resetSettings(),e.showNotification("All settings reset to defaults.")}},{name:"rag",description:"Toggle RAG context on/off",usage:"/rag",category:"navigation",execute(t,e){e.toggleRag(),e.showNotification(e.ragEnabled?"RAG context disabled.":"RAG context enabled.")}},{name:"tools",description:"Open tools settings panel",usage:"/tools",category:"navigation",execute(t,e){e.openSettings(),e.showNotification("Settings panel opened.")}},{name:"status",description:"Show Ollama connection status and model info",usage:"/status",category:"navigation",async execute(t,e){const s=await e.getOllamaStatus();e.showNotification(`Ollama: ${s.connected?"Connected":"Disconnected"}
|
|
6
|
+
Model: ${s.model||"(none)"}`)}},{name:"tokens",description:"Show token count for current session",usage:"/tokens",category:"navigation",execute(t,e){const s=e.getSessionTokenCount();if(!s){e.showNotification("No active session.");return}e.showNotification(`Prompt tokens: ${Ce(s.prompt)}
|
|
7
|
+
Completion tokens: ${Ce(s.completion)}
|
|
8
|
+
Total: ${Ce(s.prompt+s.completion)}`)}},{name:"speed",description:"Show average generation speed across sessions",usage:"/speed",category:"navigation",execute(t,e){const s=e.getAverageSpeed();if(s===null){e.showNotification("No sessions recorded yet.");return}e.showNotification(`Average speed: ${Ge(s)}`)}},{name:"compare",description:"Navigate to the Compare page",usage:"/compare",category:"navigation",execute(t,e){e.navigate("/compare")}},{name:"session",description:"View current session details",usage:"/session",category:"navigation",execute(t,e){e.openSessionDetails()}},{name:"remember",description:"Remember a fact about you across conversations",usage:"/remember <fact>",category:"memory",execute(t,e){const s=t.trim();if(!s){e.showNotification(`Usage: /remember <something to remember>
|
|
9
|
+
Example: /remember I prefer TypeScript over JavaScript`);return}e.addFact(s),e.showNotification(`Remembered: "${s}"`)}},{name:"forget",description:"Forget a previously remembered fact",usage:"/forget <search>",category:"memory",execute(t,e){const s=t.trim();if(!s){e.showNotification(`Usage: /forget <part of the fact to remove>
|
|
10
|
+
Example: /forget TypeScript`);return}e.removeFact(s)?e.showNotification(`Forgot fact matching "${s}".`):e.showNotification(`No fact found matching "${s}". Use /memories to see all facts.`)}},{name:"memories",description:"Show all remembered facts",usage:"/memories",category:"memory",execute(t,e){const s=e.getFacts();if(s.length===0){e.showNotification("No memories stored yet. Use /remember <fact> to add one.");return}const o=s.map((n,i)=>`${i+1}. ${n.content}`);e.showNotification(`Your memories (${s.length}):
|
|
11
|
+
${o.join(`
|
|
12
|
+
`)}`)}}];function bn(t){const e=t.toLowerCase().replace(/^\//,"");return e?We.filter(s=>s.name.startsWith(e)):We}function vn(t){return We.find(e=>e.name===t.toLowerCase())}function Yt(){const t={};for(const e of We){const s=e.category==="chat"?"Chat & Conversation":e.category==="settings"?"Model & Settings":e.category==="memory"?"Memory":"Features & Navigation";(t[s]??=[]).push(e)}return t}const Rt={slidingWindow:{enabled:!0,maxMessages:50},autoSummarize:{enabled:!1,triggerThreshold:30},ragMemory:{enabled:!1,embeddingModel:"",topK:3},userFacts:{enabled:!0}},At="llmxray-memory-settings",Nt="llmxray-user-facts";function zt(t,e){try{const s=localStorage.getItem(t);return s?JSON.parse(s):e}catch{return e}}function Et(t,e){localStorage.setItem(t,JSON.stringify(e))}const es=Ot("memory",()=>{const t=A(zt(At,{...Rt}));te(t,k=>Et(At,k),{deep:!0});function e(k){t.value={...t.value,...k}}function s(){t.value={...Rt}}const o=A(zt(Nt,[]));te(o,k=>Et(Nt,k),{deep:!0});const n=B(()=>o.value.length);function i(k){const z={id:be(),content:k.trim(),createdAt:Date.now()};return o.value=[...o.value,z],z}function a(k){o.value=o.value.filter(z=>z.id!==k)}function c(k){const z=k.toLowerCase().trim(),b=o.value.findIndex(I=>I.content.toLowerCase().includes(z));return b===-1?!1:(o.value=[...o.value.slice(0,b),...o.value.slice(b+1)],!0)}function l(){o.value=[]}function p(){return o.value.length===0?"":`The user has asked you to remember these facts about them:
|
|
13
|
+
${o.value.map(z=>`- ${z.content}`).join(`
|
|
14
|
+
`)}
|
|
15
|
+
|
|
16
|
+
Keep these in mind when responding.`}const u=A(new Map);function m(k,z,b){u.value.set(k,{conversationId:k,summary:z,messageCount:b,createdAt:Date.now()})}function y(k){return u.value.get(k)}function C(k){u.value.delete(k)}return{settings:t,updateSettings:e,resetSettings:s,facts:o,factCount:n,addFact:i,removeFact:a,removeFactByContent:c,clearFacts:l,getFactsAsSystemPrompt:p,summaries:u,setSummary:m,getSummary:y,clearSummary:C}}),ts=Ot("quality",()=>{const t=A(new Map);function e(n){return t.value.get(n)??null}function s(n,i){t.value.set(n,i)}function o(n){return t.value.has(n)}return{reportsByMessage:t,getReport:e,setReport:s,hasReport:o}}),yn=[/as an ai( language)? model/i,/i cannot (help|assist|provide)/i,/i('m| am) not able to/i,/i('m| am) unable to/i,/i must (decline|refuse)/i,/it('s| is) not (appropriate|ethical)/i,/i don'?t have the ability/i,/my programming (prevents|doesn'?t allow)/i];function kn(t,e){const s=[];for(let o=0;o<=t.length-e;o++)s.push(t.slice(o,o+e).join(" "));return s}function wn(t){const e=t.toLowerCase().split(/\s+/).filter(Boolean);if(e.length<8)return{detector:"repetition",status:"pass",reason:"quality.repetition.reason"};const s=kn(e,4);if(s.length===0)return{detector:"repetition",status:"pass",reason:"quality.repetition.reason"};const o=new Map;for(const a of s)o.set(a,(o.get(a)??0)+1);let n=0;for(const a of o.values())a>1&&(n+=a);const i=n/s.length;return i>.5?{detector:"repetition",status:"fail",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:i>.3?{detector:"repetition",status:"warn",reason:"quality.repetition.reason",detail:`${(i*100).toFixed(0)}% repeated 4-grams`}:{detector:"repetition",status:"pass",reason:"quality.repetition.reason"}}function $n(t){for(const e of yn)if(e.test(t))return{detector:"refusal",status:"warn",reason:"quality.refusal.reason",detail:`Matched: ${e.source}`};return{detector:"refusal",status:"pass",reason:"quality.refusal.reason"}}function Sn(t){if(t.length<=20)return{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"};let e=0;for(let o=0;o<t.length;o++)t.charCodeAt(o)>127&&e++;const s=e/t.length;return s>.4?{detector:"gibberish",status:"warn",reason:"quality.gibberish.reason",detail:`${(s*100).toFixed(0)}% non-ASCII characters`}:{detector:"gibberish",status:"pass",reason:"quality.gibberish.reason"}}function _n(t){const e=t.trim().split(/\s+/).filter(Boolean);return e.length===0?{detector:"empty",status:"fail",reason:"quality.empty.reason",detail:"0 words"}:e.length<10?{detector:"empty",status:"warn",reason:"quality.empty.reason",detail:`${e.length} words`}:{detector:"empty",status:"pass",reason:"quality.empty.reason"}}function Cn(t,e,s,o){if(o==="length")return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:"Model stopped due to token limit"};if(s&&s>0){const n=e/s,i=/[.!?\n)\]"]$/.test(t.trim());if(n>.9&&!i)return{detector:"truncation",status:"warn",reason:"quality.truncation.reason",detail:`Used ${(n*100).toFixed(0)}% of token budget without clean ending`}}return{detector:"truncation",status:"pass",reason:"quality.truncation.reason"}}function Tn(t){return t.some(e=>e.status==="fail")?"fail":t.some(e=>e.status==="warn")?"warn":"pass"}function Mn(t,e,s,o,n,i){const a=[wn(s),$n(s),Sn(s),_n(s),Cn(s,o,n,i)];return{messageId:t,sessionId:e,overall:Tn(a),checks:a,analyzedAt:Date.now()}}async function Rn(t){let e=[...t.messages],s;t.settings.userFacts.enabled&&t.userFactsPrompt&&e.unshift({role:"system",content:t.userFactsPrompt});const o=e.filter(n=>n.role!=="system");if(t.settings.autoSummarize.enabled&&o.length>t.settings.autoSummarize.triggerThreshold){const n=Math.floor(t.settings.autoSummarize.triggerThreshold/3),i=e.filter(u=>u.role==="system"),a=o.slice(0,-n),c=o.slice(-n),l=t.existingSummary?`Previous summary:
|
|
17
|
+
${t.existingSummary}
|
|
18
|
+
|
|
19
|
+
New messages to incorporate:
|
|
20
|
+
`:"",p=await Nn(t.model,l+a.map(u=>`${u.role}: ${u.content}`).join(`
|
|
21
|
+
`));p&&(s=p,e=[...i,{role:"system",content:`Summary of earlier conversation:
|
|
22
|
+
${p}`},...c])}if(t.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),i=e.filter(c=>c.role!=="system"),a=t.settings.slidingWindow.maxMessages;if(i.length>a){const c=i.slice(-a);e=[...n,...c]}}if(t.settings.ragMemory.enabled&&t.settings.ragMemory.embeddingModel)try{const n=await zn(t.conversationId,e,t.settings.ragMemory.embeddingModel,t.settings.ragMemory.topK);if(n){const i=e.filter(c=>c.role==="system"),a=e.filter(c=>c.role!=="system");e=[...i,{role:"system",content:n},...a]}}catch{}return{messages:e,newSummary:s}}async function An(t,e,s){if(!s||e.length===0)return;const o=e.map(a=>a.content),n=await De.embed({model:s,input:o}),i=[];for(let a=0;a<e.length;a++){const c=n.embeddings[a];if(!c)continue;const l=e[a];i.push({id:be(),conversationId:t,role:l.role,content:l.content,embedding:c,timestamp:l.timestamp})}await Jt.storeMessages(i)}async function Nn(t,e){try{return(await De.chat({model:t,messages:[{role:"system",content:"You are a helpful assistant. Summarize the following conversation concisely, preserving key facts, decisions, and context that would be important for continuing the conversation. Keep it under 300 words."},{role:"user",content:e}],stream:!1})).message.content.trim()||null}catch{return null}}async function zn(t,e,s,o){const n=e.filter(m=>m.role==="user"),i=n[n.length-1];if(!i)return null;const c=(await De.embed({model:s,input:[i.content]})).embeddings[0];if(!c)return null;const p=(await Jt.search(c,o,t)).filter(m=>m.score>.5);return p.length===0?null:`Relevant messages from past conversations:
|
|
23
|
+
${p.map(m=>`[${m.message.role}, relevance: ${(m.score*100).toFixed(0)}%] ${m.message.content}`).join(`
|
|
24
|
+
|
|
25
|
+
`)}
|
|
26
|
+
|
|
27
|
+
Use this context if helpful, but prioritize the current conversation.`}function ut(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var $e=ut();function ss(t){$e=t}var ke={exec:()=>null};function P(t,e=""){let s=typeof t=="string"?t:t.source,o={replace:(n,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(J.caret,"$1"),s=s.replace(n,a),o},getRegex:()=>new RegExp(s,e)};return o}var En=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),J={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},In=/^(?:[ \t]*(?:\n|$))+/,Pn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Dn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,je=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,dt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ns=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,os=P(ns).replace(/bull/g,dt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Bn=P(ns).replace(/bull/g,dt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ln=/^[^\n]+/,ht=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Fn=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ht).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),On=P(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,dt).getRegex(),Ye="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",mt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,qn=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",mt).replace("tag",Ye).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),as=P(pt).replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ye).getRegex(),Un=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",as).getRegex(),gt={blockquote:Un,code:Pn,def:Fn,fences:Dn,heading:jn,hr:je,html:qn,lheading:os,list:On,newline:In,paragraph:as,table:ke,text:Ln},It=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ye).getRegex(),Vn={...gt,lheading:Bn,table:It,paragraph:P(pt).replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",It).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ye).getRegex()},Hn={...gt,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",mt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ke,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(pt).replace("hr",je).replace("heading",` *#{1,6} *[^
|
|
28
|
+
]`).replace("lheading",os).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Gn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Wn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,rs=/^( {2,}|\\)\n(?!\s*$)/,Zn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,et=/[\p{P}\p{S}]/u,ft=/[\s\p{P}\p{S}]/u,is=/[^\s\p{P}\p{S}]/u,Kn=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ft).getRegex(),ls=/(?!~)[\p{P}\p{S}]/u,Qn=/(?!~)[\s\p{P}\p{S}]/u,Jn=/(?:[^\s\p{P}\p{S}]|~)/u,cs=/(?![*_])[\p{P}\p{S}]/u,Xn=/(?![*_])[\s\p{P}\p{S}]/u,Yn=/(?:[^\s\p{P}\p{S}]|[*_])/u,eo=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",En?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),us=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,to=P(us,"u").replace(/punct/g,et).getRegex(),so=P(us,"u").replace(/punct/g,ls).getRegex(),ds="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",no=P(ds,"gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,ft).replace(/punct/g,et).getRegex(),oo=P(ds,"gu").replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,Qn).replace(/punct/g,ls).getRegex(),ao=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,is).replace(/punctSpace/g,ft).replace(/punct/g,et).getRegex(),ro=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,cs).getRegex(),io="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",lo=P(io,"gu").replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Xn).replace(/punct/g,cs).getRegex(),co=P(/\\(punct)/,"gu").replace(/punct/g,et).getRegex(),uo=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),po=P(mt).replace("(?:-->|$)","-->").getRegex(),ho=P("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",po).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ze=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,mo=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ze).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ps=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Ze).replace("ref",ht).getRegex(),hs=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",ht).getRegex(),go=P("reflink|nolink(?!\\()","g").replace("reflink",ps).replace("nolink",hs).getRegex(),Pt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,xt={_backpedal:ke,anyPunctuation:co,autolink:uo,blockSkip:eo,br:rs,code:Wn,del:ke,delLDelim:ke,delRDelim:ke,emStrongLDelim:to,emStrongRDelimAst:no,emStrongRDelimUnd:ao,escape:Gn,link:mo,nolink:hs,punctuation:Kn,reflink:ps,reflinkSearch:go,tag:ho,text:Zn,url:ke},fo={...xt,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Ze).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ze).getRegex()},nt={...xt,emStrongRDelimAst:oo,emStrongLDelim:so,delLDelim:ro,delRDelim:lo,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Pt).getRegex()},xo={...nt,br:P(rs).replace("{2,}","*").getRegex(),text:P(nt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ve={normal:gt,gfm:Vn,pedantic:Hn},Ae={normal:xt,gfm:nt,breaks:xo,pedantic:fo},bo={"&":"&","<":"<",">":">",'"':""","'":"'"},Dt=t=>bo[t];function ue(t,e){if(e){if(J.escapeTest.test(t))return t.replace(J.escapeReplace,Dt)}else if(J.escapeTestNoEncode.test(t))return t.replace(J.escapeReplaceNoEncode,Dt);return t}function jt(t){try{t=encodeURI(t).replace(J.percentDecode,"%")}catch{return null}return t}function Bt(t,e){let s=t.replace(J.findPipe,(i,a,c)=>{let l=!1,p=a;for(;--p>=0&&c[p]==="\\";)l=!l;return l?"|":" |"}),o=s.split(J.splitPipe),n=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;n<o.length;n++)o[n]=o[n].trim().replace(J.slashPipe,"|");return o}function Ne(t,e,s){let o=t.length;if(o===0)return"";let n=0;for(;n<o&&t.charAt(o-n-1)===e;)n++;return t.slice(0,o-n)}function vo(t,e){if(t.indexOf(e[1])===-1)return-1;let s=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])s++;else if(t[o]===e[1]&&(s--,s<0))return o;return s>0?-2:-1}function yo(t,e=0){let s=e,o="";for(let n of t)if(n===" "){let i=4-s%4;o+=" ".repeat(i),s+=i}else o+=n,s++;return o}function Lt(t,e,s,o,n){let i=e.href,a=e.title||null,c=t[1].replace(n.other.outputLinkReplace,"$1");o.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:s,href:i,title:a,text:c,tokens:o.inlineTokens(c)};return o.state.inLink=!1,l}function ko(t,e,s){let o=t.match(s.other.indentCodeCompensation);if(o===null)return e;let n=o[1];return e.split(`
|
|
29
|
+
`).map(i=>{let a=i.match(s.other.beginningSpace);if(a===null)return i;let[c]=a;return c.length>=n.length?i.slice(n.length):i}).join(`
|
|
30
|
+
`)}var Ke=class{options;rules;lexer;constructor(t){this.options=t||$e}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let s=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?s:Ne(s,`
|
|
31
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let s=e[0],o=ko(s,e[3]||"",this.rules);return{type:"code",raw:s,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let s=e[2].trim();if(this.rules.other.endingHash.test(s)){let o=Ne(s,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(s=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ne(e[0],`
|
|
32
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=Ne(e[0],`
|
|
33
|
+
`).split(`
|
|
34
|
+
`),o="",n="",i=[];for(;s.length>0;){let a=!1,c=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))c.push(s[l]),a=!0;else if(!a)c.push(s[l]);else break;s=s.slice(l);let p=c.join(`
|
|
35
|
+
`),u=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
36
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
37
|
+
${p}`:p,n=n?`${n}
|
|
38
|
+
${u}`:u;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=m,s.length===0)break;let y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){let C=y,k=C.raw+`
|
|
39
|
+
`+s.join(`
|
|
40
|
+
`),z=this.blockquote(k);i[i.length-1]=z,o=o.substring(0,o.length-C.raw.length)+z.raw,n=n.substring(0,n.length-C.text.length)+z.text;break}else if(y?.type==="list"){let C=y,k=C.raw+`
|
|
41
|
+
`+s.join(`
|
|
42
|
+
`),z=this.list(k);i[i.length-1]=z,o=o.substring(0,o.length-y.raw.length)+z.raw,n=n.substring(0,n.length-C.raw.length)+z.raw,s=k.substring(i.at(-1).raw.length).split(`
|
|
43
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:i,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),o=s.length>1,n={type:"list",raw:"",ordered:o,start:o?+s.slice(0,-1):"",loose:!1,items:[]};s=o?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=o?s:"[*+-]");let i=this.rules.other.listItemRegex(s),a=!1;for(;t;){let l=!1,p="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let m=yo(e[2].split(`
|
|
44
|
+
`,1)[0],e[1].length),y=t.split(`
|
|
45
|
+
`,1)[0],C=!m.trim(),k=0;if(this.options.pedantic?(k=2,u=m.trimStart()):C?k=e[1].length+1:(k=m.search(this.rules.other.nonSpaceChar),k=k>4?1:k,u=m.slice(k),k+=e[1].length),C&&this.rules.other.blankLine.test(y)&&(p+=y+`
|
|
46
|
+
`,t=t.substring(y.length+1),l=!0),!l){let z=this.rules.other.nextBulletRegex(k),b=this.rules.other.hrRegex(k),I=this.rules.other.fencesBeginRegex(k),H=this.rules.other.headingBeginRegex(k),V=this.rules.other.htmlBeginRegex(k),K=this.rules.other.blockquoteBeginRegex(k);for(;t;){let G=t.split(`
|
|
47
|
+
`,1)[0],O;if(y=G,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),O=y):O=y.replace(this.rules.other.tabCharGlobal," "),I.test(y)||H.test(y)||V.test(y)||K.test(y)||z.test(y)||b.test(y))break;if(O.search(this.rules.other.nonSpaceChar)>=k||!y.trim())u+=`
|
|
48
|
+
`+O.slice(k);else{if(C||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||I.test(m)||H.test(m)||b.test(m))break;u+=`
|
|
49
|
+
`+y}C=!y.trim(),p+=G+`
|
|
50
|
+
`,t=t.substring(G.length+1),m=O.slice(k)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(a=!0)),n.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),n.raw+=p}let c=n.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l of n.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let u={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=u.checked,n.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=u.raw+l.tokens[0].raw,l.tokens[0].text=u.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(u)):l.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):l.tokens.unshift(u)}}if(!n.loose){let p=l.tokens.filter(m=>m.type==="space"),u=p.length>0&&p.some(m=>this.rules.other.anyLine.test(m.raw));n.loose=u}}if(n.loose)for(let l of n.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let s=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:s,raw:e[0],href:o,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let s=Bt(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
51
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(s.length===o.length){for(let a of o)this.rules.other.tableAlignRight.test(a)?i.align.push("right"):this.rules.other.tableAlignCenter.test(a)?i.align.push("center"):this.rules.other.tableAlignLeft.test(a)?i.align.push("left"):i.align.push(null);for(let a=0;a<s.length;a++)i.header.push({text:s[a],tokens:this.lexer.inline(s[a]),header:!0,align:i.align[a]});for(let a of n)i.rows.push(Bt(a,i.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let s=e[1].charAt(e[1].length-1)===`
|
|
52
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let i=Ne(s.slice(0,-1),"\\");if((s.length-i.length)%2===0)return}else{let i=vo(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],n="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(o);i&&(o=i[1],n=i[3])}else n=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?o=o.slice(1):o=o.slice(1,-1)),Lt(e,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let s;if((s=this.rules.inline.reflink.exec(t))||(s=this.rules.inline.nolink.exec(t))){let o=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[o.toLowerCase()];if(!n){let i=s[0].charAt(0);return{type:"text",raw:i,text:i}}return Lt(s,n,s[0],this.lexer,this.rules)}}emStrong(t,e,s=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!(!o||o[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(o[1]||o[2])||!s||this.rules.inline.punctuation.exec(s))){let n=[...o[0]].length-1,i,a,c=n,l=0,p=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,e=e.slice(-1*t.length+n);(o=p.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i)continue;if(a=[...i].length,o[3]||o[4]){c+=a;continue}else if((o[5]||o[6])&&n%3&&!((n+a)%3)){l+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+l);let u=[...o[0]][0].length,m=t.slice(0,n+o.index+u+a);if(Math.min(n,a)%2){let C=m.slice(1,-1);return{type:"em",raw:m,text:C,tokens:this.lexer.inlineTokens(C)}}let y=m.slice(2,-2);return{type:"strong",raw:m,text:y,tokens:this.lexer.inlineTokens(y)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(s),n=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return o&&n&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,s=""){let o=this.rules.inline.delLDelim.exec(t);if(o&&(!o[1]||!s||this.rules.inline.punctuation.exec(s))){let n=[...o[0]].length-1,i,a,c=n,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+n);(o=l.exec(e))!=null;){if(i=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!i||(a=[...i].length,a!==n))continue;if(o[3]||o[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let p=[...o[0]][0].length,u=t.slice(0,n+o.index+p+a),m=u.slice(n,-n);return{type:"del",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let s,o;return e[2]==="@"?(s=e[1],o="mailto:"+s):(s=e[1],o=s),{type:"link",raw:e[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let s,o;if(e[2]==="@")s=e[0],o="mailto:"+s;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);s=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:s,href:o,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let s=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:s}}}},re=class ot{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||$e,this.options.tokenizer=this.options.tokenizer||new Ke,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:J,block:Ve.normal,inline:Ae.normal};this.options.pedantic?(s.block=Ve.pedantic,s.inline=Ae.pedantic):this.options.gfm&&(s.block=Ve.gfm,this.options.breaks?s.inline=Ae.breaks:s.inline=Ae.gfm),this.tokenizer.rules=s}static get rules(){return{block:Ve,inline:Ae}}static lex(e,s){return new ot(s).lex(e)}static lexInline(e,s){return new ot(s).inlineTokens(e)}lex(e){e=e.replace(J.carriageReturn,`
|
|
53
|
+
`),this.blockTokens(e,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let o=this.inlineQueue[s];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,s=[],o=!1){for(this.options.pedantic&&(e=e.replace(J.tabCharGlobal," ").replace(J.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(a=>(n=a.call({lexer:this},e,s))?(e=e.substring(n.raw.length),s.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let a=s.at(-1);n.raw.length===1&&a!==void 0?a.raw+=`
|
|
54
|
+
`:s.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
55
|
+
`)?"":`
|
|
56
|
+
`)+n.raw,a.text+=`
|
|
57
|
+
`+n.text,this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
58
|
+
`)?"":`
|
|
59
|
+
`)+n.raw,a.text+=`
|
|
60
|
+
`+n.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title},s.push(n));continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),s.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),s.push(n);continue}let i=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),l;this.options.extensions.startBlock.forEach(p=>{l=p.call({lexer:this},c),typeof l=="number"&&l>=0&&(a=Math.min(a,l))}),a<1/0&&a>=0&&(i=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i))){let a=s.at(-1);o&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
61
|
+
`)?"":`
|
|
62
|
+
`)+n.raw,a.text+=`
|
|
63
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n),o=i.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let a=s.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
64
|
+
`)?"":`
|
|
65
|
+
`)+n.raw,a.text+=`
|
|
66
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n);continue}if(e){let a="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,s}inline(e,s=[]){return this.inlineQueue.push({src:e,tokens:s}),s}inlineTokens(e,s=[]){let o=e,n=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)l.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(o))!=null;)o=o.slice(0,n.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)i=n[2]?n[2].length:0,o=o.slice(0,n.index+i)+"["+"a".repeat(n[0].length-i-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let a=!1,c="";for(;e;){a||(c=""),a=!1;let l;if(this.options.extensions?.inline?.some(u=>(l=u.call({lexer:this},e,s))?(e=e.substring(l.raw.length),s.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let u=s.at(-1);l.type==="text"&&u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.del(e,o,c)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),s.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),s.push(l);continue}let p=e;if(this.options.extensions?.startInline){let u=1/0,m=e.slice(1),y;this.options.extensions.startInline.forEach(C=>{y=C.call({lexer:this},m),typeof y=="number"&&y>=0&&(u=Math.min(u,y))}),u<1/0&&u>=0&&(p=e.substring(0,u+1))}if(l=this.tokenizer.inlineText(p)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(c=l.raw.slice(-1)),a=!0;let u=s.at(-1);u?.type==="text"?(u.raw+=l.raw,u.text+=l.text):s.push(l);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return s}},Qe=class{options;parser;constructor(t){this.options=t||$e}space(t){return""}code({text:t,lang:e,escaped:s}){let o=(e||"").match(J.notSpaceStart)?.[0],n=t.replace(J.endingNewline,"")+`
|
|
67
|
+
`;return o?'<pre><code class="language-'+ue(o)+'">'+(s?n:ue(n,!0))+`</code></pre>
|
|
68
|
+
`:"<pre><code>"+(s?n:ue(n,!0))+`</code></pre>
|
|
69
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
70
|
+
${this.parser.parse(t)}</blockquote>
|
|
71
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
72
|
+
`}hr(t){return`<hr>
|
|
73
|
+
`}list(t){let e=t.ordered,s=t.start,o="";for(let a=0;a<t.items.length;a++){let c=t.items[a];o+=this.listitem(c)}let n=e?"ol":"ul",i=e&&s!==1?' start="'+s+'"':"";return"<"+n+i+`>
|
|
74
|
+
`+o+"</"+n+`>
|
|
75
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
76
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
77
|
+
`}table(t){let e="",s="";for(let n=0;n<t.header.length;n++)s+=this.tablecell(t.header[n]);e+=this.tablerow({text:s});let o="";for(let n=0;n<t.rows.length;n++){let i=t.rows[n];s="";for(let a=0;a<i.length;a++)s+=this.tablecell(i[a]);o+=this.tablerow({text:s})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
78
|
+
<thead>
|
|
79
|
+
`+e+`</thead>
|
|
80
|
+
`+o+`</table>
|
|
81
|
+
`}tablerow({text:t}){return`<tr>
|
|
82
|
+
${t}</tr>
|
|
83
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+e+`</${s}>
|
|
84
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${ue(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:s}){let o=this.parser.parseInline(s),n=jt(t);if(n===null)return o;t=n;let i='<a href="'+t+'"';return e&&(i+=' title="'+ue(e)+'"'),i+=">"+o+"</a>",i}image({href:t,title:e,text:s,tokens:o}){o&&(s=this.parser.parseInline(o,this.parser.textRenderer));let n=jt(t);if(n===null)return ue(s);t=n;let i=`<img src="${t}" alt="${ue(s)}"`;return e&&(i+=` title="${ue(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ue(t.text)}},bt=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},ie=class at{options;renderer;textRenderer;constructor(e){this.options=e||$e,this.options.renderer=this.options.renderer||new Qe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bt}static parse(e,s){return new at(s).parse(e)}static parseInline(e,s){return new at(s).parseInline(e)}parse(e){let s="";for(let o=0;o<e.length;o++){let n=e[o];if(this.options.extensions?.renderers?.[n.type]){let a=n,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){s+=c||"";continue}}let i=n;switch(i.type){case"space":{s+=this.renderer.space(i);break}case"hr":{s+=this.renderer.hr(i);break}case"heading":{s+=this.renderer.heading(i);break}case"code":{s+=this.renderer.code(i);break}case"table":{s+=this.renderer.table(i);break}case"blockquote":{s+=this.renderer.blockquote(i);break}case"list":{s+=this.renderer.list(i);break}case"checkbox":{s+=this.renderer.checkbox(i);break}case"html":{s+=this.renderer.html(i);break}case"def":{s+=this.renderer.def(i);break}case"paragraph":{s+=this.renderer.paragraph(i);break}case"text":{s+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,s=this.renderer){let o="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){o+=c||"";continue}}let a=i;switch(a.type){case"escape":{o+=s.text(a);break}case"html":{o+=s.html(a);break}case"link":{o+=s.link(a);break}case"image":{o+=s.image(a);break}case"checkbox":{o+=s.checkbox(a);break}case"strong":{o+=s.strong(a);break}case"em":{o+=s.em(a);break}case"codespan":{o+=s.codespan(a);break}case"br":{o+=s.br(a);break}case"del":{o+=s.del(a);break}case"text":{o+=s.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return o}},ze=class{options;block;constructor(t){this.options=t||$e}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?re.lex:re.lexInline}provideParser(){return this.block?ie.parse:ie.parseInline}},ms=class{defaults=ut();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ie;Renderer=Qe;TextRenderer=bt;Lexer=re;Tokenizer=Ke;Hooks=ze;constructor(...t){this.use(...t)}walkTokens(t,e){let s=[];for(let o of t)switch(s=s.concat(e.call(this,o)),o.type){case"table":{let n=o;for(let i of n.header)s=s.concat(this.walkTokens(i.tokens,e));for(let i of n.rows)for(let a of i)s=s.concat(this.walkTokens(a.tokens,e));break}case"list":{let n=o;s=s.concat(this.walkTokens(n.items,e));break}default:{let n=o;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(i=>{let a=n[i].flat(1/0);s=s.concat(this.walkTokens(a,e))}):n.tokens&&(s=s.concat(this.walkTokens(n.tokens,e)))}}return s}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let o={...s};if(o.async=this.defaults.async||o.async||!1,s.extensions&&(s.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[n.level];i?i.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),o.extensions=e),s.renderer){let n=this.defaults.renderer||new Qe(this.defaults);for(let i in s.renderer){if(!(i in n))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,c=s.renderer[a],l=n[a];n[a]=(...p)=>{let u=c.apply(n,p);return u===!1&&(u=l.apply(n,p)),u||""}}o.renderer=n}if(s.tokenizer){let n=this.defaults.tokenizer||new Ke(this.defaults);for(let i in s.tokenizer){if(!(i in n))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,c=s.tokenizer[a],l=n[a];n[a]=(...p)=>{let u=c.apply(n,p);return u===!1&&(u=l.apply(n,p)),u}}o.tokenizer=n}if(s.hooks){let n=this.defaults.hooks||new ze;for(let i in s.hooks){if(!(i in n))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,c=s.hooks[a],l=n[a];ze.passThroughHooks.has(i)?n[a]=p=>{if(this.defaults.async&&ze.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await c.call(n,p);return l.call(n,m)})();let u=c.call(n,p);return l.call(n,u)}:n[a]=(...p)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(n,p);return m===!1&&(m=await l.apply(n,p)),m})();let u=c.apply(n,p);return u===!1&&(u=l.apply(n,p)),u}}o.hooks=n}if(s.walkTokens){let n=this.defaults.walkTokens,i=s.walkTokens;o.walkTokens=function(a){let c=[];return c.push(i.call(this,a)),n&&(c=c.concat(n.call(this,a))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return re.lex(t,e??this.defaults)}parser(t,e){return ie.parse(t,e??this.defaults)}parseMarkdown(t){return(e,s)=>{let o={...s},n={...this.defaults,...o},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let a=n.hooks?await n.hooks.preprocess(e):e,c=await(n.hooks?await n.hooks.provideLexer():t?re.lex:re.lexInline)(a,n),l=n.hooks?await n.hooks.processAllTokens(c):c;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let p=await(n.hooks?await n.hooks.provideParser():t?ie.parse:ie.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(p):p})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let a=(n.hooks?n.hooks.provideLexer():t?re.lex:re.lexInline)(e,n);n.hooks&&(a=n.hooks.processAllTokens(a)),n.walkTokens&&this.walkTokens(a,n.walkTokens);let c=(n.hooks?n.hooks.provideParser():t?ie.parse:ie.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(t,e){return s=>{if(s.message+=`
|
|
85
|
+
Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+ue(s.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(s);throw s}}},we=new ms;function F(t,e){return we.parse(t,e)}F.options=F.setOptions=function(t){return we.setOptions(t),F.defaults=we.defaults,ss(F.defaults),F};F.getDefaults=ut;F.defaults=$e;F.use=function(...t){return we.use(...t),F.defaults=we.defaults,ss(F.defaults),F};F.walkTokens=function(t,e){return we.walkTokens(t,e)};F.parseInline=we.parseInline;F.Parser=ie;F.parser=ie.parse;F.Renderer=Qe;F.TextRenderer=bt;F.Lexer=re;F.lexer=re.lex;F.Tokenizer=Ke;F.Hooks=ze;F.parse=F;F.options;F.setOptions;F.use;F.walkTokens;F.parseInline;ie.parse;re.lex;const wo=new ms({breaks:!0,gfm:!0});function $o(t){return t?wo.parse(t):""}const So={key:0,class:"my-2"},_o={key:0,class:"relative inline-flex h-4 w-4 items-center justify-center"},Co={key:1,class:"text-text-muted"},To={key:0,class:"mt-1 ms-2 rounded-lg border-s-2 border-[#a78bfa]/30 bg-surface px-4 py-3 text-sm text-text-secondary leading-relaxed whitespace-pre-wrap max-h-80 overflow-auto"},Mo={key:0,class:"inline-flex items-center gap-0.5 ms-1 align-text-bottom"},Ro=se({__name:"InlineThinkingBlock",props:{isThinking:{type:Boolean},content:{},completed:{type:Boolean}},setup(t){const e=A(!1);return(s,o)=>t.isThinking||t.completed&&t.content?(h(),g("div",So,[r("button",{class:E(["flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-colors",t.isThinking?"bg-[#a78bfa]/10 text-[#a78bfa]":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:o[0]||(o[0]=n=>e.value=!e.value)},[t.isThinking?(h(),g("span",_o,[...o[1]||(o[1]=[r("span",{class:"absolute h-full w-full rounded-full border-2 border-[#a78bfa]/30"},null,-1),r("span",{class:"absolute h-full w-full rounded-full border-2 border-transparent border-t-[#a78bfa]",style:{animation:"thinking-orbit 1s linear infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-[#a78bfa]"},null,-1)])])):(h(),g("span",Co,"💭")),r("span",null,d(t.isThinking?"Thinking...":"Thought process"),1),r("span",{class:E(["text-text-muted transition-transform",{"rotate-180":e.value}])},"▾",2)],2),e.value?(h(),g("div",To,[Te(d(t.content)+" ",1),t.isThinking?(h(),g("span",Mo,[...o[2]||(o[2]=[r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1 w-1 rounded-full bg-[#a78bfa]",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):N("",!0)])):N("",!0)])):N("",!0)}}),Ao={class:"text-sm leading-relaxed text-text-primary"},No=se({__name:"AssistantTokenStream",props:{sessionId:{}},setup(t){const e=t,s=Kt(),{getColor:o}=Ws(Ps(e,"sessionId")),n=B(()=>s.getTokens(e.sessionId)),i=B(()=>{const a=n.value,c=[];let l=!1,p="";for(const u of a){if(p+=u.text,!l&&p.includes("<think>")){l=!0;const m=p.split("<think>")[0]??"";m&&c.length===0&&c.push({...u,text:m});continue}if(l){if(p.includes("</think>")){l=!1;const m=p.split("</think>").pop()??"",y=u.text;if(m.endsWith(y)&&y.includes("</think>")){const C=y.split("</think>").pop()??"";C&&c.push({...u,text:C})}}continue}c.push(u)}return c});return(a,c)=>(h(),g("div",Ao,[(h(!0),g(U,null,Q(i.value,l=>(h(),g("span",{key:l.id,class:"inline",style:Is({borderBottom:`2px solid ${x(o)(l.confidence)}`})},d(l.text),5))),128))]))}}),zo={key:0,class:"mb-1.5 space-y-1.5"},Eo=["src","alt","onClick"],Io={class:"mt-0.5 flex items-center gap-1.5 text-[10px] opacity-60"},Po={class:"truncate"},Do={class:"flex flex-wrap gap-1.5"},jo={class:"max-w-[100px] truncate opacity-90"},Bo={class:"opacity-60"},Lo=["src"],Fo=se({__name:"AttachmentBubble",props:{attachments:{}},setup(t){const e=A(null);function s(n){n.content&&(e.value=n.content)}function o(){e.value=null}return(n,i)=>t.attachments.length>0?(h(),g("div",zo,[(h(!0),g(U,null,Q(t.attachments.filter(a=>a.type==="image"&&a.content),a=>(h(),g("div",{key:a.id},[r("img",{src:a.content,alt:a.name,class:"max-h-48 max-w-full cursor-pointer rounded-lg object-contain",onClick:c=>s(a)},null,8,Eo),r("div",Io,[r("span",Po,d(a.name),1),r("span",null,d(x(st)(a.sizeBytes)),1)])]))),128)),r("div",Do,[(h(!0),g(U,null,Q(t.attachments.filter(a=>a.type==="document"),a=>(h(),g("div",{key:a.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[D(x(Xt),{class:"h-3.5 w-3.5 opacity-70"}),r("span",jo,d(a.name),1),r("span",Bo,d(x(st)(a.sizeBytes)),1)]))),128))]),(h(),Ee(Ds,{to:"body"},[D(Ut,{"enter-active-class":"transition-opacity duration-150","enter-from-class":"opacity-0","leave-active-class":"transition-opacity duration-150","leave-to-class":"opacity-0"},{default:qt(()=>[e.value?(h(),g("div",{key:0,class:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:o},[r("img",{src:e.value,class:"max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl",onClick:i[0]||(i[0]=He(()=>{},["stop"]))},null,8,Lo),r("button",{class:"absolute right-4 top-4 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",onClick:o},[D(x(Je),{class:"h-5 w-5"})])])):N("",!0)]),_:1})]))])):N("",!0)}}),Oo={key:0,class:"mt-1 flex items-center gap-1 flex-wrap"},qo=["title"],Uo=se({__name:"QualityBadges",props:{report:{}},setup(t){const e=t,s=B(()=>e.report?e.report.checks.filter(n=>n.status!=="pass"):[]),o=B(()=>s.value.length>0);return(n,i)=>o.value?(h(),g("div",Oo,[(h(!0),g(U,null,Q(s.value,a=>(h(),g("span",{key:a.detector,class:E(["inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium",a.status==="fail"?"bg-error/15 text-error":"bg-warning/15 text-warning"]),title:a.detail??n.$t(a.reason)},d(n.$t(`quality.${a.detector}.label`)),11,qo))),128))])):N("",!0)}}),Vo={class:"text-sm leading-relaxed whitespace-pre-wrap"},Ho=["innerHTML"],Go={key:3,class:"inline-flex items-center gap-1 py-1"},Wo={key:4,class:"mt-1 text-[10px] text-warning"},Zo={key:2,class:"mt-1.5 flex items-center gap-2 text-[10px] text-text-muted"},Ko=["title"],Qo={class:"text-[10px] opacity-50"},Jo=se({__name:"ChatBubble",props:{message:{}},setup(t){const e=t,s=Xe(),o=Qs(),n=it(),i=ts(),a=B(()=>i.getReport(e.message.id)),c=B(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),l=B(()=>e.message.sessionId?s.sessionById(e.message.sessionId)?.doneReason==="length":!1),p=B(()=>e.message.sessionId?o.getThinking(e.message.sessionId):{isThinking:!1,content:""}),u=B(()=>e.message.role==="user"),m=B(()=>{if(u.value){if(e.message.attachments?.length){const k=`
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
`,z=e.message.content.lastIndexOf(k);if(z!==-1)return e.message.content.slice(z+k.length)}return e.message.content}return e.message.isStreaming?"":e.message.content.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}),y=B(()=>u.value||!m.value?"":$o(m.value)),C=B(()=>new Date(e.message.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}));return(k,z)=>(h(),g("div",{class:E(["flex w-full",u.value?"justify-end":"justify-start"])},[r("div",{class:E(["max-w-[80%] rounded-2xl px-4 py-2.5",u.value?"bg-accent text-white rounded-br-md":"bg-surface-raised border border-border-default rounded-bl-md"])},[u.value?(h(),g(U,{key:0},[t.message.attachments?.length?(h(),Ee(Fo,{key:0,attachments:t.message.attachments},null,8,["attachments"])):N("",!0),r("p",Vo,d(m.value),1)],64)):(h(),g(U,{key:1},[t.message.sessionId?(h(),Ee(Ro,{key:0,"is-thinking":p.value.isThinking,content:p.value.content,completed:!t.message.isStreaming},null,8,["is-thinking","content","completed"])):N("",!0),t.message.isStreaming&&t.message.sessionId?(h(),Ee(No,{key:1,"session-id":t.message.sessionId},null,8,["session-id"])):m.value?(h(),g("div",{key:2,class:"markdown-prose",innerHTML:y.value},null,8,Ho)):N("",!0),t.message.isStreaming&&!m.value?(h(),g("span",Go,[...z[0]||(z[0]=[r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.2s infinite"}},null,-1),r("span",{class:"h-1.5 w-1.5 rounded-full bg-accent",style:{animation:"typing-bounce 1.2s ease-in-out 0.4s infinite"}},null,-1)])])):N("",!0),l.value&&!t.message.isStreaming&&!a.value?(h(),g("div",Wo,d(k.$t("dashboard.bubble.truncatedWarning")),1)):N("",!0)],64)),!u.value&&!t.message.isStreaming&&c.value?(h(),g("div",Zo,[r("span",null,d(c.value.completionTokenCount)+" "+d(k.$t("dashboard.bubble.tokens")),1),z[1]||(z[1]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,d(c.value.tokensPerSecond.toFixed(1))+" "+d(k.$t("dashboard.bubble.tokPerSec")),1),z[2]||(z[2]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,d(c.value.ttftMs<1e3?c.value.ttftMs.toFixed(0)+"ms":(c.value.ttftMs/1e3).toFixed(1)+"s")+" "+d(k.$t("dashboard.bubble.ttft")),1),a.value&&a.value.overall!=="pass"?(h(),g("span",{key:0,class:E(["ml-1 inline-block h-1.5 w-1.5 rounded-full",a.value.overall==="fail"?"bg-error":"bg-warning"]),title:k.$t("quality.issuesDetected")},null,10,Ko)):N("",!0)])):N("",!0),D(Uo,{report:a.value},null,8,["report"]),r("div",{class:E(["mt-1",u.value?"text-end":""])},[r("span",Qo,d(C.value),1)],2)],2)],2))}}),Xo={key:0,class:"flex items-center justify-center"},Yo={class:"text-center"},ea={class:"text-sm text-text-muted"},ta=se({__name:"ChatMessageList",props:{messages:{}},setup(t,{expose:e}){const s=t,o=A(null);function n(){js(()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight)})}return te(()=>s.messages.length,()=>n()),te(()=>s.messages[s.messages.length-1]?.content,()=>n()),e({scrollToBottom:n}),(i,a)=>(h(),g("div",{ref_key:"containerRef",ref:o,class:"flex-1 overflow-y-auto px-4 py-6"},[r("div",{class:E(["mx-auto max-w-3xl space-y-4",t.messages.length===0?"flex min-h-full flex-col justify-center":""])},[t.messages.length===0?(h(),g("div",Xo,[r("div",Yo,[a[0]||(a[0]=r("svg",{class:"mx-auto mb-4 h-20 w-20 text-text-muted/20",viewBox:"0 0 297.5 297.5"},[r("path",{fill:"currentColor",d:"M179.293,23.839c-64.904,0-117.707,52.804-117.707,117.707c0,1.832,0.056,3.651,0.14,5.463H9.933 c-5.486,0-9.933,4.448-9.933,9.933v46.189c0,5.486,4.448,9.933,9.933,9.933h22.349v43.209h-6.953c-4.663,0-8.443,3.78-8.443,8.443 c0,4.663,3.78,8.443,8.443,8.443h30.793c4.663,0,8.443-3.78,8.443-8.443c0-4.663-3.78-8.443-8.443-8.443h-6.953v-43.209h36.713 c21.533,28.059,55.39,46.189,93.411,46.189c64.904,0,117.707-52.804,117.707-117.707S244.196,23.839,179.293,23.839z M19.866,166.876h213.087c-5.257,11.091-13.854,20.295-24.483,26.323H19.866V166.876z M119.942,141.547 c0-32.726,26.624-59.35,59.35-59.35s59.35,26.624,59.35,59.35c0,1.843-0.096,3.663-0.261,5.463H120.206 C120.04,145.21,119.942,143.39,119.942,141.547z M179.293,239.388c-25.75,0-49.202-10.003-66.689-26.323h32.684 c10.31,4.925,21.837,7.698,34.005,7.698c43.68,0,79.217-35.536,79.217-79.217S222.973,62.33,179.293,62.33 s-79.217,35.536-79.217,79.217c0,1.839,0.086,3.657,0.214,5.463H81.611c-0.101-1.809-0.16-3.629-0.16-5.463 c0-48.871,36.016-89.488,82.901-96.702c-0.758,1.266-1.201,2.741-1.201,4.324c0,4.663,3.78,8.443,8.443,8.443h15.396 c4.663,0,8.443-3.78,8.443-8.443c0-1.583-0.443-3.058-1.201-4.324c46.884,7.214,82.901,47.83,82.901,96.702 C277.134,195.497,233.243,239.388,179.293,239.388z"})],-1)),a[1]||(a[1]=r("p",{class:"text-2xl font-semibold text-text-primary mb-2"},"LLMxRay",-1)),r("p",ea,d(i.$t("dashboard.empty.startConversation")),1)])])):N("",!0),(h(!0),g(U,null,Q(t.messages,c=>(h(),Ee(Jo,{key:c.id,message:c},null,8,["message"]))),128))],2)],512))}}),sa=new Set(["png","jpg","jpeg","gif","webp"]),na=new Set(["pdf","docx","txt","md","csv"]);function gs(t){return t.split(".").pop()?.toLowerCase()??""}function rt(t){return sa.has(gs(t))}function fs(t){return na.has(gs(t))}function oa(t){return rt(t)||fs(t)}const aa=".pdf,.docx,.txt,.md,.csv,.png,.jpg,.jpeg,.gif,.webp",Ft=8e3;function ra(){const t=A([]),e=B(()=>t.value.some(c=>c.status==="parsing"));async function s(c){for(const l of c){if(!oa(l.name))continue;const p={id:be(),name:l.name,type:rt(l.name)?"image":"document",mimeType:l.type,sizeBytes:l.size,status:"pending"};t.value.push(p),rt(l.name)?o(l,p):fs(l.name)&&n(l,p)}}function o(c,l){l.status="parsing";const p=l.id,u=new FileReader;u.onload=()=>{const m=t.value.find(y=>y.id===p);m&&(m.content=u.result,m.status="ready")},u.onerror=()=>{const m=t.value.find(y=>y.id===p);m&&(m.error="Failed to read image",m.status="error")},u.readAsDataURL(c)}async function n(c,l){l.status="parsing";const p=l.id;try{const u=Xs(c.name);if(!u){const C=t.value.find(k=>k.id===p);C&&(C.error="Unsupported format",C.status="error");return}let m=await Ys(c,u);m.length>Ft&&(m=m.slice(0,Ft)+`
|
|
90
|
+
|
|
91
|
+
[... truncated]`);const y=t.value.find(C=>C.id===p);y&&(y.content=m,y.status="ready")}catch(u){const m=t.value.find(y=>y.id===p);m&&(m.error=u instanceof Error?u.message:"Parse failed",m.status="error")}}function i(c){t.value=t.value.filter(l=>l.id!==c)}function a(){t.value=[]}return{attachments:t,isProcessing:e,addFiles:s,removeAttachment:i,clearAttachments:a}}const ia={key:0,class:"absolute bottom-full left-0 right-0 mb-2 max-h-64 overflow-y-auto rounded-xl border border-border-default bg-surface-raised shadow-lg"},la={class:"p-1.5"},ca=["onMouseenter","onClick"],ua={class:"shrink-0 font-mono text-xs text-accent"},da={class:"truncate text-xs text-text-muted"},pa={class:"ms-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 text-[10px] text-text-muted"},ha=se({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(t,{expose:e,emit:s}){const{t:o}=Vt(),n=t,i=s,a=A(0),c=B(()=>{if(!n.visible)return[];const u=n.filter.replace(/^\//,"");return u?bn(u):Object.values(Yt()).flat()});te(()=>n.filter,()=>{a.value=0});function l(u){return!n.visible||c.value.length===0?!1:u.key==="ArrowDown"?(u.preventDefault(),a.value=(a.value+1)%c.value.length,!0):u.key==="ArrowUp"?(u.preventDefault(),a.value=a.value<=0?c.value.length-1:a.value-1,!0):u.key==="Tab"||u.key==="Enter"&&c.value.length>0?(u.preventDefault(),i("select",c.value[a.value]),!0):u.key==="Escape"?(u.preventDefault(),i("close"),!0):!1}e({handleKeydown:l});const p=B(()=>({chat:o("dashboard.slashCommands.chatConversation"),settings:o("dashboard.slashCommands.modelSettings"),navigation:o("dashboard.slashCommands.featuresNavigation")}));return(u,m)=>t.visible&&c.value.length>0?(h(),g("div",ia,[r("div",la,[(h(!0),g(U,null,Q(c.value,(y,C)=>(h(),g("button",{key:y.name,class:E(["flex w-full items-center gap-3 rounded-lg px-3 py-2 text-start text-sm transition-colors",C===a.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMouseenter:k=>a.value=C,onClick:k=>u.$emit("select",y)},[r("span",ua,"/"+d(y.name),1),r("span",da,d(y.description),1),r("span",pa,d(p.value[y.category]??y.category),1)],42,ca))),128))])])):N("",!0)}}),ma={key:0,class:"flex flex-wrap gap-2 px-2.5 pb-1.5 pt-1"},ga=["src","alt"],fa={key:1,class:"text-text-muted"},xa={class:"max-w-[120px] truncate text-text-primary"},ba={class:"text-text-muted"},va={key:2,class:"h-3 w-3 animate-spin rounded-full border-2 border-accent border-t-transparent"},ya={key:3,class:"text-error",title:"Parse error"},ka=["onClick"],wa=se({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(t){return(e,s)=>t.attachments.length>0?(h(),g("div",ma,[(h(!0),g(U,null,Q(t.attachments,o=>(h(),g("div",{key:o.id,class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface-overlay px-2.5 py-1.5 text-xs"},[o.type==="image"&&o.content?(h(),g("img",{key:0,src:o.content,alt:o.name,class:"h-6 w-6 rounded object-cover"},null,8,ga)):o.type==="document"?(h(),g("span",fa,[D(x(Xt),{class:"h-4 w-4"})])):N("",!0),r("span",xa,d(o.name),1),r("span",ba,d(x(st)(o.sizeBytes)),1),o.status==="parsing"?(h(),g("span",va)):o.status==="error"?(h(),g("span",ya,"!")):N("",!0),r("button",{class:"text-text-muted hover:text-error transition-colors",onClick:n=>e.$emit("remove",o.id)},[D(x(Je),{class:"h-3.5 w-3.5"})],8,ka)]))),128))])):N("",!0)}}),$a={key:0,class:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-accent bg-accent/5"},Sa={class:"text-sm text-accent"},_a={class:"relative mx-auto max-w-3xl"},Ca=["accept"],Ta={class:"mx-auto flex max-w-3xl flex-col rounded-xl border border-border-default bg-surface transition-colors focus-within:border-accent"},Ma=["disabled","title"],Ra=["title"],Aa=["disabled","title"],Na=["disabled","placeholder"],za=["title"],Ea=["disabled","title"],Ia=se({__name:"ChatInput",props:{isStreaming:{type:Boolean},selectedModel:{},isVisionModel:{type:Boolean}},emits:["send","command","cancel"],setup(t,{expose:e,emit:s}){const o=s;e({focus:H});const n=lt(),i=A(""),a=A(null),c=A(null),l=A(null),p=A(!1),{attachments:u,isProcessing:m,addFiles:y,removeAttachment:C,clearAttachments:k}=ra();Ht(()=>{n.fetchModels()});const z=B(()=>{const T=i.value;return T.startsWith("/")&&!T.includes(`
|
|
92
|
+
`)}),b=B(()=>{if(!z.value)return"";const T=i.value.indexOf(" ");return T===-1?i.value:i.value.slice(0,T)}),I=B(()=>{const T=i.value.trim().length>0,j=u.value.length>0;return(T||j)&&!m.value});function H(){a.value?.focus()}function V(T){z.value&&l.value&&l.value.handleKeydown(T)||T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),G())}function K(T){i.value=`/${T.name} `,a.value?.focus()}function G(){const T=i.value.trim();if(!(!T&&u.value.length===0)){if(T.startsWith("/")&&u.value.length===0){const j=T.indexOf(" "),le=j===-1?T.slice(1):T.slice(1,j),q=j===-1?"":T.slice(j+1);o("command",le,q)}else o("send",T,[...u.value]),k();i.value="",a.value&&(a.value.style.height="auto")}}function O(T){const j=T.target;j.style.height="auto",j.style.height=Math.min(j.scrollHeight,200)+"px"}function he(){i.value=""}function ne(){i.value="/",a.value?.focus()}function ve(){c.value?.click()}function me(T){const j=T.target;j.files&&j.files.length>0&&(y(j.files),j.value="")}function ge(T){T.preventDefault(),p.value=!0}function f(){p.value=!1}function _(T){T.preventDefault(),p.value=!1,T.dataTransfer?.files&&T.dataTransfer.files.length>0&&y(T.dataTransfer.files)}function w(T){const j=T.clipboardData?.items;if(!j)return;const le=[];for(const q of j)if(q.type.startsWith("image/")){const fe=q.getAsFile();fe&&le.push(fe)}le.length>0&&(T.preventDefault(),y(le))}return(T,j)=>(h(),g("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:ge,onDragleave:f,onDrop:_},[p.value?(h(),g("div",$a,[r("span",Sa,d(T.$t("dashboard.dropZone")),1)])):N("",!0),r("div",_a,[D(ha,{ref_key:"dropdownRef",ref:l,filter:b.value,visible:z.value,onSelect:K,onClose:he},null,8,["filter","visible"])]),r("input",{ref_key:"fileInputRef",ref:c,type:"file",multiple:"",accept:x(aa),class:"hidden",onChange:me},null,40,Ca),r("div",Ta,[D(wa,{attachments:x(u),onRemove:x(C)},null,8,["attachments","onRemove"]),r("div",{class:E(["flex items-end gap-2 p-1.5",{"pt-0":x(u).length>0}])},[r("button",{disabled:t.isStreaming,class:"relative flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:t.isVisionModel?T.$t("dashboard.input.attachFilesVision"):T.$t("dashboard.input.attachFiles"),onClick:ve},[D(x(sn),{class:"h-4 w-4"}),t.isVisionModel?(h(),g("span",{key:0,class:"absolute -right-0.5 -top-0.5 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-success text-[8px] text-white",title:T.$t("dashboard.input.visionBadge")},[D(x(Bs),{class:"h-2.5 w-2.5","stroke-width":3})],8,Ra)):N("",!0)],8,Ma),r("button",{disabled:t.isStreaming,class:"flex h-8 shrink-0 items-center justify-center rounded-lg px-1.5 text-text-muted transition-colors hover:bg-surface-overlay hover:text-text-primary disabled:opacity-30",title:T.$t("dashboard.input.commands"),onClick:ne},[D(x(on),{class:"h-4 w-4"})],8,Aa),W(r("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":j[0]||(j[0]=le=>i.value=le),disabled:t.isStreaming,rows:"1",class:"flex-1 resize-none bg-transparent px-1 py-1 text-sm text-text-primary placeholder-text-muted outline-none disabled:opacity-50",placeholder:t.isVisionModel?T.$t("dashboard.input.placeholderVision"):T.$t("dashboard.input.placeholder"),onKeydown:V,onInput:O,onPaste:w},null,40,Na),[[X,i.value]]),t.isStreaming?(h(),g("button",{key:0,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-error text-white transition-colors hover:bg-error/80",title:T.$t("dashboard.input.stopGenerating"),onClick:j[1]||(j[1]=le=>T.$emit("cancel"))},[...j[2]||(j[2]=[r("span",{class:"inline-block h-2.5 w-2.5 rounded-sm bg-white"},null,-1)])],8,za)):(h(),g("button",{key:1,disabled:!I.value||!t.selectedModel,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-accent text-white transition-colors hover:bg-accent-hover disabled:opacity-30 disabled:cursor-not-allowed",title:T.$t("dashboard.input.sendMessage"),onClick:G},[D(x(nn),{class:"h-4 w-4 rtl:-scale-x-100"})],8,Ea))],2)])],32))}}),Pa={class:"flex h-full flex-col overflow-y-auto"},Da={class:"space-y-5 p-4 pb-12"},ja={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Ba=["placeholder"],La={class:"mt-1 text-[10px] text-text-muted"},Fa={class:"flex items-center justify-between"},Oa={class:"flex items-center gap-2"},qa={class:"text-xs font-medium text-text-secondary"},Ua=["disabled"],Va={key:0,class:"text-[10px] text-text-muted -mt-3"},Ha={key:1,class:"text-[10px] text-text-muted -mt-3"},Ga={class:"mb-1.5 flex items-center justify-between"},Wa={class:"text-xs font-medium text-text-secondary"},Za={class:"text-xs text-text-muted"},Ka={class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},Qa={class:"mb-1.5 flex items-center justify-between"},Ja={class:"text-xs font-medium text-text-secondary"},Xa={class:"text-xs text-text-muted"},Ya=["placeholder"],er={class:"mt-1 text-[10px] text-text-muted"},tr={class:"mb-1.5 flex items-center justify-between"},sr={class:"text-xs font-medium text-text-secondary"},nr={class:"text-xs text-text-muted"},or={class:"mt-1 text-[10px] text-text-muted"},ar={key:2,class:"space-y-4 ps-1"},rr={class:"mb-1.5 flex items-center justify-between"},ir={class:"text-xs font-medium text-text-secondary"},lr={class:"text-xs text-text-muted"},cr={class:"mt-1 text-[10px] text-text-muted"},ur={class:"mb-1.5 flex items-center justify-between"},dr={class:"text-xs font-medium text-text-secondary"},pr={class:"text-xs text-text-muted"},hr={class:"mt-1 text-[10px] text-text-muted"},mr={class:"mb-1.5 flex items-center justify-between"},gr={class:"text-xs font-medium text-text-secondary"},fr={class:"text-xs text-text-muted"},xr={class:"mt-1 text-[10px] text-text-muted"},br={class:"mb-1.5 flex items-center justify-between"},vr={class:"text-xs font-medium text-text-secondary"},yr={class:"text-xs text-text-muted"},kr={value:0},wr={value:1},$r={value:2},Sr={class:"mt-1 text-[10px] text-text-muted"},_r={class:"mb-1.5 flex items-center justify-between"},Cr={class:"text-xs font-medium text-text-secondary"},Tr={class:"text-xs text-text-muted"},Mr=["placeholder"],Rr={class:"mt-1 text-[10px] text-text-muted"},Ar={class:"mb-1.5 block text-xs font-medium text-text-secondary"},Nr=["placeholder"],zr={class:"mt-1 text-[10px] text-text-muted"},Er={key:0,class:"ms-1 text-accent"},Ir={key:0,class:"ps-1 space-y-2"},Pr={key:0,class:"space-y-1"},Dr=["onClick"],jr={key:1,class:"text-[10px] text-text-muted px-2"},Br={key:0,class:"ms-1 text-accent"},Lr={key:4,class:"space-y-4 ps-1"},Fr={class:"flex items-center justify-between"},Or={class:"text-xs font-medium text-text-secondary"},qr={class:"text-[10px] text-text-muted"},Ur={key:0},Vr={class:"mb-1 flex items-center justify-between"},Hr={class:"text-[10px] text-text-muted"},Gr={class:"text-[10px] text-text-muted"},Wr={class:"flex items-center justify-between"},Zr={class:"text-xs font-medium text-text-secondary"},Kr={class:"text-[10px] text-text-muted"},Qr={key:1},Jr={class:"mb-1 flex items-center justify-between"},Xr={class:"text-[10px] text-text-muted"},Yr={class:"text-[10px] text-text-muted"},ei={class:"flex items-center justify-between"},ti={class:"text-xs font-medium text-text-secondary"},si={class:"text-[10px] text-text-muted"},ni={key:2,class:"space-y-1"},oi={class:"flex-1 text-text-secondary"},ai=["onClick"],ri={class:"flex items-center justify-between"},ii={class:"text-xs font-medium text-text-secondary"},li={class:"text-[10px] text-text-muted"},ci={key:3,class:"space-y-2"},ui={class:"mb-1 block text-[10px] text-text-muted"},di={value:"",disabled:""},pi=["value"],hi={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},mi={class:"mb-2 text-[10px] text-accent"},gi={class:"space-y-1.5"},fi={class:"min-w-0 flex-1"},xi={class:"truncate text-[11px] font-mono text-text-primary"},bi={class:"text-[9px] text-text-muted"},vi=["disabled","onClick"],yi={key:0,class:"mt-2 text-[9px] text-text-muted"},ki={class:"mb-1 flex items-center justify-between"},wi={class:"text-[10px] text-text-muted"},$i={class:"text-[10px] text-text-muted"},Si=se({__name:"ChatSettingsPanel",props:{modelValue:{},selectedModel:{},ragEnabled:{type:Boolean}},emits:["update:modelValue","update:ragEnabled"],setup(t,{emit:e}){const s=t,o=e,n=A(s.modelValue.systemPrompt),i=A(s.modelValue.options.temperature??.7),a=A(s.modelValue.options.num_predict??-1),c=A(s.modelValue.options.num_ctx??4096),l=A(s.modelValue.options.top_p??.9),p=A(s.modelValue.options.top_k??40),u=A(s.modelValue.options.repeat_penalty??1.1),m=A(s.modelValue.options.seed??-1),y=A(s.modelValue.options.stop?.join(", ")??""),C=A(s.modelValue.options.mirostat??0);te(()=>s.modelValue.options,f=>{i.value=f.temperature??.7,a.value=f.num_predict??-1,c.value=f.num_ctx??4096,l.value=f.top_p??.9,p.value=f.top_k??40,u.value=f.repeat_penalty??1.1,m.value=f.seed??-1,y.value=f.stop?.join(", ")??"",C.value=f.mirostat??0},{deep:!0}),te([n,i,a,c,l,p,u,m,y,C],()=>{const f=y.value.split(",").map(_=>_.trim()).filter(Boolean);o("update:modelValue",{systemPrompt:n.value,options:{temperature:i.value,num_predict:a.value===-1?void 0:a.value,num_ctx:c.value,top_p:l.value,top_k:p.value,repeat_penalty:u.value,seed:m.value===-1?void 0:m.value,stop:f.length>0?f:void 0,mirostat:C.value}})},{deep:!0}),te(()=>s.modelValue,f=>{n.value=f.systemPrompt,i.value=f.options.temperature??.7,a.value=f.options.num_predict??-1,c.value=f.options.num_ctx??4096,l.value=f.options.top_p??.9,p.value=f.options.top_k??40,u.value=f.options.repeat_penalty??1.1,m.value=f.options.seed??-1,C.value=f.options.mirostat??0});const k=ct(),z=Gt(),b=es(),I=lt(),H=Qt(),V=B(()=>I.supportsTools(s.selectedModel));te(()=>s.selectedModel,f=>{f&&!I.supportsTools(f)&&k.enabledTools.length>0&&k.disableAll()});const K=A(!1),G=A(!1),O=A(!1),he=A(!1),ne=A(""),ve=A(""),me=[{name:"nomic-embed-text",description:"Nomic — 137M params, fast & good",size:"274 MB"},{name:"mxbai-embed-large",description:"mixedbread.ai — 335M params, high quality",size:"670 MB"},{name:"all-minilm",description:"MiniLM — 23M params, very lightweight",size:"46 MB"},{name:"snowflake-arctic-embed",description:"Snowflake — 110M params, balanced",size:"229 MB"}];async function ge(f){he.value=!0,ve.value=f,ne.value="Starting download...";try{await De.pullModel(f,(_,w,T)=>{if(w&&T){const j=Math.round(w/T*100);ne.value=`${_} ${j}%`}else ne.value=_}),ne.value="Done!",await I.fetchModels(),b.settings.ragMemory.embeddingModel=f}catch(_){ne.value=`Failed: ${_ instanceof Error?_.message:"Unknown error"}`}finally{he.value=!1,setTimeout(()=>{ne.value="",ve.value=""},3e3)}}return(f,_)=>(h(),g("div",Pa,[r("div",Da,[r("div",null,[r("label",ja,d(f.$t("dashboard.settings.systemPrompt")),1),W(r("textarea",{"onUpdate:modelValue":_[0]||(_[0]=w=>n.value=w),rows:"6",class:"w-full resize-y rounded-lg border border-border-default bg-surface px-3 py-2 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.systemPromptPlaceholder")},null,8,Ba),[[X,n.value]]),r("p",La,d(f.$t("dashboard.settings.systemPromptHint")),1)]),r("div",Fa,[r("div",Oa,[r("span",qa,d(f.$t("dashboard.settings.knowledgeBase")),1),r("span",{class:E(["rounded-full px-1.5 py-0.5 text-[9px] font-medium",t.ragEnabled&&x(H).readyDocuments.length>0?"bg-accent/10 text-accent":"bg-surface-overlay text-text-muted"])},d(t.ragEnabled&&x(H).readyDocuments.length>0?f.$t("dashboard.settings.kbEnabled"):f.$t("dashboard.settings.kbDisabled")),3)]),r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",t.ragEnabled&&x(H).readyDocuments.length>0?"bg-accent":"bg-surface-overlay"]),disabled:x(H).readyDocuments.length===0,onClick:_[1]||(_[1]=w=>o("update:ragEnabled",!t.ragEnabled))},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",t.ragEnabled&&x(H).readyDocuments.length>0?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,Ua)]),x(H).readyDocuments.length>0?(h(),g("p",Va,[Te(d(x(H).enabledDocuments.length)+"/"+d(x(H).readyDocuments.length)+" "+d(f.$t("dashboard.settings.documents"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:_[2]||(_[2]=w=>x(z).push("/rag"))},d(f.$t("dashboard.settings.manage")),1)])):(h(),g("p",Ha,[Te(d(f.$t("dashboard.settings.noDocumentsIngested"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:_[3]||(_[3]=w=>x(z).push("/rag"))},d(f.$t("dashboard.settings.addDocuments")),1)])),r("div",null,[r("div",Ga,[r("label",Wa,d(f.$t("dashboard.settings.temperature")),1),r("span",Za,d(i.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":_[4]||(_[4]=w=>i.value=w),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[X,i.value,void 0,{number:!0}]]),r("div",Ka,[r("span",null,d(f.$t("dashboard.settings.precise")),1),r("span",null,d(f.$t("dashboard.settings.creative")),1)])]),r("div",null,[r("div",Qa,[r("label",Ja,d(f.$t("dashboard.settings.maxTokens")),1),r("span",Xa,d(a.value===-1?f.$t("dashboard.settings.unlimited"):a.value),1)]),W(r("input",{"onUpdate:modelValue":_[5]||(_[5]=w=>a.value=w),type:"number",min:"-1",max:"32768",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.maxTokensPlaceholder")},null,8,Ya),[[X,a.value,void 0,{number:!0}]]),r("p",er,d(f.$t("dashboard.settings.maxTokensHint")),1)]),r("div",null,[r("div",tr,[r("label",sr,d(f.$t("dashboard.settings.contextWindow")),1),r("span",nr,d(c.value.toLocaleString()),1)]),W(r("select",{"onUpdate:modelValue":_[6]||(_[6]=w=>c.value=w),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[..._[25]||(_[25]=[r("option",{value:2048},"2,048",-1),r("option",{value:4096},"4,096",-1),r("option",{value:8192},"8,192",-1),r("option",{value:16384},"16,384",-1),r("option",{value:32768},"32,768",-1),r("option",{value:65536},"65,536",-1),r("option",{value:131072},"131,072",-1)])],512),[[tt,c.value,void 0,{number:!0}]]),r("p",or,d(f.$t("dashboard.settings.contextWindowHint")),1)]),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[7]||(_[7]=w=>K.value=!K.value)},[r("span",null,d(f.$t("dashboard.settings.advancedSampling")),1),r("span",{class:E(["transition-transform",{"rotate-180":K.value}])},"▾",2)]),K.value?(h(),g("div",ar,[r("div",null,[r("div",rr,[r("label",ir,d(f.$t("dashboard.settings.topP")),1),r("span",lr,d(l.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":_[8]||(_[8]=w=>l.value=w),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[X,l.value,void 0,{number:!0}]]),r("p",cr,d(f.$t("dashboard.settings.topPHint")),1)]),r("div",null,[r("div",ur,[r("label",dr,d(f.$t("dashboard.settings.topK")),1),r("span",pr,d(p.value),1)]),W(r("input",{"onUpdate:modelValue":_[9]||(_[9]=w=>p.value=w),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[X,p.value,void 0,{number:!0}]]),r("p",hr,d(f.$t("dashboard.settings.topKHint")),1)]),r("div",null,[r("div",mr,[r("label",gr,d(f.$t("dashboard.settings.repeatPenalty")),1),r("span",fr,d(u.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":_[10]||(_[10]=w=>u.value=w),type:"range",min:"1.0",max:"2.0",step:"0.05",class:"w-full accent-accent"},null,512),[[X,u.value,void 0,{number:!0}]]),r("p",xr,d(f.$t("dashboard.settings.repeatPenaltyHint")),1)]),r("div",null,[r("div",br,[r("label",vr,d(f.$t("dashboard.settings.mirostat")),1),r("span",yr,d(C.value===0?f.$t("dashboard.settings.mirostatOff"):`v${C.value}`),1)]),W(r("select",{"onUpdate:modelValue":_[11]||(_[11]=w=>C.value=w),class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent"},[r("option",kr,d(f.$t("dashboard.settings.mirostatDisabled")),1),r("option",wr,d(f.$t("dashboard.settings.mirostatV1")),1),r("option",$r,d(f.$t("dashboard.settings.mirostatV2")),1)],512),[[tt,C.value,void 0,{number:!0}]]),r("p",Sr,d(f.$t("dashboard.settings.mirostatHint")),1)]),r("div",null,[r("div",_r,[r("label",Cr,d(f.$t("dashboard.settings.seed")),1),r("span",Tr,d(m.value===-1?f.$t("dashboard.settings.seedRandom"):m.value),1)]),W(r("input",{"onUpdate:modelValue":_[12]||(_[12]=w=>m.value=w),type:"number",min:"-1",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.seedPlaceholder")},null,8,Mr),[[X,m.value,void 0,{number:!0}]]),r("p",Rr,d(f.$t("dashboard.settings.seedHint")),1)]),r("div",null,[r("label",Ar,d(f.$t("dashboard.settings.stopSequences")),1),W(r("input",{"onUpdate:modelValue":_[13]||(_[13]=w=>y.value=w),type:"text",class:"w-full rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary placeholder-text-muted outline-none focus:border-accent",placeholder:f.$t("dashboard.settings.stopSequencesPlaceholder")},null,8,Nr),[[X,y.value]]),r("p",zr,d(f.$t("dashboard.settings.stopSequencesHint")),1)])])):N("",!0),V.value?(h(),g(U,{key:3},[r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[14]||(_[14]=w=>G.value=!G.value)},[r("span",null,[Te(d(f.$t("dashboard.settings.tools"))+" ",1),x(k).enabledDefinitions.length>0?(h(),g("span",Er," ("+d(x(k).enabledDefinitions.length)+" "+d(f.$t("dashboard.settings.active"))+") ",1)):N("",!0)]),r("span",{class:E(["transition-transform",{"rotate-180":G.value}])},"▾",2)]),G.value?(h(),g("div",Ir,[x(k).allTools.length>0?(h(),g("div",Pr,[(h(!0),g(U,null,Q(x(k).allTools,w=>(h(),g("div",{key:w.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1.5 text-[11px]"},[r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",w.enabled?"bg-accent":"bg-surface-overlay"]),onClick:T=>x(k).toggleEnabled(w.id)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",w.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,Dr),r("span",{class:E(["font-mono",w.enabled?"text-text-primary":"text-text-muted"])},d(w.definition.function.name),3)]))),128))])):(h(),g("p",jr,d(f.$t("dashboard.settings.noToolsDefined")),1)),r("button",{class:"w-full rounded-lg border border-dashed border-border-default px-3 py-1.5 text-[11px] text-text-muted hover:border-accent hover:text-text-primary transition-colors",onClick:_[15]||(_[15]=w=>x(z).push("/tools"))},d(f.$t("dashboard.settings.manageInToolWorkshop")),1)])):N("",!0)],64)):N("",!0),r("button",{class:"flex w-full items-center justify-between rounded-lg px-3 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:_[16]||(_[16]=w=>O.value=!O.value)},[r("span",null,[Te(d(f.$t("dashboard.memory.memory"))+" ",1),x(b).factCount>0?(h(),g("span",Br," ("+d(x(b).factCount)+" "+d(f.$t("dashboard.memory.facts"))+") ",1)):N("",!0)]),r("span",{class:E(["transition-transform",{"rotate-180":O.value}])},"▾",2)]),O.value?(h(),g("div",Lr,[r("div",Fr,[r("div",null,[r("p",Or,d(f.$t("dashboard.memory.slidingWindow")),1),r("p",qr,d(f.$t("dashboard.memory.slidingWindowHint")),1)]),r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",x(b).settings.slidingWindow.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[17]||(_[17]=w=>x(b).settings.slidingWindow.enabled=!x(b).settings.slidingWindow.enabled)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",x(b).settings.slidingWindow.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x(b).settings.slidingWindow.enabled?(h(),g("div",Ur,[r("div",Vr,[r("label",Hr,d(f.$t("dashboard.memory.maxMessages")),1),r("span",Gr,d(x(b).settings.slidingWindow.maxMessages),1)]),W(r("input",{"onUpdate:modelValue":_[18]||(_[18]=w=>x(b).settings.slidingWindow.maxMessages=w),type:"range",min:"10",max:"200",step:"10",class:"w-full accent-accent"},null,512),[[X,x(b).settings.slidingWindow.maxMessages,void 0,{number:!0}]])])):N("",!0),r("div",Wr,[r("div",null,[r("p",Zr,d(f.$t("dashboard.memory.autoSummarize")),1),r("p",Kr,d(f.$t("dashboard.memory.autoSummarizeHint")),1)]),r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",x(b).settings.autoSummarize.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[19]||(_[19]=w=>x(b).settings.autoSummarize.enabled=!x(b).settings.autoSummarize.enabled)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",x(b).settings.autoSummarize.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x(b).settings.autoSummarize.enabled?(h(),g("div",Qr,[r("div",Jr,[r("label",Xr,d(f.$t("dashboard.memory.triggerAfter")),1),r("span",Yr,d(x(b).settings.autoSummarize.triggerThreshold)+" "+d(f.$t("dashboard.memory.messages")),1)]),W(r("input",{"onUpdate:modelValue":_[20]||(_[20]=w=>x(b).settings.autoSummarize.triggerThreshold=w),type:"range",min:"10",max:"100",step:"5",class:"w-full accent-accent"},null,512),[[X,x(b).settings.autoSummarize.triggerThreshold,void 0,{number:!0}]])])):N("",!0),r("div",ei,[r("div",null,[r("p",ti,d(f.$t("dashboard.memory.userMemories")),1),r("p",si,d(f.$t("dashboard.memory.userMemoriesHint")),1)]),r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",x(b).settings.userFacts.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[21]||(_[21]=w=>x(b).settings.userFacts.enabled=!x(b).settings.userFacts.enabled)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",x(b).settings.userFacts.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x(b).settings.userFacts.enabled&&x(b).facts.length>0?(h(),g("div",ni,[(h(!0),g(U,null,Q(x(b).facts,w=>(h(),g("div",{key:w.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1 text-[11px]"},[r("span",oi,d(w.content),1),r("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:T=>x(b).removeFact(w.id)},[D(x(Je),{class:"h-3 w-3"})],8,ai)]))),128))])):N("",!0),r("div",ri,[r("div",null,[r("p",ii,d(f.$t("dashboard.memory.messageMemoryRag")),1),r("p",li,d(f.$t("dashboard.memory.messageMemoryHint")),1)]),r("button",{class:E(["h-4 w-7 shrink-0 rounded-full transition-colors",x(b).settings.ragMemory.enabled?"bg-accent":"bg-surface-overlay"]),onClick:_[22]||(_[22]=w=>x(b).settings.ragMemory.enabled=!x(b).settings.ragMemory.enabled)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",x(b).settings.ragMemory.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],2)]),x(b).settings.ragMemory.enabled?(h(),g("div",ci,[r("div",null,[r("label",ui,d(f.$t("dashboard.memory.embeddingModel")),1),W(r("select",{"onUpdate:modelValue":_[23]||(_[23]=w=>x(b).settings.ragMemory.embeddingModel=w),class:"w-full rounded-lg border border-border-default bg-surface px-2 py-1 text-xs text-text-primary outline-none focus:border-accent"},[r("option",di,d(f.$t("dashboard.memory.selectEmbeddingModel")),1),(h(!0),g(U,null,Q(x(I).embeddingModelNames,w=>(h(),g("option",{key:w,value:w},d(w)+" "+d(x(I).capabilityIcons(w)),9,pi))),128))],512),[[tt,x(b).settings.ragMemory.embeddingModel]])]),x(I).embeddingModelNames.length===0?(h(),g("div",hi,[r("p",mi,d(f.$t("dashboard.memory.noEmbeddingModels")),1),r("div",gi,[(h(),g(U,null,Q(me,w=>r("div",{key:w.name,class:"flex items-center gap-2"},[r("div",fi,[r("p",xi,d(w.name),1),r("p",bi,d(w.description)+" ("+d(w.size)+")",1)]),r("button",{disabled:he.value,class:"shrink-0 rounded-md bg-accent px-2 py-0.5 text-[10px] text-white hover:bg-accent-hover disabled:opacity-30 transition-colors",onClick:T=>ge(w.name)},d(he.value&&ve.value===w.name?f.$t("dashboard.settings.pulling"):f.$t("dashboard.settings.pull")),9,vi)])),64))]),ne.value?(h(),g("p",yi,d(ne.value),1)):N("",!0)])):N("",!0),r("div",null,[r("div",ki,[r("label",wi,d(f.$t("dashboard.memory.retrieveTop")),1),r("span",$i,d(x(b).settings.ragMemory.topK)+" "+d(f.$t("dashboard.memory.messages")),1)]),W(r("input",{"onUpdate:modelValue":_[24]||(_[24]=w=>x(b).settings.ragMemory.topK=w),type:"range",min:"1",max:"10",step:"1",class:"w-full accent-accent"},null,512),[[X,x(b).settings.ragMemory.topK,void 0,{number:!0}]])])])):N("",!0)])):N("",!0)])]))}}),_i={class:"flex h-full flex-col"},Ci={key:0,class:"absolute left-1/2 top-16 z-50 -translate-x-1/2 rounded-xl border border-border-default bg-surface-raised px-4 py-3 shadow-lg"},Ti={class:"flex items-start gap-3"},Mi={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},Ri={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},Ai={class:"flex items-center gap-3"},Ni={class:"relative"},zi={key:0,class:"text-text-muted"},Ei={key:0,class:"absolute left-0 top-full z-50 mt-1 max-h-64 w-max min-w-full overflow-y-auto rounded-lg border border-border-default bg-surface-raised shadow-lg"},Ii=["onMousedown"],Pi={key:0,class:"flex items-center"},Di=["title"],ji={class:"truncate"},Bi={class:"flex items-center gap-2"},Li={class:"relative"},Fi={key:1,class:"absolute end-0 top-full z-20 mt-1 w-48 rounded-lg border border-border-default bg-surface-raised shadow-lg py-1"},Oi={class:"flex flex-1 min-h-0"},qi={key:0,class:"w-64 shrink-0 border-e border-border-default bg-surface-raised flex flex-col"},Ui={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},Vi={class:"text-xs font-medium text-text-secondary"},Hi={class:"flex-1 overflow-y-auto p-2"},Gi={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},Wi={key:1,class:"space-y-0.5"},Zi=["onClick"],Ki={key:0,class:"flex-1 min-w-0"},Qi=["onBlur","onKeydown"],Ji={class:"flex-1 min-w-0"},Xi={class:"truncate text-[11px]"},Yi={class:"truncate text-[9px] text-text-muted"},el={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},tl=["title","onClick"],sl=["title","onClick"],nl={class:"flex flex-1 flex-col min-w-0"},ol={key:0,class:"mx-4 mt-2 rounded-lg border border-error/30 bg-error/10 px-4 py-2.5 text-sm text-error"},al={class:"font-medium"},rl={key:1,class:"w-72 shrink-0 border-s border-border-default bg-surface-raised"},il={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},ll={class:"text-xs font-medium text-text-secondary"},cl=se({__name:"ChatConversation",setup(t){const{t:e}=Vt(),s=Gt(),o=Wt(),n=lt(),i=Xe(),a=Qt(),c=it(),l=ct(),p=es(),u=Kt(),m=ts(),{isStreaming:y,currentSessionId:C,startChatStream:k,cancel:z}=xn(),b=A(""),I=A(!1);function H(){setTimeout(()=>{I.value=!1},150)}const V=A(!0),K=A(!1),G=A(!1),O=A(!1);function he(){const v=de.value;if(!v||v.messages.length===0)return;const S=JSON.stringify(v.messages,null,2),$=new Blob([S],{type:"application/json"}),M=URL.createObjectURL($),R=document.createElement("a");R.href=M,R.download=`chat-${v.id}.json`,R.click(),URL.revokeObjectURL(M),O.value=!1}function ne(){const v=de.value;if(!v||v.messages.length===0)return;const S=v.messages.map(Y=>{const xe=Y.role.charAt(0).toUpperCase()+Y.role.slice(1),oe=new Date(Y.timestamp).toLocaleString();return`### ${xe}
|
|
93
|
+
*${oe}*
|
|
94
|
+
|
|
95
|
+
${Y.content}`}),$=`# Chat Export — ${v.name}
|
|
96
|
+
|
|
97
|
+
${S.join(`
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
`)}
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
*Generated by LLMxRay — Local LLM Observatory*
|
|
105
|
+
`,M=new Blob([$],{type:"text/markdown"}),R=URL.createObjectURL(M),L=document.createElement("a");L.href=R,L.download=`chat-${v.id}.md`,L.click(),URL.revokeObjectURL(R),O.value=!1}function ve(){const v=de.value;if(!v||v.messages.length===0)return;const S=v.messages.map(L=>`[${L.role}] ${L.content}`).join(`
|
|
106
|
+
|
|
107
|
+
`),$=new Blob([S],{type:"text/plain"}),M=URL.createObjectURL($),R=document.createElement("a");R.href=M,R.download=`chat-${v.id}.txt`,R.click(),URL.revokeObjectURL(M),O.value=!1}const me=A(null),ge=A("");function f(v){o.setActiveConversation(v)}function _(v,S){me.value=v,ge.value=S}function w(v){const S=ge.value.trim();S&&o.renameConversation(v,S),me.value=null}function T(){me.value=null}function j(v,S){v.key==="Enter"?w(S):v.key==="Escape"&&T()}function le(v){const $=Date.now()-v,M=Math.floor($/6e4);if(M<1)return e("common.time.justNow");if(M<60)return e("dashboard.conversation.minutesAgo",{n:M});const R=Math.floor(M/60);if(R<24)return e("dashboard.conversation.hoursAgo",{n:R});const L=Math.floor(R/24);return L<7?e("dashboard.conversation.daysAgo",{n:L}):new Date(v).toLocaleDateString()}const q=A({systemPrompt:"",options:{}}),fe=A(null);let Me=null;const de=B(()=>o.activeConversation),Be=B(()=>de.value?.messages??[]),xs=B(()=>n.isVisionModel(b.value)),vt=B(()=>{const v=Se.value??C.value;if(!v)return null;const S=i.sessionById(v);return S?.status==="error"&&S.error?S.error:null}),Se=B(()=>{const v=Be.value;for(let S=v.length-1;S>=0;S--)if(v[S].sessionId)return v[S].sessionId;return null}),_e=A(e("dashboard.conversation.untitled")),Re=A(!1),Le=A(""),yt=B(()=>de.value?.name??_e.value);function bs(){Le.value=yt.value,Re.value=!0}function kt(){const v=Le.value.trim();if(!v){Re.value=!1;return}de.value?o.renameConversation(de.value.id,v):_e.value=v,Re.value=!1}function vs(){Re.value=!1}function ys(v){v.key==="Enter"?kt():v.key==="Escape"&&vs()}Ht(async()=>{await n.fetchModels(),n.chatModelNames.length>0&&!b.value&&(b.value=n.chatModelNames[0]),await a.loadDocuments()}),te(b,v=>{if(!v)return;const S=n.getModelDefaults(v);Object.keys(S).length>0&&(q.value={systemPrompt:q.value.systemPrompt,options:{...S}})}),te(()=>o.activeConversationId,async v=>{if(!v)return;const S=o.conversations.get(v);if(S){S.model&&n.chatModelNames.includes(S.model)&&(b.value=S.model);try{const $=await Fs.getSessionsByConversation(v);for(const M of $)i.sessionById(M.id)||(i.sessions.set(M.id,{id:M.id,mode:M.mode,model:M.model,status:M.status,createdAt:M.createdAt,prompt:M.prompt,messages:M.messages,options:M.options,outputText:M.outputText,metrics:M.metrics,error:M.error,doneReason:M.doneReason}),i.linkSessionToConversation(M.id,v)),await u.loadTokens(M.id)}catch($){console.error("Failed to restore sessions for conversation:",$)}}});async function wt(v,S=[]){if(!b.value)return;let $=o.activeConversationId;$||($=o.createConversation(b.value),_e.value!==e("dashboard.conversation.untitled")&&o.renameConversation($,_e.value),_e.value=e("dashboard.conversation.untitled"));const M=o.conversations.get($);M&&M.model!==b.value&&(M.model=b.value);const R=S.filter(Z=>Z.type==="document"&&Z.content),L=S.filter(Z=>Z.type==="image"&&Z.content);let Y=v;R.length>0&&(Y=R.map(ee=>`[Attached: ${ee.name}]
|
|
108
|
+
${ee.content}`).join(`
|
|
109
|
+
|
|
110
|
+
`)+`
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
`+v);const xe={id:be(),conversationId:$,role:"user",content:Y,timestamp:Date.now(),isStreaming:!1,attachments:S.length>0?S:void 0};o.addMessage($,xe);const oe=be(),Fe={id:oe,conversationId:$,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};o.addMessage($,Fe);const pe=o.getMessagesAsOllamaFormat($).slice(0,-1);if(L.length>0){const Z=[...pe].reverse().find(ee=>ee.role==="user");Z&&(Z.images=L.map(ee=>ee.content.replace(/^data:[^;]+;base64,/,"")))}if(q.value.systemPrompt.trim()&&pe.unshift({role:"system",content:q.value.systemPrompt.trim()}),V.value&&a.enabledDocuments.length>0)try{const Z=await a.getContextForQuery(v,b.value,5);Z&&pe.unshift({role:"system",content:Z})}catch{}let $t=pe;try{const Z=p.getSummary($)?.summary,ee=await Rn({conversationId:$,messages:pe,model:b.value,settings:p.settings,userFactsPrompt:p.getFactsAsSystemPrompt(),existingSummary:Z});if($t=ee.messages,ee.newSummary){const ae=pe.filter(St=>St.role!=="system");p.setSummary($,ee.newSummary,ae.length)}}catch{}try{const Z={...de.value?.options,...q.value.options},ee=l.enabledDefinitions,ae=await k(b.value,$t,Z,ee.length>0?ee:void 0),_t=o.conversations.get($)?.messages.find(ce=>ce.id===oe);_t&&(_t.sessionId=ae),i.linkSessionToConversation(ae,$);const Ts=te(()=>i.sessionById(ae)?.outputText,ce=>{ce!==void 0&&o.updateAssistantContent($,oe,ce)}),Ct=$,Ms=v,Rs=te(()=>i.sessionById(ae)?.status,ce=>{if(ce==="completed"||ce==="error"||ce==="cancelled"){if(o.finalizeMessage(Ct,oe),y.value=!1,Ts(),Rs(),u.persistTokens(ae),ce==="completed"){const qe=i.sessionById(ae),As=(qe?.outputText??"").replace(/<think>[\s\S]*?<\/think>/g,"").trim(),Ns=c.getMetrics(ae),zs=Mn(oe,ae,As,Ns?.completionTokenCount??0,q.value.options.num_predict,qe?.doneReason);m.setReport(oe,zs)}if(ce==="completed"&&p.settings.ragMemory.enabled&&p.settings.ragMemory.embeddingModel){const qe=i.sessionById(ae)?.outputText??"";An(Ct,[{role:"user",content:Ms,timestamp:xe.timestamp},{role:"assistant",content:qe,timestamp:Date.now()}],p.settings.ragMemory.embeddingModel).catch(()=>{})}}})}catch{o.finalizeMessage($,oe)}}function ks(){z()}function ws(){o.setActiveConversation(null),_e.value=e("dashboard.conversation.untitled")}function $s(v){s.push({name:"session",params:{id:v}})}function ye(v){fe.value=v,Me&&clearTimeout(Me),Me=setTimeout(()=>{fe.value=null},5e3)}function Ss(){fe.value=null,Me&&clearTimeout(Me)}const _s={systemPrompt:"",options:{}};async function Cs(v,S){const $=vn(v);if(!$){ye(`Unknown command: /${v}. Type /help for available commands.`);return}const M={clearConversation:()=>o.setActiveConversation(null),newChat:()=>o.setActiveConversation(null),sendAsUser:R=>wt(R),copyLastResponse:()=>{const R=Be.value.filter(Y=>Y.role==="assistant"),L=R[R.length-1];L?.content?(navigator.clipboard.writeText(L.content),ye("Copied to clipboard.")):ye("No assistant response to copy.")},exportConversation:R=>{const L=de.value;if(!L||L.messages.length===0){ye("No conversation to export.");return}let Y,xe;R==="json"?(Y=JSON.stringify(L.messages,null,2),xe=`chat-${L.id}.json`):(Y=L.messages.map(pe=>`[${pe.role}] ${pe.content}`).join(`
|
|
115
|
+
|
|
116
|
+
`),xe=`chat-${L.id}.txt`);const oe=new Blob([Y],{type:"text/plain"}),Fe=URL.createObjectURL(oe),Oe=document.createElement("a");Oe.href=Fe,Oe.download=xe,Oe.click(),URL.revokeObjectURL(Fe)},setSystemPrompt:R=>{q.value={...q.value,systemPrompt:R}},setOption:(R,L)=>{q.value={...q.value,options:{...q.value.options,[R]:L}}},resetSettings:()=>{q.value={..._s}},setJsonFormat:R=>{ye("JSON format toggled. This affects the next request.")},switchModel:R=>{b.value=R},availableModels:n.chatModelNames,currentModel:b.value,toggleRag:()=>{V.value=!V.value},ragEnabled:V.value,navigate:R=>s.push(R),openSettings:()=>{K.value=!0},openSessionDetails:()=>{const R=Se.value;R?s.push({name:"session",params:{id:R}}):ye("No active session.")},addFact:R=>p.addFact(R),removeFact:R=>p.removeFactByContent(R),getFacts:()=>p.facts,showNotification:ye,messages:Be.value,chatSettings:q,currentSessionId:Se.value??C.value,getSessionTokenCount:()=>{const R=Se.value??C.value;if(!R)return null;const L=c.getMetrics(R);return L?{prompt:L.promptTokenCount,completion:L.completionTokenCount}:null},getAverageSpeed:()=>{const R=c.aggregate;return R.totalSessions>0?R.avgTps:null},getOllamaStatus:async()=>{try{return{connected:(await fetch("/api/tags")).ok,model:b.value}}catch{return{connected:!1,model:b.value}}}};await $.execute(S,M)}return(v,S)=>(h(),g("div",_i,[D(Ut,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2","leave-active-class":"transition-all duration-150 ease-in","leave-to-class":"opacity-0 -translate-y-2"},{default:qt(()=>[fe.value?(h(),g("div",Ci,[r("div",Ti,[r("p",Mi,d(fe.value),1),r("button",{class:"shrink-0 text-text-muted hover:text-text-primary transition-colors text-xs",onClick:Ss}," ✕ ")])])):N("",!0)]),_:1}),r("div",Ri,[r("div",Ai,[r("div",Ni,[r("button",{class:"flex items-center gap-2 rounded-lg border border-border-default bg-surface px-3 py-1.5 text-sm text-text-primary outline-none hover:border-accent/50 focus:border-accent",onClick:S[0]||(S[0]=$=>I.value=!I.value),onBlur:H},[b.value?(h(),g(U,{key:1},[r("span",null,d(b.value),1),D(Tt,{"model-name":b.value},null,8,["model-name"])],64)):(h(),g("span",zi,d(v.$t("common.model.noModels")),1)),D(x(Hs),{class:E(["h-3 w-3 text-text-muted transition-transform",I.value?"rotate-180":""])},null,8,["class"])],32),I.value?(h(),g("div",Ei,[(h(!0),g(U,null,Q(x(n).chatModelNames,$=>(h(),g("button",{key:$,class:E(["flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm transition-colors",$===b.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:He(M=>{b.value=$,I.value=!1},["prevent"])},[r("span",null,d($),1),D(Tt,{"model-name":$},null,8,["model-name"])],42,Ii))),128))])):N("",!0)]),Re.value?(h(),g("div",Pi,[W(r("input",{"onUpdate:modelValue":S[1]||(S[1]=$=>Le.value=$),class:"w-48 rounded border border-accent bg-surface px-2 py-0.5 text-xs text-text-primary outline-none",onBlur:kt,onKeydown:ys,onVnodeMounted:S[2]||(S[2]=$=>{$.el.focus(),$.el.select()})},null,544),[[X,Le.value]])])):(h(),g("button",{key:1,class:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-text-muted hover:text-text-primary hover:bg-surface-overlay transition-colors truncate max-w-[200px]",title:v.$t("dashboard.conversation.clickToRename"),onClick:bs},[r("span",ji,d(yt.value),1),D(x(Mt),{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100"})],8,Di))]),r("div",Bi,[Se.value?(h(),g("button",{key:0,class:"rounded-lg px-3 py-1.5 text-xs text-accent hover:bg-surface-overlay transition-colors",onClick:S[3]||(S[3]=$=>$s(Se.value))},d(v.$t("dashboard.conversation.viewSessionDetails")),1)):N("",!0),r("button",{class:E(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",G.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:S[4]||(S[4]=$=>G.value=!G.value)},[D(x(tn),{class:"h-3.5 w-3.5"}),r("span",null,d(v.$t("dashboard.conversation.history")),1)],2),r("div",Li,[r("button",{class:E(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",O.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:S[5]||(S[5]=$=>O.value=!O.value)},[D(x(en),{class:"h-3.5 w-3.5"}),r("span",null,d(v.$t("common.actions.export")),1)],2),O.value?(h(),g("div",{key:0,class:"fixed inset-0 z-10",onClick:S[6]||(S[6]=$=>O.value=!1)})):N("",!0),O.value?(h(),g("div",Fi,[r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:he},d(v.$t("dashboard.export.downloadJson")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:ne},d(v.$t("dashboard.export.downloadMarkdown")),1),r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:ve},d(v.$t("dashboard.export.downloadText")),1)])):N("",!0)]),r("button",{class:"rounded-lg px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-overlay hover:text-text-primary transition-colors",onClick:ws},d(v.$t("dashboard.conversation.newChatButton")),1),r("button",{class:E(["flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs transition-colors",K.value?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:S[7]||(S[7]=$=>K.value=!K.value)},[D(x(Ls),{class:"h-3.5 w-3.5"}),r("span",null,d(v.$t("dashboard.settings.chatSettings")),1)],2)])]),r("div",Oi,[G.value?(h(),g("div",qi,[r("div",Ui,[r("span",Vi,d(v.$t("dashboard.conversation.chatHistory")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:S[8]||(S[8]=$=>G.value=!1)}," ✕ ")]),r("div",Hi,[x(o).recentConversations.length===0?(h(),g("p",Gi,d(v.$t("dashboard.conversation.noConversationsYet")),1)):(h(),g("div",Wi,[(h(!0),g(U,null,Q(x(o).recentConversations,$=>(h(),g("div",{key:$.id,class:E(["group flex items-center gap-1 rounded-lg px-2.5 py-2 text-xs transition-colors cursor-pointer",$.id===x(o).activeConversationId?"bg-surface-overlay text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:M=>f($.id)},[me.value===$.id?(h(),g("div",Ki,[W(r("input",{"onUpdate:modelValue":S[9]||(S[9]=M=>ge.value=M),class:"w-full rounded bg-surface px-1.5 py-0.5 text-xs text-text-primary outline-none border border-accent",onBlur:M=>w($.id),onKeydown:M=>j(M,$.id),onVnodeMounted:S[10]||(S[10]=M=>{M.el.focus(),M.el.select()})},null,40,Qi),[[X,ge.value]])])):(h(),g(U,{key:1},[r("div",Ji,[r("p",Xi,d($.name),1),r("p",Yi,d($.model)+" · "+d(le($.updatedAt)),1)]),r("div",el,[r("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:v.$t("dashboard.conversation.rename"),onClick:He(M=>_($.id,$.name),["stop"])},[D(x(Mt),{class:"h-3 w-3"})],8,tl),r("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:v.$t("common.actions.delete"),onClick:He(M=>x(o).deleteConversation($.id),["stop"])},[D(x(Je),{class:"h-3 w-3"})],8,sl)])],64))],10,Zi))),128))]))])])):N("",!0),r("div",nl,[vt.value?(h(),g("div",ol,[r("span",al,d(v.$t("common.status.error"))+":",1),Te(" "+d(vt.value),1)])):N("",!0),D(ta,{messages:Be.value},null,8,["messages"]),D(Ia,{"is-streaming":x(y),"selected-model":b.value,"is-vision-model":xs.value,onSend:wt,onCommand:Cs,onCancel:ks},null,8,["is-streaming","selected-model","is-vision-model"])]),K.value?(h(),g("div",rl,[r("div",il,[r("span",ll,d(v.$t("dashboard.settings.chatSettings")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:S[11]||(S[11]=$=>K.value=!1)}," ✕ ")]),D(Si,{modelValue:q.value,"onUpdate:modelValue":S[12]||(S[12]=$=>q.value=$),"selected-model":b.value,"rag-enabled":V.value,"onUpdate:ragEnabled":S[13]||(S[13]=$=>V.value=$)},null,8,["modelValue","selected-model","rag-enabled"])])):N("",!0)])]))}}),ul={class:"rounded-lg border border-border-default bg-surface-raised"},dl={class:"overflow-x-auto"},pl={class:"w-full text-sm"},hl=["onClick"],ml={class:"px-4 py-2 font-medium text-text-primary"},gl={class:"px-4 py-2"},fl={class:"px-4 py-2 text-text-secondary"},xl={class:"px-4 py-2 text-text-secondary"},bl={class:"px-4 py-2 text-text-secondary"},vl={class:"px-4 py-2 text-text-muted"},yl={key:0},kl=se({__name:"SessionHistoryTable",setup(t){const e=Xe();return(s,o)=>(h(),g("div",ul,[o[2]||(o[2]=r("div",{class:"px-4 py-3 border-b border-border-default"},[r("h3",{class:"text-sm font-medium text-text-secondary"},"Recent Sessions")],-1)),r("div",dl,[r("table",pl,[o[1]||(o[1]=r("thead",null,[r("tr",{class:"border-b border-border-default text-left text-xs text-text-muted uppercase tracking-wide"},[r("th",{class:"px-4 py-2"},"Model"),r("th",{class:"px-4 py-2"},"Status"),r("th",{class:"px-4 py-2"},"Tokens"),r("th",{class:"px-4 py-2"},"Speed"),r("th",{class:"px-4 py-2"},"Duration"),r("th",{class:"px-4 py-2"},"When")])],-1)),r("tbody",null,[(h(!0),g(U,null,Q(x(e).recentSessions.slice(0,20),n=>(h(),g("tr",{key:n.id,class:"border-b border-border-default last:border-0 hover:bg-surface-overlay cursor-pointer transition-colors",onClick:i=>s.$router.push({name:"session",params:{id:n.id}})},[r("td",ml,d(n.model),1),r("td",gl,[D(Zs,{status:n.status,detail:n.error},null,8,["status","detail"])]),r("td",fl,d(n.metrics?n.metrics.totalTokenCount:"—"),1),r("td",xl,d(n.metrics?x(Ge)(n.metrics.tokensPerSecond):"—"),1),r("td",bl,d(n.metrics?x(Zt)(n.metrics.totalDurationMs):"—"),1),r("td",vl,d(x(Os)(n.createdAt)),1)],8,hl))),128)),x(e).recentSessions.length===0?(h(),g("tr",yl,[...o[0]||(o[0]=[r("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):N("",!0)])])])]))}}),wl={class:"flex h-full flex-col"},$l={class:"flex-1 min-h-0"},Sl={key:0,class:"border-t border-border-default"},_l={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Cl={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Tl={key:1,class:"border-t border-border-default px-4 py-2"},Ml={class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},Rl={class:"flex gap-2 overflow-x-auto pb-1"},Al=["onClick"],Wl=se({__name:"DashboardPage",setup(t){const e=it(),s=Wt(),o=A(!1),n=B(()=>e.aggregate),i=B(()=>n.value.totalSessions>0),a=B(()=>s.recentConversations);return(c,l)=>(h(),g("div",wl,[r("div",$l,[D(cl)]),i.value?(h(),g("div",Sl,[r("button",{class:"flex w-full items-center justify-between px-4 py-2 text-xs text-text-secondary hover:bg-surface-overlay transition-colors",onClick:l[0]||(l[0]=p=>o.value=!o.value)},[r("span",null,d(n.value.totalSessions)+" "+d(c.$t("dashboard.metrics.sessions"))+" · Avg "+d(x(Ge)(n.value.avgTps)),1),r("span",{class:E(["transition-transform",{"rotate-180":o.value}])},"▾",2)]),o.value?(h(),g("div",_l,[r("div",Cl,[D(Ue,{label:c.$t("dashboard.metrics.totalSessions"),value:n.value.totalSessions},null,8,["label","value"]),D(Ue,{label:c.$t("dashboard.metrics.avgTtft"),value:x(Zt)(n.value.avgTtftMs)},null,8,["label","value"]),D(Ue,{label:c.$t("dashboard.metrics.avgSpeed"),value:x(Ge)(n.value.avgTps)},null,8,["label","value"]),D(Ue,{label:c.$t("dashboard.metrics.totalTokens"),value:x(Ce)(n.value.totalTokensGenerated),unit:"tok"},null,8,["label","value"])]),D(kl)])):N("",!0)])):N("",!0),a.value.length>1?(h(),g("div",Tl,[r("p",Ml,d(c.$t("dashboard.metrics.recentChats")),1),r("div",Rl,[(h(!0),g(U,null,Q(a.value.slice(0,5),p=>(h(),g("button",{key:p.id,class:E(["shrink-0 rounded-lg px-3 py-1.5 text-xs transition-colors",x(s).activeConversationId===p.id?"bg-accent/10 text-accent":"bg-surface-overlay text-text-secondary hover:text-text-primary"]),onClick:u=>x(s).setActiveConversation(p.id)},d(p.name),11,Al))),128))])])):N("",!0)]))}});export{Wl as default};
|