teodor-new-chat-ui 4.3.135 → 4.3.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2 -2
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -12834,9 +12834,9 @@ const Au = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, rS = (e) =>
|
|
|
12834
12834
|
/* @__PURE__ */ u.jsxs("div", { className: "relative flex-1 overflow-y-auto pt-5 pb-5 pr-1", children: [
|
|
12835
12835
|
/* @__PURE__ */ u.jsxs("div", { className: "absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: [
|
|
12836
12836
|
/* @__PURE__ */ u.jsx("span", { children: "Timeline" }),
|
|
12837
|
-
/* @__PURE__ */ u.jsxs("div", { className: "group relative", children: [
|
|
12837
|
+
/* @__PURE__ */ u.jsxs("div", { className: "group relative z-50", children: [
|
|
12838
12838
|
/* @__PURE__ */ u.jsx(wg, { className: "h-3.5 w-3.5 text-muted-foreground cursor-help" }),
|
|
12839
|
-
/* @__PURE__ */ u.jsx("div", { className: "pointer-events-auto
|
|
12839
|
+
/* @__PURE__ */ u.jsx("div", { className: "pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed", style: { zIndex: 9999 }, children: 'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.' })
|
|
12840
12840
|
] })
|
|
12841
12841
|
] }),
|
|
12842
12842
|
/* @__PURE__ */ u.jsx("div", { className: "pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50" }),
|
package/dist/index.umd.js
CHANGED
|
@@ -126,7 +126,7 @@ ${t}</tr>
|
|
|
126
126
|
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Qs{constructor(t){this.options=t||_r}preprocess(t){return t}postprocess(t){return t}}qm(Qs,"passThroughHooks",new Set(["preprocess","postprocess"]));function Wb(e,t,n){return r=>{if(r.message+=`
|
|
127
127
|
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+nn(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Tf(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ee.defaults,...s};const i=Wb(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(Bb(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let h;if(!f)try{r.walkTokens&&Ee.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;Ee.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return c(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Ee.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&Ee.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ee(e,t,n){return Tf(dr.lex,fr.parse)(e,t,n)}Ee.options=Ee.setOptions=function(e){return Ee.defaults={...Ee.defaults,...e},Nb(Ee.defaults),Ee},Ee.getDefaults=hf,Ee.defaults=_r,Ee.use=function(...e){const t=Ee.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ee.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=Ee.defaults.renderer||new el;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Ee.defaults.tokenizer||new Qa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Ee.defaults.hooks||new Qs;for(const s in n.hooks){const i=o[s];Qs.passThroughHooks.has(s)?o[s]=a=>{if(Ee.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Ee.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}Ee.setOptions(r)})},Ee.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ee,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ee.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ee.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ee.walkTokens(r.items,t));break}default:Ee.defaults.extensions&&Ee.defaults.extensions.childTokens&&Ee.defaults.extensions.childTokens[r.type]?Ee.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ee.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ee.walkTokens(r.tokens,t)))}return n},Ee.parseInline=Tf(dr.lexInline,fr.parseInline),Ee.Parser=fr,Ee.parser=fr.parse,Ee.Renderer=el,Ee.TextRenderer=Cf,Ee.Lexer=dr,Ee.lexer=dr.lex,Ee.Tokenizer=Qa,Ee.Slugger=kf,Ee.Hooks=Qs,Ee.parse=Ee,Ee.options,Ee.setOptions,Ee.use,Ee.walkTokens,Ee.parseInline,fr.parse,dr.lex;function Mo({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Ee.parse(i)}return Ee.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}const Vb="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function Kb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ef(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function ei(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function qb(e){const t=o=>{try{const s=Ro(o);return typeof s=="string"?s:JSON.stringify(s??"")}catch{return""}},n=e.filter(o=>o.type==="text");let r="";return n.length?r=t(n.map(o=>o.text).join(`
|
|
128
128
|
`)):r=t(e),r||""}function Gb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function If(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Yb({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const tl=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:m,onCancelEdit:g,onCopy:x,activeInterrupt:y,disableInterruptActions:w=!1,onInterruptActionStart:C,onInterruptActionEnd:T,checkpointCandidates:k=[],activeCheckpointId:S=null,onSelectCheckpoint:E,defaultCheckpointId:j=null,messageParentCheckpointId:_=null}){const[P,D]=b.useState(!1),[z,B]=b.useState("preview"),[O,H]=b.useState(!1),{currentThreadId:R}=ps(),{respondToInterrupt:V}=ms(),$=l==="phone"||l==="half-screen",F=t.role,ne=F==="tool",Q=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),xe=!!Q,_e=!(r&&F!=="user"),{uploadingFiles:J,handleFileClick:ue,fileViewerOpen:Ce,currentFileInfo:te,closeFileViewer:L}=Jb({allowFileOpen:_e,currentThreadId:R}),q=b.useMemo(()=>{switch(F){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[F]),ie=b.useMemo(()=>Q?"":Kb(t.content),[Q,t]),ce=b.useMemo(()=>Q?{}:Ef(t),[Q,t]),U=b.useMemo(()=>Q?[]:t.content.filter(G=>G.type==="image_url"),[Q,t]),We=b.useMemo(()=>Q?[]:t.content.filter(G=>G.type==="file"),[Q,t]),re=b.useMemo(()=>Q?[]:t.content.filter(G=>G.type==="interrupt"),[Q,t]),ye=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Pe=ei(ye),$e=y==null?void 0:y.value,rt=b.useMemo(()=>Q?"":qb(t.content),[Q,t]),be=b.useCallback(async()=>{const G=ne?rt:ie;async function ke(ve){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ve);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const pt=new Blob([ve],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":pt})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ke(G),D(!0),setTimeout(()=>D(!1),2e3),x==null||x(G)}catch(ve){console.error("Failed to copy:",ve)}},[ne,rt,ie,x]),Ye=b.useCallback(()=>{if(!p)return;const G=ne?rt:ie,ke="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};p(t.id,G,ke)},[p,t.id,ne,rt,ie,t]),ot=b.useCallback(()=>{m==null||m(n)},[m,n]),et=b.useCallback(()=>{const ke=oe($?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",q);switch(F){case"user":return u.jsx(he.User,{className:ke});case"assistant":return u.jsx(he.Bot,{className:ke});case"tool":return u.jsx(he.Wrench,{className:ke});default:return u.jsx(he.Bot,{className:ke})}},[$,q,F]),Xe=b.useCallback(()=>{const G="group relative mb-4 flex w-full";switch(F){case"user":return oe(G,"justify-end");case"assistant":case"tool":case"system":return oe(G,"justify-start");default:return G}},[F]),Ke=b.useCallback(()=>{const G=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",$&&"px-3 py-2 text-sm");if(xe)return oe(G,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(F){case"user":return oe(G,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return oe(G,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(G,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(G,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(G,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[$,xe,F]);if(xe&&Q)return u.jsx("div",{className:oe(Xe(),h.container),children:u.jsxs("div",{className:oe(Ke(),h.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(he.Bot,{className:oe("h-4 w-4",q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mo,{content:Q.content,className:"text-current"})]})});const tt=b.useCallback(async G=>{if(w)return;const ke=ei((G==null?void 0:G.id)??(G==null?void 0:G.interrupt_id));if(!ke){console.warn("Interrupt part missing id",G);return}try{C==null||C(),await V(ke,!0)}catch(ve){console.error("Failed to approve interrupt:",ve)}finally{T==null||T()}},[w,T,C,V]),Ot=b.useCallback(async G=>{if(w)return;const ke=ei((G==null?void 0:G.id)??(G==null?void 0:G.interrupt_id));if(!ke){console.warn("Interrupt part missing id",G);return}try{C==null||C(),await V(ke,!1)}catch(ve){console.error("Failed to reject interrupt:",ve)}finally{T==null||T()}},[w,T,C,V]),St=b.useCallback(({part:G,i:ke})=>{if(G.type==="text"){const ve=G.text??"",pt=ve.trim(),mt=La(pt);return mt&&F!=="tool"?u.jsx(Nf,{data:mt},ke):F==="user"&&c&&pt.length>d?u.jsx(Zb,{text:pt,expanded:O,onExpandedChange:H,previewLength:d,isCompact:$},ke):u.jsx(Mo,{content:ve,allowHtml:!1},ke)}if(G.type==="image_url"){const ve=G;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ke)}if(G.type==="file"){const ve=G,pt=ve.name||"file";return u.jsxs("a",{href:ve.url,onClick:mt=>ue(mt,ve,ke),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ke]?u.jsx(he.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[pt,J[ke]?" (processing)":""]})]},ke)}if(G.type==="interrupt"){const ve=G,pt=ei((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),mt=!!(Pe&&pt&&pt===Pe),ct=mt?$e??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,Me=pt?{...ve,id:pt,interrupt_id:pt}:ve;return u.jsx(Xb,{interruptPart:Me,onApprove:tt,onReject:Ot,disabled:w,isActive:mt,payload:ct},ke)}return null},[ue,J,tt,Ot,F,c,d,O,$,Pe,$e,y,w,re]),nt=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(he.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),xt=b.useCallback(()=>{const G=ie.trim().length>0||U.length>0||We.length>0||re.length>0;if(!ne&&We.length>0&&!r)return nt();if(!ne&&!G&&!r)return null;if(ne)return u.jsx(Qb,{message:t,viewMode:z},t.id);if(!ne&&!Q){const ke=t,ve=u.jsx("div",{className:"space-y-2",children:ke.content.map((pt,mt)=>u.jsx(St,{part:pt,i:mt},mt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ve,u.jsx(Yb,{className:q})]}):ve}},[ie,U.length,We.length,re.length,r,ne,z,nt,q]),Nt=b.useMemo(()=>Q?"Assistant":Gb(t),[Q,t]),st=b.useMemo(()=>Q?[]:Array.isArray(k)?k:[],[k,Q]),Gt=b.useMemo(()=>{var G;return st.length?j&&st.some(ke=>ke.id===j)?j:((G=st[0])==null?void 0:G.id)??null:null},[j,st]),Xt=b.useMemo(()=>!st.length||!S?null:st.some(G=>G.id===S)?S:null,[S,st])??Gt,Jt=F==="user"&&st.length>0&&typeof E=="function",ft=b.useCallback(G=>{if(!E)return;const ke=(G==null?void 0:G.id)??null,ve=(G==null?void 0:G.parentId)??_??null;E(ke,ve)},[_,E]),Ve=b.useMemo(()=>Xt?st.findIndex(G=>G.id===Xt):-1,[Xt,st]),Mt=b.useMemo(()=>Ve<0?null:st[Ve]??null,[Ve,st]),_t=b.useCallback(G=>{const ke=[];if(G.step!==null&&ke.push(`Step ${G.step}`),G.source&&ke.push(G.source),!G.createdAt)return ke.length?ke.join(" • "):G.id.slice(0,8);let ve="";try{const pt=new Date(G.createdAt);Number.isNaN(pt.getTime())||(ve=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(pt))}catch{ve=""}return`${ve}`},[]);return ne&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(Xe(),h.container),children:u.jsxs("div",{className:oe(Ke(),h.content),children:[(i||a||ne)&&u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",$&&"mb-1 pb-1",q,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Nt&&u.jsx("span",{className:oe("font-medium",$?"text-xs":"text-sm"),children:Nt}),ne&&u.jsxs(dd,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",q,"border border-current/40",$&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>B(G=>G==="expanded"?"preview":"expanded"),onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),B(ke=>ke==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(he.ChevronUp,{className:"h-3 w-3"}):u.jsx(he.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Jt&&Mt&&Ve>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ve>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ve<=0)return;const G=st[Ve-1];G&&ft(G)},"aria-label":"Previous checkpoint",disabled:Ve<=0,children:u.jsx(he.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[Ve+1," / ",st.length]}),u.jsx("span",{className:"text-muted-foreground",children:_t(Mt)})]}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ve<st.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ve>=st.length-1)return;const G=st[Ve+1];G&&ft(G)},"aria-label":"Next checkpoint",disabled:Ve>=st.length-1,children:u.jsx(he.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:oe("text-xs opacity-60",q,$&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>be(),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(he.Copy,{className:oe(P?"text-success":q,$?"h-3 w-3":"h-4 w-4")})})}),F==="user"&&p&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(he.Edit,{className:oe(q,$?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&m&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:ot,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(he.RotateCcw,{className:oe(q,$?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:xt()}),ne&&z==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",$&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||ne)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>be(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.Copy,{className:oe(P?"text-success":"text-current",$?"h-3 w-3":"h-4 w-4")})}),F==="user"&&p&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.Edit,{className:oe("text-current",$?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&m&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:ot,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.RotateCcw,{className:oe("text-current",$?"h-3 w-3":"h-4 w-4")})})]})]})}),te&&u.jsx(Ib,{isOpen:Ce,onClose:L,fileId:te.id,fileName:te.name,mimeType:te.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&If(e.message)===If(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Nf({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Vb,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Oo(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Oo(e)})}function Xb({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=Oo(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(No,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(Ao,{className:"pb-3",children:[u.jsx(_o,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(fd,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(jo,{className:"pt-0 pb-3",children:a}),u.jsx(hd,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(ut,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(ut,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Jb(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Da(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,m,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const w=String(m.url??""),C=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const T=C[1],k=m.name||`file_${T}`,S=m.mimeType||"application/octet-stream";f({id:T,name:k,mimeType:S});return}if(w.startsWith("data:")){p.preventDefault(),s(k=>({...k,[g]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const k=await Qv(n??void 0);if(!k||!Array.isArray(k))throw new Error("Invalid file list response");const S=k.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(S!=null&&S.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!S.id||!S.filename)throw new Error("Invalid file data received from server");f({id:S.id,name:m.name||S.filename||`file_${S.id}`,mimeType:m.mimeType||S.mime_type||"application/octet-stream"}),(x=T.update)==null||x.call(T,{id:T.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(k){console.error("Failed to fetch server file:",k);const S=k instanceof Error?k.message:"Unknown error occurred";(y=T.update)==null||y.call(T,{id:T.id,title:"Failed",description:S}),r({title:"Failed to fetch file",description:S,open:!0})}finally{s(k=>({...k,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(C=>({...C,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Zb({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Mo,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(ut,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Qb({message:e,viewMode:t}){const r=Ef(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?La(c)??c:c;if(d&&typeof d=="object")return u.jsx(Nf,{data:d});const f=typeof d=="string"?d:(()=>{try{return Oo(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=tw(c);return f?u.jsx(Mo,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(he.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Ps(d);return s(f)}const a=Ro(i),l=Ps(a);return s(l)}const Af=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,e0=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},nl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:m=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:k,showToolMessages:S=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:_,onSelectCheckpoint:P,timelineCheckpoints:D},z)=>{const B=b.useRef(null),O=b.useRef(null),H=b.useRef(!1),[R,V]=b.useState(!0),$=b.useMemo(()=>w?e.some(re=>"type"in re&&re.type==="default_message"?!1:Array.isArray(re==null?void 0:re.content)&&re.content.some(ye=>ye&&ye.type==="interrupt"&&(ye.id??ye.interrupt_id)===w.id)):!1,[w,e]),F=b.useMemo(()=>{if(!w||$)return null;const re=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let ye;const Pe=w.value;if(Pe&&typeof Pe=="object"&&!Array.isArray(Pe)){const $e=Pe.title;typeof $e=="string"&&$e.trim()&&(ye=$e.trim())}return{id:`interrupt-${re}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:re,value:Pe,title:ye}]}},[w,$]),ne=b.useMemo(()=>F?[...e,F]:e,[e,F]),Q=b.useMemo(()=>S?ne:ne.filter(re=>(re==null?void 0:re.role)!=="tool"),[ne,S]),xe=b.useMemo(()=>{const re=new Set,ye=[];for(let Pe=Q.length-1;Pe>=0;Pe--){const $e=Q[Pe];if(!$e)continue;if("type"in $e&&$e.type==="default_message"){ye.push($e);continue}const rt=$e,be=e0(rt);re.has(be)||(re.add(be),ye.push(rt))}return ye.reverse()},[Q]),_e=b.useCallback(re=>{V(re),x&&x(!re),y&&y(re)},[x,y]),J=b.useMemo(()=>{if(a)return async()=>{if(!H.current){H.current=!0;try{await a()}finally{H.current=!1}}}},[a]),ue=b.useMemo(()=>!m||g?!1:R?"auto":!1,[R,m,g]),Ce=b.useMemo(()=>D??[],[D]),te=_??(Ce.length?Ce[Ce.length-1].id:null),L=Ce.length>0,q=b.useMemo(()=>{if(typeof p!="string")return null;const re=p.trim();return re?{id:"default-message",role:"assistant",type:"default_message",content:re,createdAt:new Date().toISOString()}:null},[p]),ie=L?u.jsxs("div",{className:"hidden w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 md:flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative",children:[u.jsx(he.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto absolute -right-48 top-full z-50 hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:Ce.map(re=>{const ye=te===re.id;return u.jsxs("button",{type:"button",disabled:!P,onClick:()=>P==null?void 0:P(re.id),className:`relative flex items-start gap-3 text-left text-xs transition ${ye?"text-primary":"text-muted-foreground"} ${P?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${ye?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:re.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[re.step!==null?`STEP ${re.step}`:"STEP —",re.next?` - ${re.next}`:""]})]})]},re.id)})})]}),P&&u.jsx("button",{type:"button",onClick:()=>P==null?void 0:P(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ce=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),U=()=>q?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(tl,{message:q,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),We=xe.length>0;return b.useImperativeHandle(z,()=>({scrollToLatest:()=>{var re,ye;if(B.current&&xe.length>0){const Pe=xe.length-1;(ye=(re=B.current).scrollToIndex)==null||ye.call(re,{index:Pe,align:"end",behavior:"auto"})}else O.current&&(O.current.scrollTop=O.current.scrollHeight)},scrollToTop:()=>{var re,ye;B.current&&xe.length>0?(ye=(re=B.current).scrollToIndex)==null||ye.call(re,{index:0,align:"start",behavior:"auto"}):O.current&&(O.current.scrollTop=0)}}),[xe]),u.jsxs("div",{className:ce,style:h,children:[ie,u.jsx("div",{className:"relative flex-1 min-h-0",children:We?u.jsx(jv,{ref:re=>{B.current=re},scrollerRef:re=>{O.current=re instanceof HTMLDivElement?re:null},data:xe,followOutput:ue,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{J&&J()},atBottomStateChange:_e,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(re,ye)=>Af(ye,re),itemContent:(re,ye)=>{var tt;const Pe=Af(ye,re),$e="type"in ye&&ye.type==="default_message";let rt=[],be=null,Ye={},ot={},et=null,Xe=null;if(!$e){const Ot=ye,St=Ot.checkpointId??null;Ye=Ot.additionalKwargs??{},ot=Ot.responseMetadata??{};const nt=St&&E?E.get(St)??null:null;et=typeof Ye.step=="number"?Ye.step:typeof ot.step=="number"?ot.step:(nt==null?void 0:nt.step)??null;const xt=typeof Ye.source=="string"?Ye.source:typeof ot.source=="string"?ot.source:(nt==null?void 0:nt.source)??null;Xe=xt?String(xt):null;const Nt=et!==null&&Xe?`${et}:${Xe}`:null;Nt&&(j!=null&&j.has(Nt))?rt=j.get(Nt)??[]:St&&nt&&(rt=[nt]),be=St??((tt=rt[0])==null?void 0:tt.id)??null}const Ke=(()=>{if(typeof Ye.parentCheckpointId=="string")return Ye.parentCheckpointId;if(typeof ot.parentCheckpointId=="string")return ot.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":Pe,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(tl,{message:ye,messageIndex:re,isStreamingMessage:t&&n===ye.id,streamingDebounceMs:r,isEditing:i===ye.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(re),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:C,onInterruptActionStart:T,onInterruptActionEnd:k,showToolMessages:S,checkpointCandidates:rt,activeCheckpointId:_??null,onSelectCheckpoint:P,defaultCheckpointId:be,messageParentCheckpointId:Ke})})}}):U()})]})});nl.displayName="MessageList";const ti=1e4;function t0(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ke]?u.jsx(he.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[pt,J[ke]?" (processing)":""]})]},ke)}if(G.type==="interrupt"){const ve=G,pt=ei((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),mt=!!(Pe&&pt&&pt===Pe),ct=mt?$e??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,Me=pt?{...ve,id:pt,interrupt_id:pt}:ve;return u.jsx(Xb,{interruptPart:Me,onApprove:tt,onReject:Ot,disabled:w,isActive:mt,payload:ct},ke)}return null},[ue,J,tt,Ot,F,c,d,O,$,Pe,$e,y,w,re]),nt=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(he.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),xt=b.useCallback(()=>{const G=ie.trim().length>0||U.length>0||We.length>0||re.length>0;if(!ne&&We.length>0&&!r)return nt();if(!ne&&!G&&!r)return null;if(ne)return u.jsx(Qb,{message:t,viewMode:z},t.id);if(!ne&&!Q){const ke=t,ve=u.jsx("div",{className:"space-y-2",children:ke.content.map((pt,mt)=>u.jsx(St,{part:pt,i:mt},mt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ve,u.jsx(Yb,{className:q})]}):ve}},[ie,U.length,We.length,re.length,r,ne,z,nt,q]),Nt=b.useMemo(()=>Q?"Assistant":Gb(t),[Q,t]),st=b.useMemo(()=>Q?[]:Array.isArray(k)?k:[],[k,Q]),Gt=b.useMemo(()=>{var G;return st.length?j&&st.some(ke=>ke.id===j)?j:((G=st[0])==null?void 0:G.id)??null:null},[j,st]),Xt=b.useMemo(()=>!st.length||!S?null:st.some(G=>G.id===S)?S:null,[S,st])??Gt,Jt=F==="user"&&st.length>0&&typeof E=="function",ft=b.useCallback(G=>{if(!E)return;const ke=(G==null?void 0:G.id)??null,ve=(G==null?void 0:G.parentId)??_??null;E(ke,ve)},[_,E]),Ve=b.useMemo(()=>Xt?st.findIndex(G=>G.id===Xt):-1,[Xt,st]),Mt=b.useMemo(()=>Ve<0?null:st[Ve]??null,[Ve,st]),_t=b.useCallback(G=>{const ke=[];if(G.step!==null&&ke.push(`Step ${G.step}`),G.source&&ke.push(G.source),!G.createdAt)return ke.length?ke.join(" • "):G.id.slice(0,8);let ve="";try{const pt=new Date(G.createdAt);Number.isNaN(pt.getTime())||(ve=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(pt))}catch{ve=""}return`${ve}`},[]);return ne&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(Xe(),h.container),children:u.jsxs("div",{className:oe(Ke(),h.content),children:[(i||a||ne)&&u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",$&&"mb-1 pb-1",q,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Nt&&u.jsx("span",{className:oe("font-medium",$?"text-xs":"text-sm"),children:Nt}),ne&&u.jsxs(dd,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",q,"border border-current/40",$&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>B(G=>G==="expanded"?"preview":"expanded"),onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),B(ke=>ke==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(he.ChevronUp,{className:"h-3 w-3"}):u.jsx(he.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Jt&&Mt&&Ve>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ve>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ve<=0)return;const G=st[Ve-1];G&&ft(G)},"aria-label":"Previous checkpoint",disabled:Ve<=0,children:u.jsx(he.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[Ve+1," / ",st.length]}),u.jsx("span",{className:"text-muted-foreground",children:_t(Mt)})]}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ve<st.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ve>=st.length-1)return;const G=st[Ve+1];G&&ft(G)},"aria-label":"Next checkpoint",disabled:Ve>=st.length-1,children:u.jsx(he.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:oe("text-xs opacity-60",q,$&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>be(),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(he.Copy,{className:oe(P?"text-success":q,$?"h-3 w-3":"h-4 w-4")})})}),F==="user"&&p&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(he.Edit,{className:oe(q,$?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&m&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:ot,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,$&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(he.RotateCcw,{className:oe(q,$?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:xt()}),ne&&z==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",$&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||ne)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>be(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.Copy,{className:oe(P?"text-success":"text-current",$?"h-3 w-3":"h-4 w-4")})}),F==="user"&&p&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Ye,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.Edit,{className:oe("text-current",$?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&m&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:ot,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(he.RotateCcw,{className:oe("text-current",$?"h-3 w-3":"h-4 w-4")})})]})]})}),te&&u.jsx(Ib,{isOpen:Ce,onClose:L,fileId:te.id,fileName:te.name,mimeType:te.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&If(e.message)===If(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Nf({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Vb,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Oo(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Oo(e)})}function Xb({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=Oo(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(No,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(Ao,{className:"pb-3",children:[u.jsx(_o,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(fd,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(jo,{className:"pt-0 pb-3",children:a}),u.jsx(hd,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(ut,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(ut,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Jb(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Da(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,m,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const w=String(m.url??""),C=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const T=C[1],k=m.name||`file_${T}`,S=m.mimeType||"application/octet-stream";f({id:T,name:k,mimeType:S});return}if(w.startsWith("data:")){p.preventDefault(),s(k=>({...k,[g]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const k=await Qv(n??void 0);if(!k||!Array.isArray(k))throw new Error("Invalid file list response");const S=k.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(S!=null&&S.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!S.id||!S.filename)throw new Error("Invalid file data received from server");f({id:S.id,name:m.name||S.filename||`file_${S.id}`,mimeType:m.mimeType||S.mime_type||"application/octet-stream"}),(x=T.update)==null||x.call(T,{id:T.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(k){console.error("Failed to fetch server file:",k);const S=k instanceof Error?k.message:"Unknown error occurred";(y=T.update)==null||y.call(T,{id:T.id,title:"Failed",description:S}),r({title:"Failed to fetch file",description:S,open:!0})}finally{s(k=>({...k,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(C=>({...C,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Zb({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Mo,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(ut,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Qb({message:e,viewMode:t}){const r=Ef(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?La(c)??c:c;if(d&&typeof d=="object")return u.jsx(Nf,{data:d});const f=typeof d=="string"?d:(()=>{try{return Oo(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=tw(c);return f?u.jsx(Mo,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(he.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Ps(d);return s(f)}const a=Ro(i),l=Ps(a);return s(l)}const Af=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,e0=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},nl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:m=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:k,showToolMessages:S=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:_,onSelectCheckpoint:P,timelineCheckpoints:D},z)=>{const B=b.useRef(null),O=b.useRef(null),H=b.useRef(!1),[R,V]=b.useState(!0),$=b.useMemo(()=>w?e.some(re=>"type"in re&&re.type==="default_message"?!1:Array.isArray(re==null?void 0:re.content)&&re.content.some(ye=>ye&&ye.type==="interrupt"&&(ye.id??ye.interrupt_id)===w.id)):!1,[w,e]),F=b.useMemo(()=>{if(!w||$)return null;const re=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let ye;const Pe=w.value;if(Pe&&typeof Pe=="object"&&!Array.isArray(Pe)){const $e=Pe.title;typeof $e=="string"&&$e.trim()&&(ye=$e.trim())}return{id:`interrupt-${re}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:re,value:Pe,title:ye}]}},[w,$]),ne=b.useMemo(()=>F?[...e,F]:e,[e,F]),Q=b.useMemo(()=>S?ne:ne.filter(re=>(re==null?void 0:re.role)!=="tool"),[ne,S]),xe=b.useMemo(()=>{const re=new Set,ye=[];for(let Pe=Q.length-1;Pe>=0;Pe--){const $e=Q[Pe];if(!$e)continue;if("type"in $e&&$e.type==="default_message"){ye.push($e);continue}const rt=$e,be=e0(rt);re.has(be)||(re.add(be),ye.push(rt))}return ye.reverse()},[Q]),_e=b.useCallback(re=>{V(re),x&&x(!re),y&&y(re)},[x,y]),J=b.useMemo(()=>{if(a)return async()=>{if(!H.current){H.current=!0;try{await a()}finally{H.current=!1}}}},[a]),ue=b.useMemo(()=>!m||g?!1:R?"auto":!1,[R,m,g]),Ce=b.useMemo(()=>D??[],[D]),te=_??(Ce.length?Ce[Ce.length-1].id:null),L=Ce.length>0,q=b.useMemo(()=>{if(typeof p!="string")return null;const re=p.trim();return re?{id:"default-message",role:"assistant",type:"default_message",content:re,createdAt:new Date().toISOString()}:null},[p]),ie=L?u.jsxs("div",{className:"hidden w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 md:flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative z-50",children:[u.jsx(he.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:Ce.map(re=>{const ye=te===re.id;return u.jsxs("button",{type:"button",disabled:!P,onClick:()=>P==null?void 0:P(re.id),className:`relative flex items-start gap-3 text-left text-xs transition ${ye?"text-primary":"text-muted-foreground"} ${P?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${ye?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ye?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:re.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[re.step!==null?`STEP ${re.step}`:"STEP —",re.next?` - ${re.next}`:""]})]})]},re.id)})})]}),P&&u.jsx("button",{type:"button",onClick:()=>P==null?void 0:P(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ce=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),U=()=>q?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(tl,{message:q,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),We=xe.length>0;return b.useImperativeHandle(z,()=>({scrollToLatest:()=>{var re,ye;if(B.current&&xe.length>0){const Pe=xe.length-1;(ye=(re=B.current).scrollToIndex)==null||ye.call(re,{index:Pe,align:"end",behavior:"auto"})}else O.current&&(O.current.scrollTop=O.current.scrollHeight)},scrollToTop:()=>{var re,ye;B.current&&xe.length>0?(ye=(re=B.current).scrollToIndex)==null||ye.call(re,{index:0,align:"start",behavior:"auto"}):O.current&&(O.current.scrollTop=0)}}),[xe]),u.jsxs("div",{className:ce,style:h,children:[ie,u.jsx("div",{className:"relative flex-1 min-h-0",children:We?u.jsx(jv,{ref:re=>{B.current=re},scrollerRef:re=>{O.current=re instanceof HTMLDivElement?re:null},data:xe,followOutput:ue,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{J&&J()},atBottomStateChange:_e,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(re,ye)=>Af(ye,re),itemContent:(re,ye)=>{var tt;const Pe=Af(ye,re),$e="type"in ye&&ye.type==="default_message";let rt=[],be=null,Ye={},ot={},et=null,Xe=null;if(!$e){const Ot=ye,St=Ot.checkpointId??null;Ye=Ot.additionalKwargs??{},ot=Ot.responseMetadata??{};const nt=St&&E?E.get(St)??null:null;et=typeof Ye.step=="number"?Ye.step:typeof ot.step=="number"?ot.step:(nt==null?void 0:nt.step)??null;const xt=typeof Ye.source=="string"?Ye.source:typeof ot.source=="string"?ot.source:(nt==null?void 0:nt.source)??null;Xe=xt?String(xt):null;const Nt=et!==null&&Xe?`${et}:${Xe}`:null;Nt&&(j!=null&&j.has(Nt))?rt=j.get(Nt)??[]:St&&nt&&(rt=[nt]),be=St??((tt=rt[0])==null?void 0:tt.id)??null}const Ke=(()=>{if(typeof Ye.parentCheckpointId=="string")return Ye.parentCheckpointId;if(typeof ot.parentCheckpointId=="string")return ot.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":Pe,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(tl,{message:ye,messageIndex:re,isStreamingMessage:t&&n===ye.id,streamingDebounceMs:r,isEditing:i===ye.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(re),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:C,onInterruptActionStart:T,onInterruptActionEnd:k,showToolMessages:S,checkpointCandidates:rt,activeCheckpointId:_??null,onSelectCheckpoint:P,defaultCheckpointId:be,messageParentCheckpointId:Ke})})}}):U()})]})});nl.displayName="MessageList";const ti=1e4;function t0(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
130
130
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
131
131
|
|
|
132
132
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
package/package.json
CHANGED