rt-chat-messages 1.0.4 → 1.0.6

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.
@@ -1 +1 @@
1
- (function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("markdown-it"),require("@vscode/markdown-it-katex"),require("mermaid")):typeof define=="function"&&define.amd?define(["exports","vue","markdown-it","@vscode/markdown-it-katex","mermaid"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.ChatMessages={},z.Vue,z.markdownit,z.markdownItKatex,z.mermaid))})(this,(function(z,e,we,Ce,ce){"use strict";const Ee={class:"cm-dialog__body"},Be=e.defineComponent({__name:"Dialog",props:{visible:{type:Boolean,default:!1},width:{default:"50%"},fullscreen:{type:Boolean,default:!1},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},appendToBody:{type:Boolean,default:!0}},emits:["update:visible","close"],setup(o,{emit:h}){const k=o,l=h,N=e.ref(!1);e.onMounted(()=>{N.value=!0});const E=e.computed(()=>k.fullscreen?{width:"100%",height:"100%",margin:0}:{width:k.width}),_=()=>{l("update:visible",!1),l("close")},B=()=>{k.closeOnClickModal&&_()};return(b,C)=>N.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[o.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cm-dialog-overlay",{"is-fullscreen":o.fullscreen}]),onClick:e.withModifiers(B,["self"])},[e.createElementVNode("div",{class:"cm-dialog",style:e.normalizeStyle(E.value),role:"dialog","aria-modal":"true"},[e.createElementVNode("div",Ee,[e.renderSlot(b.$slots,"default",{},void 0,!0)]),o.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cm-dialog__close",onClick:_},[...C[0]||(C[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[e.createElementVNode("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})],-1)])])):e.createCommentVNode("",!0)],4)],2)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),U=(o,h)=>{const k=o.__vccOpts||o;for(const[l,N]of h)k[l]=N;return k},te=U(Be,[["__scopeId","data-v-efdf0259"]]),Me=["disabled"],Ne={key:0,class:"cm-icon-loading"},L=U(e.defineComponent({__name:"Button",props:{type:{default:"default"},size:{default:"default"},circle:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(o,{emit:h}){const k=o,l=h,N=E=>{k.disabled||k.loading||l("click",E)};return(E,_)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["cm-button",[`cm-button--${o.type}`,`cm-button--${o.size}`,{"is-circle":o.circle,"is-disabled":o.disabled,"is-loading":o.loading}]]),disabled:o.disabled||o.loading,onClick:N},[o.loading?(e.openBlock(),e.createElementBlock("span",Ne,[..._[0]||(_[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"})],-1)])])):e.renderSlot(E.$slots,"default",{key:1},void 0,!0)],10,Me))}}),[["__scopeId","data-v-bab126c7"]]),T=(o,h)=>e.defineComponent({name:o,render(){return e.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",style:"vertical-align: middle"},[e.h("path",{d:h})])}}),G=T("Close","M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"),ie=T("ZoomIn","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"),de=T("ZoomOut","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"),me=T("Document","M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"),ge=T("Download","M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"),Ve=T("VideoPlay","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"),_e=T("VideoPause","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"),xe=T("ArrowLeft","M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"),Se=T("ArrowRight","M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"),fe=T("Spinner","M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"),he=T("Check","M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"),be=T("ChevronUp","M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"),$e=T("ChevronDown","M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"),ve=["src","alt"],ze={class:"preview-controls"},Le={class:"cm-button-group"},Te={key:0,class:"mobile-close-hint"},De=["innerHTML"],Ie={class:"preview-controls"},Ae={class:"cm-button-group"},He={key:0,class:"mobile-close-hint"},ae=U(e.defineComponent({__name:"MarkdownMessage",props:{content:{},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.ref(),l=e.ref(),N=e.ref(!1),E=e.ref(""),_=e.ref(""),B=e.ref(!1),b=e.ref(""),C=e.ref(!1),c=e.ref(1),i=e.ref({x:0,y:0}),y=e.ref(!1),V=e.ref({x:0,y:0}),M=e.ref(1),w=e.ref({x:0,y:0}),Y=e.ref(!1),O=e.ref({x:0,y:0}),W=e.ref(""),R=e.ref(new Map);let X=0;ce.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"});const Q=t=>{const a=t.renderer.rules.fence;t.renderer.rules.fence=(s,g,r,n,m)=>{const p=s[g],v=p.content.trim();return(p.info?p.info.trim():"")==="mermaid"?(X++,`<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${X}`}">${v}</pre></div>`):a(s,g,r,n,m)}},F=new we({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,quotes:`""''`,highlight:function(t,a){return a&&a.trim()?`<pre class="hljs language-${a}"><code>${(g=>g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"))(t)}</code></pre>`:`<pre class="hljs"><code>${t}</code></pre>`}}),Z=F.renderer.rules.image||function(t,a,s,g,r){return r.renderToken(t,a,s)};F.renderer.rules.image=function(t,a,s,g,r){const n=t[a],m=n.attrIndex("src");if(m>=0){const p=n.attrs[m][1],S="img-"+(I=>{let $=0;for(let D=0;D<I.length;D++){const H=I.charCodeAt(D);$=($<<5)-$+H,$=$&$}return Math.abs($).toString(36)})(p);n.attrSet("id",S),n.attrSet("data-image-id",S),n.attrSet("key",S),n.attrSet("loading","eager"),n.attrSet("decoding","async"),n.attrSet("fetchpriority","high"),n.attrSet("data-src",p),n.attrSet("data-cached","true")}return Z(t,a,s,g,r)},F.use(Ce,{throwOnError:!1,errorColor:"#cc0000"}),F.use(Q);const oe=t=>{const a=t.match(/```[\w]*\n/g),s=t.match(/\n```/g),g=(a==null?void 0:a.length)||0,r=(s==null?void 0:s.length)||0;return g>r&&(t+="\n```"),t},ee=t=>{if(!t)return"";t=t.replace(/;;\s*$/g,""),t=t.replace(/;;\s*$/g,"");const a=/^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/,s=t.match(a);if(s)t=s[1];else{const g=/^```\s*\n([\s\S]*?)\n```$/,r=t.match(g);if(r){const n=r[1];(/^#{1,6}\s/.test(n)||/^\*{1,2}[^*]+\*{1,2}/.test(n)||/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n))&&(t=n)}}if(h.isStreaming){const g=/^```(?:markdown|md)?\s*\n/;if(g.test(t)){const n=t.replace(g,"");(/^#{1,6}\s/.test(n)||/^\|.+\|/.test(n)||/^\|[\s-:]+\|/m.test(n)||/!\[.*?\]\(.*?\)/.test(n)||/\[.*?\]\(.*?\)/.test(n))&&(t=t.replace(g,""))}if(/^```(?:markdown|md)?\s*\n/.test(h.content)){const n=/\n```\s*$/;n.test(t)&&(t=t.replace(n,""))}}return t=t.replace(/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,(g,r)=>r),h.isStreaming&&(t=oe(t)),t},se=t=>{if(!t.includes("<img"))return t;const a=/<img[^>]*?src="([^"]*)"[^>]*?>/g;let s,g=t;const r=[];for(;(s=a.exec(t))!==null;){const n=s[0],m=s[1];if(R.value.has(m)){const p=R.value.get(m);n!==p&&r.push({original:n,cached:p})}else R.value.set(m,n)}for(const{original:n,cached:m}of r)g=g.replace(n,m);return g},le=t=>{if(!l.value)return;const a=l.value;if(!h.isStreaming||a.children.length===0){a.innerHTML=t,h.isStreaming||e.nextTick(()=>{ye(),u()});return}const s=document.createElement("div");s.innerHTML=t;const g=new Map;a.querySelectorAll("img[data-image-id]").forEach(n=>{const m=n.getAttribute("data-image-id");m&&g.set(m,n)}),s.querySelectorAll("img[data-image-id]").forEach(n=>{const m=n.getAttribute("data-image-id");if(m&&g.has(m)){const p=g.get(m);n.parentNode&&n.parentNode.replaceChild(p,n)}});const r=document.createDocumentFragment();for(;s.firstChild;)r.appendChild(s.firstChild);a.innerHTML="",a.appendChild(r)},P=()=>{try{if(!h.content){W.value="",l.value&&(l.value.innerHTML=""),h.isStreaming||R.value.clear();return}const t=ee(h.content);let a=F.render(t);h.isStreaming&&a.includes("<img")&&(a=se(a)),a!==W.value&&(W.value=a,le(a)),h.isStreaming||R.value.clear()}catch(t){console.error("Markdown rendering error:",t),l.value&&(l.value.innerHTML=`<pre style="white-space: pre-wrap; word-wrap: break-word;">${h.content}</pre>`)}};e.watch(()=>h.content,P),e.watch(()=>h.isStreaming,(t,a)=>{a&&!t&&e.nextTick(()=>{P()})});const d=()=>{C.value=window.innerWidth<768},f=t=>{let a=t;return a=a.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1"),[/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g].forEach(g=>{a=a.replace(g,(r,n,m)=>{if(m.startsWith('"')&&m.endsWith('"'))return r;let p=m.replace(/^["']+|["']+$/g,"").replace(/["]/g,'\\"');return r.includes("[")?`${n}["${p}"]`:r.includes("(")?`${n}("${p}")`:r.includes("{")?`${n}{"${p}"}`:r})}),a},u=async()=>{var a,s;if(h.isStreaming||(await e.nextTick(),!k.value))return;const t=k.value.querySelectorAll(".mermaid");if(t.length!==0)for(const g of Array.from(t)){const r=g;let n=(a=r.textContent)==null?void 0:a.trim();if(n&&r.getAttribute("data-processed")!=="true")try{r.setAttribute("data-processed","true"),n=f(n);const m=r.getAttribute("data-mermaid-id")||`mermaid-${Date.now()}-${Math.random()}`,{svg:p}=await ce.render(m,n),v=r.parentElement;if(v){const S=document.createElement("div");S.className="mermaid-svg",S.innerHTML=p,S.setAttribute("data-mermaid-svg","true"),S.style.cursor="pointer",S.title="Click to zoom",S.addEventListener("click",I=>{I.preventDefault(),I.stopPropagation(),b.value=p,M.value=1,w.value={x:0,y:0},B.value=!0}),v.replaceChild(S,r)}}catch(m){console.error("Mermaid render failure:",m);const p=document.createElement("div");p.className="mermaid-error",p.textContent=`Mermaid render error: ${m}`,(s=r.parentElement)==null||s.replaceChild(p,r)}}},x=t=>{t.preventDefault(),t.stopPropagation();const a=t.target;E.value=a.src,_.value=a.alt||"Image Preview",c.value=1,i.value={x:0,y:0},N.value=!0},A=()=>{c.value<=1&&(i.value={x:0,y:0})},Ht=()=>{c.value=Math.min(c.value+1,10),A()},Rt=()=>{c.value=Math.max(c.value-1,.5),A()},pe=()=>{c.value=1,i.value={x:0,y:0}},Ft=()=>{c.value<=1&&(N.value=!1)},Pt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5,s=Math.max(.5,Math.min(10,c.value+a));c.value=s,A()},Ut=t=>{var n;if(c.value<=1)return;t.preventDefault(),y.value=!0,V.value={x:t.clientX-i.value.x,y:t.clientY-i.value.y};const a=t.target,s=(n=a.parentElement)==null?void 0:n.getBoundingClientRect(),g=m=>{if(!y.value||!s)return;let p=m.clientX-V.value.x,v=m.clientY-V.value.y;const S=a.offsetWidth,I=a.offsetHeight,$=S*c.value,D=I*c.value,H=.3,re=s.width*(1-H-.5)-$/2,j=$/2-s.width*(1-H-.5),K=s.height*(1-H-.5)-D/2,q=D/2-s.height*(1-H-.5);$>s.width?p=Math.max(re,Math.min(j,p)):p=0,D>s.height?v=Math.max(K,Math.min(q,v)):v=0,i.value={x:p,y:v}},r=()=>{y.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Yt=t=>{var v;if(t.touches.length!==1)return;const a=t.touches[0],s=a.clientX,g=a.clientY;if(c.value<=1)return;y.value=!0,V.value={x:s-i.value.x,y:g-i.value.y};const r=t.target,n=(v=r.parentElement)==null?void 0:v.getBoundingClientRect(),m=S=>{if(!y.value||S.touches.length!==1||!n)return;const I=S.touches[0];let $=I.clientX-V.value.x,D=I.clientY-V.value.y;const H=r.offsetWidth,re=r.offsetHeight,j=H*c.value,K=re*c.value,q=.3,jt=n.width*(1-q-.5)-j/2,Kt=j/2-n.width*(1-q-.5),Gt=n.height*(1-q-.5)-K/2,Jt=K/2-n.height*(1-q-.5);j>n.width?$=Math.max(jt,Math.min(Kt,$)):$=0,K>n.height?D=Math.max(Gt,Math.min(Jt,D)):D=0,i.value={x:$,y:D}},p=()=>{y.value=!1,document.removeEventListener("touchmove",m),document.removeEventListener("touchend",p)};document.addEventListener("touchmove",m,{passive:!1}),document.addEventListener("touchend",p)},Ot=()=>{M.value=Math.min(M.value+1,10)},Wt=()=>{M.value=Math.max(M.value-1,.5)},ke=()=>{M.value=1,w.value={x:0,y:0}},Xt=t=>{t.preventDefault();const a=t.deltaY>0?-.5:.5;M.value=Math.max(.5,Math.min(10,M.value+a))},qt=t=>{var n,m;if(M.value<=1)return;t.preventDefault(),Y.value=!0,O.value={x:t.clientX-w.value.x,y:t.clientY-w.value.y};const s=(m=(n=t.target.closest(".mermaid-preview-content"))==null?void 0:n.parentElement)==null?void 0:m.getBoundingClientRect(),g=p=>{if(!Y.value||!s)return;let v=p.clientX-O.value.x,S=p.clientY-O.value.y;w.value={x:v,y:S}},r=()=>{Y.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",r)},Zt=t=>{},ye=()=>{h.isStreaming||e.nextTick(()=>{if(!k.value)return;k.value.querySelectorAll(".markdown-content img").forEach(a=>{const s=a;s.getAttribute("data-processed")!=="true"&&(s.setAttribute("data-processed","true"),s.style.cursor="pointer",s.addEventListener("click",x))})})};return e.onMounted(()=>{d(),window.addEventListener("resize",d),P(),ye(),u()}),e.onUnmounted(()=>{k.value&&k.value.querySelectorAll(".markdown-content img").forEach(a=>{a.removeEventListener("click",x)})}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{class:"markdown-message",ref_key:"markdownContainer",ref:k},[e.createElementVNode("div",{ref_key:"markdownContent",ref:l,class:"markdown-content"},null,512),e.createVNode(te,{visible:N.value,"onUpdate:visible":a[2]||(a[2]=s=>N.value=s),width:C.value?"95vw":"80vw",fullscreen:C.value,class:"image-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"image-preview-container",onClick:a[1]||(a[1]=e.withModifiers(s=>N.value=!1,["self"]))},[e.createElementVNode("img",{src:E.value,alt:_.value,class:"preview-image",style:e.normalizeStyle({transform:`translate(${i.value.x}px, ${i.value.y}px) scale(${c.value})`}),onWheel:e.withModifiers(Pt,["prevent"]),onDblclick:pe,onMousedown:Ut,onTouchstart:e.withModifiers(Yt,["prevent"]),onClick:Ft},null,44,ve),e.createElementVNode("div",ze,[e.createElementVNode("div",Le,[e.createVNode(L,{size:"small",onClick:Rt,disabled:c.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:pe},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(c.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ht,disabled:c.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[0]||(a[0]=s=>N.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),C.value?(e.openBlock(),e.createElementBlock("div",Te,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"]),e.createVNode(te,{visible:B.value,"onUpdate:visible":a[5]||(a[5]=s=>B.value=s),width:C.value?"95vw":"90vw",fullscreen:C.value,class:"mermaid-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"mermaid-preview-container",onClick:a[4]||(a[4]=e.withModifiers(s=>B.value=!1,["self"]))},[e.createElementVNode("div",{class:"mermaid-preview-content",innerHTML:b.value,style:e.normalizeStyle({transform:`translate(${w.value.x}px, ${w.value.y}px) scale(${M.value})`}),onWheel:e.withModifiers(Xt,["prevent"]),onDblclick:ke,onMousedown:qt,onTouchstart:e.withModifiers(Zt,["prevent"])},null,44,De),e.createElementVNode("div",Ie,[e.createElementVNode("div",Ae,[e.createVNode(L,{size:"small",onClick:Wt,disabled:M.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(de))]),_:1},8,["disabled"]),e.createVNode(L,{size:"small",onClick:ke},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(M.value*100))+"% ",1)]),_:1}),e.createVNode(L,{size:"small",onClick:Ot,disabled:M.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(ie))]),_:1},8,["disabled"])]),e.createVNode(L,{size:"small",onClick:a[3]||(a[3]=s=>B.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})]),C.value?(e.openBlock(),e.createElementBlock("div",He,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"])],512))}}),[["__scopeId","data-v-e47faf67"]]),Re={key:0,class:"text-content"},Fe={key:1,class:"images-content"},Pe=["onClick"],Ue=["src","alt","onError"],Ye={key:0,class:"more-images"},Oe={key:2,class:"attachments-content"},We={class:"file-icon-wrapper"},Xe={class:"attachment-info"},qe={class:"attachment-name"},Ze={class:"attachment-size"},je={key:3,class:"files-content"},Ke=["onClick"],Ge={class:"file-icon-wrapper-small"},Je={class:"file-info"},Qe={class:"file-name"},et={class:"file-type"},tt={class:"file-actions"},at={key:4,class:"audio-content"},nt={class:"audio-player"},ot={class:"audio-info"},st={class:"audio-progress"},lt={class:"progress-bar"},rt={class:"audio-time"},ct={class:"image-preview-container"},it=["src"],dt={key:0,class:"image-nav"},mt={class:"image-counter"},J=U(e.defineComponent({__name:"MultimodalMessage",props:{message:{},isUser:{type:Boolean,default:!1},isStreaming:{type:Boolean,default:!1}},setup(o){const h=o,k=e.computed(()=>{try{return h.message.metadata?JSON.parse(h.message.metadata):{}}catch{return{}}}),l=e.computed(()=>k.value.imageUrls||[]),N=e.computed(()=>k.value.fileUrls||[]),E=e.computed(()=>k.value.audioUrl),_=e.computed(()=>h.message.attachments&&h.message.attachments.length>0?h.message.attachments:k.value.attachments&&Array.isArray(k.value.attachments)?k.value.attachments:[]),B=e.ref(!1),b=e.ref(""),C=e.ref(0),c=e.ref(!1),i=e.ref(!1),y=e.ref(0),V=e.ref(0),M=e.computed(()=>V.value>0?y.value/V.value*100:0);let w=null;const Y=(d,f)=>{b.value=d,C.value=f,B.value=!0},O=()=>{C.value>0&&(C.value--,b.value=l.value[C.value])},W=()=>{C.value<l.value.length-1&&(C.value++,b.value=l.value[C.value])},R=(d,f)=>{console.error("Image load failed:",f);const u=d.target;u.style.display="none"},X=d=>{try{const u=new URL(d).pathname,x=u.substring(u.lastIndexOf("/")+1);return decodeURIComponent(x)||"Unknown File"}catch{return"Unknown File"}},Q=d=>{var x;return((x=X(d).split(".").pop())==null?void 0:x.toUpperCase())||"FILE"},F=d=>{const f=Q(d).toLowerCase();["jpg","jpeg","png","gif","webp","pdf"].includes(f)?window.open(d,"_blank"):Z(d)},Z=d=>{try{const f=document.createElement("a");f.href=d,f.download=X(d),f.target="_blank",document.body.appendChild(f),f.click(),document.body.removeChild(f)}catch(f){console.error("Download failed:",f),alert("下载失败")}},oe=async()=>{if(E.value)try{w||(w=new Audio,w.src=E.value,w.addEventListener("loadedmetadata",()=>{V.value=(w==null?void 0:w.duration)||0}),w.addEventListener("timeupdate",()=>{y.value=(w==null?void 0:w.currentTime)||0}),w.addEventListener("ended",()=>{c.value=!1,y.value=0}),w.addEventListener("error",d=>{console.error("Audio playback error:",d),i.value=!1,c.value=!1})),c.value?(w.pause(),c.value=!1):(i.value=!0,await w.play(),c.value=!0,i.value=!1)}catch(d){console.error("Audio playback failed:",d),i.value=!1,c.value=!1}},ee=d=>{const f=Math.floor(d/60),u=Math.floor(d%60);return`${f}:${u.toString().padStart(2,"0")}`},se=d=>{if(d===0)return"0 B";const f=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(d)/Math.log(f));return(d/Math.pow(f,x)).toFixed(2)+u[x]},le=d=>{var u;return((u=d.split(".").pop())==null?void 0:u.toUpperCase())||"FILE"},P=d=>{B.value&&(d.key==="ArrowLeft"?O():d.key==="ArrowRight"?W():d.key==="Escape"&&(B.value=!1))};return e.watch(B,d=>{d?document.addEventListener("keydown",P):document.removeEventListener("keydown",P)}),e.onUnmounted(()=>{w&&(w.pause(),w=null),document.removeEventListener("keydown",P)}),(d,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["multimodal-message",{"is-user":o.isUser,"is-assistant":!o.isUser}])},[o.message.content?(e.openBlock(),e.createElementBlock("div",Re,[e.createVNode(ae,{content:o.message.content,"is-streaming":o.isStreaming},null,8,["content","is-streaming"])])):e.createCommentVNode("",!0),l.value&&l.value.length>0?(e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",{class:e.normalizeClass(["images-grid",`grid-${Math.min(l.value.length,4)}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.slice(0,4),(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"image-item",onClick:A=>Y(u,x)},[e.createElementVNode("img",{src:u,alt:`图片 ${x+1}`,onError:A=>R(A,u),loading:"lazy"},null,40,Ue),x===3&&l.value.length>4?(e.openBlock(),e.createElementBlock("div",Ye," +"+e.toDisplayString(l.value.length-4),1)):e.createCommentVNode("",!0)],8,Pe))),128))],2)])):e.createCommentVNode("",!0),_.value&&_.value.length>0?(e.openBlock(),e.createElementBlock("div",Oe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"attachment-item"},[e.createElementVNode("div",We,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Xe,[e.createElementVNode("span",qe,e.toDisplayString(u.name),1),e.createElementVNode("span",Ze,e.toDisplayString(le(u.name))+"   "+e.toDisplayString(se(u.size)),1)])]))),128))])):e.createCommentVNode("",!0),N.value&&N.value.length>0?(e.openBlock(),e.createElementBlock("div",je,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(u,x)=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"file-item",onClick:A=>F(u)},[e.createElementVNode("div",Ge,[e.createVNode(e.unref(me),{class:"file-icon"})]),e.createElementVNode("div",Je,[e.createElementVNode("span",Qe,e.toDisplayString(X(u)),1),e.createElementVNode("span",et,e.toDisplayString(Q(u)),1)]),e.createElementVNode("div",tt,[e.createVNode(L,{size:"small",type:"text",onClick:e.withModifiers(A=>Z(u),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1},8,["onClick"])])],8,Ke))),128))])):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("div",at,[e.createElementVNode("div",nt,[e.createVNode(L,{onClick:oe,loading:i.value,circle:"",size:"small",class:"play-btn"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value?e.unref(_e):e.unref(Ve))))]),_:1},8,["loading"]),e.createElementVNode("div",ot,[e.createElementVNode("div",st,[e.createElementVNode("div",lt,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:M.value+"%"})},null,4)])]),e.createElementVNode("div",rt,[e.createElementVNode("span",null,e.toDisplayString(ee(y.value)),1),f[4]||(f[4]=e.createElementVNode("span",null,"/",-1)),e.createElementVNode("span",null,e.toDisplayString(ee(V.value)),1)])]),e.createVNode(L,{onClick:f[0]||(f[0]=u=>Z(E.value)),size:"small",type:"text",class:"download-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(ge))]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(te,{visible:B.value,"onUpdate:visible":f[3]||(f[3]=u=>B.value=u),width:"90%","show-close":!1,"append-to-body":"",class:"image-preview-dialog-wrapper"},{default:e.withCtx(()=>[e.createElementVNode("div",ct,[e.createElementVNode("img",{src:b.value,alt:"预览图片",class:"preview-image",onClick:f[1]||(f[1]=u=>B.value=!1)},null,8,it),l.value&&l.value.length>1?(e.openBlock(),e.createElementBlock("div",dt,[e.createVNode(L,{onClick:O,disabled:C.value===0,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(xe))]),_:1},8,["disabled"]),e.createElementVNode("span",mt,e.toDisplayString(C.value+1)+" / "+e.toDisplayString(l.value.length),1),e.createVNode(L,{onClick:W,disabled:C.value===l.value.length-1,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(Se))]),_:1},8,["disabled"])])):e.createCommentVNode("",!0),e.createVNode(L,{onClick:f[2]||(f[2]=u=>B.value=!1),class:"close-btn",circle:""},{default:e.withCtx(()=>[e.createVNode(e.unref(G))]),_:1})])]),_:1},8,["visible"])],2))}}),[["__scopeId","data-v-7795fedb"]]),gt={key:0,class:"agent-steps"},ft={class:"steps-indicator"},ht={key:0,class:"icon-running"},ut={key:1,class:"icon-completed"},pt={class:"steps-summary"},kt={class:"icon-chevron"},yt={class:"steps-list"},wt={class:"step-icon"},Ct={key:3,class:"icon-dot"},Et={class:"step-name"},ne=U(e.defineComponent({__name:"AgentSteps",props:{steps:{}},emits:["resize"],setup(o,{emit:h}){const k=o,l=e.ref(!0),N=h,E=()=>{l.value=!l.value,setTimeout(()=>{N("resize")},300)},_=e.computed(()=>k.steps.some(b=>b.status==="running")),B=e.computed(()=>{const b=k.steps.find(c=>c.status==="running");if(b)return`正在${b.displayName}...`;const C=k.steps.filter(c=>c.status==="completed").length;return C===k.steps.length?"处理完成":`已完成 ${C}/${k.steps.length} 个步骤`});return(b,C)=>o.steps.length>0?(e.openBlock(),e.createElementBlock("div",gt,[e.createElementVNode("div",{class:"steps-header",onClick:E},[e.createElementVNode("div",ft,[_.value?(e.openBlock(),e.createElementBlock("div",ht,[e.createVNode(e.unref(fe))])):(e.openBlock(),e.createElementBlock("div",ut,[e.createVNode(e.unref(he))]))]),e.createElementVNode("span",pt,e.toDisplayString(B.value),1),e.createElementVNode("div",kt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value?e.unref(be):e.unref($e))))])]),e.withDirectives(e.createElementVNode("div",yt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.steps,c=>(e.openBlock(),e.createElementBlock("div",{key:c.name,class:e.normalizeClass(["step-item",{"is-running":c.status==="running","is-completed":c.status==="completed","is-error":c.status==="error"}])},[e.createElementVNode("div",wt,[c.status==="running"?(e.openBlock(),e.createBlock(e.unref(fe),{key:0,class:"icon-spin"})):c.status==="completed"?(e.openBlock(),e.createBlock(e.unref(he),{key:1})):c.status==="error"?(e.openBlock(),e.createBlock(e.unref(G),{key:2})):(e.openBlock(),e.createElementBlock("div",Ct))]),e.createElementVNode("span",Et,e.toDisplayString(c.displayName),1)],2))),128))],512),[[e.vShow,l.value]])])):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-181f5844"]]),Bt={class:"chat-message-list-root"},Mt={key:0,class:"bg-grid"},Nt={key:0,class:"welcome-screen"},Vt={class:"welcome-content"},_t={class:"welcome-logo"},xt=["src"],St={key:1,class:"default-logo"},bt={class:"welcome-title"},$t={key:1,class:"messages-container"},vt={key:0,class:"message-bubble user-bubble"},zt={key:1,class:"message-content assistant-content"},Lt={class:"message-bubble assistant-bubble"},Tt={key:1,class:"message-actions"},Dt=["onClick"],It={key:0,class:"message-row message-assistant"},ue=U(e.defineComponent({__name:"ChatMessageList",props:{messages:{default:()=>[]},isStreaming:{type:Boolean,default:!1},isTyping:{type:Boolean,default:!1},showWelcome:{type:Boolean,default:!0},appName:{default:"AI助手"},appLogo:{},agentSteps:{},showAgentSteps:{type:Boolean,default:!0},autoScroll:{type:Boolean,default:!0},contentPaddingTop:{default:"80px"},contentPaddingBottom:{default:"140px"},showBackground:{type:Boolean,default:!0}},emits:["copy","scroll","scroll-bottom"],setup(o,{expose:h,emit:k}){const l=o,N=k,E=e.ref(null),_=e.ref(!1),B=async(i="smooth")=>{await e.nextTick(),E.value&&E.value.scrollTo({top:E.value.scrollHeight,behavior:i})},b=i=>{N("scroll",i);const y=i.target;if(!y)return;const{scrollTop:V,scrollHeight:M,clientHeight:w}=y;M-V-w<50?(_.value=!1,N("scroll-bottom")):_.value=!0};e.watch(()=>l.messages.length,async(i,y)=>{i>(y||0)&&(_.value=!1),l.autoScroll&&!_.value&&B()}),e.watch(()=>{var i;return(i=l.messages[l.messages.length-1])==null?void 0:i.content},async(i,y)=>{if(l.isStreaming&&l.autoScroll&&!_.value){const V=(i==null?void 0:i.length)||0,M=(y==null?void 0:y.length)||0;V>M&&E.value&&E.value.scrollTo({top:E.value.scrollHeight,behavior:"instant"})}}),e.watch(()=>l.isTyping,i=>{i&&l.autoScroll&&B()});const C=i=>{N("copy",i),navigator.clipboard&&i.content&&navigator.clipboard.writeText(i.content)};e.watch(()=>l.agentSteps,()=>{l.autoScroll&&!_.value&&B()},{deep:!0});const c=()=>{l.autoScroll&&!_.value&&B()};return h({scrollToBottom:B,containerRef:E}),(i,y)=>(e.openBlock(),e.createElementBlock("div",Bt,[o.showBackground?(e.openBlock(),e.createElementBlock("div",Mt)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"chat-message-list",ref_key:"containerRef",ref:E,onScroll:b,style:e.normalizeStyle({paddingTop:o.contentPaddingTop,paddingBottom:o.contentPaddingBottom})},[o.showWelcome&&o.messages.length===0?(e.openBlock(),e.createElementBlock("div",Nt,[e.renderSlot(i.$slots,"welcome",{},()=>[e.createElementVNode("div",Vt,[e.createElementVNode("div",_t,[o.appLogo?(e.openBlock(),e.createElementBlock("img",{key:0,src:o.appLogo,alt:"Logo"},null,8,xt)):(e.openBlock(),e.createElementBlock("div",St,[...y[0]||(y[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"32",height:"32"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"})],-1)])]))]),e.createElementVNode("h2",bt,e.toDisplayString(o.appName),1),y[1]||(y[1]=e.createElementVNode("p",{class:"welcome-desc"},"今天有什么可以帮您?",-1))])],!0)])):(e.openBlock(),e.createElementBlock("div",$t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.messages,(V,M)=>(e.openBlock(),e.createElementBlock("div",{key:V.id||M,class:e.normalizeClass(["message-row",V.role==="user"?"message-user":"message-assistant"])},[V.role==="user"?(e.openBlock(),e.createElementBlock("div",vt,[e.createVNode(J,{message:V,"is-user":!0},null,8,["message"])])):(e.openBlock(),e.createElementBlock("div",zt,[o.showAgentSteps&&M===o.messages.length-1&&o.agentSteps&&o.agentSteps.length>0?(e.openBlock(),e.createBlock(ne,{key:0,steps:o.agentSteps,onResize:c},null,8,["steps"])):e.createCommentVNode("",!0),e.createElementVNode("div",Lt,[e.createVNode(J,{message:V,"is-user":!1,"is-streaming":o.isStreaming&&M===o.messages.length-1},null,8,["message","is-streaming"])]),V.content&&!(o.isStreaming&&M===o.messages.length-1)?(e.openBlock(),e.createElementBlock("div",Tt,[e.createElementVNode("button",{class:"action-btn",onClick:w=>C(V),title:"复制"},[...y[2]||(y[2]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{fill:"currentColor",d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"})],-1),e.createElementVNode("span",null,"复制",-1)])],8,Dt)])):e.createCommentVNode("",!0)]))],2))),128)),o.isTyping?(e.openBlock(),e.createElementBlock("div",It,[...y[3]||(y[3]=[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("div",{class:"typing-dot"}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.2s"}}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.4s"}})],-1)])])):e.createCommentVNode("",!0)]))],36)]))}}),[["__scopeId","data-v-02d657d5"]]),At={install(o){o.component("ChatMessageList",ue),o.component("MultimodalMessage",J),o.component("MarkdownMessage",ae),o.component("AgentSteps",ne)}};z.AgentSteps=ne,z.ChatMessageList=ue,z.MarkdownMessage=ae,z.MultimodalMessage=J,z.default=At,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(D,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("a2ui-vue"),require("markdown-it"),require("@vscode/markdown-it-katex"),require("mermaid")):typeof define=="function"&&define.amd?define(["exports","vue","a2ui-vue","markdown-it","@vscode/markdown-it-katex","mermaid"],e):(D=typeof globalThis<"u"?globalThis:D||self,e(D.ChatMessages={},D.Vue,D.A2UIVue,D.markdownit,D.markdownItKatex,D.mermaid))})(this,(function(D,e,ie,$e,Ie,be){"use strict";const ze={class:"cm-dialog__body"},Le=e.defineComponent({__name:"Dialog",props:{visible:{type:Boolean,default:!1},width:{default:"50%"},fullscreen:{type:Boolean,default:!1},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},appendToBody:{type:Boolean,default:!0}},emits:["update:visible","close"],setup(l,{emit:h}){const w=l,y=h,m=e.ref(!1);e.onMounted(()=>{m.value=!0});const M=e.computed(()=>w.fullscreen?{width:"100%",height:"100%",margin:0}:{width:w.width}),B=()=>{y("update:visible",!1),y("close")},S=()=>{w.closeOnClickModal&&B()};return(v,A)=>m.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[l.visible?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["cm-dialog-overlay",{"is-fullscreen":l.fullscreen}]),onClick:e.withModifiers(S,["self"])},[e.createElementVNode("div",{class:"cm-dialog",style:e.normalizeStyle(M.value),role:"dialog","aria-modal":"true"},[e.createElementVNode("div",ze,[e.renderSlot(v.$slots,"default",{},void 0,!0)]),l.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cm-dialog__close",onClick:B},[...A[0]||(A[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"16",height:"16"},[e.createElementVNode("path",{fill:"currentColor",d:"M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"})],-1)])])):e.createCommentVNode("",!0)],4)],2)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}),ce=(l,h)=>{const w=l.__vccOpts||l;for(const[y,m]of h)w[y]=m;return w},Ce=ce(Le,[["__scopeId","data-v-efdf0259"]]),Te=["disabled"],Ue={key:0,class:"cm-icon-loading"},P=ce(e.defineComponent({__name:"Button",props:{type:{default:"default"},size:{default:"default"},circle:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(l,{emit:h}){const w=l,y=h,m=M=>{w.disabled||w.loading||y("click",M)};return(M,B)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["cm-button",[`cm-button--${l.type}`,`cm-button--${l.size}`,{"is-circle":l.circle,"is-disabled":l.disabled,"is-loading":l.loading}]]),disabled:l.disabled||l.loading,onClick:m},[l.loading?(e.openBlock(),e.createElementBlock("span",Ue,[...B[0]||(B[0]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"1em",height:"1em"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"})],-1)])])):e.renderSlot(M.$slots,"default",{key:1},void 0,!0)],10,Te))}}),[["__scopeId","data-v-bab126c7"]]),O=(l,h)=>e.defineComponent({name:l,render(){return e.h("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024",width:"1em",height:"1em",fill:"currentColor",style:"vertical-align: middle"},[e.h("path",{d:h})])}}),me=O("Close","M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"),Ve=O("ZoomIn","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm268.48-154.56a32 32 0 0 0-32 32v90.496h-90.56a32 32 0 0 0 0 64h90.56v90.56a32 32 0 0 0 64 0v-90.496h90.496a32 32 0 0 0 0-64H373.632v-90.56a32 32 0 0 0-32-32z"),Ne=O("ZoomOut","M637.696 587.392a316.032 316.032 0 1 0-45.44 49.344l191.232 191.296a32 32 0 0 0 45.312-45.184L637.696 587.392zM73.152 357.696a284.48 284.48 0 1 1 284.48 284.48A284.672 284.672 0 0 1 73.152 357.568zm145.92-58.56a32 32 0 0 0 0 64h245.12a32 32 0 0 0 0-64H219.072z"),De=O("Document","M854.6 288.7c0.4 0 0.7 0 1 0v431.5c0 17.6-14.4 32-32 32H200.4c-17.6 0-32-14.4-32-32l0-575.2c0-17.6 14.4-32 32-32h391.5c0 0.3 0 0.7 0 1l0 142.1c0 17.6 14.4 32.1 32 32.1h142.6c0-0.4 0-0.7 0-1.1L854.6 288.7zM790.2 220.2L668 97.9v122.3h122.2zM240 448h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h544a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64zm0 128h384a32 32 0 0 0 0-64H240a32 32 0 0 0 0 64z"),_e=O("Download","M505.7 661a8 8 0 0 0 12.6 0l112-141.7c4.1-5.2 0.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"),He=O("VideoPlay","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-48-247.616L668.608 512 464 375.616v272.768zm10.656-340.32a32 32 0 0 1 32 32V673.92a32 32 0 0 1-50.208 26.24l-236.8-161.92a32 32 0 0 1 0-52.48l236.8-161.92a32 32 0 0 1 18.208-5.632z"),Pe=O("VideoPause","M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 832a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm-96-544a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32zm192 0a32 32 0 0 1 32 32v256a32 32 0 0 1-64 0V384a32 32 0 0 1 32-32z"),Re=O("ArrowLeft","M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"),Fe=O("ArrowRight","M340.864 149.312a29.12 29.12 0 0 0-41.728 0 30.592 30.592 0 0 0 0 42.752L611.072 511.936 299.136 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L672.448 534.272a32 32 0 0 0 0-44.672L340.864 149.312z"),xe=O("Spinner","M512 64a448 448 0 0 1 448 448 32 32 0 1 1-64 0 416 416 0 0 0-416-416 416 416 0 0 0-416 416 32 32 0 1 1-64 0 448 448 0 0 1 448-448z"),ve=O("Check","M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1 0.4-12.8-6.3-12.8z"),Oe=O("ChevronUp","M854.6 642.5l-320-320c-12.5-12.5-32.8-12.5-45.3 0l-320 320c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L512 390.6l297.4 297.4c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3z"),We=O("ChevronDown","M854.6 381.5l-320 320c-12.5 12.5-32.8 12.5-45.3 0l-320-320c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L512 633.4l297.4-297.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3z"),je=["src","alt"],Ye={class:"preview-controls"},qe={class:"cm-button-group"},Xe={key:0,class:"mobile-close-hint"},Ze=["innerHTML"],Ke={class:"preview-controls"},Je={class:"cm-button-group"},Ge={key:0,class:"mobile-close-hint"},Me=ce(e.defineComponent({__name:"MarkdownMessage",props:{content:{},isStreaming:{type:Boolean,default:!1}},setup(l){const h=l,w=e.ref(),y=e.ref(),m=e.ref(!1),M=e.ref(""),B=e.ref(""),S=e.ref(!1),v=e.ref(""),A=e.ref(!1),k=e.ref(1),z=e.ref({x:0,y:0}),V=e.ref(!1),I=e.ref({x:0,y:0}),E=e.ref(1),T=e.ref({x:0,y:0}),C=e.ref(!1),re=e.ref({x:0,y:0}),N=e.ref(""),J=e.ref(new Map),te=e.ref(!1);let le=0;be.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"});const ue=o=>{const r=o.renderer.rules.fence;o.renderer.rules.fence=(c,p,d,t,n)=>{const a=c[p],s=a.content.trim();return(a.info?a.info.trim():"")==="mermaid"?(le++,`<div class="mermaid-container"><pre class="mermaid" data-mermaid-id="${`mermaid-${Date.now()}-${le}`}">${s}</pre></div>`):r(c,p,d,t,n)}},H=new $e({html:!0,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkify:!0,typographer:!0,quotes:`""''`,highlight:function(o,r){return r&&r.trim()?`<pre class="hljs language-${r}"><code>${(p=>p.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"))(o)}</code></pre>`:`<pre class="hljs"><code>${o}</code></pre>`}}),Y=H.renderer.rules.image||function(o,r,c,p,d){return d.renderToken(o,r,c)};H.renderer.rules.image=function(o,r,c,p,d){const t=o[r],n=t.attrIndex("src");if(n>=0){const a=t.attrs[n][1],u="img-"+(_=>{let $=0;for(let U=0;U<_.length;U++){const se=_.charCodeAt(U);$=($<<5)-$+se,$=$&$}return Math.abs($).toString(36)})(a);t.attrSet("id",u),t.attrSet("data-image-id",u),t.attrSet("key",u),t.attrSet("loading","eager"),t.attrSet("decoding","async"),t.attrSet("fetchpriority","high"),t.attrSet("data-src",a),t.attrSet("data-cached","true")}return Y(o,r,c,p,d)},H.use(Ie,{throwOnError:!1,errorColor:"#cc0000"}),H.use(ue);const R=o=>{const r=o.match(/```[\w]*\n/g),c=o.match(/\n```/g),p=(r==null?void 0:r.length)||0,d=(c==null?void 0:c.length)||0;return p>d&&(o+="\n```"),o},x=o=>{if(!o)return"";o=o.replace(/;;\s*$/g,""),o=o.replace(/;;\s*$/g,"");const r=/^```(?:markdown|md)\s*\n([\s\S]*?)\n```$/,c=o.match(r);if(c)o=c[1];else{const p=/^```\s*\n([\s\S]*?)\n```$/,d=o.match(p);if(d){const t=d[1];(/^#{1,6}\s/.test(t)||/^\*{1,2}[^*]+\*{1,2}/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/!\[.*?\]\(.*?\)/.test(t)||/\[.*?\]\(.*?\)/.test(t)||/^\|.+\|/.test(t)||/^\|[\s-:]+\|/m.test(t))&&(o=t)}}if(h.isStreaming){const p=/^```(?:markdown|md)?\s*\n/;if(p.test(o)){const t=o.replace(p,"");(/^#{1,6}\s/.test(t)||/^\|.+\|/.test(t)||/^\|[\s-:]+\|/m.test(t)||/!\[.*?\]\(.*?\)/.test(t)||/\[.*?\]\(.*?\)/.test(t))&&(o=o.replace(p,""))}if(/^```(?:markdown|md)?\s*\n/.test(h.content)){const t=/\n```\s*$/;t.test(o)&&(o=o.replace(t,""))}}return o=o.replace(/```(?:markdown|md)\s*\n([\s\S]*?)\n```/g,(p,d)=>d),h.isStreaming&&(o=R(o)),o},q=o=>{if(!o.includes("<img"))return o;const r=/<img[^>]*?src="([^"]*)"[^>]*?>/g;let c,p=o;const d=[];for(;(c=r.exec(o))!==null;){const t=c[0],n=c[1];if(J.value.has(n)){const a=J.value.get(n);t!==a&&d.push({original:t,cached:a})}else J.value.set(n,t)}for(const{original:t,cached:n}of d)p=p.replace(t,n);return p},fe=o=>{if(!y.value)return;const r=y.value,c=new Map;if(h.isStreaming&&r.children.length>0&&r.querySelectorAll("img[data-image-id]").forEach(p=>{const d=p.getAttribute("data-image-id");d&&c.set(d,p)}),r.innerHTML=o,!h.isStreaming){e.nextTick(()=>{Ee(),g()});return}c.size>0&&r.querySelectorAll("img[data-image-id]").forEach(p=>{const d=p.getAttribute("data-image-id");if(d&&c.has(d)){const t=c.get(d);p.parentNode&&t!==p&&p.parentNode.replaceChild(t,p)}})},W=()=>{try{if(!h.content){N.value="",y.value&&(y.value.innerHTML=""),h.isStreaming||J.value.clear();return}if(document.hidden&&h.isStreaming){te.value=!0;return}const o=x(h.content);let r=H.render(o);h.isStreaming&&r.includes("<img")&&(r=q(r)),r!==N.value&&(N.value=r,fe(r)),h.isStreaming||J.value.clear()}catch(o){console.error("Markdown rendering error:",o),y.value&&(y.value.innerHTML=`<pre style="white-space: pre-wrap; word-wrap: break-word;">${h.content}</pre>`)}};e.watch(()=>h.content,W),e.watch(()=>h.isStreaming,(o,r)=>{r&&!o&&e.nextTick(()=>{W()})});const j=()=>{!document.hidden&&te.value&&(te.value=!1,e.nextTick(()=>{W()}))};document.addEventListener("visibilitychange",j),e.onUnmounted(()=>{document.removeEventListener("visibilitychange",j)});const i=()=>{A.value=window.innerWidth<768},f=o=>{let r=o;return r=r.replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1"),[/([A-Za-z0-9_]+)\[([^\]]*[\u4e00-\u9fa5]+[^\]]*)\]/g,/([A-Za-z0-9_]+)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g,/([A-Za-z0-9_]+)\{([^}]*[\u4e00-\u9fa5]+[^}]*)\}/g].forEach(p=>{r=r.replace(p,(d,t,n)=>{if(n.startsWith('"')&&n.endsWith('"'))return d;let a=n.replace(/^["']+|["']+$/g,"").replace(/["]/g,'\\"');return d.includes("[")?`${t}["${a}"]`:d.includes("(")?`${t}("${a}")`:d.includes("{")?`${t}{"${a}"}`:d})}),r},g=async()=>{var r,c;if(h.isStreaming||(await e.nextTick(),!w.value))return;const o=w.value.querySelectorAll(".mermaid");if(o.length!==0)for(const p of Array.from(o)){const d=p;let t=(r=d.textContent)==null?void 0:r.trim();if(t&&d.getAttribute("data-processed")!=="true")try{d.setAttribute("data-processed","true"),t=f(t);const n=d.getAttribute("data-mermaid-id")||`mermaid-${Date.now()}-${Math.random()}`,{svg:a}=await be.render(n,t),s=d.parentElement;if(s){const u=document.createElement("div");u.className="mermaid-svg",u.innerHTML=a,u.setAttribute("data-mermaid-svg","true"),u.style.cursor="pointer",u.title="Click to zoom",u.addEventListener("click",_=>{_.preventDefault(),_.stopPropagation(),v.value=a,E.value=1,T.value={x:0,y:0},S.value=!0}),s.replaceChild(u,d)}}catch(n){console.error("Mermaid render failure:",n);const a=document.createElement("div");a.className="mermaid-error",a.textContent=`Mermaid render error: ${n}`,(c=d.parentElement)==null||c.replaceChild(a,d)}}},b=o=>{o.preventDefault(),o.stopPropagation();const r=o.target;M.value=r.src,B.value=r.alt||"Image Preview",k.value=1,z.value={x:0,y:0},m.value=!0},L=()=>{k.value<=1&&(z.value={x:0,y:0})},ne=()=>{k.value=Math.min(k.value+1,10),L()},ae=()=>{k.value=Math.max(k.value-1,.5),L()},G=()=>{k.value=1,z.value={x:0,y:0}},pe=()=>{k.value<=1&&(m.value=!1)},X=o=>{o.preventDefault();const r=o.deltaY>0?-.5:.5,c=Math.max(.5,Math.min(10,k.value+r));k.value=c,L()},Z=o=>{var t;if(k.value<=1)return;o.preventDefault(),V.value=!0,I.value={x:o.clientX-z.value.x,y:o.clientY-z.value.y};const r=o.target,c=(t=r.parentElement)==null?void 0:t.getBoundingClientRect(),p=n=>{if(!V.value||!c)return;let a=n.clientX-I.value.x,s=n.clientY-I.value.y;const u=r.offsetWidth,_=r.offsetHeight,$=u*k.value,U=_*k.value,se=.3,Se=c.width*(1-se-.5)-$/2,he=$/2-c.width*(1-se-.5),ye=c.height*(1-se-.5)-U/2,de=U/2-c.height*(1-se-.5);$>c.width?a=Math.max(Se,Math.min(he,a)):a=0,U>c.height?s=Math.max(ye,Math.min(de,s)):s=0,z.value={x:a,y:s}},d=()=>{V.value=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",d)},K=o=>{var s;if(o.touches.length!==1)return;const r=o.touches[0],c=r.clientX,p=r.clientY;if(k.value<=1)return;V.value=!0,I.value={x:c-z.value.x,y:p-z.value.y};const d=o.target,t=(s=d.parentElement)==null?void 0:s.getBoundingClientRect(),n=u=>{if(!V.value||u.touches.length!==1||!t)return;const _=u.touches[0];let $=_.clientX-I.value.x,U=_.clientY-I.value.y;const se=d.offsetWidth,Se=d.offsetHeight,he=se*k.value,ye=Se*k.value,de=.3,on=t.width*(1-de-.5)-he/2,sn=he/2-t.width*(1-de-.5),rn=t.height*(1-de-.5)-ye/2,ln=ye/2-t.height*(1-de-.5);he>t.width?$=Math.max(on,Math.min(sn,$)):$=0,ye>t.height?U=Math.max(rn,Math.min(ln,U)):U=0,z.value={x:$,y:U}},a=()=>{V.value=!1,document.removeEventListener("touchmove",n),document.removeEventListener("touchend",a)};document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",a)},F=()=>{E.value=Math.min(E.value+1,10)},ge=()=>{E.value=Math.max(E.value-1,.5)},Q=()=>{E.value=1,T.value={x:0,y:0}},oe=o=>{o.preventDefault();const r=o.deltaY>0?-.5:.5;E.value=Math.max(.5,Math.min(10,E.value+r))},we=o=>{var t,n;if(E.value<=1)return;o.preventDefault(),C.value=!0,re.value={x:o.clientX-T.value.x,y:o.clientY-T.value.y};const c=(n=(t=o.target.closest(".mermaid-preview-content"))==null?void 0:t.parentElement)==null?void 0:n.getBoundingClientRect(),p=a=>{if(!C.value||!c)return;let s=a.clientX-re.value.x,u=a.clientY-re.value.y;T.value={x:s,y:u}},d=()=>{C.value=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",d)},ee=o=>{},Ee=()=>{h.isStreaming||e.nextTick(()=>{if(!w.value)return;w.value.querySelectorAll(".markdown-content img").forEach(r=>{const c=r;c.getAttribute("data-processed")!=="true"&&(c.setAttribute("data-processed","true"),c.style.cursor="pointer",c.addEventListener("click",b))})})};return e.onMounted(()=>{i(),window.addEventListener("resize",i),W(),Ee(),g()}),e.onUnmounted(()=>{w.value&&w.value.querySelectorAll(".markdown-content img").forEach(r=>{r.removeEventListener("click",b)})}),(o,r)=>(e.openBlock(),e.createElementBlock("div",{class:"markdown-message",ref_key:"markdownContainer",ref:w},[e.createElementVNode("div",{ref_key:"markdownContent",ref:y,class:"markdown-content"},null,512),e.createVNode(Ce,{visible:m.value,"onUpdate:visible":r[2]||(r[2]=c=>m.value=c),width:A.value?"95vw":"80vw",fullscreen:A.value,class:"image-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"image-preview-container",onClick:r[1]||(r[1]=e.withModifiers(c=>m.value=!1,["self"]))},[e.createElementVNode("img",{src:M.value,alt:B.value,class:"preview-image",style:e.normalizeStyle({transform:`translate(${z.value.x}px, ${z.value.y}px) scale(${k.value})`}),onWheel:e.withModifiers(X,["prevent"]),onDblclick:G,onMousedown:Z,onTouchstart:e.withModifiers(K,["prevent"]),onClick:pe},null,44,je),e.createElementVNode("div",Ye,[e.createElementVNode("div",qe,[e.createVNode(P,{size:"small",onClick:ae,disabled:k.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(Ne))]),_:1},8,["disabled"]),e.createVNode(P,{size:"small",onClick:G},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(k.value*100))+"% ",1)]),_:1}),e.createVNode(P,{size:"small",onClick:ne,disabled:k.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(Ve))]),_:1},8,["disabled"])]),e.createVNode(P,{size:"small",onClick:r[0]||(r[0]=c=>m.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(me))]),_:1})]),A.value?(e.openBlock(),e.createElementBlock("div",Xe,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"]),e.createVNode(Ce,{visible:S.value,"onUpdate:visible":r[5]||(r[5]=c=>S.value=c),width:A.value?"95vw":"90vw",fullscreen:A.value,class:"mermaid-preview-dialog","close-on-click-modal":!1,"append-to-body":""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"mermaid-preview-container",onClick:r[4]||(r[4]=e.withModifiers(c=>S.value=!1,["self"]))},[e.createElementVNode("div",{class:"mermaid-preview-content",innerHTML:v.value,style:e.normalizeStyle({transform:`translate(${T.value.x}px, ${T.value.y}px) scale(${E.value})`}),onWheel:e.withModifiers(oe,["prevent"]),onDblclick:Q,onMousedown:we,onTouchstart:e.withModifiers(ee,["prevent"])},null,44,Ze),e.createElementVNode("div",Ke,[e.createElementVNode("div",Je,[e.createVNode(P,{size:"small",onClick:ge,disabled:E.value<=.5},{default:e.withCtx(()=>[e.createVNode(e.unref(Ne))]),_:1},8,["disabled"]),e.createVNode(P,{size:"small",onClick:Q},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(Math.round(E.value*100))+"% ",1)]),_:1}),e.createVNode(P,{size:"small",onClick:F,disabled:E.value>=10},{default:e.withCtx(()=>[e.createVNode(e.unref(Ve))]),_:1},8,["disabled"])]),e.createVNode(P,{size:"small",onClick:r[3]||(r[3]=c=>S.value=!1),type:"danger"},{default:e.withCtx(()=>[e.createVNode(e.unref(me))]),_:1})]),A.value?(e.openBlock(),e.createElementBlock("div",Ge,"双击重置 · 轻触关闭")):e.createCommentVNode("",!0)])]),_:1},8,["visible","width","fullscreen"])],512))}}),[["__scopeId","data-v-c6385dde"]]),Qe={key:0,class:"text-content"},et={key:1,class:"images-content"},tt=["onClick"],nt=["src","alt","onError"],at={key:0,class:"more-images"},ot={key:2,class:"files-content"},st=["onClick"],rt={class:"file-icon-wrapper-small"},lt=["title"],it={class:"file-name"},ct={class:"file-type"},dt={class:"file-actions"},mt={key:3,class:"audio-content"},ut={class:"audio-player"},ft={class:"audio-info"},pt={class:"audio-progress"},gt={class:"progress-bar"},ht={class:"audio-time"},yt={class:"image-preview-container"},kt=["src"],wt={key:0,class:"image-nav"},Et={class:"image-counter"},ke=ce(e.defineComponent({__name:"MultimodalMessage",props:{message:{},isUser:{type:Boolean,default:!1},isStreaming:{type:Boolean,default:!1},apiBaseUrl:{default:""},onDownload:{}},setup(l){const h=l,w=e.computed(()=>{try{return h.message.metadata?JSON.parse(h.message.metadata):{}}catch{return{}}}),y=e.computed(()=>w.value.imageUrls||[]),m=e.computed(()=>w.value.audioUrl),M=e.ref(new Set),B=e.computed(()=>w.value.fileUrls||[]),S=e.computed(()=>B.value),v=e.computed(()=>h.message.attachments&&h.message.attachments.length>0?h.message.attachments:w.value.attachments&&Array.isArray(w.value.attachments)?w.value.attachments:[]),A=e.computed(()=>{const i=[];return v.value&&v.value.length>0?v.value.forEach(f=>{var b,L;((b=f.type)==null?void 0:b.startsWith("image/"))||((L=f.name)==null?void 0:L.match(/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i))||i.push({url:f.url||f.download_url||f.file_url||"",name:f.original_name||f.name||"Unknown File",type:Y(f.original_name||f.name||"Unknown File")})}):S.value&&S.value.length>0&&S.value.forEach(f=>{i.push({url:f,name:H(f),type:Y(f)})}),i}),k=e.ref(!1),z=e.ref(""),V=e.ref(0),I=e.ref(!1),E=e.ref(!1),T=e.ref(0),C=e.ref(0),re=e.computed(()=>C.value>0?T.value/C.value*100:0);let N=null;const J=(i,f)=>{z.value=i,V.value=f,k.value=!0},te=()=>{V.value>0&&(V.value--,z.value=y.value[V.value])},le=()=>{V.value<y.value.length-1&&(V.value++,z.value=y.value[V.value])},ue=(i,f)=>{console.error("Image load failed:",f);const g=i.target;g.style.display="none"},H=i=>{if(!i)return"Unknown File";if(!i.includes("/"))return decodeURIComponent(i)||"Unknown File";try{const f=i.lastIndexOf("/"),g=f>=0?i.substring(f+1):i;return decodeURIComponent(g)||"Unknown File"}catch{return"Unknown File"}},Y=i=>{var b;return((b=H(i).split(".").pop())==null?void 0:b.toUpperCase())||"FILE"},R=(i,f)=>{q(i,f)},x=i=>!i||i.startsWith("http://")||i.startsWith("https://")||i.startsWith("blob:")?i:(h.apiBaseUrl?h.apiBaseUrl.replace(/\/$/,""):"")+(i.startsWith("/")?i:"/"+i),q=async(i,f)=>{try{const g=x(i);if(console.log("正在下载文件...",g),h.onDownload&&(M.value=new Set([...M.value,i]),await h.onDownload(i,f)!==!1)){const F=new Set(M.value);F.delete(i),M.value=F;return}M.value=new Set([...M.value,i]);const b=localStorage.getItem("token"),L={};if(b&&(L.Authorization=b.startsWith("Bearer ")?b:`Bearer ${b}`),typeof window<"u"&&typeof window.plus<"u"){const K=window.plus,F=K.downloader.createDownload(g,{method:"GET",filename:"_downloads/"+(f||H(i))},(ge,Q)=>{const oe=new Set(M.value);oe.delete(i),M.value=oe,Q===200||Q===206?K.runtime.openFile(ge.filename):console.error("App 环境原生下载失败, status:",Q)});L.Authorization&&F.setRequestHeader("Authorization",L.Authorization),F.start();return}const ne=await fetch(g,{headers:L});if(!ne.ok)throw new Error(`下载失败: ${ne.status}`);let ae=f;const G=ne.headers.get("Content-Disposition");if(G){const K=G.match(/filename\*=UTF-8''(.+)/i);if(K)ae=decodeURIComponent(K[1]);else{const F=G.match(/filename="?([^";\n]+)"?/i);F&&(ae=F[1])}}const pe=await ne.blob(),X=URL.createObjectURL(pe),Z=document.createElement("a");Z.href=X,Z.download=ae||f||H(i),document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),URL.revokeObjectURL(X)}catch(g){console.error("下载文件失败:",g)}finally{const g=new Set(M.value);g.delete(i),M.value=g}},fe=async()=>{if(m.value)try{N||(N=new Audio,N.src=x(m.value),N.addEventListener("loadedmetadata",()=>{C.value=(N==null?void 0:N.duration)||0}),N.addEventListener("timeupdate",()=>{T.value=(N==null?void 0:N.currentTime)||0}),N.addEventListener("ended",()=>{I.value=!1,T.value=0}),N.addEventListener("error",i=>{console.error("Audio playback error:",i),E.value=!1,I.value=!1})),I.value?(N.pause(),I.value=!1):(E.value=!0,await N.play(),I.value=!0,E.value=!1)}catch(i){console.error("Audio playback failed:",i),E.value=!1,I.value=!1}},W=i=>{const f=Math.floor(i/60),g=Math.floor(i%60);return`${f}:${g.toString().padStart(2,"0")}`},j=i=>{k.value&&(i.key==="ArrowLeft"?te():i.key==="ArrowRight"?le():i.key==="Escape"&&(k.value=!1))};return e.watch(k,i=>{i?document.addEventListener("keydown",j):document.removeEventListener("keydown",j)}),e.onUnmounted(()=>{N&&(N.pause(),N=null),document.removeEventListener("keydown",j)}),(i,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["multimodal-message",{"is-user":l.isUser,"is-assistant":!l.isUser}])},[l.message.content?(e.openBlock(),e.createElementBlock("div",Qe,[e.createVNode(Me,{content:l.message.content,"is-streaming":l.isStreaming},null,8,["content","is-streaming"])])):e.createCommentVNode("",!0),y.value&&y.value.length>0?(e.openBlock(),e.createElementBlock("div",et,[e.createElementVNode("div",{class:e.normalizeClass(["images-grid",`grid-${Math.min(y.value.length,4)}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value.slice(0,4),(g,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"image-item",onClick:L=>J(g,b)},[e.createElementVNode("img",{src:g,alt:`图片 ${b+1}`,onError:L=>ue(L,g),loading:"lazy"},null,40,nt),b===3&&y.value.length>4?(e.openBlock(),e.createElementBlock("div",at," +"+e.toDisplayString(y.value.length-4),1)):e.createCommentVNode("",!0)],8,tt))),128))],2)])):e.createCommentVNode("",!0),A.value&&A.value.length>0?(e.openBlock(),e.createElementBlock("div",ot,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,(g,b)=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"file-item",onClick:L=>R(g.url,g.name)},[e.createElementVNode("div",rt,[e.createVNode(e.unref(De),{class:"file-icon"})]),e.createElementVNode("div",{class:"file-info",title:g.name},[e.createElementVNode("span",it,e.toDisplayString(g.name),1),e.createElementVNode("span",ct,e.toDisplayString(g.type),1)],8,lt),e.createElementVNode("div",dt,[e.createVNode(P,{size:"small",type:"text",disabled:M.value.has(g.url),onClick:e.withModifiers(L=>q(g.url,g.name),["stop"])},{default:e.withCtx(()=>[e.createVNode(e.unref(_e),{class:e.normalizeClass({"icon-spin":M.value.has(g.url)})},null,8,["class"])]),_:2},1032,["disabled","onClick"])])],8,st))),128))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",mt,[e.createElementVNode("div",ut,[e.createVNode(P,{onClick:fe,loading:E.value,circle:"",size:"small",class:"play-btn"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(I.value?e.unref(Pe):e.unref(He))))]),_:1},8,["loading"]),e.createElementVNode("div",ft,[e.createElementVNode("div",pt,[e.createElementVNode("div",gt,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:re.value+"%"})},null,4)])]),e.createElementVNode("div",ht,[e.createElementVNode("span",null,e.toDisplayString(W(T.value)),1),f[4]||(f[4]=e.createElementVNode("span",null,"/",-1)),e.createElementVNode("span",null,e.toDisplayString(W(C.value)),1)])]),e.createVNode(P,{onClick:f[0]||(f[0]=g=>q(m.value)),size:"small",type:"text",class:"download-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(_e))]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(Ce,{visible:k.value,"onUpdate:visible":f[3]||(f[3]=g=>k.value=g),width:"90%","show-close":!1,"append-to-body":"",class:"image-preview-dialog-wrapper"},{default:e.withCtx(()=>[e.createElementVNode("div",yt,[e.createElementVNode("img",{src:z.value,alt:"预览图片",class:"preview-image",onClick:f[1]||(f[1]=g=>k.value=!1)},null,8,kt),y.value&&y.value.length>1?(e.openBlock(),e.createElementBlock("div",wt,[e.createVNode(P,{onClick:te,disabled:V.value===0,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(Re))]),_:1},8,["disabled"]),e.createElementVNode("span",Et,e.toDisplayString(V.value+1)+" / "+e.toDisplayString(y.value.length),1),e.createVNode(P,{onClick:le,disabled:V.value===y.value.length-1,circle:"",class:"nav-btn"},{default:e.withCtx(()=>[e.createVNode(e.unref(Fe))]),_:1},8,["disabled"])])):e.createCommentVNode("",!0),e.createVNode(P,{onClick:f[2]||(f[2]=g=>k.value=!1),class:"close-btn",circle:""},{default:e.withCtx(()=>[e.createVNode(e.unref(me))]),_:1})])]),_:1},8,["visible"])],2))}}),[["__scopeId","data-v-96cd8b34"]]),Ct=["aria-expanded"],Mt={class:"steps-indicator"},Bt={key:0,class:"icon-running"},St={key:1,class:"icon-error"},bt={key:2,class:"icon-completed"},Vt={class:"steps-copy"},Nt={class:"steps-summary"},_t={class:"steps-meta"},xt={class:"steps-count"},vt={class:"icon-chevron"},At={class:"steps-progress","aria-hidden":"true"},$t={class:"steps-list"},It={class:"step-rail","aria-hidden":"true"},zt={class:"step-icon"},Lt={key:3,class:"icon-dot"},Tt={class:"step-name"},Ut={class:"step-status"},Be=ce(e.defineComponent({__name:"AgentSteps",props:{steps:{}},emits:["resize"],setup(l,{emit:h}){const w=l,y=e.ref(!0),m=h,M=()=>{y.value=!y.value,e.nextTick(()=>{requestAnimationFrame(()=>m("resize"))})},B=e.computed(()=>w.steps.some(E=>E.status==="running")),S=e.computed(()=>w.steps.some(E=>E.status==="error")),v=e.computed(()=>w.steps.filter(E=>E.status==="completed").length),A=e.computed(()=>w.steps.length===0?0:Math.round(v.value/w.steps.length*100)),k=e.computed(()=>({width:`${A.value}%`})),z=e.computed(()=>B.value?"智能处理流程":S.value?"需要关注":"全部步骤已同步"),V=e.computed(()=>{const E=w.steps.find(T=>T.status==="running");return E?`正在处理 ${E.displayName}`:S.value?"处理遇到问题":v.value===w.steps.length?"处理完成":`已完成 ${v.value}/${w.steps.length} 个步骤`}),I=E=>E==="running"?"进行中":E==="error"?"异常":"完成";return(E,T)=>l.steps.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["agent-steps",{"is-running":B.value,"is-error":S.value,"is-collapsed":!y.value}])},[e.createElementVNode("button",{type:"button",class:"steps-header","aria-expanded":y.value,onClick:M},[e.createElementVNode("span",Mt,[B.value?(e.openBlock(),e.createElementBlock("span",Bt,[e.createVNode(e.unref(xe))])):S.value?(e.openBlock(),e.createElementBlock("span",St,[e.createVNode(e.unref(me))])):(e.openBlock(),e.createElementBlock("span",bt,[e.createVNode(e.unref(ve))]))]),e.createElementVNode("span",Vt,[e.createElementVNode("span",Nt,e.toDisplayString(V.value),1),e.createElementVNode("span",_t,e.toDisplayString(z.value),1)]),e.createElementVNode("span",xt,e.toDisplayString(v.value)+"/"+e.toDisplayString(l.steps.length),1),e.createElementVNode("span",vt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.value?e.unref(Oe):e.unref(We))))])],8,Ct),e.createElementVNode("div",At,[e.createElementVNode("span",{style:e.normalizeStyle(k.value)},null,4)]),e.withDirectives(e.createElementVNode("div",$t,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.steps,C=>(e.openBlock(),e.createElementBlock("div",{key:C.name,class:e.normalizeClass(["step-item",{"is-running":C.status==="running","is-completed":C.status==="completed","is-error":C.status==="error"}])},[e.createElementVNode("span",It,[e.createElementVNode("span",zt,[C.status==="running"?(e.openBlock(),e.createBlock(e.unref(xe),{key:0,class:"icon-spin"})):C.status==="completed"?(e.openBlock(),e.createBlock(e.unref(ve),{key:1})):C.status==="error"?(e.openBlock(),e.createBlock(e.unref(me),{key:2})):(e.openBlock(),e.createElementBlock("span",Lt))])]),e.createElementVNode("span",Tt,e.toDisplayString(C.displayName),1),e.createElementVNode("span",Ut,e.toDisplayString(I(C.status)),1)],2))),128))],512),[[e.vShow,y.value]])],2)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-5030f19a"]]),Dt={class:"chat-message-list-root"},Ht={key:0,class:"bg-grid"},Pt={key:0,class:"welcome-screen"},Rt={class:"welcome-content"},Ft={class:"welcome-logo"},Ot=["src"],Wt={key:1,class:"default-logo"},jt={class:"welcome-title"},Yt={key:1,class:"messages-container"},qt={key:0,class:"user-message-wrapper"},Xt={class:"message-bubble user-bubble"},Zt={key:0,class:"message-actions user-actions"},Kt=["onClick"],Jt={key:1,class:"message-content assistant-content"},Gt={key:2,class:"a2ui-card-skeleton","aria-hidden":"true"},Qt={key:1,class:"message-actions"},en=["onClick"],tn={key:0,class:"message-row message-assistant"},nn={key:0,class:"loading-ring",viewBox:"0 0 36 36"},Ae=ce(e.defineComponent({__name:"ChatMessageList",props:{messages:{default:()=>[]},isStreaming:{type:Boolean,default:!1},isTyping:{type:Boolean,default:!1},showWelcome:{type:Boolean,default:!0},appName:{default:"AI助手"},appLogo:{},agentSteps:{},showAgentSteps:{type:Boolean,default:!0},autoScroll:{type:Boolean,default:!0},contentPaddingTop:{default:"80px"},contentPaddingBottom:{default:"140px"},showBackground:{type:Boolean,default:!0},apiBaseUrl:{default:""},enableA2UI:{type:Boolean,default:!0},autoProvideA2UI:{type:Boolean,default:!0},a2uiCatalog:{},hideA2UIRawContent:{type:Boolean,default:!0},showA2UISkeleton:{type:Boolean,default:!0},a2uiActionHandler:{}},emits:["copy","scroll","scroll-bottom","a2ui-action","a2ui-error"],setup(l,{expose:h,emit:w}){const y=new WeakMap,m=l,M=w,B=e.ref(null),S=e.ref(!1),v=e.ref(!0),A=e.ref({}),k=e.ref({});(()=>{var a;if(!m.autoProvideA2UI)return;if(!m.a2uiCatalog)try{ie.useA2UIConfig();return}catch{}const t=(a=e.getCurrentInstance())==null?void 0:a.appContext.app,n=m.a2uiCatalog||ie.DEFAULT_CATALOG;!t||y.get(t)===n||(ie.provideA2UI({app:t,catalog:n,theme:ie.defaultTheme}),y.set(t,n))})();const V=ie.useMessageProcessor(),I=()=>{if(!B.value)return!0;const{scrollTop:t,scrollHeight:n,clientHeight:a}=B.value;return n-t-a<50},E=()=>{v.value=I()},T=t=>{var a,s;return!t||typeof t!="object"||t.version!=="v0.9"||[t.createSurface,t.updateComponents,t.updateDataModel,t.deleteSurface].filter(Boolean).length!==1?!1:t.createSurface?re(t.createSurface):t.updateComponents?ue(t.updateComponents):t.updateDataModel?typeof((a=C(t.updateDataModel))==null?void 0:a.surfaceId)=="string":t.deleteSurface?typeof((s=C(t.deleteSurface))==null?void 0:s.surfaceId)=="string":!1},C=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:null,re=t=>{const n=C(t);if(!n)return!1;const a=Object.keys(n);return typeof n.surfaceId=="string"&&typeof n.catalogId=="string"&&a.every(s=>s==="surfaceId"||s==="catalogId")},N=t=>Array.isArray(t)?t.every(n=>{const a=C(n);return!!(a&&typeof a.label=="string"&&typeof a.value=="string")}):!1,J=t=>Array.isArray(t)&&t.every(n=>typeof n=="string"),te=t=>Array.isArray(t)?t.every(n=>{const a=C(n);return!!(a&&typeof a.label=="string"&&typeof a.value=="string")}):!1,le=t=>{const n=C(t);return!(!n||typeof n.id!="string"||typeof n.component!="string"||Object.prototype.hasOwnProperty.call(n,"props")||Object.prototype.hasOwnProperty.call(n,"componentType")||Object.prototype.hasOwnProperty.call(n,"component_type")||n.facts!==void 0&&!N(n.facts)||n.tags!==void 0&&!J(n.tags)||["policyOptions","audienceOptions","detailOptions"].some(s=>n[s]!==void 0&&!te(n[s])))},ue=t=>{const n=C(t);return!n||typeof n.surfaceId!="string"||!Array.isArray(n.components)||n.components.length===0?!1:n.components.every(le)},H=t=>{const n=t.trim();if(!n)return null;const a=n.match(/^```(?:json|a2ui|agui|ag-ui)?\s*([\s\S]*?)\s*```$/i),s=a?a[1].trim():n;if(!s.startsWith("{")&&!s.startsWith("["))return null;try{return JSON.parse(s)}catch{return null}},Y=t=>{if(typeof t!="string")return null;const n=t.trim().toLowerCase();return n==="text_only"||n==="text-only"||n==="text"?"text_only":n==="ui_only"||n==="ui-only"||n==="ui"?"ui_only":n==="text_and_ui"||n==="text-and-ui"||n==="text+ui"||n==="both"?"text_and_ui":null},R=t=>{const n=Y(t);if(n)return n;if(typeof t=="string"){const s=H(t);return s?R(s):null}if(Array.isArray(t)){for(const s of t){const u=R(s);if(u)return u}return null}const a=C(t);return a&&(Y(a.displayMode)||Y(a.display_mode)||Y(a.a2uiDisplayMode)||Y(a.a2ui_display_mode)||R(a.metadata)||R(a.payload)||R(a.data))||null},x=t=>{if(!t)return[];if(typeof t=="string"){const u=H(t);return u?x(u):Array.from(t.matchAll(/```(?:agui|ag-ui|a2ui|json)\s*\n([\s\S]*?)\n```/gi)).flatMap(_=>{const $=H(_[1]);return $?x($):[]})}if(Array.isArray(t)){const u=t.map(_=>C(_)).filter(_=>!!_);return u.length===t.length&&u.every(T)?u:q(t)}if(typeof t!="object")return[];const n=t;if(T(n))return[n];const a=q(n);if(a.length>0)return a;const s=g(n);return s.length>0?s:[]},q=t=>{if(!t)return[];if(typeof t=="string"){const a=H(t);return a?q(a):[]}if(typeof t!="object")return[];if(Array.isArray(t))return t.map(s=>C(s)).filter(s=>!!s).flatMap(W);const n=t;return n.protocol==="ag-ui"?q(n.aguiEvents||n.agui_events):fe(n)?W(n):[]},fe=t=>{const n=String(t.type||"").toUpperCase();return n?n==="STATE_SNAPSHOT"?j(t.state).length>0:n==="STATE_DELTA"?j(t.delta).length>0:!0:!1},W=t=>{const n=String(t.type||"").toUpperCase();if(n==="STATE_SNAPSHOT"){const a=j(t.state);return a.length>0?a:f(t)}if(n==="STATE_DELTA"){const a=j(t.delta);return a.length>0?a:f(t)}return[]},j=t=>{const n=C(t);return n?[...x(n.a2uiMessages),...x(n.a2ui_messages),...x(n.a2ui)]:[]},i=t=>{const n=C(t);return n?W(n):[]},f=t=>[...i(t.rawEvent),...i(t.raw_event)],g=t=>{const n=[t.value,t.metadata,t.payload,t.data,t.a2uiMessages,t.a2ui_messages,t.a2ui,t.aguiEvents,t.agui_events,t.agui];for(const a of n){if(a===void 0||a===t)continue;const s=x(a);if(s.length>0)return s}return[]},b=t=>[...x(t.a2ui),...x(t.a2uiMessage),...x(t.a2uiMessages),...x(t.a2ui_message),...x(t.a2ui_messages),...x(t.agui),...x(t.aguiEvents),...x(t.agui_events),...x(t.metadata),...x(t.content)],L=t=>R(t.displayMode)||R(t.display_mode)||R(t.a2uiDisplayMode)||R(t.a2ui_display_mode)||R(t.metadata)||null,ne=t=>{var n,a,s,u;return((n=t==null?void 0:t.createSurface)==null?void 0:n.surfaceId)||((a=t==null?void 0:t.updateComponents)==null?void 0:a.surfaceId)||((s=t==null?void 0:t.updateDataModel)==null?void 0:s.surfaceId)||((u=t==null?void 0:t.deleteSurface)==null?void 0:u.surfaceId)||null},ae=(t,n)=>String(t.id||`index-${n}`),G=(t,n,a=!1)=>{const s={...k.value},u={...A.value},_=a?new Set(u[t]||[]):new Set;for(const $ of n){const U=ne($);U&&(s[U]=t,_.add(U))}u[t]=Array.from(_),k.value=s,A.value=u},pe=()=>{if(V.clearSurfaces(),A.value={},k.value={},!m.enableA2UI)return;const t=[];if(m.messages.forEach((n,a)=>{const s=b(n);if(s.length===0)return;const u=ae(n,a);G(u,s),t.push(...s)}),t.length!==0)try{V.processMessages(t)}catch(n){console.warn("[rt-chat-messages] A2UI payload render failed",n),M("a2ui-error",n)}},X=(t,n)=>{if(!m.enableA2UI)return[];if(L(t)==="text_only")return[];const s=ae(t,n);return(A.value[s]||[]).filter(u=>k.value[u]===s)},Z=t=>{const n=typeof t.content=="string"?t.content.trimStart():"";if(!n||b(t).length>0)return!1;const a=n.match(/^```([^\s\n`]*)?/);if(!a)return!1;const s=(a[1]||"").toLowerCase();return s?["a","ag","agu","agui","ag-","ag-u","ag-ui","a2","a2u","a2ui"].includes(s):!1},K=(t,n)=>!!(m.enableA2UI&&m.showA2UISkeleton&&m.isStreaming&&n===m.messages.length-1&&X(t,n).length===0&&Z(t)),F=(t,n)=>{if(!m.hideA2UIRawContent||t.attachments&&t.attachments.length>0)return!0;if(Z(t)||!t.content)return!1;if(b(t).length===0)return!0;const s=L(t);return s==="text_only"||s==="text_and_ui"?!0:s==="ui_only"?!1:X(t,n).length===0},ge=async t=>{var a;const n=(a=t==null?void 0:t.message)==null?void 0:a.action;M("a2ui-action",n,t);try{const s=m.a2uiActionHandler?await m.a2uiActionHandler(t):[],u=x(s);if(u.length>0){const _=k.value[n==null?void 0:n.surfaceId];_&&G(_,u,!0),V.processMessages(u),m.autoScroll&&!S.value&&(await e.nextTick(),ee("smooth"))}t.resolve(u)}catch(s){M("a2ui-error",s),t.reject(s instanceof Error?s:new Error(String(s)))}};let Q=0,oe=!1;const we=()=>{I()||(v.value=!1,S.value=!0)},ee=async(t="smooth",n=!1)=>{if(await e.nextTick(),B.value){if(n&&(S.value=!1),S.value)return;v.value=!0,oe=!0,B.value.scrollTo({top:B.value.scrollHeight,behavior:t}),setTimeout(()=>{oe=!1},50)}},Ee=t=>{if(M("scroll",t),!B.value)return;const n=B.value.scrollTop,a=n<Q;Q=n,!oe&&a&&(S.value=!0,v.value=!1),I()&&(v.value=!0,S.value=!1,M("scroll-bottom"))};e.watch(()=>m.messages.length,async(t,n)=>{t>(n||0)&&(S.value=!1,m.autoScroll&&ee("instant"))}),e.watch(()=>[m.messages,m.enableA2UI],pe,{deep:!0,immediate:!0});let o=null;e.watch(()=>m.messages,async()=>{if(!m.isStreaming||!m.autoScroll||S.value||document.hidden)return;const t=m.messages[m.messages.length-1];!t||t.role!=="assistant"||(o&&cancelAnimationFrame(o),o=requestAnimationFrame(async()=>{await e.nextTick(),B.value&&!S.value&&B.value.scrollTo({top:B.value.scrollHeight,behavior:"instant"})}))},{deep:!0}),e.watch(()=>m.isTyping,t=>{t&&m.autoScroll&&ee("instant")});const r=t=>{M("copy",t),navigator.clipboard&&t.content&&navigator.clipboard.writeText(t.content)};e.watch(()=>m.agentSteps,()=>{m.autoScroll&&!S.value&&ee()},{deep:!0});const c=()=>{m.autoScroll&&!S.value&&ee()},p=()=>{!document.hidden&&m.isStreaming&&m.autoScroll&&!S.value&&e.nextTick(()=>{B.value&&(B.value.scrollTo({top:B.value.scrollHeight,behavior:"instant"}),v.value=!0)})};let d;return e.onMounted(()=>{E(),d=V.onEvent(ge),document.addEventListener("visibilitychange",p)}),e.onUnmounted(()=>{d==null||d(),document.removeEventListener("visibilitychange",p)}),h({scrollToBottom:ee,containerRef:B}),(t,n)=>(e.openBlock(),e.createElementBlock("div",Dt,[l.showBackground?(e.openBlock(),e.createElementBlock("div",Ht)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"chat-message-list",ref_key:"containerRef",ref:B,onScroll:Ee,onWheel:we,onTouchmove:we,style:e.normalizeStyle({paddingTop:l.contentPaddingTop,paddingBottom:l.contentPaddingBottom})},[l.showWelcome&&l.messages.length===0?(e.openBlock(),e.createElementBlock("div",Pt,[e.renderSlot(t.$slots,"welcome",{},()=>[e.createElementVNode("div",Rt,[e.createElementVNode("div",Ft,[l.appLogo?(e.openBlock(),e.createElementBlock("img",{key:0,src:l.appLogo,alt:"Logo"},null,8,Ot)):(e.openBlock(),e.createElementBlock("div",Wt,[...n[1]||(n[1]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"32",height:"32"},[e.createElementVNode("path",{fill:"currentColor",d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"})],-1)])]))]),e.createElementVNode("h2",jt,e.toDisplayString(l.appName),1),n[2]||(n[2]=e.createElementVNode("p",{class:"welcome-desc"},"今天有什么可以帮您?",-1))])],!0)])):(e.openBlock(),e.createElementBlock("div",Yt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.messages,(a,s)=>(e.openBlock(),e.createElementBlock("div",{key:a.id||s,class:e.normalizeClass(["message-row",a.role==="user"?"message-user":"message-assistant"])},[a.role==="user"?(e.openBlock(),e.createElementBlock("div",qt,[e.createElementVNode("div",Xt,[e.createVNode(ke,{message:a,"is-user":!0,"api-base-url":l.apiBaseUrl},null,8,["message","api-base-url"])]),a.content?(e.openBlock(),e.createElementBlock("div",Zt,[e.createElementVNode("button",{class:"action-btn",onClick:u=>r(a),title:"复制"},[...n[3]||(n[3]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{fill:"currentColor",d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"})],-1),e.createElementVNode("span",null,"复制",-1)])],8,Kt)])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Jt,[l.showAgentSteps&&s===l.messages.length-1&&l.agentSteps&&l.agentSteps.length>0?(e.openBlock(),e.createBlock(Be,{key:0,steps:l.agentSteps,onResize:c},null,8,["steps"])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["message-bubble assistant-bubble",{"assistant-bubble-a2ui":X(a,s).length>0}])},[F(a,s)?(e.openBlock(),e.createBlock(ke,{key:0,message:a,"is-user":!1,"api-base-url":l.apiBaseUrl,"is-streaming":l.isStreaming&&s===l.messages.length-1},null,8,["message","api-base-url","is-streaming"])):e.createCommentVNode("",!0),X(a,s).length>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["a2ui-surfaces",{"a2ui-surfaces-with-content":F(a,s)}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(X(a,s),u=>(e.openBlock(),e.createBlock(e.unref(ie.A2UISurface),{key:u,"surface-id":u},null,8,["surface-id"]))),128))],2)):e.createCommentVNode("",!0),K(a,s)?(e.openBlock(),e.createElementBlock("div",Gt,[...n[4]||(n[4]=[e.createStaticVNode('<div class="skeleton-header" data-v-eac8b914><div class="skeleton-avatar skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-title-group" data-v-eac8b914><div class="skeleton-line skeleton-title skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-line skeleton-subtitle skeleton-shimmer" data-v-eac8b914></div></div></div><div class="skeleton-line skeleton-summary skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-line skeleton-summary short skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-facts" data-v-eac8b914><div class="skeleton-fact skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-fact skeleton-shimmer" data-v-eac8b914></div><div class="skeleton-fact skeleton-shimmer" data-v-eac8b914></div></div>',4)])])):e.createCommentVNode("",!0)],2),F(a,s)&&a.content&&!(l.isStreaming&&s===l.messages.length-1)?(e.openBlock(),e.createElementBlock("div",Qt,[e.createElementVNode("button",{class:"action-btn",onClick:u=>r(a),title:"复制"},[...n[5]||(n[5]=[e.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"12",height:"12"},[e.createElementVNode("path",{fill:"currentColor",d:"M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c6 6 14.1 9.4 22.6 9.4H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM352 853.3V704h149.3l-149.3 149.3zM224 256h448v640H416V672c0-17.7-14.3-32-32-32H224V256z"})],-1),e.createElementVNode("span",null,"复制",-1)])],8,en)])):e.createCommentVNode("",!0)]))],2))),128)),l.isTyping?(e.openBlock(),e.createElementBlock("div",tn,[...n[6]||(n[6]=[e.createElementVNode("div",{class:"typing-indicator"},[e.createElementVNode("div",{class:"typing-dot"}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.2s"}}),e.createElementVNode("div",{class:"typing-dot",style:{"animation-delay":"0.4s"}})],-1)])])):e.createCommentVNode("",!0)]))],36),e.createVNode(e.Transition,{name:"fade-slide"},{default:e.withCtx(()=>[v.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"scroll-to-bottom-btn",style:e.normalizeStyle({bottom:`calc(${l.contentPaddingBottom||"140px"} + 20px)`}),onClick:n[0]||(n[0]=a=>ee("smooth",!0))},[n[8]||(n[8]=e.createElementVNode("div",{class:"btn-inner"},[e.createElementVNode("svg",{class:"arrow-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2.5",d:"M19 9l-7 7-7-7"})])],-1)),l.isStreaming?(e.openBlock(),e.createElementBlock("svg",nn,[...n[7]||(n[7]=[e.createElementVNode("circle",{class:"loading-circle",cx:"18",cy:"18",r:"16"},null,-1)])])):e.createCommentVNode("",!0)],4))]),_:1})]))}}),[["__scopeId","data-v-eac8b914"]]),an={install(l){l.component("ChatMessageList",Ae),l.component("MultimodalMessage",ke),l.component("MarkdownMessage",Me),l.component("AgentSteps",Be)}};D.AgentSteps=Be,D.ChatMessageList=Ae,D.MarkdownMessage=Me,D.MultimodalMessage=ke,D.default=an,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));