llmxray 0.4.1 → 0.4.2
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 +11 -0
- package/dist/assets/{AITrainingPage-VU-Nu5i0.js → AITrainingPage-DEU4UAR7.js} +1 -1
- package/dist/assets/AnalyticsPage-C7mNUAil.js +1 -0
- package/dist/assets/{BenchmarkPage-CQUTAU0c.js → BenchmarkPage-jiUqdHmg.js} +2 -2
- package/dist/assets/{ComparisonPage-DSO_-JZF.js → ComparisonPage-BoBWSObY.js} +3 -3
- package/dist/assets/CostDashboardPage-BKQDsZhx.js +1 -0
- package/dist/assets/{DashboardPage-lqAFJvOo.js → DashboardPage-CV8Ejgxv.js} +43 -43
- package/dist/assets/{EmbeddingsPage-DDBfFe8z.js → EmbeddingsPage-DXjVT4eU.js} +1 -1
- package/dist/assets/{GoogleCallbackPage-H8X6YDz9.js → GoogleCallbackPage-BUIkYpZv.js} +1 -1
- package/dist/assets/{JsonTreeNode-DQ_R5Euc.js → JsonTreeNode-C0UNUwZm.js} +1 -1
- package/dist/assets/{ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-CV939MUZ.js → ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-vQNvYFzV.js} +1 -1
- package/dist/assets/{RAGPage-DbZxWHmi.js → RAGPage-Dv4UDEyz.js} +1 -1
- package/dist/assets/SessionPage-B0fMQGSB.js +15 -0
- package/dist/assets/{SettingsPage-fmgr8zF9.js → SettingsPage-DTJP-4xU.js} +1 -1
- package/dist/assets/{StatusBadge.vue_vue_type_script_setup_true_lang-BbHpA7hy.js → StatusBadge.vue_vue_type_script_setup_true_lang-BiB0M6lv.js} +1 -1
- package/dist/assets/{StorageGauge.vue_vue_type_style_index_0_lang-Dd3BsCg6.js → StorageGauge.vue_vue_type_style_index_0_lang-DToi3R0q.js} +1 -1
- package/dist/assets/{SystemPage-Bd3SBsWI.js → SystemPage-BPK15qwe.js} +2 -2
- package/dist/assets/{TabBar.vue_vue_type_script_setup_true_lang-DlSEPHs6.js → TabBar.vue_vue_type_script_setup_true_lang-BtGCdMZK.js} +1 -1
- package/dist/assets/{TokenStreamDisplay.vue_vue_type_script_setup_true_lang-P-I0kJTd.js → TokenStreamDisplay.vue_vue_type_script_setup_true_lang-B6juPZsY.js} +1 -1
- package/dist/assets/{ToolWorkshopPage-D9doB8PF.js → ToolWorkshopPage-DmpoHHaD.js} +3 -3
- package/dist/assets/{agent-store-CuCtjbhV.js → agent-store-C6w1zV86.js} +1 -1
- package/dist/assets/{canvas-ai-db-DBUT-nyD.js → canvas-ai-db-BpqhUp6k.js} +1 -1
- package/dist/assets/{download-C3s6K1NW.js → download-pCIjWOn5.js} +1 -1
- package/dist/assets/{generate-service-DrRYe_-5.js → generate-service-DmtXqq_h.js} +1 -1
- package/dist/assets/{google-auth-store-B0WvuFWG.js → google-auth-store-Dgv2FihL.js} +1 -1
- package/dist/assets/index-534TcCbY.js +8 -0
- package/dist/assets/index-B72Sw9uL.css +1 -0
- package/dist/assets/{index-CUNpOQX9.js → index-ClITfJ3t.js} +1 -1
- package/dist/assets/{index-DoMyvAkM.js → index-DHuj6tKB.js} +1 -1
- package/dist/assets/{info-D-oZIv7P.js → info-Eg1tUw1x.js} +1 -1
- package/dist/assets/{metrics-store-DRErjO4D.js → metrics-store-7m97Sb7w.js} +1 -1
- package/dist/assets/{papaparse.min-DJzuA_ek.js → papaparse.min-3FeAYh4d.js} +1 -1
- package/dist/assets/{pencil-MO2uWQbW.js → pencil-CZp68oBU.js} +1 -1
- package/dist/assets/{rag-store-CBWvD3Va.js → rag-store-Bm0nxdec.js} +3 -3
- package/dist/assets/session-store-BQ0TF24S.js +1 -0
- package/dist/assets/{share-2-CnM5sBDm.js → share-2-CJJGZsZO.js} +1 -1
- package/dist/assets/{storage-store-cx_2Hb_J.js → storage-store-6qFwk_C5.js} +1 -1
- package/dist/assets/stream-handler-BM5egg14.js +4 -0
- package/dist/assets/{tool-workshop-store-Cb4eb3e4.js → tool-workshop-store-9_FKfdnT.js} +1 -1
- package/dist/assets/toolcall-store-C4Trr01T.js +1 -0
- package/dist/assets/{trash-2-Cj-NOsVZ.js → trash-2-DjfJXqVK.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/CostDashboardPage-BLzCE-bT.js +0 -1
- package/dist/assets/SessionPage-DvtFE4GS.js +0 -15
- package/dist/assets/index-Bawj8X2v.css +0 -1
- package/dist/assets/index-DYHBy1xj.js +0 -8
- package/dist/assets/stream-handler-CXdBM2li.js +0 -4
- package/dist/assets/toolcall-store-xQEQUq5f.js +0 -1
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import{u as
|
|
2
|
-
`),n=e.createSession({mode:"chat",model:t.model,prompt:o,messages:t.messages,options:t.options});e.setActiveSession(n);const
|
|
3
|
-
`];for(const[n,
|
|
1
|
+
import{u as lt}from"./metrics-store-7m97Sb7w.js";import{c as De,_ as Es,o as Pe,n as be,r as A,d as Ot,w as te,a as B,b as se,e as m,f as r,g as E,t as d,h as Te,i as N,j as h,F as q,k as Q,l as Is,u as x,m as Ds,p as P,q as Ee,T as Ps,s as qt,v as He,X as Je,x as Ut,y as js,z as Vt,A as it,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-534TcCbY.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}from"./session-store-BQ0TF24S.js";import{a as qs,s as Us,C as Vs}from"./generate-service-DmtXqq_h.js";import{u as Hs,a as Gs,_ as Ws,b as Ue}from"./StatusBadge.vue_vue_type_script_setup_true_lang-BiB0M6lv.js";import{u as Zs}from"./toolcall-store-C4Trr01T.js";import{u as ct}from"./tool-workshop-store-9_FKfdnT.js";import{u as Ks,a as Kt,b as Qs}from"./agent-store-C6w1zV86.js";import{e as Js}from"./stream-handler-BM5egg14.js";import{d as Xs,p as Ys,u as Qt}from"./rag-store-Bm0nxdec.js";import{messageMemoryDB as Jt}from"./message-memory-db-C3Ifhs2B.js";import{_ as Tt}from"./ModelCapabilityIcons.vue_vue_type_script_setup_true_lang-vQNvYFzV.js";import{P as Mt}from"./pencil-CZp68oBU.js";import{D as en}from"./download-pCIjWOn5.js";import"./vector-db-ChAzHl5A.js";const tn=De("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);const Xt=De("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=De("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=De("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=De("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[l,a]of Object.entries(e))s.set(l,a);const o=[...t].sort((l,a)=>l.order-a.order);let n=null;for(const l of o)switch(l.type){case"http_request":await cn(l.config,s);break;case"extract_field":un(l.config,s);break;case"template":dn(l.config,s);break;case"return_value":n=pn(l.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[i,p]of Object.entries(t.headers))n[i]=Ie(p,e);const l=await fetch(s,{method:t.method,headers:n,body:t.method!=="GET"?o:void 0});let a;(l.headers.get("content-type")??"").includes("application/json")?a=await l.json():a=await l.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 l of o){if(n==null||typeof n!="object"){n=null;break}n=n[l]}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 l=e.get(n[0]??"");for(let a=1;a<n.length;a++){if(l==null||typeof l!="object")return"";l=l[n[a]??""]}return l==null?"":typeof l=="object"?JSON.stringify(l):String(l)})}const mn=5;async function gn(t){const e=Xe(),s=Hs(),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 l=qs(n,t.messages);s.setAnatomy(n,l);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,l){const a=Zs(),c=ct(),i=Ks();let p=0,u=0;for(;p<mn;){if(l.aborted)return;const g=await Pe.streamChat({model:e,messages:s,tools:o,options:n,logprobs:!0},l),v=await Js(t,g,l);if(v.toolCalls.length===0)return;s.push({role:"assistant",content:"",tool_calls:v.toolCalls});for(const C of v.toolCalls){const _=c.findByFunctionName(C.function.name),b=a.getToolCalls(t).find(V=>V.functionName===C.function.name&&V.status==="pending");if(!_){const V=`Tool "${C.function.name}" has no implementation`;i.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(_,C.function.arguments);i.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})}i.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,i,p,u){t.value=!0,e.value=null;try{const g=await Us({model:c,prompt:i,system:u,options:p});return s.value=g.sessionId,o=g.abort,g.sessionId}catch(g){throw e.value=g instanceof Error?g.message:"Failed to start generation",t.value=!1,g}}async function l(c,i,p,u){t.value=!0,e.value=null;try{const g=await gn({model:c,messages:i,tools:u,options:p});return s.value=g.sessionId,o=g.abort,g.sessionId}catch(g){throw e.value=g instanceof Error?g.message:"Failed to start chat",t.value=!1,g}}function a(){o&&(o(),o=null),t.value=!1}return{isStreaming:t,error:e,currentSessionId:s,startGenerate:n,startChatStream:l,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,l]of Object.entries(s)){o.push(`**${n}**`);for(const a of l)o.push(` ${a.usage} — ${a.description}`);o.push("")}e.showNotification(o.join(`
|
|
4
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
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
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
7
|
Completion tokens: ${Ce(s.completion)}
|
|
8
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
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,
|
|
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,l)=>`${l+1}. ${n.content}`);e.showNotification(`Your memories (${s.length}):
|
|
11
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,
|
|
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,_=>Et(At,_),{deep:!0});function e(_){t.value={...t.value,..._}}function s(){t.value={...Rt}}const o=A(zt(Nt,[]));te(o,_=>Et(Nt,_),{deep:!0});const n=B(()=>o.value.length);function l(_){const z={id:be(),content:_.trim(),createdAt:Date.now()};return o.value=[...o.value,z],z}function a(_){o.value=o.value.filter(z=>z.id!==_)}function c(_){const z=_.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 i(){o.value=[]}function p(){return o.value.length===0?"":`The user has asked you to remember these facts about them:
|
|
13
13
|
${o.value.map(z=>`- ${z.content}`).join(`
|
|
14
14
|
`)}
|
|
15
15
|
|
|
16
|
-
Keep these in mind when responding.`}const u=A(new Map);function
|
|
16
|
+
Keep these in mind when responding.`}const u=A(new Map);function g(_,z,b){u.value.set(_,{conversationId:_,summary:z,messageCount:b,createdAt:Date.now()})}function v(_){return u.value.get(_)}function C(_){u.value.delete(_)}return{settings:t,updateSettings:e,resetSettings:s,facts:o,factCount:n,addFact:l,removeFact:a,removeFactByContent:c,clearFacts:i,getFactsAsSystemPrompt:p,summaries:u,setSummary:g,getSummary:v,clearSummary:C}}),ts=Ot("quality",()=>{const t=A(new Map);function e(n){return t.value.get(n)??null}function s(n,l){t.value.set(n,l)}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 l=n/s.length;return l>.5?{detector:"repetition",status:"fail",reason:"quality.repetition.reason",detail:`${(l*100).toFixed(0)}% repeated 4-grams`}:l>.3?{detector:"repetition",status:"warn",reason:"quality.repetition.reason",detail:`${(l*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,l=/[.!?\n)\]"]$/.test(t.trim());if(n>.9&&!l)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,l){const a=[wn(s),$n(s),Sn(s),_n(s),Cn(s,o,n,l)];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),l=e.filter(u=>u.role==="system"),a=o.slice(0,-n),c=o.slice(-n),i=t.existingSummary?`Previous summary:
|
|
17
17
|
${t.existingSummary}
|
|
18
18
|
|
|
19
19
|
New messages to incorporate:
|
|
20
|
-
`:"",p=await Nn(t.model,
|
|
21
|
-
`));p&&(s=p,e=[...
|
|
22
|
-
${p}`},...c])}if(t.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),
|
|
23
|
-
${p.map(
|
|
20
|
+
`:"",p=await Nn(t.model,i+a.map(u=>`${u.role}: ${u.content}`).join(`
|
|
21
|
+
`));p&&(s=p,e=[...l,{role:"system",content:`Summary of earlier conversation:
|
|
22
|
+
${p}`},...c])}if(t.settings.slidingWindow.enabled){const n=e.filter(c=>c.role==="system"),l=e.filter(c=>c.role!=="system"),a=t.settings.slidingWindow.maxMessages;if(l.length>a){const c=l.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 l=e.filter(c=>c.role==="system"),a=e.filter(c=>c.role!=="system");e=[...l,{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 Pe.embed({model:s,input:o}),l=[];for(let a=0;a<e.length;a++){const c=n.embeddings[a];if(!c)continue;const i=e[a];l.push({id:be(),conversationId:t,role:i.role,content:i.content,embedding:c,timestamp:i.timestamp})}await Jt.storeMessages(l)}async function Nn(t,e){try{return(await Pe.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(g=>g.role==="user"),l=n[n.length-1];if(!l)return null;const c=(await Pe.embed({model:s,input:[l.content]})).embeddings[0];if(!c)return null;const p=(await Jt.search(c,o,t)).filter(g=>g.score>.5);return p.length===0?null:`Relevant messages from past conversations:
|
|
23
|
+
${p.map(g=>`[${g.message.role}, relevance: ${(g.score*100).toFixed(0)}%] ${g.message.content}`).join(`
|
|
24
24
|
|
|
25
25
|
`)}
|
|
26
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
|
|
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,
|
|
29
|
-
`).map(
|
|
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 D(t,e=""){let s=typeof t=="string"?t:t.source,o={replace:(n,l)=>{let a=typeof l=="string"?l:l.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|$))+/,Dn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Pn=/^ {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=D(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=D(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=D(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ht).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),On=D(/^(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=D("^ {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=D(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=D(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",as).getRegex(),gt={blockquote:Un,code:Dn,def:Fn,fences:Pn,heading:jn,hr:je,html:qn,lheading:os,list:On,newline:In,paragraph:as,table:ke,text:Ln},It=D("^ *([^\\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:D(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:D(`^ *(?: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:D(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,ls=/[^\s\p{P}\p{S}]/u,Kn=D(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ft).getRegex(),is=/(?!~)[\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=D(/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=D(us,"u").replace(/punct/g,et).getRegex(),so=D(us,"u").replace(/punct/g,is).getRegex(),ds="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",no=D(ds,"gu").replace(/notPunctSpace/g,ls).replace(/punctSpace/g,ft).replace(/punct/g,et).getRegex(),oo=D(ds,"gu").replace(/notPunctSpace/g,Jn).replace(/punctSpace/g,Qn).replace(/punct/g,is).getRegex(),ao=D("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ls).replace(/punctSpace/g,ft).replace(/punct/g,et).getRegex(),ro=D(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,cs).getRegex(),lo="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",io=D(lo,"gu").replace(/notPunctSpace/g,Yn).replace(/punctSpace/g,Xn).replace(/punct/g,cs).getRegex(),co=D(/\\(punct)/,"gu").replace(/punct/g,et).getRegex(),uo=D(/^<(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=D(mt).replace("(?:-->|$)","-->").getRegex(),ho=D("^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=D(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Ze).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ps=D(/^!?\[(label)\]\[(ref)\]/).replace("label",Ze).replace("ref",ht).getRegex(),hs=D(/^!?\[(ref)\](?:\[\])?/).replace("ref",ht).getRegex(),go=D("reflink|nolink(?!\\()","g").replace("reflink",ps).replace("nolink",hs).getRegex(),Dt=/[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:D(/^!?\[(label)\]\((.*?)\)/).replace("label",Ze).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ze).getRegex()},nt={...xt,emStrongRDelimAst:oo,emStrongLDelim:so,delLDelim:ro,delRDelim:io,url:D(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Dt).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:D(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Dt).getRegex()},xo={...nt,br:D(rs).replace("{2,}","*").getRegex(),text:D(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={"&":"&","<":"<",">":">",'"':""","'":"'"},Pt=t=>bo[t];function ue(t,e){if(e){if(J.escapeTest.test(t))return t.replace(J.escapeReplace,Pt)}else if(J.escapeTestNoEncode.test(t))return t.replace(J.escapeReplaceNoEncode,Pt);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,(l,a,c)=>{let i=!1,p=a;for(;--p>=0&&c[p]==="\\";)i=!i;return i?"|":" |"}),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 l=4-s%4;o+=" ".repeat(l),s+=l}else o+=n,s++;return o}function Lt(t,e,s,o,n){let l=e.href,a=e.title||null,c=t[1].replace(n.other.outputLinkReplace,"$1");o.state.inLink=!0;let i={type:t[0].charAt(0)==="!"?"image":"link",raw:s,href:l,title:a,text:c,tokens:o.inlineTokens(c)};return o.state.inLink=!1,i}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(l=>{let a=l.match(s.other.beginningSpace);if(a===null)return l;let[c]=a;return c.length>=n.length?l.slice(n.length):l}).join(`
|
|
30
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
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
32
|
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=Ne(e[0],`
|
|
33
33
|
`).split(`
|
|
34
|
-
`),o="",n="",
|
|
34
|
+
`),o="",n="",l=[];for(;s.length>0;){let a=!1,c=[],i;for(i=0;i<s.length;i++)if(this.rules.other.blockquoteStart.test(s[i]))c.push(s[i]),a=!0;else if(!a)c.push(s[i]);else break;s=s.slice(i);let p=c.join(`
|
|
35
35
|
`),u=p.replace(this.rules.other.blockquoteSetextReplace,`
|
|
36
36
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
37
37
|
${p}`:p,n=n?`${n}
|
|
38
|
-
${u}`:u;let
|
|
38
|
+
${u}`:u;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,l,!0),this.lexer.state.top=g,s.length===0)break;let v=l.at(-1);if(v?.type==="code")break;if(v?.type==="blockquote"){let C=v,_=C.raw+`
|
|
39
39
|
`+s.join(`
|
|
40
|
-
`),z=this.blockquote(
|
|
40
|
+
`),z=this.blockquote(_);l[l.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(v?.type==="list"){let C=v,_=C.raw+`
|
|
41
41
|
`+s.join(`
|
|
42
|
-
`),z=this.list(
|
|
43
|
-
`);continue}}return{type:"blockquote",raw:o,tokens:
|
|
44
|
-
`,1)[0],e[1].length),
|
|
45
|
-
`,1)[0],C=!
|
|
46
|
-
`,t=t.substring(
|
|
47
|
-
`,1)[0],O;if(
|
|
48
|
-
`+O.slice(
|
|
49
|
-
`+
|
|
50
|
-
`,t=t.substring(G.length+1),
|
|
51
|
-
`):[],
|
|
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
|
|
42
|
+
`),z=this.list(_);l[l.length-1]=z,o=o.substring(0,o.length-v.raw.length)+z.raw,n=n.substring(0,n.length-C.raw.length)+z.raw,s=_.substring(l.at(-1).raw.length).split(`
|
|
43
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:l,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 l=this.rules.other.listItemRegex(s),a=!1;for(;t;){let i=!1,p="",u="";if(!(e=l.exec(t))||this.rules.block.hr.test(t))break;p=e[0],t=t.substring(p.length);let g=yo(e[2].split(`
|
|
44
|
+
`,1)[0],e[1].length),v=t.split(`
|
|
45
|
+
`,1)[0],C=!g.trim(),_=0;if(this.options.pedantic?(_=2,u=g.trimStart()):C?_=e[1].length+1:(_=g.search(this.rules.other.nonSpaceChar),_=_>4?1:_,u=g.slice(_),_+=e[1].length),C&&this.rules.other.blankLine.test(v)&&(p+=v+`
|
|
46
|
+
`,t=t.substring(v.length+1),i=!0),!i){let z=this.rules.other.nextBulletRegex(_),b=this.rules.other.hrRegex(_),I=this.rules.other.fencesBeginRegex(_),H=this.rules.other.headingBeginRegex(_),V=this.rules.other.htmlBeginRegex(_),K=this.rules.other.blockquoteBeginRegex(_);for(;t;){let G=t.split(`
|
|
47
|
+
`,1)[0],O;if(v=G,this.options.pedantic?(v=v.replace(this.rules.other.listReplaceNesting," "),O=v):O=v.replace(this.rules.other.tabCharGlobal," "),I.test(v)||H.test(v)||V.test(v)||K.test(v)||z.test(v)||b.test(v))break;if(O.search(this.rules.other.nonSpaceChar)>=_||!v.trim())u+=`
|
|
48
|
+
`+O.slice(_);else{if(C||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||I.test(g)||H.test(g)||b.test(g))break;u+=`
|
|
49
|
+
`+v}C=!v.trim(),p+=G+`
|
|
50
|
+
`,t=t.substring(G.length+1),g=O.slice(_)}}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 i of n.items){if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),i.task){if(i.text=i.text.replace(this.rules.other.listReplaceTask,""),i.tokens[0]?.type==="text"||i.tokens[0]?.type==="paragraph"){i.tokens[0].raw=i.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),i.tokens[0].text=i.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(i.raw);if(p){let u={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};i.checked=u.checked,n.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=u.raw+i.tokens[0].raw,i.tokens[0].text=u.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(u)):i.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):i.tokens.unshift(u)}}if(!n.loose){let p=i.tokens.filter(g=>g.type==="space"),u=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));n.loose=u}}if(n.loose)for(let i of n.items){i.loose=!0;for(let p of i.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
|
+
`):[],l={type:"table",raw:e[0],header:[],align:[],rows:[]};if(s.length===o.length){for(let a of o)this.rules.other.tableAlignRight.test(a)?l.align.push("right"):this.rules.other.tableAlignCenter.test(a)?l.align.push("center"):this.rules.other.tableAlignLeft.test(a)?l.align.push("left"):l.align.push(null);for(let a=0;a<s.length;a++)l.header.push({text:s[a],tokens:this.lexer.inline(s[a]),header:!0,align:l.align[a]});for(let a of n)l.rows.push(Bt(a,l.header.length).map((c,i)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:l.align[i]})));return l}}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 l=Ne(s.slice(0,-1),"\\");if((s.length-l.length)%2===0)return}else{let l=vo(e[2],"()");if(l===-2)return;if(l>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+l;e[2]=e[2].substring(0,l),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let o=e[2],n="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(o);l&&(o=l[1],n=l[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 l=s[0].charAt(0);return{type:"text",raw:l,text:l}}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,l,a,c=n,i=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(l=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!l)continue;if(a=[...l].length,o[3]||o[4]){c+=a;continue}else if((o[5]||o[6])&&n%3&&!((n+a)%3)){i+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+i);let u=[...o[0]][0].length,g=t.slice(0,n+o.index+u+a);if(Math.min(n,a)%2){let C=g.slice(1,-1);return{type:"em",raw:g,text:C,tokens:this.lexer.inlineTokens(C)}}let v=g.slice(2,-2);return{type:"strong",raw:g,text:v,tokens:this.lexer.inlineTokens(v)}}}}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,l,a,c=n,i=this.rules.inline.delRDelim;for(i.lastIndex=0,e=e.slice(-1*t.length+n);(o=i.exec(e))!=null;){if(l=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!l||(a=[...l].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),g=u.slice(n,-n);return{type:"del",raw:u,text:g,tokens:this.lexer.inlineTokens(g)}}}}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
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
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
55
|
`)?"":`
|
|
@@ -57,44 +57,44 @@ ${u}`:u;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
57
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
58
|
`)?"":`
|
|
59
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
|
|
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 l=e;if(this.options.extensions?.startBlock){let a=1/0,c=e.slice(1),i;this.options.extensions.startBlock.forEach(p=>{i=p.call({lexer:this},c),typeof i=="number"&&i>=0&&(a=Math.min(a,i))}),a<1/0&&a>=0&&(l=e.substring(0,a+1))}if(this.state.top&&(n=this.tokenizer.paragraph(l))){let a=s.at(-1);o&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
61
61
|
`)?"":`
|
|
62
62
|
`)+n.raw,a.text+=`
|
|
63
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n),o=
|
|
63
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):s.push(n),o=l.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
64
|
`)?"":`
|
|
65
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
|
|
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 i=Object.keys(this.tokens.links);if(i.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)i.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 l;for(;(n=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)l=n[2]?n[2].length:0,o=o.slice(0,n.index+l)+"["+"a".repeat(n[0].length-l-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 i;if(this.options.extensions?.inline?.some(u=>(i=u.call({lexer:this},e,s))?(e=e.substring(i.raw.length),s.push(i),!0):!1))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let u=s.at(-1);i.type==="text"&&u?.type==="text"?(u.raw+=i.raw,u.text+=i.text):s.push(i);continue}if(i=this.tokenizer.emStrong(e,o,c)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.del(e,o,c)){e=e.substring(i.raw.length),s.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),s.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),s.push(i);continue}let p=e;if(this.options.extensions?.startInline){let u=1/0,g=e.slice(1),v;this.options.extensions.startInline.forEach(C=>{v=C.call({lexer:this},g),typeof v=="number"&&v>=0&&(u=Math.min(u,v))}),u<1/0&&u>=0&&(p=e.substring(0,u+1))}if(i=this.tokenizer.inlineText(p)){e=e.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(c=i.raw.slice(-1)),a=!0;let u=s.at(-1);u?.type==="text"?(u.raw+=i.raw,u.text+=i.text):s.push(i);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
67
|
`;return o?'<pre><code class="language-'+ue(o)+'">'+(s?n:ue(n,!0))+`</code></pre>
|
|
68
68
|
`:"<pre><code>"+(s?n:ue(n,!0))+`</code></pre>
|
|
69
69
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
70
70
|
${this.parser.parse(t)}</blockquote>
|
|
71
71
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
72
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",
|
|
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",l=e&&s!==1?' start="'+s+'"':"";return"<"+n+l+`>
|
|
74
74
|
`+o+"</"+n+`>
|
|
75
75
|
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
76
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
|
|
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 l=t.rows[n];s="";for(let a=0;a<l.length;a++)s+=this.tablecell(l[a]);o+=this.tablerow({text:s})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
78
78
|
<thead>
|
|
79
79
|
`+e+`</thead>
|
|
80
80
|
`+o+`</table>
|
|
81
81
|
`}tablerow({text:t}){return`<tr>
|
|
82
82
|
${t}</tr>
|
|
83
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
|
|
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=
|
|
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 l='<a href="'+t+'"';return e&&(l+=' title="'+ue(e)+'"'),l+=">"+o+"</a>",l}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 l=`<img src="${t}" alt="${ue(s)}"`;return e&&(l+=` title="${ue(e)}"`),l+=">",l}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}},le=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 l=n;switch(l.type){case"space":{s+=this.renderer.space(l);break}case"hr":{s+=this.renderer.hr(l);break}case"heading":{s+=this.renderer.heading(l);break}case"code":{s+=this.renderer.code(l);break}case"table":{s+=this.renderer.table(l);break}case"blockquote":{s+=this.renderer.blockquote(l);break}case"list":{s+=this.renderer.list(l);break}case"checkbox":{s+=this.renderer.checkbox(l);break}case"html":{s+=this.renderer.html(l);break}case"def":{s+=this.renderer.def(l);break}case"paragraph":{s+=this.renderer.paragraph(l);break}case"text":{s+=this.renderer.text(l);break}default:{let a='Token with "'+l.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 l=e[n];if(this.options.extensions?.renderers?.[l.type]){let c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){o+=c||"";continue}}let a=l;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?le.parse:le.parseInline}},ms=class{defaults=ut();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=le;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 l of n.header)s=s.concat(this.walkTokens(l.tokens,e));for(let l of n.rows)for(let a of l)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(l=>{let a=n[l].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 l=e.renderers[n.name];l?e.renderers[n.name]=function(...a){let c=n.renderer.apply(this,a);return c===!1&&(c=l.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 l=e[n.level];l?l.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 l in s.renderer){if(!(l in n))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let a=l,c=s.renderer[a],i=n[a];n[a]=(...p)=>{let u=c.apply(n,p);return u===!1&&(u=i.apply(n,p)),u||""}}o.renderer=n}if(s.tokenizer){let n=this.defaults.tokenizer||new Ke(this.defaults);for(let l in s.tokenizer){if(!(l in n))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let a=l,c=s.tokenizer[a],i=n[a];n[a]=(...p)=>{let u=c.apply(n,p);return u===!1&&(u=i.apply(n,p)),u}}o.tokenizer=n}if(s.hooks){let n=this.defaults.hooks||new ze;for(let l in s.hooks){if(!(l in n))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let a=l,c=s.hooks[a],i=n[a];ze.passThroughHooks.has(l)?n[a]=p=>{if(this.defaults.async&&ze.passThroughHooksRespectAsync.has(l))return(async()=>{let g=await c.call(n,p);return i.call(n,g)})();let u=c.call(n,p);return i.call(n,u)}:n[a]=(...p)=>{if(this.defaults.async)return(async()=>{let g=await c.apply(n,p);return g===!1&&(g=await i.apply(n,p)),g})();let u=c.apply(n,p);return u===!1&&(u=i.apply(n,p)),u}}o.hooks=n}if(s.walkTokens){let n=this.defaults.walkTokens,l=s.walkTokens;o.walkTokens=function(a){let c=[];return c.push(l.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 le.parse(t,e??this.defaults)}parseMarkdown(t){return(e,s)=>{let o={...s},n={...this.defaults,...o},l=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&o.async===!1)return l(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 l(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return l(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),i=n.hooks?await n.hooks.processAllTokens(c):c;n.walkTokens&&await Promise.all(this.walkTokens(i,n.walkTokens));let p=await(n.hooks?await n.hooks.provideParser():t?le.parse:le.parseInline)(i,n);return n.hooks?await n.hooks.postprocess(p):p})().catch(l);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?le.parse:le.parseInline)(a,n);return n.hooks&&(c=n.hooks.postprocess(c)),c}catch(a){return l(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=le;F.parser=le.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;le.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(),m("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(),m("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(),m("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(),m("div",To,[Te(d(t.content)+" ",1),t.isThinking?(h(),m("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}=Gs(Ds(e,"sessionId")),n=B(()=>s.getTokens(e.sessionId)),l=B(()=>{const a=n.value,c=[];let i=!1,p="";for(const u of a){if(p+=u.text,!i&&p.includes("<think>")){i=!0;const g=p.split("<think>")[0]??"";g&&c.length===0&&c.push({...u,text:g});continue}if(i){if(p.includes("</think>")){i=!1;const g=p.split("</think>").pop()??"",v=u.text;if(g.endsWith(v)&&v.includes("</think>")){const C=v.split("</think>").pop()??"";C&&c.push({...u,text:C})}}continue}c.push(u)}return c});return(a,c)=>(h(),m("div",Ao,[(h(!0),m(q,null,Q(l.value,i=>(h(),m("span",{key:i.id,class:"inline",style:Is({borderBottom:`2px solid ${x(o)(i.confidence)}`})},d(i.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"},Do={class:"truncate"},Po={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,l)=>t.attachments.length>0?(h(),m("div",zo,[(h(!0),m(q,null,Q(t.attachments.filter(a=>a.type==="image"&&a.content),a=>(h(),m("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",Do,d(a.name),1),r("span",null,d(x(st)(a.sizeBytes)),1)])]))),128)),r("div",Po,[(h(!0),m(q,null,Q(t.attachments.filter(a=>a.type==="document"),a=>(h(),m("div",{key:a.id,class:"flex items-center gap-1.5 rounded-md bg-white/10 px-2 py-1 text-[11px]"},[P(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(Ps,{to:"body"},[P(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(),m("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:l[0]||(l[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},[P(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,l)=>o.value?(h(),m("div",Oo,[(h(!0),m(q,null,Q(s.value,a=>(h(),m("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=["title"],Jo={class:"text-[10px] opacity-50"},Xo=se({__name:"ChatBubble",props:{message:{}},setup(t){const e=t,s=Xe(),o=Qs(),n=lt(),l=ts(),a=B(()=>l.getReport(e.message.id)),c=B(()=>e.message.sessionId?n.getMetrics(e.message.sessionId):null),i=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"),g=B(()=>c.value?c.value.loadDurationMs>500:!1),v=B(()=>{if(u.value){if(e.message.attachments?.length){const z=`
|
|
86
86
|
|
|
87
87
|
---
|
|
88
88
|
|
|
89
|
-
`,
|
|
89
|
+
`,b=e.message.content.lastIndexOf(z);if(b!==-1)return e.message.content.slice(b+z.length)}return e.message.content}return e.message.isStreaming?"":e.message.content.replace(/<think>[\s\S]*?<\/think>/g,"").trim()}),C=B(()=>u.value||!v.value?"":$o(v.value)),_=B(()=>new Date(e.message.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}));return(z,b)=>(h(),m("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(),m(q,{key:0},[t.message.attachments?.length?(h(),Ee(Fo,{key:0,attachments:t.message.attachments},null,8,["attachments"])):N("",!0),r("p",Vo,d(v.value),1)],64)):(h(),m(q,{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"])):v.value?(h(),m("div",{key:2,class:"markdown-prose",innerHTML:C.value},null,8,Ho)):N("",!0),t.message.isStreaming&&!v.value?(h(),m("span",Go,[...b[0]||(b[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),i.value&&!t.message.isStreaming&&!a.value?(h(),m("div",Wo,d(z.$t("dashboard.bubble.truncatedWarning")),1)):N("",!0)],64)),!u.value&&!t.message.isStreaming&&c.value?(h(),m("div",Zo,[r("span",null,d(c.value.completionTokenCount)+" "+d(z.$t("dashboard.bubble.tokens")),1),b[2]||(b[2]=r("span",{class:"opacity-40"},"·",-1)),r("span",null,d(c.value.tokensPerSecond.toFixed(1))+" "+d(z.$t("dashboard.bubble.tokPerSec")),1),b[3]||(b[3]=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(z.$t("dashboard.bubble.ttft")),1),g.value?(h(),m(q,{key:0},[b[1]||(b[1]=r("span",{class:"opacity-40"},"·",-1)),r("span",{class:"text-warning",title:z.$t("dashboard.bubble.coldStart")},d(z.$t("dashboard.bubble.cold")),9,Ko)],64)):N("",!0),a.value&&a.value.overall!=="pass"?(h(),m("span",{key:1,class:E(["ml-1 inline-block h-1.5 w-1.5 rounded-full",a.value.overall==="fail"?"bg-error":"bg-warning"]),title:z.$t("quality.issuesDetected")},null,10,Qo)):N("",!0)])):N("",!0),P(Uo,{report:a.value},null,8,["report"]),r("div",{class:E(["mt-1",u.value?"text-end":""])},[r("span",Jo,d(_.value),1)],2)],2)],2))}}),Yo={key:0,class:"flex items-center justify-center"},ea={class:"text-center"},ta={class:"text-sm text-text-muted"},sa=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}),(l,a)=>(h(),m("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(),m("div",Yo,[r("div",ea,[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",ta,d(l.$t("dashboard.empty.startConversation")),1)])])):N("",!0),(h(!0),m(q,null,Q(t.messages,c=>(h(),Ee(Xo,{key:c.id,message:c},null,8,["message"]))),128))],2)],512))}}),na=new Set(["png","jpg","jpeg","gif","webp"]),oa=new Set(["pdf","docx","txt","md","csv"]);function gs(t){return t.split(".").pop()?.toLowerCase()??""}function rt(t){return na.has(gs(t))}function fs(t){return oa.has(gs(t))}function aa(t){return rt(t)||fs(t)}const ra=".pdf,.docx,.txt,.md,.csv,.png,.jpg,.jpeg,.gif,.webp",Ft=8e3;function la(){const t=A([]),e=B(()=>t.value.some(c=>c.status==="parsing"));async function s(c){for(const i of c){if(!aa(i.name))continue;const p={id:be(),name:i.name,type:rt(i.name)?"image":"document",mimeType:i.type,sizeBytes:i.size,status:"pending"};t.value.push(p),rt(i.name)?o(i,p):fs(i.name)&&n(i,p)}}function o(c,i){i.status="parsing";const p=i.id,u=new FileReader;u.onload=()=>{const g=t.value.find(v=>v.id===p);g&&(g.content=u.result,g.status="ready")},u.onerror=()=>{const g=t.value.find(v=>v.id===p);g&&(g.error="Failed to read image",g.status="error")},u.readAsDataURL(c)}async function n(c,i){i.status="parsing";const p=i.id;try{const u=Xs(c.name);if(!u){const C=t.value.find(_=>_.id===p);C&&(C.error="Unsupported format",C.status="error");return}let g=await Ys(c,u);g.length>Ft&&(g=g.slice(0,Ft)+`
|
|
90
90
|
|
|
91
|
-
[... truncated]`);const
|
|
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}
|
|
91
|
+
[... truncated]`);const v=t.value.find(C=>C.id===p);v&&(v.content=g,v.status="ready")}catch(u){const g=t.value.find(v=>v.id===p);g&&(g.error=u instanceof Error?u.message:"Parse failed",g.status="error")}}function l(c){t.value=t.value.filter(i=>i.id!==c)}function a(){t.value=[]}return{attachments:t,isProcessing:e,addFiles:s,removeAttachment:l,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"},ca={class:"p-1.5"},ua=["onMouseenter","onClick"],da={class:"shrink-0 font-mono text-xs text-accent"},pa={class:"truncate text-xs text-text-muted"},ha={class:"ms-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 text-[10px] text-text-muted"},ma=se({__name:"SlashCommandDropdown",props:{filter:{},visible:{type:Boolean}},emits:["select","close"],setup(t,{expose:e,emit:s}){const{t:o}=Vt(),n=t,l=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 i(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(),l("select",c.value[a.value]),!0):u.key==="Escape"?(u.preventDefault(),l("close"),!0):!1}e({handleKeydown:i});const p=B(()=>({chat:o("dashboard.slashCommands.chatConversation"),settings:o("dashboard.slashCommands.modelSettings"),navigation:o("dashboard.slashCommands.featuresNavigation")}));return(u,g)=>t.visible&&c.value.length>0?(h(),m("div",ia,[r("div",ca,[(h(!0),m(q,null,Q(c.value,(v,C)=>(h(),m("button",{key:v.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:_=>a.value=C,onClick:_=>u.$emit("select",v)},[r("span",da,"/"+d(v.name),1),r("span",pa,d(v.description),1),r("span",ha,d(p.value[v.category]??v.category),1)],42,ua))),128))])])):N("",!0)}}),ga={key:0,class:"flex flex-wrap gap-2 px-2.5 pb-1.5 pt-1"},fa=["src","alt"],xa={key:1,class:"text-text-muted"},ba={class:"max-w-[120px] truncate text-text-primary"},va={class:"text-text-muted"},ya={key:2,class:"h-3 w-3 animate-spin rounded-full border-2 border-accent border-t-transparent"},ka={key:3,class:"text-error",title:"Parse error"},wa=["onClick"],$a=se({__name:"AttachmentPreview",props:{attachments:{}},emits:["remove"],setup(t){return(e,s)=>t.attachments.length>0?(h(),m("div",ga,[(h(!0),m(q,null,Q(t.attachments,o=>(h(),m("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(),m("img",{key:0,src:o.content,alt:o.name,class:"h-6 w-6 rounded object-cover"},null,8,fa)):o.type==="document"?(h(),m("span",xa,[P(x(Xt),{class:"h-4 w-4"})])):N("",!0),r("span",ba,d(o.name),1),r("span",va,d(x(st)(o.sizeBytes)),1),o.status==="parsing"?(h(),m("span",ya)):o.status==="error"?(h(),m("span",ka,"!")):N("",!0),r("button",{class:"text-text-muted hover:text-error transition-colors",onClick:n=>e.$emit("remove",o.id)},[P(x(Je),{class:"h-3.5 w-3.5"})],8,wa)]))),128))])):N("",!0)}}),Sa={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"},_a={class:"text-sm text-accent"},Ca={class:"relative mx-auto max-w-3xl"},Ta=["accept"],Ma={class:"mx-auto flex max-w-3xl flex-col rounded-xl border border-border-default bg-surface transition-colors focus-within:border-accent"},Ra=["disabled","title"],Aa=["title"],Na=["disabled","title"],za=["disabled","placeholder"],Ea=["title"],Ia=["disabled","title"],Da=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=it(),l=A(""),a=A(null),c=A(null),i=A(null),p=A(!1),{attachments:u,isProcessing:g,addFiles:v,removeAttachment:C,clearAttachments:_}=la();Ht(()=>{n.fetchModels()});const z=B(()=>{const T=l.value;return T.startsWith("/")&&!T.includes(`
|
|
92
|
+
`)}),b=B(()=>{if(!z.value)return"";const T=l.value.indexOf(" ");return T===-1?l.value:l.value.slice(0,T)}),I=B(()=>{const T=l.value.trim().length>0,j=u.value.length>0;return(T||j)&&!g.value});function H(){a.value?.focus()}function V(T){z.value&&i.value&&i.value.handleKeydown(T)||T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),G())}function K(T){l.value=`/${T.name} `,a.value?.focus()}function G(){const T=l.value.trim();if(!(!T&&u.value.length===0)){if(T.startsWith("/")&&u.value.length===0){const j=T.indexOf(" "),ie=j===-1?T.slice(1):T.slice(1,j),U=j===-1?"":T.slice(j+1);o("command",ie,U)}else o("send",T,[...u.value]),_();l.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(){l.value=""}function ne(){l.value="/",a.value?.focus()}function ve(){c.value?.click()}function me(T){const j=T.target;j.files&&j.files.length>0&&(v(j.files),j.value="")}function ge(T){T.preventDefault(),p.value=!0}function f(){p.value=!1}function S(T){T.preventDefault(),p.value=!1,T.dataTransfer?.files&&T.dataTransfer.files.length>0&&v(T.dataTransfer.files)}function k(T){const j=T.clipboardData?.items;if(!j)return;const ie=[];for(const U of j)if(U.type.startsWith("image/")){const fe=U.getAsFile();fe&&ie.push(fe)}ie.length>0&&(T.preventDefault(),v(ie))}return(T,j)=>(h(),m("div",{class:"relative border-t border-border-default bg-surface-raised px-4 py-3",onDragover:ge,onDragleave:f,onDrop:S},[p.value?(h(),m("div",Sa,[r("span",_a,d(T.$t("dashboard.dropZone")),1)])):N("",!0),r("div",Ca,[P(ma,{ref_key:"dropdownRef",ref:i,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(ra),class:"hidden",onChange:me},null,40,Ta),r("div",Ma,[P($a,{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},[P(x(sn),{class:"h-4 w-4"}),t.isVisionModel?(h(),m("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")},[P(x(Bs),{class:"h-2.5 w-2.5","stroke-width":3})],8,Aa)):N("",!0)],8,Ra),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},[P(x(on),{class:"h-4 w-4"})],8,Na),W(r("textarea",{ref_key:"textareaRef",ref:a,"onUpdate:modelValue":j[0]||(j[0]=ie=>l.value=ie),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:k},null,40,za),[[X,l.value]]),t.isStreaming?(h(),m("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]=ie=>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,Ea)):(h(),m("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},[P(x(nn),{class:"h-4 w-4 rtl:-scale-x-100"})],8,Ia))],2)])],32))}}),Pa={class:"flex h-full flex-col overflow-y-auto"},ja={class:"space-y-5 p-4 pb-12"},Ba={class:"mb-1.5 block text-xs font-medium text-text-secondary"},La=["placeholder"],Fa={class:"mt-1 text-[10px] text-text-muted"},Oa={class:"flex items-center justify-between"},qa={class:"flex items-center gap-2"},Ua={class:"text-xs font-medium text-text-secondary"},Va=["disabled"],Ha={key:0,class:"text-[10px] text-text-muted -mt-3"},Ga={key:1,class:"text-[10px] text-text-muted -mt-3"},Wa={class:"mb-1.5 flex items-center justify-between"},Za={class:"text-xs font-medium text-text-secondary"},Ka={class:"text-xs text-text-muted"},Qa={class:"mt-0.5 flex justify-between text-[10px] text-text-muted"},Ja={class:"mb-1.5 flex items-center justify-between"},Xa={class:"text-xs font-medium text-text-secondary"},Ya={class:"text-xs text-text-muted"},er=["placeholder"],tr={class:"mt-1 text-[10px] text-text-muted"},sr={class:"mb-1.5 flex items-center justify-between"},nr={class:"text-xs font-medium text-text-secondary"},or={class:"text-xs text-text-muted"},ar={class:"mt-1 text-[10px] text-text-muted"},rr={key:2,class:"space-y-4 ps-1"},lr={class:"mb-1.5 flex items-center justify-between"},ir={class:"text-xs font-medium text-text-secondary"},cr={class:"text-xs text-text-muted"},ur={class:"mt-1 text-[10px] text-text-muted"},dr={class:"mb-1.5 flex items-center justify-between"},pr={class:"text-xs font-medium text-text-secondary"},hr={class:"text-xs text-text-muted"},mr={class:"mt-1 text-[10px] text-text-muted"},gr={class:"mb-1.5 flex items-center justify-between"},fr={class:"text-xs font-medium text-text-secondary"},xr={class:"text-xs text-text-muted"},br={class:"mt-1 text-[10px] text-text-muted"},vr={class:"mb-1.5 flex items-center justify-between"},yr={class:"text-xs font-medium text-text-secondary"},kr={class:"text-xs text-text-muted"},wr={value:0},$r={value:1},Sr={value:2},_r={class:"mt-1 text-[10px] text-text-muted"},Cr={class:"mb-1.5 flex items-center justify-between"},Tr={class:"text-xs font-medium text-text-secondary"},Mr={class:"text-xs text-text-muted"},Rr=["placeholder"],Ar={class:"mt-1 text-[10px] text-text-muted"},Nr={class:"mb-1.5 block text-xs font-medium text-text-secondary"},zr=["placeholder"],Er={class:"mt-1 text-[10px] text-text-muted"},Ir={key:0,class:"ms-1 text-accent"},Dr={key:0,class:"ps-1 space-y-2"},Pr={key:0,class:"space-y-1"},jr=["onClick"],Br={key:1,class:"text-[10px] text-text-muted px-2"},Lr={key:0,class:"ms-1 text-accent"},Fr={key:4,class:"space-y-4 ps-1"},Or={class:"flex items-center justify-between"},qr={class:"text-xs font-medium text-text-secondary"},Ur={class:"text-[10px] text-text-muted"},Vr={key:0},Hr={class:"mb-1 flex items-center justify-between"},Gr={class:"text-[10px] text-text-muted"},Wr={class:"text-[10px] text-text-muted"},Zr={class:"flex items-center justify-between"},Kr={class:"text-xs font-medium text-text-secondary"},Qr={class:"text-[10px] text-text-muted"},Jr={key:1},Xr={class:"mb-1 flex items-center justify-between"},Yr={class:"text-[10px] text-text-muted"},el={class:"text-[10px] text-text-muted"},tl={class:"flex items-center justify-between"},sl={class:"text-xs font-medium text-text-secondary"},nl={class:"text-[10px] text-text-muted"},ol={key:2,class:"space-y-1"},al={class:"flex-1 text-text-secondary"},rl=["onClick"],ll={class:"flex items-center justify-between"},il={class:"text-xs font-medium text-text-secondary"},cl={class:"text-[10px] text-text-muted"},ul={key:3,class:"space-y-2"},dl={class:"mb-1 block text-[10px] text-text-muted"},pl={value:"",disabled:""},hl=["value"],ml={key:0,class:"rounded-lg border border-accent/20 bg-accent/5 p-2"},gl={class:"mb-2 text-[10px] text-accent"},fl={class:"space-y-1.5"},xl={class:"min-w-0 flex-1"},bl={class:"truncate text-[11px] font-mono text-text-primary"},vl={class:"text-[9px] text-text-muted"},yl=["disabled","onClick"],kl={key:0,class:"mt-2 text-[9px] text-text-muted"},wl={class:"mb-1 flex items-center justify-between"},$l={class:"text-[10px] text-text-muted"},Sl={class:"text-[10px] text-text-muted"},_l=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),l=A(s.modelValue.options.temperature??.7),a=A(s.modelValue.options.num_predict??-1),c=A(s.modelValue.options.num_ctx??4096),i=A(s.modelValue.options.top_p??.9),p=A(s.modelValue.options.top_k??40),u=A(s.modelValue.options.repeat_penalty??1.1),g=A(s.modelValue.options.seed??-1),v=A(s.modelValue.options.stop?.join(", ")??""),C=A(s.modelValue.options.mirostat??0);te(()=>s.modelValue.options,f=>{l.value=f.temperature??.7,a.value=f.num_predict??-1,c.value=f.num_ctx??4096,i.value=f.top_p??.9,p.value=f.top_k??40,u.value=f.repeat_penalty??1.1,g.value=f.seed??-1,v.value=f.stop?.join(", ")??"",C.value=f.mirostat??0},{deep:!0}),te([n,l,a,c,i,p,u,g,v,C],()=>{const f=v.value.split(",").map(S=>S.trim()).filter(Boolean);o("update:modelValue",{systemPrompt:n.value,options:{temperature:l.value,num_predict:a.value===-1?void 0:a.value,num_ctx:c.value,top_p:i.value,top_k:p.value,repeat_penalty:u.value,seed:g.value===-1?void 0:g.value,stop:f.length>0?f:void 0,mirostat:C.value}})},{deep:!0}),te(()=>s.modelValue,f=>{n.value=f.systemPrompt,l.value=f.options.temperature??.7,a.value=f.options.num_predict??-1,c.value=f.options.num_ctx??4096,i.value=f.options.top_p??.9,p.value=f.options.top_k??40,u.value=f.options.repeat_penalty??1.1,g.value=f.options.seed??-1,C.value=f.options.mirostat??0});const _=ct(),z=Gt(),b=es(),I=it(),H=Qt(),V=B(()=>I.supportsTools(s.selectedModel));te(()=>s.selectedModel,f=>{f&&!I.supportsTools(f)&&_.enabledTools.length>0&&_.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 Pe.pullModel(f,(S,k,T)=>{if(k&&T){const j=Math.round(k/T*100);ne.value=`${S} ${j}%`}else ne.value=S}),ne.value="Done!",await I.fetchModels(),b.settings.ragMemory.embeddingModel=f}catch(S){ne.value=`Failed: ${S instanceof Error?S.message:"Unknown error"}`}finally{he.value=!1,setTimeout(()=>{ne.value="",ve.value=""},3e3)}}return(f,S)=>(h(),m("div",Pa,[r("div",ja,[r("div",null,[r("label",Ba,d(f.$t("dashboard.settings.systemPrompt")),1),W(r("textarea",{"onUpdate:modelValue":S[0]||(S[0]=k=>n.value=k),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,La),[[X,n.value]]),r("p",Fa,d(f.$t("dashboard.settings.systemPromptHint")),1)]),r("div",Oa,[r("div",qa,[r("span",Ua,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:S[1]||(S[1]=k=>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,Va)]),x(H).readyDocuments.length>0?(h(),m("p",Ha,[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:S[2]||(S[2]=k=>x(z).push("/rag"))},d(f.$t("dashboard.settings.manage")),1)])):(h(),m("p",Ga,[Te(d(f.$t("dashboard.settings.noDocumentsIngested"))+" · ",1),r("button",{class:"text-accent hover:underline",onClick:S[3]||(S[3]=k=>x(z).push("/rag"))},d(f.$t("dashboard.settings.addDocuments")),1)])),r("div",null,[r("div",Wa,[r("label",Za,d(f.$t("dashboard.settings.temperature")),1),r("span",Ka,d(l.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":S[4]||(S[4]=k=>l.value=k),type:"range",min:"0",max:"2",step:"0.05",class:"w-full accent-accent"},null,512),[[X,l.value,void 0,{number:!0}]]),r("div",Qa,[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",Ja,[r("label",Xa,d(f.$t("dashboard.settings.maxTokens")),1),r("span",Ya,d(a.value===-1?f.$t("dashboard.settings.unlimited"):a.value),1)]),W(r("input",{"onUpdate:modelValue":S[5]||(S[5]=k=>a.value=k),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,er),[[X,a.value,void 0,{number:!0}]]),r("p",tr,d(f.$t("dashboard.settings.maxTokensHint")),1)]),r("div",null,[r("div",sr,[r("label",nr,d(f.$t("dashboard.settings.contextWindow")),1),r("span",or,d(c.value.toLocaleString()),1)]),W(r("select",{"onUpdate:modelValue":S[6]||(S[6]=k=>c.value=k),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"},[...S[25]||(S[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",ar,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:S[7]||(S[7]=k=>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(),m("div",rr,[r("div",null,[r("div",lr,[r("label",ir,d(f.$t("dashboard.settings.topP")),1),r("span",cr,d(i.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":S[8]||(S[8]=k=>i.value=k),type:"range",min:"0",max:"1",step:"0.05",class:"w-full accent-accent"},null,512),[[X,i.value,void 0,{number:!0}]]),r("p",ur,d(f.$t("dashboard.settings.topPHint")),1)]),r("div",null,[r("div",dr,[r("label",pr,d(f.$t("dashboard.settings.topK")),1),r("span",hr,d(p.value),1)]),W(r("input",{"onUpdate:modelValue":S[9]||(S[9]=k=>p.value=k),type:"range",min:"1",max:"100",step:"1",class:"w-full accent-accent"},null,512),[[X,p.value,void 0,{number:!0}]]),r("p",mr,d(f.$t("dashboard.settings.topKHint")),1)]),r("div",null,[r("div",gr,[r("label",fr,d(f.$t("dashboard.settings.repeatPenalty")),1),r("span",xr,d(u.value.toFixed(2)),1)]),W(r("input",{"onUpdate:modelValue":S[10]||(S[10]=k=>u.value=k),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",br,d(f.$t("dashboard.settings.repeatPenaltyHint")),1)]),r("div",null,[r("div",vr,[r("label",yr,d(f.$t("dashboard.settings.mirostat")),1),r("span",kr,d(C.value===0?f.$t("dashboard.settings.mirostatOff"):`v${C.value}`),1)]),W(r("select",{"onUpdate:modelValue":S[11]||(S[11]=k=>C.value=k),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",wr,d(f.$t("dashboard.settings.mirostatDisabled")),1),r("option",$r,d(f.$t("dashboard.settings.mirostatV1")),1),r("option",Sr,d(f.$t("dashboard.settings.mirostatV2")),1)],512),[[tt,C.value,void 0,{number:!0}]]),r("p",_r,d(f.$t("dashboard.settings.mirostatHint")),1)]),r("div",null,[r("div",Cr,[r("label",Tr,d(f.$t("dashboard.settings.seed")),1),r("span",Mr,d(g.value===-1?f.$t("dashboard.settings.seedRandom"):g.value),1)]),W(r("input",{"onUpdate:modelValue":S[12]||(S[12]=k=>g.value=k),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,Rr),[[X,g.value,void 0,{number:!0}]]),r("p",Ar,d(f.$t("dashboard.settings.seedHint")),1)]),r("div",null,[r("label",Nr,d(f.$t("dashboard.settings.stopSequences")),1),W(r("input",{"onUpdate:modelValue":S[13]||(S[13]=k=>v.value=k),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,zr),[[X,v.value]]),r("p",Er,d(f.$t("dashboard.settings.stopSequencesHint")),1)])])):N("",!0),V.value?(h(),m(q,{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:S[14]||(S[14]=k=>G.value=!G.value)},[r("span",null,[Te(d(f.$t("dashboard.settings.tools"))+" ",1),x(_).enabledDefinitions.length>0?(h(),m("span",Ir," ("+d(x(_).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(),m("div",Dr,[x(_).allTools.length>0?(h(),m("div",Pr,[(h(!0),m(q,null,Q(x(_).allTools,k=>(h(),m("div",{key:k.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",k.enabled?"bg-accent":"bg-surface-overlay"]),onClick:T=>x(_).toggleEnabled(k.id)},[r("span",{class:E(["block h-3 w-3 rounded-full bg-white transition-transform",k.enabled?"translate-x-3.5":"translate-x-0.5"])},null,2)],10,jr),r("span",{class:E(["font-mono",k.enabled?"text-text-primary":"text-text-muted"])},d(k.definition.function.name),3)]))),128))])):(h(),m("p",Br,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:S[15]||(S[15]=k=>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:S[16]||(S[16]=k=>O.value=!O.value)},[r("span",null,[Te(d(f.$t("dashboard.memory.memory"))+" ",1),x(b).factCount>0?(h(),m("span",Lr," ("+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(),m("div",Fr,[r("div",Or,[r("div",null,[r("p",qr,d(f.$t("dashboard.memory.slidingWindow")),1),r("p",Ur,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:S[17]||(S[17]=k=>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(),m("div",Vr,[r("div",Hr,[r("label",Gr,d(f.$t("dashboard.memory.maxMessages")),1),r("span",Wr,d(x(b).settings.slidingWindow.maxMessages),1)]),W(r("input",{"onUpdate:modelValue":S[18]||(S[18]=k=>x(b).settings.slidingWindow.maxMessages=k),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",Zr,[r("div",null,[r("p",Kr,d(f.$t("dashboard.memory.autoSummarize")),1),r("p",Qr,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:S[19]||(S[19]=k=>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(),m("div",Jr,[r("div",Xr,[r("label",Yr,d(f.$t("dashboard.memory.triggerAfter")),1),r("span",el,d(x(b).settings.autoSummarize.triggerThreshold)+" "+d(f.$t("dashboard.memory.messages")),1)]),W(r("input",{"onUpdate:modelValue":S[20]||(S[20]=k=>x(b).settings.autoSummarize.triggerThreshold=k),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",tl,[r("div",null,[r("p",sl,d(f.$t("dashboard.memory.userMemories")),1),r("p",nl,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:S[21]||(S[21]=k=>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(),m("div",ol,[(h(!0),m(q,null,Q(x(b).facts,k=>(h(),m("div",{key:k.id,class:"flex items-center gap-2 rounded-md bg-surface px-2 py-1 text-[11px]"},[r("span",al,d(k.content),1),r("button",{class:"shrink-0 text-text-muted hover:text-error transition-colors",onClick:T=>x(b).removeFact(k.id)},[P(x(Je),{class:"h-3 w-3"})],8,rl)]))),128))])):N("",!0),r("div",ll,[r("div",null,[r("p",il,d(f.$t("dashboard.memory.messageMemoryRag")),1),r("p",cl,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:S[22]||(S[22]=k=>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(),m("div",ul,[r("div",null,[r("label",dl,d(f.$t("dashboard.memory.embeddingModel")),1),W(r("select",{"onUpdate:modelValue":S[23]||(S[23]=k=>x(b).settings.ragMemory.embeddingModel=k),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",pl,d(f.$t("dashboard.memory.selectEmbeddingModel")),1),(h(!0),m(q,null,Q(x(I).embeddingModelNames,k=>(h(),m("option",{key:k,value:k},d(k)+" "+d(x(I).capabilityIcons(k)),9,hl))),128))],512),[[tt,x(b).settings.ragMemory.embeddingModel]])]),x(I).embeddingModelNames.length===0?(h(),m("div",ml,[r("p",gl,d(f.$t("dashboard.memory.noEmbeddingModels")),1),r("div",fl,[(h(),m(q,null,Q(me,k=>r("div",{key:k.name,class:"flex items-center gap-2"},[r("div",xl,[r("p",bl,d(k.name),1),r("p",vl,d(k.description)+" ("+d(k.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(k.name)},d(he.value&&ve.value===k.name?f.$t("dashboard.settings.pulling"):f.$t("dashboard.settings.pull")),9,yl)])),64))]),ne.value?(h(),m("p",kl,d(ne.value),1)):N("",!0)])):N("",!0),r("div",null,[r("div",wl,[r("label",$l,d(f.$t("dashboard.memory.retrieveTop")),1),r("span",Sl,d(x(b).settings.ragMemory.topK)+" "+d(f.$t("dashboard.memory.messages")),1)]),W(r("input",{"onUpdate:modelValue":S[24]||(S[24]=k=>x(b).settings.ragMemory.topK=k),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)])]))}}),Cl={class:"flex h-full flex-col"},Tl={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"},Ml={class:"flex items-start gap-3"},Rl={class:"max-w-md whitespace-pre-wrap text-sm text-text-primary"},Al={class:"flex items-center justify-between border-b border-border-default bg-surface-raised px-4 py-2"},Nl={class:"flex items-center gap-3"},zl={class:"relative"},El={key:0,class:"text-text-muted"},Il={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"},Dl=["onMousedown"],Pl={key:0,class:"flex items-center"},jl=["title"],Bl={class:"truncate"},Ll={class:"flex items-center gap-2"},Fl={class:"relative"},Ol={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"},ql={class:"flex flex-1 min-h-0"},Ul={key:0,class:"w-64 shrink-0 border-e border-border-default bg-surface-raised flex flex-col"},Vl={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},Hl={class:"text-xs font-medium text-text-secondary"},Gl={class:"flex-1 overflow-y-auto p-2"},Wl={key:0,class:"px-2 py-4 text-[10px] text-text-muted italic text-center"},Zl={key:1,class:"space-y-0.5"},Kl=["onClick"],Ql={key:0,class:"flex-1 min-w-0"},Jl=["onBlur","onKeydown"],Xl={class:"flex-1 min-w-0"},Yl={class:"truncate text-[11px]"},ei={class:"truncate text-[9px] text-text-muted"},ti={class:"hidden shrink-0 items-center gap-0.5 group-hover:flex"},si=["title","onClick"],ni=["title","onClick"],oi={class:"flex flex-1 flex-col min-w-0"},ai={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"},ri={class:"font-medium"},li={key:1,class:"w-72 shrink-0 border-s border-border-default bg-surface-raised"},ii={class:"flex items-center justify-between border-b border-border-default px-4 py-2"},ci={class:"text-xs font-medium text-text-secondary"},ui=se({__name:"ChatConversation",setup(t){const{t:e}=Vt(),s=Gt(),o=Wt(),n=it(),l=Xe(),a=Qt(),c=lt(),i=ct(),p=es(),u=Kt(),g=ts(),{isStreaming:v,currentSessionId:C,startChatStream:_,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 y=de.value;if(!y||y.messages.length===0)return;const $=JSON.stringify(y.messages,null,2),w=new Blob([$],{type:"application/json"}),M=URL.createObjectURL(w),R=document.createElement("a");R.href=M,R.download=`chat-${y.id}.json`,R.click(),URL.revokeObjectURL(M),O.value=!1}function ne(){const y=de.value;if(!y||y.messages.length===0)return;const $=y.messages.map(Y=>{const xe=Y.role.charAt(0).toUpperCase()+Y.role.slice(1),oe=new Date(Y.timestamp).toLocaleString();return`### ${xe}
|
|
93
93
|
*${oe}*
|
|
94
94
|
|
|
95
|
-
${Y.content}`})
|
|
95
|
+
${Y.content}`}),w=`# Chat Export — ${y.name}
|
|
96
96
|
|
|
97
|
-
${
|
|
97
|
+
${$.join(`
|
|
98
98
|
|
|
99
99
|
---
|
|
100
100
|
|
|
@@ -102,15 +102,15 @@ ${S.join(`
|
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
*Generated by LLMxRay — Local LLM Observatory*
|
|
105
|
-
`,M=new Blob([
|
|
105
|
+
`,M=new Blob([w],{type:"text/markdown"}),R=URL.createObjectURL(M),L=document.createElement("a");L.href=R,L.download=`chat-${y.id}.md`,L.click(),URL.revokeObjectURL(R),O.value=!1}function ve(){const y=de.value;if(!y||y.messages.length===0)return;const $=y.messages.map(L=>`[${L.role}] ${L.content}`).join(`
|
|
106
106
|
|
|
107
|
-
`)
|
|
107
|
+
`),w=new Blob([$],{type:"text/plain"}),M=URL.createObjectURL(w),R=document.createElement("a");R.href=M,R.download=`chat-${y.id}.txt`,R.click(),URL.revokeObjectURL(M),O.value=!1}const me=A(null),ge=A("");function f(y){o.setActiveConversation(y)}function S(y,$){me.value=y,ge.value=$}function k(y){const $=ge.value.trim();$&&o.renameConversation(y,$),me.value=null}function T(){me.value=null}function j(y,$){y.key==="Enter"?k($):y.key==="Escape"&&T()}function ie(y){const w=Date.now()-y,M=Math.floor(w/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(y).toLocaleDateString()}const U=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 y=Se.value??C.value;if(!y)return null;const $=l.sessionById(y);return $?.status==="error"&&$.error?$.error:null}),Se=B(()=>{const y=Be.value;for(let $=y.length-1;$>=0;$--)if(y[$].sessionId)return y[$].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 y=Le.value.trim();if(!y){Re.value=!1;return}de.value?o.renameConversation(de.value.id,y):_e.value=y,Re.value=!1}function vs(){Re.value=!1}function ys(y){y.key==="Enter"?kt():y.key==="Escape"&&vs()}Ht(async()=>{await n.fetchModels(),n.chatModelNames.length>0&&!b.value&&(b.value=n.chatModelNames[0]),await a.loadDocuments()}),te(b,y=>{if(!y)return;const $=n.getModelDefaults(y);Object.keys($).length>0&&(U.value={systemPrompt:U.value.systemPrompt,options:{...$}})}),te(()=>o.activeConversationId,async y=>{if(!y)return;const $=o.conversations.get(y);if($){$.model&&n.chatModelNames.includes($.model)&&(b.value=$.model);try{const w=await Fs.getSessionsByConversation(y);for(const M of w)l.sessionById(M.id)||(l.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}),l.linkSessionToConversation(M.id,y)),await u.loadTokens(M.id)}catch(w){console.error("Failed to restore sessions for conversation:",w)}}});async function wt(y,$=[]){if(!b.value)return;let w=o.activeConversationId;w||(w=o.createConversation(b.value),_e.value!==e("dashboard.conversation.untitled")&&o.renameConversation(w,_e.value),_e.value=e("dashboard.conversation.untitled"));const M=o.conversations.get(w);M&&M.model!==b.value&&(M.model=b.value);const R=$.filter(Z=>Z.type==="document"&&Z.content),L=$.filter(Z=>Z.type==="image"&&Z.content);let Y=y;R.length>0&&(Y=R.map(ee=>`[Attached: ${ee.name}]
|
|
108
108
|
${ee.content}`).join(`
|
|
109
109
|
|
|
110
110
|
`)+`
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
-
`+
|
|
114
|
+
`+y);const xe={id:be(),conversationId:w,role:"user",content:Y,timestamp:Date.now(),isStreaming:!1,attachments:$.length>0?$:void 0};o.addMessage(w,xe);const oe=be(),Fe={id:oe,conversationId:w,role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};o.addMessage(w,Fe);const pe=o.getMessagesAsOllamaFormat(w).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(U.value.systemPrompt.trim()&&pe.unshift({role:"system",content:U.value.systemPrompt.trim()}),V.value&&a.enabledDocuments.length>0)try{const Z=await a.getContextForQuery(y,b.value,5);Z&&pe.unshift({role:"system",content:Z})}catch{}let $t=pe;try{const Z=p.getSummary(w)?.summary,ee=await Rn({conversationId:w,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(w,ee.newSummary,ae.length)}}catch{}try{const Z={...de.value?.options,...U.value.options},ee=i.enabledDefinitions,ae=await _(b.value,$t,Z,ee.length>0?ee:void 0),_t=o.conversations.get(w)?.messages.find(ce=>ce.id===oe);_t&&(_t.sessionId=ae),l.linkSessionToConversation(ae,w);const Ts=te(()=>l.sessionById(ae)?.outputText,ce=>{ce!==void 0&&o.updateAssistantContent(w,oe,ce)}),Ct=w,Ms=y,Rs=te(()=>l.sessionById(ae)?.status,ce=>{if(ce==="completed"||ce==="error"||ce==="cancelled"){if(o.finalizeMessage(Ct,oe),v.value=!1,Ts(),Rs(),u.persistTokens(ae),ce==="completed"){const qe=l.sessionById(ae),As=(qe?.outputText??"").replace(/<think>[\s\S]*?<\/think>/g,"").trim(),Ns=c.getMetrics(ae),zs=Mn(oe,ae,As,Ns?.completionTokenCount??0,U.value.options.num_predict,qe?.doneReason);g.setReport(oe,zs)}if(ce==="completed"&&p.settings.ragMemory.enabled&&p.settings.ragMemory.embeddingModel){const qe=l.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(w,oe)}}function ks(){z()}function ws(){o.setActiveConversation(null),_e.value=e("dashboard.conversation.untitled")}function $s(y){s.push({name:"session",params:{id:y}})}function ye(y){fe.value=y,Me&&clearTimeout(Me),Me=setTimeout(()=>{fe.value=null},5e3)}function Ss(){fe.value=null,Me&&clearTimeout(Me)}const _s={systemPrompt:"",options:{}};async function Cs(y,$){const w=vn(y);if(!w){ye(`Unknown command: /${y}. 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
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};
|
|
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=>{U.value={...U.value,systemPrompt:R}},setOption:(R,L)=>{U.value={...U.value,options:{...U.value.options,[R]:L}}},resetSettings:()=>{U.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:U,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 w.execute($,M)}return(y,$)=>(h(),m("div",Cl,[P(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(),m("div",Tl,[r("div",Ml,[r("p",Rl,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",Al,[r("div",Nl,[r("div",zl,[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:$[0]||($[0]=w=>I.value=!I.value),onBlur:H},[b.value?(h(),m(q,{key:1},[r("span",null,d(b.value),1),P(Tt,{"model-name":b.value},null,8,["model-name"])],64)):(h(),m("span",El,d(y.$t("common.model.noModels")),1)),P(x(Vs),{class:E(["h-3 w-3 text-text-muted transition-transform",I.value?"rotate-180":""])},null,8,["class"])],32),I.value?(h(),m("div",Il,[(h(!0),m(q,null,Q(x(n).chatModelNames,w=>(h(),m("button",{key:w,class:E(["flex w-full items-center gap-2 px-3 py-1.5 text-start text-sm transition-colors",w===b.value?"bg-accent/10 text-accent":"text-text-primary hover:bg-surface-overlay"]),onMousedown:He(M=>{b.value=w,I.value=!1},["prevent"])},[r("span",null,d(w),1),P(Tt,{"model-name":w},null,8,["model-name"])],42,Dl))),128))])):N("",!0)]),Re.value?(h(),m("div",Pl,[W(r("input",{"onUpdate:modelValue":$[1]||($[1]=w=>Le.value=w),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:$[2]||($[2]=w=>{w.el.focus(),w.el.select()})},null,544),[[X,Le.value]])])):(h(),m("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:y.$t("dashboard.conversation.clickToRename"),onClick:bs},[r("span",Bl,d(yt.value),1),P(x(Mt),{class:"h-2.5 w-2.5 shrink-0 opacity-0 group-hover:opacity-100"})],8,jl))]),r("div",Ll,[Se.value?(h(),m("button",{key:0,class:"rounded-lg px-3 py-1.5 text-xs text-accent hover:bg-surface-overlay transition-colors",onClick:$[3]||($[3]=w=>$s(Se.value))},d(y.$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:$[4]||($[4]=w=>G.value=!G.value)},[P(x(tn),{class:"h-3.5 w-3.5"}),r("span",null,d(y.$t("dashboard.conversation.history")),1)],2),r("div",Fl,[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:$[5]||($[5]=w=>O.value=!O.value)},[P(x(en),{class:"h-3.5 w-3.5"}),r("span",null,d(y.$t("common.actions.export")),1)],2),O.value?(h(),m("div",{key:0,class:"fixed inset-0 z-10",onClick:$[6]||($[6]=w=>O.value=!1)})):N("",!0),O.value?(h(),m("div",Ol,[r("button",{class:"w-full px-3 py-2 text-start text-xs text-text-secondary hover:bg-surface-overlay",onClick:he},d(y.$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(y.$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(y.$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(y.$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:$[7]||($[7]=w=>K.value=!K.value)},[P(x(Ls),{class:"h-3.5 w-3.5"}),r("span",null,d(y.$t("dashboard.settings.chatSettings")),1)],2)])]),r("div",ql,[G.value?(h(),m("div",Ul,[r("div",Vl,[r("span",Hl,d(y.$t("dashboard.conversation.chatHistory")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:$[8]||($[8]=w=>G.value=!1)}," ✕ ")]),r("div",Gl,[x(o).recentConversations.length===0?(h(),m("p",Wl,d(y.$t("dashboard.conversation.noConversationsYet")),1)):(h(),m("div",Zl,[(h(!0),m(q,null,Q(x(o).recentConversations,w=>(h(),m("div",{key:w.id,class:E(["group flex items-center gap-1 rounded-lg px-2.5 py-2 text-xs transition-colors cursor-pointer",w.id===x(o).activeConversationId?"bg-surface-overlay text-accent":"text-text-secondary hover:bg-surface-overlay hover:text-text-primary"]),onClick:M=>f(w.id)},[me.value===w.id?(h(),m("div",Ql,[W(r("input",{"onUpdate:modelValue":$[9]||($[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=>k(w.id),onKeydown:M=>j(M,w.id),onVnodeMounted:$[10]||($[10]=M=>{M.el.focus(),M.el.select()})},null,40,Jl),[[X,ge.value]])])):(h(),m(q,{key:1},[r("div",Xl,[r("p",Yl,d(w.name),1),r("p",ei,d(w.model)+" · "+d(ie(w.updatedAt)),1)]),r("div",ti,[r("button",{class:"rounded p-0.5 text-text-muted hover:text-text-primary transition-colors",title:y.$t("dashboard.conversation.rename"),onClick:He(M=>S(w.id,w.name),["stop"])},[P(x(Mt),{class:"h-3 w-3"})],8,si),r("button",{class:"rounded p-0.5 text-text-muted hover:text-error transition-colors",title:y.$t("common.actions.delete"),onClick:He(M=>x(o).deleteConversation(w.id),["stop"])},[P(x(Je),{class:"h-3 w-3"})],8,ni)])],64))],10,Kl))),128))]))])])):N("",!0),r("div",oi,[vt.value?(h(),m("div",ai,[r("span",ri,d(y.$t("common.status.error"))+":",1),Te(" "+d(vt.value),1)])):N("",!0),P(sa,{messages:Be.value},null,8,["messages"]),P(Da,{"is-streaming":x(v),"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(),m("div",li,[r("div",ii,[r("span",ci,d(y.$t("dashboard.settings.chatSettings")),1),r("button",{class:"text-text-muted hover:text-text-primary transition-colors text-xs",onClick:$[11]||($[11]=w=>K.value=!1)}," ✕ ")]),P(_l,{modelValue:U.value,"onUpdate:modelValue":$[12]||($[12]=w=>U.value=w),"selected-model":b.value,"rag-enabled":V.value,"onUpdate:ragEnabled":$[13]||($[13]=w=>V.value=w)},null,8,["modelValue","selected-model","rag-enabled"])])):N("",!0)])]))}}),di={class:"rounded-lg border border-border-default bg-surface-raised"},pi={class:"overflow-x-auto"},hi={class:"w-full text-sm"},mi=["onClick"],gi={class:"px-4 py-2 font-medium text-text-primary"},fi={class:"px-4 py-2"},xi={class:"px-4 py-2 text-text-secondary"},bi={class:"px-4 py-2 text-text-secondary"},vi={class:"px-4 py-2 text-text-secondary"},yi={class:"px-4 py-2 text-text-muted"},ki={key:0},wi=se({__name:"SessionHistoryTable",setup(t){const e=Xe();return(s,o)=>(h(),m("div",di,[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",pi,[r("table",hi,[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),m(q,null,Q(x(e).recentSessions.slice(0,20),n=>(h(),m("tr",{key:n.id,class:"border-b border-border-default last:border-0 hover:bg-surface-overlay cursor-pointer transition-colors",onClick:l=>s.$router.push({name:"session",params:{id:n.id}})},[r("td",gi,d(n.model),1),r("td",fi,[P(Ws,{status:n.status,detail:n.error},null,8,["status","detail"])]),r("td",xi,d(n.metrics?n.metrics.totalTokenCount:"—"),1),r("td",bi,d(n.metrics?x(Ge)(n.metrics.tokensPerSecond):"—"),1),r("td",vi,d(n.metrics?x(Zt)(n.metrics.totalDurationMs):"—"),1),r("td",yi,d(x(Os)(n.createdAt)),1)],8,mi))),128)),x(e).recentSessions.length===0?(h(),m("tr",ki,[...o[0]||(o[0]=[r("td",{colspan:"6",class:"px-4 py-8 text-center text-text-muted"},"No sessions yet",-1)])])):N("",!0)])])])]))}}),$i={class:"flex h-full flex-col"},Si={class:"flex-1 min-h-0"},_i={key:0,class:"border-t border-border-default"},Ci={key:0,class:"max-h-80 overflow-auto px-4 pb-4 space-y-4"},Ti={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Mi={key:1,class:"border-t border-border-default px-4 py-2"},Ri={class:"text-[10px] uppercase tracking-wider text-text-muted mb-1"},Ai={class:"flex gap-2 overflow-x-auto pb-1"},Ni=["onClick"],Ki=se({__name:"DashboardPage",setup(t){const e=lt(),s=Wt(),o=A(!1),n=B(()=>e.aggregate),l=B(()=>n.value.totalSessions>0),a=B(()=>s.recentConversations);return(c,i)=>(h(),m("div",$i,[r("div",Si,[P(ui)]),l.value?(h(),m("div",_i,[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:i[0]||(i[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(),m("div",Ci,[r("div",Ti,[P(Ue,{label:c.$t("dashboard.metrics.totalSessions"),value:n.value.totalSessions},null,8,["label","value"]),P(Ue,{label:c.$t("dashboard.metrics.avgTtft"),value:x(Zt)(n.value.avgTtftMs)},null,8,["label","value"]),P(Ue,{label:c.$t("dashboard.metrics.avgSpeed"),value:x(Ge)(n.value.avgTps)},null,8,["label","value"]),P(Ue,{label:c.$t("dashboard.metrics.totalTokens"),value:x(Ce)(n.value.totalTokensGenerated),unit:"tok"},null,8,["label","value"])]),P(wi)])):N("",!0)])):N("",!0),a.value.length>1?(h(),m("div",Mi,[r("p",Ri,d(c.$t("dashboard.metrics.recentChats")),1),r("div",Ai,[(h(!0),m(q,null,Q(a.value.slice(0,5),p=>(h(),m("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,Ni))),128))])])):N("",!0)]))}});export{Ki as default};
|