teodor-new-chat-ui 3.0.170 → 3.0.171
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 +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -10114,7 +10114,7 @@ const Ab = W.memo(function({
|
|
|
10114
10114
|
);
|
|
10115
10115
|
}
|
|
10116
10116
|
}, [O, Y]), ut = W.useCallback(() => {
|
|
10117
|
-
if (!(q.trim().length > 0 || he.length > 0 || $.length > 0))
|
|
10117
|
+
if (!(q.trim().length > 0 || he.length > 0 || $.length > 0) && !r)
|
|
10118
10118
|
return /* @__PURE__ */ c.jsxs("div", { className: "flex items-center gap-2 p-2 bg-muted/30 rounded", children: [
|
|
10119
10119
|
/* @__PURE__ */ c.jsx(ni, { className: "h-4 w-4 text-muted-foreground" }),
|
|
10120
10120
|
/* @__PURE__ */ c.jsx("span", { className: "text-sm text-muted-foreground", children: "File upload" })
|
package/dist/index.umd.js
CHANGED
|
@@ -126,7 +126,7 @@ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHid
|
|
|
126
126
|
|
|
127
127
|
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},pw="DialogDescriptionWarning",mw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Pu(pw).contentName}}.`;return p.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},Ou=wu,gw=yu,Mu=Cu,Uo=Tu,Wo=ku,Fn=Iu,Vo=Au,Du=_u;const xw=Ou,vw=Mu,Lu=p.forwardRef(({className:e,...t},n)=>c.jsx(Uo,{ref:n,className:Y("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}));Lu.displayName=Uo.displayName;const $u=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const u=l.type;if(u===Fn||(u==null?void 0:u.displayName)===Fn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(vw,{children:[c.jsx(Lu,{}),c.jsxs(Wo,{ref:r,className:Y("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&&c.jsx(Fn,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Du,{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:[c.jsx(se.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});$u.displayName=Wo.displayName;const Fu=({className:e,...t})=>c.jsx("div",{className:Y("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Fu.displayName="DialogHeader";const zu=p.forwardRef(({className:e,...t},n)=>c.jsx(Fn,{ref:n,className:Y("text-lg font-semibold leading-none tracking-tight",e),...t}));zu.displayName=Fn.displayName;const ww=p.forwardRef(({className:e,...t},n)=>c.jsx(Vo,{ref:n,className:Y("text-sm text-muted-foreground",e),...t}));ww.displayName=Vo.displayName;function bw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=C.useState(!1),[a,l]=C.useState(null),[u,d]=C.useState(null),{toast:f}=yi(),h=C.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await Kc(n);l(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&&h()},[e,n,h]);const m=async()=>{if(n)try{await Qx(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"})}},b=async()=>{if(n)try{const x=await Kc(n),w=new Blob([x],{type:o}),y=URL.createObjectURL(w);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"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(se.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Be,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(se.Image,{className:"h-5 w-5"}):c.jsx(se.FileText,{className:"h-5 w-5"});return c.jsx(xw,{open:e,onOpenChange:t,children:c.jsxs($u,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Fu,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(zu,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Be,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[c.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Be,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[c.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}const qo="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",Ko=1e5;function yw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Sw(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 Cw(e){const t=(r,o=Ko)=>{try{const s=_r(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 Tw(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 kw(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Ew(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Bu(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 Iw(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 Nw({className:e}){const[t,n]=C.useState(0);return C.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:Y("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Hu=C.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:l=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:h=!0,userMessagePreviewLength:m=200,customStyles:b={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:w}){const[y,I]=C.useState(!1),[S,T]=C.useState(!1),[E,N]=C.useState(!1),[A,O]=C.useState(!1),{currentThreadId:j}=io(),{toast:$}=yi(),[B,D]=C.useState({}),[J,V]=C.useState(!1),[re,U]=C.useState(null),M=u==="phone"||u==="half-screen",X=t.role,Z=X==="tool",he=!(r&&X!=="user"),L=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]),K=C.useMemo(()=>yw(t.content),[t.content]),ee=C.useMemo(()=>Sw(t.content),[t.content]),pe=C.useMemo(()=>t.content.filter(we=>we.type==="image_url"),[t.content]),F=C.useMemo(()=>t.content.filter(we=>we.type==="file"),[t.content]),R=C.useMemo(()=>Cw(t.content),[t.content]),G=C.useMemo(()=>Tw(t.content),[t.content]),Q=C.useMemo(()=>R.length<=Ko?R:`${R.slice(0,Ko)}
|
|
129
|
-
… [truncated ${R.length-Ko} chars]`,[R]),de=C.useMemo(()=>kw(t.createdAt),[t.createdAt]),te=Iw(K,r),_e=C.useCallback(async()=>{const we=Z?R:K;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(we),I(!0),setTimeout(()=>I(!1),2e3),w==null||w(we)}catch(Ge){console.error("Failed to copy:",Ge)}},[Z,R,K,w]),Re=C.useCallback(()=>{if(!v)return;const we=Z?R:K;v(t.id,we)},[v,t.id,Z,R,K]),Ue=C.useCallback(()=>{g==null||g(n)},[g,n]),ke=C.useCallback(async(we,Fe,Ge)=>{if(!he){we.preventDefault();return}try{const P=String(Fe.url??""),H=P.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(H){we.preventDefault();const ue=H[1],ve=Fe.name||`file_${ue}`,ae=Fe.mimeType||"application/octet-stream";U({id:ue,name:ve,mimeType:ae}),V(!0);return}if(P.startsWith("data:")){if(we.preventDefault(),B[Ge])return;D(ve=>({...ve,[Ge]:!0}));const ue=$({title:"Fetching file...",description:"",open:!0});try{const ae=(await ev(j??void 0)).find(ze=>!ze||typeof ze!="object"||!((ze.filename??"")===(Fe.name??""))?!1:typeof Fe.size=="number"&&typeof ze.size=="number"?ze.size===Fe.size:!0);if(!(ae!=null&&ae.id))throw new Error("File is not yet available on the server");U({id:ae.id,name:Fe.name||ae.filename||`file_${ae.id}`,mimeType:Fe.mimeType||ae.mime_type||"application/octet-stream"}),V(!0),ue.update({id:ue.id,title:"Done",description:void 0})}catch(ve){console.error("Failed to fetch server file:",ve),ue.update({id:ue.id,title:"Failed",description:String(ve)}),$({title:"Failed to fetch file",description:String(ve),open:!0})}finally{D(ve=>({...ve,[Ge]:!1}))}}}catch(P){console.error("File click error:",P)}},[he,B,$,j,D,U,V]),je=C.useCallback(()=>{const Fe=Y(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",L);switch(X){case"user":return c.jsx(se.User,{className:Fe});case"assistant":return c.jsx(se.Bot,{className:Fe});case"tool":return c.jsx(se.Wrench,{className:Fe});default:return c.jsx(se.Bot,{className:Fe})}},[M,L,X]),et=C.useCallback(()=>{const we="group relative mb-4 flex w-full";switch(X){case"user":return Y(we,"justify-end");case"assistant":case"tool":case"system":return Y(we,"justify-start");default:return we}},[X]),Ke=C.useCallback(()=>{const we=Y("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 Y(we,"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 Y(we,"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 Y(we,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Y(we,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Y(we,"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(!(K.trim().length>0||pe.length>0||F.length>0))return c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(t.model==="reflection"){const P=K.trim(),H=Di(P);if(H&&typeof H=="object")return c.jsx(Pw,{data:H})}if(Z&&ee.name==="get_issues"){const P=t.content.find(ve=>ve.type==="tool_result"),H=(P==null?void 0:P.output)??R,ue=Ku(H);if(ue)return c.jsx(Ow,{issues:ue})}if(Z&&!E){const P=R.slice(0,80).replace(/\s+/g," ");return c.jsx("div",{className:Y("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",M&&"text-[10px]"),children:c.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(Z&&d){const P=R,H=P.length>f;return c.jsx(_c,{open:S,onOpenChange:T,children:c.jsxs("div",{className:"font-mono text-sm text-current",children:[c.jsx("pre",{className:Y("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:H&&!S?`${Q.substring(0,f)}...`:Q}),H&&c.jsx(Rc,{asChild:!0,children:c.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:S?c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Math.max(P.length-f,0)," chars)"]})})})]})})}if(Z&&E&&!d)return G&&Aw(G)?c.jsx(Io,{content:G.trim()}):c.jsx("div",{className:"font-mono text-sm text-current",children:c.jsx("pre",{className:Y("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:Q})});const Fe=pe.length>0&&X!=="tool",Ge=F.length>0&&X!=="tool";return c.jsxs("div",{children:[r?c.jsxs("div",{className:Y("relative transition-all duration-200 ease-out",M?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const H=Uu(X,te)?Di(te):null;if(H!==null)return c.jsx(Wu,{data:H});const ue=_w(jw(te)),ve=te.trim().length===0;return c.jsx(c.Fragment,{children:ve?c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"animate-pulse space-y-2",children:[c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):c.jsx("pre",{className:Y("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",M&&"text-xs"),children:ue})})})(),c.jsx("div",{className:"mt-2",children:c.jsx(Nw,{className:Y(L,M?"text-xs":"text-sm")})})]}):(()=>{const P=K.trim(),ue=Uu(X,P)?Di(P):null;if(ue!==null)return c.jsx(Wu,{data:ue});if(X==="user"&&h){const ve=P;if(ve.length>m)return c.jsxs(_c,{open:A,onOpenChange:O,children:[c.jsx("div",{className:Y("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:A?c.jsx(Io,{content:ve,allowHtml:!1}):c.jsxs("pre",{className:Y("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[ve.substring(0,m),"..."]})}),c.jsx(Rc,{asChild:!0,children:c.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:A?c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ve.length-m," chars)"]})})})]})}return c.jsx(Io,{content:K.trim(),allowHtml:!1})})(),Fe&&c.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:pe.map((P,H)=>{const ue=P,ve=typeof ue.width=="number"?ue.width:void 0,ae=typeof ue.height=="number"?ue.height:void 0,ze=ve&&ae&&ae>0?`${ve} / ${ae}`:"4 / 3",at=ve&&ae&&ae>0?Math.max(120,Math.round(ae/ve*140)):160;return c.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:ze,minHeight:at},"data-placeholder-height":at,children:[c.jsx("img",{src:ue.url,alt:ue.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),c.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:[c.jsx(se.Image,{className:"h-3 w-3"}),c.jsx("span",{children:"image"})]})]},H)})}),Ge&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:F.map((P,H)=>{const ue=P,ve=ue.name||"file";return c.jsxs("a",{href:ue.url,download:ve,onClick:ae=>ke(ae,ue,H),target:"_blank",rel:"noreferrer",className:Y("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:ve,"aria-disabled":!he,children:[c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-gray-500"}),B[H]?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),c.jsxs("span",{className:"truncate max-w-[140px]",children:[ve," (processing)"]})]}):c.jsx("span",{className:"truncate max-w-[180px]",children:ve})]},H)})})]})},[Z,K,pe,F,t,ee.name,R,E,d,S,Q,f,G,r,te,X,L,M,h,A,m,he,B,ke]),ut=C.useMemo(()=>Ew(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Y(et(),b.container),children:c.jsxs("div",{className:Y(Ke(),b.content),children:[(a||l||Z)&&c.jsxs("div",{className:Y("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",L,b.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[je(),l&&ut&&c.jsx("span",{className:Y("font-medium",M?"text-xs":"text-sm"),children:ut}),Z&&ee.name&&c.jsxs(kc,{variant:"outline",className:Y("text-xs flex items-center gap-1 cursor-pointer",L,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E,onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),N(Fe=>!Fe))},onClick:()=>N(we=>!we),children:[c.jsx("span",{children:ee.name}),c.jsx("span",{className:"inline-flex items-center",children:E?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!ee.name&&c.jsx(Be,{variant:"ghost",size:"sm",className:Y("h-6 px-1",L,"hover:bg-foreground/10"),onClick:()=>N(we=>!we),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[a&&c.jsx("span",{className:Y("text-xs opacity-60",L,M&&"text-xs"),children:de}),i&&!s&&c.jsxs("div",{className:Y("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[c.jsx(Be,{variant:"ghost",size:"sm",onClick:_e,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Copy message",children:c.jsx(se.Copy,{className:Y(y?"text-success":L,M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&v&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Re,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(se.Edit,{className:Y(L,M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Ue,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(se.RotateCcw,{className:Y(L,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:ct()}),Z&&E&&(ee.toolCallId||ee.name)&&c.jsxs("div",{className:Y("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ee.name&&c.jsxs("div",{children:["Function: ",ee.name]}),ee.toolCallId&&c.jsxs("div",{children:["Call ID: ",ee.toolCallId]})]}),!(a||l||Z)&&i&&!s&&c.jsxs("div",{className:Y("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[c.jsx(Be,{variant:"ghost",size:"sm",onClick:_e,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.Copy,{className:Y(y?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&v&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Re,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.Edit,{className:Y("text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Ue,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.RotateCcw,{className:Y("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),re&&c.jsx(bw,{isOpen:J,onClose:()=>{V(!1),U(null)},fileId:re.id,fileName:re.name,mimeType:re.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Bu(e.message)===Bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),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)===((u=t.customStyles)==null?void 0:u.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)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function Aw(e){return e.includes(`
|
|
129
|
+
… [truncated ${R.length-Ko} chars]`,[R]),de=C.useMemo(()=>kw(t.createdAt),[t.createdAt]),te=Iw(K,r),_e=C.useCallback(async()=>{const we=Z?R:K;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(we),I(!0),setTimeout(()=>I(!1),2e3),w==null||w(we)}catch(Ge){console.error("Failed to copy:",Ge)}},[Z,R,K,w]),Re=C.useCallback(()=>{if(!v)return;const we=Z?R:K;v(t.id,we)},[v,t.id,Z,R,K]),Ue=C.useCallback(()=>{g==null||g(n)},[g,n]),ke=C.useCallback(async(we,Fe,Ge)=>{if(!he){we.preventDefault();return}try{const P=String(Fe.url??""),H=P.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(H){we.preventDefault();const ue=H[1],ve=Fe.name||`file_${ue}`,ae=Fe.mimeType||"application/octet-stream";U({id:ue,name:ve,mimeType:ae}),V(!0);return}if(P.startsWith("data:")){if(we.preventDefault(),B[Ge])return;D(ve=>({...ve,[Ge]:!0}));const ue=$({title:"Fetching file...",description:"",open:!0});try{const ae=(await ev(j??void 0)).find(ze=>!ze||typeof ze!="object"||!((ze.filename??"")===(Fe.name??""))?!1:typeof Fe.size=="number"&&typeof ze.size=="number"?ze.size===Fe.size:!0);if(!(ae!=null&&ae.id))throw new Error("File is not yet available on the server");U({id:ae.id,name:Fe.name||ae.filename||`file_${ae.id}`,mimeType:Fe.mimeType||ae.mime_type||"application/octet-stream"}),V(!0),ue.update({id:ue.id,title:"Done",description:void 0})}catch(ve){console.error("Failed to fetch server file:",ve),ue.update({id:ue.id,title:"Failed",description:String(ve)}),$({title:"Failed to fetch file",description:String(ve),open:!0})}finally{D(ve=>({...ve,[Ge]:!1}))}}}catch(P){console.error("File click error:",P)}},[he,B,$,j,D,U,V]),je=C.useCallback(()=>{const Fe=Y(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",L);switch(X){case"user":return c.jsx(se.User,{className:Fe});case"assistant":return c.jsx(se.Bot,{className:Fe});case"tool":return c.jsx(se.Wrench,{className:Fe});default:return c.jsx(se.Bot,{className:Fe})}},[M,L,X]),et=C.useCallback(()=>{const we="group relative mb-4 flex w-full";switch(X){case"user":return Y(we,"justify-end");case"assistant":case"tool":case"system":return Y(we,"justify-start");default:return we}},[X]),Ke=C.useCallback(()=>{const we=Y("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 Y(we,"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 Y(we,"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 Y(we,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Y(we,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Y(we,"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(!(K.trim().length>0||pe.length>0||F.length>0)&&!r)return c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(t.model==="reflection"){const P=K.trim(),H=Di(P);if(H&&typeof H=="object")return c.jsx(Pw,{data:H})}if(Z&&ee.name==="get_issues"){const P=t.content.find(ve=>ve.type==="tool_result"),H=(P==null?void 0:P.output)??R,ue=Ku(H);if(ue)return c.jsx(Ow,{issues:ue})}if(Z&&!E){const P=R.slice(0,80).replace(/\s+/g," ");return c.jsx("div",{className:Y("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",M&&"text-[10px]"),children:c.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(Z&&d){const P=R,H=P.length>f;return c.jsx(_c,{open:S,onOpenChange:T,children:c.jsxs("div",{className:"font-mono text-sm text-current",children:[c.jsx("pre",{className:Y("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:H&&!S?`${Q.substring(0,f)}...`:Q}),H&&c.jsx(Rc,{asChild:!0,children:c.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:S?c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Math.max(P.length-f,0)," chars)"]})})})]})})}if(Z&&E&&!d)return G&&Aw(G)?c.jsx(Io,{content:G.trim()}):c.jsx("div",{className:"font-mono text-sm text-current",children:c.jsx("pre",{className:Y("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:Q})});const Fe=pe.length>0&&X!=="tool",Ge=F.length>0&&X!=="tool";return c.jsxs("div",{children:[r?c.jsxs("div",{className:Y("relative transition-all duration-200 ease-out",M?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const H=Uu(X,te)?Di(te):null;if(H!==null)return c.jsx(Wu,{data:H});const ue=_w(jw(te)),ve=te.trim().length===0;return c.jsx(c.Fragment,{children:ve?c.jsx("div",{className:"w-full",children:c.jsxs("div",{className:"animate-pulse space-y-2",children:[c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),c.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):c.jsx("pre",{className:Y("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",M&&"text-xs"),children:ue})})})(),c.jsx("div",{className:"mt-2",children:c.jsx(Nw,{className:Y(L,M?"text-xs":"text-sm")})})]}):(()=>{const P=K.trim(),ue=Uu(X,P)?Di(P):null;if(ue!==null)return c.jsx(Wu,{data:ue});if(X==="user"&&h){const ve=P;if(ve.length>m)return c.jsxs(_c,{open:A,onOpenChange:O,children:[c.jsx("div",{className:Y("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:A?c.jsx(Io,{content:ve,allowHtml:!1}):c.jsxs("pre",{className:Y("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[ve.substring(0,m),"..."]})}),c.jsx(Rc,{asChild:!0,children:c.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:A?c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ve.length-m," chars)"]})})})]})}return c.jsx(Io,{content:K.trim(),allowHtml:!1})})(),Fe&&c.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:pe.map((P,H)=>{const ue=P,ve=typeof ue.width=="number"?ue.width:void 0,ae=typeof ue.height=="number"?ue.height:void 0,ze=ve&&ae&&ae>0?`${ve} / ${ae}`:"4 / 3",at=ve&&ae&&ae>0?Math.max(120,Math.round(ae/ve*140)):160;return c.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:ze,minHeight:at},"data-placeholder-height":at,children:[c.jsx("img",{src:ue.url,alt:ue.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),c.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:[c.jsx(se.Image,{className:"h-3 w-3"}),c.jsx("span",{children:"image"})]})]},H)})}),Ge&&c.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:F.map((P,H)=>{const ue=P,ve=ue.name||"file";return c.jsxs("a",{href:ue.url,download:ve,onClick:ae=>ke(ae,ue,H),target:"_blank",rel:"noreferrer",className:Y("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:ve,"aria-disabled":!he,children:[c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-gray-500"}),B[H]?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),c.jsxs("span",{className:"truncate max-w-[140px]",children:[ve," (processing)"]})]}):c.jsx("span",{className:"truncate max-w-[180px]",children:ve})]},H)})})]})},[Z,K,pe,F,t,ee.name,R,E,d,S,Q,f,G,r,te,X,L,M,h,A,m,he,B,ke]),ut=C.useMemo(()=>Ew(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Y(et(),b.container),children:c.jsxs("div",{className:Y(Ke(),b.content),children:[(a||l||Z)&&c.jsxs("div",{className:Y("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",L,b.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[je(),l&&ut&&c.jsx("span",{className:Y("font-medium",M?"text-xs":"text-sm"),children:ut}),Z&&ee.name&&c.jsxs(kc,{variant:"outline",className:Y("text-xs flex items-center gap-1 cursor-pointer",L,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E,onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),N(Fe=>!Fe))},onClick:()=>N(we=>!we),children:[c.jsx("span",{children:ee.name}),c.jsx("span",{className:"inline-flex items-center",children:E?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!ee.name&&c.jsx(Be,{variant:"ghost",size:"sm",className:Y("h-6 px-1",L,"hover:bg-foreground/10"),onClick:()=>N(we=>!we),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[a&&c.jsx("span",{className:Y("text-xs opacity-60",L,M&&"text-xs"),children:de}),i&&!s&&c.jsxs("div",{className:Y("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[c.jsx(Be,{variant:"ghost",size:"sm",onClick:_e,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Copy message",children:c.jsx(se.Copy,{className:Y(y?"text-success":L,M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&v&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Re,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(se.Edit,{className:Y(L,M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Ue,className:Y("h-6 w-6 p-0 hover:bg-foreground/10",L,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(se.RotateCcw,{className:Y(L,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:ct()}),Z&&E&&(ee.toolCallId||ee.name)&&c.jsxs("div",{className:Y("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ee.name&&c.jsxs("div",{children:["Function: ",ee.name]}),ee.toolCallId&&c.jsxs("div",{children:["Call ID: ",ee.toolCallId]})]}),!(a||l||Z)&&i&&!s&&c.jsxs("div",{className:Y("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[c.jsx(Be,{variant:"ghost",size:"sm",onClick:_e,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.Copy,{className:Y(y?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&v&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Re,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.Edit,{className:Y("text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&c.jsx(Be,{variant:"ghost",size:"sm",onClick:Ue,className:Y("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(se.RotateCcw,{className:Y("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),re&&c.jsx(bw,{isOpen:J,onClose:()=>{V(!1),U(null)},fileId:re.id,fileName:re.name,mimeType:re.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Bu(e.message)===Bu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),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)===((u=t.customStyles)==null?void 0:u.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)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function Aw(e){return e.includes(`
|
|
130
130
|
`)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function jw(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 _w(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 Di(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 Uu(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 Wu({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:qo,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:qu(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 c.jsxs("div",{className:qo,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:qo,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:Rw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:qu(e)})}function Rw(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 c.jsx("code",{className:"text-xs",children:JSON.stringify(_r(e))})}catch{return String(e)}}function Vu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function _r(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(_r).filter(r=>r!==void 0);return n.length?n:void 0}if(Vu(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=_r(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function qu(e){if(typeof e=="string")return e;if(Vu(e))return"";try{const t=_r(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Pw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Ku(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 Ku(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 l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),b=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=m?m[2].trim():"",g=b?b[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}function Ow({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:qo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Gu=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Li=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:b=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},w)=>{const y=C.useRef(null),I=C.useRef(null),S=C.useRef(!1),[T,E]=C.useState(!0),N=C.useCallback(j=>{E(j),g&&g(!j),x&&x(j)},[g,x]),A=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(!b||v){O.current!==!1&&(O.current=!1);return}const j=t&&T?"auto":!1;O.current!==j&&(O.current=j)},[t,T,b,v]),e.length===0?c.jsx("div",{className:f,style:h,children:c.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!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(ox,{ref:j=>{y.current=j},scrollerRef:j=>{I.current=j instanceof HTMLDivElement?j:null},data:e,followOutput:O.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{A&&A()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,$)=>Gu($,j),itemContent:(j,$)=>{const B=Gu($,j);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":B,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Hu,{message:$,messageIndex:j,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(j),onCancelEdit:d})})}})})});Li.displayName="MessageList";const Go=1e4;function Mw(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
|
|
package/package.json
CHANGED