khoj 1.42.3.dev1__py3-none-any.whl → 1.42.4.dev1__py3-none-any.whl

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.
Files changed (61) hide show
  1. khoj/database/models/__init__.py +3 -3
  2. khoj/interface/compiled/404/index.html +2 -2
  3. khoj/interface/compiled/_next/static/chunks/2327-024b9e0bd6d8c9eb.js +1 -0
  4. khoj/interface/compiled/_next/static/chunks/7127-a6dc754bce8b6855.js +1 -0
  5. khoj/interface/compiled/_next/static/chunks/{7211-bc820ef9de53f166.js → 7211-7fedd2ee3655239c.js} +1 -1
  6. khoj/interface/compiled/_next/static/chunks/app/agents/layout-4e2a134ec26aa606.js +1 -0
  7. khoj/interface/compiled/_next/static/chunks/app/agents/{page-e18e67cff45758c8.js → page-2fac1d5ac7192e73.js} +1 -1
  8. khoj/interface/compiled/_next/static/chunks/app/automations/{page-1c2280ae9678b4ce.js → page-ef89ac958e78aa81.js} +1 -1
  9. khoj/interface/compiled/_next/static/chunks/app/chat/layout-ad4d1792ab1a4108.js +1 -0
  10. khoj/interface/compiled/_next/static/chunks/app/chat/page-0b8cd503b9723fd3.js +1 -0
  11. khoj/interface/compiled/_next/static/chunks/app/{page-a4b97dd0c2a70cfb.js → page-45ae5e99e8a61821.js} +1 -1
  12. khoj/interface/compiled/_next/static/chunks/app/search/layout-c02531d586972d7d.js +1 -0
  13. khoj/interface/compiled/_next/static/chunks/app/search/{page-44072d929427ee56.js → page-afb5e7ed13d221c1.js} +1 -1
  14. khoj/interface/compiled/_next/static/chunks/app/settings/{page-4e8fdd30a3238357.js → page-8fb6cc97be8774a7.js} +1 -1
  15. khoj/interface/compiled/_next/static/chunks/app/share/chat/layout-e8e5db7830bf3f47.js +1 -0
  16. khoj/interface/compiled/_next/static/chunks/app/share/chat/{page-27560c92db5fc2d9.js → page-da90c78180a86040.js} +1 -1
  17. khoj/interface/compiled/_next/static/chunks/{webpack-b61b76223325589e.js → webpack-66805ff7f301c13a.js} +1 -1
  18. khoj/interface/compiled/_next/static/css/37a73b87f02df402.css +1 -0
  19. khoj/interface/compiled/_next/static/css/{e1bf03aa79521f86.css → 9a460202d29476e5.css} +1 -1
  20. khoj/interface/compiled/_next/static/css/c34713c98384ee87.css +1 -0
  21. khoj/interface/compiled/agents/index.html +2 -2
  22. khoj/interface/compiled/agents/index.txt +2 -2
  23. khoj/interface/compiled/automations/index.html +2 -2
  24. khoj/interface/compiled/automations/index.txt +3 -3
  25. khoj/interface/compiled/chat/index.html +2 -2
  26. khoj/interface/compiled/chat/index.txt +2 -2
  27. khoj/interface/compiled/index.html +2 -2
  28. khoj/interface/compiled/index.txt +2 -2
  29. khoj/interface/compiled/search/index.html +2 -2
  30. khoj/interface/compiled/search/index.txt +2 -2
  31. khoj/interface/compiled/settings/index.html +2 -2
  32. khoj/interface/compiled/settings/index.txt +4 -4
  33. khoj/interface/compiled/share/chat/index.html +2 -2
  34. khoj/interface/compiled/share/chat/index.txt +2 -2
  35. khoj/processor/conversation/openai/utils.py +46 -6
  36. khoj/processor/conversation/utils.py +8 -8
  37. khoj/processor/image/generate.py +3 -3
  38. khoj/routers/api_agents.py +1 -1
  39. khoj/routers/api_chat.py +6 -2
  40. {khoj-1.42.3.dev1.dist-info → khoj-1.42.4.dev1.dist-info}/METADATA +1 -1
  41. {khoj-1.42.3.dev1.dist-info → khoj-1.42.4.dev1.dist-info}/RECORD +52 -52
  42. khoj/interface/compiled/_next/static/chunks/2327-f03b2a77f67b8f8c.js +0 -1
  43. khoj/interface/compiled/_next/static/chunks/7127-79a3af5138960272.js +0 -1
  44. khoj/interface/compiled/_next/static/chunks/app/agents/layout-e49165209d2e406c.js +0 -1
  45. khoj/interface/compiled/_next/static/chunks/app/chat/layout-d5ae861e1ade9d08.js +0 -1
  46. khoj/interface/compiled/_next/static/chunks/app/chat/page-2714aec91bd8f3ea.js +0 -1
  47. khoj/interface/compiled/_next/static/chunks/app/search/layout-f5881c7ae3ba0795.js +0 -1
  48. khoj/interface/compiled/_next/static/chunks/app/share/chat/layout-64a53f8ec4afa6b3.js +0 -1
  49. khoj/interface/compiled/_next/static/css/1e9b757ee2a2b34b.css +0 -1
  50. khoj/interface/compiled/_next/static/css/ee66643a6a5bf71c.css +0 -1
  51. /khoj/interface/compiled/_next/static/{tl-RqF8W5lpwWPPHYumnV → YzN1Uv2RYxwjHlNYy9Loa}/_buildManifest.js +0 -0
  52. /khoj/interface/compiled/_next/static/{tl-RqF8W5lpwWPPHYumnV → YzN1Uv2RYxwjHlNYy9Loa}/_ssgManifest.js +0 -0
  53. /khoj/interface/compiled/_next/static/chunks/{1915-1943ee8a628b893c.js → 1915-ab4353eaca76f690.js} +0 -0
  54. /khoj/interface/compiled/_next/static/chunks/{2117-056a00add390772b.js → 2117-3537ef9986be74d3.js} +0 -0
  55. /khoj/interface/compiled/_next/static/chunks/{4363-e6ac2203564d1a3b.js → 4363-4efaf12abe696251.js} +0 -0
  56. /khoj/interface/compiled/_next/static/chunks/{4447-e038b251d626c340.js → 4447-5d44807c40355b1a.js} +0 -0
  57. /khoj/interface/compiled/_next/static/chunks/{8667-8136f74e9a086fca.js → 8667-adbe6017a66cef10.js} +0 -0
  58. /khoj/interface/compiled/_next/static/chunks/{9259-640fdd77408475df.js → 9259-d8bcd9da9e80c81e.js} +0 -0
  59. {khoj-1.42.3.dev1.dist-info → khoj-1.42.4.dev1.dist-info}/WHEEL +0 -0
  60. {khoj-1.42.3.dev1.dist-info → khoj-1.42.4.dev1.dist-info}/entry_points.txt +0 -0
  61. {khoj-1.42.3.dev1.dist-info → khoj-1.42.4.dev1.dist-info}/licenses/LICENSE +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7127],{27127:function(e,t,a){"use strict";a.d(t,{Z:function(){return eE}});var n=a(57437),s=a(42501),o=a.n(s),r=a(2265),l=a(48614),c=a(99597),i=a(91499),d=a.n(i),h=a(19983),u=a(13506),g=a.n(u),m=a(34040);a(2446);var f=a(5147),p=a(86018),x=a(38525),v=a(45178),j=a(66070),y=a(69304),w=a(57054),b=a(18848),M=a(42225),C=a(27648);let N=new h.Z({html:!0,linkify:!0,typographer:!0});function _(e){let t=(0,M.Le)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=e.title.split("/").pop()||e.title,s=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?b.Z.sanitize(N.render(t)):b.Z.sanitize(t)}(e),[o,l]=(0,r.useState)(!1);return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(w.J2,{open:o&&!e.showFullContent,onOpenChange:l,children:[(0,n.jsx)(w.xo,{asChild:!0,children:(0,n.jsx)(j.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto bg-muted":"w-auto"," overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none"),children:e.showFullContent?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.showFullContent?e.title:a]}),(0,n.jsx)("p",{className:"text-sm overflow-x-auto block",dangerouslySetInnerHTML:{__html:s}})]}):(0,n.jsx)(T,{type:"notes"},"".concat(e.title))})}),(0,n.jsx)(w.yk,{className:"w-[400px] mx-2",children:(0,n.jsxs)(j.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none p-2",children:[(0,n.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,n.jsx)("p",{className:"border-t mt-1 pt-1 text-sm overflow-hidden line-clamp-5",dangerouslySetInnerHTML:{__html:s}})]})})]})})}function k(e){var t,a,s,o,l,c;let i=(0,M.Le)(".py","!w-4 h-4 text-muted-foreground flex-shrink-0"),d=b.Z.sanitize(e.code),[h,u]=(0,r.useState)(!1),[g,m]=(0,r.useState)(!1),p=e=>{let t="text/plain",a=e.b64_data;e.filename.match(/\.(png|jpg|jpeg|webp)$/)?(t="image/".concat(e.filename.split(".").pop()),a=atob(e.b64_data)):e.filename.endsWith(".json")?t="application/json":e.filename.endsWith(".csv")&&(t="text/csv");let n=new ArrayBuffer(a.length),s=new Uint8Array(n);for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);let o=new Blob([n],{type:t}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.download=e.filename,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)},x=(t,a)=>(null==t?void 0:t.length)==0?null:(0,n.jsx)("div",{className:"".concat(a||e.showFullContent?"border-t mt-1 pt-1":void 0),children:t.slice(0,e.showFullContent?void 0:1).map((t,s)=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("h4",{className:"text-sm text-muted-foreground flex items-center",children:[(0,n.jsx)("span",{className:"overflow-hidden mr-2 font-bold ".concat(e.showFullContent?void 0:"line-clamp-1"),children:t.filename}),(0,n.jsx)("button",{className:"".concat(a?"hidden":void 0),onClick:e=>{e.preventDefault(),p(t)},onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),title:"Download file: ".concat(t.filename),children:(0,n.jsx)(f.b,{className:"w-4 h-4",weight:g?"fill":"regular"})})]}),t.filename.match(/\.(txt|org|md|csv|json)$/)?(0,n.jsx)("pre",{className:"".concat(e.showFullContent?"block":"line-clamp-2"," text-sm mt-1 p-1 bg-background rounded overflow-x-auto"),children:t.b64_data}):t.filename.match(/\.(png|jpg|jpeg|webp)$/)?(0,n.jsx)("img",{src:"data:image/".concat(t.filename.split(".").pop(),";base64,").concat(t.b64_data),alt:t.filename,className:"mt-1 max-h-32 rounded"}):null]},"".concat(t.filename,"-").concat(s)))});return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(w.J2,{open:h&&!e.showFullContent,onOpenChange:u,children:[(0,n.jsx)(w.xo,{asChild:!0,children:(0,n.jsx)(j.Zb,{onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:"".concat(e.showFullContent?"w-auto bg-muted":"w-auto"," overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none"),children:e.showFullContent?(0,n.jsxs)("div",{className:"flex flex-col px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[i,(0,n.jsxs)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:["code ",(null===(t=e.output_files)||void 0===t?void 0:t.length)>0?"artifacts":""]})]}),(0,n.jsx)("pre",{className:"text-xs pb-2 ".concat(e.showFullContent?"block overflow-x-auto":(null===(a=e.output_files)||void 0===a?void 0:a.length)>0?"hidden":"overflow-hidden line-clamp-3"),children:d}),(null===(s=e.output_files)||void 0===s?void 0:s.length)>0&&x(e.output_files,!1)]}):(0,n.jsx)(T,{type:"code"},"code-".concat(e.code))})}),(0,n.jsx)(w.yk,{className:"w-[400px] mx-2",children:(0,n.jsxs)(j.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none p-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[i,(0,n.jsxs)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:["code ",(null===(o=e.output_files)||void 0===o?void 0:o.length)>0?"artifact":""]})]}),(null===(l=e.output_files)||void 0===l?void 0:l.length)>0&&x(null===(c=e.output_files)||void 0===c?void 0:c.slice(0,1),!0)||(0,n.jsx)("pre",{className:"text-xs border-t mt-1 pt-1 overflow-hidden line-clamp-10",children:d})]})})]})})}function R(e){let[t,a]=(0,r.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let s="https://www.google.com/s2/favicons?domain=globe",o="unknown";try{o=new URL(e.link).hostname,s="https://www.google.com/s2/favicons?domain=".concat(o)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)(w.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,n.jsx)(w.xo,{asChild:!0,children:(0,n.jsx)(j.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto bg-muted":"w-auto"," overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none"),children:e.showFullContent?(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)(C.default,{href:e.link,children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:s,alt:"",className:"!w-4 h-4 flex-shrink-0"}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground flex-grow"),children:o})]})}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,n.jsx)("p",{className:"overflow-hidden text-sm ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]}):(0,n.jsx)(T,{type:"online",link:e.link},e.title)})}),(0,n.jsx)(w.yk,{className:"w-[400px] mx-2",children:(0,n.jsx)(j.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,n.jsx)("div",{className:"flex flex-col",children:(0,n.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline px-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("img",{src:s,alt:"",className:"!w-4 h-4 flex-shrink-0"}),(0,n.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground flex-grow"),children:o})]}),(0,n.jsx)("h3",{className:"border-t mt-1 pt-1 overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,n.jsx)("p",{className:"overflow-hidden text-sm ".concat(e.showFullContent?"block":"line-clamp-5"),children:e.description})]})})})})]})})}function T(e){let t="",a="unknown";if(e.link)try{a=new URL(e.link).hostname,t="https://www.google.com/s2/favicons?domain=".concat(a)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}let s=null,o="!w-4 !h-4 text-muted-foreground inline-flex mr-2 rounded-lg";switch(e.type){case"code":s=(0,n.jsx)(p.E,{className:"".concat(o)});break;case"online":s=(0,n.jsx)("img",{src:t,alt:"",className:"".concat(o)});break;case"notes":s=(0,n.jsx)(x.j,{className:"".concat(o)});break;default:s=null}return s?(0,n.jsx)("div",{className:"flex items-center gap-2",children:s}):null}function E(e){let t=e.notesReferenceCardData.length>0||e.codeReferenceCardData.length>0||e.onlineReferenceCardData.length>0,a=e.notesReferenceCardData.length+e.codeReferenceCardData.length+e.onlineReferenceCardData.length;return 0===a?null:(0,n.jsx)("div",{className:"pt-0 px-4 pb-4",children:(0,n.jsxs)("h3",{className:"inline-flex items-center",children:[(0,n.jsxs)("div",{className:"text-gray-400 m-2",children:[a," sources"]}),(0,n.jsx)("div",{className:"flex flex-wrap gap-2 w-auto m-2",children:t&&(0,n.jsx)(O,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData,codeReferenceCardData:e.codeReferenceCardData,isMobileWidth:e.isMobileWidth})})]})})}function O(e){let[t,a]=(0,r.useState)(3);if((0,r.useEffect)(()=>{a(e.isMobileWidth?3:5)},[e.isMobileWidth]),!e.notesReferenceCardData&&!e.onlineReferenceCardData)return null;let s=e.codeReferenceCardData.slice(0,t),o=e.notesReferenceCardData.slice(0,t-s.length),l=o.length+s.length<t?e.onlineReferenceCardData.filter(e=>e.link).slice(0,t-s.length-o.length):[];return(0,n.jsxs)(y.yo,{children:[(0,n.jsxs)(y.aM,{className:"text-balance w-auto justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center m-0 inline-flex",children:[s.map((e,t)=>(0,r.createElement)(k,{showFullContent:!1,...e,key:"code-".concat(t)})),o.map((e,t)=>(0,r.createElement)(_,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,r.createElement)(R,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),(0,n.jsx)(v.o,{className:"m-0"})]}),(0,n.jsxs)(y.ue,{className:"overflow-y-scroll",children:[(0,n.jsxs)(y.Tu,{children:[(0,n.jsx)(y.bC,{children:"References"}),(0,n.jsx)(y.Ei,{children:"View all references for this response"})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.codeReferenceCardData.map((e,t)=>(0,r.createElement)(k,{showFullContent:!0,...e,key:"code-".concat(t)})),e.notesReferenceCardData.map((e,t)=>(0,r.createElement)(_,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,r.createElement)(R,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]})}var I=a(59199),S=a(62467),F=a(93893),L=a(2452),D=a(22105),B=a(52938),P=a(68950),z=a(63329),q=a(35099),A=a(46561),H=a(33758),U=a(58717),Z=a(33511),W=a(51059),V=a(38513),G=a(46732),J=a(47924),Q=a(19841),$=a(45401),K=a(88435),Y=a(14308),X=a(84671),ee=a(36663);let et=(0,a(30166).default)(()=>Promise.all([a.e(6555),a.e(7293),a.e(4609),a.e(479)]).then(a.bind(a,60479)).then(e=>e.default),{loadableGenerated:{webpack:()=>[60479]},ssr:!1});function ea(e){return(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)(Y.Z,{}),children:(0,n.jsx)(et,{data:e.data})})}var en=a(26110),es=a(49027),eo=a(7436),er=a(19378),el=a(50656),ec=a(75419),ei=a(41648),ed=a(62869),eh=e=>{let{chart:t}=e,[a,s]=(0,r.useState)(null),[o]=(0,r.useState)("mermaid-chart-".concat(Math.random().toString(12).substring(7))),l=(0,r.useRef)(null);(0,r.useEffect)(()=>{el.Z.initialize({startOnLoad:!1}),el.Z.parseError=e=>{let t;console.error("Mermaid errors:",e);try{t="string"==typeof e?JSON.parse(e):e}catch(a){t=(null==e?void 0:e.toString())||"Unknown error"}console.log("Mermaid error message:",t),"element is null"!==t.str?s("Something went wrong while rendering the diagram. Please try again later or downvote the message if the issue persists."):s(null)},el.Z.contentLoaded()},[]);let c=async()=>{if(l.current)try{var e;let t=l.current.querySelector("svg");if(!t)throw Error("No SVG found");let[,,a,n]=(null===(e=t.getAttribute("viewBox"))||void 0===e?void 0:e.split(" ").map(Number))||[0,0,0,0],s=document.createElement("canvas");s.width=2*a,s.height=2*n;let o=s.getContext("2d");if(!o)throw Error("Failed to get canvas context");let r=new XMLSerializer().serializeToString(t),c=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(c),d=new Image;d.src=i,await new Promise((e,t)=>{d.onload=()=>{o.scale(2,2),o.drawImage(d,0,0,a,n),s.toBlob(a=>{if(!a){t(Error("Failed to create blob"));return}let n=URL.createObjectURL(a),s=document.createElement("a");s.href=n,s.download="mermaid-diagram-".concat(Date.now(),".png"),s.click(),URL.revokeObjectURL(n),URL.revokeObjectURL(i),e(!0)},"image/png")},d.onerror=()=>t(Error("Failed to load SVG"))})}catch(e){console.error("Error exporting diagram:",e),s("Failed to export diagram")}};return(0,r.useEffect)(()=>{l.current&&(l.current.removeAttribute("data-processed"),el.Z.run({nodes:[l.current]}).then(()=>{s(null)}).catch(e=>{let t;try{t="string"==typeof e?JSON.parse(e):e}catch(a){t=(null==e?void 0:e.toString())||"Unknown error"}console.log("Mermaid error message:",t),"element is null"!==t.str?s("Something went wrong while rendering the diagram. Please try again later or downvote the message if the issue persists."):s(null)}))},[t]),(0,n.jsxs)("div",{children:[a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 bg-red-100 border border-red-500 rounded-md p-1 mt-3 text-red-900 text-sm",children:[(0,n.jsx)(ec.k,{className:"w-12 h-12"}),(0,n.jsx)("span",{children:a})]}),(0,n.jsx)("code",{className:"block bg-secondary text-secondary-foreground p-4 mt-3 rounded-lg font-mono text-sm whitespace-pre-wrap overflow-x-auto max-h-[400px] border border-gray-200",children:t})]}):(0,n.jsx)("div",{id:o,ref:l,className:"mermaid",style:{width:"auto",height:"auto",boxSizing:"border-box",overflow:"auto"},children:t}),!a&&(0,n.jsxs)(ed.z,{onClick:c,variant:"secondary",className:"mt-3",children:[(0,n.jsx)(ei.U,{className:"w-5 h-5"}),"Export as PNG"]})]})};let eu=new h.Z({html:!0,linkify:!0,typographer:!0});function eg(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function em(e){let{uquery:t,kquery:a}=e,[s,o]=(0,r.useState)(null);return(0,r.useEffect)(()=>{null!==s&&setTimeout(()=>{o(null)},2e3)},[s]),(0,n.jsxs)("div",{className:"".concat(d().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,n.jsx)("button",{title:"Like",className:d().thumbsUpButton,disabled:null!==s,onClick:()=>{eg(t,a,"positive"),o(!0)},children:!0===s?(0,n.jsx)(S.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,n.jsx)(S.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,n.jsx)("button",{title:"Dislike",className:d().thumbsDownButton,disabled:null!==s,onClick:()=>{eg(t,a,"negative"),o(!1)},children:!1===s?(0,n.jsx)(F.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,n.jsx)(F.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function ef(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),s="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,n.jsx)(L.a,{className:"".concat(s)}):a.includes("generating")?(0,n.jsx)(D.Z,{className:"".concat(s)}):a.includes("tools")?(0,n.jsx)(B.v,{className:"".concat(s)}):a.includes("notes")?(0,n.jsx)(P.g,{className:"".concat(s)}):a.includes("read")?(0,n.jsx)(z.f,{className:"".concat(s)}):a.includes("search")?(0,n.jsx)(q.Y,{className:"".concat(s)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,n.jsx)(A.u,{className:"".concat(s)}):a.includes("diagram")?(0,n.jsx)(H.j,{className:"".concat(s)}):a.includes("paint")?(0,n.jsx)(U.Y,{className:"".concat(s)}):a.includes("code")?(0,n.jsx)(p.E,{className:"".concat(s)}):a.includes("operating")?(0,n.jsx)(Z.A,{className:"".concat(s)}):(0,n.jsx)(L.a,{className:"".concat(s)})}(t?t[1]:"",e.primary?(0,X.oz)(e.agentColor):"text-gray-500"),s=e.message,o=null;try{let e=s.match(/\{.*("action": "screenshot"|"type": "screenshot"|"image": "data:image\/.*").*\}/);if(e){o=JSON.parse(e[0]);let t='<img src="'.concat(o.image,'" alt="State of environment" class="max-w-full" />');s=s.replace(":\n**Action**: ".concat(e[0]),"\n\n- ".concat(o.text,"\n").concat(t))}}catch(e){console.error("Failed to parse screenshot data",e)}let r=b.Z.sanitize(eu.render(s));return r=r.replace(/<h[1-6].*?<\/h[1-6]>/g,""),(0,n.jsxs)("div",{className:"".concat(d().trainOfThoughtElement," break-words items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(d().trainOfThought," ").concat(e.primary?d().primary:""),children:[a,(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:r},className:"break-words"})]})}eu.use(g(),{inline:!0,code:!0});let ep=(0,r.forwardRef)((e,t)=>{var a,s;let o,l,c,i,h;let[u,g]=(0,r.useState)(!1),[f,p]=(0,r.useState)(!1),[x,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(""),[w,C]=(0,r.useState)(!1),[N,_]=(0,r.useState)(!1),[k,R]=(0,r.useState)(""),[T,O]=(0,r.useState)(""),S=(0,r.useRef)(!1),F=(0,r.useRef)(null);async function L(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;C(!0);let a=D(t[0]);for(let e=0;e<t.length&&!S.current;e++){let n=a;e<t.length-1&&(a=D(t[e+1]));try{let e=await n,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let n=new Audio(e);n.onended=t,n.onerror=a,n.play()})}(t)}catch(e){console.error("Error:",e);break}}C(!1),_(!1)}async function D(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}(0,r.useEffect)(()=>{S.current=N},[N]),(0,r.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(F.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,ee.Z)(F.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]})});return F.current&&e.observe(F.current,{childList:!0}),()=>e.disconnect()},[F.current]),(0,r.useEffect)(()=>{let t=e.chatMessage.message;e.chatMessage.excalidrawDiagram&&R(e.chatMessage.excalidrawDiagram),e.chatMessage.mermaidjsDiagram&&O(e.chatMessage.mermaidjsDiagram),t=t.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET"),t=(0,I.AQ)(t,e.chatMessage.codeContext),e.chatMessage.codeContext&&Object.entries(e.chatMessage.codeContext).forEach(e=>{var a;let[n,s]=e;null===(a=s.results.output_files)||void 0===a||a.forEach(e=>{(e.filename.endsWith(".png")||e.filename.endsWith(".jpg"))&&!t.includes("![".concat(e.filename,"]("))&&(t+="\n\n![".concat(e.filename,"](data:image/png;base64,").concat(e.b64_data,")"))})});let a=t,n=t;if(e.chatMessage.images&&e.chatMessage.images.length>0){let t=e.chatMessage.images.map(e=>{let t=e.startsWith("data%3Aimage")?decodeURIComponent(e):e;return b.Z.sanitize(t)}),s=t.map((e,t)=>"![uploaded image ".concat(t+1,"](").concat(e,")")).join("\n"),o=t.map((e,t)=>'<div class="'.concat(d().imageWrapper,'"><img src="').concat(e,'" alt="uploaded image ').concat(t+1,'" /></div>')).join(""),r='<div class="'.concat(d().imagesContainer,'">').concat(o,"</div>");a="".concat(s,"\n\n").concat(a),n="".concat(r).concat(n)}v(a);let s=eu.render(n);s=s.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),y(b.Z.sanitize(s))},[e.chatMessage.message,e.chatMessage.images,e.chatMessage.intent]),(0,r.useEffect)(()=>{u&&setTimeout(()=>{g(!1)},2e3)},[u]),(0,r.useEffect)(()=>{F.current&&(F.current.querySelectorAll("pre > .hljs").forEach(e=>{if(!e.querySelector("".concat(d().codeCopyButton))){let t=document.createElement("button"),a=(0,n.jsx)(W.w,{size:24});(0,m.createRoot)(t).render(a),t.className="hljs ".concat(d().codeCopyButton),t.addEventListener("click",()=>{let a=e.textContent||"";a=(a=(a=a.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(a);let s=(0,n.jsx)(V.J,{size:24});(0,m.createRoot)(t).render(s)}),e.prepend(t)}}),(0,ee.Z)(F.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"\\(",right:"\\)",display:!1}]}))},[j,f,F]);let B=async t=>{let a=t.turnId||e.turnId;(await fetch("/api/chat/conversation/message",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation_id:e.conversationId,turn_id:a})})).ok?e.onDeleteMessage(a):console.error("Failed to delete message")},P=function(e,t,a){let n=[],s=[],o=[];if(a)for(let[e,t]of Object.entries(a))t.results&&o.push({code:t.code,output:t.results.std_out,output_files:t.results.output_files,error:t.results.std_err});if(t){let e=[];for(let[a,n]of Object.entries(t)){if(n.answerBox&&e.push({title:n.answerBox.title,description:n.answerBox.answer,link:n.answerBox.source}),n.knowledgeGraph&&e.push({title:n.knowledgeGraph.title,description:n.knowledgeGraph.description,link:n.knowledgeGraph.descriptionLink}),n.webpages){if(n.webpages instanceof Array){let t=n.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=n.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(n.organic){let t=n.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}n.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:n,codeReferenceCardData:o}}(e.chatMessage.context,e.chatMessage.onlineContext,e.chatMessage.codeContext);return(0,n.jsxs)("div",{ref:t,className:(a=e.chatMessage,o=[d().chatMessageContainer],"khoj"===a.by&&o.push("shadow-md"),o.push(d()[a.by]),a.message||o.push(d().emptyChatMessage),e.customClassName&&o.push(d()["".concat(a.by).concat(e.customClassName)]),o.join(" ")),onMouseLeave:e=>p(!1),onMouseEnter:e=>p(!0),children:[(0,n.jsxs)("div",{className:(s=e.chatMessage,(l=[d().chatMessageWrapper]).push(d()[s.by]),"khoj"===s.by&&l.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),l.join(" ")),children:[e.chatMessage.queryFiles&&e.chatMessage.queryFiles.length>0&&(0,n.jsx)("div",{className:"flex flex-wrap flex-col mb-2 max-w-full",children:e.chatMessage.queryFiles.map((e,t)=>(0,n.jsxs)(en.Vq,{children:[(0,n.jsx)(en.hg,{asChild:!0,children:(0,n.jsxs)("div",{className:"flex items-center space-x-2 cursor-pointer bg-gray-500 bg-opacity-25 rounded-lg p-2 w-full ",children:[(0,n.jsx)("div",{className:"flex-shrink-0",children:(0,M.Le)(e.file_type)}),(0,n.jsx)("span",{className:"truncate flex-1 min-w-0 max-w-[200px]",children:e.name}),e.size&&(0,n.jsxs)("span",{className:"text-gray-400 flex-shrink-0",children:["(",(0,eo.xq)(e.size),")"]})]})}),(0,n.jsxs)(en.cZ,{children:[(0,n.jsx)(en.fK,{children:(0,n.jsx)(es.$N,{children:(0,n.jsx)("div",{className:"truncate min-w-0 break-words break-all text-wrap max-w-full whitespace-normal",children:e.name})})}),(0,n.jsx)(en.Be,{children:(0,n.jsx)(er.x,{className:"h-72 w-full rounded-md break-words break-all text-wrap",children:e.content})})]})]},t))}),(0,n.jsx)("div",{ref:F,className:d().chatMessage,dangerouslySetInnerHTML:{__html:j}}),k&&(0,n.jsx)(ea,{data:k}),T&&(0,n.jsx)(eh,{chart:T})]}),(0,n.jsx)("div",{className:d().teaserReferencesContainer,children:(0,n.jsx)(E,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:P.notesReferenceCardData,onlineReferenceCardData:P.onlineReferenceCardData,codeReferenceCardData:P.codeReferenceCardData})}),(0,n.jsx)("div",{className:d().chatFooter,children:(f||e.isMobileWidth||e.isLastMessage||w)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{title:(i=(c=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),h=c.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(i," on ").concat(h)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,n.jsxs)("div",{className:"".concat(d().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(w?N?(0,n.jsx)(Y.l,{iconClassName:"p-0",className:"m-0"}):(0,n.jsx)("button",{title:"Pause Speech",onClick:e=>_(!0),children:(0,n.jsx)(G.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,n.jsx)("button",{title:"Speak",onClick:e=>L(),children:(0,n.jsx)(J.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),e.chatMessage.turnId&&(0,n.jsx)("button",{title:"Delete",className:"".concat(d().deleteButton),onClick:()=>B(e.chatMessage),children:(0,n.jsx)(Q.r,{alt:"Delete Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})}),"khoj"===e.chatMessage.by&&e.onRetryMessage&&e.isLastMessage&&(0,n.jsx)("button",{title:"Retry",className:"".concat(d().retryButton),onClick:()=>{var t,a,n;let s=e.chatMessage.turnId||e.turnId,o=e.chatMessage.rawQuery||(null===(t=e.chatMessage.intent)||void 0===t?void 0:t.query);if(console.log("Retry button clicked for turnId:",s),console.log("ChatMessage data:",{rawQuery:e.chatMessage.rawQuery,intent:e.chatMessage.intent,message:e.chatMessage.message}),console.log("Extracted query:",o),o)null===(a=e.onRetryMessage)||void 0===a||a.call(e,o,s);else{console.error("No original query found for retry");let t=prompt("Enter the original query to retry:");t&&(null===(n=e.onRetryMessage)||void 0===n||n.call(e,t,s))}},children:(0,n.jsx)($._,{alt:"Retry Message",className:"hsl(var(--muted-foreground)) hover:text-blue-500"})}),(0,n.jsx)("button",{title:"Copy",className:"".concat(d().copyButton),onClick:()=>{navigator.clipboard.writeText(x),g(!0)},children:u?(0,n.jsx)(K.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,n.jsx)(K.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,n.jsx)(em,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,n.jsx)(em,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})});ep.displayName="ChatMessage";var ex=a(46843),ev=a(87332),ej=a(91832),ey=a(44849),ew=a.n(ey);function eb(e){let{frames:t,autoPlay:a=!0,playbackSpeed:s=1e3}=e,[o,l]=(0,r.useState)(0),[c,i]=(0,r.useState)(a),[d,h]=(0,r.useState)(!0),u=(0,r.useRef)(null);(0,r.useEffect)(()=>{d&&t.length>0&&l(t.length-1)},[t.length,d]),(0,r.useEffect)(()=>(c&&t.length>1?u.current=setInterval(()=>{l(e=>{let a=e+1;return a>=t.length?(i(!1),e):a})},s):u.current&&(clearInterval(u.current),u.current=null),()=>{u.current&&clearInterval(u.current)}),[c,t.length,s]);let g=t[o],m=e=>{l(e),h(!1),i(!1)};return t.length?(0,n.jsxs)("div",{className:ew().videoPlayer,children:[(0,n.jsxs)("div",{className:ew().screen,children:[(null==g?void 0:g.image)&&(0,n.jsx)("img",{src:g.image,alt:"Train of thought frame ".concat(o+1),className:ew().screenImage}),(0,n.jsx)("div",{className:ew().textOverlay,children:(0,n.jsx)("div",{className:ew().thoughtText,children:null==g?void 0:g.text})})]}),(0,n.jsxs)("div",{className:ew().controls,children:[(0,n.jsxs)("div",{className:ew().timeline,children:[(0,n.jsx)("input",{type:"range",min:0,max:Math.max(0,t.length-1),value:o,onChange:e=>m(parseInt(e.target.value)),className:ew().timelineSlider}),(0,n.jsx)("div",{className:ew().frameMarkers,children:t.map((e,t)=>(0,n.jsx)("div",{className:"".concat(ew().frameMarker," ").concat(e.image?ew().hasImage:ew().textOnly," ").concat(t===o?ew().active:""),onClick:()=>m(t),title:"Frame ".concat(t+1,": ").concat(e.text.slice(0,50),"...")},t))})]}),(0,n.jsxs)("div",{className:ew().controlButtons,children:[(0,n.jsx)("button",{onClick:()=>{o>0&&(l(o-1),h(!1),i(!1))},disabled:0===o,title:"Previous frame",className:ew().controlButton,children:(0,n.jsx)(ex.F,{size:16})}),(0,n.jsx)("button",{onClick:()=>{i(!c),h(!1)},disabled:t.length<=1,title:c?"Pause":"Play",className:ew().controlButton,children:c?(0,n.jsx)(G.d,{size:16}):(0,n.jsx)(ev.s,{size:16})}),(0,n.jsx)("button",{onClick:()=>{o<t.length-1&&(l(o+1),h(!1),i(!1))},disabled:o===t.length-1,title:"Next frame",className:ew().controlButton,children:(0,n.jsx)(ej.N,{size:16})}),(0,n.jsx)("button",{onClick:()=>{h(!0),l(t.length-1),i(!1)},className:"".concat(ew().controlButton," ").concat(d?ew().active:""),title:"Auto-track latest",children:"Live"})]}),(0,n.jsx)("div",{className:ew().frameInfo,children:(0,n.jsxs)("span",{children:[o+1," / ",t.length]})})]})]}):null}var eM=a(3894),eC=a(20461),eN=a(77168),e_=a(15483),ek=a(81103),eR=e=>{let{name:t,avatar:a,link:s,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(ek.pn,{children:(0,n.jsxs)(ek.u,{delayDuration:0,children:[(0,n.jsx)(ek.aJ,{asChild:!0,children:(0,n.jsxs)(ed.z,{variant:"ghost",className:"flex items-center justify-center",children:[a,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(ek._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[a,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(v.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})};function eT(e){let[t,a]=(0,r.useState)(e.completed),[s,i]=(0,r.useState)([]);return(0,r.useEffect)(()=>{e.completed&&a(!0)},[e.completed]),(0,r.useEffect)(()=>{if(!e.trainOfThought||0===e.trainOfThought.length){i([]);return}i(function(e){if(!e)return[];let t=[],a=[],n=[];return e.forEach((e,s)=>{let o=e.data,r=!1;try{let e=o.match(/\{.*(\"action\": \"screenshot\"|\"type\": \"screenshot\"|\"image\": \"data:image\/.*\").*\}/);if(e){let l=JSON.parse(e[0]);l.image&&(r=!0,o=o.replace(":\n**Action**: ".concat(e[0]),""),l.text&&(o+="\n\n".concat(l.text)),n.length>0&&(t.push({type:"text",textEntries:[...n]}),n=[]),a.push({text:o,image:l.image,timestamp:s}))}}catch(e){console.error("Failed to parse screenshot data",e)}r||(a.length>0&&(t.push({type:"video",frames:[...a]}),a=[]),n.push(e))}),a.length>0&&t.push({type:"video",frames:a}),n.length>0&&t.push({type:"text",textEntries:n}),t}("string"==typeof e.trainOfThought[0]?e.trainOfThought.map((e,t)=>({type:"text",data:e})):e.trainOfThought))},[e.trainOfThought]),(0,n.jsxs)("div",{className:"".concat(t?"":o().trainOfThought+" border"," rounded-lg"),children:[!e.completed&&(0,n.jsx)(Y.l,{className:"float-right"}),e.completed&&(t?(0,n.jsxs)(ed.z,{className:"w-fit text-left justify-start content-start text-xs",onClick:()=>a(!1),variant:"ghost",size:"sm",children:["Thought Process ",(0,n.jsx)(eM.p,{size:16,className:"ml-1"})]}):(0,n.jsxs)(ed.z,{className:"w-fit text-left justify-start content-start text-xs p-0 h-fit",onClick:()=>a(!0),variant:"ghost",size:"sm",children:["Close ",(0,n.jsx)(eC.U,{size:16,className:"ml-1"})]})),(0,n.jsx)(l.M,{initial:!1,children:!t&&(0,n.jsx)(c.E.div,{initial:"closed",animate:"open",exit:"closed",variants:{open:{height:"auto",opacity:1,transition:{duration:.3,ease:"easeOut"}},closed:{height:0,opacity:0,transition:{duration:.3,ease:"easeIn"}}},children:s.map((t,a)=>(0,n.jsxs)("div",{children:["video"===t.type&&t.frames&&t.frames.length>0&&(0,n.jsx)(eb,{frames:t.frames,autoPlay:!1,playbackSpeed:1500}),"text"===t.type&&t.textEntries&&t.textEntries.map((o,r)=>{let l=s.length-1,c=r===t.textEntries.length-1,i=a===l&&c&&e.lastMessage&&!e.completed;return(0,n.jsx)(ef,{message:o.data,primary:i,agentColor:e.agentColor},"train-text-".concat(a,"-").concat(r,"-").concat(o.data.length))})]},"train-group-".concat(a)))})})]},e.keyId)}function eE(e){var t,a,s,l,c,i,d,h,u;let[g,m]=(0,r.useState)(null),[f,p]=(0,r.useState)(0),[x,v]=(0,r.useState)(!0),[j,y]=(0,r.useState)(null),w=(0,r.useRef)(null),b=(0,r.useRef)(null),C=(0,r.useRef)(null),N=(0,r.useRef)(null),_=(0,r.useRef)(null),[k,R]=(0,r.useState)(null),[T,E]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!0),S=(0,eo.IC)(),F="[data-radix-scroll-area-viewport]",L=localStorage.getItem("message");(0,r.useEffect)(()=>{var e;let t=null===(e=b.current)||void 0===e?void 0:e.querySelector(F);if(!t)return;let a=()=>{let{scrollTop:e,scrollHeight:a,clientHeight:n}=t;I(a-(e+n)<=50)};return t.addEventListener("scroll",a),a(),()=>t.removeEventListener("scroll",a)},[b]),(0,r.useEffect)(()=>{e.incomingMessages&&e.incomingMessages.length>0&&O&&B(!0)},[e.incomingMessages,O]),(0,r.useEffect)(()=>{var t;let a=C.current,n=null===(t=b.current)||void 0===t?void 0:t.querySelector(F);if(!a||!n)return;let s=new ResizeObserver(()=>{let{scrollTop:t,scrollHeight:a,clientHeight:s}=n;if(a-(t+s)<=50&&e.incomingMessages&&e.incomingMessages.length>0){let t=e.incomingMessages[e.incomingMessages.length-1];(!t.completed||t.completed&&null!==k)&&B(!0)}});return s.observe(a),()=>s.disconnect()},[e.incomingMessages,k,b]),(0,r.useEffect)(()=>{g&&g.chat&&g.chat.length>0&&f<2&&requestAnimationFrame(()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"})})},[g,f]),(0,r.useEffect)(()=>{if(!x||T)return;let t=new IntersectionObserver(t=>{t[0].isIntersecting&&x&&(E(!0),function(t){if(!x||T)return;let a=(t+1)*10,n="";if(e.conversationId)n="/api/chat/history?client=web&conversation_id=".concat(encodeURIComponent(e.conversationId),"&n=").concat(a);else{if(!e.publicConversationSlug)return;n="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(a)}fetch(n).then(e=>e.json()).then(a=>{var n;if(e.setTitle(a.response.slug),e.setIsOwner&&e.setIsOwner(null==a?void 0:null===(n=a.response)||void 0===n?void 0:n.is_owner),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(p(Math.ceil(a.response.chat.length/10)),a.response.chat.length===(null==g?void 0:g.chat.length)){v(!1),E(!1);return}e.setAgent(a.response.agent),m(a.response),E(!1),0===t?B(!0):D()}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug,is_owner:a.response.is_owner};e.setAgent(a.response.agent),m(t),e.setIsChatSideBarOpen&&!L&&e.setIsChatSideBarOpen(!0)}v(!1),E(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(f))},{threshold:1});return w.current&&t.observe(w.current),()=>t.disconnect()},[x,f,T]),(0,r.useEffect)(()=>{v(!0),E(!1),p(0),m(null)},[e.conversationId]),(0,r.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&(R(e.incomingMessages.length-1),e.setTitle(t.rawQuery),t.turnId&&y(t.turnId))}},[e.incomingMessages]);let D=()=>{var e;let t=null===(e=b.current)||void 0===e?void 0:e.querySelector(F);requestAnimationFrame(()=>{var e;null===(e=_.current)||void 0===e||e.scrollIntoView({behavior:"auto",block:"start"}),null==t||t.scrollBy({behavior:"smooth",top:-150})})},B=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=null===(e=b.current)||void 0===e?void 0:e.querySelector(F);requestAnimationFrame(()=>{null==a||a.scrollTo({top:a.scrollHeight,behavior:t?"auto":"smooth"})}),(t||a&&a.scrollHeight-(a.scrollTop+a.clientHeight)<5)&&I(!0)},P=t=>{t&&(m(e=>e&&t?{...e,chat:e.chat.filter(e=>e.turnId!==t)}:e),e.incomingMessages&&e.setIncomingMessages&&e.setIncomingMessages(e.incomingMessages.filter(e=>e.turnId!==t)))},z=(t,a)=>{var n;t&&(a&&P(a),null===(n=e.onRetryMessage)||void 0===n||n.call(e,t,a))};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(er.x,{className:"\n h-[calc(100svh-theme(spacing.44))]\n sm:h-[calc(100svh-theme(spacing.44))]\n md:h-[calc(100svh-theme(spacing.44))]\n lg:h-[calc(100svh-theme(spacing.72))]\n ",ref:b,children:(0,n.jsxs)("div",{ref:C,children:[(0,n.jsxs)("div",{className:"".concat(o().chatHistory," ").concat(e.customClassName),children:[(0,n.jsx)("div",{ref:w,style:{height:"1px"},children:T&&(0,n.jsx)(Y.l,{className:"opacity-50"})}),g&&g.chat&&g.chat.map((t,a)=>{var s,o;return(0,n.jsxs)(r.Fragment,{children:[t.trainOfThought&&"khoj"===t.by&&(0,n.jsx)(eT,{trainOfThought:t.trainOfThought,lastMessage:!1,agentColor:(null==g?void 0:null===(s=g.agent)||void 0===s?void 0:s.color)||"orange",keyId:"".concat(a,"trainOfThought"),completed:!0},"".concat(a,"trainOfThought")),(0,n.jsx)(ep,{ref:a===g.chat.length-2?N:a===g.chat.length-(f-1)*10?_:null,isMobileWidth:S,chatMessage:t,customClassName:"fullHistory",borderLeftColor:"".concat(null==g?void 0:null===(o=g.agent)||void 0===o?void 0:o.color,"-500"),isLastMessage:a===g.chat.length-1,onDeleteMessage:P,onRetryMessage:z,conversationId:e.conversationId},"".concat(a,"fullHistory"))]},"chatMessage-".concat(a))}),e.incomingMessages&&e.incomingMessages.map((t,a)=>{var s,o,l,c,i;let d=null!==(i=null!==(c=t.turnId)&&void 0!==c?c:j)&&void 0!==i?i:void 0;return(0,n.jsxs)(r.Fragment,{children:[(0,n.jsx)(ep,{isMobileWidth:S,chatMessage:{message:t.rawQuery,context:[],onlineContext:{},codeContext:{},created:t.timestamp,by:"you",automationId:"",images:t.images,conversationId:e.conversationId,turnId:d,queryFiles:t.queryFiles},customClassName:"fullHistory",borderLeftColor:"".concat(null==g?void 0:null===(s=g.agent)||void 0===s?void 0:s.color,"-500"),onDeleteMessage:P,onRetryMessage:z,conversationId:e.conversationId,turnId:d},"".concat(a,"outgoing")),t.trainOfThought&&t.trainOfThought.length>0&&(0,n.jsx)(eT,{trainOfThought:t.trainOfThought,lastMessage:a===k,agentColor:(null==g?void 0:null===(o=g.agent)||void 0===o?void 0:o.color)||"orange",keyId:"".concat(a,"trainOfThought"),completed:t.completed},"".concat(a,"trainOfThought-").concat(t.trainOfThought.length,"-").concat(t.trainOfThought.map(e=>e.length).join("-"))),(0,n.jsx)(ep,{isMobileWidth:S,chatMessage:{message:t.rawResponse,context:t.context,onlineContext:t.onlineContext,codeContext:t.codeContext,created:t.timestamp,by:"khoj",automationId:"",rawQuery:t.rawQuery,intent:{type:t.intentType||"",query:t.rawQuery,"memory-type":"","inferred-queries":t.inferredQueries||[]},conversationId:e.conversationId,images:t.generatedImages,queryFiles:t.generatedFiles,mermaidjsDiagram:t.generatedMermaidjsDiagram,turnId:d},conversationId:e.conversationId,turnId:d,onDeleteMessage:P,onRetryMessage:z,customClassName:"fullHistory",borderLeftColor:"".concat(null==g?void 0:null===(l=g.agent)||void 0===l?void 0:l.color,"-500"),isLastMessage:a===e.incomingMessages.length-1},"".concat(a,"incoming"))]},"incomingMessage".concat(a))}),e.pendingMessage&&(0,n.jsx)(ep,{isMobileWidth:S,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},codeContext:{},created:new Date().getTime().toString(),by:"you",automationId:"",conversationId:e.conversationId,turnId:void 0},conversationId:e.conversationId,onDeleteMessage:P,onRetryMessage:z,customClassName:"fullHistory",borderLeftColor:"".concat(null==g?void 0:null===(t=g.agent)||void 0===t?void 0:t.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),g&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(eR,{name:g&&g.agent&&(null===(l=g.agent)||void 0===l?void 0:l.name)?g.agent.is_hidden?"Khoj":null===(c=g.agent)||void 0===c?void 0:c.name:"Agent",link:g&&g.agent&&(null===(i=g.agent)||void 0===i?void 0:i.slug)?"/agents?agent=".concat(null===(d=g.agent)||void 0===d?void 0:d.slug):"/agents",avatar:(0,M.TI)(null===(a=g.agent)||void 0===a?void 0:a.icon,null===(s=g.agent)||void 0===s?void 0:s.color)||(0,n.jsx)(eN.v,{}),description:g&&g.agent?(null===(h=g.agent)||void 0===h?void 0:h.persona)?null===(u=g.agent)||void 0===u?void 0:u.persona:"You can set a persona for your agent in the Chat Options side panel.":"Your agent is no longer available. You will be reset to the default agent."})})})]}),(0,n.jsx)("div",{className:"".concat(e.customClassName," fixed bottom-[20%] z-10"),children:!O&&(0,n.jsx)("button",{title:"Scroll to bottom",className:"absolute bottom-0 right-0 bg-white dark:bg-[hsl(var(--background))] text-neutral-500 dark:text-white p-2 rounded-full shadow-xl",onClick:()=>{B()},children:(0,n.jsx)(e_.K,{size:24})})})]})}):null}},42501:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}},91499:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",emptyChatMessage:"chatMessage_emptyChatMessage__J9JRn",imagesContainer:"chatMessage_imagesContainer__HTRjT",imageWrapper:"chatMessage_imageWrapper__DF92M",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",retryButton:"chatMessage_retryButton__Z7Pzk",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}},44849:function(e){e.exports={videoPlayer:"trainOfThoughtVideoPlayer_videoPlayer__Dz3mA",screen:"trainOfThoughtVideoPlayer_screen__dvEVh",screenImage:"trainOfThoughtVideoPlayer_screenImage__3SgOQ",textOverlay:"trainOfThoughtVideoPlayer_textOverlay__BGbhO",thoughtText:"trainOfThoughtVideoPlayer_thoughtText__zn_vT",controls:"trainOfThoughtVideoPlayer_controls__HDkO_",timeline:"trainOfThoughtVideoPlayer_timeline__hSpWu",timelineSlider:"trainOfThoughtVideoPlayer_timelineSlider__GQ8dx",frameMarkers:"trainOfThoughtVideoPlayer_frameMarkers__5y3He",frameMarker:"trainOfThoughtVideoPlayer_frameMarker__DBO9Y",hasImage:"trainOfThoughtVideoPlayer_hasImage__GFGAk",textOnly:"trainOfThoughtVideoPlayer_textOnly__okufk",active:"trainOfThoughtVideoPlayer_active__zp6u9",controlButtons:"trainOfThoughtVideoPlayer_controlButtons__rqfIH",controlButton:"trainOfThoughtVideoPlayer_controlButton___RdE_",frameInfo:"trainOfThoughtVideoPlayer_frameInfo__u5nwA"}}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8459,244,3317,7138],{63521:function(){}},function(n){n.O(0,[2971,2117,1744],function(){return n(n.s=63521)}),_N_E=n.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3317,244,8459,7138],{63521:function(){}},function(n){n.O(0,[2971,2117,1744],function(){return n(n.s=63521)}),_N_E=n.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,s,t){Promise.resolve().then(t.bind(t,42780))},42780:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return er}});var a=t(57437),n=t(63136),i=t.n(n),l=t(2265),o=t(27127),r=t(99376),d=t(14308),c=t(59199);t(2446);var u=t(7436),h=t(5477),m=t(56937),x=t(55287),f=t(60729),p=t(34124),g=t(6512),j=t(37104),v=t(62869),y=t(632),N=t(47615),b=t(96108),w=t(36360),_=t(60906),S=t(36720),C=t(61563),O=t(82123),k=t(76818),I=t(78299),M=t(38513),E=t(94508),T=t(23518),z=t(57054),B=t(16605);let R=B.fC,L=B.xz,F=l.forwardRef((e,s)=>{let{className:t,align:n="center",sideOffset:i=4,...l}=e;return(0,a.jsx)(B.VY,{ref:s,align:n,sideOffset:i,className:(0,E.cn)("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",t),...l})});F.displayName=B.VY.displayName;var A=t(54036);function P(e){var s;let{...t}=e,[n,i]=l.useState(!1),[o,r]=(0,l.useState)(void 0),[d,c]=(0,l.useState)(void 0),{data:h,error:x,isLoading:f}=(0,m.h2)(!0),[p,g]=(0,l.useState)([]),j=(0,u.IC)();return((0,l.useEffect)(()=>{if(!f&&h){if(g(h.chat_model_options),t.initialModel)c(h.chat_model_options.find(e=>e.name===t.initialModel));else{let e=h.chat_model_options.find(e=>e.id===h.selected_chat_model_config);!e&&h.chat_model_options.length>0?c(h.chat_model_options[0]):c(e)}}},[h,t.initialModel,f]),(0,l.useEffect)(()=>{d&&h&&t.onSelect(d)},[d,h,t.onSelect]),f)?(0,a.jsx)(A.O,{className:"w-full h-10"}):x?(0,a.jsx)("div",{className:"text-sm text-error",children:x.message}):(0,a.jsx)("div",{className:"grid gap-2 w-[250px]",children:(0,a.jsxs)(z.J2,{open:n,onOpenChange:i,...t,children:[(0,a.jsx)(z.xo,{asChild:!0,children:(0,a.jsxs)(v.z,{variant:"outline",role:"combobox","aria-expanded":n,"aria-label":"Select a model",className:"w-full justify-between text-left",disabled:null!==(s=t.disabled)&&void 0!==s&&s,children:[(0,a.jsx)("p",{className:"truncate",children:d?d.name.substring(0,20):"Select a model..."}),(0,a.jsx)(I.K,{className:"opacity-50"})]})}),(0,a.jsx)(z.yk,{align:"end",className:"w-[250px] p-0",children:j?(0,a.jsx)("div",{children:(0,a.jsx)(T.mY,{loop:!0,children:(0,a.jsxs)(T.e8,{className:"h-[var(--cmdk-list-height)]",children:[(0,a.jsx)(T.sZ,{placeholder:"Search Models..."}),(0,a.jsx)(T.rb,{children:"No Models found."}),(0,a.jsx)(T.fu,{heading:"Models",children:p&&p.length>0&&p.map(e=>(0,a.jsx)(Z,{model:e,isSelected:(null==d?void 0:d.id)===e.id,onPeek:e=>r(e),onSelect:()=>{c(e),i(!1)},isActive:t.isActive},e.id))},"models")]})})}):(0,a.jsxs)(R,{children:[(0,a.jsx)(F,{side:"left",align:"start",forceMount:!0,className:"min-h-[280px]",children:(0,a.jsxs)("div",{className:"grid gap-2",children:[(0,a.jsx)("h4",{className:"font-medium leading-none",children:null==o?void 0:o.name}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:null==o?void 0:o.description}),(null==o?void 0:o.strengths)?(0,a.jsxs)("div",{className:"mt-4 grid gap-2",children:[(0,a.jsx)("h5",{className:"text-sm font-medium leading-none",children:"Strengths"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:o.strengths})]}):null]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)(L,{}),(0,a.jsx)(T.mY,{loop:!0,children:(0,a.jsxs)(T.e8,{className:"h-[var(--cmdk-list-height)]",children:[(0,a.jsx)(T.sZ,{placeholder:"Search Models..."}),(0,a.jsx)(T.rb,{children:"No Models found."}),(0,a.jsx)(T.fu,{heading:"Models",children:p&&p.length>0&&p.map(e=>(0,a.jsx)(Z,{model:e,isSelected:(null==d?void 0:d.id)===e.id,onPeek:e=>r(e),onSelect:()=>{c(e),i(!1)},isActive:t.isActive},e.id))},"models")]})})]})]})})]})})}function Z(e){let{model:s,isSelected:t,onSelect:n,onPeek:i,isActive:o}=e,r=l.useRef(null);return(0,u.Iy)(r,e=>{e.forEach(e=>{var t;"attributes"===e.type&&"aria-selected"===e.attributeName&&(null===(t=r.current)||void 0===t?void 0:t.getAttribute("aria-selected"))==="true"&&i(s)})}),(0,a.jsxs)(T.di,{onSelect:n,ref:r,className:"data-[selected=true]:bg-muted data-[selected=true]:text-secondary-foreground",disabled:!o&&"free"!==s.tier,children:[s.name," ","standard"===s.tier&&(0,a.jsx)("span",{className:"text-green-500 ml-2",children:"(Futurist)"}),(0,a.jsx)(M.J,{className:(0,E.cn)("ml-auto",t?"opacity-100":"opacity-0")})]},s.id)}var J=t(17200),W=t(2602),D=t(69304),K=t(42225),U=t(26815),V=t(9270),G=t(30401);let H=l.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(V.fC,{ref:s,className:(0,E.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-secondary-foreground ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-500 data-[state=checked]:text-primary-foreground",t),...n,children:(0,a.jsx)(V.z$,{className:(0,E.cn)("flex items-center justify-center text-current"),children:(0,a.jsx)(G.Z,{className:"h-4 w-4"})})})});H.displayName=V.fC.displayName;var Q=t(81103),q=t(61312),Y=t(26110),$=t(53647),X=t(84671),ee=t(95186),es=t(27648),et=t(99597);let ea=e=>fetch(e).then(e=>e.json());function en(e){let{...s}=e;return s.isMobileWidth?(0,a.jsx)(D.yo,{open:s.isOpen,onOpenChange:s.onOpenChange,children:(0,a.jsx)(D.ue,{className:"w-[300px] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",children:(0,a.jsx)(el,{...s})})}):(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)(el,{...s})})}function ei(e){let s=(0,K.BI)(),t=X.xF,[n,i]=(0,l.useState)(!1),[o,r]=(0,l.useState)(),[d,c]=(0,l.useState)(),[u,h]=(0,l.useState)(),[m,x]=(0,l.useState)(!1),[f,p]=(0,l.useState)(),[g,j]=(0,l.useState)(!1),[y,S]=(0,l.useState)();return(0,l.useEffect)(()=>{o&&d&&u?j(!0):j(!1)},[o,d,u]),(0,a.jsxs)(Y.Vq,{children:[(0,a.jsx)(Y.hg,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",variant:"secondary",children:"Create Agent"})}),(0,a.jsxs)(Y.cZ,{children:[(0,a.jsxs)(Y.fK,{children:[m&&f?(0,a.jsxs)(Y.$N,{children:["Created ",o]}):(0,a.jsx)(Y.$N,{children:"Create a New Agent"}),(0,a.jsx)(Y.GG,{}),(0,a.jsx)(Y.Be,{children:"If these settings have been helpful, create a dedicated agent you can re-use across conversations."})]}),(0,a.jsx)("div",{className:"py-4",children:m&&f?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,a.jsx)(et.E.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:260,damping:20},children:(0,a.jsx)(N.f,{className:"w-16 h-16 text-green-500",weight:"fill"})}),(0,a.jsx)(et.E.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2},className:"text-center text-lg font-medium text-accent-foreground",children:"Created successfully!"}),(0,a.jsx)(et.E.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4},children:(0,a.jsx)(es.default,{href:"/agents?agent=".concat(f),children:(0,a.jsx)(v.z,{variant:"secondary",className:"mt-2",children:"Manage Agent"})})})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(U._,{htmlFor:"agent_name",children:"Name"}),(0,a.jsx)(ee.I,{id:"agent_name",className:"w-full p-2 border mt-4 border-slate-500 rounded-lg",disabled:n,value:o,onChange:e=>r(e.target.value)})]}),(0,a.jsxs)("div",{className:"flex gap-4",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)($.Ph,{onValueChange:h,defaultValue:u,children:[(0,a.jsx)($.i4,{className:"w-full dark:bg-muted",disabled:n,children:(0,a.jsx)($.ki,{placeholder:"Color"})}),(0,a.jsx)($.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:t.map(e=>(0,a.jsx)($.Ql,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(b.C,{className:"w-6 h-6 mr-2 ".concat((0,X.oz)(e)),weight:"fill"}),e]})},e))})]})}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsxs)($.Ph,{onValueChange:c,defaultValue:d,children:[(0,a.jsx)($.i4,{className:"w-full dark:bg-muted",disabled:n,children:(0,a.jsx)($.ki,{placeholder:"Icon"})}),(0,a.jsx)($.Bw,{className:"items-center space-y-1 inline-flex flex-col",children:s.map(e=>(0,a.jsx)($.Ql,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,K.TI)(e,null!=u?u:"gray","w-6","h-6"),e]})},e))})]})})]})]})}),(0,a.jsxs)(Y.cN,{children:[y&&(0,a.jsx)("div",{className:"text-red-500 text-sm",children:y}),!m&&(0,a.jsxs)(v.z,{type:"submit",onClick:()=>void(!n&&(i(!0),fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o,icon:d,color:u,persona:e.customPrompt,chat_model:e.selectedModel,input_tools:e.inputTools,output_modes:e.outputModes,privacy_level:"private"})}).then(e=>e.json()).then(e=>{if(console.log("Success:",e),"detail"in e){S("Error creating agent: ".concat(e.detail)),i(!1);return}x(!0),p(e.slug),i(!1)}).catch(e=>{console.error("Error:",e),S("Error creating agent: ".concat(e)),i(!1)}))),disabled:n||!g,children:[n?(0,a.jsx)(w.U,{className:"animate-spin"}):(0,a.jsx)(_.R,{}),"Create"]}),(0,a.jsx)(Y.GG,{})]})]})]})}function el(e){var s,t,n,i;let{...o}=e,[r,d]=(0,l.useState)(!1),{data:c,error:u}=(0,J.ZP)("/api/agents/options",ea),{data:h,isLoading:p,error:g}=(0,J.ZP)("/api/agents/conversation?conversation_id=".concat(o.conversationId),ea),{data:j,error:y,isLoading:N}=(0,m.GW)(),[b,_]=(0,l.useState)(),[I,M]=(0,l.useState)(),[E,T]=(0,l.useState)(),[B,R]=(0,l.useState)(),[L,F]=(0,l.useState)(!1),[A,Z]=(0,l.useState)(!h||(null==h?void 0:h.slug.toLowerCase())==="khoj"),[D,V]=(0,l.useState)(),[G,Y]=(0,l.useState)(),[$,X]=(0,l.useState)(!1),ee=null!==(s=null==j?void 0:j.is_active)&&void 0!==s&&s;function es(){h&&(T(h.input_tools),V(h.input_tools),(void 0===h.input_tools||0===h.input_tools.length)&&V((null==c?void 0:c.input_tools)?Object.keys(c.input_tools):[]),R(h.output_modes),Y(h.output_modes),(void 0===h.output_modes||0===h.output_modes.length)&&Y((null==c?void 0:c.output_modes)?Object.keys(c.output_modes):[]),("khoj"===h.name.toLowerCase()||!0===h.is_hidden)&&d(!0),"khoj"===h.slug.toLowerCase()?(M(void 0),_(void 0),Z(!0)):(Z(!1),_(h.persona),M(h.chat_model)))}function et(e,s){return s.includes(e)?s.filter(s=>s!==e):[...s,e]}return(0,l.useEffect)(()=>{es(),F(!1)},[h]),(0,l.useEffect)(()=>{var e,s;if(!h||p)return;let t=!!I&&I!==h.chat_model,a=!!b&&b!==h.persona,n=JSON.stringify((null==E?void 0:E.sort())||[])!==JSON.stringify(null===(e=h.input_tools)||void 0===e?void 0:e.sort()),i=JSON.stringify((null==B?void 0:B.sort())||[])!==JSON.stringify(null===(s=h.output_modes)||void 0===s?void 0:s.sort());F(t||a||n||i)},[I,b,E,B,h,p]),(0,a.jsxs)(f.DD,{collapsible:"none",className:"ml-auto opacity-30 rounded-lg p-2 transition-all transform duration-300 ease-in-out\n ".concat(o.isOpen?"translate-x-0 opacity-100 w-[300px] relative":"translate-x-full opacity-100 w-0 p-0 m-0","\n "),variant:"floating",children:[(0,a.jsxs)(f.TZ,{children:[(0,a.jsx)(f.$l,{children:h&&!r?(0,a.jsx)("div",{className:"flex items-center relative text-sm",children:(0,a.jsxs)("a",{className:"text-lg font-bold flex flex-row items-center",href:"/agents?agent=".concat(h.slug),children:[(0,K.TI)(h.icon,h.color),h.name]})}):(0,a.jsx)("div",{className:"flex items-center relative text-sm justify-between",children:(0,a.jsx)("p",{children:"Chat Options"})})}),(0,a.jsx)(f.Hz,{className:"border-b last:border-none",children:(0,a.jsx)(f.Ks,{className:"gap-0",children:(0,a.jsx)(f.w3,{className:"p-0 m-0",children:h&&h.has_files?(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 rounded-full",children:[(0,a.jsx)("div",{className:"text-muted-foreground",children:(0,a.jsx)(S.J,{})}),(0,a.jsx)("div",{className:"text-muted-foreground text-sm",children:"Using custom knowledge base"})]})},"agent_knowledge"):null})})},"knowledge"),(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsx)(f.nO,{children:"Instructions"}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(k.g,{className:"w-full h-32 resize-none hover:resize-y",value:b||"",onChange:e=>{_(e.target.value)},readOnly:!r,disabled:!r})})})]})},"instructions"),!p&&h&&(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsxs)(f.nO,{children:["Model",!ee&&(0,a.jsx)("a",{href:"/settings",className:"hover:font-bold text-accent-foreground m-2 bg-accent bg-opacity-10 p-1 rounded-lg",children:"Upgrade"})]}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(P,{disabled:!r,onSelect:e=>{M(e.name)},initialModel:A?void 0:null==h?void 0:h.chat_model,isActive:o.isActive})},"model")})]})},"model"),(0,a.jsx)(z.J2,{defaultOpen:!1,children:(0,a.jsxs)(f.Hz,{children:[(0,a.jsx)(f.nO,{asChild:!0,children:(0,a.jsxs)(z.xo,{children:["Tools",(0,a.jsx)(C._,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),(0,a.jsx)(z.yk,{children:(0,a.jsx)(f.Ks,{children:(0,a.jsxs)(f.w3,{className:"p-1 m-0",children:[Object.entries(null!==(t=null==c?void 0:c.input_tools)&&void 0!==t?t:{}).map(e=>{let[s,t]=e;return(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)(Q.u,{children:[(0,a.jsx)(Q.aJ,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 py-1 justify-between",children:[(0,a.jsxs)(U._,{htmlFor:s,className:"flex items-center gap-2 text-accent-foreground p-1 cursor-pointer",children:[(0,K.vH)(s),(0,a.jsx)("p",{className:"text-sm my-auto flex items-center",children:s})]}),(0,a.jsx)(H,{id:s,className:"".concat(r?"cursor-pointer":""),checked:(null!=D?D:[]).includes(s),onCheckedChange:()=>{let e=et(s,null!=D?D:[]);T(e),V(e)},disabled:!r,children:s})]})},s),(0,a.jsx)(q._v,{sideOffset:5,side:"left",align:"start",className:"text-sm bg-background text-foreground shadow-sm border border-slate-500 border-opacity-20 p-2 rounded-lg",children:t})]})},s)}),Object.entries(null!==(n=null==c?void 0:c.output_modes)&&void 0!==n?n:{}).map(e=>{let[s,t]=e;return(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsxs)(Q.u,{children:[(0,a.jsx)(Q.aJ,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center space-x-2 py-1 justify-between",children:[(0,a.jsxs)(U._,{htmlFor:s,className:"flex items-center gap-2 p-1 rounded-lg cursor-pointer",children:[(0,K.vH)(s),(0,a.jsx)("p",{className:"text-sm my-auto flex items-center",children:s})]}),(0,a.jsx)(H,{id:s,className:"".concat(r?"cursor-pointer":""),checked:(null!=G?G:[]).includes(s),onCheckedChange:()=>{let e=et(s,null!=G?G:[]);R(e),Y(e)},disabled:!r,children:s})]})},s),(0,a.jsx)(q._v,{sideOffset:5,side:"left",align:"start",className:"text-sm bg-background text-foreground shadow-sm border border-slate-500 border-opacity-20 p-2 rounded-lg",children:t})]})},s)})]})})})]})}),(0,a.jsx)(f.Hz,{children:(0,a.jsxs)(f.Ks,{children:[(0,a.jsx)(f.nO,{children:"Files"}),(0,a.jsx)(f.w3,{className:"p-0 m-0",children:(0,a.jsx)(f.LO,{className:"list-none",children:(0,a.jsx)(x.J_,{conversationId:o.conversationId,uploadedFiles:[],isMobileWidth:null!==(i=o.isMobileWidth)&&void 0!==i&&i})},"files-conversation")})]})},"files")]}),o.isOpen&&(0,a.jsx)(f.ZW,{children:(0,a.jsx)(f.w3,{className:"p-0 m-0",children:h&&!r&&h.is_creator?(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",variant:"ghost",onClick:()=>window.location.href="/agents?agent=".concat(null==h?void 0:h.slug),children:"Manage"})})}):(0,a.jsxs)(a.Fragment,{children:[!L&&r&&b&&!A&&I&&(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(ei,{customPrompt:b,selectedModel:I,inputTools:null!=D?D:[],outputModes:null!=G?G:[]})})}),(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsx)(v.z,{className:"w-full",onClick:()=>void(es(),F(!1)),variant:"ghost",disabled:!r||!L,children:"Reset"})})}),(0,a.jsx)(f.LO,{children:(0,a.jsx)(f.bb,{asChild:!0,children:(0,a.jsxs)(v.z,{className:"w-full ".concat(L?"bg-accent-foreground text-accent":""),variant:"secondary",onClick:()=>(function(){if(L){if(!A&&(null==h?void 0:h.is_hidden)===!1){alert("This agent is not a hidden agent. It cannot be modified from this interface.");return}let e="PATCH";A&&(e="POST");let s={persona:b,chat_model:I,input_tools:E,output_modes:B,...A?{}:{slug:null==h?void 0:h.slug}};X(!0),fetch(A?"/api/agents/hidden?conversation_id=".concat(o.conversationId):"/api/agents/hidden",{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then(e=>{X(!1),e.json()}).then(e=>{(0,W.j)("/api/agents/conversation?conversation_id=".concat(o.conversationId)),F(!1)}).catch(e=>{console.error("Error:",e),X(!1)})}})(),disabled:!r||!L||$,children:[$?(0,a.jsx)(w.U,{className:"animate-spin"}):(0,a.jsx)(O.Z,{}),$?"Saving":"Save"]})})})]})})},"actions")]})}function eo(e){let s=(0,r.useSearchParams)().get("conversationId"),[t,n]=(0,l.useState)(""),[d,c]=(0,l.useState)([]),[u,m]=(0,l.useState)(!1),[x,f]=(0,l.useState)(null),[p,g]=(0,l.useState)(!1),j=(0,l.useRef)(null),v=e.setQueryToProcess,y=e.onConversationIdChange,N=e.isMobileWidth?"w-full":"w-4/6";if((0,l.useEffect)(()=>{if(d.length>0){let s=d.map(e=>encodeURIComponent(e));e.setImages(s)}},[d,e.setImages]),(0,l.useEffect)(()=>{let s=localStorage.getItem("images");if(s){let t=JSON.parse(s);c(t);let a=t.map(e=>encodeURIComponent(e));e.setImages(a),localStorage.removeItem("images")}let t=localStorage.getItem("message");t&&(m(!0),v(t),t.trim().startsWith("/research")&&g(!0));let a=localStorage.getItem("uploadedFiles");if(a){let s=a?JSON.parse(a):[],t=[];for(let e of s)t.push({name:e.name,file_type:e.file_type,content:e.content,size:e.size});localStorage.removeItem("uploadedFiles"),e.setUploadedFiles(t)}},[v,e.setImages,s]),(0,l.useEffect)(()=>{t&&(m(!0),v(t))},[t,v]),(0,l.useEffect)(()=>{s&&(null==y||y(s))},[s,y]),(0,l.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?(m(!1),c([]),e.setUploadedFiles(void 0)):n("")},[e.streamedMessages]),!s){window.location.href="/";return}return(0,a.jsxs)("div",{className:"flex flex-row h-full w-full",children:[(0,a.jsxs)("div",{className:"flex flex-col h-full w-full",children:[(0,a.jsx)("div",{className:i().chatBodyFull,children:(0,a.jsx)(o.Z,{conversationId:s,setTitle:e.setTitle,setAgent:f,pendingMessage:u?t:"",incomingMessages:e.streamedMessages,setIncomingMessages:e.setStreamedMessages,customClassName:N,setIsChatSideBarOpen:e.setIsChatSideBarOpen,onRetryMessage:e.onRetryMessage})}),(0,a.jsx)("div",{className:"".concat(i().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-2xl md:rounded-xl h-fit ").concat(N," mr-auto ml-auto mt-auto"),children:(0,a.jsx)(h.a,{agentColor:null==x?void 0:x.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>n(e),sendImage:e=>c(s=>[...s,e]),sendDisabled:e.isParentProcessing||!1,chatOptionsData:e.chatOptionsData,conversationId:s,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles,ref:j,isResearchModeEnabled:p,setTriggeredAbort:e.setTriggeredAbort})})]}),(0,a.jsx)(en,{conversationId:s,isActive:e.isActive,isOpen:e.isChatSideBarOpen,onOpenChange:e.setIsChatSideBarOpen,isMobileWidth:e.isMobileWidth})]})}function er(){let e="Khoj AI - Chat",[s,t]=(0,l.useState)(null),[n,o]=(0,l.useState)(!0),[r,h]=(0,l.useState)(e),[N,b]=(0,l.useState)(null),[w,_]=(0,l.useState)([]),[S,C]=(0,l.useState)(""),[O,k]=(0,l.useState)(!1),[I,M]=(0,l.useState)(void 0),[E,T]=(0,l.useState)([]),[z,B]=(0,l.useState)(null),[R,L]=(0,l.useState)(!1),[F,A]=(0,l.useState)(!1),{locationData:P,locationDataError:Z,locationDataLoading:J}=(0,u.k6)()||{locationData:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}},{data:W,error:D,isLoading:K}=(0,m.GW)(),U=(0,u.IC)(),[V,G]=(0,l.useState)(!1);async function H(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let s=e.body.getReader(),t=new TextDecoder,a="␃\uD83D\uDD1A␗",n="",i=[],l={},o={};for(;;){let e;let{done:r,value:d}=await s.read();if(r){C(""),k(!1),T([]),N&&(0,c.tQ)(N,h);break}for(n+=t.decode(d,{stream:!0});-1!==(e=n.indexOf(a));){let s=n.slice(0,e);if(n=n.slice(e+a.length),s){let e=w.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:i,onlineContext:l,codeContext:o}=(0,c.VK)(s,e,i,l,o)),_([...w])}}}}async function Q(){if(localStorage.removeItem("message"),!S||!N){k(!1);return}let e={q:S,conversation_id:N,stream:!0,interrupt:F,...P&&{city:P.city,region:P.region,country:P.country,country_code:P.countryCode,timezone:P.timezone},...E.length>0&&{images:E},...I&&{files:I}};A(!1);let s=await fetch("/api/chat?client=web",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:null==z?void 0:z.signal});try{await H(s)}catch(i){let e;try{e=await s.json()}catch(s){e={streamError:"Error reading API error response stream. Expected JSON response."}}console.error(e);let t=w.find(e=>!e.completed);if(!t)return;let a=i.message,n=i.name;a.includes("Error in input stream")?t.rawResponse="Woops! The connection broke while I was writing my thoughts down. Maybe try again in a bit or dislike this message if the issue persists?":e.streamError?t.rawResponse="Umm, not sure what just happened but I lost my train of thought. Could you try again or ask my developers to look into this if the issue persists? They can be contacted at the Khoj Github, Discord or team@khoj.dev.":429===s.status?"detail"in e?t.rawResponse="".concat(e.detail):t.rawResponse="I'm a bit overwhelmed at the moment. Could you try again in a bit or dislike this message if the issue persists?":"AbortError"===n?t.rawResponse="I've stopped processing this message. If you'd like to continue, please send the message again.":t.rawResponse="Umm, not sure what just happened. I see this error message: ".concat(a,". Could you try again or dislike this message if the issue persists?"),t.completed=!0,_([...w]),C(""),k(!1)}}return(0,l.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{o(!1),e&&t(e)}).catch(e=>{console.error(e)}),(0,u.EK)()},[]),(0,l.useEffect)(()=>{R&&(null==z||z.abort(),function(){let e=w.find(e=>!e.completed);e&&(e.completed=!0,_([...w]),k(!1))}(),A(!0),L(!1))},[R]),(0,l.useEffect)(()=>{if(S){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},codeContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:S||"",images:E,queryFiles:I};_(s=>[...s,e]),k(!0),B(new AbortController)}},[S]),(0,l.useEffect)(()=>{O&&!J&&Q()},[O,J]),n?(0,a.jsx)(d.Z,{}):(0,a.jsxs)(f.Hn,{children:[(0,a.jsx)(p.S,{conversationId:N||""}),(0,a.jsxs)(f.kV,{children:[(0,a.jsxs)("header",{className:"flex h-16 shrink-0 items-center gap-2 border-b px-4",children:[(0,a.jsx)(f.vP,{className:"-ml-1"}),(0,a.jsx)(g.Z,{orientation:"vertical",className:"mr-2 h-4"}),N&&(0,a.jsx)("div",{className:"".concat(i().chatTitleWrapper," text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mx-2 md:mr-8 col-auto h-fit"),children:U?(0,a.jsx)("a",{className:"p-0 no-underline",href:"/",children:(0,a.jsx)(j.VO,{className:"h-auto w-16"})}):r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden mr-4",children:r}),(0,a.jsx)(x.En,{conversationId:N,setTitle:h,sizing:"md"})]})}),(0,a.jsx)("div",{className:"flex justify-end items-start gap-2 text-sm ml-auto",children:(0,a.jsx)(v.z,{variant:"ghost",size:"icon",className:"h-12 w-12 data-[state=open]:bg-accent",onClick:()=>G(!V),children:(0,a.jsx)(y.T,{className:"w-6 h-6"})})})]}),(0,a.jsxs)("div",{className:"".concat(i().main," ").concat(i().chatLayout),children:[(0,a.jsx)("title",{children:"".concat(e).concat(r&&r!==e?": ".concat(r):"")}),(0,a.jsx)("div",{className:i().chatBox,children:(0,a.jsx)("div",{className:i().chatBoxBody,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(d.Z,{}),children:(0,a.jsx)(eo,{isLoggedIn:!!W,streamedMessages:w,setStreamedMessages:_,chatOptionsData:s,setTitle:h,setQueryToProcess:C,setUploadedFiles:M,isMobileWidth:U,onConversationIdChange:e=>{b(e)},setImages:T,setTriggeredAbort:L,isChatSideBarOpen:V,setIsChatSideBarOpen:G,isActive:null==W?void 0:W.is_active,isParentProcessing:O,onRetryMessage:(e,s)=>{if(!e){console.warn("No query provided for retry");return}s&&(_(e=>e.filter(e=>e.turnId!==s)),fetch("/api/chat/conversation/message",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversation_id:N,turn_id:s})}).catch(e=>{console.error("Failed to delete message for retry:",e)})),C(e)}})})})})]})]})]})}},26815:function(e,s,t){"use strict";t.d(s,{_:function(){return d}});var a=t(57437),n=t(2265),i=t(6394),l=t(90535),o=t(94508);let r=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(i.f,{ref:s,className:(0,o.cn)(r(),t),...n})});d.displayName=i.f.displayName},53647:function(e,s,t){"use strict";t.d(s,{Bw:function(){return f},Ph:function(){return c},Ql:function(){return p},i4:function(){return h},ki:function(){return u}});var a=t(57437),n=t(2265),i=t(56873),l=t(40875),o=t(22135),r=t(30401),d=t(94508);let c=i.fC;i.ZA;let u=i.B4,h=n.forwardRef((e,s)=>{let{className:t,children:n,...o}=e;return(0,a.jsxs)(i.xz,{ref:s,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...o,children:[n,(0,a.jsx)(i.JO,{asChild:!0,children:(0,a.jsx)(l.Z,{className:"h-4 w-4 opacity-50"})})]})});h.displayName=i.xz.displayName;let m=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(i.u_,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...n,children:(0,a.jsx)(o.Z,{className:"h-4 w-4"})})});m.displayName=i.u_.displayName;let x=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(i.$G,{ref:s,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...n,children:(0,a.jsx)(l.Z,{className:"h-4 w-4"})})});x.displayName=i.$G.displayName;let f=n.forwardRef((e,s)=>{let{className:t,children:n,position:l="popper",...o}=e;return(0,a.jsx)(i.h_,{children:(0,a.jsxs)(i.VY,{ref:s,className:(0,d.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:l,...o,children:[(0,a.jsx)(m,{}),(0,a.jsx)(i.l_,{className:(0,d.cn)("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),(0,a.jsx)(x,{})]})})});f.displayName=i.VY.displayName,n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(i.__,{ref:s,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...n})}).displayName=i.__.displayName;let p=n.forwardRef((e,s)=>{let{className:t,children:n,...l}=e;return(0,a.jsxs)(i.ck,{ref:s,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...l,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(i.wU,{children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(i.eT,{children:n})]})});p.displayName=i.ck.displayName,n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,a.jsx)(i.Z0,{ref:s,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",t),...n})}).displayName=i.Z0.displayName},63136:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w",chatTitleWrapper:"chat_chatTitleWrapper__6ChWq"}}},function(e){e.O(0,[8255,9853,1189,3954,1919,9259,7200,8667,4363,4447,4357,7211,9334,2327,5477,7127,2971,2117,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[244,3317,8459,7138],{63521:function(){}},function(n){n.O(0,[2971,2117,1744],function(){return n(n.s=63521)}),_N_E=n.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7138,244,3317,8459],{63521:function(){}},function(n){n.O(0,[2971,2117,1744],function(){return n(n.s=63521)}),_N_E=n.O()}]);
@@ -1 +0,0 @@
1
- div.agents_titleBar__FzYbY{padding:16px 0;text-align:left}.agents_agentPersonality__o0Ysz p{white-space:inherit;overflow:hidden;height:77px;line-height:1.5}div.agents_agentPersonality__o0Ysz{text-align:left;grid-column:span 3;overflow:hidden}div.agents_pageLayout__gR3S3{max-width:60vw;margin:auto auto 2rem}button.agents_infoButton__NqI7E{border:none;background-color:transparent!important;text-align:left;font-family:inherit;font-size:medium}div.agents_agentList__XVx4A{display:grid;gap:20px;padding-top:30px;margin-right:auto;grid-auto-flow:row;grid-template-columns:1fr 1fr;margin-left:auto}@media only screen and (max-width:768px){div.agents_agentList__XVx4A{width:100%;padding:0;margin-right:auto;margin-left:auto;grid-template-columns:1fr}div.agents_pageLayout__gR3S3{max-width:90vw}}.loginPrompt_gsiMaterialButton__8QVFH{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-webkit-appearance:none;background-image:none;border-radius:20px;box-sizing:border-box;color:#1f1f1f;cursor:pointer;font-family:Roboto,arial,sans-serif;font-size:14px;height:40px;letter-spacing:.25px;outline:none;overflow:hidden;padding:0;position:relative;text-align:center;transition:background-color .218s,border-color .218s,box-shadow .218s;vertical-align:middle;white-space:nowrap;width:40px;max-width:400px;min-width:-moz-min-content;min-width:min-content}.loginPrompt_gsiMaterialButton__8QVFH .loginPrompt_gsiMaterialButtonIcon__6TSC5{height:100%;min-width:20px;width:100%;margin:0;padding:9px}.loginPrompt_gsiMaterialButton__8QVFH .loginPrompt_gsiMaterialButtonContentWrapper__9tahB{align-items:center;display:flex;flex-direction:row;flex-wrap:nowrap;height:100%;justify-content:space-between;position:relative;width:100%}.loginPrompt_gsiMaterialButton__8QVFH .loginPrompt_gsiMaterialButtonContents__3_YcB{flex-grow:1;font-family:Roboto,arial,sans-serif;font-weight:500;overflow:hidden;text-overflow:ellipsis;vertical-align:top}.loginPrompt_gsiMaterialButton__8QVFH .loginPrompt_gsiMaterialButtonState__CDGQm{transition:opacity .218s;bottom:0;left:0;opacity:0;position:absolute;right:0;top:0}.loginPrompt_gsiMaterialButton__8QVFH:disabled{cursor:default;background-color:#ffffff61;border-color:#1f1f1f1f}.loginPrompt_gsiMaterialButton__8QVFH:disabled .loginPrompt_gsiMaterialButtonContents__3_YcB,.loginPrompt_gsiMaterialButton__8QVFH:disabled .loginPrompt_gsiMaterialButtonIcon__6TSC5{opacity:38%}.loginPrompt_gsiMaterialButton__8QVFH:not(:disabled):active .loginPrompt_gsiMaterialButton-State__mAfCZ,.loginPrompt_gsiMaterialButton__8QVFH:not(:disabled):focus .loginPrompt_gsiMaterialButtonState__CDGQm{background-color:#303030;opacity:12%}.loginPrompt_gsiMaterialButton__8QVFH:not(:disabled):hover{box-shadow:0 1px 2px 0 rgba(60,64,67,.3),0 1px 3px 1px rgba(60,64,67,.15)}.loginPrompt_gsiMaterialButton__8QVFH:not(:disabled):hover .loginPrompt_gsiMaterialButtonState__CDGQm{background-color:#303030;opacity:8%}.trainOfThoughtVideoPlayer_videoPlayer__Dz3mA{border:1px solid hsl(var(--border));border-radius:8px;background-color:hsl(var(--background));margin:16px 0;overflow:hidden}.trainOfThoughtVideoPlayer_screen__dvEVh{position:relative;background-color:hsl(var(--muted));min-height:300px;display:flex;align-items:center;justify-content:center}.trainOfThoughtVideoPlayer_screenImage__3SgOQ{max-width:100%;max-height:400px;-o-object-fit:contain;object-fit:contain;border-radius:4px}.trainOfThoughtVideoPlayer_textOverlay__BGbhO{position:absolute;bottom:0;left:0;right:0;background:linear-gradient(transparent,rgba(0,0,0,.8));padding:20px 16px 12px;color:#fff}.trainOfThoughtVideoPlayer_thoughtText__zn_vT{font-size:14px;line-height:1.4;max-height:100px;overflow-y:auto}.trainOfThoughtVideoPlayer_controls__HDkO_{padding:12px 16px;background-color:hsl(var(--card));border-top:1px solid hsl(var(--border))}.trainOfThoughtVideoPlayer_timeline__hSpWu{position:relative;margin-bottom:12px}.trainOfThoughtVideoPlayer_timelineSlider__GQ8dx{width:100%;height:4px;background-color:hsl(var(--muted));border-radius:2px;outline:none;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.trainOfThoughtVideoPlayer_timelineSlider__GQ8dx::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background-color:hsl(var(--primary));cursor:pointer;border:2px solid #fff;box-shadow:0 2px 4px rgba(0,0,0,.2)}.trainOfThoughtVideoPlayer_timelineSlider__GQ8dx::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background-color:hsl(var(--primary));cursor:pointer;border:2px solid #fff;box-shadow:0 2px 4px rgba(0,0,0,.2)}.trainOfThoughtVideoPlayer_frameMarkers__5y3He{position:absolute;top:-2px;left:0;right:0;height:8px;display:flex;justify-content:space-between;pointer-events:none}.trainOfThoughtVideoPlayer_frameMarker__DBO9Y{width:6px;height:8px;border-radius:1px;cursor:pointer;pointer-events:auto;transition:all .2s ease}.trainOfThoughtVideoPlayer_frameMarker__DBO9Y.trainOfThoughtVideoPlayer_hasImage__GFGAk{background-color:hsl(var(--primary))}.trainOfThoughtVideoPlayer_frameMarker__DBO9Y.trainOfThoughtVideoPlayer_textOnly__okufk{background-color:hsl(var(--muted-foreground))}.trainOfThoughtVideoPlayer_frameMarker__DBO9Y.trainOfThoughtVideoPlayer_active__zp6u9{background-color:hsl(var(--accent))!important;transform:scaleY(1.5)}.trainOfThoughtVideoPlayer_frameMarker__DBO9Y:hover{transform:scaleY(1.2)}.trainOfThoughtVideoPlayer_controlButtons__rqfIH{display:flex;align-items:center;gap:8px;margin-bottom:8px}.trainOfThoughtVideoPlayer_controlButton___RdE_{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid hsl(var(--border));border-radius:4px;background-color:hsl(var(--background));color:hsl(var(--foreground));cursor:pointer;transition:all .2s ease}.trainOfThoughtVideoPlayer_controlButton___RdE_:hover:not(:disabled){background-color:hsl(var(--muted))}.trainOfThoughtVideoPlayer_controlButton___RdE_:disabled{opacity:.5;cursor:not-allowed}.trainOfThoughtVideoPlayer_controlButton___RdE_.trainOfThoughtVideoPlayer_active__zp6u9{background-color:hsl(var(--primary));color:hsl(var(--primary-foreground))}.trainOfThoughtVideoPlayer_frameInfo__u5nwA{display:flex;justify-content:center;font-size:12px;color:hsl(var(--muted-foreground))}@media (prefers-color-scheme:dark){.trainOfThoughtVideoPlayer_textOverlay__BGbhO{background:linear-gradient(transparent,rgba(0,0,0,.9))}}div.automations_automationsLayout__Atoh_{display:grid;grid-template-columns:1fr 1fr;gap:1rem}div.automations_automationCard__BKidA{display:grid;grid-template-rows:auto 1fr auto}div.automations_pageLayout__OaoYA{max-width:60vw;margin:auto auto 2rem}@media screen and (max-width:768px){div.automations_automationsLayout__Atoh_{grid-template-columns:1fr}div.automations_pageLayout__OaoYA{max-width:90vw}}
@@ -1 +0,0 @@
1
- div.search_searchLayout__fP3m0{display:grid;grid-template-columns:1fr;gap:1rem;height:100%}@media screen and (max-width:768px){div.search_searchLayout__fP3m0{gap:0}}div.sidePanel_session__EeNjH{padding:.5rem;margin-bottom:.25rem;border-radius:.5rem;cursor:pointer;max-width:14rem;font-size:medium;display:grid;grid-template-columns:minmax(auto,400px) 1fr;gap:0}div.sidePanel_compressed__CUgIn{grid-template-columns:minmax(12rem,100%) 1fr 1fr}div.sidePanel_sessionHover__cf_VO,div.sidePanel_session__EeNjH:hover{background-color:hsla(var(--popover))}div.sidePanel_session__EeNjH:hover{color:hsla(var(--popover-foreground))}div.sidePanel_session__EeNjH a{text-decoration:none}button.sidePanel_button__NzdN_{border:none;outline:none;background-color:transparent;cursor:pointer;color:var(--main-text-color);width:24px}button.sidePanel_showMoreButton__nDt4Z{border-radius:.5rem;padding:8px}div.sidePanel_panel__9offQ{display:flex;flex-direction:column;padding:1rem;overflow-y:auto;max-width:auto;transition:background-color .5s}div.sidePanel_expanded__aHnYV{gap:1rem;background-color:hsla(var(--muted));height:100%}div.sidePanel_collapsed__ewO3e{display:grid;grid-template-columns:1fr;height:-moz-fit-content;height:fit-content;padding:1rem 0 0 1rem}p.sidePanel_session__EeNjH{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;text-align:left;font-size:small}p.sidePanel_compressed__CUgIn{width:11rem}p.sidePanel_expanded__aHnYV{max-width:20rem}div.sidePanel_header__NCT_v{display:grid;grid-template-columns:1fr auto}div.sidePanel_profile__pfAJU{display:grid;grid-template-columns:auto 1fr;gap:1rem;align-items:center;margin-top:auto}div.sidePanel_panelWrapper__cDMvb{display:grid;grid-template-rows:1fr auto auto;height:100%}div.sidePanel_modalSessionsList___u3aa{position:fixed;top:0;left:0;width:100%;height:100%;background-color:hsla(var(--frosted-background-color));z-index:1;display:flex;justify-content:center;align-items:center;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}div.sidePanel_modalSessionsList___u3aa div.sidePanel_content__z60YO{max-width:80%;max-height:80%;background-color:hsla(var(--frosted-background-color));overflow:auto;padding:20px;border-radius:10px}div.sidePanel_modalSessionsList___u3aa div.sidePanel_session__EeNjH{max-width:100%;text-overflow:ellipsis}@media screen and (max-width:768px){div.sidePanel_panel__9offQ{padding:.25rem;width:100%}div.sidePanel_expanded__aHnYV{z-index:1}div.sidePanel_singleReference__vmXZr{padding:4px}div.sidePanel_panelWrapper__cDMvb{width:100%;padding:0 1rem}div.sidePanel_session__EeNjH.sidePanel_compressed__CUgIn{max-width:100%;display:grid;grid-template-columns:70vw auto;justify-content:space-between}div.sidePanel_session__EeNjH{max-width:100%;grid-template-columns:minmax(auto,70vw) 1fr}}.agentCard_agentPersonality__MmRlN p{white-space:inherit;overflow:hidden;height:77px;line-height:1.5}div.agentCard_agentPersonality__MmRlN{text-align:left;grid-column:span 3;overflow:hidden}button.agentCard_infoButton__heh_w{border:none;background-color:transparent!important;text-align:left;font-family:inherit;font-size:medium}