research-agent-ui 0.1.354 → 0.1.355

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.
@@ -1,4 +1,4 @@
1
- const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-DgR_99cQ.cjs"),i=require("./config.cjs");let a=require("react");a=e.t(a,1);let o=require("react/jsx-runtime"),s=require("motion/react"),c=require("lucide-react"),l=require("qwksearch-api-client"),u=require("quantum-sphere-loading-icon/react");u=e.t(u,1);let d=require("markdown-to-jsx");d=e.t(d,1);let f=require("extract-webpage/html-to-content/html-utils"),p=require("@radix-ui/react-popover");p=e.t(p,1);let m=require("grab-url/animations");m=e.t(m,1);var h=(0,a.memo)(({blur:e=0,inactiveZone:n=.7,proximity:r=0,spread:i=20,variant:c=`default`,glow:l=!1,className:u,movementDuration:d=2,borderWidth:f=1,disabled:p=!0})=>{let m=(0,a.useRef)(null),h=(0,a.useRef)({x:0,y:0}),g=(0,a.useRef)(0),_=(0,a.useCallback)(e=>{m.current&&(g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(()=>{let t=m.current;if(!t)return;let{left:i,top:a,width:o,height:c}=t.getBoundingClientRect(),l=e?.x??h.current.x,u=e?.y??h.current.y;e&&(h.current={x:l,y:u});let f=[i+o*.5,a+c*.5];if(Math.hypot(l-f[0],u-f[1])<.5*Math.min(o,c)*n){t.style.setProperty(`--active`,`0`);return}let p=l>i-r&&l<i+o+r&&u>a-r&&u<a+c+r;if(t.style.setProperty(`--active`,p?`1`:`0`),!p)return;let g=parseFloat(t.style.getPropertyValue(`--start`))||0,_=g+((180*Math.atan2(u-f[1],l-f[0])/Math.PI+90-g+180)%360-180);(0,s.animate)(g,_,{duration:d,ease:[.16,1,.3,1],onUpdate:e=>{t.style.setProperty(`--start`,String(e))}})}))},[n,r,d]);return(0,a.useEffect)(()=>{if(p)return;let e=()=>_(),t=e=>_(e);return window.addEventListener(`scroll`,e,{passive:!0}),document.body.addEventListener(`pointermove`,t,{passive:!0}),()=>{g.current&&cancelAnimationFrame(g.current),window.removeEventListener(`scroll`,e),document.body.removeEventListener(`pointermove`,t)}},[_,p]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:t.o(`pointer-events-none absolute -inset-px hidden rounded-[inherit] border opacity-0 transition-opacity`,l&&`opacity-100`,c===`white`&&`border-white`,p&&`!block`)}),(0,o.jsx)(`div`,{ref:m,style:{"--blur":`${e}px`,"--spread":i,"--start":`0`,"--active":`0`,"--glowingeffect-border-width":`${f}px`,"--repeating-conic-gradient-times":`5`,"--gradient":c===`white`?`repeating-conic-gradient(
1
+ const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-D7eu9lB9.cjs"),i=require("./config.cjs");let a=require("react");a=e.t(a,1);let o=require("react/jsx-runtime"),s=require("motion/react"),c=require("lucide-react"),l=require("qwksearch-api-client"),u=require("quantum-sphere-loading-icon/react");u=e.t(u,1);let d=require("markdown-to-jsx");d=e.t(d,1);let f=require("extract-webpage/html-to-content/html-utils"),p=require("@radix-ui/react-popover");p=e.t(p,1);let m=require("grab-url/animations");m=e.t(m,1);var h=(0,a.memo)(({blur:e=0,inactiveZone:n=.7,proximity:r=0,spread:i=20,variant:c=`default`,glow:l=!1,className:u,movementDuration:d=2,borderWidth:f=1,disabled:p=!0})=>{let m=(0,a.useRef)(null),h=(0,a.useRef)({x:0,y:0}),g=(0,a.useRef)(0),_=(0,a.useCallback)(e=>{m.current&&(g.current&&cancelAnimationFrame(g.current),g.current=requestAnimationFrame(()=>{let t=m.current;if(!t)return;let{left:i,top:a,width:o,height:c}=t.getBoundingClientRect(),l=e?.x??h.current.x,u=e?.y??h.current.y;e&&(h.current={x:l,y:u});let f=[i+o*.5,a+c*.5];if(Math.hypot(l-f[0],u-f[1])<.5*Math.min(o,c)*n){t.style.setProperty(`--active`,`0`);return}let p=l>i-r&&l<i+o+r&&u>a-r&&u<a+c+r;if(t.style.setProperty(`--active`,p?`1`:`0`),!p)return;let g=parseFloat(t.style.getPropertyValue(`--start`))||0,_=g+((180*Math.atan2(u-f[1],l-f[0])/Math.PI+90-g+180)%360-180);(0,s.animate)(g,_,{duration:d,ease:[.16,1,.3,1],onUpdate:e=>{t.style.setProperty(`--start`,String(e))}})}))},[n,r,d]);return(0,a.useEffect)(()=>{if(p)return;let e=()=>_(),t=e=>_(e);return window.addEventListener(`scroll`,e,{passive:!0}),document.body.addEventListener(`pointermove`,t,{passive:!0}),()=>{g.current&&cancelAnimationFrame(g.current),window.removeEventListener(`scroll`,e),document.body.removeEventListener(`pointermove`,t)}},[_,p]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:t.o(`pointer-events-none absolute -inset-px hidden rounded-[inherit] border opacity-0 transition-opacity`,l&&`opacity-100`,c===`white`&&`border-white`,p&&`!block`)}),(0,o.jsx)(`div`,{ref:m,style:{"--blur":`${e}px`,"--spread":i,"--start":`0`,"--active":`0`,"--glowingeffect-border-width":`${f}px`,"--repeating-conic-gradient-times":`5`,"--gradient":c===`white`?`repeating-conic-gradient(
2
2
  from 236.84deg at 50% 50%,
3
3
  var(--black),
4
4
  var(--black) calc(25% / var(--repeating-conic-gradient-times))
@@ -13,5 +13,5 @@ const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.
13
13
  #5a922c calc(50% / var(--repeating-conic-gradient-times)),
14
14
  #4c7894 calc(75% / var(--repeating-conic-gradient-times)),
15
15
  #dd7bbb calc(100% / var(--repeating-conic-gradient-times))
