PageSourceSearch

https://vc.ru/assets/TerminalChat-RcHWOY_F.js

js vc.ru collected 2026-10-01 07:58:49 UTC 16,783 bytes, 18 lines download raw bytes

1import{dw as ke,y as ie,W as Me,o as xe,aq as x,r as I,v as S,ef as se,eg as we,eJ as Be,bH as He,dv as C,d as _,a as m,b as E,S as h,p as w,t as oe,c as B,f as $,cP as Pe,s as W,U as G,b5 as Fe,f0 as Ue,f1 as Ie,df as j,Z as We,D as ae,F as O,L as ce,e as D,aC as X,bQ as je,av as Ne,w as Oe,bj as De}from"./index-BXQnu0Fm.js";import{r as qe,u as ue,g as Ke,b as Ve}from"./index-Dr_o1GSC.js";import{u as ze}from"./useTerminalSettings-DrZ2ER6A.js";import{u as Xe}from"./useTerminalChatScroll-FM4lP-Xu.js";import{u as Qe}from"./useEnergyBalance-Cl9rcAHv.js";import{T as Je}from"./TokensExhausted--IJUMB7u.js";const Ye=ke(e=>{var T;const t=qe(),{t:n}=ue(),{alert:s,AlertType:l}=ie(),i=(T=ze)==null?void 0:T(),{recallAfterAuth:r}=Me(),d=I(!1),a=I(!1),u=S(()=>He(e)),y=S(()=>u.value.length===0?[]:t.getMessages(u.value)),M=S(()=>y.value.some(c=>c.isPending===!0));async function R(){const c=u.value;if(c.length===0)return;if(!se()){a.value=!0;return}if(t.getMessages(c).some(A=>A.isPending===!0||A.isError===!0)){a.value=!0;return}const f=t.getChats().find(A=>A.uuid===c);if(f!==void 0&&f.userId===0&&t.getMessages(c).length===0){a.value=!0;return}d.value=!0;try{await t.loadMessages(c),a.value=!0}catch(A){console.error(A),!(f===void 0||f.userId===0)&&t.getMessages(c).length===0&&s({type:l.Error,text:n("terminal.errorLoadMessages")}),a.value=!0}finally{d.value=!1}}async function b(c){const f=u.value;if(!(f.length===0||c.length===0))try{await r(async()=>{var v;if(!se())throw new we;await t.resendMessage(f,c,((v=i==null?void 0:i.model)==null?void 0:v.value)??Be)})}catch(v){console.error(v),v instanceof Error&&v.message==="ENERGY_EXHAUSTED"&&s({type:l.Error,text:n("terminal.tokensExhaustedTitle")})}}function L(c){const f=u.value;f.length===0||c.length===0||t.removeFailedMessage(f,c)}return xe(()=>{R()}),x(u,()=>{a.value=!1,R()}),x(()=>t.getSessionEpoch(),(c,f)=>{f===void 0||c===f||(a.value=!1,R())}),{messages:y,isLoading:d,isLoaded:a,isSending:M,load:R,resend:b,removeFailed:L}});function _e(e){const t=e.trim();return/^https?:\/\//i.test(t)||t.startsWith("/")||t.startsWith("#")?t:null}function H(e){return e.length===0?"":e.split(/(`[^`]+`)/g).map(n=>{if(n.length>=2&&n.startsWith("`")&&n.endsWith("`"))return`<code class="md-inline-code">${C(n.slice(1,-1))}</code>`;const s=[],l=/\[([^\]]+)\]\(([^)\s]+)\)/g;let i=0;for(const r of n.matchAll(l)){const d=r.index??0;d>i&&s.push(le(n.slice(i,d)));const a=r[1]??"",u=r[2]??"",y=_e(u);y===null?s.push(C(r[0])):s.push(`<a href="${C(y)}" target="_blank" rel="noopener noreferrer">${C(a)}</a>`),i=d+r[0].length}return i<n.length&&s.push(le(n.slice(i))),s.join("")}).join("")}function le(e){if(e.length===0)return"";const t=[],n=new RegExp(["\\*\\*([^*]+)\\*\\*","__([^_]+)__","~~([^~]+)~~","\\*([^*]+)\\*","_([^_]+)_"].join("|"),"g");let s=0;for(const l of e.matchAll(n)){const i=l.index??0;i>s&&t.push(C(e.slice(s,i))),l[1]!==void 0?t.push(`<strong>${C(l[1])}</strong>`):l[2]!==void 0?t.push(`<strong>${C(l[2])}</strong>`):l[3]!==void 0?t.push(`<del>${C(l[3])}</del>`):l[4]!==void 0?t.push(`<em>${C(l[4])}</em>`):l[5]!==void 0&&t.push(`<em>${C(l[5])}</em>`),s=i+l[0].length}return s<e.length&&t.push(C(e.slice(s))),t.join("")}const de={pattern:/^```([^\n`]*)\n([\s\S]*?)\n```(?:\n|$)/,render(e){return Y(e[1]??"",e[2]??"")}};function J(e){return(e.trim().split(/\s+/)[0]??"").toLowerCase()}function Y(e,t,n=!1){const s=J(e),l=s.length>0?` class="language-${C(s)}"`:"";return`<pre class="md-code${n?" md-code--open":""}"><code${l}>${C(t)}</code></pre>`}const Ge={pattern:/^(#{1,6})[ \t]+(.+?)(?:\n|$)/,completesPreviousParagraph:!0,render(e){var s;const t=((s=e[1])==null?void 0:s.length)??1,n=H((e[2]??"").trimEnd());return`<h${t} class="md-heading">${n}</h${t}>`}};function Ze(e){return/^[ \t]*(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/.test(e)}const et={pattern:/^[ \t]*(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})(?:\n|$)/,completesPreviousParagraph:!0,render(){return'<hr class="md-hr">'}},tt={pattern:/^(?:>[ \t]?[^\n]*(?:\n|$))+/,completesPreviousParagraph:!0,continuesAcrossNewlines:!0,render(e){const t=e[0].replace(/\n$/,"").split(`
2`).map(n=>n.replace(/^>[ \t]?/,"")).join(`
3`).replace(/\n+$/,"");return`<blockquote class="md-quote">${H(t).replaceAll(`
4`,"<br>")}</blockquote>`}},fe={pattern:new RegExp(["^","[^\\n]*\\|[^\\n]*\\n","\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?[ \\t]*(?:\\n|$)","(?:[^\\n]*\\|[^\\n]*(?:\\n|$))*"].join("")),completesPreviousParagraph:!0,continuesAcrossNewlines:!0,render(e){return ge(e[0])}};function Z(e){return/^\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?[ \t]*$/.test(e.trim())}function nt(e){const t=e.trim();return t.length===0||!t.includes("|")?!1:!Z(t)}function he(e){const t=e.replace(/\n$/,"").split(`
5`).filter(n=>n.trim().length>0);return t.length===0||!nt(t[0]??"")?!1:t.length===1?!0:Z(t[1]??"")}function N(e){let t=e.trim();
5return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())}function st(e){return N(e).map(t=>{const n=t.startsWith(":"),s=t.endsWith(":");return n&&s?"center":s?"right":n?"left":null})}function Q(e){return H(e)}function re(e){return e==null?"":` style="text-align:${e}"`}function ge(e){const t=e.replace(/\n$/,"").split(`
6`).filter(d=>d.trim().length>0);if(t.length===0)return"";if(t.length===1||!Z(t[1]??""))return`<div class="md-table-wrap"><table class="md-table"><tbody><tr>${N(t[0]??"").map(u=>`<td>${Q(u)}</td>`).join("")}</tr></tbody></table></div>`;const n=st(t[1]??""),l=N(t[0]??"").map((d,a)=>`<th${re(n[a])}>${Q(d)}</th>`).join(""),i=t.slice(2).map(d=>`<tr>${N(d).map((u,y)=>`<td${re(n[y])}>${Q(u)}</td>`).join("")}</tr>`).join(""),r=i.length>0?`<tbody>${i}</tbody>`:"";return`<div class="md-table-wrap"><table class="md-table"><thead><tr>${l}</tr></thead>${r}</table></div>`}const me={pattern:new RegExp(["^","(?:","[ \\t]*","(?:[-*+]|\\d+[.)])","(?:[ \\t]+[^\\n]*)?","(?:\\n+|$)",")+"].join("")),completesPreviousParagraph:!0,continuesAcrossNewlines:!0,render(e){return ye(e[0])}},lt=/^([ \t]*)([-*+]|\d+[.)])(?:[ \t]+(.*))?$/;function rt(e){let t=0;for(const n of e)n==="	"?t+=2:t+=1;return t}function ee(e){const t=lt.exec(e);if(t===null)return null;const n=t[1]??"",s=t[2]??"",l=e.slice(n.length+s.length);return(s==="*"||s==="-")&&l.startsWith(s)?null:{indent:rt(n),ordered:/^\d/.test(s),text:t[3]??""}}function q(e){const t=e.replace(/\n$/,"").split(`
7`).filter(n=>n.trim().length>0);return t.length>0&&t.every(n=>ee(n)!==null)}function it(e){var s;const t=[],n=[];for(const l of e){const i={ordered:l.ordered,text:l.text,children:[]};for(;n.length>0&&l.indent<=(((s=n.at(-1))==null?void 0:s.indent)??0);)n.pop();const r=n.at(-1);r===void 0?t.push(i):r.node.children.push(i),n.push({indent:l.indent,node:i})}return t}function pe(e){var s,l;if(e.length===0)return"";let t="",n=0;for(;n<e.length;){const i=((s=e[n])==null?void 0:s.ordered)===!0,r=[];for(;n<e.length&&((l=e[n])==null?void 0:l.ordered)===i;){const u=e[n];u!==void 0&&r.push(u),n+=1}const d=i?"ol":"ul",a=r.map(u=>{const y=pe(u.children);return`<li>${H(u.text)}${y}</li>`}).join("");t+=`<${d} class="md-list">${a}</${d}>`}return t}function ye(e){const t=e.replace(/\n$/,"").split(`
8`).filter(n=>n.trim().length>0).map(n=>ee(n)).filter(n=>n!==null);return pe(it(t))}const ot={pattern:/^[\s\S]+/,render(e){const t=e[0].replace(/\n$/,"");return`<p class="md-paragraph">${H(t).replaceAll(`
9`,"<br>")}</p>`}},ve=[de,Ge,fe,et,tt,me,ot];function at(e){let t=0;for(;;){const n=e.indexOf(`
10`,t);if(n===-1)return null;const s=e.slice(n+1);if(s.startsWith("```"))return{newlineAt:n,rule:de};for(const l of ve){if(l.completesPreviousParagraph!==!0)continue;const i=l.pattern.exec(s);if(i!==null&&i.index===0)return{newlineAt:n,rule:l}}t=n+1}}function ct(e,t){if(t.continuesAcrossNewlines!==!0)return!1;if(t===me)return q(e);if(t===fe)return he(e);const n=t.pattern.exec(e);if(n===null||n.index!==0)return!1;const s=e.slice(n[0].length);return s.length===0||/^[\n]*$/.test(s)}function te(e){if(e.length===0||/^\n+$/.test(e))return"";for(const n of ve){const s=n.pattern.exec(e);if(s===null||s.index!==0)continue;const l=e.slice(s[0].length);if(!(l.length>0&&!/^[\n]*$/.test(l)))return n.render(s)}const t=e.replace(/\n$/,"");return`<p class="md-paragraph">${H(t).replaceAll(`
11`,"<br>")}</p>`}function ut(e,t=!1){var i;if(e.length===0)return null;const n=/^(\n+)/.exec(e);if(n!==null)return{block:n[1]??"",rest:e.slice(((i=n[1])==null?void 0:i.length)??0)};if(e.startsWith("```")){const r=/^```[^\n`]*\n([\s\S]*?)\n```(?:\n|$)/.exec(e);return r===null?t?{block:e,rest:""}:null:{block:r[0],rest:e.slice(r[0].length)}}if(/^#{1,6}[ \t]+/.test(e)){const r=e.indexOf(`
12`);return r===-1?t?{block:e,rest:""}:null:{block:e.slice(0,r+1),rest:e.slice(r+1)}}if(Ze(e.split(`
13`)[0]??"")){const r=e.indexOf(`
14`);return r===-1?t?{block:e,rest:""}:null:{block:e.slice(0,r+1),rest:e.slice(r+1)}}const s=at(e);
14if(s!==null){const r=e.slice(0,s.newlineAt);if(r.length>0&&!ct(r,s.rule))return{block:e.slice(0,s.newlineAt+1),rest:e.slice(s.newlineAt+1)}}let l=0;for(;;){const r=e.indexOf(`
15
16`,l);if(r===-1)break;const d=e.slice(0,r),a=e.slice(r+2),u=a.split(`
17`).find(y=>y.trim().length>0)??"";if(q(d)&&ee(u)!==null){l=r+2;continue}return!t&&q(d)&&u.length===0?null:{block:e.slice(0,r+2),rest:a}}return t?{block:e,rest:""}:null}function $e(e){if(e.length===0)return"";if(e.startsWith("```")){const t=e.indexOf(`
18`);if(t===-1){const l=J(e.slice(3));return Y(l,"",!0)}const n=J(e.slice(3,t)),s=e.slice(t+1);return Y(n,s,!0)}return q(e)?ye(e):he(e)?ge(e):te(e)}function dt(){let e="",t="",n="",s=!1,l="",i="";return{get completedLength(){return e.length},get completedHtml(){return t},get openHtml(){return i},reset(){e="",t="",n="",s=!1,l="",i=""},render(r,d=!1){if(r===n&&d===s)return l;e.length>0&&!r.startsWith(e)&&(e="",t="");let a=r.slice(e.length);for(;;){const u=ut(a,!1);if(u===null||u.block.length===0)break;t+=te(u.block),e+=u.block,a=u.rest}return d&&a.length>0&&(t+=ft(a),e+=a,a=""),i=$e(a),l=t+i,n=r,s=d,l}}}function ft(e){return e.startsWith("```")&&!/^```[^\n`]*\n([\s\S]*?)\n```(?:\n|$)/.test(e)?$e(e):te(e)}const ht=["src","alt"],gt=_({__name:"TerminalAttachment",props:{type:{},filename:{},mediaType:{},previewUrl:{default:""},removable:{type:Boolean,default:!1}},emits:["remove"],setup(e,{emit:t}){const n=e,s=t,l=S(()=>Ke(n.filename,n.mediaType));return(i,r)=>(m(),E("div",{class:h(i.$style.attachment)},[w("div",{class:h(i.$style.content)},[e.type==="image"&&e.previewUrl.length>0?(m(),E("img",{key:0,class:h(i.$style.preview),src:e.previewUrl,alt:e.filename},null,10,ht)):(m(),E("div",{key:1,class:h(i.$style.extension)},oe(l.value),3))],2),e.removable?(m(),B($(Pe),{key:0,onClick:r[0]||(r[0]=d=>s("remove"))})):W("",!0)],2))}}),mt="Xy-wqTKw",pt="hkVHHy-V",yt="C0Ez4Pop",vt="JrEYjq2N",$t={attachment:mt,content:pt,preview:yt,extension:vt,"underlay-in":"_4zExdJs-","modal-enter":"_65C4hoKU","modal-enter-slide":"TRySQHVg"},bt={$style:$t},Ct=G(gt,[["__cssModules",bt]]),Et=30,Tt=400,At=_({__name:"MessageBubble",props:{message:{},isResendDisabled:{type:Boolean}},emits:["resend","remove"],setup(e,{emit:t}){const n=e,s=t,{t:l}=ue(),{copy:i}=Fe(),{alert:r,AlertType:d}=ie(),{colorMode:a}=Ue(),{highlightElement:u}=Ie(a),y=j("contentEl"),M=j("completedEl"),R=j("openEl"),b=I(""),L=I(""),T=I(""),c=dt();let f=null;const v=S(()=>n.message.content.length>0&&n.message.isPending!==!0);function A(){return n.message.role==="assistant"&&n.message.isPending===!0}function P(){V(),b.value=n.message.content,F()}const K=S(()=>n.message.metadata.map((o,g)=>{var U;const p=(U=n.message.attachments)==null?void 0:U[g];return{key:`${o.type}-${o.filename}-${g}`,type:o.type,filename:o.filename,mediaType:o.mediaType,previewUrl:Ve(o,p)}}));async function be(){try{await i(n.message.content),r({type:d.Success,text:l("terminal.messageCopied")})}catch{r({type:d.Error,text:l("terminal.errorCopy")})}}function V(){f!==null&&(clearTimeout(f),f=null)}function F(){const o=b.value.length>=n.message.content.length,g=n.message.isPending!==!0&&o;c.render(b.value,g),L.value=c.completedHtml,T.value=c.openHtml}async function Ce(){await Ne();const o=y.value;if(o==null)return;const g=o.querySelectorAll("pre.md-code > code");for(const p of g)p.dataset.highlighted!=="yes"&&await u(p)}function ne(o,g){o!=null&&(o.innerHTML=g)}x([L,T],je(()=>{Ce()},40)),x([L,T,M,R],([o,g,p,U],k)=>{const Ae=k===void 0||o!==k[0],Le=k===void 0||p!==k[2],Re=k===void 0||g!==k[1],Se=k===void 0||U!==k[3];(Ae||Le)&&ne(p,o),(Re||Se)&&ne(U,g)},{flush:"post"});function Ee(){f=null;const o=n.message.content,g=b.value;if(o.length-g.length>Tt){b.value=o,F();return}const p=o.indexOf(" ",g.length);b.value=o.slice(0,p===-1?o.length:p+1),F(),b.value.length<o.length&&z(Et)}function z(o=0){if(f===null){if(b.value.length>=n.message.content.length){F();return}f=setTimeout(Ee,o)}}const Te=S(()=>n.message.localId??`${n.message.role}-${n.message.dateCreated}`);return x(Te,()=>{if(V(),c.reset(),b.value="",L.value="",T.value="",A()){z();return}P()}),x(()=>n.message.content,()=>{if(A()){z();return}P()},{immediate:!0}),x(()=>n.message.isPending,()=>{F()}),We(V),(o,g)=>(m(),E("div",{class:h([o.$style.root,{[o.$style.user]:e.message.role==="user",[o.$style.assistant]:e.message.role==="assistant"}])}
18,[w("div",{class:h([o.$style.bubble,{[o.$style.pending]:e.message.isPending===!0}])},[e.message.isPending===!0&&e.message.content.length===0&&K.value.length===0?(m(),B($(ae),{key:0,class:h(o.$style.loader)},null,8,["class"])):(m(),E(O,{key:1},[K.value.length>0?(m(),E("div",{key:0,class:h(o.$style.attachments)},[(m(!0),E(O,null,ce(K.value,p=>(m(),B(Ct,{key:p.key,type:p.type,filename:p.filename,"media-type":p.mediaType,"preview-url":p.previewUrl},null,8,["type","filename","media-type","preview-url"]))),128))],2)):W("",!0),e.message.content.length>0||e.message.isPending===!0?(m(),E("div",{key:1,ref_key:"contentEl",ref:y,class:h([o.$style.content,{[o.$style.split]:L.value.length>0&&T.value.length>0}])},[w("div",{ref_key:"completedEl",ref:M,class:h(o.$style.completed)},null,2),w("div",{ref_key:"openEl",ref:R,class:h(o.$style.open)},null,2)],2)):W("",!0)],64))],2),e.message.isError===!0?(m(),E("div",{key:0,class:h(o.$style.errorRow)},[w("span",{class:h(o.$style.errorLabel)},oe($(l)("terminal.sendFailed")),3),D($(X),{icon:"refresh","icon-size":16,"is-negative":"",disabled:e.isResendDisabled,"aria-label":$(l)("terminal.resend"),onClick:g[0]||(g[0]=p=>s("resend"))},null,8,["disabled","aria-label"]),D($(X),{icon:"delete","icon-size":16,"is-negative":"","aria-label":$(l)("terminal.deleteMessage"),onClick:g[1]||(g[1]=p=>s("remove"))},null,8,["aria-label"])],2)):v.value?(m(),B($(X),{key:1,icon:"copy","icon-size":16,class:h(o.$style.copy),"aria-label":$(l)("terminal.copyMessage"),onClick:be},null,8,["class","aria-label"])):W("",!0)],2))}}),Lt="IQATH4MS",Rt="sFes5CqU",St="h3tI2vtt",kt="VvymoD0a",Mt="r9hfvQ--",xt="m33vK4Fy",wt="Kp1F0jwA",Bt="tXe9qyuD",Ht="joXvdByx",Pt="lCyiEdkX",Ft="xFryT2yQ",Ut="JtzmgD7Z",It="mTgfmHl1",Wt={root:Lt,user:Rt,assistant:St,bubble:kt,pending:Mt,attachments:xt,content:wt,loader:Bt,copy:Ht,errorRow:Pt,errorLabel:Ft,split:Ut,completed:It,"underlay-in":"z3jqkgRA","modal-enter":"KBayISRv","modal-enter-slide":"vbIB-YGU"},jt={$style:Wt},Nt=G(At,[["__cssModules",jt]]),Ot=_({__name:"TerminalChat",props:{chatUuid:{}},setup(e){var L,T;const t=e,n=S(()=>t.chatUuid),{messages:s,isLoading:l,isSending:i,resend:r,removeFailed:d}=Ye(n),a=(L=Qe)==null?void 0:L(),u=S(()=>(a==null?void 0:a.isExhausted.value)===!0),y=j("chatBody"),M=j("pinSentinel");(T=Xe)==null||T({scrollable:y,pinSentinel:M,chatUuid:n,messages:s});function R(c){const f=c.localId;f===void 0||f.length===0||r(f)}function b(c){const f=c.localId;f===void 0||f.length===0||d(f)}return(c,f)=>(m(),E("div",{class:h(c.$style.chat)},[D($(De),{ref_key:"chatBody",ref:y,class:h(c.$style.body),"ignore-content-mutations":"","stick-to-bottom":""},{default:Oe(()=>[w("div",{ref_key:"pinSentinel",ref:M,class:h(c.$style.pinSentinel),"aria-hidden":"true"},null,2),w("div",{class:h(c.$style.content)},[$(l)&&$(s).length===0?(m(),E("div",{key:0,class:h(c.$style.loader)},[D($(ae))],2)):(m(),E(O,{key:1},[(m(!0),E(O,null,ce($(s),(v,A)=>(m(),B(Nt,{key:v.localId??`${v.role}-${v.dateCreated}-${A}`,message:v,"is-resend-disabled":$(i),onResend:P=>R(v),onRemove:P=>b(v)},null,8,["message","is-resend-disabled","onResend","onRemove"]))),128)),u.value?(m(),B(Je,{key:0,class:h(c.$style.exhausted)},null,8,["class"])):W("",!0)],64))],2)]),_:1},8,["class"])],2))}}),Dt="_1SFXoK8m",qt="dqEDnGV7",Kt="fp313bo3",Vt="t2dYqDXk",zt="lNxn7mJM",Xt="Us382ChX",Qt={chat:Dt,body:qt,content:Kt,pinSentinel:Vt,exhausted:zt,loader:Xt,"underlay-in":"CAQ6m2e6","modal-enter":"L05UenSK","modal-enter-slide":"v8AWxAOz"},Jt={$style:Qt},nn=G(Ot,[["__cssModules",Jt]]);export{nn as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.