teodor-new-chat-ui 3.0.167 → 3.0.168

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 CHANGED
@@ -10746,13 +10746,13 @@ const gc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, zd = V.forwa
10746
10746
  scrollerRef: (N) => {
10747
10747
  R.current = N instanceof HTMLDivElement ? N : null;
10748
10748
  },
10749
- data: e.reverse(),
10749
+ data: e,
10750
10750
  followOutput: P.current,
10751
10751
  overscan: 200,
10752
10752
  increaseViewportBy: { top: 100, bottom: 200 },
10753
10753
  defaultItemHeight: 80,
10754
10754
  atBottomThreshold: 50,
10755
- alignToBottom: !0,
10755
+ alignToBottom: !1,
10756
10756
  startReached: () => {
10757
10757
  I && I();
10758
10758
  },
package/dist/index.umd.js CHANGED
@@ -127,7 +127,7 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
127
127
  For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Xv="DialogDescriptionWarning",Jv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yu(Xv).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Xu=Mu,Zv=Lu,Ju=Fu,Go=zu,Yo=Bu,Fn=Uu,Xo=Vu,Zu=qu;const Qv=Xu,ew=Ju,Qu=h.forwardRef(({className:e,...t},n)=>l.jsx(Go,{ref:n,className:L("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Qu.displayName=Go.displayName;const ed=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,c=>{if(s||!h.isValidElement(c))return;const u=c.type;if(u===Fn||(u==null?void 0:u.displayName)===Fn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(ew,{children:[l.jsx(Qu,{}),l.jsxs(Yo,{ref:r,className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&l.jsx(Fn,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Zu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(se.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});ed.displayName=Yo.displayName;const td=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});td.displayName="DialogHeader";const nd=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));nd.displayName=Fn.displayName;const tw=h.forwardRef(({className:e,...t},n)=>l.jsx(Xo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));tw.displayName=Xo.displayName;function nw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=C.useState(!1),[a,c]=C.useState(null),[u,d]=C.useState(null),{toast:f}=Ni(),p=C.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await cu(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);C.useEffect(()=>{e&&n&&p()},[e,n,p]);const m=async()=>{if(n)try{await Mb(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await cu(n),v=new Blob([x],{type:o}),y=URL.createObjectURL(v);window.open(y,"_blank"),URL.revokeObjectURL(y)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},b=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(se.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(ze,{onClick:p,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(se.Image,{className:"h-5 w-5"}):l.jsx(se.FileText,{className:"h-5 w-5"});return l.jsx(Qv,{open:e,onOpenChange:t,children:l.jsxs(ed,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(td,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(nd,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(ze,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[l.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(ze,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:b()})]})})}const Jo="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",Zo=1e5;function rw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function ow(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function sw(e){const t=(r,o=Zo)=>{try{const s=Dr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
128
  … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function iw(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function aw(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function lw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function rd(e){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"tool_result":return"result";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function cw(e,t){const[n,r]=C.useState(e),o=C.useRef(e),s=C.useRef(null);return C.useEffect(()=>{if(o.current=e,!t){s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r(e);return}return s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,r(o.current)})),()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)}},[e,t]),n}function uw({className:e}){const[t,n]=C.useState(0);return C.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:L("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const od=C.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:w={},onEdit:b,onRegenerate:g,onCancelEdit:x,onCopy:v}){const[y,E]=C.useState(!1),[S,T]=C.useState(!1),[I,N]=C.useState(!1),[j,O]=C.useState(!1),{currentThreadId:A}=ho(),{toast:F}=Ni(),[H,D]=C.useState({}),[J,K]=C.useState(!1),[oe,W]=C.useState(null),M=u==="phone"||u==="half-screen",X=t.role,Z=X==="tool",he=!(r&&X!=="user"),$=C.useMemo(()=>{switch(X){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))]"}},[X]),G=C.useMemo(()=>rw(t.content),[t.content]),ee=C.useMemo(()=>ow(t.content),[t.content]),pe=C.useMemo(()=>t.content.filter(ve=>ve.type==="image_url"),[t.content]),z=C.useMemo(()=>t.content.filter(ve=>ve.type==="file"),[t.content]),_=C.useMemo(()=>sw(t.content),[t.content]),Y=C.useMemo(()=>iw(t.content),[t.content]),Q=C.useMemo(()=>_.length<=Zo?_:`${_.slice(0,Zo)}
129
129
  … [truncated ${_.length-Zo} chars]`,[_]),de=C.useMemo(()=>aw(t.createdAt),[t.createdAt]),ne=cw(G,r),_e=C.useCallback(async()=>{const ve=Z?_:G;async function Fe(Ge){try{await navigator.clipboard.writeText(Ge)}catch{try{const P=document.createElement("textarea");P.value=Ge,P.setAttribute("readonly",""),P.style.position="absolute",P.style.left="-9999px",document.body.appendChild(P),P.select(),document.execCommand("copy"),document.body.removeChild(P)}catch(P){throw console.error("Failed to copy:",P),P}}}try{await Fe(ve),E(!0),setTimeout(()=>E(!1),2e3),v==null||v(ve)}catch(Ge){console.error("Failed to copy:",Ge)}},[Z,_,G,v]),Pe=C.useCallback(()=>{if(!b)return;const ve=Z?_:G;b(t.id,ve)},[b,t.id,Z,_,G]),Ue=C.useCallback(()=>{g==null||g(n)},[g,n]),Ee=C.useCallback(async(ve,Fe,Ge)=>{if(!he){ve.preventDefault();return}try{const P=String(Fe.url??""),U=P.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(U){ve.preventDefault();const ue=U[1],be=Fe.name||`file_${ue}`,le=Fe.mimeType||"application/octet-stream";W({id:ue,name:be,mimeType:le}),K(!0);return}if(P.startsWith("data:")){if(ve.preventDefault(),H[Ge])return;D(be=>({...be,[Ge]:!0}));const ue=F({title:"Fetching file...",description:"",open:!0});try{const le=(await Db(A??void 0)).find(Be=>!Be||typeof Be!="object"||!((Be.filename??"")===(Fe.name??""))?!1:typeof Fe.size=="number"&&typeof Be.size=="number"?Be.size===Fe.size:!0);if(!(le!=null&&le.id))throw new Error("File is not yet available on the server");W({id:le.id,name:Fe.name||le.filename||`file_${le.id}`,mimeType:Fe.mimeType||le.mime_type||"application/octet-stream"}),K(!0),ue.update({id:ue.id,title:"Done",description:void 0})}catch(be){console.error("Failed to fetch server file:",be),ue.update({id:ue.id,title:"Failed",description:String(be)}),F({title:"Failed to fetch file",description:String(be),open:!0})}finally{D(be=>({...be,[Ge]:!1}))}}}catch(P){console.error("File click error:",P)}},[he,H,F,A,D,W,K]),Ae=C.useCallback(()=>{const Fe=L(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",$);switch(X){case"user":return l.jsx(se.User,{className:Fe});case"assistant":return l.jsx(se.Bot,{className:Fe});case"tool":return l.jsx(se.Wrench,{className:Fe});default:return l.jsx(se.Bot,{className:Fe})}},[M,$,X]),et=C.useCallback(()=>{const ve="group relative mb-4 flex w-full";switch(X){case"user":return L(ve,"justify-end");case"assistant":case"tool":case"system":return L(ve,"justify-start");default:return ve}},[X]),qe=C.useCallback(()=>{const ve=L("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");switch(X){case"user":return L(ve,"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 L(ve,"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 L(ve,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return L(ve,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return L(ve,"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")}},[M,X]),ct=C.useCallback(()=>{if(!(G.trim().length>0||pe.length>0||z.length>0))return l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(t.model==="reflection"){const P=G.trim(),U=Ui(P);if(U&&typeof U=="object")return l.jsx(mw,{data:U})}if(Z&&ee.name==="get_issues"){const P=t.content.find(be=>be.type==="tool_result"),U=(P==null?void 0:P.output)??_,ue=cd(U);if(ue)return l.jsx(gw,{issues:ue})}if(Z&&!I){const P=_.slice(0,80).replace(/\s+/g," ");return l.jsx("div",{className:L("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",M&&"text-[10px]"),children:l.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(Z&&d){const P=_,U=P.length>f;return l.jsx(qc,{open:S,onOpenChange:T,children:l.jsxs("div",{className:"font-mono text-sm text-current",children:[l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:U&&!S?`${Q.substring(0,f)}...`:Q}),U&&l.jsx(Gc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:S?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Math.max(P.length-f,0)," chars)"]})})})]})})}if(Z&&I&&!d)return Y&&dw(Y)?l.jsx(Po,{content:Y.trim()}):l.jsx("div",{className:"font-mono text-sm text-current",children:l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:Q})});const Fe=pe.length>0&&X!=="tool",Ge=z.length>0&&X!=="tool";return l.jsxs("div",{children:[r?l.jsxs("div",{className:L("relative transition-all duration-200 ease-out",M?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const U=sd(X,ne)?Ui(ne):null;if(U!==null)return l.jsx(id,{data:U});const ue=hw(fw(ne)),be=ne.trim().length===0;return l.jsx(l.Fragment,{children:be?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:L("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",M&&"text-xs"),children:ue})})})(),l.jsx("div",{className:"mt-2",children:l.jsx(uw,{className:L($,M?"text-xs":"text-sm")})})]}):(()=>{const P=G.trim(),ue=sd(X,P)?Ui(P):null;if(ue!==null)return l.jsx(id,{data:ue});if(X==="user"&&p){const be=P;if(be.length>m)return l.jsxs(qc,{open:j,onOpenChange:O,children:[l.jsx("div",{className:L("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:j?l.jsx(Po,{content:be,allowHtml:!1}):l.jsxs("pre",{className:L("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[be.substring(0,m),"..."]})}),l.jsx(Gc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",be.length-m," chars)"]})})})]})}return l.jsx(Po,{content:G.trim(),allowHtml:!1})})(),Fe&&l.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:pe.map((P,U)=>{const ue=P,be=typeof ue.width=="number"?ue.width:void 0,le=typeof ue.height=="number"?ue.height:void 0,Be=be&&le&&le>0?`${be} / ${le}`:"4 / 3",at=be&&le&&le>0?Math.max(120,Math.round(le/be*140)):160;return l.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:Be,minHeight:at},"data-placeholder-height":at,children:[l.jsx("img",{src:ue.url,alt:ue.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),l.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[l.jsx(se.Image,{className:"h-3 w-3"}),l.jsx("span",{children:"image"})]})]},U)})}),Ge&&l.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:z.map((P,U)=>{const ue=P,be=ue.name||"file";return l.jsxs("a",{href:ue.url,download:be,onClick:le=>Ee(le,ue,U),target:"_blank",rel:"noreferrer",className:L("inline-flex items-center gap-2 rounded px-2 py-1 text-xs","bg-gray-100 border border-gray-200 hover:bg-gray-200","dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20","text-current",!he&&"pointer-events-none opacity-60"),title:be,"aria-disabled":!he,children:[l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-gray-500"}),H[U]?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),l.jsxs("span",{className:"truncate max-w-[140px]",children:[be," (processing)"]})]}):l.jsx("span",{className:"truncate max-w-[180px]",children:be})]},U)})})]})},[Z,G,pe,z,t,ee.name,_,I,d,S,Q,f,Y,r,ne,X,$,M,p,j,m,he,H,Ee]),ut=C.useMemo(()=>lw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:L(et(),w.container),children:l.jsxs("div",{className:L(qe(),w.content),children:[(a||c||Z)&&l.jsxs("div",{className:L("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",$,w.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Ae(),c&&ut&&l.jsx("span",{className:L("font-medium",M?"text-xs":"text-sm"),children:ut}),Z&&ee.name&&l.jsxs(Bc,{variant:"outline",className:L("text-xs flex items-center gap-1 cursor-pointer",$,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":I,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),N(Fe=>!Fe))},onClick:()=>N(ve=>!ve),children:[l.jsx("span",{children:ee.name}),l.jsx("span",{className:"inline-flex items-center",children:I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!ee.name&&l.jsx(ze,{variant:"ghost",size:"sm",className:L("h-6 px-1",$,"hover:bg-foreground/10"),onClick:()=>N(ve=>!ve),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&l.jsx("span",{className:L("text-xs opacity-60",$,M&&"text-xs"),children:de}),i&&!s&&l.jsxs("div",{className:L("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Copy message",children:l.jsx(se.Copy,{className:L(y?"text-success":$,M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(se.Edit,{className:L($,M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(se.RotateCcw,{className:L($,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:ct()}),Z&&I&&(ee.toolCallId||ee.name)&&l.jsxs("div",{className:L("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ee.name&&l.jsxs("div",{children:["Function: ",ee.name]}),ee.toolCallId&&l.jsxs("div",{children:["Call ID: ",ee.toolCallId]})]}),!(a||c||Z)&&i&&!s&&l.jsxs("div",{className:L("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Copy,{className:L(y?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Edit,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.RotateCcw,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&l.jsx(nw,{isOpen:J,onClose:()=>{K(!1),W(null)},fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,p,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&rd(e.message)===rd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((p=e.customStyles)==null?void 0:p.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function dw(e){return e.includes(`
130
- `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function fw(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function hw(e){try{const t=[],n=[],r="\0F",o="\0I";let s=e.replace(/```[\s\S]*?```/g,i=>(t.push(i),`${r}${t.length-1}\0`));return s=s.replace(/`[^`]*`/g,i=>(n.push(i),`${o}${n.length-1}\0`)),s=s.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1"),s=s.replace(/\u0000F(\d+)\u0000/g,(i,a)=>t[+a]??""),s=s.replace(/\u0000I(\d+)\u0000/g,(i,a)=>n[+a]??""),s}catch{return e}}function Ui(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function sd(e,t){const n=t==null?void 0:t.trim();return n?!!(e==="tool"||n.startsWith("```json")||n.length<5e3&&(n.startsWith("{")||n.startsWith("["))):!1}function id({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Jo,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Jo,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Jo,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:pw(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(e)})}function pw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(Dr(e))})}catch{return String(e)}}function ad(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Dr(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Dr).filter(r=>r!==void 0);return n.length?n:void 0}if(ad(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Dr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function ld(e){if(typeof e=="string")return e;if(ad(e))return"";try{const t=Dr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function mw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function cd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return cd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const p=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(p),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(p),b=m?m[2].trim():"",g=w?w[2].trim():"";n[i].push({title:b,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}function gw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Jo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ud=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Wi=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:p,emptyMessage:m,followNewMessages:w=!0,isNavigatingCheckpoint:b=!1,onScrollAway:g,onAtBottom:x},v)=>{const y=C.useRef(null),E=C.useRef(null),S=C.useRef(!1),[T,I]=C.useState(!0),N=C.useCallback(A=>{I(A),g&&g(!A),x&&x(A)},[g,x]),j=C.useMemo(()=>{if(a)return async()=>{if(!S.current){S.current=!0;try{await a()}finally{S.current=!1}}}},[a]),O=C.useRef(!1);return C.useEffect(()=>{if(!w||b){O.current!==!1&&(O.current=!1);return}const A=t&&T?"auto":!1;O.current!==A&&(O.current=A)},[t,T,w,b]),e.length===0?l.jsx("div",{className:f,style:p,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:p,children:l.jsx(zx,{ref:A=>{y.current=A},scrollerRef:A=>{E.current=A instanceof HTMLDivElement?A:null},data:e.reverse(),followOutput:O.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{j&&j()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(A,F)=>ud(F,A),itemContent:(A,F)=>{const H=ud(F,A);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(od,{message:F,messageIndex:A,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(A),onCancelEdit:d})})}})})});Wi.displayName="MessageList";const Qo=1e4;function xw(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
+ `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function fw(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function hw(e){try{const t=[],n=[],r="\0F",o="\0I";let s=e.replace(/```[\s\S]*?```/g,i=>(t.push(i),`${r}${t.length-1}\0`));return s=s.replace(/`[^`]*`/g,i=>(n.push(i),`${o}${n.length-1}\0`)),s=s.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1"),s=s.replace(/\u0000F(\d+)\u0000/g,(i,a)=>t[+a]??""),s=s.replace(/\u0000I(\d+)\u0000/g,(i,a)=>n[+a]??""),s}catch{return e}}function Ui(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function sd(e,t){const n=t==null?void 0:t.trim();return n?!!(e==="tool"||n.startsWith("```json")||n.length<5e3&&(n.startsWith("{")||n.startsWith("["))):!1}function id({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Jo,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Jo,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Jo,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:pw(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(e)})}function pw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(Dr(e))})}catch{return String(e)}}function ad(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Dr(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Dr).filter(r=>r!==void 0);return n.length?n:void 0}if(ad(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Dr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function ld(e){if(typeof e=="string")return e;if(ad(e))return"";try{const t=Dr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function mw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function cd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return cd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const p=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(p),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(p),b=m?m[2].trim():"",g=w?w[2].trim():"";n[i].push({title:b,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}function gw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Jo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ud=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Wi=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:p,emptyMessage:m,followNewMessages:w=!0,isNavigatingCheckpoint:b=!1,onScrollAway:g,onAtBottom:x},v)=>{const y=C.useRef(null),E=C.useRef(null),S=C.useRef(!1),[T,I]=C.useState(!0),N=C.useCallback(A=>{I(A),g&&g(!A),x&&x(A)},[g,x]),j=C.useMemo(()=>{if(a)return async()=>{if(!S.current){S.current=!0;try{await a()}finally{S.current=!1}}}},[a]),O=C.useRef(!1);return C.useEffect(()=>{if(!w||b){O.current!==!1&&(O.current=!1);return}const A=t&&T?"auto":!1;O.current!==A&&(O.current=A)},[t,T,w,b]),e.length===0?l.jsx("div",{className:f,style:p,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:p,children:l.jsx(zx,{ref:A=>{y.current=A},scrollerRef:A=>{E.current=A instanceof HTMLDivElement?A:null},data:e,followOutput:O.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(A,F)=>ud(F,A),itemContent:(A,F)=>{const H=ud(F,A);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(od,{message:F,messageIndex:A,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(A),onCancelEdit:d})})}})})});Wi.displayName="MessageList";const Qo=1e4;function xw(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,`
131
131
  `).replace(/<p>(.*?)<\/p>/gi,`$1
132
132
 
133
133
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "3.0.167",
3
+ "version": "3.0.168",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",