research-agent-ui 0.1.311 → 0.1.312
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/{ArticleExtractPanel-BdvTS_iQ.cjs → ArticleExtractPanel-BIQb3d3o.cjs} +1 -1
- package/dist/{ArticleExtractPanel-Cjwmqxef.js → ArticleExtractPanel-DVwjco1q.js} +1 -1
- package/dist/{ChatConversationThread-CNCj2kLC.cjs → ChatConversationThread-CVaSsBBI.cjs} +2 -2
- package/dist/{ChatConversationThread-D-Vmap22.js → ChatConversationThread-rjA-PDdh.js} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-SllRa2bC.js → src-BQX5Q6k1.js} +34 -30
- package/dist/{src-WYNNidsJ.cjs → src-cbzeR_Vl.cjs} +2 -2
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.mjs +1 -1
- package/package.json +12 -12
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-
|
|
1
|
+
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-cbzeR_Vl.cjs"),i=require("./config.cjs");let a=require("react");a=e.t(a,1);let o=require("react/jsx-runtime"),s=require("sonner"),c=require("qwksearch-api-client");var l=a.forwardRef(({className:e,...n},r)=>(0,o.jsx)(`span`,{ref:r,className:t.o(`absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0`,e),style:{clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`},...n}));l.displayName=`VisuallyHidden`;function u(e){return e instanceof Error&&e.name===`AbortError`}async function ee(e,t){if(t.share)try{return await t.share(e),`shared`}catch(e){if(u(e))return`cancelled`}return await t.writeText(e.url),`copied`}var d=e=>{let{isOpen:u,url:d,searchText:te,suggestQuestions:f,panelWidth:ne,setPanelWidth:p,closePanel:re}=n.a(),{isAuthenticated:ie}=n.c(),{chatModelProvider:m}=n.u(),h=e.isOpen===void 0?u:e.isOpen,g=e.onClose||re,_=e.url||d,ae=e.searchText===void 0?te:e.searchText,[v,y]=(0,a.useState)(null),[b,oe]=(0,a.useState)([]),[se,x]=(0,a.useState)(!1),[ce,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(i.researchAgentUIConfig.defaultSummarizePrompt),[le,T]=(0,a.useState)(!1),[E,ue]=(0,a.useState)(!1),[D,de]=(0,a.useState)(!1),[O,fe]=(0,a.useState)(``),[k,pe]=(0,a.useState)(``),[me,A]=(0,a.useState)([]),[he,ge]=(0,a.useState)(``),[j,M]=(0,a.useState)(!1),[_e,N]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[I,ve]=(0,a.useState)(!1),[ye,be]=(0,a.useState)(ne),[L,R]=(0,a.useState)(!1),[xe,z]=(0,a.useState)(!1),[B,V]=(0,a.useState)(1),Se=(0,a.useRef)(null),H=(0,a.useRef)({}),U=.5,W=1.8,G=.1;(0,a.useEffect)(()=>{let e=parseFloat(localStorage.getItem(`articleFontScale`)||``);Number.isNaN(e)||V(Math.min(W,Math.max(U,e)))},[]);let K=e=>{let t=Math.min(W,Math.max(U,Math.round(e*100)/100));V(t);try{localStorage.setItem(`articleFontScale`,String(t))}catch(e){console.error(`Error storing article font scale:`,e)}},q=()=>K(B+G),J=()=>K(B-G),Y=()=>K(1);(0,a.useEffect)(()=>{let e=()=>{ve(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{let e=e=>{if(!L)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));be(n),p(n)},t=()=>{R(!1)};return L&&(document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[L,p]),(0,a.useEffect)(()=>{h&&_?(z(!1),Ce()):h||z(!1)},[h,_]);let Ce=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,_);try{let e=new URL(_);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(_))){s.toast.error(`Cannot extract articles from search result pages`),T(!1),z(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,_),s.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,_,e)}T(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:_}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:_}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:_}}),i=r?.article;i&&(y(i),i.followUpQuestions?.length>0?A(i.followUpQuestions):f&&(A([]),Z(`suggest-followups`,{source:i}))),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(y(t),t?.followUpQuestions&&t.followUpQuestions.length>0?A(t.followUpQuestions):f&&t&&(A([]),Z(`suggest-followups`,{source:t}))),ie&&we()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),s.toast.error(`Failed to load article`)}finally{T(!1),z(!0)}},we=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===_);M(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},X=async()=>{if(v){N(!0);try{j?(await(0,c.removeFavorite)({query:{url:_}}),M(!1),s.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:v.url||_,title:v.title,cite:v.cite,author:v.author,author_cite:v.author_cite,date:v.date,source:v.source,word_count:v.word_count,html:v.html}}),M(!0),s.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),s.toast.error(`Failed to toggle favorite`)}finally{N(!1)}}},Te=()=>{if(m?.key&&m?.providerId)return m;try{let e=localStorage.getItem(`chatModelKey`)||``,t=localStorage.getItem(`chatModelProviderId`)||``;if(e&&t)return{key:e,providerId:t}}catch(e){console.error(`Error reading persisted chat model:`,e)}return m},Z=async(e,{source:t=v,question:n=C}={})=>{if(!t)return;let r=Te(),a=t.html?.replace(/<[^>]*>?/g,``).slice(0,i.researchAgentUIConfig.maxArticleLength),o=e===`question`,s=o?ue:de,l=o?pe:ge;s(!0),l(``);try{if(o){let e=[ae,n].filter(Boolean).join(`
|
|
2
2
|
`);if(!a||a.length===0)throw Error(`Article content is empty`);let{data:t,error:i}=await(0,c.articleQa)({body:{article:a,question:e,chatHistory:b.slice(-5),chatModel:r}});if(i){let e=i.details||i.error||i.message||`Article QA failed`;throw Error(e)}let o=t?.content||``;fe(o),oe(e=>[...e,{role:`user`,content:n,time:new Date().toISOString()},{role:`assistant`,content:o,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:_,question:n,answer:o}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`);if(!a||a.length===0)throw Error(`Article content is empty`);let{data:t,error:n}=await(0,c.articleFollowups)({body:{article:a,chatHistory:b.slice(-5),maxQuestions:e,chatModel:r}});if(n){let e=n.details||n.error||n.message||`Article followups failed`;throw Error(e)}let i=t?.extract||[];A(i);try{await(0,c.updateArticle)({body:{url:_,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),l(e instanceof Error||typeof e==`object`&&e&&`message`in e?e.message:`Failed to get AI response`)}finally{s(!1)}},Ee=e=>{w(e),Z(`question`,{question:e})},Q=async()=>{if(!v)return;let e=`${O}\n\n\n${v.cite||``}\n\n\n${v.html}`;try{await navigator.clipboard.writeText(e),x(!0),setTimeout(()=>x(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},De=async()=>{let e=v?.url||_;if(e)try{await ee({title:v?.title,text:v?.cite,url:e},{share:typeof navigator<`u`&&navigator.share?e=>navigator.share(e):void 0,writeText:e=>navigator.clipboard.writeText(e)})===`copied`&&(S(!0),setTimeout(()=>S(!1),2e3))}catch(e){console.error(`Failed to share article:`,e)}};H.current={ask:()=>Z(`question`),suggest:()=>Z(`suggest-followups`),copy:Q,highlight:()=>F(e=>!e),favorite:X,open:()=>{let e=v?.url||_;e&&window.open(e,`_blank`,`noopener,noreferrer`)},zoomIn:q,zoomOut:J,zoomReset:Y,close:g},(0,a.useEffect)(()=>{if(!h)return;let e=e=>/^[a-z]$/.test(e)?`Key${e.toUpperCase()}`:/^[0-9]$/.test(e)?`Digit${e}`:e===`-`?`Minus`:e===`=`?`Equal`:e,t={};Object.keys(r.D).forEach(n=>{let{alt:i,key:a}=r.D[n];i&&(t[e(a.toLowerCase())]=n)});let n=e=>{if(e.key===`Escape`){H.current.close?.();return}if(!e.altKey||e.ctrlKey||e.metaKey)return;let n=e.target;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;let r=t[e.code];if(!r)return;let i=H.current[r];i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[h]);let $=()=>(0,o.jsxs)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:[(0,o.jsx)(`div`,{className:`shrink-0 border-b border-border bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/80`,children:(0,o.jsx)(r.O,{isLoadingAI:E,isLoadingFollowups:D,isLoadingFavorite:_e,isFavorited:j,isHighlightMode:P,articleUrl:v?.url||_,fontScale:B,onAskClick:()=>Z(`question`),onSuggestClick:()=>Z(`suggest-followups`),onCopyClick:Q,onShareClick:De,onFavoriteClick:X,onHighlightToggle:()=>F(!P),onZoomIn:q,onZoomOut:J,onZoomReset:Y,onClose:g})}),(0,o.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,o.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,o.jsxs)(`div`,{className:`space-y-4`,children:[se&&(0,o.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),ce&&(0,o.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Link copied!`}),(0,o.jsx)(r.E,{value:C,onChange:w,onSubmit:()=>Z(`question`)}),(0,o.jsx)(r.T,{questions:me,isLoading:D,error:he,onQuestionClick:Ee}),b.length>0&&(0,o.jsx)(`div`,{className:`space-y-4`,children:b.map((e,t)=>(0,o.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,o.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,o.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,o.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,o.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,o.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,o.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(E||O&&b.length===0)&&(0,o.jsx)(r.w,{response:O,isLoading:E,error:k}),k&&!E&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:k})]}),v&&(0,o.jsx)(r.S,{article:v,isHighlightMode:P,fontScale:B})]})})]});return!h||!xe?null:I?(0,o.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${ye}px`},children:[(0,o.jsx)(`div`,{ref:Se,onMouseDown:()=>R(!0),className:`absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-primary bg-transparent transition-colors z-50`,style:{touchAction:`none`},children:(0,o.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity`})}),$()]}):(0,o.jsx)(t.t,{open:h,onOpenChange:e=>!e&&g(),children:(0,o.jsxs)(t.n,{className:`pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden 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]:slide-out-to-right data-[state=open]:slide-in-from-right`,hideCloseButton:!0,children:[(0,o.jsx)(l,{children:(0,o.jsx)(t.i,{children:`Article Details`})}),(0,o.jsx)(`div`,{className:`h-full overflow-y-auto`,children:$()})]})})};exports.default=d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as e, n as t, o as n, t as r } from "./dialog-Cufn2u50.js";
|
|
2
2
|
import { a as i, c as a, u as o } from "./tooltip-Bl3IdX-I.js";
|
|
3
|
-
import { D as s, E as ee, O as te, S as ne, T as re, w as ie } from "./src-
|
|
3
|
+
import { D as s, E as ee, O as te, S as ne, T as re, w as ie } from "./src-BQX5Q6k1.js";
|
|
4
4
|
import { researchAgentUIConfig as ae } from "./config.mjs";
|
|
5
5
|
import * as c from "react";
|
|
6
6
|
import { useEffect as l, useRef as u, useState as d } from "react";
|
|
@@ -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-
|
|
1
|
+
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-cbzeR_Vl.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))
|
|
@@ -14,4 +14,4 @@ const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.
|
|
|
14
14
|
#4c7894 calc(75% / var(--repeating-conic-gradient-times)),
|
|
15
15
|
#dd7bbb calc(100% / var(--repeating-conic-gradient-times))
|
|
16
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-BdvTS_iQ.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;
|
|
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-BIQb3d3o.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,6 +1,6 @@
|
|
|
1
1
|
import { i as e, n as t, o as n, r, s as i, t as a } from "./dialog-Cufn2u50.js";
|
|
2
2
|
import { a as o, c as s, n as c, r as l, t as u, u as d } from "./tooltip-Bl3IdX-I.js";
|
|
3
|
-
import { G as f, J as p, K as m, Q as h, U as g, V as _, W as v, X as y, Y as b, Z as x, d as S, q as C, tt as w } from "./src-
|
|
3
|
+
import { G as f, J as p, K as m, Q as h, U as g, V as _, W as v, X as y, Y as b, Z as x, d as S, q as C, tt as w } from "./src-BQX5Q6k1.js";
|
|
4
4
|
import { researchAgentUIConfig as T } from "./config.mjs";
|
|
5
5
|
import { Fragment as E, Suspense as D, lazy as O, memo as k, useCallback as A, useEffect as j, useMemo as M, useRef as N, useState as P } from "react";
|
|
6
6
|
import { Fragment as F, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
@@ -1378,7 +1378,7 @@ var it = ({ size: e = 140, className: t }) => {
|
|
|
1378
1378
|
dangerouslySetInnerHTML: { __html: rt(r, e) }
|
|
1379
1379
|
}) : null
|
|
1380
1380
|
});
|
|
1381
|
-
}, at = O(() => import("./ArticleExtractPanel-
|
|
1381
|
+
}, at = O(() => import("./ArticleExtractPanel-DVwjco1q.js")), ot = () => {
|
|
1382
1382
|
let { sections: e, chatTurns: t, loading: n, messageAppeared: r, newChat: i, chatId: a } = d(), { isOpen: c, panelWidth: l } = o(), { isAuthenticated: u } = s(), [f, p] = P(!1);
|
|
1383
1383
|
j(() => {
|
|
1384
1384
|
c && p(!0);
|
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-
|
|
1
|
+
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs"),t=require("./src-cbzeR_Vl.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 { $ 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-
|
|
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-BQX5Q6k1.js";
|
|
5
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
6
|
import { c as Q, o as $, s as ee } from "./dialog-Cufn2u50.js";
|
|
7
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 };
|
|
@@ -3830,7 +3830,7 @@ function ci({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
|
|
|
3830
3830
|
});
|
|
3831
3831
|
}
|
|
3832
3832
|
// src/components/ArticleReader/ArticleReaderMount.tsx
|
|
3833
|
-
var li = S(() => import("./ArticleExtractPanel-
|
|
3833
|
+
var li = S(() => import("./ArticleExtractPanel-DVwjco1q.js"));
|
|
3834
3834
|
function ui() {
|
|
3835
3835
|
let e = o()?.isOpen ?? !1, [t, n] = O(!1);
|
|
3836
3836
|
return T(() => {
|
|
@@ -4271,7 +4271,7 @@ function Li() {
|
|
|
4271
4271
|
});
|
|
4272
4272
|
}
|
|
4273
4273
|
// src/components/ChatConversation/ChatWindow.tsx
|
|
4274
|
-
var Ri = () => import("./ChatConversationThread-
|
|
4274
|
+
var Ri = () => import("./ChatConversationThread-rjA-PDdh.js"), zi = S(Ri), Bi = () => {
|
|
4275
4275
|
let e = j(), { hasError: t, isReady: r, notFound: i, messages: a } = u(), { isAuthenticated: o } = n(), s = r && !i && a.length === 0;
|
|
4276
4276
|
return T(() => {
|
|
4277
4277
|
if (!s) return;
|
|
@@ -6309,7 +6309,7 @@ function Do() {
|
|
|
6309
6309
|
}
|
|
6310
6310
|
}
|
|
6311
6311
|
function Oo() {
|
|
6312
|
-
let { chatId: e, chatTurns: t, startNewChat: n, switchToChat: r } = u(), [i, a] = O(Do);
|
|
6312
|
+
let { chatId: e, chatTurns: t, startNewChat: n, switchToChat: r } = u(), [i, a] = O(Do), o = D(null);
|
|
6313
6313
|
T(() => {
|
|
6314
6314
|
window.localStorage.setItem(To, JSON.stringify(i));
|
|
6315
6315
|
}, [i]), T(() => {
|
|
@@ -6317,7 +6317,7 @@ function Oo() {
|
|
|
6317
6317
|
let n = t[0]?.content?.slice(0, Eo), r = t.length > 0;
|
|
6318
6318
|
a((t) => {
|
|
6319
6319
|
let i = t.find((t) => t.id === e);
|
|
6320
|
-
return i ? n && i.title !== n || i.hasMessages !== r ? t.map((t) => t.id === e ? {
|
|
6320
|
+
return !i && e === o.current && !r ? t : i ? n && i.title !== n || i.hasMessages !== r ? t.map((t) => t.id === e ? {
|
|
6321
6321
|
...t,
|
|
6322
6322
|
title: n || t.title,
|
|
6323
6323
|
hasMessages: r
|
|
@@ -6328,49 +6328,53 @@ function Oo() {
|
|
|
6328
6328
|
}];
|
|
6329
6329
|
});
|
|
6330
6330
|
}, [e, t]);
|
|
6331
|
-
let
|
|
6331
|
+
let s = C((e, t) => {
|
|
6332
6332
|
let i = t.find((t) => t.id === e);
|
|
6333
6333
|
i && !i.hasMessages ? n(e) : r(e);
|
|
6334
|
-
}, [n, r]),
|
|
6335
|
-
|
|
6336
|
-
}, [
|
|
6334
|
+
}, [n, r]), c = C((e) => {
|
|
6335
|
+
s(e, i);
|
|
6336
|
+
}, [s, i]), l = C(() => {
|
|
6337
6337
|
let e = crypto.randomUUID();
|
|
6338
6338
|
return a((t) => [...t, {
|
|
6339
6339
|
id: e,
|
|
6340
6340
|
title: "New Chat"
|
|
6341
6341
|
}]), n(e), e;
|
|
6342
|
-
}, [n]),
|
|
6343
|
-
let
|
|
6344
|
-
a(
|
|
6345
|
-
let
|
|
6346
|
-
if (!
|
|
6342
|
+
}, [n]), d = C((t) => {
|
|
6343
|
+
let r = new Set(t), c = i.filter((e) => !r.has(e.id));
|
|
6344
|
+
a(c);
|
|
6345
|
+
let l = e != null && r.has(e);
|
|
6346
|
+
if (!l) return {
|
|
6347
6347
|
closedWasActive: !1,
|
|
6348
6348
|
nextActiveId: null
|
|
6349
6349
|
};
|
|
6350
|
-
if (
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
let d = (
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6350
|
+
if (c.length === 0) {
|
|
6351
|
+
let e = crypto.randomUUID();
|
|
6352
|
+
return o.current = e, n(e), {
|
|
6353
|
+
closedWasActive: l,
|
|
6354
|
+
nextActiveId: null
|
|
6355
|
+
};
|
|
6356
|
+
}
|
|
6357
|
+
let u = i.findIndex((t) => t.id === e), d = (e) => e != null && !r.has(e.id), f;
|
|
6358
|
+
for (let e = u - 1; e >= 0 && !f; e--) d(i[e]) && (f = i[e]);
|
|
6359
|
+
for (let e = u + 1; e < i.length && !f; e++) d(i[e]) && (f = i[e]);
|
|
6360
|
+
let p = (f ?? c[0]).id;
|
|
6361
|
+
return s(p, c), {
|
|
6362
|
+
closedWasActive: l,
|
|
6363
|
+
nextActiveId: p
|
|
6361
6364
|
};
|
|
6362
6365
|
}, [
|
|
6363
6366
|
i,
|
|
6364
6367
|
e,
|
|
6365
|
-
|
|
6366
|
-
|
|
6368
|
+
s,
|
|
6369
|
+
n
|
|
6370
|
+
]), f = C((e) => d([e]), [d]);
|
|
6367
6371
|
return {
|
|
6368
6372
|
chatTabs: i,
|
|
6369
6373
|
activeChatId: e ?? null,
|
|
6370
|
-
openChat:
|
|
6371
|
-
newChat:
|
|
6372
|
-
closeChat:
|
|
6373
|
-
closeChats:
|
|
6374
|
+
openChat: c,
|
|
6375
|
+
newChat: l,
|
|
6376
|
+
closeChat: f,
|
|
6377
|
+
closeChats: d
|
|
6374
6378
|
};
|
|
6375
6379
|
}
|
|
6376
6380
|
export { Cn as $, Zi as A, $r as B, sa as C, $i as D, ia as E, Gi as F, wr as G, qr as H, qi as I, lr as J, Er as K, Bi as L, Yi as M, Xi as N, ra as O, Ji as P, Un as Q, ui as R, ca as S, aa as T, Rr as U, Xr as V, Tr as W, Wn as X, Hn as Y, X as Z, Pa as _, yo as a, wa as b, po as c, oo as d, xn as et, ao as f, La as g, Na as h, vo as i, Vi as j, ta as k, lo as l, Ua as m, wo as n, bo as o, Ka as p, Dr as q, Co as r, mo as s, Oo as t, J as tt, co as u, Da as v, oa as w, va as x, xa as y, ni as z };
|
|
@@ -13,7 +13,7 @@ const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./config.cjs"),n=r
|
|
|
13
13
|
${P?`text-red-500 bg-red-500/10 animate-pulse`:`text-text-400 hover:text-text-200 hover:bg-bg-200`}
|
|
14
14
|
`,"aria-label":P?`Stop listening`:`Voice input`,children:(0,o.jsx)(R.Mic,{className:`w-5 h-5`})}),(0,o.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:P?`Stop listening`:`Voice input`})})]}),m.length>0&&(0,o.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),f()},disabled:t,className:`transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200`,"aria-label":`New chat`,children:(0,o.jsx)(R.SquarePen,{className:`w-5 h-5`})}),(0,o.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`New chat`})})]}),(0,o.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[t?(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`inline-flex items-center justify-center shrink-0 transition-colors h-8 w-8 rounded-full active:scale-95 bg-red-500 text-white hover:bg-red-600 shadow-md`,type:`button`,"aria-label":`Stop generating`,children:(0,o.jsx)(R.Stop,{className:`w-3.5 h-3.5 fill-current`})}):(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ae()},disabled:!se,className:`inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
|
|
15
15
|
${se?`bg-accent text-bg-0 hover:bg-accent-hover shadow-md`:`bg-bg-300 text-text-400 cursor-default opacity-50`}
|
|
16
|
-
`,type:`button`,"aria-label":`Send message`,children:(0,o.jsx)(R.ArrowUp,{className:`w-4 h-4`})}),(0,o.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,o.jsx)(j,{...ie}),C&&(0,o.jsxs)(`div`,{className:`absolute inset-0 bg-bg-200/90 border-2 border-dashed border-accent rounded-[28px] z-50 flex flex-col items-center justify-center backdrop-blur-sm pointer-events-none`,children:[(0,o.jsx)(R.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,o.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})},kt=200,At=[`message`,`error`,`detail`];function jt(e){return e.length>kt?`${e.slice(0,199).trimEnd()}…`:e}function Mt(e,t){let n=t?`HTTP ${t}`:`Unknown error`;if(typeof e==`string`){let t=e.trim();return!t||t.startsWith(`<`)?n:jt(t)}if(e&&typeof e==`object`){let t=e;for(let e of At){let n=t[e];if(typeof n==`string`&&n.trim())return jt(n.trim())}}return n}var Nt=`qwksearch_pinned_chats`;function Pt(e){let t=e.messages?.[e.messages.length-1],n=t&&`createdAt`in t?t.createdAt:void 0;if(n){let e=new Date(n).getTime();if(!Number.isNaN(e))return new Date(e).toISOString()}return e.createdAt}function Ft(){if(typeof window>`u`)return[];try{let e=localStorage.getItem(Nt);return e?JSON.parse(e):[]}catch{return[]}}function It(e){typeof window<`u`&&localStorage.setItem(Nt,JSON.stringify(e))}function Lt(){let[e,t]=(0,i.useState)([]),[r,a]=(0,i.useState)(!0),[o,s]=(0,i.useState)(!1),[c,u]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(!1),[v,y]=(0,i.useState)([]),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)([]),[w,T]=(0,i.useState)(!1),{isAuthenticated:E,isLoading:D}=n.c(),{incognito:O,setIncognito:k}=n.u();(0,i.useEffect)(()=>{y(Ft())},[]);let A=(0,i.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),y(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return It(n),n})},[]),j=(0,i.useMemo)(()=>[...e].sort((e,t)=>{let n=v.includes(e.id),r=v.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,v]),M=(0,i.useMemo)(()=>b.trim()?S:j,[b,S,j]),N=(0,i.useCallback)(async()=>{if(!D){a(!0);try{if(E){let{data:e,error:n,response:r}=await(0,d.listChats)();if(n&&r?.status===401){let e=U().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:Pt(e)}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${Mt(n,r?.status)}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=U().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e)}}catch(e){console.error(`Failed to fetch chat history:`,e),t([]),l.toast.error(`Failed to load chat history`)}finally{a(!1)}}},[E,D]);(0,i.useEffect)(()=>{N()},[N]);let P=(e,t)=>{e.preventDefault(),e.stopPropagation(),u(t),s(!0)},F=async()=>{if(c){p(!0);try{if(E){let{error:e,response:t}=await(0,d.deleteChatById)({path:{id:c}});if(e)throw Error(`Failed to delete chat: ${Mt(e,t?.status)}`)}else ne(c);t(e=>e.filter(e=>e.id!==c)),l.toast.success(`Chat deleted`)}catch(e){l.toast.error(e.message||`Failed to delete chat`)}finally{s(!1),u(null),p(!1)}}},I=()=>{h(!0)},L=async()=>{_(!0);try{if(E){let{error:e,response:t}=await(0,d.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${Mt(e,t?.status)}`)}else re();t([]),l.toast.success(`All history cleared`)}catch(e){l.toast.error(e.message||`Failed to clear history`)}finally{h(!1),_(!1)}},R=()=>{k(!O),l.toast.success(O?`Private mode off`:`Private mode on — messages won't be saved`)},z=(0,i.useCallback)(async e=>{if(!e.trim())C([]),T(!1);else{T(!0);try{if(E){let{data:t,error:n,response:r}=await(0,d.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${Mt(n,r?.status)}`);C(Array.isArray(t?.chats)?t.chats:[])}else{let t=U().filter(t=>{let n=t.title.toLowerCase().includes(e.toLowerCase()),r=t.messages?.some(t=>`content`in t&&t.content?.toLowerCase().includes(e.toLowerCase()));return n||r});C(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:Pt(e)})))}}catch(e){console.error(`Failed to search chat history:`,e),C([]),l.toast.error(`Failed to search chat history`)}finally{T(!1)}}},[E]);return(0,i.useEffect)(()=>{let e=setTimeout(()=>{z(b)},300);return()=>clearTimeout(e)},[b,z]),{chats:e,sortedChats:j,displayChats:M,loading:r,pinnedIds:v,togglePin:A,incognito:O,toggleIncognito:R,searchQuery:b,searchResults:S,searching:w,handleSearchChange:(0,i.useCallback)(e=>{x(e)},[]),deleteDialogOpen:o,setDeleteDialogOpen:s,chatToDelete:c,setChatToDelete:u,deleting:f,handleDeleteClick:P,handleConfirmDelete:F,clearAllDialogOpen:m,setClearAllDialogOpen:h,clearingAll:g,handleClearAllClick:I,handleConfirmClearAll:L}}function Rt({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,o.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,o.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-2 py-1 text-xs rounded-lg transition-colors duration-200 ${e?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary`}`,title:e?`Private mode on`:`Private mode`,children:[(0,o.jsx)(c.Lock,{size:12}),(0,o.jsx)(`span`,{children:`Private`})]}),n&&(0,o.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors duration-200`,title:`Clear all history`,children:[(0,o.jsx)(c.Trash2,{size:12}),(0,o.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(c.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,o.jsx)(`input`,{type:`text`,placeholder:`Search chats...`,value:i,onChange:e=>a(e.target.value),className:`w-full pl-7 pr-7 py-1.5 text-sm bg-secondary/50 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 placeholder:text-muted-foreground/50`}),i&&(0,o.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,o.jsx)(c.X,{size:14})})]})]})}var zt=(0,_.cva)(`inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,new:`text-purple-600 dark:text-purple-300 bg-purple-600/30 dark:bg-purple-600/30`,beta:`text-blue-600 dark:text-blue-300 bg-blue-600/30 dark:bg-blue-600/30`,highlight:`text-green-800 dark:text-green-300 bg-green-600/30 dark:bg-green-600/30`}},defaultVariants:{variant:`default`}});function Bt({className:e,variant:t,asChild:n=!1,...i}){return(0,o.jsx)(n?g.Slot:`span`,{"data-slot":`badge`,className:r.o(zt({variant:t}),e),...i})}function Vt({chat:e,isPinned:n,onTogglePin:i,onDelete:a}){let s=e.messageCount??0;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,o.jsxs)(h.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,o.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[s>0&&(0,o.jsxs)(Bt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md`,children:[s,`Q`]}),(0,o.jsx)(Bt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md`,children:r.c(new Date,e.createdAt)})]}),(0,o.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[n&&(0,o.jsx)(c.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,o.jsx)(`button`,{onClick:t=>i(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${n?`opacity-100 text-primary hover:bg-primary/10`:`opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10`}`,title:n?`Unpin chat`:`Pin chat`,children:(0,o.jsx)(c.Pin,{size:14})}),(0,o.jsx)(`button`,{onClick:t=>a(t,e.id),className:`opacity-0 group-hover:opacity-100 p-1.5 rounded-lg hover:bg-red-500/10 text-muted-foreground hover:text-red-500 transition-all duration-200`,title:`Delete chat`,children:(0,o.jsx)(c.Trash,{size:14})})]})}function Ht({open:e,onOpenChange:t,title:n,description:i,confirmLabel:a,loadingLabel:s,loading:c,onConfirm:l}){return(0,o.jsx)(r.t,{open:e,onOpenChange:e=>{!e&&!c&&t(!1)},children:(0,o.jsxs)(r.n,{className:`w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl`,children:[(0,o.jsx)(r.i,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,o.jsx)(r.r,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:i}),(0,o.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,o.jsx)(`button`,{onClick:()=>{c||t(!1)},className:`text-black/50 dark:text-white/50 text-sm hover:text-black/70 hover:dark:text-white/70 transition duration-200`,children:`Cancel`}),(0,o.jsx)(`button`,{onClick:l,disabled:c,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:c?s:a})]})]})})}function Ut({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:s,setClearAllDialogOpen:c,clearingAll:l,onConfirmClearAll:u}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ht,{open:e,onOpenChange:e=>{t(e),e||r(null)},title:`Delete Confirmation`,description:`Are you sure you want to delete this chat?`,confirmLabel:`Delete`,loadingLabel:`Deleting...`,loading:i,onConfirm:a}),(0,o.jsx)(Ht,{open:s,onOpenChange:c,title:`Clear All History`,description:`Are you sure you want to delete all your chat history? This action cannot be undone.`,confirmLabel:`Clear All`,loadingLabel:`Clearing...`,loading:l,onConfirm:u})]})}var Wt={Today:(0,o.jsx)(c.Sun,{size:12}),Yesterday:(0,o.jsx)(c.Clock,{size:12}),"This Week":(0,o.jsx)(c.CalendarDays,{size:12}),Older:(0,o.jsx)(c.Archive,{size:12})};function Gt(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-5184e5),a={Today:[],Yesterday:[],"This Week":[],Older:[]};for(let t of e){let e=new Date(t.createdAt);e>=n?a.Today.push(t):e>=r?a.Yesterday.push(t):e>=i?a[`This Week`].push(t):a.Older.push(t)}return[`Today`,`Yesterday`,`This Week`,`Older`].filter(e=>a[e].length>0).map(e=>({label:e,chats:a[e]}))}var Kt=({showLabel:e=!1})=>{let t=Lt();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(r.t,{children:[(0,o.jsxs)(r.a,{className:e?`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150`:`p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30`,children:[(0,o.jsx)(c.History,{size:e?14:18}),e&&(0,o.jsx)(`span`,{children:`History`})]}),(0,o.jsxs)(r.n,{className:`max-w-[420px] p-3`,children:[(0,o.jsx)(r.i,{className:`sr-only`,children:`Chat History`}),(0,o.jsx)(Rt,{incognito:t.incognito,onToggleIncognito:t.toggleIncognito,showClearAll:t.chats.length>0&&!t.loading,onClearAll:t.handleClearAllClick,searchQuery:t.searchQuery,onSearchChange:t.handleSearchChange}),t.loading||t.searching?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-6 h-6 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,o.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,o.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]})}):t.searchQuery.trim()&&t.displayChats.length===0?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,o.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,o.jsx)(Vt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):Gt(t.displayChats).map(({label:e,chats:n})=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider`,children:[Wt[e],e]}),n.map(e=>(0,o.jsx)(Vt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,o.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,o.jsx)(h.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,o.jsx)(Ut,{deleteDialogOpen:t.deleteDialogOpen,setDeleteDialogOpen:t.setDeleteDialogOpen,chatToDelete:t.chatToDelete,setChatToDelete:t.setChatToDelete,deleting:t.deleting,onConfirmDelete:t.handleConfirmDelete,clearAllDialogOpen:t.clearAllDialogOpen,setClearAllDialogOpen:t.setClearAllDialogOpen,clearingAll:t.clearingAll,onConfirmClearAll:t.handleConfirmClearAll})]})},qt=e=>new Date(e.lastMessageAt||e.createdAt).getTime();function Jt(){let{chats:e,loading:n}=Lt(),r=[...e].sort((e,t)=>qt(t)-qt(e)).slice(0,5);return n||r.length===0?null:(0,o.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,o.jsx)(Kt,{showLabel:!0}),r.map(e=>{let n=at(e.lastMessageAt||e.createdAt);return(0,o.jsxs)(h.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 max-w-[220px]`,title:e.title,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.title}),n&&(0,o.jsx)(`span`,{className:`italic text-muted-foreground/70 whitespace-nowrap`,children:n})]},e.id)})]})}var Yt={Bot:c.Bot,BookOpen:c.BookOpen,Building2:c.Building2,Download:c.Download,HelpCircle:c.HelpCircle,Info:c.Info,Lock:c.Lock,Mail:c.Mail,MessageCircle:c.MessageCircle,Newspaper:c.Newspaper,Sparkles:c.Sparkles};function Xt({name:e}){let t=Yt[e];return t?(0,o.jsx)(t,{size:14}):null}var Zt=`relative group inline-flex items-center gap-1 px-[3px] sm:px-1.5 py-0.5 rounded-md whitespace-nowrap transition-all duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] hover:text-white hover:bg-white/10 hover:-translate-y-0.5 hover:scale-110 hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] active:scale-95 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/60`;function Qt({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:n=`bg-black/40`}){return e.length===0?null:(0,o.jsx)(`nav`,{"aria-label":`Footer`,className:`relative z-20 mx-auto flex w-max flex-nowrap items-center justify-center gap-0 sm:gap-1 max-w-full text-slate-200 ${n} backdrop-blur-sm rounded-full px-1 sm:px-1.5 py-0.5 shadow-lg hover:shadow-xl transition-shadow duration-300`,children:e.map(({url:e,text:n,icon:r,onClick:i})=>{let a=e.startsWith(`http`),s=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,o.jsxs)(o.Fragment,{children:[t&&r&&(0,o.jsx)(`span`,{className:`hidden sm:inline-flex transition-transform duration-300 group-hover:-rotate-12 group-hover:scale-125`,children:(0,o.jsx)(Xt,{name:r})}),(0,o.jsx)(`span`,{className:`font-semibold tracking-wide text-[11px] sm:text-xs`,style:{fontVariant:`small-caps`},children:n}),(0,o.jsx)(`span`,{className:`absolute bottom-0 left-1/2 w-0 h-px -translate-x-1/2 bg-current transition-all duration-300 group-hover:w-3/4 group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return i?(0,o.jsx)(`button`,{type:`button`,onClick:i,className:Zt,children:c},e):a?(0,o.jsx)(`a`,{href:e,...s,className:Zt,children:c},e):(0,o.jsx)(h.default,{href:e,className:Zt,children:c},e)})})}var $t=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./ArticleExtractPanel-BdvTS_iQ.cjs")));function en(){let e=n.o()?.isOpen??!1,[t,r]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{e&&r(!0)},[e]),!t&&!e?null:(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)($t,{})})}var tn=`hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg`.split(`,`).map(e=>`https://i.imgur.com/`+e),nn=`qwksearch-background-art-v1`,rn=`backgroundArtCache`,an=e=>typeof e==`string`&&tn.includes(e);function on(){try{let e=JSON.parse(localStorage.getItem(`backgroundArtCache`)||`[]`);return Array.isArray(e)?[...new Set(e.filter(an))]:[]}catch{return[]}}function sn(e){try{localStorage.setItem(rn,JSON.stringify(e))}catch{}}function cn(e){let t=on().filter(t=>t!==e);t.push(e);let n=t.splice(0,Math.max(0,t.length-10));return sn(t),n}function ln(e){sn(on().filter(t=>t!==e))}var un=e=>e.length?e[Math.floor(Math.random()*e.length)]:null;function dn(e){return un(on().filter(t=>t!==e))}function fn(){let e=new Set(on());return un(tn.filter(t=>!e.has(t)))}async function pn(){if(typeof caches>`u`)return null;try{return await caches.open(nn)}catch{return null}}async function mn(e){let t=await pn();if(!t)return null;try{let n=await t.match(e);return n?URL.createObjectURL(await n.blob()):(ln(e),null)}catch{return null}}async function hn(e){let t=await pn();if(!t)return e;let n;try{let t=await fetch(e,{mode:`cors`,credentials:`omit`});if(!t.ok)return null;n=await t.blob()}catch{return e}if(n.size<=15728640)try{await t.put(e,new Response(n,{headers:{"Content-Type":n.type}}));let r=cn(e);await Promise.all(r.map(e=>t.delete(e)))}catch{}return URL.createObjectURL(n)}var gn=(0,i.lazy)(()=>import(`use-weather-forecast`).then(e=>({default:e.WeatherForecast}))),_n=(0,i.lazy)(()=>import(`trending-news-api`).then(e=>({default:e.TrendingNews}))),vn=(0,i.lazy)(()=>import(`education-playlists`).then(e=>({default:e.EducationPlaylists}))),yn=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./DownloadsDialog-CCPj0hA8.cjs"))),bn=15;function xn(e){return e?e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean):[]}function Sn(e){return e?e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(`,`).map(e=>e.trim()),n=Number(t[t.length-2]),r=Number(t[t.length-1]);return t.length>=2&&t[t.length-2]!==``&&t[t.length-1]!==``&&Number.isFinite(n)&&Number.isFinite(r)?{label:t.slice(0,t.length-2).filter(Boolean).join(`, `)||void 0,latitude:n,longitude:r}:{label:e}}):[]}var Cn=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),wn=e=>e.startsWith(`blob:`);function Tn({url:e,src:t}){return Cn(e)?Promise.resolve(!0):new Promise(e=>{let n=new Image;n.decoding=`async`,n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=t})}function En(){let{sendMessage:e}=n.u(),r=n.o(),a=r?e=>r.openPanel(e.url,``,{suggestQuestions:!0}):void 0,[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),[_,y]=(0,i.useState)([]),[b,x]=(0,i.useState)(!0),[S,C]=(0,i.useState)(5),[w,T]=(0,i.useState)(12),[D,O]=(0,i.useState)(`fahrenheit`),[k,A]=(0,i.useState)(null),[j,M]=(0,i.useState)(!0),[N,P]=(0,i.useState)(null),[F,I]=(0,i.useState)(null),[L,R]=(0,i.useState)([]),[z,ee]=(0,i.useState)(`trending`),[B,te]=(0,i.useState)(null),[V,H]=(0,i.useState)(!0),[U,W]=(0,i.useState)(!1),[G,ne]=(0,i.useState)(!1),[re,ie]=(0,i.useState)(!1),ae=t.researchAgentUIConfig.footerLinks.map(e=>e.url===`/#downloads`?{...e,onClick:()=>{g(!0),m(!0)}}:e),oe=k||t.researchAgentUIConfig.trendingNewsApiUrl,se=B?.enabled!==!1,ce=B?.allowUserTopics===!1?[]:L,le=N??B?.maxTopics??6,ue=F??B?.showImages??!0,de=j&&se;(0,i.useEffect)(()=>{let e=t.researchAgentUIConfig.trendingNewsSettingsUrl;if(!e)return;let n=!0;return fetch(e).then(e=>e.ok?e.json():null).then(e=>{n&&e&&te(e)}).catch(()=>{}),()=>{n=!1}},[]),(0,i.useEffect)(()=>{let e=()=>{y(Sn(localStorage.getItem(`weatherLocations`))),x(localStorage.getItem(`showWeatherWidget`)!==`false`),C(Number(localStorage.getItem(`weatherForecastDays`))||5),T(Number(localStorage.getItem(`weatherForecastHours`))||12),O(localStorage.getItem(`weatherTemperatureUnit`)===`celsius`?`celsius`:`fahrenheit`),A(localStorage.getItem(`trendingNewsApiUrl`)),M(localStorage.getItem(`showTrendingNewsWidget`)!==`false`);let e=localStorage.getItem(`trendingNewsMaxTopics`);P(e&&Number(e)||null);let t=localStorage.getItem(`trendingNewsShowImages`);I(t===null?null:t!==`false`),R(xn(localStorage.getItem(`trendingNewsCustomTopics`))),ee(localStorage.getItem(`trendingNewsSource`)===`hckrnews`?`hckrnews`:`trending`),H(localStorage.getItem(`showEducationPlaylistsWidget`)!==`false`),ne(localStorage.getItem(`orbHoverGlow`)===`true`),ie(localStorage.getItem(`cursorGlowTrail`)===`true`)};return e(),window.addEventListener(`client-config-changed`,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(`client-config-changed`,e),window.removeEventListener(`storage`,e)}},[]),(0,i.useEffect)(()=>{let e,t=()=>{if(typeof window.requestIdleCallback==`function`){let t=window.requestIdleCallback(()=>W(!0),{timeout:2500});e=()=>window.cancelIdleCallback(t)}else{let t=window.setTimeout(()=>W(!0),800);e=()=>window.clearTimeout(t)}};return document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0}),()=>{window.removeEventListener(`load`,t),e?.()}},[]),(0,i.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;let e=!1,t,n,r,i=null,a=null,o=new Set,s=e=>(e&&wn(e.src)&&o.add(e.src),e),l=e=>{e&&wn(e.src)&&(URL.revokeObjectURL(e.src),o.delete(e.src))},d=async t=>t?e||!await Tn(t)?(l(t),null):t:null,p=async e=>{if(!e)return null;let t=await mn(e);return d(s(t?{url:e,src:t}:null))},m=async e=>{let t=on().length<10?fn():null;if(t){let e=await hn(t),n=await d(s(e?{url:t,src:e}:null));if(n)return n}return p(dn(e?.url))},h=e=>{let t=i;i=e,t?(u(e),f(!0),n=setTimeout(()=>{c(e),f(!1),u(null),l(t)},1e3)):c(e)},g=!1,_=async()=>{if(document.hidden||g)return;g=!0;let t=await(a??m(i));a=null,g=!1,e||(t&&h(t),a=m(i))},v=p(dn()).then(t=>{t&&!e&&h(t)}),y=()=>{v.then(()=>{e||(i?a=m(i):_(),t=setInterval(_,2e4))})},b=()=>{if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(y,{timeout:3e3});r=()=>window.cancelIdleCallback(e)}else{let e=window.setTimeout(y,1e3);r=()=>window.clearTimeout(e)}};return document.readyState===`complete`?b():window.addEventListener(`load`,b,{once:!0}),()=>{e=!0,window.removeEventListener(`load`,b),r?.(),clearInterval(t),clearTimeout(n);for(let e of o)URL.revokeObjectURL(e)}},[]);let fe=({url:e,src:t},n)=>Cn(e)?(0,o.jsx)(`video`,{src:t,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t):(0,o.jsx)(`img`,{src:t,alt:``,decoding:`async`,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t);return(0,o.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,o.jsxs)(`div`,{className:`absolute inset-0 z-0`,children:[s&&fe(s,d?`opacity-0`:`opacity-30`),l&&fe(l,d?`opacity-30`:`opacity-0`),re&&(0,o.jsx)(E,{})]}),(0,o.jsx)(`div`,{className:`relative z-10`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-end md:justify-center min-h-[calc(100dvh-64px)] md:min-h-screen max-w-screen-sm mx-auto p-2 pb-1 md:pb-2`,children:[(0,o.jsx)(`div`,{style:{height:`160px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},className:G?void 0:`pointer-events-none`,children:(0,o.jsx)(v.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,o.jsxs)(`div`,{className:`w-full max-w-2xl mt-2 space-y-2`,children:[(0,o.jsx)(Jt,{}),(0,o.jsx)(Ot,{}),U&&(V||b||de)&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsxs)(`div`,{className:`flex flex-col gap-2 w-full`,children:[V&&(0,o.jsx)(vn,{planEndpoint:t.researchAgentUIConfig.educationPlaylistsApiUrl||void 0,openHref:t.researchAgentUIConfig.educationPlaylistsPageUrl||void 0,onOpenItem:a,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),de&&(0,o.jsx)(_n,{expandable:!0,maxTopics:le,expandedMaxTopics:bn,showImages:ue,apiEndpoint:oe,topics:ce,source:z,limit:bn,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),b&&(0,o.jsx)(gn,{forecastDays:S,forecastHours:w,temperatureUnit:D,locations:_.length>0?_:void 0,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`}})]})}),(0,o.jsx)(Qt,{listFooterLinks:ae})]})]})}),h&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)(yn,{open:p,onOpenChange:m})}),(0,o.jsx)(en,{})]})}var Dn=()=>(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border fill-secondary animate-spin`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,o.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,o.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]});function On(){return(0,o.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,o.jsxs)(`div`,{className:`max-w-2xl w-full space-y-6 bg-light-secondary dark:bg-dark-secondary rounded-lg p-8 border border-black/10 dark:border-white/10`,children:[(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,o.jsx)(`p`,{className:`text-black/70 dark:text-white/70`,children:`No AI model providers are configured. Add at least one API key to continue.`})]}),(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,o.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,o.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs overflow-x-auto`,children:`apps/qwksearch-web/.env.local`})]}),(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,o.jsx)(`pre`,{className:`block bg-black/10 dark:bg-white/10 rounded p-3 text-xs overflow-x-auto text-black/80 dark:text-white/80`,children:`# Database
|
|
16
|
+
`,type:`button`,"aria-label":`Send message`,children:(0,o.jsx)(R.ArrowUp,{className:`w-4 h-4`})}),(0,o.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,o.jsx)(j,{...ie}),C&&(0,o.jsxs)(`div`,{className:`absolute inset-0 bg-bg-200/90 border-2 border-dashed border-accent rounded-[28px] z-50 flex flex-col items-center justify-center backdrop-blur-sm pointer-events-none`,children:[(0,o.jsx)(R.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,o.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})},kt=200,At=[`message`,`error`,`detail`];function jt(e){return e.length>kt?`${e.slice(0,199).trimEnd()}…`:e}function Mt(e,t){let n=t?`HTTP ${t}`:`Unknown error`;if(typeof e==`string`){let t=e.trim();return!t||t.startsWith(`<`)?n:jt(t)}if(e&&typeof e==`object`){let t=e;for(let e of At){let n=t[e];if(typeof n==`string`&&n.trim())return jt(n.trim())}}return n}var Nt=`qwksearch_pinned_chats`;function Pt(e){let t=e.messages?.[e.messages.length-1],n=t&&`createdAt`in t?t.createdAt:void 0;if(n){let e=new Date(n).getTime();if(!Number.isNaN(e))return new Date(e).toISOString()}return e.createdAt}function Ft(){if(typeof window>`u`)return[];try{let e=localStorage.getItem(Nt);return e?JSON.parse(e):[]}catch{return[]}}function It(e){typeof window<`u`&&localStorage.setItem(Nt,JSON.stringify(e))}function Lt(){let[e,t]=(0,i.useState)([]),[r,a]=(0,i.useState)(!0),[o,s]=(0,i.useState)(!1),[c,u]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(!1),[v,y]=(0,i.useState)([]),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)([]),[w,T]=(0,i.useState)(!1),{isAuthenticated:E,isLoading:D}=n.c(),{incognito:O,setIncognito:k}=n.u();(0,i.useEffect)(()=>{y(Ft())},[]);let A=(0,i.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),y(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return It(n),n})},[]),j=(0,i.useMemo)(()=>[...e].sort((e,t)=>{let n=v.includes(e.id),r=v.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,v]),M=(0,i.useMemo)(()=>b.trim()?S:j,[b,S,j]),N=(0,i.useCallback)(async()=>{if(!D){a(!0);try{if(E){let{data:e,error:n,response:r}=await(0,d.listChats)();if(n&&r?.status===401){let e=U().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:Pt(e)}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${Mt(n,r?.status)}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=U().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e)}}catch(e){console.error(`Failed to fetch chat history:`,e),t([]),l.toast.error(`Failed to load chat history`)}finally{a(!1)}}},[E,D]);(0,i.useEffect)(()=>{N()},[N]);let P=(e,t)=>{e.preventDefault(),e.stopPropagation(),u(t),s(!0)},F=async()=>{if(c){p(!0);try{if(E){let{error:e,response:t}=await(0,d.deleteChatById)({path:{id:c}});if(e)throw Error(`Failed to delete chat: ${Mt(e,t?.status)}`)}else ne(c);t(e=>e.filter(e=>e.id!==c)),l.toast.success(`Chat deleted`)}catch(e){l.toast.error(e.message||`Failed to delete chat`)}finally{s(!1),u(null),p(!1)}}},I=()=>{h(!0)},L=async()=>{_(!0);try{if(E){let{error:e,response:t}=await(0,d.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${Mt(e,t?.status)}`)}else re();t([]),l.toast.success(`All history cleared`)}catch(e){l.toast.error(e.message||`Failed to clear history`)}finally{h(!1),_(!1)}},R=()=>{k(!O),l.toast.success(O?`Private mode off`:`Private mode on — messages won't be saved`)},z=(0,i.useCallback)(async e=>{if(!e.trim())C([]),T(!1);else{T(!0);try{if(E){let{data:t,error:n,response:r}=await(0,d.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${Mt(n,r?.status)}`);C(Array.isArray(t?.chats)?t.chats:[])}else{let t=U().filter(t=>{let n=t.title.toLowerCase().includes(e.toLowerCase()),r=t.messages?.some(t=>`content`in t&&t.content?.toLowerCase().includes(e.toLowerCase()));return n||r});C(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:Pt(e)})))}}catch(e){console.error(`Failed to search chat history:`,e),C([]),l.toast.error(`Failed to search chat history`)}finally{T(!1)}}},[E]);return(0,i.useEffect)(()=>{let e=setTimeout(()=>{z(b)},300);return()=>clearTimeout(e)},[b,z]),{chats:e,sortedChats:j,displayChats:M,loading:r,pinnedIds:v,togglePin:A,incognito:O,toggleIncognito:R,searchQuery:b,searchResults:S,searching:w,handleSearchChange:(0,i.useCallback)(e=>{x(e)},[]),deleteDialogOpen:o,setDeleteDialogOpen:s,chatToDelete:c,setChatToDelete:u,deleting:f,handleDeleteClick:P,handleConfirmDelete:F,clearAllDialogOpen:m,setClearAllDialogOpen:h,clearingAll:g,handleClearAllClick:I,handleConfirmClearAll:L}}function Rt({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,o.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,o.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-2 py-1 text-xs rounded-lg transition-colors duration-200 ${e?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary`}`,title:e?`Private mode on`:`Private mode`,children:[(0,o.jsx)(c.Lock,{size:12}),(0,o.jsx)(`span`,{children:`Private`})]}),n&&(0,o.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors duration-200`,title:`Clear all history`,children:[(0,o.jsx)(c.Trash2,{size:12}),(0,o.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(c.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,o.jsx)(`input`,{type:`text`,placeholder:`Search chats...`,value:i,onChange:e=>a(e.target.value),className:`w-full pl-7 pr-7 py-1.5 text-sm bg-secondary/50 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 placeholder:text-muted-foreground/50`}),i&&(0,o.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,o.jsx)(c.X,{size:14})})]})]})}var zt=(0,_.cva)(`inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,new:`text-purple-600 dark:text-purple-300 bg-purple-600/30 dark:bg-purple-600/30`,beta:`text-blue-600 dark:text-blue-300 bg-blue-600/30 dark:bg-blue-600/30`,highlight:`text-green-800 dark:text-green-300 bg-green-600/30 dark:bg-green-600/30`}},defaultVariants:{variant:`default`}});function Bt({className:e,variant:t,asChild:n=!1,...i}){return(0,o.jsx)(n?g.Slot:`span`,{"data-slot":`badge`,className:r.o(zt({variant:t}),e),...i})}function Vt({chat:e,isPinned:n,onTogglePin:i,onDelete:a}){let s=e.messageCount??0;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,o.jsxs)(h.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,o.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[s>0&&(0,o.jsxs)(Bt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md`,children:[s,`Q`]}),(0,o.jsx)(Bt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md`,children:r.c(new Date,e.createdAt)})]}),(0,o.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[n&&(0,o.jsx)(c.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,o.jsx)(`button`,{onClick:t=>i(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${n?`opacity-100 text-primary hover:bg-primary/10`:`opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10`}`,title:n?`Unpin chat`:`Pin chat`,children:(0,o.jsx)(c.Pin,{size:14})}),(0,o.jsx)(`button`,{onClick:t=>a(t,e.id),className:`opacity-0 group-hover:opacity-100 p-1.5 rounded-lg hover:bg-red-500/10 text-muted-foreground hover:text-red-500 transition-all duration-200`,title:`Delete chat`,children:(0,o.jsx)(c.Trash,{size:14})})]})}function Ht({open:e,onOpenChange:t,title:n,description:i,confirmLabel:a,loadingLabel:s,loading:c,onConfirm:l}){return(0,o.jsx)(r.t,{open:e,onOpenChange:e=>{!e&&!c&&t(!1)},children:(0,o.jsxs)(r.n,{className:`w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl`,children:[(0,o.jsx)(r.i,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,o.jsx)(r.r,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:i}),(0,o.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,o.jsx)(`button`,{onClick:()=>{c||t(!1)},className:`text-black/50 dark:text-white/50 text-sm hover:text-black/70 hover:dark:text-white/70 transition duration-200`,children:`Cancel`}),(0,o.jsx)(`button`,{onClick:l,disabled:c,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:c?s:a})]})]})})}function Ut({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:s,setClearAllDialogOpen:c,clearingAll:l,onConfirmClearAll:u}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ht,{open:e,onOpenChange:e=>{t(e),e||r(null)},title:`Delete Confirmation`,description:`Are you sure you want to delete this chat?`,confirmLabel:`Delete`,loadingLabel:`Deleting...`,loading:i,onConfirm:a}),(0,o.jsx)(Ht,{open:s,onOpenChange:c,title:`Clear All History`,description:`Are you sure you want to delete all your chat history? This action cannot be undone.`,confirmLabel:`Clear All`,loadingLabel:`Clearing...`,loading:l,onConfirm:u})]})}var Wt={Today:(0,o.jsx)(c.Sun,{size:12}),Yesterday:(0,o.jsx)(c.Clock,{size:12}),"This Week":(0,o.jsx)(c.CalendarDays,{size:12}),Older:(0,o.jsx)(c.Archive,{size:12})};function Gt(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-5184e5),a={Today:[],Yesterday:[],"This Week":[],Older:[]};for(let t of e){let e=new Date(t.createdAt);e>=n?a.Today.push(t):e>=r?a.Yesterday.push(t):e>=i?a[`This Week`].push(t):a.Older.push(t)}return[`Today`,`Yesterday`,`This Week`,`Older`].filter(e=>a[e].length>0).map(e=>({label:e,chats:a[e]}))}var Kt=({showLabel:e=!1})=>{let t=Lt();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(r.t,{children:[(0,o.jsxs)(r.a,{className:e?`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150`:`p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30`,children:[(0,o.jsx)(c.History,{size:e?14:18}),e&&(0,o.jsx)(`span`,{children:`History`})]}),(0,o.jsxs)(r.n,{className:`max-w-[420px] p-3`,children:[(0,o.jsx)(r.i,{className:`sr-only`,children:`Chat History`}),(0,o.jsx)(Rt,{incognito:t.incognito,onToggleIncognito:t.toggleIncognito,showClearAll:t.chats.length>0&&!t.loading,onClearAll:t.handleClearAllClick,searchQuery:t.searchQuery,onSearchChange:t.handleSearchChange}),t.loading||t.searching?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-6 h-6 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,o.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,o.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]})}):t.searchQuery.trim()&&t.displayChats.length===0?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,o.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,o.jsx)(Vt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):Gt(t.displayChats).map(({label:e,chats:n})=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider`,children:[Wt[e],e]}),n.map(e=>(0,o.jsx)(Vt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,o.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,o.jsx)(h.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,o.jsx)(Ut,{deleteDialogOpen:t.deleteDialogOpen,setDeleteDialogOpen:t.setDeleteDialogOpen,chatToDelete:t.chatToDelete,setChatToDelete:t.setChatToDelete,deleting:t.deleting,onConfirmDelete:t.handleConfirmDelete,clearAllDialogOpen:t.clearAllDialogOpen,setClearAllDialogOpen:t.setClearAllDialogOpen,clearingAll:t.clearingAll,onConfirmClearAll:t.handleConfirmClearAll})]})},qt=e=>new Date(e.lastMessageAt||e.createdAt).getTime();function Jt(){let{chats:e,loading:n}=Lt(),r=[...e].sort((e,t)=>qt(t)-qt(e)).slice(0,5);return n||r.length===0?null:(0,o.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,o.jsx)(Kt,{showLabel:!0}),r.map(e=>{let n=at(e.lastMessageAt||e.createdAt);return(0,o.jsxs)(h.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 max-w-[220px]`,title:e.title,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.title}),n&&(0,o.jsx)(`span`,{className:`italic text-muted-foreground/70 whitespace-nowrap`,children:n})]},e.id)})]})}var Yt={Bot:c.Bot,BookOpen:c.BookOpen,Building2:c.Building2,Download:c.Download,HelpCircle:c.HelpCircle,Info:c.Info,Lock:c.Lock,Mail:c.Mail,MessageCircle:c.MessageCircle,Newspaper:c.Newspaper,Sparkles:c.Sparkles};function Xt({name:e}){let t=Yt[e];return t?(0,o.jsx)(t,{size:14}):null}var Zt=`relative group inline-flex items-center gap-1 px-[3px] sm:px-1.5 py-0.5 rounded-md whitespace-nowrap transition-all duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] hover:text-white hover:bg-white/10 hover:-translate-y-0.5 hover:scale-110 hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] active:scale-95 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/60`;function Qt({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:n=`bg-black/40`}){return e.length===0?null:(0,o.jsx)(`nav`,{"aria-label":`Footer`,className:`relative z-20 mx-auto flex w-max flex-nowrap items-center justify-center gap-0 sm:gap-1 max-w-full text-slate-200 ${n} backdrop-blur-sm rounded-full px-1 sm:px-1.5 py-0.5 shadow-lg hover:shadow-xl transition-shadow duration-300`,children:e.map(({url:e,text:n,icon:r,onClick:i})=>{let a=e.startsWith(`http`),s=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,o.jsxs)(o.Fragment,{children:[t&&r&&(0,o.jsx)(`span`,{className:`hidden sm:inline-flex transition-transform duration-300 group-hover:-rotate-12 group-hover:scale-125`,children:(0,o.jsx)(Xt,{name:r})}),(0,o.jsx)(`span`,{className:`font-semibold tracking-wide text-[11px] sm:text-xs`,style:{fontVariant:`small-caps`},children:n}),(0,o.jsx)(`span`,{className:`absolute bottom-0 left-1/2 w-0 h-px -translate-x-1/2 bg-current transition-all duration-300 group-hover:w-3/4 group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return i?(0,o.jsx)(`button`,{type:`button`,onClick:i,className:Zt,children:c},e):a?(0,o.jsx)(`a`,{href:e,...s,className:Zt,children:c},e):(0,o.jsx)(h.default,{href:e,className:Zt,children:c},e)})})}var $t=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./ArticleExtractPanel-BIQb3d3o.cjs")));function en(){let e=n.o()?.isOpen??!1,[t,r]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{e&&r(!0)},[e]),!t&&!e?null:(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)($t,{})})}var tn=`hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg`.split(`,`).map(e=>`https://i.imgur.com/`+e),nn=`qwksearch-background-art-v1`,rn=`backgroundArtCache`,an=e=>typeof e==`string`&&tn.includes(e);function on(){try{let e=JSON.parse(localStorage.getItem(`backgroundArtCache`)||`[]`);return Array.isArray(e)?[...new Set(e.filter(an))]:[]}catch{return[]}}function sn(e){try{localStorage.setItem(rn,JSON.stringify(e))}catch{}}function cn(e){let t=on().filter(t=>t!==e);t.push(e);let n=t.splice(0,Math.max(0,t.length-10));return sn(t),n}function ln(e){sn(on().filter(t=>t!==e))}var un=e=>e.length?e[Math.floor(Math.random()*e.length)]:null;function dn(e){return un(on().filter(t=>t!==e))}function fn(){let e=new Set(on());return un(tn.filter(t=>!e.has(t)))}async function pn(){if(typeof caches>`u`)return null;try{return await caches.open(nn)}catch{return null}}async function mn(e){let t=await pn();if(!t)return null;try{let n=await t.match(e);return n?URL.createObjectURL(await n.blob()):(ln(e),null)}catch{return null}}async function hn(e){let t=await pn();if(!t)return e;let n;try{let t=await fetch(e,{mode:`cors`,credentials:`omit`});if(!t.ok)return null;n=await t.blob()}catch{return e}if(n.size<=15728640)try{await t.put(e,new Response(n,{headers:{"Content-Type":n.type}}));let r=cn(e);await Promise.all(r.map(e=>t.delete(e)))}catch{}return URL.createObjectURL(n)}var gn=(0,i.lazy)(()=>import(`use-weather-forecast`).then(e=>({default:e.WeatherForecast}))),_n=(0,i.lazy)(()=>import(`trending-news-api`).then(e=>({default:e.TrendingNews}))),vn=(0,i.lazy)(()=>import(`education-playlists`).then(e=>({default:e.EducationPlaylists}))),yn=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./DownloadsDialog-CCPj0hA8.cjs"))),bn=15;function xn(e){return e?e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean):[]}function Sn(e){return e?e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(`,`).map(e=>e.trim()),n=Number(t[t.length-2]),r=Number(t[t.length-1]);return t.length>=2&&t[t.length-2]!==``&&t[t.length-1]!==``&&Number.isFinite(n)&&Number.isFinite(r)?{label:t.slice(0,t.length-2).filter(Boolean).join(`, `)||void 0,latitude:n,longitude:r}:{label:e}}):[]}var Cn=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),wn=e=>e.startsWith(`blob:`);function Tn({url:e,src:t}){return Cn(e)?Promise.resolve(!0):new Promise(e=>{let n=new Image;n.decoding=`async`,n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=t})}function En(){let{sendMessage:e}=n.u(),r=n.o(),a=r?e=>r.openPanel(e.url,``,{suggestQuestions:!0}):void 0,[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),[_,y]=(0,i.useState)([]),[b,x]=(0,i.useState)(!0),[S,C]=(0,i.useState)(5),[w,T]=(0,i.useState)(12),[D,O]=(0,i.useState)(`fahrenheit`),[k,A]=(0,i.useState)(null),[j,M]=(0,i.useState)(!0),[N,P]=(0,i.useState)(null),[F,I]=(0,i.useState)(null),[L,R]=(0,i.useState)([]),[z,ee]=(0,i.useState)(`trending`),[B,te]=(0,i.useState)(null),[V,H]=(0,i.useState)(!0),[U,W]=(0,i.useState)(!1),[G,ne]=(0,i.useState)(!1),[re,ie]=(0,i.useState)(!1),ae=t.researchAgentUIConfig.footerLinks.map(e=>e.url===`/#downloads`?{...e,onClick:()=>{g(!0),m(!0)}}:e),oe=k||t.researchAgentUIConfig.trendingNewsApiUrl,se=B?.enabled!==!1,ce=B?.allowUserTopics===!1?[]:L,le=N??B?.maxTopics??6,ue=F??B?.showImages??!0,de=j&&se;(0,i.useEffect)(()=>{let e=t.researchAgentUIConfig.trendingNewsSettingsUrl;if(!e)return;let n=!0;return fetch(e).then(e=>e.ok?e.json():null).then(e=>{n&&e&&te(e)}).catch(()=>{}),()=>{n=!1}},[]),(0,i.useEffect)(()=>{let e=()=>{y(Sn(localStorage.getItem(`weatherLocations`))),x(localStorage.getItem(`showWeatherWidget`)!==`false`),C(Number(localStorage.getItem(`weatherForecastDays`))||5),T(Number(localStorage.getItem(`weatherForecastHours`))||12),O(localStorage.getItem(`weatherTemperatureUnit`)===`celsius`?`celsius`:`fahrenheit`),A(localStorage.getItem(`trendingNewsApiUrl`)),M(localStorage.getItem(`showTrendingNewsWidget`)!==`false`);let e=localStorage.getItem(`trendingNewsMaxTopics`);P(e&&Number(e)||null);let t=localStorage.getItem(`trendingNewsShowImages`);I(t===null?null:t!==`false`),R(xn(localStorage.getItem(`trendingNewsCustomTopics`))),ee(localStorage.getItem(`trendingNewsSource`)===`hckrnews`?`hckrnews`:`trending`),H(localStorage.getItem(`showEducationPlaylistsWidget`)!==`false`),ne(localStorage.getItem(`orbHoverGlow`)===`true`),ie(localStorage.getItem(`cursorGlowTrail`)===`true`)};return e(),window.addEventListener(`client-config-changed`,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(`client-config-changed`,e),window.removeEventListener(`storage`,e)}},[]),(0,i.useEffect)(()=>{let e,t=()=>{if(typeof window.requestIdleCallback==`function`){let t=window.requestIdleCallback(()=>W(!0),{timeout:2500});e=()=>window.cancelIdleCallback(t)}else{let t=window.setTimeout(()=>W(!0),800);e=()=>window.clearTimeout(t)}};return document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0}),()=>{window.removeEventListener(`load`,t),e?.()}},[]),(0,i.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;let e=!1,t,n,r,i=null,a=null,o=new Set,s=e=>(e&&wn(e.src)&&o.add(e.src),e),l=e=>{e&&wn(e.src)&&(URL.revokeObjectURL(e.src),o.delete(e.src))},d=async t=>t?e||!await Tn(t)?(l(t),null):t:null,p=async e=>{if(!e)return null;let t=await mn(e);return d(s(t?{url:e,src:t}:null))},m=async e=>{let t=on().length<10?fn():null;if(t){let e=await hn(t),n=await d(s(e?{url:t,src:e}:null));if(n)return n}return p(dn(e?.url))},h=e=>{let t=i;i=e,t?(u(e),f(!0),n=setTimeout(()=>{c(e),f(!1),u(null),l(t)},1e3)):c(e)},g=!1,_=async()=>{if(document.hidden||g)return;g=!0;let t=await(a??m(i));a=null,g=!1,e||(t&&h(t),a=m(i))},v=p(dn()).then(t=>{t&&!e&&h(t)}),y=()=>{v.then(()=>{e||(i?a=m(i):_(),t=setInterval(_,2e4))})},b=()=>{if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(y,{timeout:3e3});r=()=>window.cancelIdleCallback(e)}else{let e=window.setTimeout(y,1e3);r=()=>window.clearTimeout(e)}};return document.readyState===`complete`?b():window.addEventListener(`load`,b,{once:!0}),()=>{e=!0,window.removeEventListener(`load`,b),r?.(),clearInterval(t),clearTimeout(n);for(let e of o)URL.revokeObjectURL(e)}},[]);let fe=({url:e,src:t},n)=>Cn(e)?(0,o.jsx)(`video`,{src:t,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t):(0,o.jsx)(`img`,{src:t,alt:``,decoding:`async`,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t);return(0,o.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,o.jsxs)(`div`,{className:`absolute inset-0 z-0`,children:[s&&fe(s,d?`opacity-0`:`opacity-30`),l&&fe(l,d?`opacity-30`:`opacity-0`),re&&(0,o.jsx)(E,{})]}),(0,o.jsx)(`div`,{className:`relative z-10`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-end md:justify-center min-h-[calc(100dvh-64px)] md:min-h-screen max-w-screen-sm mx-auto p-2 pb-1 md:pb-2`,children:[(0,o.jsx)(`div`,{style:{height:`160px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},className:G?void 0:`pointer-events-none`,children:(0,o.jsx)(v.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,o.jsxs)(`div`,{className:`w-full max-w-2xl mt-2 space-y-2`,children:[(0,o.jsx)(Jt,{}),(0,o.jsx)(Ot,{}),U&&(V||b||de)&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsxs)(`div`,{className:`flex flex-col gap-2 w-full`,children:[V&&(0,o.jsx)(vn,{planEndpoint:t.researchAgentUIConfig.educationPlaylistsApiUrl||void 0,openHref:t.researchAgentUIConfig.educationPlaylistsPageUrl||void 0,onOpenItem:a,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),de&&(0,o.jsx)(_n,{expandable:!0,maxTopics:le,expandedMaxTopics:bn,showImages:ue,apiEndpoint:oe,topics:ce,source:z,limit:bn,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),b&&(0,o.jsx)(gn,{forecastDays:S,forecastHours:w,temperatureUnit:D,locations:_.length>0?_:void 0,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`}})]})}),(0,o.jsx)(Qt,{listFooterLinks:ae})]})]})}),h&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)(yn,{open:p,onOpenChange:m})}),(0,o.jsx)(en,{})]})}var Dn=()=>(0,o.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border fill-secondary animate-spin`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,o.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,o.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]});function On(){return(0,o.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,o.jsxs)(`div`,{className:`max-w-2xl w-full space-y-6 bg-light-secondary dark:bg-dark-secondary rounded-lg p-8 border border-black/10 dark:border-white/10`,children:[(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,o.jsx)(`p`,{className:`text-black/70 dark:text-white/70`,children:`No AI model providers are configured. Add at least one API key to continue.`})]}),(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,o.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,o.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs overflow-x-auto`,children:`apps/qwksearch-web/.env.local`})]}),(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,o.jsx)(`pre`,{className:`block bg-black/10 dark:bg-white/10 rounded p-3 text-xs overflow-x-auto text-black/80 dark:text-white/80`,children:`# Database
|
|
17
17
|
DATABASE_URL=file:./data/qwksearch.db
|
|
18
18
|
|
|
19
19
|
# Auth (generate: openssl rand -base64 32)
|
|
@@ -31,4 +31,4 @@ OPENAI_API_KEY=sk-your_key_here
|
|
|
31
31
|
OPENAI_BASE_URL=https://api.openai.com/v1
|
|
32
32
|
|
|
33
33
|
# Or Anthropic
|
|
34
|
-
ANTHROPIC_API_KEY=sk-ant-your_key_here`})]}),(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`3. Restart the server`}),(0,o.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs`,children:`Ctrl+C, then: npm run dev`})]})]}),(0,o.jsxs)(`div`,{className:`pt-4 border-t border-black/10 dark:border-white/10`,children:[(0,o.jsx)(`h3`,{className:`font-medium text-black dark:text-white mb-2`,children:`Get API Keys:`}),(0,o.jsxs)(`ul`,{className:`space-y-2 text-sm text-black/70 dark:text-white/70`,children:[(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Groq`}),` (FREE): `,(0,o.jsx)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.groq.com/keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`OpenAI`}),`: `,(0,o.jsx)(`a`,{href:`https://platform.openai.com/api-keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`platform.openai.com/api-keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Anthropic`}),`: `,(0,o.jsx)(`a`,{href:`https://console.anthropic.com/settings/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.anthropic.com`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`text-xs text-black/50 dark:text-white/50 pt-4 border-t border-black/10 dark:border-white/10`,children:[`See `,(0,o.jsx)(`code`,{children:`SETUP_INSTRUCTIONS.md`}),` in the project root for full details.`]})]})})}var kn=()=>Promise.resolve().then(()=>require("./ChatConversationThread-CNCj2kLC.cjs")),An=(0,i.lazy)(kn),jn=()=>{let e=(0,a.useRouter)(),{hasError:t,isReady:r,notFound:s,messages:c}=n.u(),{isAuthenticated:l}=n.c(),u=r&&!s&&c.length===0;return(0,i.useEffect)(()=>{if(!u)return;if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(()=>void kn(),{timeout:5e3});return()=>window.cancelIdleCallback(e)}let e=window.setTimeout(()=>void kn(),3e3);return()=>window.clearTimeout(e)},[u]),(0,i.useEffect)(()=>{r&&s&&!l&&e.replace(`/`)},[r,s,l,e]),t?(0,o.jsx)(On,{}):r&&s&&!l?(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})}):r?s?(0,o.jsxs)(`div`,{className:`flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,o.jsx)(`p`,{className:`text-sm text-black/70 dark:text-white/70`,children:`This chat could not be found.`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>e.push(`/`),className:`rounded-md border border-black/15 px-3 py-1.5 text-sm hover:bg-black/5 dark:border-white/20 dark:hover:bg-white/10`,children:`Go Home`})]}):(0,o.jsx)(`div`,{children:c.length>0?(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})}),children:(0,o.jsx)(An,{})})}):(0,o.jsx)(En,{})}):(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})})},Mn=`https://qwksearch.com`,Nn=null,Pn=Mn,Fn=!1;function In(e,t){let n;n=typeof e==`string`?e:e instanceof URL?e.href:e.url;try{let e=typeof window<`u`?window.location.href:t,r=new URL(n,e);return r.origin===t&&r.pathname.startsWith(`/api/`)}catch{return!1}}function Ln(){if(Fn||typeof window>`u`||typeof window.fetch!=`function`)return;Fn=!0;let e=window.fetch.bind(window);window.fetch=(t,n)=>{if(!Nn||!In(t,Pn))return e(t,n);let r=new Headers(n?.headers??(t instanceof Request?t.headers:void 0));return!r.has(`x-api-key`)&&!r.has(`authorization`)&&r.set(`X-API-Key`,Nn),e(t,{...n,headers:r})}}function Rn(e,t=Mn){Nn=e||null,Pn=t.replace(/\/+$/,``),Nn&&Ln()}function zn(){return Nn}function Bn(e,t){let n=t??(typeof window<`u`?`${window.location.pathname}${window.location.search}`:`/`);return`${e}${e.includes(`?`)?`&`:`?`}returnTo=${encodeURIComponent(n)}`}function Vn(e){let t=e.qwksearchOrigin??`https://qwksearch.com`,n={connected:!1},r=new Set,i=i=>{n=i,Rn(i.connected?i.apiKey??null:null,t),e.onSession?.(i),r.forEach(e=>e())},a=null,o=()=>(a??=fetch(e.sessionUrl,{credentials:`same-origin`,headers:{Accept:`application/json`}}).then(async e=>e.ok?await e.json():{connected:!1}).catch(()=>({connected:!1})).then(e=>(i(e),e)).finally(()=>{a=null}),a);return{getCachedSession:()=>n,refresh:o,subscribe:e=>(r.add(e),()=>r.delete(e)),getSession:async()=>{let e=await o();return{data:e.connected&&e.user?{user:e.user}:null}},oneTap:e=>{},signIn:{social:t=>{typeof window<`u`&&window.location.assign(Bn(e.connectUrl))}},signOut:async t=>{try{await fetch(e.disconnectUrl,{method:`POST`,credentials:`same-origin`})}finally{i({connected:!1}),t?.fetchOptions?.onSuccess?.()}return{data:null}}}}var Hn=({onClose:e})=>(0,o.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,o.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,o.jsx)(c.X,{className:`h-5 w-5`})})}),Un=(0,_.cva)(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border-[1.5px] bg-background hover:bg-accent hover:text-accent-foreground dark:bg-card dark:hover:bg-card/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 px-6 has-[>svg]:px-4`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function Z({className:e,variant:t,size:n,asChild:i=!1,...a}){return(0,o.jsx)(i?g.Slot:`button`,{"data-slot":`button`,className:r.o(Un({variant:t,size:n,className:e})),...a})}var Wn={ask:{alt:!0,key:`a`},suggest:{alt:!0,key:`s`},copy:{alt:!0,key:`c`},highlight:{alt:!0,key:`h`},favorite:{alt:!0,key:`f`},open:{alt:!0,key:`o`},zoomOut:{alt:!0,key:`-`},zoomReset:{alt:!0,key:`0`},zoomIn:{alt:!0,key:`=`},close:{alt:!1,key:`Escape`}},Gn=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||``);function Kn(e){let{alt:t,key:n}=Wn[e],r=n===`Escape`?`Esc`:n.length===1?n.toUpperCase():n;return t?Gn?`⌥${r}`:`Alt+${r}`:r}var qn=r.o(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),Q=({label:e,action:t,children:r})=>(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:r}),(0,o.jsx)(n.n,{side:`bottom`,children:(0,o.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(`span`,{children:e}),t&&(0,o.jsx)(`kbd`,{className:`rounded bg-primary-foreground/20 px-1 py-0.5 text-[10px] font-semibold leading-none tracking-wide`,children:Kn(t)})]})})]}),Jn=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:i,isHighlightMode:a,articleUrl:s,fontScale:l,onAskClick:u,onSuggestClick:d,onCopyClick:f,onShareClick:p,onFavoriteClick:m,onHighlightToggle:h,onZoomIn:g,onZoomOut:_,onZoomReset:v,onClose:y})=>{let b=g||_,x=Math.round((l??1)*100);return(0,o.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,o.jsx)(Q,{label:`Ask AI about this article`,action:`ask`,children:(0,o.jsxs)(Z,{onClick:u,disabled:e,variant:`ghost`,size:`sm`,className:r.o(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,o.jsx)(c.Bot,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]})}),(0,o.jsx)(Q,{label:`Suggest follow-up questions`,action:`suggest`,children:(0,o.jsxs)(Z,{onClick:d,disabled:t,variant:`ghost`,size:`sm`,className:r.o(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,o.jsx)(c.MessageCircleQuestion,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]})}),(0,o.jsx)(Q,{label:`Copy article`,action:`copy`,children:(0,o.jsx)(Z,{onClick:f,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(c.Clipboard,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Share article`,children:(0,o.jsx)(Z,{onClick:p,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(c.Share2,{className:`size-4`})})}),(0,o.jsx)(Q,{label:a?`Disable highlighting`:`Enable highlighting`,action:`highlight`,children:(0,o.jsx)(Z,{onClick:h,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,a?`text-yellow-500 bg-yellow-50 dark:bg-yellow-950/30 hover:bg-yellow-100 dark:hover:bg-yellow-950/50`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,o.jsx)(c.Highlighter,{className:`size-4`})})}),(0,o.jsx)(Q,{label:i?`Remove from favorites`:`Add to favorites`,action:`favorite`,children:(0,o.jsx)(Z,{onClick:m,disabled:n,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,i?`text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-950/30`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,o.jsx)(c.Star,{className:r.o(`size-4`,i&&`fill-yellow-400`)})})}),s&&(0,o.jsx)(Q,{label:`Open in new tab`,action:`open`,children:(0,o.jsx)(Z,{asChild:!0,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,children:(0,o.jsx)(c.ExternalLink,{className:`size-4`})})})}),b&&(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 rounded-xl border border-muted/60 bg-muted/20 px-1`,children:[(0,o.jsx)(Q,{label:`Zoom out`,action:`zoomOut`,children:(0,o.jsx)(Z,{onClick:_,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(c.ZoomOut,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Reset zoom`,action:`zoomReset`,children:(0,o.jsxs)(`button`,{type:`button`,onClick:v,className:`min-w-[3rem] rounded-md px-1 text-center text-xs font-medium tabular-nums text-muted-foreground transition-colors hover:text-foreground`,children:[x,`%`]})}),(0,o.jsx)(Q,{label:`Zoom in`,action:`zoomIn`,children:(0,o.jsx)(Z,{onClick:g,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(c.ZoomIn,{className:`size-4`})})})]}),(0,o.jsx)(Q,{label:`Close`,action:`close`,children:(0,o.jsx)(Z,{onClick:y,variant:`ghost`,size:`icon`,className:r.o(qn,!b&&`ml-auto`),children:(0,o.jsx)(c.X,{className:`size-4`})})})]})},Yn=({value:e,onChange:t,onSubmit:n})=>(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n(),type:`text`,placeholder:`Ask AI any question...`,className:`w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),Xn=({questions:e,isLoading:n,error:r,onQuestionClick:a})=>{let s=i.default.useMemo(()=>{let t=[];return e.forEach(e=>{e.includes(`?`)&&e.split(`?`).length>2?e.split(`?`).map(e=>e.trim()).filter(Boolean).forEach(e=>{t.push(e.endsWith(`?`)?e:`${e}?`)}):t.push(e)}),t},[e]);return(0,o.jsxs)(o.Fragment,{children:[s.length>0&&(0,o.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,o.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsx)(`div`,{onClick:()=>a(t.researchAgentUIConfig.defaultSummarizePrompt),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-primary/30 transition-all hover:border-primary shadow-sm hover:shadow-md`,children:t.researchAgentUIConfig.defaultSummarizePrompt}),s.map((e,t)=>(0,o.jsx)(`div`,{onClick:()=>a(e),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-border transition-all hover:border-primary shadow-sm hover:shadow-md`,dangerouslySetInnerHTML:{__html:e}},t))]})]}),n&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),r&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:r})]})},Zn=({response:e,isLoading:t,error:n})=>(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,o.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Qn=({html:e,isHighlightMode:t=!1,fontScale:n=1})=>{let[r,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{a(y.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,o.jsx)(`div`,{className:[`prose prose-neutral dark:prose-invert max-w-none`,`prose-p:leading-[1.9] prose-li:leading-[1.9] prose-p:my-5 prose-li:my-1.5`,`prose-headings:font-semibold prose-headings:tracking-tight prose-headings:leading-snug`,`prose-h1:mt-8 prose-h2:mt-8 prose-h3:mt-6`,`prose-blockquote:leading-[1.8] prose-blockquote:border-l-2`,`prose-img:rounded-lg prose-img:my-6`,t?`select-text`:``].join(` `),style:{fontSize:`${n}em`,fontFamily:`ui-serif, Georgia, Cambria, "Times New Roman", Times, serif`},dangerouslySetInnerHTML:{__html:r}})},$n=({article:e,isHighlightMode:t,fontScale:n=1})=>(0,o.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.cite&&(0,o.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,o.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,o.jsx)(`div`,{id:`article-content`,children:(0,o.jsx)(Qn,{html:e.html||``,isHighlightMode:t,fontScale:n})})]})}),er=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,tr=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function nr(e){return e.includes(`](`)||e.includes(`)[`)?!1:/\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e)}function rr(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function ir(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(tr.lastIndex=0;(r=tr.exec(t))!==null;){let e=r[0],i=r.index,a=t.substring(0,i),o=t.substring(i+e.length);!a.endsWith(`](`)&&!o.startsWith(`)`)&&n.push({email:e,index:i})}for(let e=n.length-1;e>=0;e--){let{email:r,index:i}=n[e];t=t.substring(0,i)+`[${r}](mailto:${r})`+t.substring(i+r.length)}let i=[],a;for(er.lastIndex=0;(a=er.exec(t))!==null;){let e=a[0],n=a.index;if(tr.test(e))continue;let r=t.substring(0,n),o=t.substring(n+e.length);if(r.endsWith(`](`)||o.startsWith(`)`)||(r.match(/```/g)||[]).length%2!=0)continue;let s=r.lastIndexOf("`");if(s!==-1){let e=t.substring(s+1).indexOf("`");if(e!==-1&&e>n-s-1)continue}nr(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=rr(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function ar(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function or(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function sr({code:e}){let[t,n]=(0,i.useState)(!1),a=(0,i.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]);return(0,o.jsx)(`button`,{onClick:a,className:r.o(`absolute top-3 right-3 p-1.5 rounded-md`,`opacity-0 group-hover:opacity-100 transition-opacity duration-150`,`bg-zinc-200/80 hover:bg-zinc-300 dark:bg-zinc-700/80 dark:hover:bg-zinc-600`,`text-zinc-600 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,`focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500`),"aria-label":t?`Copied!`:`Copy code`,children:t?(0,o.jsx)(c.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,o.jsx)(c.Copy,{className:`h-4 w-4`})})}function cr({children:e}){let t=(0,i.useRef)(null),[n,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;a(t.trim())}}},[e]),(0,o.jsxs)(`div`,{className:`relative group my-5`,children:[(0,o.jsx)(`pre`,{ref:t,className:r.o(`p-4 rounded-xl overflow-x-auto`,`bg-zinc-100 dark:bg-zinc-900`,`border border-zinc-200 dark:border-zinc-800`,`text-[13px] font-mono leading-relaxed`,`text-zinc-800 dark:text-zinc-200`,`[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0`),children:e}),n&&(0,o.jsx)(sr,{code:n})]})}var lr=i.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,o.jsx)(`div`,{className:r.o(`text-muted-foreground text-sm`,t),children:`No content`});let i=ir(e);return(0,o.jsx)(`div`,{className:r.o(`kortix-markdown`,t),children:(0,o.jsx)(b.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,o.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground mt-8 mb-4 first:mt-0 pb-2 border-b border-border/40`,children:e}),h2:({children:e})=>(0,o.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,o.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,o.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,o.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,o.jsx)(`h6`,{className:`text-sm font-medium text-muted-foreground mt-4 mb-1 first:mt-0 uppercase tracking-wide`,children:e}),p:({children:e})=>(0,o.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed my-4 first:mt-0 last:mb-0 [&:has(img)]:my-0`,children:e}),ul:({children:e})=>(0,o.jsx)(`ul`,{className:`my-4 ml-6 list-disc marker:text-muted-foreground/60 space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),ol:({children:e})=>(0,o.jsx)(`ol`,{className:`my-4 ml-6 list-decimal marker:text-muted-foreground/60 marker:font-medium space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),li:({children:e})=>(0,o.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=ar(e),i=e?.startsWith(`#`),a=r.o(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return i?(0,o.jsx)(`a`,{href:e,onClick:t=>or(t,e),className:a,children:t}):n?(0,o.jsx)(h.default,{href:e||`#`,className:a,children:t}):(0,o.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,o.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,o.jsx)(`code`,{className:`px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground`,children:e}),pre:({children:e})=>(0,o.jsx)(cr,{children:e}),blockquote:({children:e})=>(0,o.jsx)(`blockquote`,{className:r.o(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,o.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,o.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,o.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,o.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,o.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,o.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,o.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,o.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,o.jsxs)(`span`,{className:`block my-5`,children:[(0,o.jsx)(`img`,{src:e,alt:t||``,className:r.o(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,o.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,o.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,o.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,o.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,o.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:r.o(`mr-2 h-4 w-4 rounded border-border`,`accent-secondary cursor-default`,`align-middle relative -top-[1px]`),...t}),div:({children:e,style:t,className:n,...i})=>(0,o.jsx)(`div`,{className:r.o(`text-sm text-foreground`,n),style:t,...i,children:e}),span:({children:e,style:t,className:n,...i})=>(0,o.jsx)(`span`,{className:r.o(`text-foreground`,n),style:t,...i,children:e})},children:i})})});lr.displayName=`UnifiedMarkdown`;var ur=(0,i.createContext)(null),dr=`qwksearch-main-view`;function fr({children:e,docsEnabled:t=!0}){let[n,r]=(0,i.useState)(`research`),[a,s]=(0,i.useState)(0),c=(0,i.useCallback)(e=>r(t?e:`research`),[t]);(0,i.useEffect)(()=>{if(typeof window>`u`||!t)return;let e=window.localStorage.getItem(dr);(e===`research`||e===`docs`)&&r(e)},[t]),(0,i.useEffect)(()=>{typeof window<`u`&&t&&window.localStorage.setItem(dr,n)},[n,t]);let l=(0,i.useMemo)(()=>({activeView:n,setActiveView:c,docsEnabled:t,toggleToDocs:()=>c(`docs`),toggleToResearch:()=>c(`research`),filesSidebarRequestId:a,requestFilesSidebar:()=>s(e=>e+1)}),[n,c,t,a]);return(0,o.jsx)(ur.Provider,{value:l,children:e})}var pr=Object.freeze({activeView:`research`,setActiveView:()=>{},docsEnabled:!1,toggleToDocs:()=>{},toggleToResearch:()=>{},filesSidebarRequestId:0,requestFilesSidebar:()=>{}}),mr=!1;function hr(){return(0,i.useContext)(ur)||(!mr&&process.env.NODE_ENV!==`production`&&(mr=!0,console.error(`useMainView was called outside a MainViewProvider. The component is rendering with view switching disabled — mount it inside MainViewProvider (see QwkSearchProviders).`)),pr)}var gr=[{key:`account`,name:`Account`,description:`Manage your profile, password, and linked accounts.`,icon:`UserCircle`,dataAdd:`account`},{key:`models`,name:`Language Models`,description:`Connect to AI services and manage connections.`,icon:`BrainCog`,dataAdd:`modelProviders`},{key:`mcpservers`,name:`Connectors`,description:`Configure Model Context Protocol servers.`,icon:`Server`,dataAdd:`mcpServers`},{key:`skills-memory`,name:`Skills & Memory`,description:`Manage agent skills and view your stored memories.`,icon:`Brain`,dataAdd:`skillsMemory`},{key:`searchEngines`,name:`Search Sources`,description:`Manage search engine sources by category.`,icon:`Search`,dataAdd:`searchEngines`},{key:`search`,name:`Search Settings`,description:`Configure search parameters.`,icon:`Search`,dataAdd:`search`},{key:`fileSources`,name:`Cloud Storage`,description:`Manage storage sources (SSH, S3, R2, B2, Google Docs, Turso DB).`,icon:`HardDrive`,dataAdd:`storage`},{key:`aiRewriteModes`,name:`Rewrite Modes`,description:`Customize AI rewrite prompts and add your own modes.`,icon:`Wand2`,dataAdd:`rewritePrompts`},{key:`voice`,name:`Voice Settings`,description:`Configure text-to-speech with Kokoro.js or Cloudflare TTS.`,icon:`Volume2`,dataAdd:`voice`}],_r=[{key:`webSearch`,title:`All`,description:`Searches across all of the internet`,icon:(0,o.jsx)(c.Globe,{size:16})},{key:`academicSearch`,title:`Academic`,description:`Search in published academic papers`,icon:(0,o.jsx)(c.SwatchBook,{size:16})},{key:`writingAssistant`,title:`Writing`,description:`Chat without searching the web`,icon:(0,o.jsx)(c.Pencil,{size:16})},{key:`wolframAlphaSearch`,title:`Wolfram Alpha`,description:`Computational knowledge engine`,icon:(0,o.jsx)(c.BadgePercent,{size:16})},{key:`youtubeSearch`,title:`Youtube`,description:`Search and watch videos`,icon:(0,o.jsx)(x.FaYoutube,{className:`h-[16px] w-auto mr-0.5`})},{key:`redditSearch`,title:`Reddit`,description:`Search for discussions and opinions`,icon:(0,o.jsx)(x.FaReddit,{className:`h-[16px] w-auto mr-0.5`})}],vr=[{href:`/`,label:`Research`,description:`The search and chat window`,keywords:`home chat ask question search`},{href:`/workspace`,label:`REASON Editor`,description:`Write up findings in the document editor`,keywords:`docs document write draft report`,docsOnly:!0},{href:`/library`,label:`Library`,description:`Saved chats, uploads and extracted articles`,keywords:`history saved files uploads archive`},{href:`/news`,label:`News`,description:`Trending stories by topic`,keywords:`discover trending headlines`},{href:`/docs`,label:`User Guide`,description:`How every part of the app works`,keywords:`documentation help manual`},{href:`/features`,label:`Features`,description:`Everything the research agent can do`,keywords:`capabilities tour`},{href:`/settings`,label:`Settings`,description:`Models, connectors, search sources and preferences`,keywords:`preferences configure options`},{href:`/enterprise`,label:`Enterprise`,description:`Self-hosting and team plans`,keywords:`business pricing teams`},{href:`/legal/privacy`,label:`Privacy Policy`,description:`What is stored and what is not`,keywords:`legal terms data`}];function yr(e){let t=e=>e===`/`?c.Search:e===`/workspace`?c.FileText:e===`/settings`?c.Settings:e===`/docs`?c.BookOpen:c.LayoutGrid;return vr.filter(t=>!t.docsOnly||e.docsEnabled).map(n=>({id:`page:${n.href}`,source:`page`,name:n.label,meta:n.description,keywords:`${n.keywords??``} ${n.href}`,icon:t(n.href),run:()=>e.navigate(n.href)}))}function br(e,t){let n=new Date;return e.map(e=>({id:`chat:${e.id}`,source:`chat`,name:e.title||`Untitled chat`,meta:`${e.messageCount??0} question${(e.messageCount??0)===1?``:`s`}`,keywords:e.focusMode??``,icon:c.MessageSquare,hint:r.c(n,e.lastMessageAt||e.createdAt),run:()=>t.openChat(e.id)}))}function xr(e){return gr.map(t=>({id:`setting:${t.key}`,source:`setting`,name:t.name,meta:t.description,keywords:`settings ${t.key}`,icon:c.SlidersHorizontal,run:()=>e.openSettings(t.key)}))}function Sr(e){let t=[{id:`action:new-chat`,source:`action`,name:`New chat`,meta:`Start a fresh conversation`,keywords:`clear reset blank`,icon:c.Plus,run:e.newChat},{id:`action:settings`,source:`action`,name:`Open settings`,meta:`Models, connectors, search sources and preferences`,keywords:`preferences configure`,icon:c.Settings,run:()=>e.openSettings()},{id:`action:incognito`,source:`action`,name:e.incognito?`Turn off incognito`:`Turn on incognito`,meta:`Stop saving this conversation to history`,keywords:`private incognito history off`,icon:c.EyeOff,hint:e.incognito?`on`:`off`,run:()=>e.setIncognito(!e.incognito)}];for(let n of _r)t.push({id:`action:focus:${n.key}`,source:`action`,name:`Focus: ${n.title}`,meta:n.description,keywords:`focus mode ${n.key}`,icon:c.Globe,hint:e.focusMode===n.key?`current`:void 0,run:()=>e.setFocusMode(n.key)});return e.docsEnabled&&t.push({id:`action:view-docs`,source:`action`,name:`Switch to documents`,meta:`Open the REASON editor view`,keywords:`reason editor write docs`,icon:c.FileText,run:()=>e.setActiveView(`docs`)},{id:`action:view-research`,source:`action`,name:`Switch to research`,meta:`Back to the search and chat view`,keywords:`chat search`,icon:c.Search,run:()=>e.setActiveView(`research`)},{id:`action:files-sidebar`,source:`action`,name:`Show files sidebar`,meta:`Browse REASON documents`,keywords:`files documents sidebar`,icon:c.FileText,run:()=>{e.setActiveView(`docs`),e.requestFilesSidebar()}}),t.push(e.isAuthenticated?{id:`action:sign-out`,source:`action`,name:`Sign out`,meta:`End this session`,keywords:`logout log out`,icon:c.LogOut,run:e.signOut}:{id:`action:sign-in`,source:`action`,name:`Sign in`,meta:`Sync chats and settings across devices`,keywords:`login log in account`,icon:c.LogIn,run:e.signIn}),t}function Cr(e,t){let n=e.trim();return n?{id:`search:ask`,source:`search`,name:n,meta:`Ask ${t.appName} — searches the web and answers with sources`,icon:c.Sparkles,hint:`Enter`,run:()=>t.ask(n)}:null}var $=[{prefix:`c`,source:`chat`,label:`chats`},{prefix:`t`,source:`page`,label:`pages`},{prefix:`s`,source:`setting`,label:`settings`},{prefix:`a`,source:`action`,label:`actions`},{prefix:`w`,source:`search`,label:`web`}];function wr(e){let t=e.match(/^([a-zA-Z])\s+(.*)$/);if(t){let e=t[1].toLowerCase(),n=$.find(t=>t.prefix===e);if(n)return{prefix:n.prefix,query:t[2]}}return{prefix:null,query:e}}var Tr=18;function Er(e){return`${e.meta??``} ${e.keywords??``}`.toLowerCase()}function Dr(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e.map(e=>({item:e,matchedName:!0,snippet:null}));let r=[],i=[];for(let t of e){let e=t.name.toLowerCase();if(n.every(t=>e.includes(t)))r.push(t);else{let r=`${e} ${Er(t)}`;n.every(e=>r.includes(e))&&i.push(t)}}let a=n[0];return r.sort((e,t)=>e.name.toLowerCase().indexOf(a)-t.name.toLowerCase().indexOf(a)),[...r.map(e=>({item:e,matchedName:!0,snippet:null})),...i.map(e=>({item:e,matchedName:!1,snippet:Or(Er(e),a)}))]}function Or(e,t){let n=e.indexOf(t);if(n<0)return``;let r=Math.max(0,n-Tr),i=Math.min(e.length,n+t.length+Tr),a=e.slice(r,i).replace(/\s+/g,` `).trim();return r>0&&(a=`…`+a),i<e.length&&(a+=`…`),a}var kr=`qwksearch:open-spotlight`,Ar=100,jr=6,Mr=40;function Nr(){typeof window<`u`&&window.dispatchEvent(new Event(kr))}function Pr(e){return e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.code===`Space`||e.key===` `)}var Fr={search:`ask`,chat:`chat`,page:`page`,setting:`setting`,action:`action`};function Ir(){let[e,s]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),[d,f]=(0,i.useState)(0),p=(0,a.useRouter)(),m=n.u(),{isAuthenticated:h,signIn:g,signOut:_}=n.c(),{docsEnabled:v,setActiveView:y,requestFilesSidebar:b}=hr(),{recentChats:x,load:S}=it(Ar),C=(0,i.useRef)(null),w=(0,i.useRef)(null),T=(0,i.useRef)(null),E=(0,i.useCallback)(()=>s(!1),[]),D=(0,i.useRef)(S);(0,i.useEffect)(()=>{D.current=S},[S]);let O=(0,i.useMemo)(()=>({appName:t.researchAgentUIConfig.appName,navigate:e=>p.push(e),openChat:e=>{t.researchAgentUIConfig.onOpenChat?.(e)||p.push(`/c/${e}`)},openSettings:e=>{t.researchAgentUIConfig.onOpenSettings?.(e)||p.push(e?`/settings/${e}`:`/settings`)},ask:e=>{m.newChat(),p.push(`/?q=${encodeURIComponent(e)}`)},newChat:m.newChat,focusMode:m.focusMode,setFocusMode:m.setFocusMode,incognito:m.incognito,setIncognito:m.setIncognito,isAuthenticated:h,signIn:g,signOut:_,docsEnabled:v,setActiveView:y,requestFilesSidebar:b}),[p,m.newChat,m.focusMode,m.setFocusMode,m.incognito,m.setIncognito,h,g,_,v,y,b]),{prefix:k,query:A}=wr(l),j=A.trim(),M=(0,i.useMemo)(()=>({chat:br(x,O),page:yr(O),setting:xr(O),action:Sr(O)}),[x,O]),N=(0,i.useMemo)(()=>{let e=Cr(A,O);if(k===`w`)return e?[e]:[];if(k){let e=$.find(e=>e.prefix===k).source;return Dr(M[e],A).map(e=>e.item).slice(0,Mr)}if(!j)return[...M.chat.slice(0,jr),...M.action,...M.page].slice(0,Mr);let t=Dr([...M.action,...M.page,...M.setting,...M.chat],A).map(e=>e.item);return[...e?[e]:[],...t].slice(0,Mr)},[k,A,j,M,O]);(0,i.useEffect)(()=>{let e=e=>{Pr(e)&&(e.preventDefault(),s(e=>!e))},t=()=>s(!0);return window.addEventListener(`keydown`,e),window.addEventListener(kr,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(kr,t)}},[]),(0,i.useEffect)(()=>{e?(f(0),D.current(),w.current?.focus()):(u(``),f(0))},[e]),(0,i.useEffect)(()=>{if(!e)return;let t=e=>{C.current&&!C.current.contains(e.target)&&E()};return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e,E]),(0,i.useEffect)(()=>{f(e=>e<N.length?e:Math.max(0,N.length-1))},[N.length]),(0,i.useEffect)(()=>{T.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[d,N.length]);let P=(0,i.useCallback)(e=>{e&&(E(),e.run())},[E]),F=(0,i.useCallback)(()=>{let e=$.map(e=>e.prefix),t=e[((k?e.indexOf(k):-1)+1)%e.length];u(`${t} ${A}`),f(0)},[k,A]),I=e=>{switch(e.key){case`Escape`:e.preventDefault(),E();break;case`ArrowDown`:e.preventDefault(),f(e=>N.length?(e+1)%N.length:0);break;case`ArrowUp`:e.preventDefault(),f(e=>N.length?(e-1+N.length)%N.length:0);break;case`Enter`:e.preventDefault(),e.stopPropagation(),P(N[d]);break;case`Tab`:e.preventDefault(),F()}};if(!e)return null;let L=k?$.find(e=>e.prefix===k):null;return(0,o.jsx)(`div`,{className:`fixed inset-0 z-[10000] flex items-start justify-center bg-black/40 backdrop-blur-[2px] px-4 pt-[12vh]`,role:`presentation`,children:(0,o.jsxs)(`div`,{ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Search everything`,className:`w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-popover shadow-2xl`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4`,children:[(0,o.jsx)(c.Search,{size:18,className:`shrink-0 text-muted-foreground`}),(0,o.jsx)(`input`,{ref:w,value:l,onChange:e=>{u(e.target.value),f(0)},onKeyDown:I,type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Search everything`,"aria-autocomplete":`list`,"aria-controls":`spotlight-results`,"aria-activedescendant":N[d]?.id,placeholder:L?`Search ${L.label}…`:`Search chats, pages, settings — or ask anything`,className:`w-full bg-transparent py-4 text-base text-popover-foreground outline-none placeholder:text-muted-foreground`}),L&&(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:L.label})]}),(0,o.jsx)(`div`,{ref:T,id:`spotlight-results`,role:`listbox`,"aria-label":`Results`,className:`max-h-[50vh] overflow-y-auto p-1`,onMouseDown:e=>e.preventDefault(),children:N.length===0?(0,o.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No matches. Press Tab to search another source.`}):N.map((e,t)=>{let n=e.icon;return(0,o.jsxs)(`div`,{id:e.id,role:`option`,"aria-selected":t===d,"data-selected":t===d,onMouseMove:()=>f(t),onClick:()=>P(e),className:r.o(`flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2 transition-colors`,t===d?`bg-secondary`:`hover:bg-secondary/60`),children:[(0,o.jsx)(n,{size:16,className:r.o(`shrink-0`,t===d?`text-primary`:`text-muted-foreground`)}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm text-popover-foreground`,children:e.name}),e.meta&&(0,o.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.meta})]}),e.hint&&(0,o.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.hint}),(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-1.5 py-0 text-[10px] text-muted-foreground`,children:Fr[e.source]})]},e.id)})}),(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-4 py-2 text-[11px] text-muted-foreground`,children:[(0,o.jsx)(`span`,{children:`↑↓ move`}),(0,o.jsx)(`span`,{children:`↵ open`}),(0,o.jsx)(`span`,{children:`⇥ next source`}),(0,o.jsx)(`span`,{children:`esc close`}),(0,o.jsx)(`span`,{className:`ml-auto`,children:$.map(e=>`${e.prefix} ${e.label}`).join(` · `)})]})]})})}var Lr={device:`webgpu`,dtype:`fp32`},Rr={device:`wasm`,dtype:`q8`},zr=`hexgrad/Kokoro-82M`,Br=null,Vr=null;function Hr(){return typeof navigator<`u`&&`gpu`in navigator}async function Ur(){if(!Hr())return!1;try{return await navigator.gpu.requestAdapter()!=null}catch{return!1}}async function Wr(e){let t=[];await Ur()&&t.push(Lr),t.push(Rr);let{KokoroTTS:n}=await import(`kokoro-js`),r;for(let i of t)try{let t=await n.from_pretrained(zr,{device:i.device,dtype:i.dtype,progress_callback:e});return Vr=i.device,t}catch(e){r=e,console.warn(`Kokoro model failed to load on "${i.device}" backend:`,e)}throw r instanceof Error?r:Error(`Failed to load Kokoro model`)}async function Gr(e){return Br||=Wr(e).catch(e=>{throw Br=null,e}),Br}async function Kr(e){return Gr(e)}async function qr(){let e=await Kr();return Object.keys(e.voices)}function Jr(){return Vr}function Yr(e,t){let[n,r]=(0,i.useState)(`idle`),[a,o]=(0,i.useState)(!1),[s,c]=(0,i.useState)([]),[l,u]=(0,i.useState)(`af_heart`),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null),h=(0,i.useRef)(null),g=(0,i.useRef)(null);(0,i.useEffect)(()=>{t?.autoPreload&&!a&&v()},[t?.autoPreload,a]),(0,i.useEffect)(()=>{let e=localStorage.getItem(`kokoroVoice`);e&&u(e)},[]),(0,i.useEffect)(()=>()=>{h.current&&h.current.pause(),g.current?.abort()},[]);let _=(0,i.useCallback)(()=>{h.current&&=(h.current.pause(),h.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(h.current.src),null),g.current?.abort(),g.current=null},[]),v=(0,i.useCallback)(async()=>{try{r(`loading`),f(null),m(null),await Gr(e=>{m(e)});let e=await qr();c(e),e.length&&!e.includes(l)&&u(e[0]),o(!0),r(`idle`)}catch(e){let t=e instanceof Error?e.message:`Failed to load model`;f(t),r(`error`),console.error(`Failed to load Kokoro model:`,e)}},[l]);return{status:n,modelReady:a,voices:s,selectedVoice:l,error:d,progress:p,warmupModel:v,speak:(0,i.useCallback)(async()=>{if(e?.trim()){if(!a)f(`Model not loaded. Click "Preload Model" first.`);else try{_(),r(`generating`),f(null);let t=new AbortController;g.current=t;let n=(await(await Kr()).generate(e.slice(0,5e3),{voice:l})).toWav(),i=new Blob([n],{type:`audio/wav`}),a=URL.createObjectURL(i),o=new Audio(a);h.current=o,o.onended=()=>{r(`idle`),URL.revokeObjectURL(a),h.current=null},o.onerror=()=>{r(`error`),f(`Failed to play audio`),URL.revokeObjectURL(a),h.current=null},r(`playing`),await o.play()}catch(e){if(e?.name!==`AbortError`){let t=e instanceof Error?e.message:`Speech generation failed`;f(t),r(`error`),console.error(`Kokoro TTS error:`,e)}}}},[e,l,a,_]),stop:(0,i.useCallback)(()=>{_(),r(`idle`),f(null)},[_]),changeVoice:(0,i.useCallback)(e=>{u(e),localStorage.setItem(`kokoroVoice`,e)},[]),backend:Jr()}}function Xr(e,t){let[n,r]=(0,i.useState)(`stopped`),[a,o]=(0,i.useState)(!1),s=(0,i.useRef)(null),c=(0,i.useRef)(null),l=(0,i.useRef)(null),d=(0,i.useRef)(t);d.current=t;let f=(0,i.useCallback)(()=>{s.current&&=(s.current.pause(),s.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(s.current.src),null),l.current?.abort(),l.current=null},[]),p=(0,i.useCallback)(()=>{f(),c.current=null,window.speechSynthesis?.cancel(),r(`stopped`),o(!1)},[f]),m=(0,i.useCallback)(()=>{if(!(`speechSynthesis`in window))return!1;try{window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);return c.current=t,t.onend=()=>{c.current=null,r(`stopped`)},t.onerror=()=>{c.current=null,r(`stopped`)},window.speechSynthesis.speak(t),r(`started`),!0}catch{return!1}},[e]);return{speechStatus:n,isLoading:a,start:(0,i.useCallback)(async()=>{if(!e?.trim())return;f(),window.speechSynthesis?.cancel(),c.current=null,r(`started`),o(!0);let t=new AbortController;l.current=t;try{let n=localStorage.getItem(`useTTSKokoro`);if(n===null||n!==`false`)try{let t=await Kr(e=>{(e.status===`progress_total`||e.status===`progress`||e.status===`download`)&&console.log(`[Kokoro] Loading: ${Math.round(e.progress??0)}%`)}),n=localStorage.getItem(`kokoroVoice`)||`af_heart`,i=(await t.generate(e.slice(0,5e3),{voice:n})).toWav(),a=new Blob([i],{type:`audio/wav`}),c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},o(!1),await l.play();return}catch(e){console.debug(`Kokoro TTS unavailable, using server-side TTS:`,e instanceof Error?e.message:String(e)),o(!1)}o(!1);let i=await(0,u.default)(`agent/voice`,{method:`POST`,body:{text:e.slice(0,5e3),voice:localStorage.getItem(`kokoroVoice`)||`af_heart`},signal:t.signal}),a=typeof i.blob==`function`?await i.blob():i;if(!a||a.size===0){m()||r(`stopped`);return}let c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},await l.play()}catch{m()||r(`stopped`)}},[e,f,m]),stop:p}}var Zr={af_heart:`American Female - Heart`,af_bella:`American Female - Bella`,af_nicole:`American Female - Nicole`,af_sarah:`American Female - Sarah`,am_adam:`American Male - Adam`,am_michael:`American Male - Michael`,am_tony:`American Male - Tony`,bf_emma:`British Female - Emma`,bm_george:`British Male - George`,bm_thomas:`British Male - Thomas`};function Qr({preloadOnMount:e=!1}){let{status:t,modelReady:a,voices:s,selectedVoice:l,error:u,progress:d,warmupModel:f,changeVoice:p,backend:m}=Yr(``,{autoPreload:e}),[h,g]=(0,i.useState)(!1),_=t===`loading`,v=t===`error`;return(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:f,disabled:_||a,className:r.o(`p-2 rounded-full transition duration-200`,a?`bg-green-500/10 text-green-600 dark:text-green-400`:`bg-white/10 dark:bg-black/10 text-muted-foreground hover:bg-white/20 dark:hover:bg-black/20`,_&&`opacity-70 cursor-not-allowed`),children:_?(0,o.jsx)(c.Loader2,{size:18,className:`animate-spin`}):(0,o.jsx)(c.Download,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:_?d?d.status===`progress_total`||d.status===`progress`?`Downloading Kokoro model... ${Math.round(d.progress??0)}%`:`Loading Kokoro model... ${d.status}`:`Loading Kokoro model...`:a?`Model ready`:`Preload Kokoro.js model`})]}),a&&m&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[m,` • `,s.length,` voices`]}),_&&d&&(d.status===`progress_total`||d.status===`progress`||d.status===`download`)&&(0,o.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 max-w-xs`,children:[(0,o.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-white/10 dark:bg-black/10`,children:(0,o.jsx)(`div`,{className:`h-1.5 bg-blue-500 transition-all duration-200`,style:{width:`${Math.round(d.progress??0)}%`}})}),(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap tabular-nums`,children:[Math.round(d.progress??0),`%`]})]}),v&&(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(c.AlertCircle,{size:18,className:`text-red-500`})}),(0,o.jsx)(n.n,{side:`bottom`,className:`max-w-xs`,children:u})]})]}),a&&(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsx)(`button`,{onClick:()=>g(!h),className:`w-full text-left px-3 py-2 rounded-md bg-white/5 dark:bg-black/5 hover:bg-white/10 dark:hover:bg-black/10 transition text-sm font-medium`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(c.Volume2,{size:16}),Zr[l]||l]})}),h&&(0,o.jsx)(`div`,{className:`grid grid-cols-2 gap-2 p-2 bg-white/5 dark:bg-black/5 rounded-md max-h-64 overflow-y-auto`,children:s.map(e=>(0,o.jsx)(`button`,{onClick:()=>{p(e),g(!1)},className:r.o(`p-2 text-left text-sm rounded transition duration-200`,l===e?`bg-blue-500/20 text-blue-600 dark:text-blue-400 font-medium`:`bg-white/5 dark:bg-black/5 text-foreground hover:bg-white/10 dark:hover:bg-black/10`),children:Zr[e]||e},e))})]})]})}function $r(){let[e,t]=(0,i.useState)(!1),[a,s]=(0,i.useState)(()=>{let e=localStorage.getItem(`useTTSKokoro`);return e===null||e!==`false`}),[l,u]=(0,i.useState)(()=>localStorage.getItem(`ttsSpeaker`)||`angus`),[d,f]=(0,i.useState)(()=>Se()),{start:p,speechStatus:m}=Xr(`This is a preview of the selected voice.`,{enableInterrupt:!1}),h=e=>{s(e),localStorage.setItem(`useTTSKokoro`,String(e))},g=e=>{u(e),localStorage.setItem(`ttsSpeaker`,e)},_=e=>{f(e),Ce(e)};return(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(c.Settings2,{size:18}),(0,o.jsx)(`h3`,{className:`font-semibold`,children:`Voice Settings`})]}),(0,o.jsx)(`button`,{onClick:()=>t(!e),className:`text-xs px-3 py-1 rounded-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition`,children:e?`Collapse`:`Expand`})]}),e&&(0,o.jsxs)(`div`,{className:`space-y-4 p-4 rounded-lg bg-white/5 dark:bg-black/5 border border-white/10 dark:border-black/10`,children:[(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>h(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Kokoro.js (Local TTS)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Runs locally in your browser. No server requests, lower latency, and multiple voice options.`})]})]}),a&&(0,o.jsx)(Qr,{preloadOnMount:!1})]}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!a,onChange:e=>h(!e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Cloudflare TTS (Fallback)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Uses Cloudflare Workers AI. Slightly higher latency but can be a fallback.`})]})]}),!a&&(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`select`,{value:l,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 rounded-md bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 text-sm`,children:[(0,o.jsx)(`option`,{value:`angus`,children:`Angus`}),(0,o.jsx)(`option`,{value:`flora`,children:`Flora`}),(0,o.jsx)(`option`,{value:`james`,children:`James`}),(0,o.jsx)(`option`,{value:`natalie`,children:`Natalie`})]}),(0,o.jsxs)(`button`,{onClick:()=>p(),disabled:m===`started`,className:r.o(`w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition`,m===`started`?`bg-gray-500/20 text-gray-600 dark:text-gray-400 cursor-not-allowed`:`bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30`),children:[(0,o.jsx)(c.Volume2,{size:16}),m===`started`?`Playing...`:`Preview`]})]})]}),(0,o.jsx)(`div`,{className:`space-y-2 pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>_(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Start talking automatically on first visit`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Opens the mic the first time you load the chat composer in this browser, so you can start talking right away instead of clicking the mic button.`})]})]})}),(0,o.jsx)(`div`,{className:`text-xs text-muted-foreground pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:`Tip:`}),` Kokoro.js loads once and runs locally. The first model load may take a few seconds, but subsequent TTS generation is very fast.`]})})]})]})}var ei=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%3e%3cpath%20style='fill:%23FE5022;'%20d='M438.802,390.609V278.595h55.174c9.938,0,18.023,8.085,18.023,18.023v75.967%20c0,9.938-8.086,18.024-18.023,18.024L438.802,390.609L438.802,390.609z'/%3e%3cpath%20style='fill:%23ECE5DD;'%20d='M28.107,511.637C12.609,511.637,0,499.027,0,483.529V134.326c0-1.441,0-12.123,0-12.123%20L121.715,0.363c0,0,10.8,0,12.248,0h271.569c15.498,0,28.107,12.609,28.107,28.106v455.059c0,15.499-12.609,28.108-28.107,28.108%20H28.107V511.637z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M405.533,0.363h-31.991c15.498,0,28.107,12.609,28.107,28.107v455.059%20c0,15.499-12.609,28.108-28.107,28.108h31.991c15.498,0,28.107-12.609,28.107-28.108V28.469%20C433.64,12.972,421.031,0.363,405.533,0.363z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3c/g%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M0.726,123.171L122.442,1.331l1.39,105.939c0,9.465-7.7,17.166-17.166,17.166L0.726,123.171z'/%3e%3cpath%20style='fill:%23FFB656;'%20d='M270.226,401.7V267.504H456.87c5.938,0,10.768,4.83,10.768,10.768v112.659%20c0,5.938-4.83,10.769-10.768,10.769H270.226z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M367.785,335.156c-12.822,0-23.252-10.431-23.252-23.254v-44.399h89.833v44.399%20c0,12.823-10.431,23.254-23.252,23.254H367.785z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M345.087,448.28H101.096c-4.594,0-8.318,3.723-8.318,8.318c0,4.595,3.724,8.318,8.318,8.318h243.992%20c4.594,0,8.318-3.723,8.318-8.318C353.405,452.003,349.681,448.28,345.087,448.28z'/%3e%3c/g%3e%3cpath%20style='fill:%23FE5022;'%20d='M163.689,357.337c-3.692,0-6.094-3.886-4.443-7.189l16.225-32.451%20c1.799-3.597,5.416-5.833,9.438-5.833h44.282v45.471h-65.503V357.337z'/%3e%3cpolygon%20style='fill:%23FFB656;'%20points='256.918,278.252%20211.447,300.988%20211.447,368.216%20256.918,390.953%20284.321,390.953%20284.321,278.214%20'/%3e%3cg%3e%3cpath%20style='fill:%23FE5022;'%20d='M268.64,401.7c-7.075,0-12.832-5.756-12.832-12.832V280.336c0-7.075,5.756-12.831,12.832-12.831%20h19.808c7.075,0,12.832,5.756,12.832,12.831v108.532c0,7.076-5.756,12.832-12.832,12.832H268.64z'/%3e%3cpath%20style='fill:%23FE5022;'%20d='M104.156,379.377H26.143V301.33h91.398c8.546,0,14.88,7.936,12.986,16.27l-11.313,49.758%20C117.615,374.388,111.366,379.377,104.156,379.377z'/%3e%3c/g%3e%3c/svg%3e`,ti=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%2064%2064'%20xml:space='preserve'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%2376C2AF;}%20.st1{fill:%234F5D73;}%20.st2{opacity:0.2;}%20.st3{fill:%23231F20;}%20.st4{fill:%23FFFFFF;}%20%3c/style%3e%3cg%20id='Layer_1'%3e%3cg%3e%3ccircle%20class='st0'%20cx='32'%20cy='32'%20r='32'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M32,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C34,51.1,33.1,52,32,52L32,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M46,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C48,51.1,47.1,52,46,52L46,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M18,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C20,51.1,19.1,52,18,52L18,52z'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='45.9'%20cy='38'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='32'%20cy='27'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='18'%20cy='44'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='45.9'%20cy='36'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='32'%20cy='25'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='18'%20cy='42'%20r='4'/%3e%3c/g%3e%3c/g%3e%3cg%20id='Layer_2'%3e%3c/g%3e%3c/svg%3e`;function ni(){let e=(0,a.usePathname)(),r=(0,a.useRouter)(),{isAuthenticated:i,signIn:s,signOut:l}=n.c(),{newChat:u}=n.u(),{activeView:d,setActiveView:f,docsEnabled:p,requestFilesSidebar:m}=hr(),h=[{href:`/`,label:`Research`,icon:t.researchAgentUIConfig.appIconUrl},...p?[{href:`/workspace`,label:`Docs`,icon:(0,o.jsx)(w.default,{src:ei,alt:`Docs`,width:24,height:24,unoptimized:!0,className:`w-full h-full`})}]:[]],g=e===`/`||e.startsWith(`/c`),_=[...h.map(({href:e,label:t,icon:n})=>({key:e,label:t,icon:n,active:e===`/`?d===`research`:d===`docs`,onClick:()=>{e===`/`?(f(`research`),g&&u()):f(`docs`)}})),...p?[{key:`files`,label:`Files`,icon:(0,o.jsx)(c.FileText,{className:`w-full h-full p-1`}),onClick:()=>{f(`docs`),m()}}]:[],{key:`settings`,label:`Settings`,icon:(0,o.jsx)(w.default,{src:ti,alt:`Settings`,width:24,height:24,unoptimized:!0,className:`w-full h-full`}),menu:{renderContent:()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>Nr(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.Search,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Search`}),(0,o.jsx)(`span`,{className:`ml-auto pl-3 text-[10px] text-muted-foreground`,children:`Ctrl Space`})]}),(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>{t.researchAgentUIConfig.onOpenSettings?.()||r.push(`/settings`)},className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.Settings,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Settings`})]}),i?(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>l(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.LogOut,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Logout`})]}):(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>s(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.LogIn,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Login`})]}),(0,o.jsx)(C.DropdownMenuSeparator,{}),(0,o.jsx)(C.ThemeMenu,{})]})}}],v=_.filter(e=>e.key!==`files`),y=(e,t,n)=>(0,o.jsx)(w.default,{src:e,alt:t,width:n,height:n,unoptimized:!0,className:`w-full h-full`});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(C.CategoryDock,{items:v,enableKeyboardShortcuts:!0,placements:{desktop:!0,mobile:!1},renderImage:y}),(0,o.jsx)(C.CategoryDock,{items:_,placements:{desktop:!1,mobile:!0},mobileAlign:d===`docs`?`end`:`center`,renderImage:y})]})}function ri(){return(0,o.jsx)(T.CookieConsent,{appName:t.researchAgentUIConfig.appName,links:t.researchAgentUIConfig.footerLinks,heightVar:`--qs-bottom-right-inset`})}var ii=`qwk:chunk-error-reload`,ai=6e4,oi=/Loading (CSS )?chunk|ChunkLoadError|Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function si(e){if(typeof e==`string`)return oi.test(e);if(e&&typeof e==`object`){let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&oi.test(n)}return!1}function ci(e){if(typeof window>`u`||!si(e))return!1;try{let e=Number(window.sessionStorage.getItem(ii));if(e&&Date.now()-e<ai)return!1;window.sessionStorage.setItem(ii,String(Date.now()))}catch{return!1}return window.location.reload(),!0}function li(){(0,i.useEffect)(()=>{let e=e=>{ci(e.error??e.message)},t=e=>{ci(e.reason)},n=e=>{ci(e.payload??`Loading chunk`)&&e.preventDefault()};return window.addEventListener(`error`,e),window.addEventListener(`unhandledrejection`,t),window.addEventListener(`vite:preloadError`,n),()=>{window.removeEventListener(`error`,e),window.removeEventListener(`unhandledrejection`,t),window.removeEventListener(`vite:preloadError`,n)}},[])}var ui=({children:e})=>(0,o.jsx)(o.Fragment,{children:e});function di(e){let[t,n]=(0,i.useState)(e===!0);return(0,i.useEffect)(()=>{if(e!==`auto`){n(e);return}let t=!1;return(0,u.default)(`auth/providers`).then(e=>{t||n(!!e.providers?.includes(`google`))}).catch(()=>{t||n(!1)}),()=>{t=!0}},[e]),t}function fi({children:e,authClient:r,config:i,googleOneTap:a=`auto`,docsEnabled:s=!0,ChromeProvider:c=ui,showDock:u=!0,showCookieConsent:d=!0,showToaster:f=!0,showSpotlight:p=!0}){i&&t.configureResearchAgentUI(i);let m=di(a);return li(),(0,o.jsx)(S.ThemeProvider,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,children:(0,o.jsx)(n.s,{authClient:r,enableGoogleOneTap:m,children:(0,o.jsx)(n.i,{children:(0,o.jsx)(ge,{children:(0,o.jsx)(fr,{docsEnabled:s,children:(0,o.jsx)(C.CategoryDockProvider,{children:(0,o.jsxs)(c,{children:[(0,o.jsxs)(`div`,{id:`app-scroll-root`,className:`w-screen h-screen overflow-y-auto overflow-x-hidden pb-[calc(60px+env(safe-area-inset-bottom,0px))] md:pb-0`,children:[u&&(0,o.jsx)(ni,{}),(0,o.jsx)(`main`,{className:`bg-light-primary dark:bg-dark-primary min-h-screen`,children:e})]}),f&&(0,o.jsx)(l.Toaster,{toastOptions:{unstyled:!0,classNames:{toast:`bg-light-secondary dark:bg-dark-secondary dark:text-white/70 text-black-70 rounded-lg p-4 flex flex-row items-center space-x-2`}}}),d&&(0,o.jsx)(ri,{}),p&&(0,o.jsx)(Ir,{})]})})})})})})})}function pi(e){return(0,o.jsx)(fi,{...e,docsEnabled:!1,children:(0,o.jsx)(jn,{})})}var mi=`qwksearch-open-chat-tabs`,hi=50;function gi(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(mi);return e?JSON.parse(e):[]}catch{return[]}}function _i(){let{chatId:e,chatTurns:t,startNewChat:r,switchToChat:a}=n.u(),[o,s]=(0,i.useState)(gi);(0,i.useEffect)(()=>{window.localStorage.setItem(mi,JSON.stringify(o))},[o]),(0,i.useEffect)(()=>{if(!e)return;let n=t[0]?.content?.slice(0,hi),r=t.length>0;s(t=>{let i=t.find(t=>t.id===e);return i?n&&i.title!==n||i.hasMessages!==r?t.map(t=>t.id===e?{...t,title:n||t.title,hasMessages:r}:t):t:[...t,{id:e,title:n||`New Chat`,hasMessages:r}]})},[e,t]);let c=(0,i.useCallback)((e,t)=>{let n=t.find(t=>t.id===e);n&&!n.hasMessages?r(e):a(e)},[r,a]),l=(0,i.useCallback)(e=>{c(e,o)},[c,o]),u=(0,i.useCallback)(()=>{let e=crypto.randomUUID();return s(t=>[...t,{id:e,title:`New Chat`}]),r(e),e},[r]),d=(0,i.useCallback)(t=>{let n=new Set(t),r=o.filter(e=>!n.has(e.id));s(r);let i=e!=null&&n.has(e);if(!i)return{closedWasActive:!1,nextActiveId:null};if(r.length===0)return{closedWasActive:i,nextActiveId:null};let a=o.findIndex(t=>t.id===e),l=e=>e!=null&&!n.has(e.id),u;for(let e=a-1;e>=0&&!u;e--)l(o[e])&&(u=o[e]);for(let e=a+1;e<o.length&&!u;e++)l(o[e])&&(u=o[e]);let d=(u??r[0]).id;return c(d,r),{closedWasActive:i,nextActiveId:d}},[o,e,c]),f=(0,i.useCallback)(e=>d([e]),[d]);return{chatTabs:o,activeChatId:e??null,openChat:l,newChat:u,closeChat:f,closeChats:d}}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Rn}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return jn}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return Bn}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return zn}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return en}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ni}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Xr}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $r}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return li}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _i}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return lr}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return Kt}});
|
|
34
|
+
ANTHROPIC_API_KEY=sk-ant-your_key_here`})]}),(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`3. Restart the server`}),(0,o.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs`,children:`Ctrl+C, then: npm run dev`})]})]}),(0,o.jsxs)(`div`,{className:`pt-4 border-t border-black/10 dark:border-white/10`,children:[(0,o.jsx)(`h3`,{className:`font-medium text-black dark:text-white mb-2`,children:`Get API Keys:`}),(0,o.jsxs)(`ul`,{className:`space-y-2 text-sm text-black/70 dark:text-white/70`,children:[(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Groq`}),` (FREE): `,(0,o.jsx)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.groq.com/keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`OpenAI`}),`: `,(0,o.jsx)(`a`,{href:`https://platform.openai.com/api-keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`platform.openai.com/api-keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Anthropic`}),`: `,(0,o.jsx)(`a`,{href:`https://console.anthropic.com/settings/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.anthropic.com`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`text-xs text-black/50 dark:text-white/50 pt-4 border-t border-black/10 dark:border-white/10`,children:[`See `,(0,o.jsx)(`code`,{children:`SETUP_INSTRUCTIONS.md`}),` in the project root for full details.`]})]})})}var kn=()=>Promise.resolve().then(()=>require("./ChatConversationThread-CVaSsBBI.cjs")),An=(0,i.lazy)(kn),jn=()=>{let e=(0,a.useRouter)(),{hasError:t,isReady:r,notFound:s,messages:c}=n.u(),{isAuthenticated:l}=n.c(),u=r&&!s&&c.length===0;return(0,i.useEffect)(()=>{if(!u)return;if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(()=>void kn(),{timeout:5e3});return()=>window.cancelIdleCallback(e)}let e=window.setTimeout(()=>void kn(),3e3);return()=>window.clearTimeout(e)},[u]),(0,i.useEffect)(()=>{r&&s&&!l&&e.replace(`/`)},[r,s,l,e]),t?(0,o.jsx)(On,{}):r&&s&&!l?(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})}):r?s?(0,o.jsxs)(`div`,{className:`flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,o.jsx)(`p`,{className:`text-sm text-black/70 dark:text-white/70`,children:`This chat could not be found.`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>e.push(`/`),className:`rounded-md border border-black/15 px-3 py-1.5 text-sm hover:bg-black/5 dark:border-white/20 dark:hover:bg-white/10`,children:`Go Home`})]}):(0,o.jsx)(`div`,{children:c.length>0?(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})}),children:(0,o.jsx)(An,{})})}):(0,o.jsx)(En,{})}):(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(Dn,{})})},Mn=`https://qwksearch.com`,Nn=null,Pn=Mn,Fn=!1;function In(e,t){let n;n=typeof e==`string`?e:e instanceof URL?e.href:e.url;try{let e=typeof window<`u`?window.location.href:t,r=new URL(n,e);return r.origin===t&&r.pathname.startsWith(`/api/`)}catch{return!1}}function Ln(){if(Fn||typeof window>`u`||typeof window.fetch!=`function`)return;Fn=!0;let e=window.fetch.bind(window);window.fetch=(t,n)=>{if(!Nn||!In(t,Pn))return e(t,n);let r=new Headers(n?.headers??(t instanceof Request?t.headers:void 0));return!r.has(`x-api-key`)&&!r.has(`authorization`)&&r.set(`X-API-Key`,Nn),e(t,{...n,headers:r})}}function Rn(e,t=Mn){Nn=e||null,Pn=t.replace(/\/+$/,``),Nn&&Ln()}function zn(){return Nn}function Bn(e,t){let n=t??(typeof window<`u`?`${window.location.pathname}${window.location.search}`:`/`);return`${e}${e.includes(`?`)?`&`:`?`}returnTo=${encodeURIComponent(n)}`}function Vn(e){let t=e.qwksearchOrigin??`https://qwksearch.com`,n={connected:!1},r=new Set,i=i=>{n=i,Rn(i.connected?i.apiKey??null:null,t),e.onSession?.(i),r.forEach(e=>e())},a=null,o=()=>(a??=fetch(e.sessionUrl,{credentials:`same-origin`,headers:{Accept:`application/json`}}).then(async e=>e.ok?await e.json():{connected:!1}).catch(()=>({connected:!1})).then(e=>(i(e),e)).finally(()=>{a=null}),a);return{getCachedSession:()=>n,refresh:o,subscribe:e=>(r.add(e),()=>r.delete(e)),getSession:async()=>{let e=await o();return{data:e.connected&&e.user?{user:e.user}:null}},oneTap:e=>{},signIn:{social:t=>{typeof window<`u`&&window.location.assign(Bn(e.connectUrl))}},signOut:async t=>{try{await fetch(e.disconnectUrl,{method:`POST`,credentials:`same-origin`})}finally{i({connected:!1}),t?.fetchOptions?.onSuccess?.()}return{data:null}}}}var Hn=({onClose:e})=>(0,o.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,o.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,o.jsx)(c.X,{className:`h-5 w-5`})})}),Un=(0,_.cva)(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border-[1.5px] bg-background hover:bg-accent hover:text-accent-foreground dark:bg-card dark:hover:bg-card/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 px-6 has-[>svg]:px-4`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function Z({className:e,variant:t,size:n,asChild:i=!1,...a}){return(0,o.jsx)(i?g.Slot:`button`,{"data-slot":`button`,className:r.o(Un({variant:t,size:n,className:e})),...a})}var Wn={ask:{alt:!0,key:`a`},suggest:{alt:!0,key:`s`},copy:{alt:!0,key:`c`},highlight:{alt:!0,key:`h`},favorite:{alt:!0,key:`f`},open:{alt:!0,key:`o`},zoomOut:{alt:!0,key:`-`},zoomReset:{alt:!0,key:`0`},zoomIn:{alt:!0,key:`=`},close:{alt:!1,key:`Escape`}},Gn=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||``);function Kn(e){let{alt:t,key:n}=Wn[e],r=n===`Escape`?`Esc`:n.length===1?n.toUpperCase():n;return t?Gn?`⌥${r}`:`Alt+${r}`:r}var qn=r.o(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),Q=({label:e,action:t,children:r})=>(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:r}),(0,o.jsx)(n.n,{side:`bottom`,children:(0,o.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(`span`,{children:e}),t&&(0,o.jsx)(`kbd`,{className:`rounded bg-primary-foreground/20 px-1 py-0.5 text-[10px] font-semibold leading-none tracking-wide`,children:Kn(t)})]})})]}),Jn=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:i,isHighlightMode:a,articleUrl:s,fontScale:l,onAskClick:u,onSuggestClick:d,onCopyClick:f,onShareClick:p,onFavoriteClick:m,onHighlightToggle:h,onZoomIn:g,onZoomOut:_,onZoomReset:v,onClose:y})=>{let b=g||_,x=Math.round((l??1)*100);return(0,o.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,o.jsx)(Q,{label:`Ask AI about this article`,action:`ask`,children:(0,o.jsxs)(Z,{onClick:u,disabled:e,variant:`ghost`,size:`sm`,className:r.o(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,o.jsx)(c.Bot,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]})}),(0,o.jsx)(Q,{label:`Suggest follow-up questions`,action:`suggest`,children:(0,o.jsxs)(Z,{onClick:d,disabled:t,variant:`ghost`,size:`sm`,className:r.o(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,o.jsx)(c.MessageCircleQuestion,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]})}),(0,o.jsx)(Q,{label:`Copy article`,action:`copy`,children:(0,o.jsx)(Z,{onClick:f,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(c.Clipboard,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Share article`,children:(0,o.jsx)(Z,{onClick:p,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(c.Share2,{className:`size-4`})})}),(0,o.jsx)(Q,{label:a?`Disable highlighting`:`Enable highlighting`,action:`highlight`,children:(0,o.jsx)(Z,{onClick:h,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,a?`text-yellow-500 bg-yellow-50 dark:bg-yellow-950/30 hover:bg-yellow-100 dark:hover:bg-yellow-950/50`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,o.jsx)(c.Highlighter,{className:`size-4`})})}),(0,o.jsx)(Q,{label:i?`Remove from favorites`:`Add to favorites`,action:`favorite`,children:(0,o.jsx)(Z,{onClick:m,disabled:n,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,i?`text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-950/30`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,o.jsx)(c.Star,{className:r.o(`size-4`,i&&`fill-yellow-400`)})})}),s&&(0,o.jsx)(Q,{label:`Open in new tab`,action:`open`,children:(0,o.jsx)(Z,{asChild:!0,variant:`ghost`,size:`icon`,className:qn,children:(0,o.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,children:(0,o.jsx)(c.ExternalLink,{className:`size-4`})})})}),b&&(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 rounded-xl border border-muted/60 bg-muted/20 px-1`,children:[(0,o.jsx)(Q,{label:`Zoom out`,action:`zoomOut`,children:(0,o.jsx)(Z,{onClick:_,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(c.ZoomOut,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Reset zoom`,action:`zoomReset`,children:(0,o.jsxs)(`button`,{type:`button`,onClick:v,className:`min-w-[3rem] rounded-md px-1 text-center text-xs font-medium tabular-nums text-muted-foreground transition-colors hover:text-foreground`,children:[x,`%`]})}),(0,o.jsx)(Q,{label:`Zoom in`,action:`zoomIn`,children:(0,o.jsx)(Z,{onClick:g,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(c.ZoomIn,{className:`size-4`})})})]}),(0,o.jsx)(Q,{label:`Close`,action:`close`,children:(0,o.jsx)(Z,{onClick:y,variant:`ghost`,size:`icon`,className:r.o(qn,!b&&`ml-auto`),children:(0,o.jsx)(c.X,{className:`size-4`})})})]})},Yn=({value:e,onChange:t,onSubmit:n})=>(0,o.jsx)(`div`,{className:`relative`,children:(0,o.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n(),type:`text`,placeholder:`Ask AI any question...`,className:`w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),Xn=({questions:e,isLoading:n,error:r,onQuestionClick:a})=>{let s=i.default.useMemo(()=>{let t=[];return e.forEach(e=>{e.includes(`?`)&&e.split(`?`).length>2?e.split(`?`).map(e=>e.trim()).filter(Boolean).forEach(e=>{t.push(e.endsWith(`?`)?e:`${e}?`)}):t.push(e)}),t},[e]);return(0,o.jsxs)(o.Fragment,{children:[s.length>0&&(0,o.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,o.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsx)(`div`,{onClick:()=>a(t.researchAgentUIConfig.defaultSummarizePrompt),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-primary/30 transition-all hover:border-primary shadow-sm hover:shadow-md`,children:t.researchAgentUIConfig.defaultSummarizePrompt}),s.map((e,t)=>(0,o.jsx)(`div`,{onClick:()=>a(e),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-border transition-all hover:border-primary shadow-sm hover:shadow-md`,dangerouslySetInnerHTML:{__html:e}},t))]})]}),n&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),r&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:r})]})},Zn=({response:e,isLoading:t,error:n})=>(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,o.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Qn=({html:e,isHighlightMode:t=!1,fontScale:n=1})=>{let[r,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{a(y.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,o.jsx)(`div`,{className:[`prose prose-neutral dark:prose-invert max-w-none`,`prose-p:leading-[1.9] prose-li:leading-[1.9] prose-p:my-5 prose-li:my-1.5`,`prose-headings:font-semibold prose-headings:tracking-tight prose-headings:leading-snug`,`prose-h1:mt-8 prose-h2:mt-8 prose-h3:mt-6`,`prose-blockquote:leading-[1.8] prose-blockquote:border-l-2`,`prose-img:rounded-lg prose-img:my-6`,t?`select-text`:``].join(` `),style:{fontSize:`${n}em`,fontFamily:`ui-serif, Georgia, Cambria, "Times New Roman", Times, serif`},dangerouslySetInnerHTML:{__html:r}})},$n=({article:e,isHighlightMode:t,fontScale:n=1})=>(0,o.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.cite&&(0,o.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,o.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,o.jsx)(`div`,{id:`article-content`,children:(0,o.jsx)(Qn,{html:e.html||``,isHighlightMode:t,fontScale:n})})]})}),er=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,tr=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function nr(e){return e.includes(`](`)||e.includes(`)[`)?!1:/\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e)}function rr(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function ir(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(tr.lastIndex=0;(r=tr.exec(t))!==null;){let e=r[0],i=r.index,a=t.substring(0,i),o=t.substring(i+e.length);!a.endsWith(`](`)&&!o.startsWith(`)`)&&n.push({email:e,index:i})}for(let e=n.length-1;e>=0;e--){let{email:r,index:i}=n[e];t=t.substring(0,i)+`[${r}](mailto:${r})`+t.substring(i+r.length)}let i=[],a;for(er.lastIndex=0;(a=er.exec(t))!==null;){let e=a[0],n=a.index;if(tr.test(e))continue;let r=t.substring(0,n),o=t.substring(n+e.length);if(r.endsWith(`](`)||o.startsWith(`)`)||(r.match(/```/g)||[]).length%2!=0)continue;let s=r.lastIndexOf("`");if(s!==-1){let e=t.substring(s+1).indexOf("`");if(e!==-1&&e>n-s-1)continue}nr(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=rr(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function ar(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function or(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function sr({code:e}){let[t,n]=(0,i.useState)(!1),a=(0,i.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]);return(0,o.jsx)(`button`,{onClick:a,className:r.o(`absolute top-3 right-3 p-1.5 rounded-md`,`opacity-0 group-hover:opacity-100 transition-opacity duration-150`,`bg-zinc-200/80 hover:bg-zinc-300 dark:bg-zinc-700/80 dark:hover:bg-zinc-600`,`text-zinc-600 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,`focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500`),"aria-label":t?`Copied!`:`Copy code`,children:t?(0,o.jsx)(c.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,o.jsx)(c.Copy,{className:`h-4 w-4`})})}function cr({children:e}){let t=(0,i.useRef)(null),[n,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;a(t.trim())}}},[e]),(0,o.jsxs)(`div`,{className:`relative group my-5`,children:[(0,o.jsx)(`pre`,{ref:t,className:r.o(`p-4 rounded-xl overflow-x-auto`,`bg-zinc-100 dark:bg-zinc-900`,`border border-zinc-200 dark:border-zinc-800`,`text-[13px] font-mono leading-relaxed`,`text-zinc-800 dark:text-zinc-200`,`[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0`),children:e}),n&&(0,o.jsx)(sr,{code:n})]})}var lr=i.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,o.jsx)(`div`,{className:r.o(`text-muted-foreground text-sm`,t),children:`No content`});let i=ir(e);return(0,o.jsx)(`div`,{className:r.o(`kortix-markdown`,t),children:(0,o.jsx)(b.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,o.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground mt-8 mb-4 first:mt-0 pb-2 border-b border-border/40`,children:e}),h2:({children:e})=>(0,o.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,o.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,o.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,o.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,o.jsx)(`h6`,{className:`text-sm font-medium text-muted-foreground mt-4 mb-1 first:mt-0 uppercase tracking-wide`,children:e}),p:({children:e})=>(0,o.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed my-4 first:mt-0 last:mb-0 [&:has(img)]:my-0`,children:e}),ul:({children:e})=>(0,o.jsx)(`ul`,{className:`my-4 ml-6 list-disc marker:text-muted-foreground/60 space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),ol:({children:e})=>(0,o.jsx)(`ol`,{className:`my-4 ml-6 list-decimal marker:text-muted-foreground/60 marker:font-medium space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),li:({children:e})=>(0,o.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=ar(e),i=e?.startsWith(`#`),a=r.o(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return i?(0,o.jsx)(`a`,{href:e,onClick:t=>or(t,e),className:a,children:t}):n?(0,o.jsx)(h.default,{href:e||`#`,className:a,children:t}):(0,o.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,o.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,o.jsx)(`code`,{className:`px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground`,children:e}),pre:({children:e})=>(0,o.jsx)(cr,{children:e}),blockquote:({children:e})=>(0,o.jsx)(`blockquote`,{className:r.o(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,o.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,o.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,o.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,o.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,o.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,o.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,o.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,o.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,o.jsxs)(`span`,{className:`block my-5`,children:[(0,o.jsx)(`img`,{src:e,alt:t||``,className:r.o(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,o.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,o.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,o.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,o.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,o.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:r.o(`mr-2 h-4 w-4 rounded border-border`,`accent-secondary cursor-default`,`align-middle relative -top-[1px]`),...t}),div:({children:e,style:t,className:n,...i})=>(0,o.jsx)(`div`,{className:r.o(`text-sm text-foreground`,n),style:t,...i,children:e}),span:({children:e,style:t,className:n,...i})=>(0,o.jsx)(`span`,{className:r.o(`text-foreground`,n),style:t,...i,children:e})},children:i})})});lr.displayName=`UnifiedMarkdown`;var ur=(0,i.createContext)(null),dr=`qwksearch-main-view`;function fr({children:e,docsEnabled:t=!0}){let[n,r]=(0,i.useState)(`research`),[a,s]=(0,i.useState)(0),c=(0,i.useCallback)(e=>r(t?e:`research`),[t]);(0,i.useEffect)(()=>{if(typeof window>`u`||!t)return;let e=window.localStorage.getItem(dr);(e===`research`||e===`docs`)&&r(e)},[t]),(0,i.useEffect)(()=>{typeof window<`u`&&t&&window.localStorage.setItem(dr,n)},[n,t]);let l=(0,i.useMemo)(()=>({activeView:n,setActiveView:c,docsEnabled:t,toggleToDocs:()=>c(`docs`),toggleToResearch:()=>c(`research`),filesSidebarRequestId:a,requestFilesSidebar:()=>s(e=>e+1)}),[n,c,t,a]);return(0,o.jsx)(ur.Provider,{value:l,children:e})}var pr=Object.freeze({activeView:`research`,setActiveView:()=>{},docsEnabled:!1,toggleToDocs:()=>{},toggleToResearch:()=>{},filesSidebarRequestId:0,requestFilesSidebar:()=>{}}),mr=!1;function hr(){return(0,i.useContext)(ur)||(!mr&&process.env.NODE_ENV!==`production`&&(mr=!0,console.error(`useMainView was called outside a MainViewProvider. The component is rendering with view switching disabled — mount it inside MainViewProvider (see QwkSearchProviders).`)),pr)}var gr=[{key:`account`,name:`Account`,description:`Manage your profile, password, and linked accounts.`,icon:`UserCircle`,dataAdd:`account`},{key:`models`,name:`Language Models`,description:`Connect to AI services and manage connections.`,icon:`BrainCog`,dataAdd:`modelProviders`},{key:`mcpservers`,name:`Connectors`,description:`Configure Model Context Protocol servers.`,icon:`Server`,dataAdd:`mcpServers`},{key:`skills-memory`,name:`Skills & Memory`,description:`Manage agent skills and view your stored memories.`,icon:`Brain`,dataAdd:`skillsMemory`},{key:`searchEngines`,name:`Search Sources`,description:`Manage search engine sources by category.`,icon:`Search`,dataAdd:`searchEngines`},{key:`search`,name:`Search Settings`,description:`Configure search parameters.`,icon:`Search`,dataAdd:`search`},{key:`fileSources`,name:`Cloud Storage`,description:`Manage storage sources (SSH, S3, R2, B2, Google Docs, Turso DB).`,icon:`HardDrive`,dataAdd:`storage`},{key:`aiRewriteModes`,name:`Rewrite Modes`,description:`Customize AI rewrite prompts and add your own modes.`,icon:`Wand2`,dataAdd:`rewritePrompts`},{key:`voice`,name:`Voice Settings`,description:`Configure text-to-speech with Kokoro.js or Cloudflare TTS.`,icon:`Volume2`,dataAdd:`voice`}],_r=[{key:`webSearch`,title:`All`,description:`Searches across all of the internet`,icon:(0,o.jsx)(c.Globe,{size:16})},{key:`academicSearch`,title:`Academic`,description:`Search in published academic papers`,icon:(0,o.jsx)(c.SwatchBook,{size:16})},{key:`writingAssistant`,title:`Writing`,description:`Chat without searching the web`,icon:(0,o.jsx)(c.Pencil,{size:16})},{key:`wolframAlphaSearch`,title:`Wolfram Alpha`,description:`Computational knowledge engine`,icon:(0,o.jsx)(c.BadgePercent,{size:16})},{key:`youtubeSearch`,title:`Youtube`,description:`Search and watch videos`,icon:(0,o.jsx)(x.FaYoutube,{className:`h-[16px] w-auto mr-0.5`})},{key:`redditSearch`,title:`Reddit`,description:`Search for discussions and opinions`,icon:(0,o.jsx)(x.FaReddit,{className:`h-[16px] w-auto mr-0.5`})}],vr=[{href:`/`,label:`Research`,description:`The search and chat window`,keywords:`home chat ask question search`},{href:`/workspace`,label:`REASON Editor`,description:`Write up findings in the document editor`,keywords:`docs document write draft report`,docsOnly:!0},{href:`/library`,label:`Library`,description:`Saved chats, uploads and extracted articles`,keywords:`history saved files uploads archive`},{href:`/news`,label:`News`,description:`Trending stories by topic`,keywords:`discover trending headlines`},{href:`/docs`,label:`User Guide`,description:`How every part of the app works`,keywords:`documentation help manual`},{href:`/features`,label:`Features`,description:`Everything the research agent can do`,keywords:`capabilities tour`},{href:`/settings`,label:`Settings`,description:`Models, connectors, search sources and preferences`,keywords:`preferences configure options`},{href:`/enterprise`,label:`Enterprise`,description:`Self-hosting and team plans`,keywords:`business pricing teams`},{href:`/legal/privacy`,label:`Privacy Policy`,description:`What is stored and what is not`,keywords:`legal terms data`}];function yr(e){let t=e=>e===`/`?c.Search:e===`/workspace`?c.FileText:e===`/settings`?c.Settings:e===`/docs`?c.BookOpen:c.LayoutGrid;return vr.filter(t=>!t.docsOnly||e.docsEnabled).map(n=>({id:`page:${n.href}`,source:`page`,name:n.label,meta:n.description,keywords:`${n.keywords??``} ${n.href}`,icon:t(n.href),run:()=>e.navigate(n.href)}))}function br(e,t){let n=new Date;return e.map(e=>({id:`chat:${e.id}`,source:`chat`,name:e.title||`Untitled chat`,meta:`${e.messageCount??0} question${(e.messageCount??0)===1?``:`s`}`,keywords:e.focusMode??``,icon:c.MessageSquare,hint:r.c(n,e.lastMessageAt||e.createdAt),run:()=>t.openChat(e.id)}))}function xr(e){return gr.map(t=>({id:`setting:${t.key}`,source:`setting`,name:t.name,meta:t.description,keywords:`settings ${t.key}`,icon:c.SlidersHorizontal,run:()=>e.openSettings(t.key)}))}function Sr(e){let t=[{id:`action:new-chat`,source:`action`,name:`New chat`,meta:`Start a fresh conversation`,keywords:`clear reset blank`,icon:c.Plus,run:e.newChat},{id:`action:settings`,source:`action`,name:`Open settings`,meta:`Models, connectors, search sources and preferences`,keywords:`preferences configure`,icon:c.Settings,run:()=>e.openSettings()},{id:`action:incognito`,source:`action`,name:e.incognito?`Turn off incognito`:`Turn on incognito`,meta:`Stop saving this conversation to history`,keywords:`private incognito history off`,icon:c.EyeOff,hint:e.incognito?`on`:`off`,run:()=>e.setIncognito(!e.incognito)}];for(let n of _r)t.push({id:`action:focus:${n.key}`,source:`action`,name:`Focus: ${n.title}`,meta:n.description,keywords:`focus mode ${n.key}`,icon:c.Globe,hint:e.focusMode===n.key?`current`:void 0,run:()=>e.setFocusMode(n.key)});return e.docsEnabled&&t.push({id:`action:view-docs`,source:`action`,name:`Switch to documents`,meta:`Open the REASON editor view`,keywords:`reason editor write docs`,icon:c.FileText,run:()=>e.setActiveView(`docs`)},{id:`action:view-research`,source:`action`,name:`Switch to research`,meta:`Back to the search and chat view`,keywords:`chat search`,icon:c.Search,run:()=>e.setActiveView(`research`)},{id:`action:files-sidebar`,source:`action`,name:`Show files sidebar`,meta:`Browse REASON documents`,keywords:`files documents sidebar`,icon:c.FileText,run:()=>{e.setActiveView(`docs`),e.requestFilesSidebar()}}),t.push(e.isAuthenticated?{id:`action:sign-out`,source:`action`,name:`Sign out`,meta:`End this session`,keywords:`logout log out`,icon:c.LogOut,run:e.signOut}:{id:`action:sign-in`,source:`action`,name:`Sign in`,meta:`Sync chats and settings across devices`,keywords:`login log in account`,icon:c.LogIn,run:e.signIn}),t}function Cr(e,t){let n=e.trim();return n?{id:`search:ask`,source:`search`,name:n,meta:`Ask ${t.appName} — searches the web and answers with sources`,icon:c.Sparkles,hint:`Enter`,run:()=>t.ask(n)}:null}var $=[{prefix:`c`,source:`chat`,label:`chats`},{prefix:`t`,source:`page`,label:`pages`},{prefix:`s`,source:`setting`,label:`settings`},{prefix:`a`,source:`action`,label:`actions`},{prefix:`w`,source:`search`,label:`web`}];function wr(e){let t=e.match(/^([a-zA-Z])\s+(.*)$/);if(t){let e=t[1].toLowerCase(),n=$.find(t=>t.prefix===e);if(n)return{prefix:n.prefix,query:t[2]}}return{prefix:null,query:e}}var Tr=18;function Er(e){return`${e.meta??``} ${e.keywords??``}`.toLowerCase()}function Dr(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e.map(e=>({item:e,matchedName:!0,snippet:null}));let r=[],i=[];for(let t of e){let e=t.name.toLowerCase();if(n.every(t=>e.includes(t)))r.push(t);else{let r=`${e} ${Er(t)}`;n.every(e=>r.includes(e))&&i.push(t)}}let a=n[0];return r.sort((e,t)=>e.name.toLowerCase().indexOf(a)-t.name.toLowerCase().indexOf(a)),[...r.map(e=>({item:e,matchedName:!0,snippet:null})),...i.map(e=>({item:e,matchedName:!1,snippet:Or(Er(e),a)}))]}function Or(e,t){let n=e.indexOf(t);if(n<0)return``;let r=Math.max(0,n-Tr),i=Math.min(e.length,n+t.length+Tr),a=e.slice(r,i).replace(/\s+/g,` `).trim();return r>0&&(a=`…`+a),i<e.length&&(a+=`…`),a}var kr=`qwksearch:open-spotlight`,Ar=100,jr=6,Mr=40;function Nr(){typeof window<`u`&&window.dispatchEvent(new Event(kr))}function Pr(e){return e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.code===`Space`||e.key===` `)}var Fr={search:`ask`,chat:`chat`,page:`page`,setting:`setting`,action:`action`};function Ir(){let[e,s]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),[d,f]=(0,i.useState)(0),p=(0,a.useRouter)(),m=n.u(),{isAuthenticated:h,signIn:g,signOut:_}=n.c(),{docsEnabled:v,setActiveView:y,requestFilesSidebar:b}=hr(),{recentChats:x,load:S}=it(Ar),C=(0,i.useRef)(null),w=(0,i.useRef)(null),T=(0,i.useRef)(null),E=(0,i.useCallback)(()=>s(!1),[]),D=(0,i.useRef)(S);(0,i.useEffect)(()=>{D.current=S},[S]);let O=(0,i.useMemo)(()=>({appName:t.researchAgentUIConfig.appName,navigate:e=>p.push(e),openChat:e=>{t.researchAgentUIConfig.onOpenChat?.(e)||p.push(`/c/${e}`)},openSettings:e=>{t.researchAgentUIConfig.onOpenSettings?.(e)||p.push(e?`/settings/${e}`:`/settings`)},ask:e=>{m.newChat(),p.push(`/?q=${encodeURIComponent(e)}`)},newChat:m.newChat,focusMode:m.focusMode,setFocusMode:m.setFocusMode,incognito:m.incognito,setIncognito:m.setIncognito,isAuthenticated:h,signIn:g,signOut:_,docsEnabled:v,setActiveView:y,requestFilesSidebar:b}),[p,m.newChat,m.focusMode,m.setFocusMode,m.incognito,m.setIncognito,h,g,_,v,y,b]),{prefix:k,query:A}=wr(l),j=A.trim(),M=(0,i.useMemo)(()=>({chat:br(x,O),page:yr(O),setting:xr(O),action:Sr(O)}),[x,O]),N=(0,i.useMemo)(()=>{let e=Cr(A,O);if(k===`w`)return e?[e]:[];if(k){let e=$.find(e=>e.prefix===k).source;return Dr(M[e],A).map(e=>e.item).slice(0,Mr)}if(!j)return[...M.chat.slice(0,jr),...M.action,...M.page].slice(0,Mr);let t=Dr([...M.action,...M.page,...M.setting,...M.chat],A).map(e=>e.item);return[...e?[e]:[],...t].slice(0,Mr)},[k,A,j,M,O]);(0,i.useEffect)(()=>{let e=e=>{Pr(e)&&(e.preventDefault(),s(e=>!e))},t=()=>s(!0);return window.addEventListener(`keydown`,e),window.addEventListener(kr,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(kr,t)}},[]),(0,i.useEffect)(()=>{e?(f(0),D.current(),w.current?.focus()):(u(``),f(0))},[e]),(0,i.useEffect)(()=>{if(!e)return;let t=e=>{C.current&&!C.current.contains(e.target)&&E()};return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e,E]),(0,i.useEffect)(()=>{f(e=>e<N.length?e:Math.max(0,N.length-1))},[N.length]),(0,i.useEffect)(()=>{T.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[d,N.length]);let P=(0,i.useCallback)(e=>{e&&(E(),e.run())},[E]),F=(0,i.useCallback)(()=>{let e=$.map(e=>e.prefix),t=e[((k?e.indexOf(k):-1)+1)%e.length];u(`${t} ${A}`),f(0)},[k,A]),I=e=>{switch(e.key){case`Escape`:e.preventDefault(),E();break;case`ArrowDown`:e.preventDefault(),f(e=>N.length?(e+1)%N.length:0);break;case`ArrowUp`:e.preventDefault(),f(e=>N.length?(e-1+N.length)%N.length:0);break;case`Enter`:e.preventDefault(),e.stopPropagation(),P(N[d]);break;case`Tab`:e.preventDefault(),F()}};if(!e)return null;let L=k?$.find(e=>e.prefix===k):null;return(0,o.jsx)(`div`,{className:`fixed inset-0 z-[10000] flex items-start justify-center bg-black/40 backdrop-blur-[2px] px-4 pt-[12vh]`,role:`presentation`,children:(0,o.jsxs)(`div`,{ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Search everything`,className:`w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-popover shadow-2xl`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4`,children:[(0,o.jsx)(c.Search,{size:18,className:`shrink-0 text-muted-foreground`}),(0,o.jsx)(`input`,{ref:w,value:l,onChange:e=>{u(e.target.value),f(0)},onKeyDown:I,type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Search everything`,"aria-autocomplete":`list`,"aria-controls":`spotlight-results`,"aria-activedescendant":N[d]?.id,placeholder:L?`Search ${L.label}…`:`Search chats, pages, settings — or ask anything`,className:`w-full bg-transparent py-4 text-base text-popover-foreground outline-none placeholder:text-muted-foreground`}),L&&(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:L.label})]}),(0,o.jsx)(`div`,{ref:T,id:`spotlight-results`,role:`listbox`,"aria-label":`Results`,className:`max-h-[50vh] overflow-y-auto p-1`,onMouseDown:e=>e.preventDefault(),children:N.length===0?(0,o.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No matches. Press Tab to search another source.`}):N.map((e,t)=>{let n=e.icon;return(0,o.jsxs)(`div`,{id:e.id,role:`option`,"aria-selected":t===d,"data-selected":t===d,onMouseMove:()=>f(t),onClick:()=>P(e),className:r.o(`flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2 transition-colors`,t===d?`bg-secondary`:`hover:bg-secondary/60`),children:[(0,o.jsx)(n,{size:16,className:r.o(`shrink-0`,t===d?`text-primary`:`text-muted-foreground`)}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm text-popover-foreground`,children:e.name}),e.meta&&(0,o.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.meta})]}),e.hint&&(0,o.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.hint}),(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-1.5 py-0 text-[10px] text-muted-foreground`,children:Fr[e.source]})]},e.id)})}),(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-4 py-2 text-[11px] text-muted-foreground`,children:[(0,o.jsx)(`span`,{children:`↑↓ move`}),(0,o.jsx)(`span`,{children:`↵ open`}),(0,o.jsx)(`span`,{children:`⇥ next source`}),(0,o.jsx)(`span`,{children:`esc close`}),(0,o.jsx)(`span`,{className:`ml-auto`,children:$.map(e=>`${e.prefix} ${e.label}`).join(` · `)})]})]})})}var Lr={device:`webgpu`,dtype:`fp32`},Rr={device:`wasm`,dtype:`q8`},zr=`hexgrad/Kokoro-82M`,Br=null,Vr=null;function Hr(){return typeof navigator<`u`&&`gpu`in navigator}async function Ur(){if(!Hr())return!1;try{return await navigator.gpu.requestAdapter()!=null}catch{return!1}}async function Wr(e){let t=[];await Ur()&&t.push(Lr),t.push(Rr);let{KokoroTTS:n}=await import(`kokoro-js`),r;for(let i of t)try{let t=await n.from_pretrained(zr,{device:i.device,dtype:i.dtype,progress_callback:e});return Vr=i.device,t}catch(e){r=e,console.warn(`Kokoro model failed to load on "${i.device}" backend:`,e)}throw r instanceof Error?r:Error(`Failed to load Kokoro model`)}async function Gr(e){return Br||=Wr(e).catch(e=>{throw Br=null,e}),Br}async function Kr(e){return Gr(e)}async function qr(){let e=await Kr();return Object.keys(e.voices)}function Jr(){return Vr}function Yr(e,t){let[n,r]=(0,i.useState)(`idle`),[a,o]=(0,i.useState)(!1),[s,c]=(0,i.useState)([]),[l,u]=(0,i.useState)(`af_heart`),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null),h=(0,i.useRef)(null),g=(0,i.useRef)(null);(0,i.useEffect)(()=>{t?.autoPreload&&!a&&v()},[t?.autoPreload,a]),(0,i.useEffect)(()=>{let e=localStorage.getItem(`kokoroVoice`);e&&u(e)},[]),(0,i.useEffect)(()=>()=>{h.current&&h.current.pause(),g.current?.abort()},[]);let _=(0,i.useCallback)(()=>{h.current&&=(h.current.pause(),h.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(h.current.src),null),g.current?.abort(),g.current=null},[]),v=(0,i.useCallback)(async()=>{try{r(`loading`),f(null),m(null),await Gr(e=>{m(e)});let e=await qr();c(e),e.length&&!e.includes(l)&&u(e[0]),o(!0),r(`idle`)}catch(e){let t=e instanceof Error?e.message:`Failed to load model`;f(t),r(`error`),console.error(`Failed to load Kokoro model:`,e)}},[l]);return{status:n,modelReady:a,voices:s,selectedVoice:l,error:d,progress:p,warmupModel:v,speak:(0,i.useCallback)(async()=>{if(e?.trim()){if(!a)f(`Model not loaded. Click "Preload Model" first.`);else try{_(),r(`generating`),f(null);let t=new AbortController;g.current=t;let n=(await(await Kr()).generate(e.slice(0,5e3),{voice:l})).toWav(),i=new Blob([n],{type:`audio/wav`}),a=URL.createObjectURL(i),o=new Audio(a);h.current=o,o.onended=()=>{r(`idle`),URL.revokeObjectURL(a),h.current=null},o.onerror=()=>{r(`error`),f(`Failed to play audio`),URL.revokeObjectURL(a),h.current=null},r(`playing`),await o.play()}catch(e){if(e?.name!==`AbortError`){let t=e instanceof Error?e.message:`Speech generation failed`;f(t),r(`error`),console.error(`Kokoro TTS error:`,e)}}}},[e,l,a,_]),stop:(0,i.useCallback)(()=>{_(),r(`idle`),f(null)},[_]),changeVoice:(0,i.useCallback)(e=>{u(e),localStorage.setItem(`kokoroVoice`,e)},[]),backend:Jr()}}function Xr(e,t){let[n,r]=(0,i.useState)(`stopped`),[a,o]=(0,i.useState)(!1),s=(0,i.useRef)(null),c=(0,i.useRef)(null),l=(0,i.useRef)(null),d=(0,i.useRef)(t);d.current=t;let f=(0,i.useCallback)(()=>{s.current&&=(s.current.pause(),s.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(s.current.src),null),l.current?.abort(),l.current=null},[]),p=(0,i.useCallback)(()=>{f(),c.current=null,window.speechSynthesis?.cancel(),r(`stopped`),o(!1)},[f]),m=(0,i.useCallback)(()=>{if(!(`speechSynthesis`in window))return!1;try{window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);return c.current=t,t.onend=()=>{c.current=null,r(`stopped`)},t.onerror=()=>{c.current=null,r(`stopped`)},window.speechSynthesis.speak(t),r(`started`),!0}catch{return!1}},[e]);return{speechStatus:n,isLoading:a,start:(0,i.useCallback)(async()=>{if(!e?.trim())return;f(),window.speechSynthesis?.cancel(),c.current=null,r(`started`),o(!0);let t=new AbortController;l.current=t;try{let n=localStorage.getItem(`useTTSKokoro`);if(n===null||n!==`false`)try{let t=await Kr(e=>{(e.status===`progress_total`||e.status===`progress`||e.status===`download`)&&console.log(`[Kokoro] Loading: ${Math.round(e.progress??0)}%`)}),n=localStorage.getItem(`kokoroVoice`)||`af_heart`,i=(await t.generate(e.slice(0,5e3),{voice:n})).toWav(),a=new Blob([i],{type:`audio/wav`}),c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},o(!1),await l.play();return}catch(e){console.debug(`Kokoro TTS unavailable, using server-side TTS:`,e instanceof Error?e.message:String(e)),o(!1)}o(!1);let i=await(0,u.default)(`agent/voice`,{method:`POST`,body:{text:e.slice(0,5e3),voice:localStorage.getItem(`kokoroVoice`)||`af_heart`},signal:t.signal}),a=typeof i.blob==`function`?await i.blob():i;if(!a||a.size===0){m()||r(`stopped`);return}let c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},await l.play()}catch{m()||r(`stopped`)}},[e,f,m]),stop:p}}var Zr={af_heart:`American Female - Heart`,af_bella:`American Female - Bella`,af_nicole:`American Female - Nicole`,af_sarah:`American Female - Sarah`,am_adam:`American Male - Adam`,am_michael:`American Male - Michael`,am_tony:`American Male - Tony`,bf_emma:`British Female - Emma`,bm_george:`British Male - George`,bm_thomas:`British Male - Thomas`};function Qr({preloadOnMount:e=!1}){let{status:t,modelReady:a,voices:s,selectedVoice:l,error:u,progress:d,warmupModel:f,changeVoice:p,backend:m}=Yr(``,{autoPreload:e}),[h,g]=(0,i.useState)(!1),_=t===`loading`,v=t===`error`;return(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:f,disabled:_||a,className:r.o(`p-2 rounded-full transition duration-200`,a?`bg-green-500/10 text-green-600 dark:text-green-400`:`bg-white/10 dark:bg-black/10 text-muted-foreground hover:bg-white/20 dark:hover:bg-black/20`,_&&`opacity-70 cursor-not-allowed`),children:_?(0,o.jsx)(c.Loader2,{size:18,className:`animate-spin`}):(0,o.jsx)(c.Download,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:_?d?d.status===`progress_total`||d.status===`progress`?`Downloading Kokoro model... ${Math.round(d.progress??0)}%`:`Loading Kokoro model... ${d.status}`:`Loading Kokoro model...`:a?`Model ready`:`Preload Kokoro.js model`})]}),a&&m&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[m,` • `,s.length,` voices`]}),_&&d&&(d.status===`progress_total`||d.status===`progress`||d.status===`download`)&&(0,o.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 max-w-xs`,children:[(0,o.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-white/10 dark:bg-black/10`,children:(0,o.jsx)(`div`,{className:`h-1.5 bg-blue-500 transition-all duration-200`,style:{width:`${Math.round(d.progress??0)}%`}})}),(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap tabular-nums`,children:[Math.round(d.progress??0),`%`]})]}),v&&(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(c.AlertCircle,{size:18,className:`text-red-500`})}),(0,o.jsx)(n.n,{side:`bottom`,className:`max-w-xs`,children:u})]})]}),a&&(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsx)(`button`,{onClick:()=>g(!h),className:`w-full text-left px-3 py-2 rounded-md bg-white/5 dark:bg-black/5 hover:bg-white/10 dark:hover:bg-black/10 transition text-sm font-medium`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(c.Volume2,{size:16}),Zr[l]||l]})}),h&&(0,o.jsx)(`div`,{className:`grid grid-cols-2 gap-2 p-2 bg-white/5 dark:bg-black/5 rounded-md max-h-64 overflow-y-auto`,children:s.map(e=>(0,o.jsx)(`button`,{onClick:()=>{p(e),g(!1)},className:r.o(`p-2 text-left text-sm rounded transition duration-200`,l===e?`bg-blue-500/20 text-blue-600 dark:text-blue-400 font-medium`:`bg-white/5 dark:bg-black/5 text-foreground hover:bg-white/10 dark:hover:bg-black/10`),children:Zr[e]||e},e))})]})]})}function $r(){let[e,t]=(0,i.useState)(!1),[a,s]=(0,i.useState)(()=>{let e=localStorage.getItem(`useTTSKokoro`);return e===null||e!==`false`}),[l,u]=(0,i.useState)(()=>localStorage.getItem(`ttsSpeaker`)||`angus`),[d,f]=(0,i.useState)(()=>Se()),{start:p,speechStatus:m}=Xr(`This is a preview of the selected voice.`,{enableInterrupt:!1}),h=e=>{s(e),localStorage.setItem(`useTTSKokoro`,String(e))},g=e=>{u(e),localStorage.setItem(`ttsSpeaker`,e)},_=e=>{f(e),Ce(e)};return(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(c.Settings2,{size:18}),(0,o.jsx)(`h3`,{className:`font-semibold`,children:`Voice Settings`})]}),(0,o.jsx)(`button`,{onClick:()=>t(!e),className:`text-xs px-3 py-1 rounded-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition`,children:e?`Collapse`:`Expand`})]}),e&&(0,o.jsxs)(`div`,{className:`space-y-4 p-4 rounded-lg bg-white/5 dark:bg-black/5 border border-white/10 dark:border-black/10`,children:[(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>h(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Kokoro.js (Local TTS)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Runs locally in your browser. No server requests, lower latency, and multiple voice options.`})]})]}),a&&(0,o.jsx)(Qr,{preloadOnMount:!1})]}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!a,onChange:e=>h(!e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Cloudflare TTS (Fallback)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Uses Cloudflare Workers AI. Slightly higher latency but can be a fallback.`})]})]}),!a&&(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`select`,{value:l,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 rounded-md bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 text-sm`,children:[(0,o.jsx)(`option`,{value:`angus`,children:`Angus`}),(0,o.jsx)(`option`,{value:`flora`,children:`Flora`}),(0,o.jsx)(`option`,{value:`james`,children:`James`}),(0,o.jsx)(`option`,{value:`natalie`,children:`Natalie`})]}),(0,o.jsxs)(`button`,{onClick:()=>p(),disabled:m===`started`,className:r.o(`w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition`,m===`started`?`bg-gray-500/20 text-gray-600 dark:text-gray-400 cursor-not-allowed`:`bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30`),children:[(0,o.jsx)(c.Volume2,{size:16}),m===`started`?`Playing...`:`Preview`]})]})]}),(0,o.jsx)(`div`,{className:`space-y-2 pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>_(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Start talking automatically on first visit`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Opens the mic the first time you load the chat composer in this browser, so you can start talking right away instead of clicking the mic button.`})]})]})}),(0,o.jsx)(`div`,{className:`text-xs text-muted-foreground pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:`Tip:`}),` Kokoro.js loads once and runs locally. The first model load may take a few seconds, but subsequent TTS generation is very fast.`]})})]})]})}var ei=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%3e%3cpath%20style='fill:%23FE5022;'%20d='M438.802,390.609V278.595h55.174c9.938,0,18.023,8.085,18.023,18.023v75.967%20c0,9.938-8.086,18.024-18.023,18.024L438.802,390.609L438.802,390.609z'/%3e%3cpath%20style='fill:%23ECE5DD;'%20d='M28.107,511.637C12.609,511.637,0,499.027,0,483.529V134.326c0-1.441,0-12.123,0-12.123%20L121.715,0.363c0,0,10.8,0,12.248,0h271.569c15.498,0,28.107,12.609,28.107,28.106v455.059c0,15.499-12.609,28.108-28.107,28.108%20H28.107V511.637z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M405.533,0.363h-31.991c15.498,0,28.107,12.609,28.107,28.107v455.059%20c0,15.499-12.609,28.108-28.107,28.108h31.991c15.498,0,28.107-12.609,28.107-28.108V28.469%20C433.64,12.972,421.031,0.363,405.533,0.363z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3c/g%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M0.726,123.171L122.442,1.331l1.39,105.939c0,9.465-7.7,17.166-17.166,17.166L0.726,123.171z'/%3e%3cpath%20style='fill:%23FFB656;'%20d='M270.226,401.7V267.504H456.87c5.938,0,10.768,4.83,10.768,10.768v112.659%20c0,5.938-4.83,10.769-10.768,10.769H270.226z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M367.785,335.156c-12.822,0-23.252-10.431-23.252-23.254v-44.399h89.833v44.399%20c0,12.823-10.431,23.254-23.252,23.254H367.785z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M345.087,448.28H101.096c-4.594,0-8.318,3.723-8.318,8.318c0,4.595,3.724,8.318,8.318,8.318h243.992%20c4.594,0,8.318-3.723,8.318-8.318C353.405,452.003,349.681,448.28,345.087,448.28z'/%3e%3c/g%3e%3cpath%20style='fill:%23FE5022;'%20d='M163.689,357.337c-3.692,0-6.094-3.886-4.443-7.189l16.225-32.451%20c1.799-3.597,5.416-5.833,9.438-5.833h44.282v45.471h-65.503V357.337z'/%3e%3cpolygon%20style='fill:%23FFB656;'%20points='256.918,278.252%20211.447,300.988%20211.447,368.216%20256.918,390.953%20284.321,390.953%20284.321,278.214%20'/%3e%3cg%3e%3cpath%20style='fill:%23FE5022;'%20d='M268.64,401.7c-7.075,0-12.832-5.756-12.832-12.832V280.336c0-7.075,5.756-12.831,12.832-12.831%20h19.808c7.075,0,12.832,5.756,12.832,12.831v108.532c0,7.076-5.756,12.832-12.832,12.832H268.64z'/%3e%3cpath%20style='fill:%23FE5022;'%20d='M104.156,379.377H26.143V301.33h91.398c8.546,0,14.88,7.936,12.986,16.27l-11.313,49.758%20C117.615,374.388,111.366,379.377,104.156,379.377z'/%3e%3c/g%3e%3c/svg%3e`,ti=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%2064%2064'%20xml:space='preserve'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%2376C2AF;}%20.st1{fill:%234F5D73;}%20.st2{opacity:0.2;}%20.st3{fill:%23231F20;}%20.st4{fill:%23FFFFFF;}%20%3c/style%3e%3cg%20id='Layer_1'%3e%3cg%3e%3ccircle%20class='st0'%20cx='32'%20cy='32'%20r='32'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M32,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C34,51.1,33.1,52,32,52L32,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M46,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C48,51.1,47.1,52,46,52L46,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M18,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C20,51.1,19.1,52,18,52L18,52z'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='45.9'%20cy='38'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='32'%20cy='27'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='18'%20cy='44'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='45.9'%20cy='36'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='32'%20cy='25'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='18'%20cy='42'%20r='4'/%3e%3c/g%3e%3c/g%3e%3cg%20id='Layer_2'%3e%3c/g%3e%3c/svg%3e`;function ni(){let e=(0,a.usePathname)(),r=(0,a.useRouter)(),{isAuthenticated:i,signIn:s,signOut:l}=n.c(),{newChat:u}=n.u(),{activeView:d,setActiveView:f,docsEnabled:p,requestFilesSidebar:m}=hr(),h=[{href:`/`,label:`Research`,icon:t.researchAgentUIConfig.appIconUrl},...p?[{href:`/workspace`,label:`Docs`,icon:(0,o.jsx)(w.default,{src:ei,alt:`Docs`,width:24,height:24,unoptimized:!0,className:`w-full h-full`})}]:[]],g=e===`/`||e.startsWith(`/c`),_=[...h.map(({href:e,label:t,icon:n})=>({key:e,label:t,icon:n,active:e===`/`?d===`research`:d===`docs`,onClick:()=>{e===`/`?(f(`research`),g&&u()):f(`docs`)}})),...p?[{key:`files`,label:`Files`,icon:(0,o.jsx)(c.FileText,{className:`w-full h-full p-1`}),onClick:()=>{f(`docs`),m()}}]:[],{key:`settings`,label:`Settings`,icon:(0,o.jsx)(w.default,{src:ti,alt:`Settings`,width:24,height:24,unoptimized:!0,className:`w-full h-full`}),menu:{renderContent:()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>Nr(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.Search,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Search`}),(0,o.jsx)(`span`,{className:`ml-auto pl-3 text-[10px] text-muted-foreground`,children:`Ctrl Space`})]}),(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>{t.researchAgentUIConfig.onOpenSettings?.()||r.push(`/settings`)},className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.Settings,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Settings`})]}),i?(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>l(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.LogOut,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Logout`})]}):(0,o.jsxs)(C.DropdownMenuItem,{onClick:()=>s(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(c.LogIn,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Login`})]}),(0,o.jsx)(C.DropdownMenuSeparator,{}),(0,o.jsx)(C.ThemeMenu,{})]})}}],v=_.filter(e=>e.key!==`files`),y=(e,t,n)=>(0,o.jsx)(w.default,{src:e,alt:t,width:n,height:n,unoptimized:!0,className:`w-full h-full`});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(C.CategoryDock,{items:v,enableKeyboardShortcuts:!0,placements:{desktop:!0,mobile:!1},renderImage:y}),(0,o.jsx)(C.CategoryDock,{items:_,placements:{desktop:!1,mobile:!0},mobileAlign:d===`docs`?`end`:`center`,renderImage:y})]})}function ri(){return(0,o.jsx)(T.CookieConsent,{appName:t.researchAgentUIConfig.appName,links:t.researchAgentUIConfig.footerLinks,heightVar:`--qs-bottom-right-inset`})}var ii=`qwk:chunk-error-reload`,ai=6e4,oi=/Loading (CSS )?chunk|ChunkLoadError|Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function si(e){if(typeof e==`string`)return oi.test(e);if(e&&typeof e==`object`){let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&oi.test(n)}return!1}function ci(e){if(typeof window>`u`||!si(e))return!1;try{let e=Number(window.sessionStorage.getItem(ii));if(e&&Date.now()-e<ai)return!1;window.sessionStorage.setItem(ii,String(Date.now()))}catch{return!1}return window.location.reload(),!0}function li(){(0,i.useEffect)(()=>{let e=e=>{ci(e.error??e.message)},t=e=>{ci(e.reason)},n=e=>{ci(e.payload??`Loading chunk`)&&e.preventDefault()};return window.addEventListener(`error`,e),window.addEventListener(`unhandledrejection`,t),window.addEventListener(`vite:preloadError`,n),()=>{window.removeEventListener(`error`,e),window.removeEventListener(`unhandledrejection`,t),window.removeEventListener(`vite:preloadError`,n)}},[])}var ui=({children:e})=>(0,o.jsx)(o.Fragment,{children:e});function di(e){let[t,n]=(0,i.useState)(e===!0);return(0,i.useEffect)(()=>{if(e!==`auto`){n(e);return}let t=!1;return(0,u.default)(`auth/providers`).then(e=>{t||n(!!e.providers?.includes(`google`))}).catch(()=>{t||n(!1)}),()=>{t=!0}},[e]),t}function fi({children:e,authClient:r,config:i,googleOneTap:a=`auto`,docsEnabled:s=!0,ChromeProvider:c=ui,showDock:u=!0,showCookieConsent:d=!0,showToaster:f=!0,showSpotlight:p=!0}){i&&t.configureResearchAgentUI(i);let m=di(a);return li(),(0,o.jsx)(S.ThemeProvider,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,children:(0,o.jsx)(n.s,{authClient:r,enableGoogleOneTap:m,children:(0,o.jsx)(n.i,{children:(0,o.jsx)(ge,{children:(0,o.jsx)(fr,{docsEnabled:s,children:(0,o.jsx)(C.CategoryDockProvider,{children:(0,o.jsxs)(c,{children:[(0,o.jsxs)(`div`,{id:`app-scroll-root`,className:`w-screen h-screen overflow-y-auto overflow-x-hidden pb-[calc(60px+env(safe-area-inset-bottom,0px))] md:pb-0`,children:[u&&(0,o.jsx)(ni,{}),(0,o.jsx)(`main`,{className:`bg-light-primary dark:bg-dark-primary min-h-screen`,children:e})]}),f&&(0,o.jsx)(l.Toaster,{toastOptions:{unstyled:!0,classNames:{toast:`bg-light-secondary dark:bg-dark-secondary dark:text-white/70 text-black-70 rounded-lg p-4 flex flex-row items-center space-x-2`}}}),d&&(0,o.jsx)(ri,{}),p&&(0,o.jsx)(Ir,{})]})})})})})})})}function pi(e){return(0,o.jsx)(fi,{...e,docsEnabled:!1,children:(0,o.jsx)(jn,{})})}var mi=`qwksearch-open-chat-tabs`,hi=50;function gi(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(mi);return e?JSON.parse(e):[]}catch{return[]}}function _i(){let{chatId:e,chatTurns:t,startNewChat:r,switchToChat:a}=n.u(),[o,s]=(0,i.useState)(gi),c=(0,i.useRef)(null);(0,i.useEffect)(()=>{window.localStorage.setItem(mi,JSON.stringify(o))},[o]),(0,i.useEffect)(()=>{if(!e)return;let n=t[0]?.content?.slice(0,hi),r=t.length>0;s(t=>{let i=t.find(t=>t.id===e);return!i&&e===c.current&&!r?t:i?n&&i.title!==n||i.hasMessages!==r?t.map(t=>t.id===e?{...t,title:n||t.title,hasMessages:r}:t):t:[...t,{id:e,title:n||`New Chat`,hasMessages:r}]})},[e,t]);let l=(0,i.useCallback)((e,t)=>{let n=t.find(t=>t.id===e);n&&!n.hasMessages?r(e):a(e)},[r,a]),u=(0,i.useCallback)(e=>{l(e,o)},[l,o]),d=(0,i.useCallback)(()=>{let e=crypto.randomUUID();return s(t=>[...t,{id:e,title:`New Chat`}]),r(e),e},[r]),f=(0,i.useCallback)(t=>{let n=new Set(t),i=o.filter(e=>!n.has(e.id));s(i);let a=e!=null&&n.has(e);if(!a)return{closedWasActive:!1,nextActiveId:null};if(i.length===0){let e=crypto.randomUUID();return c.current=e,r(e),{closedWasActive:a,nextActiveId:null}}let u=o.findIndex(t=>t.id===e),d=e=>e!=null&&!n.has(e.id),f;for(let e=u-1;e>=0&&!f;e--)d(o[e])&&(f=o[e]);for(let e=u+1;e<o.length&&!f;e++)d(o[e])&&(f=o[e]);let p=(f??i[0]).id;return l(p,i),{closedWasActive:a,nextActiveId:p}},[o,e,l,r]),p=(0,i.useCallback)(e=>f([e]),[f]);return{chatTabs:o,activeChatId:e??null,openChat:u,newChat:d,closeChat:p,closeChats:f}}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Yn}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return Rn}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return jn}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return Bn}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return zn}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return en}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ni}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Xr}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Kn}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $r}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return li}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _i}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return lr}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return Kt}});
|
package/dist/workspace.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./src-
|
|
1
|
+
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./src-cbzeR_Vl.cjs"),n=require("./config.cjs"),r=require("./tooltip-DmUO6ZUz.cjs"),i=require("./dialog-7GDz0sWx.cjs");let a=require("react"),o=require("next/navigation"),s=require("react/jsx-runtime"),c=require("grab-url");c=e.t(c,1);let l=require("react-reason-editor/reason-docs"),u=require("react-reason-editor/theme"),d=require("react-reason-editor/locale-bundle"),f=require("react-reason-editor-sidebar");function p(e){return e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,` `).replace(/<[^>]+>/g,` `).replace(/ /g,` `).replace(/\s+/g,` `).trim()}var m=async(e,t)=>{try{let n=await(0,c.default)(`agent/page-tips`,{method:`POST`,body:JSON.stringify({title:e,content:t})});return Array.isArray(n.tips)?n.tips:[]}catch{return[]}},h=async(e,t)=>{try{let n=await(0,c.default)(`agent/topic-searches`,{method:`POST`,body:JSON.stringify({title:e,content:t})});return Array.isArray(n.topics)?n.topics:[]}catch{return[]}},g=`/api/doc/google-docs`,_=`application/vnd.google-apps.document`,v=`application/vnd.google-apps.spreadsheet`,y=`application/vnd.google-apps.presentation`,b=`application/vnd.google-apps.drawing`,x=`application/vnd.google-apps.folder`,S=class extends Error{needsReauth;needsFolderAccess;status;constructor(e,t,n={}){super(e),this.name=`GoogleDriveError`,this.status=t,this.needsReauth=!!n.needsReauth,this.needsFolderAccess=!!n.needsFolderAccess}};async function C(e){let t=await fetch(`${g}${e}`,{credentials:`same-origin`}),n={};try{n=await t.json()}catch{}if(!t.ok||n?.success===!1)throw new S(n?.error||`Google Drive request failed (${t.status})`,t.status,n);return n}function w(e){return e===_||e===`text/plain`||e===`text/markdown`?`editor`:e===`application/pdf`||e===v||e===y?`pdf`:e===b||e.startsWith(`image/`)?`image`:`unsupported`}function T(e){if(e.mimeType===_)return`docx`;if(e.mimeType===v)return`xlsx`;if(e.mimeType===y)return`pptx`;if(e.mimeType===b)return`png`;let t=e.name.lastIndexOf(`.`);if(t>0&&t<e.name.length-1)return e.name.slice(t+1).toLowerCase();if(e.mimeType===`application/pdf`)return`pdf`;let n=e.mimeType.split(`/`)[1];return n&&/^[a-z0-9]{2,5}$/.test(n)?n:void 0}var E=(e,t)=>`${e}:${t}`,D=e=>`${g}/content?fileId=${encodeURIComponent(e)}`;function O(e,t){let n=[],r=new Set,i=(e,t)=>Number(t.mimeType===`application/vnd.google-apps.folder`)-Number(e.mimeType===`application/vnd.google-apps.folder`)||e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:`base`});for(let{root:a,items:o}of t){let s=E(e,a.id);if(r.has(s))continue;r.add(s),n.push({id:s,title:a.name,content:``,parentId:null,isFolder:!0,isExpanded:t.length===1,external:{sourceId:e,fileId:a.id,mimeType:x,view:`unsupported`,webViewLink:a.webViewLink}});let c=new Set([a.id,...o.filter(e=>e.mimeType===x).map(e=>e.id)]);for(let t of[...o].sort(i)){let i=E(e,t.id);if(r.has(i))continue;r.add(i);let o=t.parents?.find(e=>c.has(e))??a.id,s=t.mimeType===x,l=s?`unsupported`:w(t.mimeType);n.push({id:i,title:t.name,content:``,parentId:E(e,o),isFolder:s,isExpanded:!1,external:{sourceId:e,fileId:t.id,mimeType:t.mimeType,view:l,extension:s?void 0:T(t),contentUrl:s||l===`unsupported`?void 0:D(t.id),webViewLink:t.webViewLink}})}}return n}function k(e){return e?.folders?.length?e.folders:(e?.folderIds??[]).map(e=>({id:e,name:e===`root`?`My Drive`:e}))}async function A(e){let t=k(e.credentials);if(t.length===0)return[];let n=await Promise.allSettled(t.map(e=>C(`/folder-tree?folderId=${encodeURIComponent(e.id)}`))),r=n.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);if(r.length===0)throw n[0].reason;return O(e.id,r)}function j(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function M(e){return e.split(/\r?\n\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${j(e).replace(/\r?\n/g,`<br>`)}</p>`).join(``)}function N(e){if(typeof DOMParser>`u`){let t=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return(t?t[1]:e).replace(/<(script|style)[\s\S]*?<\/\1>/gi,``)}let t=new DOMParser().parseFromString(e,`text/html`),n=new Map;for(let e of Array.from(t.querySelectorAll(`style`)))for(let t of(e.textContent??``).matchAll(/\.([A-Za-z0-9_-]+)\s*\{([^}]*)\}/g))n.set(t[1],`${n.get(t[1])??``};${t[2]}`);t.querySelectorAll(`script, style, meta, link, title`).forEach(e=>e.remove());for(let e of Array.from(t.body.querySelectorAll(`span`))){let r=[...Array.from(e.classList).map(e=>n.get(e)??``),e.getAttribute(`style`)??``].join(`;`),i=Array.from(e.childNodes),a=e=>{let n=t.createElement(e);i.forEach(e=>n.appendChild(e)),i=[n]};/font-weight:\s*(700|800|900|bold)/i.test(r)&&a(`strong`),/font-style:\s*italic/i.test(r)&&a(`em`),/text-decoration[^;]*underline/i.test(r)&&a(`u`),/text-decoration[^;]*line-through/i.test(r)&&a(`s`),e.replaceWith(...i)}for(let e of Array.from(t.body.querySelectorAll(`a[href]`)))try{let t=new URL(e.getAttribute(`href`));t.hostname===`www.google.com`&&t.pathname===`/url`&&t.searchParams.get(`q`)&&e.setAttribute(`href`,t.searchParams.get(`q`))}catch{}for(let e of Array.from(t.body.querySelectorAll(`[class], [style], [id]`)))e.removeAttribute(`class`),e.removeAttribute(`style`),e.removeAttribute(`id`);return t.body.innerHTML.trim()}async function P(e){let t=e.external;if(!t?.contentUrl)return``;let n=await fetch(t.contentUrl,{credentials:`same-origin`});if(!n.ok){let e={};try{e=await n.json()}catch{}throw new S(e?.error||`Couldn't load the file (${n.status})`,n.status,e)}let r=await n.text();return t.mimeType===_?N(r):M(r)}var F={canList:e=>e.type===`gdocs`,listDocuments:e=>A(e),loadDocumentContent:P};function I({SidebarComponent:e=f.Sidebar,SidebarContentComponent:i=f.SidebarContent,openSidebarEvent:c}={}){let{activeView:g,toggleToDocs:_,toggleToResearch:v,filesSidebarRequestId:y,requestFilesSidebar:b}=t.b(),{chatTabs:x,activeChatId:S,openChat:C,newChat:w,closeChat:T,closeChats:E}=t.t(),{sendMessage:D}=r.u(),{signIn:O}=r.c(),k=(0,o.useSearchParams)(),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(null),[P,I]=(0,a.useState)(!1),[L,R]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(c)return window.addEventListener(c,b),()=>window.removeEventListener(c,b)},[c,b]),(0,a.useEffect)(()=>{d.localeActions.setLang(`en`),u.themeActions.setColor(`default`)},[]);let z=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(z.current)return;z.current=!0;let e=k.get(`docs`),t=k.get(`chat`);e?(N(e),_()):t&&(C(t),v()),I(!0)},[]),(0,a.useEffect)(()=>{if(typeof window>`u`||!P)return;let e=new URL(window.location.href);e.searchParams.set(`chat`,g===`research`?S??``:``),e.searchParams.set(`docs`,g===`docs`?A??``:``);let t=`${e.pathname}?${e.searchParams.toString()}${e.hash}`;t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(null,``,t)},[g,S,A,P]);let B=x.map(e=>({id:e.id,title:e.title,kind:`chat`})),V=e=>{C(e),v()},H=e=>{let{closedWasActive:t,nextActiveId:n}=T(e);t&&!n&&_()},U=e=>{let{closedWasActive:t,nextActiveId:n}=E(e);t&&!n&&_()},W=()=>{w(),v()},G=(0,a.useCallback)(e=>(C(e),v(),!0),[C,v]);(0,a.useEffect)(()=>(n.configureResearchAgentUI({onOpenChat:G}),()=>n.configureResearchAgentUI({onOpenChat:void 0})),[G]);let K=async(e,t)=>m(e,p(t)),q=async(e,t)=>h(e,p(t)),J=(0,a.useCallback)(e=>{w(),v(),R(e)},[w,v]);(0,a.useEffect)(()=>{L&&S&&(D(L),R(null))},[L,S,D]);let Y={extraTabs:B,activeExtraTabId:g===`research`?S??void 0:void 0,onExtraTabSelect:V,onExtraTabClose:H,onExtraTabsClose:U,onExtraTabAdd:W,onFileTabSelect:_,initialDocId:M,onActiveDocumentChange:j,onGenerateTips:K,onGenerateTopics:q,onSearchTopic:J,onSignIn:O,fileSourceProvider:F};return g===`docs`?(0,s.jsx)(l.ReasonDocs,{SidebarComponent:e,SidebarContentComponent:i,belowMainContent:(0,s.jsx)(t.U,{}),openFilesSidebarSignal:y,...Y}):(0,s.jsx)(l.ReasonDocs,{SidebarComponent:e,SidebarContentComponent:i,mainContent:(0,s.jsx)(t.L,{}),openFilesSidebarSignal:y,...Y})}function L({SidebarComponent:e,SidebarContentComponent:n,openSidebarEvent:r,...i}){return(0,s.jsx)(t.r,{...i,docsEnabled:!0,children:(0,s.jsx)(I,{SidebarComponent:e,SidebarContentComponent:n,openSidebarEvent:r})})}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=r.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.QwkSearchWorkspaceApp=L,exports.ResearchWorkspaceView=I,exports.SPOTLIGHT_LINKS=t.v,exports.SPOTLIGHT_PREFIXES=t.h,exports.SessionProvider=r.s,exports.SpotlightPalette=t.p,exports.UnifiedMarkdown=t.x,exports.VoiceSettingsPanel=t.l,exports.buildConnectStartUrl=t.M,exports.cn=i.o,exports.configureResearchAgentUI=n.configureResearchAgentUI,exports.createQwkSearchConnectAuthClient=t.N,exports.formatMessageTime=i.s,exports.formatTimeDifference=i.c,exports.formatToolbarShortcut=t.k,exports.getPageTips=m,exports.getQwkSearchApiKey=t.P,exports.getTopicSearches=h,exports.htmlToPlainText=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=n.researchAgentUIConfig,exports.setQwkSearchApiKey=t.I,exports.useChat=r.u,exports.useChatState=t.et,exports.useChatTabs=t.t,exports.useChunkErrorReload=t.o,exports.useExtractPanel=r.a,exports.useHistoryState=t.H,exports.useKokoroTTS=t.f,exports.useMainView=t.b,exports.useOptionalExtractPanel=r.o,exports.useSession=r.c,exports.useTextToSpeech=t.d;
|
package/dist/workspace.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, U as _, _ as v, a as y, b, c as x, d as S, et as C, f as w, g as T, h as E, i as D, j as O, k, l as ee, m as te, n as ne, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as re, x as ie, y as ae, z as oe } from "./src-
|
|
3
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, U as _, _ as v, a as y, b, c as x, d as S, et as C, f as w, g as T, h as E, i as D, j as O, k, l as ee, m as te, n as ne, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as re, x as ie, y as ae, z as oe } from "./src-BQX5Q6k1.js";
|
|
4
4
|
import { configureResearchAgentUI as L, researchAgentUIConfig as se } from "./config.mjs";
|
|
5
5
|
import { a as ce, c as R, i as le, o as ue, s as de, u as z } from "./tooltip-Bl3IdX-I.js";
|
|
6
6
|
import { c as fe, o as pe, s as me } from "./dialog-Cufn2u50.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "research-agent-ui",
|
|
3
3
|
"description": "The QwkSearch app UI: conversation window, article reader, search config, file uploads, chat history, and the app shell — exported both with and without the REASON editor and its sidebar",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.312",
|
|
5
5
|
"author": "vtempest",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -97,35 +97,35 @@
|
|
|
97
97
|
"@radix-ui/react-slot": "^1.5.0",
|
|
98
98
|
"@radix-ui/react-tooltip": "^1.4.1",
|
|
99
99
|
"ai": "^7.0.159",
|
|
100
|
-
"chat-agent-toolkit": "^1.2.
|
|
100
|
+
"chat-agent-toolkit": "^1.2.446",
|
|
101
101
|
"class-variance-authority": "^0.7.1",
|
|
102
102
|
"clsx": "^2.1.1",
|
|
103
103
|
"dompurify": "^3.4.17",
|
|
104
104
|
"drizzle-orm": "^0.45.4",
|
|
105
|
-
"extract-webpage": "^1.2.
|
|
105
|
+
"extract-webpage": "^1.2.439",
|
|
106
106
|
"grab-url": "^3.0.9",
|
|
107
107
|
"html2canvas": "^1.4.1",
|
|
108
108
|
"kokoro-js": "^1.2.1",
|
|
109
|
-
"legal-terms-privacy-policy": "^0.1.
|
|
109
|
+
"legal-terms-privacy-policy": "^0.1.261",
|
|
110
110
|
"lucide-react": "^1.66.0",
|
|
111
111
|
"markdown-to-jsx": "^9.10.4",
|
|
112
112
|
"motion": "^14.9.0",
|
|
113
113
|
"quantum-sphere-loading-icon": "^1.0.6",
|
|
114
|
-
"qwksearch-api-client": "^1.0.
|
|
114
|
+
"qwksearch-api-client": "^1.0.256",
|
|
115
115
|
"react-icons": "^5.7.0",
|
|
116
116
|
"react-native-app-buttons": "^0.1.4",
|
|
117
117
|
"react-textarea-autosize": "^8.5.9",
|
|
118
|
-
"search-web-api": "^1.0.
|
|
119
|
-
"shadcn-app-dock": "^0.1.
|
|
118
|
+
"search-web-api": "^1.0.298",
|
|
119
|
+
"shadcn-app-dock": "^0.1.296",
|
|
120
120
|
"shadcn-theme-menu": "^1.1.74",
|
|
121
121
|
"sonner": "^2.0.8",
|
|
122
122
|
"streamdown": "^2.7.1",
|
|
123
123
|
"tailwind-merge": "^3.7.0",
|
|
124
|
-
"trending-news-api": "^0.1.
|
|
125
|
-
"education-playlists": "^0.1.
|
|
124
|
+
"trending-news-api": "^0.1.174",
|
|
125
|
+
"education-playlists": "^0.1.121",
|
|
126
126
|
"turndown": "^7.2.4",
|
|
127
127
|
"use-voice-control": "^0.1.235",
|
|
128
|
-
"use-weather-forecast": "^0.1.
|
|
128
|
+
"use-weather-forecast": "^0.1.398"
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
131
|
"@cloudflare/workers-types": "^5.20261101.1",
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"next": "^16.4.3",
|
|
143
143
|
"react": "^19.3.1",
|
|
144
144
|
"react-dom": "^19.3.1",
|
|
145
|
-
"react-reason-editor": "^1.0.
|
|
146
|
-
"react-reason-editor-sidebar": "^0.1.
|
|
145
|
+
"react-reason-editor": "^1.0.248",
|
|
146
|
+
"react-reason-editor-sidebar": "^0.1.303",
|
|
147
147
|
"search-autocomplete": "^0.1.0",
|
|
148
148
|
"storybook": "^10.6.5",
|
|
149
149
|
"tailwindcss": "^4.3.3",
|