16
- )`},className:t.o(`pointer-events-none absolute inset-0 rounded-[inherit] opacity-100 transition-opacity`,l&&`opacity-100`,e>0&&`blur-[var(--blur)] `,u,p&&`!hidden`),children:(0,o.jsx)(`div`,{className:t.o(`glow`,`rounded-[inherit]`,`after:content-[""] after:rounded-[inherit] after:absolute after:inset-[calc(-1*var(--glowingeffect-border-width))]`,`after:[border:var(--glowingeffect-border-width)_solid_transparent]`,`after:[background:var(--gradient)] after:[background-attachment:fixed]`,`after:opacity-[var(--active)] after:transition-opacity after:duration-300`,`after:[mask-clip:padding-box,border-box]`,`after:[mask-composite:intersect]`,`after:[mask-image:linear-gradient(#0000,#0000),conic-gradient(from_calc((var(--start)-var(--spread))*1deg),#00000000_0deg,#fff,#00000000_calc(var(--spread)*2deg))]`)})})]})});h.displayName=`GlowingEffect`;function g(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}function _(e){return e.iframe_src&&g(e.iframe_src)?{type:`inline`,src:e.iframe_src}:{type:`external`,url:e.url||``}}function v(e){return{pageContent:e.snippet||e.content||``,metadata:{title:e.title||``,source:e.source||``,thumbnail:e.thumbnail||``,url:e.url||``,...e.img_src&&{img_src:e.img_src},...e.iframe_src&&{iframe_src:e.iframe_src}}}}var y=r.Q.filter(e=>[`general`,`news`,`videos`,`images`,`science`,`files`].includes(e.code)),b=({sources:e,query:r})=>{let[i,s]=(0,a.useState)(`general`),[u,d]=(0,a.useState)(e),[p,m]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[x,S]=(0,a.useState)(1),[C,w]=(0,a.useState)(!0),[T,E]=(0,a.useState)(!1),[D,O]=(0,a.useState)(!1),[k,A]=(0,a.useState)(null),j=(0,a.useRef)(null),M=(0,a.useRef)(!1),N=(0,a.useRef)(!1),{openPanel:P,isOpen:F}=n.a();(0,a.useEffect)(()=>{let e=()=>{O(localStorage.getItem(`searchResultGlow`)===`true`)};return e(),window.addEventListener(`client-config-changed`,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(`client-config-changed`,e),window.removeEventListener(`storage`,e)}},[]);let[I,L]=(0,a.useState)({});(0,a.useEffect)(()=>{let e=()=>{E(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{d(e),s(`general`),S(1),w(!0),L({}),R(e)},[e]);let R=(0,a.useCallback)(async e=>{let t=e.filter(e=>e.metadata.url&&e.metadata.url!==`File`&&!e.metadata.iframe_src);for(let e of t)try{let{data:t}=await(0,l.getArticle)({query:{url:e.metadata.url}});t?.cached&&t?.article?.html&&L(t=>({...t,[e.metadata.url]:`loaded`}))}catch{}},[]);(0,a.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search).get(`extract`);e&&(P(decodeURIComponent(e),``),N.current=!1)}},[P]),(0,a.useEffect)(()=>{N.current=!1},[e]),(0,a.useEffect)(()=>{M.current&&!F&&(N.current=!0),M.current=F},[F]),(0,a.useEffect)(()=>{if(T&&u&&u.length>0&&!F&&!N.current){let e=u[0];e?.metadata?.url&&P(e.metadata.url,``)}},[u,T]);let z=async(e,t)=>{e.preventDefault(),N.current=!1,L(e=>({...e,[t]:`loading`})),P(t,``);try{await(0,l.getArticle)({query:{url:t}}),L(e=>({...e,[t]:`loaded`}))}catch{L(e=>({...e,[t]:`loaded`}))}},B=(0,a.useCallback)(async()=>{if(!r||g||!C)return;b(!0);let e=x+1,{data:t}=await(0,l.agentSearch)({query:{q:r,cat:i,page:e}}),n=t?.results??[];if(n.length===0){w(!1),b(!1);return}let a=n.map(e=>{if(e.url)try{let t=new URL(e.url);(t.pathname===`/`||t.pathname===``)&&console.warn(`[MessageSources] Search result URL is domain-only:`,e.url,`Title:`,e.title)}catch{console.error(`[MessageSources] Invalid URL in search result:`,e.url)}return v(e)});d(e=>[...e,...a]),S(e),b(!1)},[r,i,x,g,C]),V=async e=>{if(e!==i&&r){s(e),m(!0),S(1),w(!0);try{let{data:t}=await(0,l.agentSearch)({query:{q:r,cat:e,page:1}}),n=(t?.results??[]).map(e=>{if(e.url)try{let t=new URL(e.url);(t.pathname===`/`||t.pathname===``)&&console.warn(`[MessageSources] Category search result URL is domain-only:`,e.url,`Title:`,e.title)}catch{console.error(`[MessageSources] Invalid URL in category search result:`,e.url)}return v(e)});d(n)}catch(e){console.error(`Error searching:`,e)}finally{m(!1)}}};(0,a.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<100&&B()};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[B]);let H=(e,t)=>{let n=i===`images`,r=i===`videos`,a=e.metadata.img_src||e.metadata.thumbnail;if(n&&a)return(0,o.jsx)(`div`,{className:`relative rounded-lg group`,children:(0,o.jsxs)(`a`,{className:`relative block overflow-hidden rounded-lg cursor-pointer`,href:e.metadata.url,onClick:t=>z(t,e.metadata.url),children:[(0,o.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-auto object-cover rounded-lg hover:scale-105 transition-transform duration-200`,loading:`lazy`}),(0,o.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200`,children:[(0,o.jsx)(`p`,{className:`text-xs text-white line-clamp-2`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)}),(0,o.jsx)(`p`,{className:`text-[10px] text-white/70 truncate mt-0.5`,children:e.metadata.source})]})]})},t);if(r&&a){let n=_(e.metadata),r=(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-24 object-cover`}),(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`div`,{className:`w-10 h-10 bg-black/60 rounded-full flex items-center justify-center`,children:(0,o.jsx)(c.Video,{size:18,className:`text-white ml-0.5`})})})]}),i=(0,o.jsx)(`p`,{className:`text-xs line-clamp-2 p-2 text-muted-foreground`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)});return(0,o.jsxs)(`div`,{className:`relative rounded-xl`,children:[(0,o.jsx)(h,{spread:40,glow:!0,disabled:!D,proximity:64,inactiveZone:.01,borderWidth:2}),n.type===`inline`?(0,o.jsxs)(`button`,{type:`button`,className:`relative w-full text-left bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200`,onClick:()=>A({src:n.src,title:e.metadata.title}),children:[r,i]}):(0,o.jsxs)(`a`,{className:`relative bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200`,href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:[r,i]})]},t)}let s=I[e.metadata.url];return(0,o.jsxs)(`div`,{className:`relative rounded-xl group h-full`,children:[(0,o.jsx)(h,{spread:40,glow:!0,disabled:!D,proximity:64,inactiveZone:.01,borderWidth:2}),(0,o.jsxs)(`div`,{className:`relative bg-card text-card-foreground border border-border rounded-xl p-2.5 flex flex-col font-medium cursor-pointer shadow-sm hover:shadow-md transition-all duration-200 h-full`,onClick:t=>z(t,e.metadata.url),children:[s&&(0,o.jsx)(`div`,{className:`absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]`,children:s===`loading`?(0,o.jsx)(c.Loader2,{size:14,className:`text-primary animate-spin`}):(0,o.jsx)(c.FileText,{size:14,className:`text-green-500`})}),(0,o.jsx)(`a`,{href:e.metadata.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`absolute top-1.5 right-1.5 p-1 rounded-md bg-secondary/50 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-secondary z-10`,title:`Open in new tab`,children:(0,o.jsx)(c.ExternalLink,{size:12,className:`text-muted-foreground`})}),(0,o.jsxs)(`p`,{className:`text-xs line-clamp-4 text-muted-foreground`,children:[(0,o.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle`,children:[e.metadata.url===`File`?(0,o.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0`,children:(0,o.jsx)(c.File,{size:10,className:`text-muted-foreground`})}):(0,o.jsx)(`img`,{src:`https://s2.googleusercontent.com/s2/favicons?domain_url=${e.metadata.url}`,width:20,height:20,alt:`favicon`,className:`inline rounded h-5 w-5 flex-shrink-0`}),e.metadata.source]}),` `,(0,o.jsx)(`span`,{className:`align-middle`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]})]},t)};return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(`div`,{className:`flex items-center gap-1 mb-3 overflow-x-auto pb-1`,children:y.map(e=>(0,o.jsxs)(`button`,{onClick:()=>V(e.code),disabled:p,className:t.o(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap`,i===e.code?`bg-primary text-primary-foreground`:`bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground`),children:[(0,o.jsx)(e.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:e.name})]},e.code))}),(0,o.jsx)(`div`,{ref:j,className:t.o(`overflow-y-auto pb-2 pr-1`,i===`images`?`max-h-[400px] lg:max-h-[500px]`:`max-h-[180px] lg:max-h-[280px]`),children:p?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(c.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`})}):u.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:t.o(i===`images`?`columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid`:t.o(`grid gap-3 auto-rows-fr`,F&&T?`grid-cols-2`:`grid-cols-3`)),children:u.map((e,t)=>H(e,t))}),g&&(0,o.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,o.jsx)(c.Loader2,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!C&&u.length>0&&(0,o.jsx)(`div`,{className:`flex items-center justify-center py-4 text-muted-foreground text-xs`,children:`No more results`})]}):(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`No results found`})}),(0,o.jsx)(t.t,{open:k!==null,onOpenChange:e=>!e&&A(null),children:(0,o.jsxs)(t.n,{className:`max-w-3xl p-0 overflow-hidden gap-0`,children:[(0,o.jsx)(t.i,{className:`sr-only`,children:k?.title||`Video player`}),k&&(0,o.jsx)(`iframe`,{src:k.src,title:k.title||`Video player`,className:`w-full aspect-video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0})]})})]})},x={extract:`Extract`,arxiv:`ArXiv`,"google scholar":`Scholar`,pubmed:`PubMed`,wolframalpha:`Wolfram`,youtube:`YouTube`,Web:`Web`};function S(e){return e?x[e]??e:`Web`}function C({queries:e,loading:n}){let r=e.filter(e=>e.status===`done`).length,i=e.length,a=n&&e.some(e=>e.status===`running`);return n?(0,o.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/50`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[a?(0,o.jsx)(c.Loader2,{className:`w-3.5 h-3.5 animate-spin`}):(0,o.jsx)(c.Search,{className:`w-3.5 h-3.5`}),(0,o.jsx)(`span`,{className:`font-medium text-foreground`,children:a?`Running analysis…`:`Analysis complete`})]}),i>0&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[r,`/`,i,` searches`]})]}),e.length>0&&(0,o.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map((e,n)=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2`,children:[e.status===`running`?(0,o.jsx)(c.Loader2,{className:`w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0`}):(0,o.jsx)(c.Search,{className:t.o(`w-3.5 h-3.5 flex-shrink-0`,e.status===`done`?`text-muted-foreground`:`text-muted-foreground/40`)}),(0,o.jsxs)(`div`,{className:`flex items-baseline gap-1.5 min-w-0 flex-1`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap flex-shrink-0`,children:[S(e.category),` ·`]}),(0,o.jsx)(`span`,{className:`text-foreground/80 truncate`,children:e.query})]})]},n))})]}):null}var w=({href:e,children:t,sources:r})=>{let{openPanel:i}=n.a(),s=(0,a.useMemo)(()=>!r||!e?null:r.find(t=>t.metadata?.url===e)??null,[r,e]),c=(0,a.useMemo)(()=>{try{return new URL(e).hostname.replace(`www.`,``)}catch{return s?.metadata?.source||``}},[e,s]),l=s?.metadata?.title||``,u=`https://s2.googleusercontent.com/s2/favicons?domain_url=${e}`;return(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`a`,{href:e,onClick:t=>{t.preventDefault(),i(e,``)},className:`bg-light-secondary dark:bg-dark-secondary px-1 rounded ml-1 no-underline text-xs text-black/70 dark:text-white/70 relative cursor-pointer hover:bg-black/10 dark:hover:bg-white/20 transition-colors`,children:t})}),(0,o.jsx)(n.n,{side:`top`,className:`max-w-72 p-2.5`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,o.jsx)(`img`,{src:u,alt:``,width:16,height:16,className:`rounded flex-shrink-0 mt-0.5`}),(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium leading-snug line-clamp-2`,children:l||c}),l&&(0,o.jsx)(`p`,{className:`text-[10px] opacity-70 truncate mt-0.5`,children:c})]})]})})]})},T=({content:e,thinkingEnded:t})=>{let[n,r]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{r(!t)},[t]),(0,o.jsxs)(`div`,{className:`my-4 bg-secondary/50 rounded-xl border border-border overflow-hidden`,children:[(0,o.jsxs)(`button`,{onClick:()=>r(!n),className:`w-full flex items-center justify-between px-4 py-1 text-foreground/90 hover:bg-secondary transition duration-200`,children:[(0,o.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,o.jsx)(c.BrainCircuit,{size:20,className:`text-accent-foreground`}),(0,o.jsx)(`p`,{className:`font-medium text-sm`,children:`Thinking Process`})]}),n?(0,o.jsx)(c.ChevronUp,{size:18,className:`text-muted-foreground`}):(0,o.jsx)(c.ChevronDown,{size:18,className:`text-muted-foreground`})]}),n&&(0,o.jsx)(`div`,{className:`px-4 py-3 text-foreground/80 text-sm border-t border-border bg-muted/50 whitespace-pre-wrap`,children:e})]})},E=({children:e,thinkingEnded:t})=>(0,o.jsx)(T,{content:e,thinkingEnded:t}),D=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`avif`],O=e=>{let t=(e||``).toLowerCase();return D.includes(t)?(0,o.jsx)(c.Image,{size:15}):t===`url`?(0,o.jsx)(c.Link2,{size:15}):(0,o.jsx)(c.FileText,{size:15})},k=({file:e})=>{let{deleteAttachedFile:r}=n.u(),[i,s]=(0,a.useState)(!1),[l,u]=(0,a.useState)(!1);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-2 rounded-lg border border-border bg-secondary/40 py-1.5 pl-2.5 pr-1.5 text-sm`,children:[(0,o.jsx)(`span`,{className:`text-muted-foreground`,children:O(e.fileExtension)}),(0,o.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,title:e.fileName,children:e.fileName}),e.fileExtension&&e.fileExtension!==`url`&&(0,o.jsx)(`span`,{className:`hidden shrink-0 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:inline`,children:e.fileExtension}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.fileName}`,onClick:()=>s(!0),className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-red-500/10 hover:text-red-500`,children:(0,o.jsx)(c.Trash2,{size:14})})]}),(0,o.jsx)(t.t,{open:i,onOpenChange:e=>{l||s(e)},children:(0,o.jsxs)(t.n,{className:`w-full max-w-md rounded-2xl`,children:[(0,o.jsx)(t.i,{className:`text-lg font-medium leading-6`,children:`Delete file`}),(0,o.jsxs)(t.r,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,o.jsx)(`span`,{className:`font-medium text-foreground`,children:e.fileName}),`? This removes it from the conversation and permanently deletes the upload.`]}),(0,o.jsxs)(`div`,{className:`mt-6 flex flex-row items-center justify-end gap-4`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>!l&&s(!1),className:`text-sm text-muted-foreground transition-colors hover:text-foreground`,children:`Cancel`}),(0,o.jsxs)(`button`,{type:`button`,onClick:async()=>{u(!0);try{await r(e.fileId),s(!1)}finally{u(!1)}},disabled:l,className:`inline-flex items-center gap-1.5 text-sm text-red-500 transition-colors hover:text-red-600 disabled:opacity-60`,children:[l&&(0,o.jsx)(c.Loader2,{size:14,className:`animate-spin`}),`Delete`]})]})]})})]})},A=({files:e})=>!e||e.length===0?null:(0,o.jsx)(`div`,{className:`ml-10 mt-2 flex flex-wrap gap-2`,children:e.map(e=>(0,o.jsx)(k,{file:e},e.fileId))}),j=({section:e,isExpanded:r,setIsExpanded:i,isEditing:s,setIsEditing:l,editText:u,setEditText:d,handleEditSubmit:f,copiedUserMsg:p,handleCopyUserMsg:m})=>{let h=(0,a.useRef)(null);return(0,o.jsxs)(`div`,{className:`w-full pt-8 break-words`,children:[(0,o.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-3 group text-left w-full`,children:[(0,o.jsx)(`div`,{className:`flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200`,children:r?(0,o.jsx)(c.ChevronDown,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`}):(0,o.jsx)(c.ChevronRight,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`})}),(0,o.jsx)(`h2`,{className:`text-foreground font-medium text-lg lg:text-3xl lg:w-9/12 group-hover:text-foreground/80 transition-colors line-clamp-3 lg:line-clamp-none`,children:e.userMessage.content})]}),(0,o.jsxs)(`div`,{className:`flex items-center gap-0.5 mt-1 ml-10`,children:[(()=>{let n=t.s(e.userMessage.createdAt);return n?(0,o.jsx)(`time`,{dateTime:new Date(e.userMessage.createdAt).toISOString(),className:`mr-1.5 text-xs text-muted-foreground tabular-nums select-none`,children:n}):null})(),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:m,className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,o.jsx)(`span`,{className:t.o(`flex items-center transition-all duration-300`,p?`scale-110`:`scale-100`),children:p?(0,o.jsx)(c.Check,{size:14,className:`text-green-500`}):(0,o.jsx)(c.ClipboardList,{size:14})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:p?`Copied!`:`Copy prompt`})]}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{d(e.userMessage.content),l(!0),setTimeout(()=>h.current?.focus(),50)},className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,o.jsx)(c.Pencil,{size:14})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Edit & resubmit`})]})]}),(0,o.jsx)(A,{files:e.userMessage.files}),s&&(0,o.jsxs)(`div`,{className:`mt-3 ml-10 flex flex-col gap-2`,children:[(0,o.jsx)(`textarea`,{ref:h,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f()),e.key===`Escape`&&l(!1)},rows:3,className:`w-full rounded-xl border border-border bg-background p-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 transition-colors`}),(0,o.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,o.jsx)(`button`,{onClick:()=>l(!1),className:`px-3 py-1.5 text-sm text-muted-foreground rounded-lg hover:bg-secondary transition-colors duration-200`,children:`Cancel`}),(0,o.jsx)(`button`,{onClick:f,disabled:!u.trim(),className:`px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:`Resubmit`})]})]})]})},M=({section:e,initialMessage:t})=>{let[r,i]=(0,a.useState)(!1);return(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{let n=`${t}${e?.sourceMessage?.sources&&e.sourceMessage.sources.length>0&&`\n\nCitations:\n${e.sourceMessage.sources?.map((e,t)=>`[${t+1}] ${e.metadata.url}`).join(`
17
- `)}`}`;navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1e3)},className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:r?(0,o.jsx)(c.Check,{size:18}):(0,o.jsx)(c.ClipboardList,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:r?`Copied!`:`Copy`})]})};function N({...e}){return(0,o.jsx)(p.Root,{"data-slot":`popover`,...e})}function P({...e}){return(0,o.jsx)(p.Trigger,{"data-slot":`popover-trigger`,...e})}function F({className:e,align:n=`center`,sideOffset:r=4,container:i,...a}){return(0,o.jsx)(p.Portal,{container:i,children:(0,o.jsx)(p.Content,{"data-slot":`popover-content`,align:n,sideOffset:r,className:t.o(`bg-popover text-popover-foreground 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-2xl border p-4 shadow-md outline-hidden`,e),...a})})}var I=({messageId:e})=>{let{rewrite:i,chatModelProvider:s,setChatModelProvider:u}=n.u(),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(!0),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{_&&(async()=>{try{m(!0);let{data:e}=await(0,l.listProviders)();f(e?.providers??[])}catch(e){console.error(`Error loading providers:`,e)}finally{m(!1)}})()},[_]);let y=(0,a.useMemo)(()=>{if(!s?.providerId)return d;let e=d.findIndex(e=>e.id===s.providerId);return e===-1?d:[d[e],...d.filter((t,n)=>n!==e)]},[d,s]).map(e=>({...e,chatModels:(e.chatModels??[]).filter(t=>t.name.toLowerCase().includes(h.toLowerCase())||e.name.toLowerCase().includes(h.toLowerCase()))})).filter(e=>e.chatModels.length>0),b=(0,a.useMemo)(()=>{if(!s.key)return`Rewrite`;for(let e of d){let t=e.chatModels.find(e=>e.key===s.key);if(t)return t.name}return s.key},[d,s.key]),x=(t,n)=>{u({providerId:t,key:n}),localStorage.setItem(`chatModelProviderId`,t),localStorage.setItem(`chatModelKey`,n),v(!1),i(e)};return(0,o.jsxs)(N,{open:_,onOpenChange:v,children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(P,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.ArrowLeftRight,{size:18})})})}),(0,o.jsxs)(n.n,{side:`bottom`,children:[`Rewrite with `,b]})]}),(0,o.jsx)(F,{className:`w-[280px] p-0`,align:`start`,side:`top`,sideOffset:8,children:(0,o.jsxs)(`div`,{className:`bg-white dark:bg-[#212121] max-h-[400px] border rounded-2xl border-[#DDDDDD] dark:border-[#30302E] w-full flex flex-col shadow-2xl overflow-hidden`,children:[(0,o.jsx)(`div`,{className:`p-3 border-b border-[#EEEEEE] dark:border-[#30302E]`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(c.Search,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-text-400 dark:text-[#999999]`}),(0,o.jsx)(`input`,{type:`text`,placeholder:`Search models...`,value:h,onChange:e=>g(e.target.value),className:`w-full pl-9 pr-3 py-2 text-[13px] bg-bg-100 dark:bg-[#30302E] border border-bg-300 dark:border-[#404040] rounded-lg text-text-100 dark:text-[#ECECEC] placeholder:text-text-400 dark:placeholder:text-[#999999] focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-500/30 transition-all`})]})}),(0,o.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:p?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,o.jsx)(r.at.Loader2,{className:`animate-spin text-text-400 dark:text-[#999999]`,size:20})}):y.length===0?(0,o.jsx)(`div`,{className:`text-center py-12 px-4 text-text-400 dark:text-[#999999] text-sm`,children:h?`No models found`:`No chat models configured`}):(0,o.jsx)(`div`,{className:`flex flex-col`,children:y.map((e,n)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`px-4 py-2 sticky top-0 bg-white dark:bg-[#212121] border-b border-[#EEEEEE]/50 dark:border-[#30302E]/50`,children:(0,o.jsx)(`p`,{className:`text-[11px] text-text-400 dark:text-[#999999] uppercase tracking-wider font-medium`,children:e.name})}),(0,o.jsx)(`div`,{className:`flex flex-col px-1.5 py-1.5 space-y-0.5`,children:e.chatModels.map(n=>(0,o.jsxs)(`button`,{onClick:()=>x(e.id,n.key),type:`button`,className:t.o(`px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group`,s?.providerId===e.id&&s?.key===n.key?`bg-sky-50 dark:bg-sky-500/10`:`hover:bg-bg-100 dark:hover:bg-[#30302E]`),children:[(0,o.jsxs)(`div`,{className:`flex items-center space-x-2.5 min-w-0 flex-1`,children:[(0,o.jsx)(c.Cpu,{size:14,className:t.o(`shrink-0`,s?.providerId===e.id&&s?.key===n.key?`text-sky-500`:`text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]`)}),(0,o.jsx)(`p`,{className:t.o(`text-[13px] truncate`,s?.providerId===e.id&&s?.key===n.key?`text-sky-600 dark:text-sky-400 font-medium`:`text-text-200 dark:text-[#ECECEC] group-hover:text-text-100 dark:group-hover:text-white`),children:n.name})]}),s?.providerId===e.id&&s?.key===n.key&&(0,o.jsx)(r.at.Check,{className:`w-4 h-4 text-sky-500 shrink-0`})]},n.key))}),n<y.length-1&&(0,o.jsx)(`div`,{className:`h-px bg-[#EEEEEE] dark:bg-[#30302E] mx-2`})]},e.id))})})]})})]})},L=({section:e,speechStatus:t,isLoadingTTS:i=!1,start:a,stop:s,handleOpenInLLM:l})=>e.assistantMessage?(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2`,children:(0,o.jsxs)(`div`,{className:`flex flex-row items-center space-x-1`,children:[(0,o.jsx)(I,{messageId:e.assistantMessage.messageId}),(0,o.jsx)(M,{initialMessage:e.assistantMessage.content,section:e}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{t===`started`?s():a()},disabled:i,className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:i?(0,o.jsx)(c.Loader2,{size:18,className:`animate-spin`}):t===`started`?(0,o.jsx)(c.StopCircle,{size:18}):(0,o.jsx)(c.Volume2,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:i?`Loading TTS...`:t===`started`?`Stop`:`Read aloud`})]}),(0,o.jsxs)(r.$,{children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(r.nt,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.Download,{size:18})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Export`})]}),(0,o.jsxs)(r.et,{align:`end`,side:`top`,children:[(0,o.jsxs)(r.tt,{onClick:()=>r.Y(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileText,{size:16}),`Markdown`]}),(0,o.jsxs)(r.tt,{onClick:()=>r.X(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileType,{size:16}),`PDF`]}),(0,o.jsxs)(r.tt,{onClick:()=>r.J(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileDown,{size:16}),`DOCX`]}),(0,o.jsxs)(r.tt,{onClick:()=>r.Z(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileSpreadsheet,{size:16}),`Google Docs`]})]})]}),(0,o.jsxs)(r.$,{children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(r.nt,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.ExternalLink,{size:18})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Open in LLM`})]}),(0,o.jsxs)(r.et,{align:`end`,side:`top`,children:[(0,o.jsx)(r.tt,{onClick:()=>l(`qwksearch`),children:`QwkSearch`}),(0,o.jsx)(r.tt,{onClick:()=>l(`claude`),children:`Claude`}),(0,o.jsx)(r.tt,{onClick:()=>l(`perplexity`),children:`Perplexity`}),(0,o.jsx)(r.tt,{onClick:()=>l(`gemini`),children:`Google Gemini`}),(0,o.jsx)(r.tt,{onClick:()=>l(`chatgpt`),children:`ChatGPT`})]})]})]})}):null,R=({section:e,isLast:t,loading:n,sendMessage:i})=>{let s=(0,a.useRef)([]);return(0,a.useEffect)(()=>{e.suggestions&&e.suggestions.length>0&&(s.current=e.suggestions.slice(0,5))},[e.suggestions]),(0,a.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)return;let n=e.key,r=parseInt(n);r>=1&&r<=5&&s.current.length>=r&&(e.preventDefault(),i(s.current[r-1]))};if(t&&s.current.length>0)return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]),!e.suggestions||e.suggestions.length===0||!e.assistantMessage?null:(0,o.jsx)(`div`,{className:`mt-8 pt-6 border-t border-border/50`,children:(0,o.jsx)(`div`,{className:`space-y-2`,children:e.suggestions?.slice(0,5).map((e,t)=>(0,o.jsx)(`button`,{onClick:()=>i(e),className:`group w-full px-4 py-4 text-left transition-all duration-200 cursor-pointer rounded-lg border border-border/50 hover:border-primary/30 hover:bg-accent/50 hover:shadow-sm`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(r.G,{variant:`secondary`,className:`flex-shrink-0 h-6 w-6 p-0 flex items-center justify-center rounded-full text-sm font-semibold`,children:t+1}),(0,o.jsx)(`p`,{className:`flex-1 text-base font-medium text-muted-foreground group-hover:text-primary transition-colors duration-200 leading-relaxed`,children:e}),(0,o.jsx)(c.Plus,{size:18,className:`text-muted-foreground/60 group-hover:text-primary transition-colors duration-200 flex-shrink-0`})]})},t))})})},z=({section:e,dividerRef:i,isLast:s})=>{let{loading:c,sendMessage:l}=n.u(),[u,f]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(e.userMessage.content),y=()=>{navigator.clipboard.writeText(e.userMessage.content),m(!0),setTimeout(()=>m(!1),1500)},x=()=>{_.trim()&&(l(_.trim()),g(!1))},S=e.parsedAssistantMessage||``,T=e.speechMessage||``,D=e.thinkingEnded,{speechStatus:O,start:k,stop:A,isLoading:M}=r.d(T,{enableInterrupt:!0}),N=t=>{if(!e.assistantMessage)return;let n=`${e.userMessage.content}\n\n${e.assistantMessage.content}`;navigator.clipboard.writeText(n);let r={qwksearch:`https://qwksearch.com/?q=`,claude:`https://claude.ai/new?q=`,perplexity:`https://www.perplexity.ai/?q=`,gemini:`https://gemini.google.com/?q=`,chatgpt:`https://chat.openai.com/?q=`}[t];r&&window.open(`${r}${encodeURIComponent(n)}`,`_blank`)},P={overrides:{think:{component:E,props:{thinkingEnded:D}},citation:{component:w,props:{sources:e.sourceMessage?.sources||[]}},table:{component:({children:e,...t})=>(0,o.jsx)(`div`,{className:`not-prose -mx-2 my-4 max-w-full overflow-x-auto sm:mx-0`,children:(0,o.jsx)(`table`,{...t,className:`w-max min-w-full border-collapse text-sm`,children:e})})}}};return(0,o.jsxs)(`div`,{className:`space-y-3`,children:[(0,o.jsx)(j,{section:e,isExpanded:u,setIsExpanded:f,isEditing:h,setIsEditing:g,editText:_,setEditText:v,handleEditSubmit:x,copiedUserMsg:p,handleCopyUserMsg:y}),(0,o.jsx)(`div`,{className:t.o(`flex flex-col space-y-3 overflow-hidden transition-all duration-300 ease-in-out`,u?`max-h-[100000px] opacity-100`:`max-h-0 opacity-0`),children:(0,o.jsxs)(`div`,{ref:i,className:`flex flex-col space-y-6 w-full`,children:[e.searchingMessage&&e.searchingMessage.queries.length>0&&(0,o.jsx)(C,{queries:e.searchingMessage.queries,loading:c&&s}),e.sourceMessage&&e.sourceMessage.sources.length>0&&(0,o.jsx)(`div`,{className:`flex flex-col space-y-2`,children:(0,o.jsx)(b,{sources:e.sourceMessage.sources,query:e.userMessage.content})}),(0,o.jsx)(`div`,{className:`flex min-w-0 flex-col space-y-2`,children:e.assistantMessage&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d.default,{className:t.o(`prose prose-lg prose-h1:mb-3 prose-h2:mb-2 prose-h2:mt-6 prose-h2:font-[800] prose-h3:mt-4 prose-h3:mb-1.5 prose-h3:font-[600] dark:prose-invert prose-p:leading-loose prose-pre:p-0 font-[400]`,`min-w-0 max-w-none break-words text-foreground font-inter`),options:P,children:S}),c&&s?null:(0,o.jsx)(L,{section:e,speechStatus:O,isLoadingTTS:M,start:k,stop:A,handleOpenInLLM:N}),(0,o.jsx)(R,{section:e,isLast:s,loading:c,sendMessage:l})]})})]})})]})},B=[`default`,`circle`,`pinwheel`,`circle-filled`,`ellipsis`,`ring`,`bars`,`infinite`],V=`M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z`,H={transformBox:`view-box`,transformOrigin:`center`},U=[[12,2,12,6],[16.24,7.76,19.07,4.93],[18,12,22,12],[16.24,16.24,19.07,19.07],[12,18,12,22],[4.93,19.07,7.76,16.24],[2,12,6,12],[4.93,4.93,7.76,7.76]],W=e=>{switch(e){case`circle`:return(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:(0,o.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})});case`pinwheel`:return(0,o.jsxs)(`g`,{className:`animate-spin`,style:H,children:[(0,o.jsx)(`path`,{d:`M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0`}),(0,o.jsx)(`path`,{d:`M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6`}),(0,o.jsx)(`path`,{d:`M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6`}),(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`})]});case`circle-filled`:return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`0.2`}),(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:(0,o.jsx)(`path`,{d:`M21 12a9 9 0 0 0-9-9`})})]});case`ellipsis`:return(0,o.jsx)(`g`,{fill:`currentColor`,stroke:`none`,children:[4,12,20].map((e,t)=>(0,o.jsx)(`circle`,{cx:e,cy:`12`,r:`2.5`,children:(0,o.jsx)(`animate`,{attributeName:`cy`,values:`12;7.5;12`,keyTimes:`0;0.5;1`,dur:`1.2s`,begin:`${t*.16}s`,repeatCount:`indefinite`})},e))});case`ring`:return(0,o.jsx)(o.Fragment,{children:[0,-.8].map(e=>(0,o.jsxs)(`circle`,{cx:`12`,cy:`12`,r:`2`,children:[(0,o.jsx)(`animate`,{attributeName:`r`,values:`2;11`,dur:`1.6s`,begin:`${e}s`,repeatCount:`indefinite`}),(0,o.jsx)(`animate`,{attributeName:`opacity`,values:`1;0`,dur:`1.6s`,begin:`${e}s`,repeatCount:`indefinite`})]},e))});case`bars`:return(0,o.jsx)(`g`,{fill:`currentColor`,stroke:`none`,children:[2.5,10,17.5].map((e,t)=>(0,o.jsxs)(`rect`,{x:e,y:`8`,width:`4`,height:`8`,rx:`1.5`,children:[(0,o.jsx)(`animate`,{attributeName:`height`,values:`8;18;8`,keyTimes:`0;0.5;1`,dur:`1.1s`,begin:`${t*.18}s`,repeatCount:`indefinite`}),(0,o.jsx)(`animate`,{attributeName:`y`,values:`8;3;8`,keyTimes:`0;0.5;1`,dur:`1.1s`,begin:`${t*.18}s`,repeatCount:`indefinite`})]},e))});case`infinite`:return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`path`,{d:V,opacity:`0.2`}),(0,o.jsx)(`path`,{d:V,pathLength:`100`,strokeDasharray:`25 75`,children:(0,o.jsx)(`animate`,{attributeName:`stroke-dashoffset`,values:`100;0`,dur:`1.5s`,repeatCount:`indefinite`})})]});default:return(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:U.map(([e,t,n,r],i)=>(0,o.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,opacity:1-i*.1},`${e}-${t}`))})}},G=({variant:e=`default`,size:n=24,className:r,...i})=>(0,o.jsx)(`svg`,{"aria-hidden":`true`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:n,height:n,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t.o(`shrink-0`,r),...i,children:W(e)}),K=`quantumSphere`,q=`spinner:`,J=new Set([`loadingSpokes`,`loadingCircleNotch`,`loadingPinwheel`,`loadingCircleTrack`,`loadingDotsBounce`,`loadingPulseRing`,`loadingEqualizerBars`,`loadingInfiniteDash`]),Y=Object.fromEntries(Object.entries(m).filter(([e,t])=>typeof t==`function`&&e.startsWith(`loading`)&&!J.has(e))),X=[K,...B.map(e=>`${q}${e}`),...Object.keys(Y).sort()],Z;function Q(){let e=X.filter(e=>e!==Z),t=e.length>0?e:X;return Z=t[Math.floor(Math.random()*t.length)],Z}function $(e){if(!e.startsWith(`spinner:`))return;let t=e.slice(8);return B.find(e=>e===t)}function ee(e,t){let n=Y[e];return n?n({size:t,raw:!0}):``}var te=({size:e=140,className:n})=>{let[r,i]=(0,a.useState)(null);(0,a.useEffect)(()=>{i(Q())},[]);let s=r?$(r):void 0;return(0,o.jsx)(`div`,{role:`status`,"aria-label":`Loading`,className:t.o(`flex items-center justify-center w-full h-[200px]`,n),children:r===`quantumSphere`?(0,o.jsx)(u.default,{autoRandomize:!0}):s?(0,o.jsx)(G,{variant:s,size:e,className:`text-muted-foreground`}):r?(0,o.jsx)(`div`,{className:`flex items-center justify-center`,dangerouslySetInnerHTML:{__html:ee(r,e)}}):null})},ne=(0,a.lazy)(()=>Promise.resolve().then(()=>require("./ArticleExtractPanel-BnRqqEL_.cjs"))),re=()=>{let{sections:e,chatTurns:t,loading:s,messageAppeared:c,newChat:l,chatId:u}=n.u(),{isOpen:d,panelWidth:f}=n.a(),{isAuthenticated:p}=n.c(),[m,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{d&&h(!0)},[d]);let[g,_]=(0,a.useState)(!1),v=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(!1);(0,a.useEffect)(()=>{let e=()=>{_(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{t.length===1&&(document.title=`${t[0].content.substring(0,30)} - ${i.researchAgentUIConfig.appName}`),t[t.length-1]?.role===`user`&&(b.current=!0,y.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{b.current=!1},100))},[t]);let x=g&&d?{width:`calc(100% - ${f}px)`}:{};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:x,children:[(0,o.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${g&&!d?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,n)=>{let r=n===e.length-1;return(0,o.jsxs)(a.Fragment,{children:[(0,o.jsx)(z,{section:t,sectionIndex:n,dividerRef:r?v:void 0,isLast:r}),!r&&(0,o.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),s&&!c&&(0,o.jsx)(te,{}),(0,o.jsx)(`div`,{ref:y,className:`h-0`})]}),(0,o.jsx)(`div`,{className:`sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2`,children:(0,o.jsx)(r.q,{})})]}),(m||d)&&(0,o.jsx)(a.Suspense,{fallback:null,children:(0,o.jsx)(ne,{})})]})};exports.default=re;
16
+ )`},className:t.o(`pointer-events-none absolute inset-0 rounded-[inherit] opacity-100 transition-opacity`,l&&`opacity-100`,e>0&&`blur-[var(--blur)] `,u,p&&`!hidden`),children:(0,o.jsx)(`div`,{className:t.o(`glow`,`rounded-[inherit]`,`after:content-[""] after:rounded-[inherit] after:absolute after:inset-[calc(-1*var(--glowingeffect-border-width))]`,`after:[border:var(--glowingeffect-border-width)_solid_transparent]`,`after:[background:var(--gradient)] after:[background-attachment:fixed]`,`after:opacity-[var(--active)] after:transition-opacity after:duration-300`,`after:[mask-clip:padding-box,border-box]`,`after:[mask-composite:intersect]`,`after:[mask-image:linear-gradient(#0000,#0000),conic-gradient(from_calc((var(--start)-var(--spread))*1deg),#00000000_0deg,#fff,#00000000_calc(var(--spread)*2deg))]`)})})]})});h.displayName=`GlowingEffect`;function g(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}function _(e){return e.iframe_src&&g(e.iframe_src)?{type:`inline`,src:e.iframe_src}:{type:`external`,url:e.url||``}}function v(e){return{pageContent:e.snippet||e.content||``,metadata:{title:e.title||``,source:e.source||``,thumbnail:e.thumbnail||``,url:e.url||``,...e.img_src&&{img_src:e.img_src},...e.iframe_src&&{iframe_src:e.iframe_src}}}}var y=r.J.filter(e=>[`general`,`news`,`videos`,`images`,`science`,`files`].includes(e.code)),b=({sources:e,query:r})=>{let[i,s]=(0,a.useState)(`general`),[u,d]=(0,a.useState)(e),[p,m]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[x,S]=(0,a.useState)(1),[C,w]=(0,a.useState)(!0),[T,E]=(0,a.useState)(!1),[D,O]=(0,a.useState)(!1),[k,A]=(0,a.useState)(null),j=(0,a.useRef)(null),M=(0,a.useRef)(!1),N=(0,a.useRef)(!1),{openPanel:P,isOpen:F}=n.a();(0,a.useEffect)(()=>{let e=()=>{O(localStorage.getItem(`searchResultGlow`)===`true`)};return e(),window.addEventListener(`client-config-changed`,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(`client-config-changed`,e),window.removeEventListener(`storage`,e)}},[]);let[I,L]=(0,a.useState)({});(0,a.useEffect)(()=>{let e=()=>{E(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{d(e),s(`general`),S(1),w(!0),L({}),R(e)},[e]);let R=(0,a.useCallback)(async e=>{let t=e.filter(e=>e.metadata.url&&e.metadata.url!==`File`&&!e.metadata.iframe_src);for(let e of t)try{let{data:t}=await(0,l.getArticle)({query:{url:e.metadata.url}});t?.cached&&t?.article?.html&&L(t=>({...t,[e.metadata.url]:`loaded`}))}catch{}},[]);(0,a.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search).get(`extract`);e&&(P(decodeURIComponent(e),``),N.current=!1)}},[P]),(0,a.useEffect)(()=>{N.current=!1},[e]),(0,a.useEffect)(()=>{M.current&&!F&&(N.current=!0),M.current=F},[F]),(0,a.useEffect)(()=>{if(T&&u&&u.length>0&&!F&&!N.current){let e=u[0];e?.metadata?.url&&P(e.metadata.url,``)}},[u,T]);let z=async(e,t)=>{e.preventDefault(),N.current=!1,L(e=>({...e,[t]:`loading`})),P(t,``);try{await(0,l.getArticle)({query:{url:t}}),L(e=>({...e,[t]:`loaded`}))}catch{L(e=>({...e,[t]:`loaded`}))}},B=(0,a.useCallback)(async()=>{if(!r||g||!C)return;b(!0);let e=x+1,{data:t}=await(0,l.agentSearch)({query:{q:r,cat:i,page:e}}),n=t?.results??[];if(n.length===0){w(!1),b(!1);return}let a=n.map(e=>{if(e.url)try{let t=new URL(e.url);(t.pathname===`/`||t.pathname===``)&&console.warn(`[MessageSources] Search result URL is domain-only:`,e.url,`Title:`,e.title)}catch{console.error(`[MessageSources] Invalid URL in search result:`,e.url)}return v(e)});d(e=>[...e,...a]),S(e),b(!1)},[r,i,x,g,C]),V=async e=>{if(e!==i&&r){s(e),m(!0),S(1),w(!0);try{let{data:t}=await(0,l.agentSearch)({query:{q:r,cat:e,page:1}}),n=(t?.results??[]).map(e=>{if(e.url)try{let t=new URL(e.url);(t.pathname===`/`||t.pathname===``)&&console.warn(`[MessageSources] Category search result URL is domain-only:`,e.url,`Title:`,e.title)}catch{console.error(`[MessageSources] Invalid URL in category search result:`,e.url)}return v(e)});d(n)}catch(e){console.error(`Error searching:`,e)}finally{m(!1)}}};(0,a.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<100&&B()};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[B]);let H=(e,t)=>{let n=i===`images`,r=i===`videos`,a=e.metadata.img_src||e.metadata.thumbnail;if(n&&a)return(0,o.jsx)(`div`,{className:`relative rounded-lg group`,children:(0,o.jsxs)(`a`,{className:`relative block overflow-hidden rounded-lg cursor-pointer`,href:e.metadata.url,onClick:t=>z(t,e.metadata.url),children:[(0,o.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-auto object-cover rounded-lg hover:scale-105 transition-transform duration-200`,loading:`lazy`}),(0,o.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200`,children:[(0,o.jsx)(`p`,{className:`text-xs text-white line-clamp-2`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)}),(0,o.jsx)(`p`,{className:`text-[10px] text-white/70 truncate mt-0.5`,children:e.metadata.source})]})]})},t);if(r&&a){let n=_(e.metadata),r=(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-24 object-cover`}),(0,o.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,o.jsx)(`div`,{className:`w-10 h-10 bg-black/60 rounded-full flex items-center justify-center`,children:(0,o.jsx)(c.Video,{size:18,className:`text-white ml-0.5`})})})]}),i=(0,o.jsx)(`p`,{className:`text-xs line-clamp-2 p-2 text-muted-foreground`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)});return(0,o.jsxs)(`div`,{className:`relative rounded-xl`,children:[(0,o.jsx)(h,{spread:40,glow:!0,disabled:!D,proximity:64,inactiveZone:.01,borderWidth:2}),n.type===`inline`?(0,o.jsxs)(`button`,{type:`button`,className:`relative w-full text-left bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200`,onClick:()=>A({src:n.src,title:e.metadata.title}),children:[r,i]}):(0,o.jsxs)(`a`,{className:`relative bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200`,href:n.url,target:`_blank`,rel:`noopener noreferrer`,children:[r,i]})]},t)}let s=I[e.metadata.url];return(0,o.jsxs)(`div`,{className:`relative rounded-xl group h-full`,children:[(0,o.jsx)(h,{spread:40,glow:!0,disabled:!D,proximity:64,inactiveZone:.01,borderWidth:2}),(0,o.jsxs)(`div`,{className:`relative bg-card text-card-foreground border border-border rounded-xl p-2.5 flex flex-col font-medium cursor-pointer shadow-sm hover:shadow-md transition-all duration-200 h-full`,onClick:t=>z(t,e.metadata.url),children:[s&&(0,o.jsx)(`div`,{className:`absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]`,children:s===`loading`?(0,o.jsx)(c.Loader2,{size:14,className:`text-primary animate-spin`}):(0,o.jsx)(c.FileText,{size:14,className:`text-green-500`})}),(0,o.jsx)(`a`,{href:e.metadata.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`absolute top-1.5 right-1.5 p-1 rounded-md bg-secondary/50 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-secondary z-10`,title:`Open in new tab`,children:(0,o.jsx)(c.ExternalLink,{size:12,className:`text-muted-foreground`})}),(0,o.jsxs)(`p`,{className:`text-xs line-clamp-4 text-muted-foreground`,children:[(0,o.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle`,children:[e.metadata.url===`File`?(0,o.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0`,children:(0,o.jsx)(c.File,{size:10,className:`text-muted-foreground`})}):(0,o.jsx)(`img`,{src:`https://s2.googleusercontent.com/s2/favicons?domain_url=${e.metadata.url}`,width:20,height:20,alt:`favicon`,className:`inline rounded h-5 w-5 flex-shrink-0`}),e.metadata.source]}),` `,(0,o.jsx)(`span`,{className:`align-middle`,children:(0,f.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]})]},t)};return(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(`div`,{className:`flex items-center gap-1 mb-3 overflow-x-auto pb-1`,children:y.map(e=>(0,o.jsxs)(`button`,{onClick:()=>V(e.code),disabled:p,className:t.o(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap`,i===e.code?`bg-primary text-primary-foreground`:`bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground`),children:[(0,o.jsx)(e.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:e.name})]},e.code))}),(0,o.jsx)(`div`,{ref:j,className:t.o(`overflow-y-auto pb-2 pr-1`,i===`images`?`max-h-[400px] lg:max-h-[500px]`:`max-h-[180px] lg:max-h-[280px]`),children:p?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(c.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`})}):u.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:t.o(i===`images`?`columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid`:t.o(`grid gap-3 auto-rows-fr`,F&&T?`grid-cols-2`:`grid-cols-3`)),children:u.map((e,t)=>H(e,t))}),g&&(0,o.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,o.jsx)(c.Loader2,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!C&&u.length>0&&(0,o.jsx)(`div`,{className:`flex items-center justify-center py-4 text-muted-foreground text-xs`,children:`No more results`})]}):(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`No results found`})}),(0,o.jsx)(t.t,{open:k!==null,onOpenChange:e=>!e&&A(null),children:(0,o.jsxs)(t.n,{className:`max-w-3xl p-0 overflow-hidden gap-0`,children:[(0,o.jsx)(t.i,{className:`sr-only`,children:k?.title||`Video player`}),k&&(0,o.jsx)(`iframe`,{src:k.src,title:k.title||`Video player`,className:`w-full aspect-video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0})]})})]})},x={extract:`Extract`,arxiv:`ArXiv`,"google scholar":`Scholar`,pubmed:`PubMed`,wolframalpha:`Wolfram`,youtube:`YouTube`,Web:`Web`};function S(e){return e?x[e]??e:`Web`}function C({queries:e,loading:n}){let r=e.filter(e=>e.status===`done`).length,i=e.length,a=n&&e.some(e=>e.status===`running`);return n?(0,o.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/50`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[a?(0,o.jsx)(c.Loader2,{className:`w-3.5 h-3.5 animate-spin`}):(0,o.jsx)(c.Search,{className:`w-3.5 h-3.5`}),(0,o.jsx)(`span`,{className:`font-medium text-foreground`,children:a?`Running analysis…`:`Analysis complete`})]}),i>0&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[r,`/`,i,` searches`]})]}),e.length>0&&(0,o.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map((e,n)=>(0,o.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2`,children:[e.status===`running`?(0,o.jsx)(c.Loader2,{className:`w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0`}):(0,o.jsx)(c.Search,{className:t.o(`w-3.5 h-3.5 flex-shrink-0`,e.status===`done`?`text-muted-foreground`:`text-muted-foreground/40`)}),(0,o.jsxs)(`div`,{className:`flex items-baseline gap-1.5 min-w-0 flex-1`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap flex-shrink-0`,children:[S(e.category),` ·`]}),(0,o.jsx)(`span`,{className:`text-foreground/80 truncate`,children:e.query})]})]},n))})]}):null}var w=({href:e,children:t,sources:r})=>{let{openPanel:i}=n.a(),s=(0,a.useMemo)(()=>!r||!e?null:r.find(t=>t.metadata?.url===e)??null,[r,e]),c=(0,a.useMemo)(()=>{try{return new URL(e).hostname.replace(`www.`,``)}catch{return s?.metadata?.source||``}},[e,s]),l=s?.metadata?.title||``,u=`https://s2.googleusercontent.com/s2/favicons?domain_url=${e}`;return(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`a`,{href:e,onClick:t=>{t.preventDefault(),i(e,``)},className:`bg-light-secondary dark:bg-dark-secondary px-1 rounded ml-1 no-underline text-xs text-black/70 dark:text-white/70 relative cursor-pointer hover:bg-black/10 dark:hover:bg-white/20 transition-colors`,children:t})}),(0,o.jsx)(n.n,{side:`top`,className:`max-w-72 p-2.5`,children:(0,o.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,o.jsx)(`img`,{src:u,alt:``,width:16,height:16,className:`rounded flex-shrink-0 mt-0.5`}),(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium leading-snug line-clamp-2`,children:l||c}),l&&(0,o.jsx)(`p`,{className:`text-[10px] opacity-70 truncate mt-0.5`,children:c})]})]})})]})},T=({content:e,thinkingEnded:t})=>{let[n,r]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{r(!t)},[t]),(0,o.jsxs)(`div`,{className:`my-4 bg-secondary/50 rounded-xl border border-border overflow-hidden`,children:[(0,o.jsxs)(`button`,{onClick:()=>r(!n),className:`w-full flex items-center justify-between px-4 py-1 text-foreground/90 hover:bg-secondary transition duration-200`,children:[(0,o.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,o.jsx)(c.BrainCircuit,{size:20,className:`text-accent-foreground`}),(0,o.jsx)(`p`,{className:`font-medium text-sm`,children:`Thinking Process`})]}),n?(0,o.jsx)(c.ChevronUp,{size:18,className:`text-muted-foreground`}):(0,o.jsx)(c.ChevronDown,{size:18,className:`text-muted-foreground`})]}),n&&(0,o.jsx)(`div`,{className:`px-4 py-3 text-foreground/80 text-sm border-t border-border bg-muted/50 whitespace-pre-wrap`,children:e})]})},E=({children:e,thinkingEnded:t})=>(0,o.jsx)(T,{content:e,thinkingEnded:t}),D=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`avif`],O=e=>{let t=(e||``).toLowerCase();return D.includes(t)?(0,o.jsx)(c.Image,{size:15}):t===`url`?(0,o.jsx)(c.Link2,{size:15}):(0,o.jsx)(c.FileText,{size:15})},k=({file:e})=>{let{deleteAttachedFile:r}=n.u(),[i,s]=(0,a.useState)(!1),[l,u]=(0,a.useState)(!1);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-2 rounded-lg border border-border bg-secondary/40 py-1.5 pl-2.5 pr-1.5 text-sm`,children:[(0,o.jsx)(`span`,{className:`text-muted-foreground`,children:O(e.fileExtension)}),(0,o.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,title:e.fileName,children:e.fileName}),e.fileExtension&&e.fileExtension!==`url`&&(0,o.jsx)(`span`,{className:`hidden shrink-0 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:inline`,children:e.fileExtension}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Delete ${e.fileName}`,onClick:()=>s(!0),className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-red-500/10 hover:text-red-500`,children:(0,o.jsx)(c.Trash2,{size:14})})]}),(0,o.jsx)(t.t,{open:i,onOpenChange:e=>{l||s(e)},children:(0,o.jsxs)(t.n,{className:`w-full max-w-md rounded-2xl`,children:[(0,o.jsx)(t.i,{className:`text-lg font-medium leading-6`,children:`Delete file`}),(0,o.jsxs)(t.r,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,o.jsx)(`span`,{className:`font-medium text-foreground`,children:e.fileName}),`? This removes it from the conversation and permanently deletes the upload.`]}),(0,o.jsxs)(`div`,{className:`mt-6 flex flex-row items-center justify-end gap-4`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>!l&&s(!1),className:`text-sm text-muted-foreground transition-colors hover:text-foreground`,children:`Cancel`}),(0,o.jsxs)(`button`,{type:`button`,onClick:async()=>{u(!0);try{await r(e.fileId),s(!1)}finally{u(!1)}},disabled:l,className:`inline-flex items-center gap-1.5 text-sm text-red-500 transition-colors hover:text-red-600 disabled:opacity-60`,children:[l&&(0,o.jsx)(c.Loader2,{size:14,className:`animate-spin`}),`Delete`]})]})]})})]})},A=({files:e})=>!e||e.length===0?null:(0,o.jsx)(`div`,{className:`ml-10 mt-2 flex flex-wrap gap-2`,children:e.map(e=>(0,o.jsx)(k,{file:e},e.fileId))}),j=({section:e,isExpanded:r,setIsExpanded:i,isEditing:s,setIsEditing:l,editText:u,setEditText:d,handleEditSubmit:f,copiedUserMsg:p,handleCopyUserMsg:m})=>{let h=(0,a.useRef)(null);return(0,o.jsxs)(`div`,{className:`w-full pt-8 break-words`,children:[(0,o.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-3 group text-left w-full`,children:[(0,o.jsx)(`div`,{className:`flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200`,children:r?(0,o.jsx)(c.ChevronDown,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`}):(0,o.jsx)(c.ChevronRight,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`})}),(0,o.jsx)(`h2`,{className:`text-foreground font-medium text-lg lg:text-3xl lg:w-9/12 group-hover:text-foreground/80 transition-colors line-clamp-3 lg:line-clamp-none`,children:e.userMessage.content})]}),(0,o.jsxs)(`div`,{className:`flex items-center gap-0.5 mt-1 ml-10`,children:[(()=>{let n=t.s(e.userMessage.createdAt);return n?(0,o.jsx)(`time`,{dateTime:new Date(e.userMessage.createdAt).toISOString(),className:`mr-1.5 text-xs text-muted-foreground tabular-nums select-none`,children:n}):null})(),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:m,className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,o.jsx)(`span`,{className:t.o(`flex items-center transition-all duration-300`,p?`scale-110`:`scale-100`),children:p?(0,o.jsx)(c.Check,{size:14,className:`text-green-500`}):(0,o.jsx)(c.ClipboardList,{size:14})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:p?`Copied!`:`Copy prompt`})]}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{d(e.userMessage.content),l(!0),setTimeout(()=>h.current?.focus(),50)},className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,o.jsx)(c.Pencil,{size:14})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Edit & resubmit`})]})]}),(0,o.jsx)(A,{files:e.userMessage.files}),s&&(0,o.jsxs)(`div`,{className:`mt-3 ml-10 flex flex-col gap-2`,children:[(0,o.jsx)(`textarea`,{ref:h,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f()),e.key===`Escape`&&l(!1)},rows:3,className:`w-full rounded-xl border border-border bg-background p-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 transition-colors`}),(0,o.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,o.jsx)(`button`,{onClick:()=>l(!1),className:`px-3 py-1.5 text-sm text-muted-foreground rounded-lg hover:bg-secondary transition-colors duration-200`,children:`Cancel`}),(0,o.jsx)(`button`,{onClick:f,disabled:!u.trim(),className:`px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:`Resubmit`})]})]})]})},M=({section:e,initialMessage:t})=>{let[r,i]=(0,a.useState)(!1);return(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{let n=`${t}${e?.sourceMessage?.sources&&e.sourceMessage.sources.length>0&&`\n\nCitations:\n${e.sourceMessage.sources?.map((e,t)=>`[${t+1}] ${e.metadata.url}`).join(`
17
+ `)}`}`;navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1e3)},className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:r?(0,o.jsx)(c.Check,{size:18}):(0,o.jsx)(c.ClipboardList,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:r?`Copied!`:`Copy`})]})};function N({...e}){return(0,o.jsx)(p.Root,{"data-slot":`popover`,...e})}function P({...e}){return(0,o.jsx)(p.Trigger,{"data-slot":`popover-trigger`,...e})}function F({className:e,align:n=`center`,sideOffset:r=4,container:i,...a}){return(0,o.jsx)(p.Portal,{container:i,children:(0,o.jsx)(p.Content,{"data-slot":`popover-content`,align:n,sideOffset:r,className:t.o(`bg-popover text-popover-foreground 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-2xl border p-4 shadow-md outline-hidden`,e),...a})})}var I=({messageId:e})=>{let{rewrite:i,chatModelProvider:s,setChatModelProvider:u}=n.u(),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(!0),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(!1);(0,a.useEffect)(()=>{_&&(async()=>{try{m(!0);let{data:e}=await(0,l.listProviders)();f(e?.providers??[])}catch(e){console.error(`Error loading providers:`,e)}finally{m(!1)}})()},[_]);let y=(0,a.useMemo)(()=>{if(!s?.providerId)return d;let e=d.findIndex(e=>e.id===s.providerId);return e===-1?d:[d[e],...d.filter((t,n)=>n!==e)]},[d,s]).map(e=>({...e,chatModels:(e.chatModels??[]).filter(t=>t.name.toLowerCase().includes(h.toLowerCase())||e.name.toLowerCase().includes(h.toLowerCase()))})).filter(e=>e.chatModels.length>0),b=(0,a.useMemo)(()=>{if(!s.key)return`Rewrite`;for(let e of d){let t=e.chatModels.find(e=>e.key===s.key);if(t)return t.name}return s.key},[d,s.key]),x=(t,n)=>{u({providerId:t,key:n}),localStorage.setItem(`chatModelProviderId`,t),localStorage.setItem(`chatModelKey`,n),v(!1),i(e)};return(0,o.jsxs)(N,{open:_,onOpenChange:v,children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(P,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.ArrowLeftRight,{size:18})})})}),(0,o.jsxs)(n.n,{side:`bottom`,children:[`Rewrite with `,b]})]}),(0,o.jsx)(F,{className:`w-[280px] p-0`,align:`start`,side:`top`,sideOffset:8,children:(0,o.jsxs)(`div`,{className:`bg-white dark:bg-[#212121] max-h-[400px] border rounded-2xl border-[#DDDDDD] dark:border-[#30302E] w-full flex flex-col shadow-2xl overflow-hidden`,children:[(0,o.jsx)(`div`,{className:`p-3 border-b border-[#EEEEEE] dark:border-[#30302E]`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(c.Search,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-text-400 dark:text-[#999999]`}),(0,o.jsx)(`input`,{type:`text`,placeholder:`Search models...`,value:h,onChange:e=>g(e.target.value),className:`w-full pl-9 pr-3 py-2 text-[13px] bg-bg-100 dark:bg-[#30302E] border border-bg-300 dark:border-[#404040] rounded-lg text-text-100 dark:text-[#ECECEC] placeholder:text-text-400 dark:placeholder:text-[#999999] focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-500/30 transition-all`})]})}),(0,o.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:p?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,o.jsx)(r.tt.Loader2,{className:`animate-spin text-text-400 dark:text-[#999999]`,size:20})}):y.length===0?(0,o.jsx)(`div`,{className:`text-center py-12 px-4 text-text-400 dark:text-[#999999] text-sm`,children:h?`No models found`:`No chat models configured`}):(0,o.jsx)(`div`,{className:`flex flex-col`,children:y.map((e,n)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`px-4 py-2 sticky top-0 bg-white dark:bg-[#212121] border-b border-[#EEEEEE]/50 dark:border-[#30302E]/50`,children:(0,o.jsx)(`p`,{className:`text-[11px] text-text-400 dark:text-[#999999] uppercase tracking-wider font-medium`,children:e.name})}),(0,o.jsx)(`div`,{className:`flex flex-col px-1.5 py-1.5 space-y-0.5`,children:e.chatModels.map(n=>(0,o.jsxs)(`button`,{onClick:()=>x(e.id,n.key),type:`button`,className:t.o(`px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group`,s?.providerId===e.id&&s?.key===n.key?`bg-sky-50 dark:bg-sky-500/10`:`hover:bg-bg-100 dark:hover:bg-[#30302E]`),children:[(0,o.jsxs)(`div`,{className:`flex items-center space-x-2.5 min-w-0 flex-1`,children:[(0,o.jsx)(c.Cpu,{size:14,className:t.o(`shrink-0`,s?.providerId===e.id&&s?.key===n.key?`text-sky-500`:`text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]`)}),(0,o.jsx)(`p`,{className:t.o(`text-[13px] truncate`,s?.providerId===e.id&&s?.key===n.key?`text-sky-600 dark:text-sky-400 font-medium`:`text-text-200 dark:text-[#ECECEC] group-hover:text-text-100 dark:group-hover:text-white`),children:n.name})]}),s?.providerId===e.id&&s?.key===n.key&&(0,o.jsx)(r.tt.Check,{className:`w-4 h-4 text-sky-500 shrink-0`})]},n.key))}),n<y.length-1&&(0,o.jsx)(`div`,{className:`h-px bg-[#EEEEEE] dark:bg-[#30302E] mx-2`})]},e.id))})})]})})]})},L=({section:e,speechStatus:t,isLoadingTTS:i=!1,start:a,stop:s,handleOpenInLLM:l})=>e.assistantMessage?(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2`,children:(0,o.jsxs)(`div`,{className:`flex flex-row items-center space-x-1`,children:[(0,o.jsx)(I,{messageId:e.assistantMessage.messageId}),(0,o.jsx)(M,{initialMessage:e.assistantMessage.content,section:e}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:()=>{t===`started`?s():a()},disabled:i,className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:i?(0,o.jsx)(c.Loader2,{size:18,className:`animate-spin`}):t===`started`?(0,o.jsx)(c.StopCircle,{size:18}):(0,o.jsx)(c.Volume2,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:i?`Loading TTS...`:t===`started`?`Stop`:`Read aloud`})]}),(0,o.jsxs)(r.Y,{children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(r.Q,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.Download,{size:18})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Export`})]}),(0,o.jsxs)(r.X,{align:`end`,side:`top`,children:[(0,o.jsxs)(r.Z,{onClick:()=>r.G(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileText,{size:16}),`Markdown`]}),(0,o.jsxs)(r.Z,{onClick:()=>r.K(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileType,{size:16}),`PDF`]}),(0,o.jsxs)(r.Z,{onClick:()=>r.W(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileDown,{size:16}),`DOCX`]}),(0,o.jsxs)(r.Z,{onClick:()=>r.q(e.userMessage.content,e.assistantMessage.content),children:[(0,o.jsx)(c.FileSpreadsheet,{size:16}),`Google Docs`]})]})]}),(0,o.jsxs)(r.Y,{children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(r.Q,{asChild:!0,children:(0,o.jsx)(`button`,{className:`p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground`,children:(0,o.jsx)(c.ExternalLink,{size:18})})})}),(0,o.jsx)(n.n,{side:`bottom`,children:`Open in LLM`})]}),(0,o.jsxs)(r.X,{align:`end`,side:`top`,children:[(0,o.jsx)(r.Z,{onClick:()=>l(`qwksearch`),children:`QwkSearch`}),(0,o.jsx)(r.Z,{onClick:()=>l(`claude`),children:`Claude`}),(0,o.jsx)(r.Z,{onClick:()=>l(`perplexity`),children:`Perplexity`}),(0,o.jsx)(r.Z,{onClick:()=>l(`gemini`),children:`Google Gemini`}),(0,o.jsx)(r.Z,{onClick:()=>l(`chatgpt`),children:`ChatGPT`})]})]})]})}):null,R=({section:e,isLast:t,loading:n,sendMessage:i})=>{let s=(0,a.useRef)([]);return(0,a.useEffect)(()=>{e.suggestions&&e.suggestions.length>0&&(s.current=e.suggestions.slice(0,5))},[e.suggestions]),(0,a.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)return;let n=e.key,r=parseInt(n);r>=1&&r<=5&&s.current.length>=r&&(e.preventDefault(),i(s.current[r-1]))};if(t&&s.current.length>0)return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]),!e.suggestions||e.suggestions.length===0||!e.assistantMessage?null:(0,o.jsx)(`div`,{className:`mt-8 pt-6 border-t border-border/50`,children:(0,o.jsx)(`div`,{className:`space-y-2`,children:e.suggestions?.slice(0,5).map((e,t)=>(0,o.jsx)(`button`,{onClick:()=>i(e),className:`group w-full px-4 py-4 text-left transition-all duration-200 cursor-pointer rounded-lg border border-border/50 hover:border-primary/30 hover:bg-accent/50 hover:shadow-sm`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(r.V,{variant:`secondary`,className:`flex-shrink-0 h-6 w-6 p-0 flex items-center justify-center rounded-full text-sm font-semibold`,children:t+1}),(0,o.jsx)(`p`,{className:`flex-1 text-base font-medium text-muted-foreground group-hover:text-primary transition-colors duration-200 leading-relaxed`,children:e}),(0,o.jsx)(c.Plus,{size:18,className:`text-muted-foreground/60 group-hover:text-primary transition-colors duration-200 flex-shrink-0`})]})},t))})})},z=({section:e,dividerRef:i,isLast:s})=>{let{loading:c,sendMessage:l}=n.u(),[u,f]=(0,a.useState)(!0),[p,m]=(0,a.useState)(!1),[h,g]=(0,a.useState)(!1),[_,v]=(0,a.useState)(e.userMessage.content),y=()=>{navigator.clipboard.writeText(e.userMessage.content),m(!0),setTimeout(()=>m(!1),1500)},x=()=>{_.trim()&&(l(_.trim()),g(!1))},S=e.parsedAssistantMessage||``,T=e.speechMessage||``,D=e.thinkingEnded,{speechStatus:O,start:k,stop:A,isLoading:M}=r.d(T,{enableInterrupt:!0}),N=t=>{if(!e.assistantMessage)return;let n=`${e.userMessage.content}\n\n${e.assistantMessage.content}`;navigator.clipboard.writeText(n);let r={qwksearch:`https://qwksearch.com/?q=`,claude:`https://claude.ai/new?q=`,perplexity:`https://www.perplexity.ai/?q=`,gemini:`https://gemini.google.com/?q=`,chatgpt:`https://chat.openai.com/?q=`}[t];r&&window.open(`${r}${encodeURIComponent(n)}`,`_blank`)},P={overrides:{think:{component:E,props:{thinkingEnded:D}},citation:{component:w,props:{sources:e.sourceMessage?.sources||[]}},table:{component:({children:e,...t})=>(0,o.jsx)(`div`,{className:`not-prose -mx-2 my-4 max-w-full overflow-x-auto sm:mx-0`,children:(0,o.jsx)(`table`,{...t,className:`w-max min-w-full border-collapse text-sm`,children:e})})}}};return(0,o.jsxs)(`div`,{className:`space-y-3`,children:[(0,o.jsx)(j,{section:e,isExpanded:u,setIsExpanded:f,isEditing:h,setIsEditing:g,editText:_,setEditText:v,handleEditSubmit:x,copiedUserMsg:p,handleCopyUserMsg:y}),(0,o.jsx)(`div`,{className:t.o(`flex flex-col space-y-3 overflow-hidden transition-all duration-300 ease-in-out`,u?`max-h-[100000px] opacity-100`:`max-h-0 opacity-0`),children:(0,o.jsxs)(`div`,{ref:i,className:`flex flex-col space-y-6 w-full`,children:[e.searchingMessage&&e.searchingMessage.queries.length>0&&(0,o.jsx)(C,{queries:e.searchingMessage.queries,loading:c&&s}),e.sourceMessage&&e.sourceMessage.sources.length>0&&(0,o.jsx)(`div`,{className:`flex flex-col space-y-2`,children:(0,o.jsx)(b,{sources:e.sourceMessage.sources,query:e.userMessage.content})}),(0,o.jsx)(`div`,{className:`flex min-w-0 flex-col space-y-2`,children:e.assistantMessage&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d.default,{className:t.o(`prose prose-lg prose-h1:mb-3 prose-h2:mb-2 prose-h2:mt-6 prose-h2:font-[800] prose-h3:mt-4 prose-h3:mb-1.5 prose-h3:font-[600] dark:prose-invert prose-p:leading-loose prose-pre:p-0 font-[400]`,`min-w-0 max-w-none break-words text-foreground font-inter`),options:P,children:S}),c&&s?null:(0,o.jsx)(L,{section:e,speechStatus:O,isLoadingTTS:M,start:k,stop:A,handleOpenInLLM:N}),(0,o.jsx)(R,{section:e,isLast:s,loading:c,sendMessage:l})]})})]})})]})},B=[`default`,`circle`,`pinwheel`,`circle-filled`,`ellipsis`,`ring`,`bars`,`infinite`],V=`M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z`,H={transformBox:`view-box`,transformOrigin:`center`},U=[[12,2,12,6],[16.24,7.76,19.07,4.93],[18,12,22,12],[16.24,16.24,19.07,19.07],[12,18,12,22],[4.93,19.07,7.76,16.24],[2,12,6,12],[4.93,4.93,7.76,7.76]],W=e=>{switch(e){case`circle`:return(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:(0,o.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})});case`pinwheel`:return(0,o.jsxs)(`g`,{className:`animate-spin`,style:H,children:[(0,o.jsx)(`path`,{d:`M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0`}),(0,o.jsx)(`path`,{d:`M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6`}),(0,o.jsx)(`path`,{d:`M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6`}),(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`})]});case`circle-filled`:return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`0.2`}),(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:(0,o.jsx)(`path`,{d:`M21 12a9 9 0 0 0-9-9`})})]});case`ellipsis`:return(0,o.jsx)(`g`,{fill:`currentColor`,stroke:`none`,children:[4,12,20].map((e,t)=>(0,o.jsx)(`circle`,{cx:e,cy:`12`,r:`2.5`,children:(0,o.jsx)(`animate`,{attributeName:`cy`,values:`12;7.5;12`,keyTimes:`0;0.5;1`,dur:`1.2s`,begin:`${t*.16}s`,repeatCount:`indefinite`})},e))});case`ring`:return(0,o.jsx)(o.Fragment,{children:[0,-.8].map(e=>(0,o.jsxs)(`circle`,{cx:`12`,cy:`12`,r:`2`,children:[(0,o.jsx)(`animate`,{attributeName:`r`,values:`2;11`,dur:`1.6s`,begin:`${e}s`,repeatCount:`indefinite`}),(0,o.jsx)(`animate`,{attributeName:`opacity`,values:`1;0`,dur:`1.6s`,begin:`${e}s`,repeatCount:`indefinite`})]},e))});case`bars`:return(0,o.jsx)(`g`,{fill:`currentColor`,stroke:`none`,children:[2.5,10,17.5].map((e,t)=>(0,o.jsxs)(`rect`,{x:e,y:`8`,width:`4`,height:`8`,rx:`1.5`,children:[(0,o.jsx)(`animate`,{attributeName:`height`,values:`8;18;8`,keyTimes:`0;0.5;1`,dur:`1.1s`,begin:`${t*.18}s`,repeatCount:`indefinite`}),(0,o.jsx)(`animate`,{attributeName:`y`,values:`8;3;8`,keyTimes:`0;0.5;1`,dur:`1.1s`,begin:`${t*.18}s`,repeatCount:`indefinite`})]},e))});case`infinite`:return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`path`,{d:V,opacity:`0.2`}),(0,o.jsx)(`path`,{d:V,pathLength:`100`,strokeDasharray:`25 75`,children:(0,o.jsx)(`animate`,{attributeName:`stroke-dashoffset`,values:`100;0`,dur:`1.5s`,repeatCount:`indefinite`})})]});default:return(0,o.jsx)(`g`,{className:`animate-spin`,style:H,children:U.map(([e,t,n,r],i)=>(0,o.jsx)(`line`,{x1:e,y1:t,x2:n,y2:r,opacity:1-i*.1},`${e}-${t}`))})}},G=({variant:e=`default`,size:n=24,className:r,...i})=>(0,o.jsx)(`svg`,{"aria-hidden":`true`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:n,height:n,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t.o(`shrink-0`,r),...i,children:W(e)}),K=`quantumSphere`,q=`spinner:`,J=new Set([`loadingSpokes`,`loadingCircleNotch`,`loadingPinwheel`,`loadingCircleTrack`,`loadingDotsBounce`,`loadingPulseRing`,`loadingEqualizerBars`,`loadingInfiniteDash`]),Y=Object.fromEntries(Object.entries(m).filter(([e,t])=>typeof t==`function`&&e.startsWith(`loading`)&&!J.has(e))),X=[K,...B.map(e=>`${q}${e}`),...Object.keys(Y).sort()],Z;function Q(){let e=X.filter(e=>e!==Z),t=e.length>0?e:X;return Z=t[Math.floor(Math.random()*t.length)],Z}function $(e){if(!e.startsWith(`spinner:`))return;let t=e.slice(8);return B.find(e=>e===t)}function ee(e,t){let n=Y[e];return n?n({size:t,raw:!0}):``}var te=({size:e=140,className:n})=>{let[r,i]=(0,a.useState)(null);(0,a.useEffect)(()=>{i(Q())},[]);let s=r?$(r):void 0;return(0,o.jsx)(`div`,{role:`status`,"aria-label":`Loading`,className:t.o(`flex items-center justify-center w-full h-[200px]`,n),children:r===`quantumSphere`?(0,o.jsx)(u.default,{autoRandomize:!0}):s?(0,o.jsx)(G,{variant:s,size:e,className:`text-muted-foreground`}):r?(0,o.jsx)(`div`,{className:`flex items-center justify-center`,dangerouslySetInnerHTML:{__html:ee(r,e)}}):null})},ne=(0,a.lazy)(()=>Promise.resolve().then(()=>require("./ArticleExtractPanel-YlXZ8P18.cjs"))),re=()=>{let{sections:e,chatTurns:t,loading:s,messageAppeared:c,newChat:l,chatId:u}=n.u(),{isOpen:d,panelWidth:f}=n.a(),{isAuthenticated:p}=n.c(),[m,h]=(0,a.useState)(!1);(0,a.useEffect)(()=>{d&&h(!0)},[d]);let[g,_]=(0,a.useState)(!1),v=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(!1);(0,a.useEffect)(()=>{let e=()=>{_(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{t.length===1&&(document.title=`${t[0].content.substring(0,30)} - ${i.researchAgentUIConfig.appName}`),t[t.length-1]?.role===`user`&&(b.current=!0,y.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{b.current=!1},100))},[t]);let x=g&&d?{width:`calc(100% - ${f}px)`}:{};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:x,children:[(0,o.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${g&&!d?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,n)=>{let r=n===e.length-1;return(0,o.jsxs)(a.Fragment,{children:[(0,o.jsx)(z,{section:t,sectionIndex:n,dividerRef:r?v:void 0,isLast:r}),!r&&(0,o.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),s&&!c&&(0,o.jsx)(te,{}),(0,o.jsx)(`div`,{ref:y,className:`h-0`})]}),(0,o.jsx)(`div`,{className:`sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2`,children:(0,o.jsx)(r.U,{})})]}),(m||d)&&(0,o.jsx)(a.Suspense,{fallback:null,children:(0,o.jsx)(ne,{})})]})};exports.default=re;
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Article } from '../../types/research';
3
- import type { ArticleOutlineItem } from './articleOutline';
4
3
  interface ArticleContentProps {
5
4
  article: Article;
6
5
  isHighlightMode: boolean;
7
6
  fontScale?: number;
8
- onOutlineChange?: (items: ArticleOutlineItem[]) => void;
9
7
  }
10
8
  declare const ArticleContent: React.FC<ArticleContentProps>;
11
9
  export default ArticleContent;
@@ -1,12 +1,9 @@
1
1
  import React from 'react';
2
- import { type ArticleOutlineItem } from './articleOutline';
3
2
  interface LexicalArticleViewerProps {
4
3
  html: string;
5
4
  isHighlightMode?: boolean;
6
5
  /** Reading zoom multiplier applied to the article font size (1 = 100%). */
7
6
  fontScale?: number;
8
- /** Called with the article's H1–H3 headings each time the rendered HTML changes. */
9
- onOutlineChange?: (items: ArticleOutlineItem[]) => void;
10
7
  }
11
8
  /**
12
9
  * Renders extracted article HTML as sanitized, styled prose.
@@ -8,9 +8,6 @@ export { default as ArticlePromptInput } from "./ArticlePromptInput";
8
8
  export { default as ArticleFollowupQuestions } from "./ArticleFollowupQuestions";
9
9
  export { default as ArticleAIResponse } from "./ArticleAIResponse";
10
10
  export { default as ArticleContent } from "./ArticleContent";
11
- export { default as ArticleOutline } from "./ArticleOutline";
12
- export { default as ArticleSidebarTabs, articleTabIds, type ArticleSidebarTab, } from "./ArticleSidebarTabs";
13
- export { extractOutline, type ArticleOutlineItem } from "./articleOutline";
14
11
  export { default as LexicalArticleViewer } from "./LexicalArticleViewer";
15
12
  export { UnifiedMarkdown, type UnifiedMarkdownProps } from "./unified-markdown";
16
13
  export * from "../../types/research";
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs"),t=require("./src-DgR_99cQ.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./dialog-7GDz0sWx.cjs");exports.ARTICLE_TOOLBAR_SHORTCUTS=t.j,exports.ArticleAIResponse=t.O,exports.ArticleActionButtons=t.M,exports.ArticleContent=t.T,exports.ArticleFollowupQuestions=t.k,exports.ArticleOutline=t.w,exports.ArticlePanelHeader=t.P,exports.ArticlePromptInput=t.A,exports.ArticleReaderMount=t.H,exports.ArticleSidebarTabs=t.S,exports.CategoryDock=t.c,exports.ChatInputBox=t.q,exports.ChatProvider=t.rt,exports.ChatWindow=t.V,exports.CookieConsent=t.s,exports.ExtractPanelProvider=n.i,exports.HistoryDialogs=t.W,exports.HistoryDropdown=t.U,exports.KokoroVoiceSelector=t.u,exports.LexicalArticleViewer=t.E,exports.MainViewProvider=t.y,exports.QWKSEARCH_DEFAULT_ORIGIN=t.F,exports.QwkSearchApp=t.n,exports.QwkSearchProviders=t.r,exports.SPOTLIGHT_LINKS=t.v,exports.SPOTLIGHT_PREFIXES=t.h,exports.SessionProvider=n.s,exports.SpotlightPalette=t.p,exports.UnifiedMarkdown=t.x,exports.VoiceSettingsPanel=t.l,exports.articleTabIds=t.C,exports.buildConnectStartUrl=t.I,exports.cn=r.o,exports.configureResearchAgentUI=e.configureResearchAgentUI,exports.createQwkSearchConnectAuthClient=t.L,exports.extractOutline=t.D,exports.formatMessageTime=r.s,exports.formatTimeDifference=r.c,exports.formatToolbarShortcut=t.N,exports.getQwkSearchApiKey=t.R,exports.isChunkLoadError=t.i,exports.isQwkSearchApiRequest=t.z,exports.matchSpotlight=t.g,exports.openSpotlight=t.m,exports.parsePrefix=t._,exports.reloadForChunkError=t.a,exports.researchAgentUIConfig=e.researchAgentUIConfig,exports.setQwkSearchApiKey=t.B,exports.useChat=n.u,exports.useChatState=t.it,exports.useChatTabs=t.t,exports.useChunkErrorReload=t.o,exports.useExtractPanel=n.a,exports.useHistoryState=t.K,exports.useKokoroTTS=t.f,exports.useMainView=t.b,exports.useOptionalExtractPanel=n.o,exports.useSession=n.c,exports.useTextToSpeech=t.d;
1
+ "use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs"),t=require("./src-D7eu9lB9.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./dialog-7GDz0sWx.cjs");exports.ARTICLE_TOOLBAR_SHORTCUTS=t.D,exports.ArticleAIResponse=t.w,exports.ArticleActionButtons=t.O,exports.ArticleContent=t.S,exports.ArticleFollowupQuestions=t.T,exports.ArticlePanelHeader=t.A,exports.ArticlePromptInput=t.E,exports.ArticleReaderMount=t.R,exports.CategoryDock=t.c,exports.ChatInputBox=t.U,exports.ChatProvider=t.$,exports.ChatWindow=t.L,exports.CookieConsent=t.s,exports.ExtractPanelProvider=n.i,exports.HistoryDialogs=t.B,exports.HistoryDropdown=t.z,exports.KokoroVoiceSelector=t.u,exports.LexicalArticleViewer=t.C,exports.MainViewProvider=t.y,exports.QWKSEARCH_DEFAULT_ORIGIN=t.j,exports.QwkSearchApp=t.n,exports.QwkSearchProviders=t.r,exports.SPOTLIGHT_LINKS=t.v,exports.SPOTLIGHT_PREFIXES=t.h,exports.SessionProvider=n.s,exports.SpotlightPalette=t.p,exports.UnifiedMarkdown=t.x,exports.VoiceSettingsPanel=t.l,exports.buildConnectStartUrl=t.M,exports.cn=r.o,exports.configureResearchAgentUI=e.configureResearchAgentUI,exports.createQwkSearchConnectAuthClient=t.N,exports.formatMessageTime=r.s,exports.formatTimeDifference=r.c,exports.formatToolbarShortcut=t.k,exports.getQwkSearchApiKey=t.P,exports.isChunkLoadError=t.i,exports.isQwkSearchApiRequest=t.F,exports.matchSpotlight=t.g,exports.openSpotlight=t.m,exports.parsePrefix=t._,exports.reloadForChunkError=t.a,exports.researchAgentUIConfig=e.researchAgentUIConfig,exports.setQwkSearchApiKey=t.I,exports.useChat=n.u,exports.useChatState=t.et,exports.useChatTabs=t.t,exports.useChunkErrorReload=t.o,exports.useExtractPanel=n.a,exports.useHistoryState=t.H,exports.useKokoroTTS=t.f,exports.useMainView=t.b,exports.useOptionalExtractPanel=n.o,exports.useSession=n.c,exports.useTextToSpeech=t.d;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  "use client";
3
3
  import { configureResearchAgentUI as e, researchAgentUIConfig as t } from "./config.mjs";
4
- import { A as n, B as r, C as i, D as a, E as o, F as s, H as c, I as l, K as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, V as b, W as x, _ as S, a as C, b as w, c as T, d as E, f as D, g as O, h as k, i as A, it as j, j as M, k as N, l as P, m as F, n as I, o as L, p as R, q as z, r as B, rt as V, s as H, t as U, u as W, v as G, w as K, x as q, y as J, z as Y } from "./src-Czo4Yrd2.js";
5
- import { a as X, c as Z, i as Q, o as $, s as ee, u as te } from "./tooltip-Bl3IdX-I.js";
6
- import { c as ne, o as re, s as ie } from "./dialog-Cufn2u50.js";
7
- export { M as ARTICLE_TOOLBAR_SHORTCUTS, m as ArticleAIResponse, f as ArticleActionButtons, v as ArticleContent, N as ArticleFollowupQuestions, K as ArticleOutline, h as ArticlePanelHeader, n as ArticlePromptInput, c as ArticleReaderMount, _ as ArticleSidebarTabs, T as CategoryDock, z as ChatInputBox, V as ChatProvider, b as ChatWindow, H as CookieConsent, Q as ExtractPanelProvider, x as HistoryDialogs, y as HistoryDropdown, W as KokoroVoiceSelector, o as LexicalArticleViewer, J as MainViewProvider, s as QWKSEARCH_DEFAULT_ORIGIN, I as QwkSearchApp, B as QwkSearchProviders, G as SPOTLIGHT_LINKS, k as SPOTLIGHT_PREFIXES, ee as SessionProvider, R as SpotlightPalette, q as UnifiedMarkdown, P as VoiceSettingsPanel, i as articleTabIds, l as buildConnectStartUrl, re as cn, e as configureResearchAgentUI, d as createQwkSearchConnectAuthClient, a as extractOutline, ie as formatMessageTime, ne as formatTimeDifference, p as formatToolbarShortcut, g as getQwkSearchApiKey, A as isChunkLoadError, Y as isQwkSearchApiRequest, O as matchSpotlight, F as openSpotlight, S as parsePrefix, C as reloadForChunkError, t as researchAgentUIConfig, r as setQwkSearchApiKey, te as useChat, j as useChatState, U as useChatTabs, L as useChunkErrorReload, X as useExtractPanel, u as useHistoryState, D as useKokoroTTS, w as useMainView, $ as useOptionalExtractPanel, Z as useSession, E as useTextToSpeech };
4
+ import { $ as n, A as r, B as i, C as a, D as o, E as s, F as c, H as l, I as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, _ as b, a as x, b as S, c as C, d as w, et as T, f as E, g as D, h as O, i as k, j as A, k as j, l as M, m as N, n as P, o as F, p as I, r as L, s as R, t as z, u as B, v as V, w as H, x as U, y as W, z as G } from "./src-Cgy6IAES.js";
5
+ import { a as K, c as q, i as J, o as Y, s as X, u as Z } from "./tooltip-Bl3IdX-I.js";
6
+ import { c as Q, o as $, s as ee } from "./dialog-Cufn2u50.js";
7
+ export { o as ARTICLE_TOOLBAR_SHORTCUTS, H as ArticleAIResponse, m as ArticleActionButtons, _ as ArticleContent, v as ArticleFollowupQuestions, r as ArticlePanelHeader, s as ArticlePromptInput, g as ArticleReaderMount, C as CategoryDock, y as ChatInputBox, n as ChatProvider, d as ChatWindow, R as CookieConsent, J as ExtractPanelProvider, i as HistoryDialogs, G as HistoryDropdown, B as KokoroVoiceSelector, a as LexicalArticleViewer, W as MainViewProvider, A as QWKSEARCH_DEFAULT_ORIGIN, P as QwkSearchApp, L as QwkSearchProviders, V as SPOTLIGHT_LINKS, O as SPOTLIGHT_PREFIXES, X as SessionProvider, I as SpotlightPalette, U as UnifiedMarkdown, M as VoiceSettingsPanel, f as buildConnectStartUrl, $ as cn, e as configureResearchAgentUI, p as createQwkSearchConnectAuthClient, ee as formatMessageTime, Q as formatTimeDifference, j as formatToolbarShortcut, h as getQwkSearchApiKey, k as isChunkLoadError, c as isQwkSearchApiRequest, D as matchSpotlight, N as openSpotlight, b as parsePrefix, x as reloadForChunkError, t as researchAgentUIConfig, u as setQwkSearchApiKey, Z as useChat, T as useChatState, z as useChatTabs, F as useChunkErrorReload, K as useExtractPanel, l as useHistoryState, E as useKokoroTTS, S as useMainView, Y as useOptionalExtractPanel, q as useSession, w as useTextToSpeech };