0||e<0)?new b(t):(n<0?t=t.takeRight(-n):n&&(t=t.drop(n)),e!==o&&(e=I(e),t=e<0?t.dropRight(-e):t.take(e-n)),t)},b.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},b.prototype.toArray=function(){return this.take(Qn)},Vn(b.prototype,function(n,e){var t=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=u[r?"take"+(e=="last"?"Right":""):e],f=r||/^find/.test(e);i&&(u.prototype[e]=function(){var l=this.__wrapped__,a=r?[1]:arguments,c=l instanceof b,p=a[0],_=c||R(l),d=function(O){var W=i.apply(u,_e([O],a));return r&&v?W[0]:W};_&&t&&typeof p=="function"&&p.length!=1&&(c=_=!1);var v=this.__chain__,x=!!this.__actions__.length,T=f&&!v,S=c&&!x;if(!f&&_){l=S?l:new b(this);var m=n.apply(l,a);return m.__actions__.push({func:hr,args:[d],thisArg:o}),new On(m,v)}return T&&S?n.apply(this,a):(m=this.thru(d),T?r?m.value()[0]:m.value():m)})}),mn(["pop","push","shift","sort","splice","unshift"],function(n){var e=Dt[n],t=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);u.prototype[n]=function(){var i=arguments;if(r&&!this.__chain__){var f=this.value();return e.apply(R(f)?f:[],i)}return this[t](function(l){return e.apply(R(l)?l:[],i)})}}),Vn(b.prototype,function(n,e){var t=u[e];if(t){var r=t.name+"";M.call(ze,r)||(ze[r]=[]),ze[r].push({name:e,func:t})}}),ze[ur(o,Jn).name]=[{name:"wrapper",func:o}],b.prototype.clone=Ga,b.prototype.reverse=$a,b.prototype.value=qa,u.prototype.at=wh,u.prototype.chain=xh,u.prototype.commit=mh,u.prototype.next=Ah,u.prototype.plant=Th,u.prototype.reverse=Eh,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=Rh,u.prototype.first=u.prototype.head,lt&&(u.prototype[lt]=yh),u}),ve=ma();typeof o=="function"&&typeof o.amd=="object"&&o.amd?(j._=ve,o(function(){return ve})):Le?((Le.exports=ve)._=ve,Gr._=ve):j._=ve}).call(J_)})(Rt,Rt.exports)),Rt.exports}var Q_=X_();const k_={name:"jeecg-tool-exec",component:z_},V_={name:"jeecg-chart",component:Z_},Xi=new Map,Do=[];Ho(k_);Ho(V_);const No="jeecg-tag";function j_(H){const Pn=H.renderer.rules.html_block||function(o,zn){return o[zn].content};H.renderer.rules.html_block=function(o,zn){const en=o[zn].content;let z=!1,Un="";for(const J of Do){const X=new RegExp(`<${J}(\\s|>)`,"i"),se=new RegExp(`${J}>`,"i");if(X.test(en)||se.test(en)){z=!0,Un=J;break}}if(z){const J=document.createElement("div");J.innerHTML=en;const X=J.firstElementChild;return X.classList.add(No),X.outerHTML}return Pn(o,zn)}}function Ho(H){Xi.has(H.name)||(H.component=I_(H.component),Xi.set(H.name,H),Do.push(H.name))}const nd=["innerHTML"],ed=["src"],td={style:{"max-width":"240px",overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"}},rd={key:1,class:"error-message"},id=["innerHTML"],ud=S_({__name:"chatText",props:["dateTime","text","inversion","error","errorMsg","currentToolTag","loading","referenceKnowledge","isLast"],setup(H){const Pn=Fe(),{domainUrl:o}=U_(),{getIsMobile:zn}=D_(),un=H,en=Fe(),z=Fe(),Un=Fe(""),J=Fe(!1),X=Fe(""),se=Fe([]),Zn=new G_({html:!0,linkify:!0,highlight(L,A){if(!!(A&&Ji.getLanguage(A))){const P=A!=null?A:"";return ln(Ji.highlight(L,{language:P}).value,P)}return ln(Ji.highlightAuto(L).value,"")}});Zn.use(j_),Zn.use($_,{attrs:{target:"_blank",rel:"noopener"}}),Zn.use(q_,{blockClass:"katexmath-block rounded-md p-[10px]",errorColor:" #cc0000"});const Yn=Q_.throttle(()=>{var A;let L=(A=un.text)!=null?A:"";if(un.inversion!=="user"){L=he(L),L=Pe(L),X.value=Zn.render(L),In();return}X.value=L.replace(`
`,"
")},100),Ve=Mo(()=>{const{loading:L,referenceKnowledge:A}=un;return L?!1:Array.isArray(A)&&A.length>0}),ce=Mo(()=>{if(Ve.value)return!1;const L=un.text||"";if(!L)return!1;const A=/!\[.*?\]\(.*?\)/g;return A.test(L)?L.replace(A,"").trim().length===0:!1});Wo(()=>un.text,()=>Yn(),{immediate:!0}),Wo(()=>un.currentToolTag,()=>{const{isLast:L,inversion:A,currentToolTag:q,loading:P}=un;L&&A!="user"&&q&&P&&(X.value+=Zn.render(q),In())},{immediate:!0});function he(L){const A=/!\[([^\]]*)\]\(([^)]+)\s=([0-9]+)\)/g;L=L.replace(A,(ne,tn,V,an)=>{let Er=/#\s*{\s*domainURL\s*}/g;return V=V.replace(Er,o),``});const q=/!\[([^\]]*)\]\(([^)]+)\)/g,P=L.match(q),wn=P?P.length:0;return wn>0&&(L=L.replace(q,(ne,tn,V)=>{let an=/#\s*{\s*domainURL\s*}/g;return V=V.replace(an,o),wn>1?``:``})),L}function Pe(L){const A=/!\[([^\]]*)\]\(.*?#\s*{\s*domainURL\s*}.*?\)/g;return L.replace(A,q=>{let P=/#\s*{\s*domainURL\s*}/g;return q.replace(P,o)})}function ln(L,A){return`${L}
`}function Jn(){en.value&&en.value.querySelectorAll(".code-block-header__copy").forEach(A=>{A.addEventListener("click",()=>{var P,wn;const q=(wn=(P=A.parentElement)==null?void 0:P.nextElementSibling)==null?void 0:wn.textContent;q&&je(q).then(()=>{A.textContent="复制成功",setTimeout(()=>{A.textContent="复制代码"},1e3)})})})}function Lt(){en.value&&en.value.querySelectorAll(".code-block-header__copy").forEach(A=>{A.removeEventListener("click",()=>{})})}function vn(){en.value&&en.value.querySelectorAll("img").forEach(A=>{A.addEventListener("click",()=>{Un.value=A.src,J.value=!0})})}function ge(){en.value&&en.value.querySelectorAll("img").forEach(A=>{A.removeEventListener("click",()=>{})})}function Ln(){J.value=!1,Un.value=""}function Xn(){window.innerWidth>600&&window.innerWidth<1024?Pn.value=window.innerWidth-120+"px":window.innerWidth<600&&(Pn.value=window.innerWidth-60+"px")}function In(){return bo(this,null,function*(){if(yield C_(),!z.value)return;se.value=[],z.value.querySelectorAll("."+No).forEach(A=>{const q=A.nodeName.toLowerCase(),P=Xi.get(q);if(!P)return;const wn=A.querySelector("render");if(!wn){if(un.loading){A.innerHTML='图表渲染中,请稍候...
';return}A.innerHTML='模型返回的图表渲染格式不正确,请优化提示词或重新尝试。
';return}const ne=A.querySelector("data"),tn=(ne==null?void 0:ne.textContent)||"";Re(P,tn,wn)})})}function Re(L,A,q){se.value.push({key:N_(L.name+"_"+A).toString(),to:q,tag:L,data:A})}O_(()=>{Jn(),vn(),Xn(),window.addEventListener("resize",Xn)}),b_(()=>{Jn(),vn()}),W_(()=>{Lt(),ge(),window.removeEventListener("resize",Xn)});function je(L){return new Promise((A,q)=>{try{const P=document.createElement("textarea");P.setAttribute("readonly","readonly"),P.value=L,document.body.appendChild(P),P.select(),document.execCommand("copy")&&document.execCommand("copy"),document.body.removeChild(P),A(L)}catch(P){q(P)}})}return(L,A)=>{const q=xr("a-divider"),P=xr("a-space"),wn=xr("a-tag"),ne=xr("a-tooltip");return Fn(),Ee(mr,null,[X.value!=""?(Fn(),Ee("div",{key:0,class:Bo(["textWrap",[H.inversion==="user"?"self":ce.value?"chatgpt-image":"chatgpt"]]),ref_key:"textRef",ref:en},[H.inversion!="user"?(Fn(),Ee("div",{key:0,style:B_({width:Fo(zn)?Pn.value:"auto"})},[Tt("div",{ref_key:"markdownBodyRef",ref:z,class:Bo(["markdown-body",{"markdown-body-generate":H.loading}]),innerHTML:X.value},null,10,nd),Ve.value?(Fn(),Ee(mr,{key:0},[yr(q,{orientation:"left"},{default:Et(()=>[...A[0]||(A[0]=[M_("引用",-1)])]),_:1}),(Fn(!0),Ee(mr,null,Po(H.referenceKnowledge,(tn,V)=>{var an;return Fn(),Ar(ne,{key:V,title:(an=tn.content)==null?void 0:an.substring(0,800)},{default:Et(()=>[yr(wn,{style:{"min-width":"80px",background:"#F7F8FA","padding-inline":"0 7px"}},{default:Et(()=>[yr(P,{style:{"min-height":"30px","padding-left":"4px","padding-right":"4px","background-color":"#F0F1F6",color:"#788194"}},{default:Et(()=>[Tt("div",null,Yi("chunk-"+tn.chunk),1)]),_:2},1024),yr(P,{style:{"min-height":"30px","padding-left":"4px"}},{default:Et(()=>[Tt("img",{src:Fo(Y_),width:"14",height:"14",style:{position:"relative",top:"-2px"}},null,8,ed),Tt("div",td,Yi(tn.docName),1)]),_:2},1024)]),_:2},1024)]),_:2},1032,["title"])}),128))],64)):yt("",!0),H.error?(Fn(),Ee("div",rd,[Tt("p",null,Yi(H.errorMsg),1)])):yt("",!0)],4)):(Fn(),Ee("div",{key:1,class:"msg",innerHTML:X.value},null,8,id))],2)):yt("",!0),J.value?(Fn(),Ar(K_,{key:1,imageUrl:Un.value,onHide:Ln},null,8,["imageUrl"])):yt("",!0),se.value.length?(Fn(!0),Ee(mr,{key:2},Po(se.value,tn=>(Fn(),Ar(F_,{key:tn.key,to:tn.to},[(Fn(),Ar(P_(tn.tag.component),{data:tn.data,loading:H.loading},null,8,["data","loading"]))],8,["to"]))),128)):yt("",!0)],64)}}}),Rd=H_(ud,[["__scopeId","data-v-d1adb923"]]);export{Rd as default};