research-agent-ui 0.1.35 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -13,11 +13,11 @@
13
13
  #5a922c calc(50% / var(--repeating-conic-gradient-times)),
14
14
  #4c7894 calc(75% / var(--repeating-conic-gradient-times)),
15
15
  #dd7bbb calc(100% / var(--repeating-conic-gradient-times))
16
- )`},className:E(`pointer-events-none absolute inset-0 rounded-[inherit] opacity-100 transition-opacity`,o&&`opacity-100`,e>0&&`blur-[var(--blur)] `,s,f&&`!hidden`),children:(0,d.jsx)(`div`,{className:E(`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))]`)})})]})});O.displayName=`GlowingEffect`;var k=(0,n.createContext)(void 0),A=()=>{let e=(0,n.useContext)(k);if(!e)throw Error(`useExtractPanel must be used within an ExtractPanelProvider`);return e},j=({children:e})=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(``),[o,s]=(0,n.useState)(``),[c,l]=(0,n.useState)(600);return(0,d.jsx)(k.Provider,{value:{isOpen:t,url:i,searchText:o,panelWidth:c,setIsOpen:r,setUrl:a,setSearchText:s,setPanelWidth:l,openPanel:(e,t=``)=>{console.log(`[ExtractPanelContext] openPanel called with URL:`,e);try{let t=new URL(e);(t.pathname===`/`||t.pathname===``)&&console.error(`[ExtractPanelContext] URL is domain-only, missing article path:`,e)}catch(t){console.error(`[ExtractPanelContext] Invalid URL format:`,e,t)}if(a(e),s(t),r(!0),typeof window<`u`){let t=new URLSearchParams(window.location.search);t.set(`extract`,encodeURIComponent(e));let n=`${window.location.pathname}?${t.toString()}`;window.history.pushState({},``,n)}},closePanel:()=>{if(r(!1),typeof window<`u`){let e=new URLSearchParams(window.location.search);e.delete(`extract`);let t=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.pushState({},``,t)}}},children:e})};function M(e){return(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 214.6279 198.1416`,...e,children:[(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{fill:`#5CB0FF`,d:`M171.748,142.3193c0-15.4375-12.5625-28-28-28s-28,12.5625-28,28s12.5625,28,28,28 S171.748,157.7568,171.748,142.3193z`}),(0,d.jsx)(`path`,{fill:`#1C71DA`,d:`M95.748,166.3193v-76h42.989c0.0146,0.7878,0.0696,1.5579,0.0696,2.3516c0,2.2109,1.7891,4,4,4 s4-1.7891,4-4c0-0.7937-0.0603-1.5632-0.0745-2.3516h25.0159h5.6484h2.3516c0-46.3164-37.6836-84-84-84h-8v0.4053 c-42.5754,4.0447-76,39.9785-76,83.5947c0,46.3164,37.6836,84,84,84c2.2109,0,4-1.7891,4-4S97.959,166.3193,95.748,166.3193z M87.748,164.9949c-19.9287-6.438-35.0586-36.3945-35.0586-72.324c0-0.7937,0.0549-1.5637,0.0696-2.3516h34.989V164.9949z M53.1655,82.3193C55.75,51.1135,69.7729,26.157,87.748,20.3506v61.9688H53.1655z M95.748,82.3193v-63.293 c21.6829,0,39.6248,27.5808,42.5825,63.293H95.748z M171.3181,82.3193h-24.9685c-2.3884-29.9812-14.96-54.8911-31.9993-65.6013 C144.7681,24.4146,167.9641,50.417,171.3181,82.3193z M77.1458,16.718C60.1064,27.4282,47.5349,52.3381,45.1465,82.3193H20.178 C23.532,50.417,46.728,24.4146,77.1458,16.718z M19.748,90.3193h25.0159c-0.0142,0.7883-0.0745,1.5579-0.0745,2.3516 c0,28.5327,9.217,53.6572,23.1233,68.2603C39.7031,149.769,19.748,122.3567,19.748,90.3193z`}),(0,d.jsx)(`path`,{fill:`#1C71DA`,d:`M191.5137,184.4287l-19.665-19.665c4.9307-6.1609,7.8994-13.9573,7.8994-22.4443 c0-19.8516-16.1484-36-36-36s-36,16.1484-36,36s16.1484,36,36,36c8.4871,0,16.2834-2.9688,22.4443-7.8994l19.665,19.665 L191.5137,184.4287z M115.748,142.3193c0-15.4375,12.5625-28,28-28s28,12.5625,28,28s-12.5625,28-28,28 S115.748,157.7568,115.748,142.3193z`})]}),(0,d.jsx)(`path`,{fill:`#FF5D5D`,d:`M4,22.1416c-1.0234,0-2.0479-0.3906-2.8281-1.1719c-1.5625-1.5615-1.5625-4.0947,0-5.6562L15.3145,1.1719 c1.5625-1.5625,4.0957-1.5625,5.6562,0c1.5625,1.5615,1.5625,4.0947,0,5.6562L6.8281,20.9697 C6.0469,21.751,5.0234,22.1416,4,22.1416z`}),(0,d.jsx)(`path`,{fill:`#FF5D5D`,d:`M18.1426,22.1416c-1.0234,0-2.0469-0.3906-2.8281-1.1719L1.1719,6.8281 c-1.5625-1.5615-1.5625-4.0947,0-5.6562c1.5605-1.5625,4.0938-1.5625,5.6562,0l14.1426,14.1416 c1.5625,1.5615,1.5625,4.0947,0,5.6562C20.1904,21.751,19.166,22.1416,18.1426,22.1416z`}),(0,d.jsx)(`path`,{fill:`#00D40B`,d:`M14,198.1416c-7.7197,0-14-6.2803-14-14s6.2803-14,14-14s14,6.2803,14,14S21.7197,198.1416,14,198.1416z M14,178.1416c-3.3086,0-6,2.6914-6,6s2.6914,6,6,6s6-2.6914,6-6S17.3086,178.1416,14,178.1416z`}),(0,d.jsx)(`path`,{fill:`#FFC504`,d:`M199.3145,56.7695c-1.0605,0-2.0781-0.4219-2.8281-1.1719l-11.3145-11.3145 c-0.75-0.75-1.1719-1.7676-1.1719-2.8281s0.4219-2.0781,1.1719-2.8281l11.3145-11.3135c1.5625-1.5625,4.0938-1.5625,5.6562,0 l11.3135,11.3135c1.5625,1.5615,1.5625,4.0947,0,5.6562l-11.3135,11.3145C201.3926,56.3477,200.375,56.7695,199.3145,56.7695z M193.6572,41.4551l5.6572,5.6572l5.6572-5.6572l-5.6572-5.6572L193.6572,41.4551z`})]})}function N(e){return(0,d.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 508 508`,...e,children:[(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M316.1,353.2H191.9c13.2,60.9,37.8,102.2,62.1,102.2C278.3,455.4,302.9,414.1,316.1,353.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M78.2,353.2c26.2,46.5,69.8,80.1,120.6,94.5c-15.4-22.5-27.7-54.7-35.7-94.5H78.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.8,353.2h-84.9c-8,39.8-20.4,72-35.7,94.5C360,433.4,403.6,399.7,429.8,353.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.3,154.8c-26.3-46.4-69.6-80-120-94.4c15.3,22.4,27.7,54.7,35.6,94.4H429.3z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M163.1,154.8c8-39.7,20.3-71.9,35.7-94.4c-50.4,14.4-93.8,48-120,94.4H163.1z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M479.8,310.9V197.1c0-7.8-6.3-14.1-14.1-14.1H42.3c-7.8,0-14.1,6.3-14.1,14.1v113.8 c0,7.8,6.3,14.1,14.1,14.1h423.3C473.4,325,479.8,318.7,479.8,310.9z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M254,52.6c-24.3,0-48.9,41.3-62.1,102.2h124.2C302.9,93.9,278.3,52.6,254,52.6z`})]}),(0,d.jsx)(`path`,{style:{fill:`#56ACE0`},d:`M254,426.5c-95.3,0-172.9-77.5-172.9-172.9S158.7,80.8,254,80.8s172.9,77.5,172.9,172.9 S349.3,426.5,254,426.5z`}),(0,d.jsx)(`rect`,{x:`56.4`,y:`211.2`,style:{fill:`#FFC10D`},width:`395.1`,height:`85.6`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#194F82`},d:`M465.7,154.8H461C422.8,75.3,342.7,24.4,254,24.4S85.1,75.3,47,154.8h-4.7C19,154.8,0,173.7,0,197.1 v113.8c0,23.3,19,42.3,42.3,42.3h4.2c38,79.5,118.4,130.4,207.5,130.4c89.2,0,169.5-50.9,207.5-130.4h4.2c23.3,0,42.3-19,42.3-42.3 V197.1C508,173.7,489,154.8,465.7,154.8z M429.3,154.8h-84.4c-8-39.7-20.3-71.9-35.6-94.4C359.7,74.7,403,108.4,429.3,154.8z M254,52.6c24.3,0,48.9,41.3,62.1,102.2H191.9C205.1,93.9,229.7,52.6,254,52.6z M198.7,60.4c-15.3,22.4-27.7,54.7-35.7,94.4H78.7 C105,108.4,148.3,74.7,198.7,60.4z M78.2,353.2h84.9c8,39.8,20.4,72,35.7,94.5C148,433.4,104.4,399.7,78.2,353.2z M254,455.4 c-24.3,0-48.9-41.3-62.1-102.2h124.2C302.9,414.1,278.3,455.4,254,455.4z M309.2,447.7c15.4-22.5,27.7-54.7,35.7-94.5h84.9 C403.6,399.7,360,433.4,309.2,447.7z M479.8,310.9c0,7.8-6.3,14.1-14.1,14.1H42.3c-7.8,0-14.1-6.3-14.1-14.1V197.1 c0-7.8,6.3-14.1,14.1-14.1h423.3c7.8,0,14.1,6.3,14.1,14.1v113.8H479.8z`}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`146,265.7 109.1,215.3 93.4,215.3 93.4,293.6 110.2,293.6 110.2,244.5 146,293.6 162.7,293.6 162.7,215.3 146,215.3 `}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`197.9,261.9 231.6,261.9 231.6,247 197.9,247 197.9,230.9 235.3,230.9 235.3,215.3 181.2,215.3 181.2,293.6 236.5,293.6 236.5,278.1 197.9,278.1 `}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`318.9,260.3 305.7,215.3 288.1,215.3 274.8,260.3 260,215.3 241.9,215.3 268.1,293.6 280.5,293.6 296.8,239.2 313.3,293.6 325.7,293.6 351.9,215.3 333.8,215.3 `}),(0,d.jsx)(`path`,{style:{fill:`#194F82`},d:`M392,246.6c-8.2-1.9-16.5-3.8-16.6-10.2c0.5-5.4,3.9-7.5,9-7.6c6.9,0,13.7,2.6,20.2,7.7l8.5-12.8 c-8-6.2-17-10.4-28.1-10.3c-12.5-0.6-27,7.6-26.8,23.2c-1,15.4,10.4,21.4,25.2,24.8c9.2,2,14.5,5.1,13.9,9.8 c0.1,5.2-4.6,7.7-9.9,7.7c-6.9,0-14.3-3.7-22.4-11.1l-10,12.8c9.5,9.2,20.2,13.8,32.1,13.8c15.1,0.7,27.6-8.8,27.5-23.6 C414.8,257.3,406.3,250,392,246.6z`})]})]})}function P(e){return(0,d.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 512 512`,...e,children:[(0,d.jsx)(`circle`,{style:{fill:`#8AD5DD`},cx:`256`,cy:`256`,r:`256`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_0`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_1`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_2`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_3`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_4`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`path`,{id:`SVGCleanerId_5`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_0_1_`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_1_1_`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_2_1_`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_3_1_`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_4_1_`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`path`,{id:`SVGCleanerId_5_1_`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`})}),(0,d.jsx)(`polygon`,{style:{fill:`#FFFFFF`},points:`232.496,191.472 303,232.176 232.496,272.88 `}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#E0E0E0`},d:`M365.664,100.072v19.616h-135.24v-19.616H365.664 M367.624,98.112h-139.16v23.536h139.16 L367.624,98.112L367.624,98.112z`}),(0,d.jsx)(`rect`,{x:`341.312`,y:`98.112`,style:{fill:`#E0E0E0`},width:`26.312`,height:`23.536`})]}),(0,d.jsx)(`path`,{style:{fill:`#DB2B42`},d:`M207.656,121.648H173.2c-1.312,0-2.384-1.072-2.384-2.384v-18.768c0-1.312,1.072-2.384,2.384-2.384 h34.456c1.312,0,2.384,1.072,2.384,2.384v18.768C210.04,120.576,208.96,121.648,207.656,121.648z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M178.008,107.264h-2.784v-1.488h7.384v1.488h-2.816v8.28h-1.784L178.008,107.264L178.008,107.264z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M189.28,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M191.144,115.544c0.032-0.48,0.064-1.264,0.064-1.984v-8.312h1.784v4.2h0.032 c0.432-0.672,1.2-1.128,2.256-1.128c1.728,0,2.96,1.432,2.944,3.584c0,2.536-1.608,3.8-3.208,3.8c-0.912,0-1.728-0.352-2.232-1.216 h-0.032l-0.088,1.056H191.144z M192.992,112.632c0,0.152,0.016,0.288,0.04,0.424c0.192,0.712,0.808,1.256,1.584,1.256 c1.12,0,1.8-0.904,1.8-2.32c0-1.256-0.592-2.264-1.784-2.264c-0.72,0-1.376,0.528-1.584,1.304 c-0.024,0.128-0.056,0.288-0.056,0.464V112.632z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M200.952,112.512c0.04,1.28,1.04,1.832,2.176,1.832c0.824,0,1.416-0.12,1.96-0.32l0.264,1.232 c-0.616,0.248-1.456,0.44-2.472,0.44c-2.288,0-3.64-1.408-3.64-3.576c0-1.952,1.192-3.8,3.448-3.8c2.296,0,3.048,1.888,3.048,3.44 c0,0.336-0.032,0.592-0.056,0.752C205.68,112.512,200.952,112.512,200.952,112.512z M204.056,111.264 c0.016-0.648-0.272-1.728-1.464-1.728c-1.104,0-1.568,1.008-1.64,1.728H204.056z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M147.464,115.544v-4.072l-3.088-5.696h2.032l1.176,2.504c0.336,0.728,0.584,1.28,0.848,1.944h0.024 c0.248-0.624,0.52-1.232,0.856-1.944l1.176-2.504h2.016l-3.248,5.656v4.112H147.464z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M158.864,111.944c0,2.6-1.824,3.76-3.624,3.76c-2,0-3.536-1.376-3.536-3.632 c0-2.328,1.52-3.744,3.656-3.744C157.464,108.32,158.864,109.8,158.864,111.944z M153.544,112.024c0,1.36,0.664,2.392,1.752,2.392 c1.016,0,1.728-1,1.728-2.424c0-1.104-0.496-2.368-1.712-2.368C154.056,109.624,153.544,110.84,153.544,112.024z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M166.656,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M353.936,113.776c-3.096,0-5.616-2.52-5.616-5.616s2.52-5.616,5.616-5.616s5.616,2.52,5.616,5.616 C359.552,111.256,357.032,113.776,353.936,113.776z M353.936,103.816c-2.392,0-4.344,1.952-4.344,4.344s1.952,4.344,4.344,4.344 s4.344-1.952,4.344-4.344S356.328,103.816,353.936,103.816z`}),(0,d.jsx)(`rect`,{x:`356.02`,y:`113.813`,transform:`matrix(-0.6044 -0.7967 0.7967 -0.6044 484.7665 469.5985)`,style:{fill:`#2D2D2D`},width:`5.896`,height:`1.272`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M240.088,113.168c0.48,0.296,1.184,0.544,1.92,0.544c1.096,0,1.736-0.576,1.736-1.416 c0-0.768-0.44-1.216-1.56-1.648c-1.352-0.48-2.192-1.184-2.192-2.352c0-1.296,1.072-2.248,2.68-2.248 c0.848,0,1.464,0.192,1.832,0.4l-0.296,0.872c-0.272-0.152-0.824-0.392-1.576-0.392c-1.136,0-1.56,0.672-1.56,1.24 c0,0.776,0.504,1.152,1.648,1.6c1.4,0.544,2.12,1.216,2.12,2.432c0,1.28-0.952,2.392-2.904,2.392c-0.8,0-1.68-0.24-2.12-0.528 L240.088,113.168z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M246.984,111.688c0.024,1.472,0.96,2.064,2.048,2.064c0.776,0,1.24-0.128,1.648-0.304l0.184,0.776 c-0.384,0.176-1.032,0.368-1.984,0.368c-1.832,0-2.928-1.208-2.928-3s1.056-3.216,2.792-3.216c1.952,0,2.464,1.704,2.464,2.808 c0,0.216-0.024,0.392-0.04,0.496h-4.184V111.688z M250.16,110.92c0.016-0.688-0.288-1.76-1.504-1.76 c-1.096,0-1.576,1.008-1.664,1.76H250.16z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M255.88,114.472l-0.088-0.752h-0.032c-0.336,0.472-0.968,0.888-1.824,0.888 c-1.208,0-1.824-0.848-1.824-1.704c0-1.448,1.28-2.232,3.584-2.216v-0.128c0-0.488-0.136-1.384-1.36-1.384 c-0.552,0-1.128,0.176-1.552,0.448l-0.248-0.72c0.488-0.312,1.208-0.528,1.96-0.528c1.824,0,2.264,1.24,2.264,2.432v2.232 c0,0.52,0.024,1.024,0.104,1.424h-0.984V114.472z M255.72,111.44c-1.184-0.024-2.528,0.184-2.528,1.336 c0,0.704,0.472,1.032,1.024,1.032c0.776,0,1.272-0.488,1.44-1c0.04-0.112,0.064-0.24,0.064-0.344V111.44z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M258.552,110.376c0-0.704-0.016-1.304-0.056-1.864h0.944l0.04,1.176h0.04 c0.272-0.8,0.928-1.304,1.656-1.304c0.12,0,0.2,0.008,0.304,0.032v1.024c-0.112-0.024-0.224-0.032-0.368-0.032 c-0.768,0-1.312,0.576-1.456,1.392c-0.024,0.144-0.056,0.312-0.056,0.496v3.176h-1.072v-4.096H258.552z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M266.72,114.256c-0.288,0.152-0.912,0.344-1.72,0.344c-1.792,0-2.968-1.216-2.968-3.04 c0-1.84,1.264-3.168,3.208-3.168c0.64,0,1.208,0.168,1.504,0.304l-0.248,0.84c-0.264-0.152-0.664-0.28-1.264-0.28 c-1.368,0-2.104,1.008-2.104,2.248c0,1.384,0.888,2.232,2.064,2.232c0.616,0,1.024-0.168,1.328-0.296L266.72,114.256z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M268.016,105.736h1.08v3.712h0.024c0.176-0.304,0.448-0.576,0.776-0.76 c0.312-0.184,0.704-0.304,1.104-0.304c0.808,0,2.08,0.488,2.08,2.544v3.544H272v-3.424c0-0.96-0.352-1.768-1.376-1.768 c-0.704,0-1.264,0.488-1.456,1.08c-0.064,0.152-0.08,0.304-0.08,0.52v3.6h-1.08v-8.744H268.016z`})]})]})}function F(e){return(0,d.jsx)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 73 73`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,...e,children:(0,d.jsx)(`g`,{id:`fundamentals/css/images`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,d.jsxs)(`g`,{id:`container`,transform:`translate(2.000000, 2.000000)`,fillRule:`nonzero`,children:[(0,d.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,fill:`#424A60`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`}),(0,d.jsx)(`circle`,{id:`Oval`,fill:`#EFCE4A`,cx:`21.069`,cy:`23.069`,r:`9.069`}),(0,d.jsx)(`polygon`,{id:`Shape`,fill:`#1A9172`,points:`69.5 56.7492553 68.1170213 55.212766 51.5212766 40 37 55.9042553 44.5828723 63.4871277 50.1382979 69.0425532 60.7455406 69.0425532 69.5 60.1780353`}),(0,d.jsx)(`polygon`,{id:`Shape`,fill:`#25AE88`,points:`47.8532188 64.0501875 33.8030313 50 12 69.1969687 53 69.1969687`}),(0,d.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`})]})})})}function I(e){return(0,d.jsxs)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 32 32`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,d.jsx)(`path`,{d:`M23.3 8.40007L21.82 6.40008C21.7248 6.27314 21.6008 6.17066 21.4583 6.10111C21.3157 6.03156 21.1586 5.99693 21 6.00008H11.2C11.0555 6.00007 10.9128 6.03135 10.7816 6.09177C10.6504 6.15219 10.5339 6.24031 10.44 6.35007L8.71998 8.35008C8.57227 8.53401 8.49435 8.76424 8.49998 9.00008V16.2901C8.50262 18.0317 9.19567 19.7013 10.4272 20.9328C11.6588 22.1644 13.3283 22.8574 15.07 22.8601H16.93C18.6716 22.8574 20.3412 22.1644 21.5728 20.9328C22.8043 19.7013 23.4973 18.0317 23.5 16.2901V9.00008C23.5 8.7837 23.4298 8.57317 23.3 8.40007Z`,fill:`#FFCC80`}),(0,d.jsx)(`path`,{d:`M29.78 28.38L25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38Z`,fill:`#01579B`}),(0,d.jsx)(`path`,{d:`M29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003L15.73 11.6C15.906 11.6534 16.094 11.6534 16.27 11.6L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003Z`,fill:`#01579B`}),(0,d.jsx)(`path`,{d:`M11.22 6C11.0756 5.99999 10.9328 6.03127 10.8016 6.09169C10.6704 6.15211 10.5539 6.24023 10.46 6.35L8.74 8.35C8.58509 8.53114 8.49998 8.76166 8.5 9V16.29C8.50264 18.0317 9.19569 19.7012 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16V6H11.22Z`,fill:`#FFE0B2`}),(0,d.jsx)(`path`,{d:`M7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H16V25L7.21999 23Z`,fill:`#0277BD`}),(0,d.jsx)(`path`,{d:`M15.71 2.00002L2.71 6.00002C2.49742 6.06422 2.31226 6.19734 2.1837 6.3784C2.05515 6.55947 1.99052 6.77817 2 7.00002C1.9917 7.22447 2.0592 7.44518 2.19163 7.62658C2.32405 7.80799 2.5137 7.93954 2.73 8.00002L15.73 11.6C15.8194 11.6146 15.9106 11.6146 16 11.6V2.00002C15.9039 1.98469 15.8061 1.98469 15.71 2.00002Z`,fill:`#0277BD`}),(0,d.jsx)(`path`,{d:`M2.73 8.00003L8.5 9.56003V16.29C8.50264 18.0317 9.19569 19.7013 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16.93C18.6717 22.8574 20.3412 22.1643 21.5728 20.9328C22.8043 19.7013 23.4974 18.0317 23.5 16.29V9.56003L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003ZM21.5 16.29C21.4974 17.5013 21.015 18.6621 20.1586 19.5186C19.3021 20.3751 18.1412 20.8574 16.93 20.86H15.07C13.8588 20.8574 12.6979 20.3751 11.8414 19.5186C10.985 18.6621 10.5026 17.5013 10.5 16.29V10.11L15.73 11.56C15.906 11.6134 16.094 11.6134 16.27 11.56L21.5 10.11V16.29ZM16 4.05003L25.44 7.00003L16 9.56003L6.56 7.00003L16 4.05003Z`,fill:`#263238`}),(0,d.jsx)(`path`,{d:`M25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38L25.78 23.38ZM5.07999 28L7.38999 25.11L15.78 27C15.9251 27.0299 16.0748 27.0299 16.22 27L24.61 25.13L26.92 28H5.07999Z`,fill:`#263238`})]})}function L(e){return(0,d.jsxs)(`svg`,{height:`800px`,width:`800px`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 503.322 503.322`,...e,children:[(0,d.jsx)(`path`,{style:{fill:`#FBC176`},d:`M0,73.763v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627c6.942,0,13.017-6.075,13.017-13.017 V73.763c0-6.942-6.075-13.017-13.017-13.017H13.017C6.075,60.746,0,66.82,0,73.763`}),(0,d.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M225.627,60.746V39.051c0-6.942-6.075-13.017-13.017-13.017h-69.424L121.492,0H30.373 c-6.942,0-13.017,6.075-13.017,13.017v47.729H225.627z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,104.136H34.712c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678C95.458,100.664,91.986,104.136,86.78,104.136`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,138.847H34.712c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678S91.986,138.847,86.78,138.847`})]}),(0,d.jsx)(`path`,{style:{fill:`#FBC176`},d:`M251.661,360.136v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627 c6.942,0,13.017-6.075,13.017-13.017V360.136c0-6.942-6.075-13.017-13.017-13.017H264.678 C257.736,347.119,251.661,353.193,251.661,360.136`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,390.508h-52.068c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678S343.647,390.508,338.441,390.508`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,425.22h-52.068c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678C347.119,421.749,343.647,425.22,338.441,425.22`})]}),(0,d.jsx)(`path`,{style:{fill:`#F38774`},d:`M208.271,451.254H78.102c-5.207,0-8.678-3.471-8.678-8.678V260.339c0-5.207,3.471-8.678,8.678-8.678 c5.207,0,8.678,3.471,8.678,8.678v173.559h121.492c5.207,0,8.678,3.471,8.678,8.678 C216.949,447.783,213.478,451.254,208.271,451.254`}),(0,d.jsx)(`path`,{style:{fill:`#26B999`},d:`M433.898,277.695c-5.207,0-8.678-3.471-8.678-8.678V95.458H295.051c-5.207,0-8.678-3.471-8.678-8.678 c0-5.207,3.471-8.678,8.678-8.678h138.847c5.207,0,8.678,3.471,8.678,8.678v182.237 C442.576,274.224,439.105,277.695,433.898,277.695`}),(0,d.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M477.288,347.119v-21.695c0-6.942-6.075-13.017-13.017-13.017h-69.424l-21.695-26.034h-91.119 c-6.942,0-13.017,6.075-13.017,13.017v47.729H477.288z`})]})}function R(e){return(0,d.jsxs)(`svg`,{height:`800px`,width:`800px`,viewBox:`0 0 128 128`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,className:`iconify iconify--noto`,preserveAspectRatio:`xMidYMid meet`,...e,children:[(0,d.jsx)(`path`,{d:`M106 24.79H22.15c-1.92 0-3.48 1.56-3.48 3.48v57.59c0 1.92 1.56 3.48 3.48 3.48H106c1.92 0 3.48-1.56 3.48-3.48V28.27c0-1.92-1.55-3.48-3.48-3.48z`,fill:`#b7d5e5`}),(0,d.jsxs)(`radialGradient`,{id:`IconifyId17ecdb2904d178eab9910`,cx:`48.408`,cy:`13.024`,r:`75.465`,gradientTransform:`matrix(1 0 0 1.0843 0 -10.19)`,gradientUnits:`userSpaceOnUse`,children:[(0,d.jsx)(`stop`,{offset:`0`,stopColor:`#2f7889`}),(0,d.jsx)(`stop`,{offset:`1`,stopColor:`#424242`})]}),(0,d.jsx)(`path`,{fill:`url(#IconifyId17ecdb2904d178eab9910)`,d:`M104.75 83.2H23.4l.96-52.27h79.43z`}),(0,d.jsx)(`path`,{d:`M121.09 123.82H7.59c-.43 0-.83-.03-1.2-.09c-2.88-.44-4.21-4.18-2.5-6.74l.39-.59h119.59l.4.6c1.86 2.78.12 6.76-3.04 6.81c-.04.01-.09.01-.14.01z`,fill:`#2f7889`}),(0,d.jsx)(`path`,{d:`M106.84 90.41H20.6c-1.27 0-2.54.77-3.25 1.99l-14 25.48c-.59.88-.01 2.12.99 2.12H123.8c1 0 1.58-1.24.99-2.12l-14.71-25.63c-.7-1.08-1.97-1.84-3.24-1.84z`,fill:`#eee`}),(0,d.jsx)(`path`,{fill:`#b7d5e5`,d:`M86.36 115.52H41.8l2.85-7.98h39.07z`}),(0,d.jsxs)(`g`,{opacity:`0.57`,fill:`#69a1ba`,children:[(0,d.jsx)(`path`,{d:`M72.69 94.84l-.27-2.2h-3.44l.13 2.2z`}),(0,d.jsx)(`path`,{d:`M67.14 94.84l-.14-2.2h-3.45v2.2z`}),(0,d.jsx)(`path`,{d:`M93.61 94.84l-.81-2.2h-3.26l.68 2.2z`}),(0,d.jsx)(`path`,{d:`M88.36 94.84l-.68-2.2h-3.32l.54 2.2z`}),(0,d.jsx)(`path`,{d:`M83.18 94.84l-.54-2.2h-3.37l.41 2.2z`}),(0,d.jsx)(`path`,{d:`M102.11 94.84l-.95-2.2h-6.71l.82 2.2z`}),(0,d.jsx)(`path`,{d:`M77.61 94.84l-.41-2.2h-3.41l.28 2.2z`}),(0,d.jsx)(`path`,{d:`M33.76 94.84l.68-2.2h-3.26l-.81 2.2z`}),(0,d.jsx)(`path`,{d:`M50.51 94.84l.27-2.2h-3.41l-.4 2.2z`}),(0,d.jsx)(`path`,{d:`M39.35 94.84l.54-2.2h-3.32l-.67 2.2z`}),(0,d.jsx)(`path`,{d:`M28.17 94.84l.81-2.2H25.8l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M44.93 94.84l.41-2.2h-3.37l-.54 2.2z`}),(0,d.jsx)(`path`,{d:`M56.08 94.84l.14-2.2h-3.44l-.27 2.2z`}),(0,d.jsx)(`path`,{d:`M61.65 94.84v-2.2H58.2l-.14 2.2z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M83.78 103.73H44.36l-.75 2.2h41.08z`}),(0,d.jsx)(`path`,{d:`M102.15 105.93l-1.21-2.2h6.54l.95 2.2z`}),(0,d.jsx)(`path`,{d:`M86.75 105.93l-.83-2.2h6.29l.96 2.2z`}),(0,d.jsx)(`path`,{d:`M95.39 105.93l-.96-2.2h4.31l1.1 2.2z`}),(0,d.jsx)(`path`,{d:`M25.67 105.93l1.21-2.2h-6.54l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M41.07 105.93l.83-2.2h-6.29l-.96 2.2z`}),(0,d.jsx)(`path`,{d:`M32.42 105.93l.97-2.2h-4.31l-1.11 2.2z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M29.71 98.51l.82-2.19h-6.67l-.95 2.19z`}),(0,d.jsx)(`path`,{d:`M97.95 98.51l-.81-2.19h6.66l.95 2.19z`}),(0,d.jsx)(`path`,{d:`M96.25 98.51l-.96-2.19h-3.85l.82 2.19z`}),(0,d.jsx)(`path`,{d:`M86.23 98.51l-.65-2.19h3.85l.78 2.19z`}),(0,d.jsx)(`path`,{d:`M80.19 98.51l-.47-2.19h3.85l.6 2.19z`}),(0,d.jsx)(`path`,{d:`M74.15 98.51l-.28-2.19h3.84l.43 2.19z`}),(0,d.jsx)(`path`,{d:`M68.12 98.51l-.11-2.19h3.85l.24 2.19z`}),(0,d.jsx)(`path`,{d:`M62.08 98.51l.07-2.19H66l.06 2.19z`}),(0,d.jsx)(`path`,{d:`M56.04 98.51l.25-2.19h3.85l-.11 2.19z`}),(0,d.jsx)(`path`,{d:`M50.01 98.51l.42-2.19h3.85l-.29 2.19z`}),(0,d.jsx)(`path`,{d:`M43.97 98.51l.6-2.19h3.85l-.47 2.19z`}),(0,d.jsx)(`path`,{d:`M37.93 98.51l.78-2.19h3.85l-.64 2.19z`}),(0,d.jsx)(`path`,{d:`M31.9 98.51l.95-2.19h3.85l-.82 2.19z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M29.7 102.22l.81-2.2h-8.75l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M95.87 102.22l-.77-2.2h-4.17l.64 2.2z`}),(0,d.jsx)(`path`,{d:`M84.93 102.22l-.48-2.2h4.16l.62 2.2z`}),(0,d.jsx)(`path`,{d:`M78.28 102.22l-.32-2.2h4.17l.45 2.2z`}),(0,d.jsx)(`path`,{d:`M71.64 102.22l-.17-2.2h4.17l.3 2.2z`}),(0,d.jsx)(`path`,{d:`M65 102.22l-.01-2.2h4.16l.15 2.2z`}),(0,d.jsx)(`path`,{d:`M58.36 102.22l.14-2.2h4.17l-.01 2.2z`}),(0,d.jsx)(`path`,{d:`M51.71 102.22l.3-2.2h4.17l-.17 2.2z`}),(0,d.jsx)(`path`,{d:`M45.07 102.22l.46-2.2h4.16l-.32 2.2z`}),(0,d.jsx)(`path`,{d:`M38.43 102.22l.61-2.2h4.17l-.48 2.2z`}),(0,d.jsx)(`path`,{d:`M31.78 102.22l.77-2.2h4.17l-.63 2.2z`}),(0,d.jsx)(`path`,{d:`M97.47 102.22l-.82-2.2h8.75l.95 2.2z`})]})]}),(0,d.jsx)(`path`,{d:`M124.73 117.88L110.39 92.4c-.71-1.07-1.98-1.84-3.25-1.84c0 0 1.22 1.1 1.59 1.63l12.59 23.59c.56 1.02-.18 2.26-1.34 2.26H7.96c-1.15 0-1.89-1.23-1.35-2.24l11.95-23.18c.35-.6 1.88-1.99 1.88-1.99h-.45c-1.27 0-2.54.77-3.25 1.99L3.28 117.88c-.59.88-.01 2.12.99 2.12h119.46c1.01 0 1.59-1.24 1-2.12z`,fill:`#b7d5e5`}),(0,d.jsx)(`path`,{fill:`none`,stroke:`#eee`,strokeWidth:`2.936`,strokeLinecap:`round`,strokeMiterlimit:`10`,d:`M25.97 28.02h13.21`}),(0,d.jsx)(`path`,{d:`M109.37 30.11c0-1.04-1.01-1.12-1.01.11v55.8c0 1.34-1.09 2.43-2.43 2.43H22.08c-1.34 0-2.43-1.09-2.43-2.43v-55.8c0-1.23-1.01-1.15-1.01-.11l-.95 55.91c0 2.42 1.24 4.39 4.39 4.39h83.85c2.73 0 4.39-1.97 4.39-4.39l-.95-55.91z`,fill:`#75a7bc`})]})}var z=[{code:`general`,icon:M,name:`Web`},{code:`news`,icon:N,name:`News`},{code:`videos`,icon:P,name:`Videos`},{code:`images`,icon:F,name:`Images`},{code:`science`,icon:I,name:`Academic`},{code:`files`,icon:L,name:`Files`},{code:`it`,icon:R,name:`Tech`}],ee=z.filter(e=>[`general`,`news`,`videos`,`images`,`science`,`files`].includes(e.code)),B=({sources:e,query:t})=>{let[r,i]=(0,n.useState)(`general`),[a,o]=(0,n.useState)(e),[u,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(1),[_,v]=(0,n.useState)(!0),[y,b]=(0,n.useState)(!1),x=(0,n.useRef)(null),S=(0,n.useRef)(!1),C=(0,n.useRef)(!1),{openPanel:w,isOpen:T}=A(),[D,k]=(0,n.useState)({});(0,n.useEffect)(()=>{let e=()=>{b(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{o(e),i(`general`),g(1),v(!0),k({}),j(e)},[e]);let j=(0,n.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 t=await(await fetch(`/api/doc/article?url=${encodeURIComponent(e.metadata.url)}`)).json();t.cached&&t.article?.html&&k(t=>({...t,[e.metadata.url]:`loaded`}))}catch{}},[]);(0,n.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search).get(`extract`);e&&(w(decodeURIComponent(e),``),C.current=!1)}},[w]),(0,n.useEffect)(()=>{C.current=!1},[e]),(0,n.useEffect)(()=>{S.current&&!T&&(C.current=!0),S.current=T},[T]),(0,n.useEffect)(()=>{if(y&&a&&a.length>0&&!T&&!C.current){let e=a[0];e?.metadata?.url&&w(e.metadata.url,``)}},[a,y]);let M=async(e,t)=>{e.preventDefault(),C.current=!1,k(e=>({...e,[t]:`loading`})),w(t,``);try{await(0,c.getArticle)({query:{url:t}}),k(e=>({...e,[t]:`loaded`}))}catch{k(e=>({...e,[t]:`loaded`}))}},N=(0,n.useCallback)(async()=>{if(!t||p||!_)return;m(!0);let e=h+1,{data:n}=await(0,c.agentSearch)({query:{q:t,cat:r,page:e}}),i=n?.results??[];if(i.length===0){v(!1),m(!1);return}let a=i.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{pageContent:e.snippet||e.content||``,metadata:{title:e.title||``,source:e.source||``,thumbnail:e.thumbnail||``,url:e.url||``,...e.thumbnail&&{thumbnail:e.thumbnail}}}});o(e=>[...e,...a]),g(e),m(!1)},[t,r,h,p,_]),P=async e=>{if(!(e===r||!t)){i(e),f(!0),g(1),v(!0);try{let{data:n}=await(0,c.agentSearch)({query:{q:t,cat:e,page:1}}),r=(n?.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{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.thumbnail&&{thumbnail:e.thumbnail},...e.iframe_src&&{iframe_src:e.iframe_src}}}});o(r)}catch(e){console.error(`Error searching:`,e)}finally{f(!1)}}};(0,n.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<100&&N()};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[N]);let F=(e,t)=>{let n=r===`images`,i=r===`videos`,a=e.metadata.img_src||e.metadata.thumbnail;if(n&&a)return(0,d.jsx)(`div`,{className:`relative rounded-lg group`,children:(0,d.jsxs)(`a`,{className:`relative block overflow-hidden rounded-lg cursor-pointer`,href:e.metadata.url,onClick:t=>M(t,e.metadata.url),children:[(0,d.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,d.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,d.jsx)(`p`,{className:`text-xs text-white line-clamp-2`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)}),(0,d.jsx)(`p`,{className:`text-[10px] text-white/70 truncate mt-0.5`,children:e.metadata.source})]})]})},t);if(i&&a)return(0,d.jsxs)(`div`,{className:`relative rounded-xl`,children:[(0,d.jsx)(O,{spread:40,glow:!0,disabled:!1,proximity:64,inactiveZone:.01,borderWidth:2}),(0,d.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:e.metadata.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-24 object-cover`}),(0,d.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,d.jsx)(`div`,{className:`w-10 h-10 bg-black/60 rounded-full flex items-center justify-center`,children:(0,d.jsx)(s.Video,{size:18,className:`text-white ml-0.5`})})})]}),(0,d.jsx)(`p`,{className:`text-xs line-clamp-2 p-2 text-muted-foreground`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]},t);let o=D[e.metadata.url];return(0,d.jsxs)(`div`,{className:`relative rounded-xl group h-full`,children:[(0,d.jsx)(O,{spread:40,glow:!0,disabled:!1,proximity:64,inactiveZone:.01,borderWidth:2}),(0,d.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=>M(t,e.metadata.url),children:[o&&(0,d.jsx)(`div`,{className:`absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]`,children:o===`loading`?(0,d.jsx)(s.Loader2,{size:14,className:`text-primary animate-spin`}):(0,d.jsx)(s.FileText,{size:14,className:`text-green-500`})}),(0,d.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,d.jsx)(s.ExternalLink,{size:12,className:`text-muted-foreground`})}),(0,d.jsxs)(`p`,{className:`text-xs line-clamp-4 text-muted-foreground`,children:[(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle`,children:[e.metadata.url===`File`?(0,d.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0`,children:(0,d.jsx)(s.File,{size:10,className:`text-muted-foreground`})}):(0,d.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,d.jsx)(`span`,{className:`align-middle`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]})]},t)};return(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex items-center gap-1 mb-3 overflow-x-auto pb-1`,children:ee.map(e=>(0,d.jsxs)(`button`,{onClick:()=>P(e.code),disabled:u,className:E(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap`,r===e.code?`bg-primary text-primary-foreground`:`bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground`),children:[(0,d.jsx)(e.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:e.name})]},e.code))}),(0,d.jsx)(`div`,{ref:x,className:E(`overflow-y-auto pb-2 pr-1`,r===`images`?`max-h-[400px] lg:max-h-[500px]`:`max-h-[180px] lg:max-h-[280px]`),children:u?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(s.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`})}):a.length>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:E(r===`images`?`columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid`:E(`grid gap-3 auto-rows-fr`,T&&y?`grid-cols-2`:`grid-cols-3`)),children:a.map((e,t)=>F(e,t))}),p&&(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,d.jsx)(s.Loader2,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!_&&a.length>0&&(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4 text-muted-foreground text-xs`,children:`No more results`})]}):(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`No results found`})})]})},te={extract:`Extract`,arxiv:`ArXiv`,"google scholar":`Scholar`,pubmed:`PubMed`,wolframalpha:`Wolfram`,youtube:`YouTube`,Web:`Web`};function V(e){return e?te[e]??e:`Web`}function H({queries:e,loading:t}){let n=e.filter(e=>e.status===`done`).length,r=e.length,i=t&&e.some(e=>e.status===`running`);return t?(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/50`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[i?(0,d.jsx)(s.Loader2,{className:`w-3.5 h-3.5 animate-spin`}):(0,d.jsx)(s.Search,{className:`w-3.5 h-3.5`}),(0,d.jsx)(`span`,{className:`font-medium text-foreground`,children:i?`Running analysis…`:`Analysis complete`})]}),r>0&&(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n,`/`,r,` searches`]})]}),e.length>0&&(0,d.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map((e,t)=>(0,d.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2`,children:[e.status===`running`?(0,d.jsx)(s.Loader2,{className:`w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0`}):(0,d.jsx)(s.Search,{className:E(`w-3.5 h-3.5 flex-shrink-0`,e.status===`done`?`text-muted-foreground`:`text-muted-foreground/40`)}),(0,d.jsxs)(`div`,{className:`flex items-baseline gap-1.5 min-w-0 flex-1`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap flex-shrink-0`,children:[V(e.category),` ·`]}),(0,d.jsx)(`span`,{className:`text-foreground/80 truncate`,children:e.query})]})]},t))})]}):null}function ne(e,t){let[r,i]=(0,n.useState)(`stopped`),a=(0,n.useRef)(null),o=(0,n.useRef)(null),s=(0,n.useRef)(null),c=(0,n.useRef)(t);c.current=t;let l=(0,n.useCallback)(()=>{a.current&&=(a.current.pause(),a.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(a.current.src),null),s.current?.abort(),s.current=null},[]),u=(0,n.useCallback)(()=>{if(!(`speechSynthesis`in window))return!1;try{window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);return o.current=t,t.onend=()=>{o.current=null,i(`stopped`)},t.onerror=()=>{o.current=null,i(`stopped`)},window.speechSynthesis.speak(t),i(`started`),!0}catch{return!1}},[e]);return{speechStatus:r,start:(0,n.useCallback)(async()=>{if(!e?.trim())return;l(),window.speechSynthesis?.cancel(),o.current=null,i(`started`);let t=new AbortController;s.current=t;try{let n=await(0,f.default)(`/api/agent/tts`,{method:`POST`,body:{text:e.slice(0,5e3),speaker:localStorage.getItem(`ttsSpeaker`)||`angus`},signal:t.signal}),r=typeof n.blob==`function`?await n.blob():n;if(!r||r.size===0){u()||i(`stopped`);return}let o=URL.createObjectURL(r),s=new Audio(o);a.current=s,s.onended=()=>{i(`stopped`),URL.revokeObjectURL(o),a.current=null},s.onerror=()=>{URL.revokeObjectURL(o),a.current=null,u()||i(`stopped`)},await s.play()}catch{u()||i(`stopped`)}},[e,l,u]),stop:(0,n.useCallback)(()=>{l(),o.current=null,window.speechSynthesis?.cancel(),i(`stopped`)},[l])}}var U=async(e,t,n)=>{let r=localStorage.getItem(`chatModelKey`),i=localStorage.getItem(`chatModelProviderId`),a=(await(0,f.default)(`/api/agent/providers`))?.providers||[];if(!a||a.length===0){t(!0);return}let o=a.find(e=>e.id===i&&(e.chatModels?.length??0)>0);if(o||=a.find(e=>e.name.toLowerCase().includes(`openrouter`)&&(e.chatModels?.length??0)>0)||a.find(e=>e.name.toLowerCase().includes(`nvidia`)&&(e.chatModels?.length??0)>0)||a.find(e=>(e.chatModels?.length??0)>0),!o){t(!0);return}i=o.id;let s=o.chatModels.find(e=>e.key===r);if(s||(o.name.toLowerCase().includes(`openrouter`)&&(s=o.chatModels.find(e=>e.key===`openrouter/free`)),!s&&o.name.toLowerCase().includes(`openrouter`)&&(s=o.chatModels.find(e=>e.key===`nvidia/nemotron-3-super-120b-a12b:free`)),s||=o.chatModels.find(e=>(e.key.toLowerCase().includes(`nemotron-3-super`)||e.name.toLowerCase().includes(`nemotron 3 super`))&&e.key.toLowerCase().includes(`120b`)),s||=o.chatModels.find(e=>e.key.toLowerCase().includes(`nemotron`)||e.name.toLowerCase().includes(`nemotron`)),s||=o.chatModels[0]),!s){t(!0);return}r=s.key,localStorage.setItem(`chatModelKey`,r),localStorage.setItem(`chatModelProviderId`,i),e({key:r,providerId:i}),t(!0)},W=`qwksearch_guest_chats`,G=typeof window<`u`;function K(){if(!G)return[];try{let e=localStorage.getItem(W);return e?JSON.parse(e).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()):[]}catch(e){return console.error(`Failed to get guest chats:`,e),[]}}function re(e){return G&&K().find(t=>t.id===e)||null}function ie(e){if(G)try{let t=K(),n=t.findIndex(t=>t.id===e.id);n>=0?t[n]=e:t.push(e),localStorage.setItem(W,JSON.stringify(t))}catch(e){console.error(`Failed to save guest chat:`,e)}}function ae(e){if(G)try{let t=K().filter(t=>t.id!==e);localStorage.setItem(W,JSON.stringify(t))}catch(e){console.error(`Failed to delete guest chat:`,e)}}function oe(){if(G)try{localStorage.removeItem(W)}catch(e){console.error(`Failed to clear guest chats:`,e)}}var se=async(e,t,n,r,i,a,o,s,c)=>{if(!t){let t=re(e);if(t){n(t.messages);let e=t.messages.filter(e=>e.role===`user`||e.role===`assistant`),o=e.map(e=>[e.role,e.content]);e.length>0&&(document.title=e[0].content),s(t.files||[]),c((t.files||[]).map(e=>e.fileId)),i(o),a(t.focusMode),r(!0);return}try{let t=await fetch(`/api/agent/chats/${e}`,{headers:{"Content-Type":`application/json`}});if(!t.ok){if(t.status===404||t.status===403){o(!0),r(!0);return}throw Error(`HTTP ${t.status}: ${t.statusText}`)}let{messages:l,chat:u}=await t.json();if(!l||!u){o(!0),r(!0);return}n(l);let d=l.filter(e=>e.role===`user`||e.role===`assistant`),f=d.map(e=>[e.role,e.content]);d.length>0&&(document.title=d[0].content);let p=u.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(p),c(p.map(e=>e.fileId)),i(f),a(u.focusMode),r(!0);return}catch(e){console.error(`[chatMessages] Failed to load public chat:`,e),o(!0),r(!0);return}}try{let t=await fetch(`/api/agent/chats/${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`}});if(!t.ok){if(t.status===404||t.status===401||t.status===403){o(!0),r(!0);return}throw Error(`HTTP ${t.status}: ${t.statusText}`)}let{messages:l,chat:u}=await t.json();if(!l||!u){o(!0),r(!0);return}n(l);let d=l.filter(e=>e.role===`user`||e.role===`assistant`),f=d.map(e=>[e.role,e.content]);console.debug(new Date,`app:messages_loaded`),d.length>0&&(document.title=d[0].content);let p=u.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(p),c(p.map(e=>e.fileId)),i(f),a(u.focusMode),r(!0)}catch(e){console.error(`[chatMessages] Failed to load chat:`,e),o(!0),r(!0)}},ce=e=>{let t=[];return e.forEach((n,r)=>{if(n.role===`user`){let i=e.findIndex((e,t)=>t>r&&e.role===`user`),a=e.find((e,t)=>t>r&&e.role===`assistant`&&(i===-1||t<i)),o=e.find((e,t)=>t>r&&e.role===`source`&&e.sources&&(i===-1||t<i)),s=e.find((e,t)=>t>r&&e.role===`searching`&&(i===-1||t<i)),c=!1,l=a?.content??``,u=a?.content??``,d=[];if(a){let t=/\[([^\]]+)\]/g,n=/\[(\d+)\]/g;if(l.includes(`<think>`)){let e=l.match(/<think>/g)?.length||0,t=l.match(/<\/think>/g)?.length||0;e&&!t&&(l+=`</think> <a> </a>`)}a.content.includes(`</think>`)&&(c=!0),o&&o.sources&&o.sources.length>0?(l=l.replace(t,(e,t)=>t.split(`,`).map(e=>e.trim()).map(e=>{let t=parseInt(e);if(isNaN(t)||t<=0)return`[${e}]`;let n=(o.sources?.[t-1])?.metadata?.url;return n?`<citation href="${n}">${e}</citation>`:``}).join(``)),u=a.content.replace(n,``)):(l=l.replace(n,``),u=a.content.replace(n,``));let s=e.find((e,t)=>t>r&&e.role===`suggestion`&&(i===-1||t<i));s&&s.suggestions.length>0&&(d=s.suggestions)}t.push({userMessage:n,assistantMessage:a,sourceMessage:o,searchingMessage:s,parsedAssistantMessage:l,speechMessage:u,thinkingEnded:c,suggestions:d})}}),t},le=async e=>{let t=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`),r=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),i=e.filter(e=>e.role===`user`||e.role===`assistant`);try{let e=await(0,f.default)(`agent/suggestions`,{method:`POST`,body:JSON.stringify({chatHistory:i,chatModel:{providerId:n,key:t},maxQuestions:r})});return Array.isArray(e.suggestions)?e.suggestions:[]}catch{return[]}},ue=3,q=()=>Array.from(crypto.getRandomValues(new Uint8Array(7)),e=>e.toString(16).padStart(2,`0`)).join(``),de=`sourceExtractionEnabled`,fe=`thinkingTimeLimit`;async function pe(e,n){let{message:r,messageId:i,rewrite:a=!1}=e,{chatId:o,loading:s,messages:l,fileIds:u,focusMode:d,category:m,optimizationMode:h,chatHistory:g,chatModelProvider:_,isAuthenticated:v,messagesRef:y,abortControllerRef:b,setLoading:x,setMessageAppeared:S,setMessages:C,setChatHistory:w,setChatModelProvider:T}=n,E=typeof window<`u`&&localStorage.getItem(de)===`true`,D=typeof window<`u`&&Number(localStorage.getItem(fe)??`0`)||0;if(s||!r)return;let O=new AbortController;b.current=O,x(!0),S(!1),l.length<=1&&window.history.replaceState(null,``,`/c/${o}`);let k=``,A=!1,j=!1,M=[],N=Date.now(),P=D>0,F=``,I=``,L=i??q();C(e=>[...e,{content:r,messageId:L,chatId:o,role:`user`,createdAt:new Date}]);let R=async e=>{if(e.type===`error`){let t=e.data;typeof t==`string`&&(t.includes(`no longer available`)||t.includes(`deprecated`)||t.includes(`410`))&&(localStorage.removeItem(`chatModelKey`),localStorage.removeItem(`chatModelProviderId`),T?.({key:``,providerId:``})),p.toast.error(t),x(!1);return}if(e.type===`searching`){let t=e.data;C(n=>{let r=n.findIndex(t=>t.messageId===e.messageId&&t.role===`searching`);return r===-1?[...n,{role:`searching`,messageId:e.messageId,chatId:o,createdAt:new Date,queries:[{query:t.query,category:t.category,status:t.status}]}]:n.map((e,n)=>{if(n!==r)return e;let i=e,a=i.queries.findIndex(e=>e.query===t.query);if(a===-1)return{...i,queries:[...i.queries,{query:t.query,category:t.category,status:t.status}]};let o=i.queries.map((e,n)=>n===a?{...e,status:t.status}:e);return{...i,queries:o}})})}if(e.type===`sources`&&(M=e.data||[],C(t=>[...t,{messageId:e.messageId,chatId:o,role:`source`,sources:M,createdAt:new Date}]),M.length>0&&(S(!0),M.slice(0,ue).forEach(e=>{let t=e?.metadata?.url;t&&t!==`File`&&(0,f.default)(`doc/article?url=${encodeURIComponent(t)}`).catch(()=>{})}))),e.type===`message`&&(k+=e.data,P?(F+=e.data,I||=e.messageId,A=!0):A?C(t=>t.map(t=>t.messageId===e.messageId&&t.role===`assistant`?{...t,content:t.content+e.data}:t)):(C(t=>[...t,{content:e.data,messageId:e.messageId,chatId:o,role:`assistant`,createdAt:new Date}]),A=!0,S(!0))),e.type===`messageEnd`){let e=async()=>{P&&F&&(C(e=>[...e,{content:F,messageId:I,chatId:o,role:`assistant`,createdAt:new Date}]),S(!0)),w(e=>[...e,[`human`,r],[`assistant`,k]]),x(!1);let e=y.current[y.current.length-1];if(t.researchAgentUIConfig.getAutoMediaSearch()&&(document.getElementById(`search-images-${e.messageId}`)?.click(),document.getElementById(`search-videos-${e.messageId}`)?.click()),!j){j=!0;let e=await le(y.current),t=q();if(C(n=>[...n,{role:`suggestion`,suggestions:e,chatId:o,createdAt:new Date,messageId:t}]),v&&e.length>0)try{await fetch(`/api/agent/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:o,messageId:t,role:`suggestion`,suggestions:e})})}catch(e){console.error(`Failed to save suggestions:`,e)}}};if(P){let e=Date.now()-N,t=D*1e3-e;t>0&&await new Promise(e=>setTimeout(e,t))}await e()}},z=l.findIndex(e=>e.messageId===L);try{let{stream:e}=await(0,c.agentChat)({signal:O.signal,body:{message:{messageId:L,chatId:o,content:r},optimizationMode:h,focusMode:d,category:m,history:a?g.slice(0,z===-1?void 0:z):g,files:u,chatModel:{key:_.key,providerId:_.providerId},sourceExtractionEnabled:E,thinkingTimeLimit:D,systemInstructions:localStorage.getItem(`systemInstructions`)??void 0},onSseError:e=>{if((e instanceof Error?e.message:String(e)).includes(`401`)&&v){p.toast.error(`Your session has expired. Please sign in again.`),x(!1),window.location.href=`/`;return}p.toast.error(`Failed to send message. Please try again.`),x(!1)}});for await(let t of e)await R(t)}catch(e){if(e.name===`AbortError`){P&&F&&(C(e=>[...e,{content:F,messageId:I,chatId:o,role:`assistant`,createdAt:new Date}]),S(!0)),k&&w(e=>[...e,[`human`,r],[`assistant`,k]]),x(!1),b.current=null;return}throw e}b.current=null}function me(e){let[t,r]=(0,n.useState)(e),[i,a]=(0,n.useState)(!1),[o,s]=(0,n.useState)(!1),[c,l]=(0,n.useState)(!1),[u,d]=(0,n.useState)(!1),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!1),[b,x]=(0,n.useState)([]),[S,C]=(0,n.useState)([]),[w,T]=(0,n.useState)([]),[E,D]=(0,n.useState)([]),[O,k]=(0,n.useState)(`webSearch`),[A,j]=(0,n.useState)(`general`),[M,N]=(0,n.useState)(`speed`),[P,F]=(0,n.useState)({key:``,providerId:``}),I=(0,n.useRef)([]),L=(0,n.useMemo)(()=>S.filter(e=>e.role===`user`||e.role===`assistant`),[S]),R=(0,n.useMemo)(()=>ce(S),[S]);return{state:{chatId:t,newChatCreated:i,loading:o,messageAppeared:c,chatHistory:b,messages:S,files:w,fileIds:E,focusMode:O,category:A,optimizationMode:M,isMessagesLoaded:u,notFound:v,chatModelProvider:P,isConfigReady:f,hasError:m,isReady:g},setters:{setChatId:r,setNewChatCreated:a,setLoading:s,setMessageAppeared:l,setChatHistory:x,setMessages:C,setFiles:T,setFileIds:D,setFocusMode:k,setCategory:j,setOptimizationMode:N,setIsMessagesLoaded:d,setNotFound:y,setChatModelProvider:F,setIsConfigReady:p,setHasError:h,setIsReady:_},messagesRef:I,chatTurns:L,sections:R}}var he=(0,n.createContext)({chatHistory:[],chatId:``,fileIds:[],files:[],focusMode:``,category:``,hasError:!1,isMessagesLoaded:!1,isReady:!1,loading:!1,messageAppeared:!1,messages:[],chatTurns:[],sections:[],notFound:!1,optimizationMode:``,chatModelProvider:{key:``,providerId:``},rewrite:()=>{},sendMessage:async()=>{},setFileIds:()=>{},setFiles:()=>{},setFocusMode:()=>{},setCategory:()=>{},setOptimizationMode:()=>{},setChatModelProvider:()=>{},stopStreaming:()=>{},newChat:()=>{},incognito:!1,setIncognito:()=>{}});function J(){return(0,n.useContext)(he)}var ge=(0,n.createContext)({user:null,isLoading:!0,isAuthenticated:!1,signIn:()=>{},signOut:async()=>{}});function _e({children:e,authClient:t}){let[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{(async()=>{try{let{data:e}=await t.getSession();i(e?.user??null)}catch(e){console.error(`Failed to fetch session:`,e),i(null)}finally{o(!1)}})()},[]),(0,n.useEffect)(()=>{a||r||t.oneTap({fetchOptions:{onSuccess:async()=>{let{data:e}=await t.getSession();i(e?.user??null)}}})},[a,r]),(0,d.jsx)(ge.Provider,{value:{user:r,isLoading:a,isAuthenticated:!!r,signIn:()=>{t.signIn.social({provider:`google`,callbackURL:`/`})},signOut:async()=>{try{await t.signOut({fetchOptions:{onSuccess:()=>{i(null),window.location.href=`/`}}})}catch(e){console.error(`Sign out failed:`,e)}}},children:e})}function ve(){let e=(0,n.useContext)(ge);if(!e)throw Error(`useSession must be used within SessionProvider`);return e}function ye({children:e}){let t=(0,r.useParams)(),i=(0,r.useSearchParams)(),a=(0,r.useRouter)(),o=i.get(`q`),{isAuthenticated:s,isLoading:c}=ve(),{state:l,setters:u,messagesRef:f,chatTurns:p,sections:m}=me(t.chatId),h=(0,n.useRef)(null),[g,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{U(u.setChatModelProvider,u.setIsConfigReady,u.setHasError)},[]),(0,n.useEffect)(()=>{t.chatId&&t.chatId!==l.chatId&&(u.setChatId(t.chatId),u.setMessages([]),u.setChatHistory([]),u.setFiles([]),u.setFileIds([]),u.setIsMessagesLoaded(!1),u.setNotFound(!1),u.setNewChatCreated(!1))},[t.chatId,l.chatId]),(0,n.useEffect)(()=>{if(l.chatId&&!l.newChatCreated&&!l.isMessagesLoaded&&l.messages.length===0){if(c)return;se(l.chatId,s,u.setMessages,u.setIsMessagesLoaded,u.setChatHistory,u.setFocusMode,u.setNotFound,u.setFiles,u.setFileIds)}else l.chatId||(u.setNewChatCreated(!0),u.setIsMessagesLoaded(!0),u.setChatId(crypto.randomUUID()))},[l.chatId,l.isMessagesLoaded,l.newChatCreated,l.messages.length,s,c]),(0,n.useEffect)(()=>{if(!g&&!s&&l.chatId&&l.messages.length>0){let e=l.messages.filter(e=>e.role===`user`||e.role===`assistant`);if(e.length>0){let t=e[0].content.slice(0,50);ie({id:l.chatId,title:t,createdAt:new Date().toISOString(),focusMode:l.focusMode,files:l.files,messages:l.messages})}}},[l.messages,l.chatId,s,l.focusMode,l.files]),(0,n.useEffect)(()=>{f.current=l.messages},[l.messages]),(0,n.useEffect)(()=>{l.isMessagesLoaded&&l.isConfigReady?(u.setIsReady(!0),console.debug(new Date,`app:ready`)):u.setIsReady(!1)},[l.isMessagesLoaded,l.isConfigReady]),(0,n.useEffect)(()=>{l.isReady&&o&&l.isConfigReady&&v(o)},[l.isConfigReady,l.isReady,o]);let v=(0,n.useCallback)(async(e,t,n=!1)=>{l.chatId&&await pe({message:e,messageId:t,rewrite:n},{chatId:l.chatId,loading:l.loading,messages:l.messages,fileIds:l.fileIds,focusMode:l.focusMode,category:l.category,optimizationMode:l.optimizationMode,chatHistory:l.chatHistory,chatModelProvider:l.chatModelProvider,isAuthenticated:s,messagesRef:f,abortControllerRef:h,setLoading:u.setLoading,setMessageAppeared:u.setMessageAppeared,setMessages:u.setMessages,setChatHistory:u.setChatHistory,setChatModelProvider:u.setChatModelProvider})},[l.chatId,l.loading,l.messages,l.fileIds,l.focusMode,l.category,l.optimizationMode,l.chatHistory,l.chatModelProvider,s,f]),y=(0,n.useCallback)(e=>{let t=l.messages.findIndex(t=>t.messageId===e),n=p.findIndex(t=>t.messageId===e);if(t===-1)return;let r=p[n-1];u.setMessages(e=>[...e.slice(0,l.messages.length>2?l.messages.indexOf(r):0)]),u.setChatHistory(e=>[...e.slice(0,p.length>2?n-1:0)]),v(r.content,r.messageId,!0)},[l.messages,p,v]),b=(0,n.useCallback)(()=>{h.current&&=(h.current.abort(),null)},[]),x=(0,n.useCallback)(()=>{b(),u.setMessages([]),u.setChatHistory([]),u.setFiles([]),u.setFileIds([]),u.setChatId(void 0),u.setNewChatCreated(!1),u.setIsMessagesLoaded(!1),u.setNotFound(!1),a.push(`/`)},[b,a]),S={messages:l.messages,chatTurns:p,sections:m,chatHistory:l.chatHistory,files:l.files,fileIds:l.fileIds,focusMode:l.focusMode,category:l.category,chatId:l.chatId,hasError:l.hasError,isMessagesLoaded:l.isMessagesLoaded,isReady:l.isReady,loading:l.loading,messageAppeared:l.messageAppeared,notFound:l.notFound,optimizationMode:l.optimizationMode,chatModelProvider:l.chatModelProvider,incognito:g,setFileIds:u.setFileIds,setFiles:u.setFiles,setFocusMode:u.setFocusMode,setCategory:u.setCategory,setOptimizationMode:u.setOptimizationMode,rewrite:y,sendMessage:v,setChatModelProvider:u.setChatModelProvider,stopStreaming:b,newChat:x,setIncognito:_};return(0,d.jsx)(he.Provider,{value:S,children:e})}function be({delayDuration:e=0,...t}){return(0,d.jsx)(m.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Y({...e}){return(0,d.jsx)(be,{children:(0,d.jsx)(m.Root,{"data-slot":`tooltip`,...e})})}function X({...e}){return(0,d.jsx)(m.Trigger,{"data-slot":`tooltip-trigger`,...e})}function xe({className:e,sideOffset:t=0,children:n,...r}){return(0,d.jsx)(m.Portal,{children:(0,d.jsxs)(m.Content,{"data-slot":`tooltip-content`,sideOffset:t,className:E(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,d.jsx)(m.Arrow,{className:`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var Se=({href:e,children:t,sources:r})=>{let{openPanel:i}=A(),a=(0,n.useMemo)(()=>!r||!e?null:r.find(t=>t.metadata?.url===e)??null,[r,e]),o=(0,n.useMemo)(()=>{try{return new URL(e).hostname.replace(`www.`,``)}catch{return a?.metadata?.source||``}},[e,a]),s=a?.metadata?.title||``,c=`https://s2.googleusercontent.com/s2/favicons?domain_url=${e}`;return(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.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,d.jsx)(xe,{side:`top`,className:`max-w-72 p-2.5`,children:(0,d.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,d.jsx)(`img`,{src:c,alt:``,width:16,height:16,className:`rounded flex-shrink-0 mt-0.5`}),(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium leading-snug line-clamp-2`,children:s||o}),s&&(0,d.jsx)(`p`,{className:`text-[10px] opacity-70 truncate mt-0.5`,children:o})]})]})})]})},Ce=({content:e,thinkingEnded:t})=>{let[r,i]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{i(!t)},[t]),(0,d.jsxs)(`div`,{className:`my-4 bg-secondary/50 rounded-xl border border-border overflow-hidden`,children:[(0,d.jsxs)(`button`,{onClick:()=>i(!r),className:`w-full flex items-center justify-between px-4 py-1 text-foreground/90 hover:bg-secondary transition duration-200`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(s.BrainCircuit,{size:20,className:`text-accent-foreground`}),(0,d.jsx)(`p`,{className:`font-medium text-sm`,children:`Thinking Process`})]}),r?(0,d.jsx)(s.ChevronUp,{size:18,className:`text-muted-foreground`}):(0,d.jsx)(s.ChevronDown,{size:18,className:`text-muted-foreground`})]}),r&&(0,d.jsx)(`div`,{className:`px-4 py-3 text-foreground/80 text-sm border-t border-border bg-muted/50 whitespace-pre-wrap`,children:e})]})},we=({children:e,thinkingEnded:t})=>(0,d.jsx)(Ce,{content:e,thinkingEnded:t}),Te=({section:e,isExpanded:t,setIsExpanded:r,isEditing:i,setIsEditing:a,editText:o,setEditText:c,handleEditSubmit:l,copiedUserMsg:u,handleCopyUserMsg:f})=>{let p=(0,n.useRef)(null);return(0,d.jsxs)(`div`,{className:`w-full pt-8 break-words`,children:[(0,d.jsxs)(`button`,{onClick:()=>r(!t),className:`flex items-center gap-3 group text-left w-full`,children:[(0,d.jsx)(`div`,{className:`flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200`,children:t?(0,d.jsx)(s.ChevronDown,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`}):(0,d.jsx)(s.ChevronRight,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`})}),(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-0.5 mt-1 ml-10`,children:[(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:f,className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,d.jsx)(`span`,{className:E(`flex items-center transition-all duration-300`,u?`scale-110`:`scale-100`),children:u?(0,d.jsx)(s.Check,{size:14,className:`text-green-500`}):(0,d.jsx)(s.ClipboardList,{size:14})})})}),(0,d.jsx)(xe,{side:`bottom`,children:u?`Copied!`:`Copy prompt`})]}),(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:()=>{c(e.userMessage.content),a(!0),setTimeout(()=>p.current?.focus(),50)},className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,d.jsx)(s.Pencil,{size:14})})}),(0,d.jsx)(xe,{side:`bottom`,children:`Edit & resubmit`})]})]}),i&&(0,d.jsxs)(`div`,{className:`mt-3 ml-10 flex flex-col gap-2`,children:[(0,d.jsx)(`textarea`,{ref:p,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l()),e.key===`Escape`&&a(!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,d.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,d.jsx)(`button`,{onClick:()=>a(!1),className:`px-3 py-1.5 text-sm text-muted-foreground rounded-lg hover:bg-secondary transition-colors duration-200`,children:`Cancel`}),(0,d.jsx)(`button`,{onClick:l,disabled:!o.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`})]})]})]})};function Ee({...e}){return(0,d.jsx)(h.Root,{"data-slot":`dropdown-menu`,...e})}function De({...e}){return(0,d.jsx)(h.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function Oe({className:e,sideOffset:t=4,...n}){return(0,d.jsx)(h.Portal,{children:(0,d.jsx)(h.Content,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:E(`bg-card 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 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl border p-1 shadow-md`,e),...n})})}function Z({className:e,inset:t,variant:n=`default`,...r}){return(0,d.jsx)(h.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:E(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function ke({className:e,children:t,checked:n,...r}){return(0,d.jsxs)(h.CheckboxItem,{"data-slot":`dropdown-menu-checkbox-item`,className:E(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-2xl py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,d.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,d.jsx)(h.ItemIndicator,{children:(0,d.jsx)(s.CheckIcon,{className:`size-4`})})}),t]})}function Ae({className:e,inset:t,...n}){return(0,d.jsx)(h.Label,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:E(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Q({className:e,...t}){return(0,d.jsx)(h.Separator,{"data-slot":`dropdown-menu-separator`,className:E(`bg-border -mx-1 my-1 h-px`,e),...t})}function je({...e}){return(0,d.jsx)(h.Sub,{"data-slot":`dropdown-menu-sub`,...e})}function Me({className:e,inset:t,children:n,...r}){return(0,d.jsxs)(h.SubTrigger,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:E(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8`,e),...r,children:[n,(0,d.jsx)(s.ChevronRightIcon,{className:`ml-auto size-4`})]})}function Ne({className:e,...t}){return(0,d.jsx)(h.SubContent,{"data-slot":`dropdown-menu-sub-content`,className:E(`bg-card 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 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl border p-1 shadow-lg`,e),...t})}var Pe=({section:e,initialMessage:t})=>{let[r,i]=(0,n.useState)(!1);return(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.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,d.jsx)(s.Check,{size:18}):(0,d.jsx)(s.ClipboardList,{size:18})})}),(0,d.jsx)(xe,{side:`bottom`,children:r?`Copied!`:`Copy`})]})};function Fe({...e}){return(0,d.jsx)(g.Root,{"data-slot":`popover`,...e})}function Ie({...e}){return(0,d.jsx)(g.Trigger,{"data-slot":`popover-trigger`,...e})}function Le({className:e,align:t=`center`,sideOffset:n=4,container:r,...i}){return(0,d.jsx)(g.Portal,{container:r,children:(0,d.jsx)(g.Content,{"data-slot":`popover-content`,align:t,sideOffset:n,className:E(`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),...i})})}var $={Plus:s.Plus,Paperclip:s.Paperclip,Cloud:s.Cloud,Upload:s.Upload,File:s.File,SquarePen:s.SquarePen,Thinking:e=>(0,d.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,d.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})}),SelectArrow:s.ChevronDown,ArrowUp:s.ArrowUp,X:s.X,FileText:s.FileText,Loader2:s.Loader2,Check:s.Check,Archive:s.Archive,Mic:s.Mic,Stop:s.Square,Clock:e=>(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,...e,children:(0,d.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})})},Re=({messageId:e})=>{let{rewrite:t,chatModelProvider:r,setChatModelProvider:i}=J(),[a,o]=(0,n.useState)([]),[l,u]=(0,n.useState)(!0),[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{m&&(async()=>{try{u(!0);let{data:e}=await(0,c.listProviders)();o(e?.providers??[])}catch(e){console.error(`Error loading providers:`,e)}finally{u(!1)}})()},[m]);let g=(0,n.useMemo)(()=>{if(!r?.providerId)return a;let e=a.findIndex(e=>e.id===r.providerId);return e===-1?a:[a[e],...a.filter((t,n)=>n!==e)]},[a,r]).map(e=>({...e,chatModels:(e.chatModels??[]).filter(t=>t.name.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase()))})).filter(e=>e.chatModels.length>0),_=(0,n.useMemo)(()=>{if(!r.key)return`Rewrite`;for(let e of a){let t=e.chatModels.find(e=>e.key===r.key);if(t)return t.name}return r.key},[a,r.key]),v=(n,r)=>{i({providerId:n,key:r}),localStorage.setItem(`chatModelProviderId`,n),localStorage.setItem(`chatModelKey`,r),h(!1),t(e)};return(0,d.jsxs)(Fe,{open:m,onOpenChange:h,children:[(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(Ie,{asChild:!0,children:(0,d.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,d.jsx)(s.ArrowLeftRight,{size:18})})})}),(0,d.jsxs)(xe,{side:`bottom`,children:[`Rewrite with `,_]})]}),(0,d.jsx)(Le,{className:`w-[280px] p-0`,align:`start`,side:`top`,sideOffset:8,children:(0,d.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,d.jsx)(`div`,{className:`p-3 border-b border-[#EEEEEE] dark:border-[#30302E]`,children:(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-text-400 dark:text-[#999999]`}),(0,d.jsx)(`input`,{type:`text`,placeholder:`Search models...`,value:f,onChange:e=>p(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,d.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:l?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,d.jsx)($.Loader2,{className:`animate-spin text-text-400 dark:text-[#999999]`,size:20})}):g.length===0?(0,d.jsx)(`div`,{className:`text-center py-12 px-4 text-text-400 dark:text-[#999999] text-sm`,children:f?`No models found`:`No chat models configured`}):(0,d.jsx)(`div`,{className:`flex flex-col`,children:g.map((e,t)=>(0,d.jsxs)(`div`,{children:[(0,d.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,d.jsx)(`p`,{className:`text-[11px] text-text-400 dark:text-[#999999] uppercase tracking-wider font-medium`,children:e.name})}),(0,d.jsx)(`div`,{className:`flex flex-col px-1.5 py-1.5 space-y-0.5`,children:e.chatModels.map(t=>(0,d.jsxs)(`button`,{onClick:()=>v(e.id,t.key),type:`button`,className:E(`px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group`,r?.providerId===e.id&&r?.key===t.key?`bg-sky-50 dark:bg-sky-500/10`:`hover:bg-bg-100 dark:hover:bg-[#30302E]`),children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2.5 min-w-0 flex-1`,children:[(0,d.jsx)(s.Cpu,{size:14,className:E(`shrink-0`,r?.providerId===e.id&&r?.key===t.key?`text-sky-500`:`text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]`)}),(0,d.jsx)(`p`,{className:E(`text-[13px] truncate`,r?.providerId===e.id&&r?.key===t.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:t.name})]}),r?.providerId===e.id&&r?.key===t.key&&(0,d.jsx)($.Check,{className:`w-4 h-4 text-sky-500 shrink-0`})]},t.key))}),t<g.length-1&&(0,d.jsx)(`div`,{className:`h-px bg-[#EEEEEE] dark:bg-[#30302E] mx-2`})]},e.id))})})]})})]})},ze=new Map;function Be(e){if(typeof window>`u`)return Promise.reject(Error(`CDN scripts require a browser environment`));let t=ze.get(e);if(t)return t;let n=new Promise((t,n)=>{let r=document.querySelector(`script[data-cdn-loader="${e}"]`);if(r){r.dataset.loaded===`true`?t():(r.addEventListener(`load`,()=>t(),{once:!0}),r.addEventListener(`error`,()=>n(Error(`Failed to load ${e}`)),{once:!0}));return}let i=document.createElement(`script`);i.src=e,i.async=!0,i.dataset.cdnLoader=e,i.onload=()=>{i.dataset.loaded=`true`,t()},i.onerror=()=>{ze.delete(e),n(Error(`Failed to load ${e}`))},document.head.appendChild(i)});return ze.set(e,n),n}var Ve=`https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js`,He=`https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js`;async function Ue(){await Be(Ve);let e=window.jspdf?.jsPDF;if(!e)throw Error(`jsPDF global not found after CDN load`);return e}async function We(){await Be(He);let e=window.docx;if(!e)throw Error(`docx global not found after CDN load`);return e}async function Ge(e,t){Ye(`# ${e}\n\n${new v.default({headingStyle:`atx`,codeBlockStyle:`fenced`}).turndown(t)}`,`${e}.md`,`text/markdown`)}async function Ke(e,t){let{Document:n,Paragraph:r,TextRun:i,HeadingLevel:a,Packer:o}=await We(),s=new DOMParser().parseFromString(t,`text/html`),c=[];c.push(new r({text:e,heading:a.HEADING_1,spacing:{after:200}}));let l=e=>{if(e.nodeType===Node.TEXT_NODE){let t=e.textContent?.trim();t&&c.push(new r({children:[new i(t)]}))}else if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.tagName.toLowerCase();switch(n){case`h1`:c.push(new r({text:t.textContent||``,heading:a.HEADING_1}));break;case`h2`:c.push(new r({text:t.textContent||``,heading:a.HEADING_2}));break;case`h3`:c.push(new r({text:t.textContent||``,heading:a.HEADING_3}));break;case`p`:let e=[];t.childNodes.forEach(t=>{if(t.nodeType===Node.TEXT_NODE)e.push(new i(t.textContent||``));else if(t.nodeType===Node.ELEMENT_NODE){let n=t,r={text:n.textContent||``};(n.tagName===`STRONG`||n.tagName===`B`)&&(r.bold=!0),(n.tagName===`EM`||n.tagName===`I`)&&(r.italics=!0),n.tagName===`U`&&(r.underline={}),n.tagName===`CODE`&&(r.font=`Courier New`),e.push(new i(r))}}),e.length>0?c.push(new r({children:e})):c.push(new r({text:t.textContent||``}));break;case`ul`:case`ol`:t.querySelectorAll(`li`).forEach(e=>{c.push(new r({text:e.textContent||``,bullet:n===`ul`?{level:0}:void 0,numbering:n===`ol`?{reference:`default`,level:0}:void 0}))});break;case`blockquote`:c.push(new r({children:[new i({text:t.textContent||``,italics:!0})],indent:{left:720}}));break;default:t.childNodes.forEach(l)}}};s.body.childNodes.forEach(l);let u=new n({sections:[{properties:{},children:c}]}),d=await o.toBlob(u),f=URL.createObjectURL(d),p=document.createElement(`a`);p.href=f,p.download=`${e}.docx`,p.click(),URL.revokeObjectURL(f)}async function qe(e,t){let n=document.createElement(`div`);n.style.position=`absolute`,n.style.left=`-9999px`,n.style.width=`210mm`,n.style.padding=`20mm`,n.style.backgroundColor=`white`,n.style.fontFamily=`Arial, sans-serif`,n.style.fontSize=`12pt`,n.style.lineHeight=`1.6`,n.innerHTML=`
16
+ )`},className:E(`pointer-events-none absolute inset-0 rounded-[inherit] opacity-100 transition-opacity`,o&&`opacity-100`,e>0&&`blur-[var(--blur)] `,s,f&&`!hidden`),children:(0,d.jsx)(`div`,{className:E(`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))]`)})})]})});O.displayName=`GlowingEffect`;var k=(0,n.createContext)(void 0),A=()=>{let e=(0,n.useContext)(k);if(!e)throw Error(`useExtractPanel must be used within an ExtractPanelProvider`);return e},j=({children:e})=>{let[t,r]=(0,n.useState)(!1),[i,a]=(0,n.useState)(``),[o,s]=(0,n.useState)(``),[c,l]=(0,n.useState)(600);return(0,d.jsx)(k.Provider,{value:{isOpen:t,url:i,searchText:o,panelWidth:c,setIsOpen:r,setUrl:a,setSearchText:s,setPanelWidth:l,openPanel:(e,t=``)=>{console.log(`[ExtractPanelContext] openPanel called with URL:`,e);try{let t=new URL(e);(t.pathname===`/`||t.pathname===``)&&console.error(`[ExtractPanelContext] URL is domain-only, missing article path:`,e)}catch(t){console.error(`[ExtractPanelContext] Invalid URL format:`,e,t)}if(a(e),s(t),r(!0),typeof window<`u`){let t=new URLSearchParams(window.location.search);t.set(`extract`,encodeURIComponent(e));let n=`${window.location.pathname}?${t.toString()}`;window.history.pushState({},``,n)}},closePanel:()=>{if(r(!1),typeof window<`u`){let e=new URLSearchParams(window.location.search);e.delete(`extract`);let t=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.pushState({},``,t)}}},children:e})};function M(e){return(0,d.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 214.6279 198.1416`,...e,children:[(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{fill:`#5CB0FF`,d:`M171.748,142.3193c0-15.4375-12.5625-28-28-28s-28,12.5625-28,28s12.5625,28,28,28 S171.748,157.7568,171.748,142.3193z`}),(0,d.jsx)(`path`,{fill:`#1C71DA`,d:`M95.748,166.3193v-76h42.989c0.0146,0.7878,0.0696,1.5579,0.0696,2.3516c0,2.2109,1.7891,4,4,4 s4-1.7891,4-4c0-0.7937-0.0603-1.5632-0.0745-2.3516h25.0159h5.6484h2.3516c0-46.3164-37.6836-84-84-84h-8v0.4053 c-42.5754,4.0447-76,39.9785-76,83.5947c0,46.3164,37.6836,84,84,84c2.2109,0,4-1.7891,4-4S97.959,166.3193,95.748,166.3193z M87.748,164.9949c-19.9287-6.438-35.0586-36.3945-35.0586-72.324c0-0.7937,0.0549-1.5637,0.0696-2.3516h34.989V164.9949z M53.1655,82.3193C55.75,51.1135,69.7729,26.157,87.748,20.3506v61.9688H53.1655z M95.748,82.3193v-63.293 c21.6829,0,39.6248,27.5808,42.5825,63.293H95.748z M171.3181,82.3193h-24.9685c-2.3884-29.9812-14.96-54.8911-31.9993-65.6013 C144.7681,24.4146,167.9641,50.417,171.3181,82.3193z M77.1458,16.718C60.1064,27.4282,47.5349,52.3381,45.1465,82.3193H20.178 C23.532,50.417,46.728,24.4146,77.1458,16.718z M19.748,90.3193h25.0159c-0.0142,0.7883-0.0745,1.5579-0.0745,2.3516 c0,28.5327,9.217,53.6572,23.1233,68.2603C39.7031,149.769,19.748,122.3567,19.748,90.3193z`}),(0,d.jsx)(`path`,{fill:`#1C71DA`,d:`M191.5137,184.4287l-19.665-19.665c4.9307-6.1609,7.8994-13.9573,7.8994-22.4443 c0-19.8516-16.1484-36-36-36s-36,16.1484-36,36s16.1484,36,36,36c8.4871,0,16.2834-2.9688,22.4443-7.8994l19.665,19.665 L191.5137,184.4287z M115.748,142.3193c0-15.4375,12.5625-28,28-28s28,12.5625,28,28s-12.5625,28-28,28 S115.748,157.7568,115.748,142.3193z`})]}),(0,d.jsx)(`path`,{fill:`#FF5D5D`,d:`M4,22.1416c-1.0234,0-2.0479-0.3906-2.8281-1.1719c-1.5625-1.5615-1.5625-4.0947,0-5.6562L15.3145,1.1719 c1.5625-1.5625,4.0957-1.5625,5.6562,0c1.5625,1.5615,1.5625,4.0947,0,5.6562L6.8281,20.9697 C6.0469,21.751,5.0234,22.1416,4,22.1416z`}),(0,d.jsx)(`path`,{fill:`#FF5D5D`,d:`M18.1426,22.1416c-1.0234,0-2.0469-0.3906-2.8281-1.1719L1.1719,6.8281 c-1.5625-1.5615-1.5625-4.0947,0-5.6562c1.5605-1.5625,4.0938-1.5625,5.6562,0l14.1426,14.1416 c1.5625,1.5615,1.5625,4.0947,0,5.6562C20.1904,21.751,19.166,22.1416,18.1426,22.1416z`}),(0,d.jsx)(`path`,{fill:`#00D40B`,d:`M14,198.1416c-7.7197,0-14-6.2803-14-14s6.2803-14,14-14s14,6.2803,14,14S21.7197,198.1416,14,198.1416z M14,178.1416c-3.3086,0-6,2.6914-6,6s2.6914,6,6,6s6-2.6914,6-6S17.3086,178.1416,14,178.1416z`}),(0,d.jsx)(`path`,{fill:`#FFC504`,d:`M199.3145,56.7695c-1.0605,0-2.0781-0.4219-2.8281-1.1719l-11.3145-11.3145 c-0.75-0.75-1.1719-1.7676-1.1719-2.8281s0.4219-2.0781,1.1719-2.8281l11.3145-11.3135c1.5625-1.5625,4.0938-1.5625,5.6562,0 l11.3135,11.3135c1.5625,1.5615,1.5625,4.0947,0,5.6562l-11.3135,11.3145C201.3926,56.3477,200.375,56.7695,199.3145,56.7695z M193.6572,41.4551l5.6572,5.6572l5.6572-5.6572l-5.6572-5.6572L193.6572,41.4551z`})]})}function N(e){return(0,d.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 508 508`,...e,children:[(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M316.1,353.2H191.9c13.2,60.9,37.8,102.2,62.1,102.2C278.3,455.4,302.9,414.1,316.1,353.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M78.2,353.2c26.2,46.5,69.8,80.1,120.6,94.5c-15.4-22.5-27.7-54.7-35.7-94.5H78.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.8,353.2h-84.9c-8,39.8-20.4,72-35.7,94.5C360,433.4,403.6,399.7,429.8,353.2z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.3,154.8c-26.3-46.4-69.6-80-120-94.4c15.3,22.4,27.7,54.7,35.6,94.4H429.3z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M163.1,154.8c8-39.7,20.3-71.9,35.7-94.4c-50.4,14.4-93.8,48-120,94.4H163.1z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M479.8,310.9V197.1c0-7.8-6.3-14.1-14.1-14.1H42.3c-7.8,0-14.1,6.3-14.1,14.1v113.8 c0,7.8,6.3,14.1,14.1,14.1h423.3C473.4,325,479.8,318.7,479.8,310.9z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M254,52.6c-24.3,0-48.9,41.3-62.1,102.2h124.2C302.9,93.9,278.3,52.6,254,52.6z`})]}),(0,d.jsx)(`path`,{style:{fill:`#56ACE0`},d:`M254,426.5c-95.3,0-172.9-77.5-172.9-172.9S158.7,80.8,254,80.8s172.9,77.5,172.9,172.9 S349.3,426.5,254,426.5z`}),(0,d.jsx)(`rect`,{x:`56.4`,y:`211.2`,style:{fill:`#FFC10D`},width:`395.1`,height:`85.6`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#194F82`},d:`M465.7,154.8H461C422.8,75.3,342.7,24.4,254,24.4S85.1,75.3,47,154.8h-4.7C19,154.8,0,173.7,0,197.1 v113.8c0,23.3,19,42.3,42.3,42.3h4.2c38,79.5,118.4,130.4,207.5,130.4c89.2,0,169.5-50.9,207.5-130.4h4.2c23.3,0,42.3-19,42.3-42.3 V197.1C508,173.7,489,154.8,465.7,154.8z M429.3,154.8h-84.4c-8-39.7-20.3-71.9-35.6-94.4C359.7,74.7,403,108.4,429.3,154.8z M254,52.6c24.3,0,48.9,41.3,62.1,102.2H191.9C205.1,93.9,229.7,52.6,254,52.6z M198.7,60.4c-15.3,22.4-27.7,54.7-35.7,94.4H78.7 C105,108.4,148.3,74.7,198.7,60.4z M78.2,353.2h84.9c8,39.8,20.4,72,35.7,94.5C148,433.4,104.4,399.7,78.2,353.2z M254,455.4 c-24.3,0-48.9-41.3-62.1-102.2h124.2C302.9,414.1,278.3,455.4,254,455.4z M309.2,447.7c15.4-22.5,27.7-54.7,35.7-94.5h84.9 C403.6,399.7,360,433.4,309.2,447.7z M479.8,310.9c0,7.8-6.3,14.1-14.1,14.1H42.3c-7.8,0-14.1-6.3-14.1-14.1V197.1 c0-7.8,6.3-14.1,14.1-14.1h423.3c7.8,0,14.1,6.3,14.1,14.1v113.8H479.8z`}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`146,265.7 109.1,215.3 93.4,215.3 93.4,293.6 110.2,293.6 110.2,244.5 146,293.6 162.7,293.6 162.7,215.3 146,215.3 `}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`197.9,261.9 231.6,261.9 231.6,247 197.9,247 197.9,230.9 235.3,230.9 235.3,215.3 181.2,215.3 181.2,293.6 236.5,293.6 236.5,278.1 197.9,278.1 `}),(0,d.jsx)(`polygon`,{style:{fill:`#194F82`},points:`318.9,260.3 305.7,215.3 288.1,215.3 274.8,260.3 260,215.3 241.9,215.3 268.1,293.6 280.5,293.6 296.8,239.2 313.3,293.6 325.7,293.6 351.9,215.3 333.8,215.3 `}),(0,d.jsx)(`path`,{style:{fill:`#194F82`},d:`M392,246.6c-8.2-1.9-16.5-3.8-16.6-10.2c0.5-5.4,3.9-7.5,9-7.6c6.9,0,13.7,2.6,20.2,7.7l8.5-12.8 c-8-6.2-17-10.4-28.1-10.3c-12.5-0.6-27,7.6-26.8,23.2c-1,15.4,10.4,21.4,25.2,24.8c9.2,2,14.5,5.1,13.9,9.8 c0.1,5.2-4.6,7.7-9.9,7.7c-6.9,0-14.3-3.7-22.4-11.1l-10,12.8c9.5,9.2,20.2,13.8,32.1,13.8c15.1,0.7,27.6-8.8,27.5-23.6 C414.8,257.3,406.3,250,392,246.6z`})]})]})}function P(e){return(0,d.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 512 512`,...e,children:[(0,d.jsx)(`circle`,{style:{fill:`#8AD5DD`},cx:`256`,cy:`256`,r:`256`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_0`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_1`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_2`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_3`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`rect`,{id:`SVGCleanerId_4`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,d.jsx)(`path`,{id:`SVGCleanerId_5`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_0_1_`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_1_1_`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_2_1_`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_3_1_`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`rect`,{id:`SVGCleanerId_4_1_`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,d.jsx)(`g`,{children:(0,d.jsx)(`path`,{id:`SVGCleanerId_5_1_`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`})}),(0,d.jsx)(`polygon`,{style:{fill:`#FFFFFF`},points:`232.496,191.472 303,232.176 232.496,272.88 `}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,d.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#E0E0E0`},d:`M365.664,100.072v19.616h-135.24v-19.616H365.664 M367.624,98.112h-139.16v23.536h139.16 L367.624,98.112L367.624,98.112z`}),(0,d.jsx)(`rect`,{x:`341.312`,y:`98.112`,style:{fill:`#E0E0E0`},width:`26.312`,height:`23.536`})]}),(0,d.jsx)(`path`,{style:{fill:`#DB2B42`},d:`M207.656,121.648H173.2c-1.312,0-2.384-1.072-2.384-2.384v-18.768c0-1.312,1.072-2.384,2.384-2.384 h34.456c1.312,0,2.384,1.072,2.384,2.384v18.768C210.04,120.576,208.96,121.648,207.656,121.648z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M178.008,107.264h-2.784v-1.488h7.384v1.488h-2.816v8.28h-1.784L178.008,107.264L178.008,107.264z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M189.28,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M191.144,115.544c0.032-0.48,0.064-1.264,0.064-1.984v-8.312h1.784v4.2h0.032 c0.432-0.672,1.2-1.128,2.256-1.128c1.728,0,2.96,1.432,2.944,3.584c0,2.536-1.608,3.8-3.208,3.8c-0.912,0-1.728-0.352-2.232-1.216 h-0.032l-0.088,1.056H191.144z M192.992,112.632c0,0.152,0.016,0.288,0.04,0.424c0.192,0.712,0.808,1.256,1.584,1.256 c1.12,0,1.8-0.904,1.8-2.32c0-1.256-0.592-2.264-1.784-2.264c-0.72,0-1.376,0.528-1.584,1.304 c-0.024,0.128-0.056,0.288-0.056,0.464V112.632z`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M200.952,112.512c0.04,1.28,1.04,1.832,2.176,1.832c0.824,0,1.416-0.12,1.96-0.32l0.264,1.232 c-0.616,0.248-1.456,0.44-2.472,0.44c-2.288,0-3.64-1.408-3.64-3.576c0-1.952,1.192-3.8,3.448-3.8c2.296,0,3.048,1.888,3.048,3.44 c0,0.336-0.032,0.592-0.056,0.752C205.68,112.512,200.952,112.512,200.952,112.512z M204.056,111.264 c0.016-0.648-0.272-1.728-1.464-1.728c-1.104,0-1.568,1.008-1.64,1.728H204.056z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M147.464,115.544v-4.072l-3.088-5.696h2.032l1.176,2.504c0.336,0.728,0.584,1.28,0.848,1.944h0.024 c0.248-0.624,0.52-1.232,0.856-1.944l1.176-2.504h2.016l-3.248,5.656v4.112H147.464z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M158.864,111.944c0,2.6-1.824,3.76-3.624,3.76c-2,0-3.536-1.376-3.536-3.632 c0-2.328,1.52-3.744,3.656-3.744C157.464,108.32,158.864,109.8,158.864,111.944z M153.544,112.024c0,1.36,0.664,2.392,1.752,2.392 c1.016,0,1.728-1,1.728-2.424c0-1.104-0.496-2.368-1.712-2.368C154.056,109.624,153.544,110.84,153.544,112.024z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M166.656,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M353.936,113.776c-3.096,0-5.616-2.52-5.616-5.616s2.52-5.616,5.616-5.616s5.616,2.52,5.616,5.616 C359.552,111.256,357.032,113.776,353.936,113.776z M353.936,103.816c-2.392,0-4.344,1.952-4.344,4.344s1.952,4.344,4.344,4.344 s4.344-1.952,4.344-4.344S356.328,103.816,353.936,103.816z`}),(0,d.jsx)(`rect`,{x:`356.02`,y:`113.813`,transform:`matrix(-0.6044 -0.7967 0.7967 -0.6044 484.7665 469.5985)`,style:{fill:`#2D2D2D`},width:`5.896`,height:`1.272`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M240.088,113.168c0.48,0.296,1.184,0.544,1.92,0.544c1.096,0,1.736-0.576,1.736-1.416 c0-0.768-0.44-1.216-1.56-1.648c-1.352-0.48-2.192-1.184-2.192-2.352c0-1.296,1.072-2.248,2.68-2.248 c0.848,0,1.464,0.192,1.832,0.4l-0.296,0.872c-0.272-0.152-0.824-0.392-1.576-0.392c-1.136,0-1.56,0.672-1.56,1.24 c0,0.776,0.504,1.152,1.648,1.6c1.4,0.544,2.12,1.216,2.12,2.432c0,1.28-0.952,2.392-2.904,2.392c-0.8,0-1.68-0.24-2.12-0.528 L240.088,113.168z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M246.984,111.688c0.024,1.472,0.96,2.064,2.048,2.064c0.776,0,1.24-0.128,1.648-0.304l0.184,0.776 c-0.384,0.176-1.032,0.368-1.984,0.368c-1.832,0-2.928-1.208-2.928-3s1.056-3.216,2.792-3.216c1.952,0,2.464,1.704,2.464,2.808 c0,0.216-0.024,0.392-0.04,0.496h-4.184V111.688z M250.16,110.92c0.016-0.688-0.288-1.76-1.504-1.76 c-1.096,0-1.576,1.008-1.664,1.76H250.16z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M255.88,114.472l-0.088-0.752h-0.032c-0.336,0.472-0.968,0.888-1.824,0.888 c-1.208,0-1.824-0.848-1.824-1.704c0-1.448,1.28-2.232,3.584-2.216v-0.128c0-0.488-0.136-1.384-1.36-1.384 c-0.552,0-1.128,0.176-1.552,0.448l-0.248-0.72c0.488-0.312,1.208-0.528,1.96-0.528c1.824,0,2.264,1.24,2.264,2.432v2.232 c0,0.52,0.024,1.024,0.104,1.424h-0.984V114.472z M255.72,111.44c-1.184-0.024-2.528,0.184-2.528,1.336 c0,0.704,0.472,1.032,1.024,1.032c0.776,0,1.272-0.488,1.44-1c0.04-0.112,0.064-0.24,0.064-0.344V111.44z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M258.552,110.376c0-0.704-0.016-1.304-0.056-1.864h0.944l0.04,1.176h0.04 c0.272-0.8,0.928-1.304,1.656-1.304c0.12,0,0.2,0.008,0.304,0.032v1.024c-0.112-0.024-0.224-0.032-0.368-0.032 c-0.768,0-1.312,0.576-1.456,1.392c-0.024,0.144-0.056,0.312-0.056,0.496v3.176h-1.072v-4.096H258.552z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M266.72,114.256c-0.288,0.152-0.912,0.344-1.72,0.344c-1.792,0-2.968-1.216-2.968-3.04 c0-1.84,1.264-3.168,3.208-3.168c0.64,0,1.208,0.168,1.504,0.304l-0.248,0.84c-0.264-0.152-0.664-0.28-1.264-0.28 c-1.368,0-2.104,1.008-2.104,2.248c0,1.384,0.888,2.232,2.064,2.232c0.616,0,1.024-0.168,1.328-0.296L266.72,114.256z`}),(0,d.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M268.016,105.736h1.08v3.712h0.024c0.176-0.304,0.448-0.576,0.776-0.76 c0.312-0.184,0.704-0.304,1.104-0.304c0.808,0,2.08,0.488,2.08,2.544v3.544H272v-3.424c0-0.96-0.352-1.768-1.376-1.768 c-0.704,0-1.264,0.488-1.456,1.08c-0.064,0.152-0.08,0.304-0.08,0.52v3.6h-1.08v-8.744H268.016z`})]})]})}function F(e){return(0,d.jsx)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 73 73`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,...e,children:(0,d.jsx)(`g`,{id:`fundamentals/css/images`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,d.jsxs)(`g`,{id:`container`,transform:`translate(2.000000, 2.000000)`,fillRule:`nonzero`,children:[(0,d.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,fill:`#424A60`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`}),(0,d.jsx)(`circle`,{id:`Oval`,fill:`#EFCE4A`,cx:`21.069`,cy:`23.069`,r:`9.069`}),(0,d.jsx)(`polygon`,{id:`Shape`,fill:`#1A9172`,points:`69.5 56.7492553 68.1170213 55.212766 51.5212766 40 37 55.9042553 44.5828723 63.4871277 50.1382979 69.0425532 60.7455406 69.0425532 69.5 60.1780353`}),(0,d.jsx)(`polygon`,{id:`Shape`,fill:`#25AE88`,points:`47.8532188 64.0501875 33.8030313 50 12 69.1969687 53 69.1969687`}),(0,d.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`})]})})})}function I(e){return(0,d.jsxs)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 32 32`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,d.jsx)(`path`,{d:`M23.3 8.40007L21.82 6.40008C21.7248 6.27314 21.6008 6.17066 21.4583 6.10111C21.3157 6.03156 21.1586 5.99693 21 6.00008H11.2C11.0555 6.00007 10.9128 6.03135 10.7816 6.09177C10.6504 6.15219 10.5339 6.24031 10.44 6.35007L8.71998 8.35008C8.57227 8.53401 8.49435 8.76424 8.49998 9.00008V16.2901C8.50262 18.0317 9.19567 19.7013 10.4272 20.9328C11.6588 22.1644 13.3283 22.8574 15.07 22.8601H16.93C18.6716 22.8574 20.3412 22.1644 21.5728 20.9328C22.8043 19.7013 23.4973 18.0317 23.5 16.2901V9.00008C23.5 8.7837 23.4298 8.57317 23.3 8.40007Z`,fill:`#FFCC80`}),(0,d.jsx)(`path`,{d:`M29.78 28.38L25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38Z`,fill:`#01579B`}),(0,d.jsx)(`path`,{d:`M29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003L15.73 11.6C15.906 11.6534 16.094 11.6534 16.27 11.6L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003Z`,fill:`#01579B`}),(0,d.jsx)(`path`,{d:`M11.22 6C11.0756 5.99999 10.9328 6.03127 10.8016 6.09169C10.6704 6.15211 10.5539 6.24023 10.46 6.35L8.74 8.35C8.58509 8.53114 8.49998 8.76166 8.5 9V16.29C8.50264 18.0317 9.19569 19.7012 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16V6H11.22Z`,fill:`#FFE0B2`}),(0,d.jsx)(`path`,{d:`M7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H16V25L7.21999 23Z`,fill:`#0277BD`}),(0,d.jsx)(`path`,{d:`M15.71 2.00002L2.71 6.00002C2.49742 6.06422 2.31226 6.19734 2.1837 6.3784C2.05515 6.55947 1.99052 6.77817 2 7.00002C1.9917 7.22447 2.0592 7.44518 2.19163 7.62658C2.32405 7.80799 2.5137 7.93954 2.73 8.00002L15.73 11.6C15.8194 11.6146 15.9106 11.6146 16 11.6V2.00002C15.9039 1.98469 15.8061 1.98469 15.71 2.00002Z`,fill:`#0277BD`}),(0,d.jsx)(`path`,{d:`M2.73 8.00003L8.5 9.56003V16.29C8.50264 18.0317 9.19569 19.7013 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16.93C18.6717 22.8574 20.3412 22.1643 21.5728 20.9328C22.8043 19.7013 23.4974 18.0317 23.5 16.29V9.56003L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003ZM21.5 16.29C21.4974 17.5013 21.015 18.6621 20.1586 19.5186C19.3021 20.3751 18.1412 20.8574 16.93 20.86H15.07C13.8588 20.8574 12.6979 20.3751 11.8414 19.5186C10.985 18.6621 10.5026 17.5013 10.5 16.29V10.11L15.73 11.56C15.906 11.6134 16.094 11.6134 16.27 11.56L21.5 10.11V16.29ZM16 4.05003L25.44 7.00003L16 9.56003L6.56 7.00003L16 4.05003Z`,fill:`#263238`}),(0,d.jsx)(`path`,{d:`M25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38L25.78 23.38ZM5.07999 28L7.38999 25.11L15.78 27C15.9251 27.0299 16.0748 27.0299 16.22 27L24.61 25.13L26.92 28H5.07999Z`,fill:`#263238`})]})}function L(e){return(0,d.jsxs)(`svg`,{height:`800px`,width:`800px`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 503.322 503.322`,...e,children:[(0,d.jsx)(`path`,{style:{fill:`#FBC176`},d:`M0,73.763v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627c6.942,0,13.017-6.075,13.017-13.017 V73.763c0-6.942-6.075-13.017-13.017-13.017H13.017C6.075,60.746,0,66.82,0,73.763`}),(0,d.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M225.627,60.746V39.051c0-6.942-6.075-13.017-13.017-13.017h-69.424L121.492,0H30.373 c-6.942,0-13.017,6.075-13.017,13.017v47.729H225.627z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,104.136H34.712c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678C95.458,100.664,91.986,104.136,86.78,104.136`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,138.847H34.712c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678S91.986,138.847,86.78,138.847`})]}),(0,d.jsx)(`path`,{style:{fill:`#FBC176`},d:`M251.661,360.136v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627 c6.942,0,13.017-6.075,13.017-13.017V360.136c0-6.942-6.075-13.017-13.017-13.017H264.678 C257.736,347.119,251.661,353.193,251.661,360.136`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,390.508h-52.068c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678S343.647,390.508,338.441,390.508`}),(0,d.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,425.22h-52.068c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678C347.119,421.749,343.647,425.22,338.441,425.22`})]}),(0,d.jsx)(`path`,{style:{fill:`#F38774`},d:`M208.271,451.254H78.102c-5.207,0-8.678-3.471-8.678-8.678V260.339c0-5.207,3.471-8.678,8.678-8.678 c5.207,0,8.678,3.471,8.678,8.678v173.559h121.492c5.207,0,8.678,3.471,8.678,8.678 C216.949,447.783,213.478,451.254,208.271,451.254`}),(0,d.jsx)(`path`,{style:{fill:`#26B999`},d:`M433.898,277.695c-5.207,0-8.678-3.471-8.678-8.678V95.458H295.051c-5.207,0-8.678-3.471-8.678-8.678 c0-5.207,3.471-8.678,8.678-8.678h138.847c5.207,0,8.678,3.471,8.678,8.678v182.237 C442.576,274.224,439.105,277.695,433.898,277.695`}),(0,d.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M477.288,347.119v-21.695c0-6.942-6.075-13.017-13.017-13.017h-69.424l-21.695-26.034h-91.119 c-6.942,0-13.017,6.075-13.017,13.017v47.729H477.288z`})]})}function R(e){return(0,d.jsxs)(`svg`,{height:`800px`,width:`800px`,viewBox:`0 0 128 128`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,className:`iconify iconify--noto`,preserveAspectRatio:`xMidYMid meet`,...e,children:[(0,d.jsx)(`path`,{d:`M106 24.79H22.15c-1.92 0-3.48 1.56-3.48 3.48v57.59c0 1.92 1.56 3.48 3.48 3.48H106c1.92 0 3.48-1.56 3.48-3.48V28.27c0-1.92-1.55-3.48-3.48-3.48z`,fill:`#b7d5e5`}),(0,d.jsxs)(`radialGradient`,{id:`IconifyId17ecdb2904d178eab9910`,cx:`48.408`,cy:`13.024`,r:`75.465`,gradientTransform:`matrix(1 0 0 1.0843 0 -10.19)`,gradientUnits:`userSpaceOnUse`,children:[(0,d.jsx)(`stop`,{offset:`0`,stopColor:`#2f7889`}),(0,d.jsx)(`stop`,{offset:`1`,stopColor:`#424242`})]}),(0,d.jsx)(`path`,{fill:`url(#IconifyId17ecdb2904d178eab9910)`,d:`M104.75 83.2H23.4l.96-52.27h79.43z`}),(0,d.jsx)(`path`,{d:`M121.09 123.82H7.59c-.43 0-.83-.03-1.2-.09c-2.88-.44-4.21-4.18-2.5-6.74l.39-.59h119.59l.4.6c1.86 2.78.12 6.76-3.04 6.81c-.04.01-.09.01-.14.01z`,fill:`#2f7889`}),(0,d.jsx)(`path`,{d:`M106.84 90.41H20.6c-1.27 0-2.54.77-3.25 1.99l-14 25.48c-.59.88-.01 2.12.99 2.12H123.8c1 0 1.58-1.24.99-2.12l-14.71-25.63c-.7-1.08-1.97-1.84-3.24-1.84z`,fill:`#eee`}),(0,d.jsx)(`path`,{fill:`#b7d5e5`,d:`M86.36 115.52H41.8l2.85-7.98h39.07z`}),(0,d.jsxs)(`g`,{opacity:`0.57`,fill:`#69a1ba`,children:[(0,d.jsx)(`path`,{d:`M72.69 94.84l-.27-2.2h-3.44l.13 2.2z`}),(0,d.jsx)(`path`,{d:`M67.14 94.84l-.14-2.2h-3.45v2.2z`}),(0,d.jsx)(`path`,{d:`M93.61 94.84l-.81-2.2h-3.26l.68 2.2z`}),(0,d.jsx)(`path`,{d:`M88.36 94.84l-.68-2.2h-3.32l.54 2.2z`}),(0,d.jsx)(`path`,{d:`M83.18 94.84l-.54-2.2h-3.37l.41 2.2z`}),(0,d.jsx)(`path`,{d:`M102.11 94.84l-.95-2.2h-6.71l.82 2.2z`}),(0,d.jsx)(`path`,{d:`M77.61 94.84l-.41-2.2h-3.41l.28 2.2z`}),(0,d.jsx)(`path`,{d:`M33.76 94.84l.68-2.2h-3.26l-.81 2.2z`}),(0,d.jsx)(`path`,{d:`M50.51 94.84l.27-2.2h-3.41l-.4 2.2z`}),(0,d.jsx)(`path`,{d:`M39.35 94.84l.54-2.2h-3.32l-.67 2.2z`}),(0,d.jsx)(`path`,{d:`M28.17 94.84l.81-2.2H25.8l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M44.93 94.84l.41-2.2h-3.37l-.54 2.2z`}),(0,d.jsx)(`path`,{d:`M56.08 94.84l.14-2.2h-3.44l-.27 2.2z`}),(0,d.jsx)(`path`,{d:`M61.65 94.84v-2.2H58.2l-.14 2.2z`}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M83.78 103.73H44.36l-.75 2.2h41.08z`}),(0,d.jsx)(`path`,{d:`M102.15 105.93l-1.21-2.2h6.54l.95 2.2z`}),(0,d.jsx)(`path`,{d:`M86.75 105.93l-.83-2.2h6.29l.96 2.2z`}),(0,d.jsx)(`path`,{d:`M95.39 105.93l-.96-2.2h4.31l1.1 2.2z`}),(0,d.jsx)(`path`,{d:`M25.67 105.93l1.21-2.2h-6.54l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M41.07 105.93l.83-2.2h-6.29l-.96 2.2z`}),(0,d.jsx)(`path`,{d:`M32.42 105.93l.97-2.2h-4.31l-1.11 2.2z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M29.71 98.51l.82-2.19h-6.67l-.95 2.19z`}),(0,d.jsx)(`path`,{d:`M97.95 98.51l-.81-2.19h6.66l.95 2.19z`}),(0,d.jsx)(`path`,{d:`M96.25 98.51l-.96-2.19h-3.85l.82 2.19z`}),(0,d.jsx)(`path`,{d:`M86.23 98.51l-.65-2.19h3.85l.78 2.19z`}),(0,d.jsx)(`path`,{d:`M80.19 98.51l-.47-2.19h3.85l.6 2.19z`}),(0,d.jsx)(`path`,{d:`M74.15 98.51l-.28-2.19h3.84l.43 2.19z`}),(0,d.jsx)(`path`,{d:`M68.12 98.51l-.11-2.19h3.85l.24 2.19z`}),(0,d.jsx)(`path`,{d:`M62.08 98.51l.07-2.19H66l.06 2.19z`}),(0,d.jsx)(`path`,{d:`M56.04 98.51l.25-2.19h3.85l-.11 2.19z`}),(0,d.jsx)(`path`,{d:`M50.01 98.51l.42-2.19h3.85l-.29 2.19z`}),(0,d.jsx)(`path`,{d:`M43.97 98.51l.6-2.19h3.85l-.47 2.19z`}),(0,d.jsx)(`path`,{d:`M37.93 98.51l.78-2.19h3.85l-.64 2.19z`}),(0,d.jsx)(`path`,{d:`M31.9 98.51l.95-2.19h3.85l-.82 2.19z`})]}),(0,d.jsxs)(`g`,{children:[(0,d.jsx)(`path`,{d:`M29.7 102.22l.81-2.2h-8.75l-.95 2.2z`}),(0,d.jsx)(`path`,{d:`M95.87 102.22l-.77-2.2h-4.17l.64 2.2z`}),(0,d.jsx)(`path`,{d:`M84.93 102.22l-.48-2.2h4.16l.62 2.2z`}),(0,d.jsx)(`path`,{d:`M78.28 102.22l-.32-2.2h4.17l.45 2.2z`}),(0,d.jsx)(`path`,{d:`M71.64 102.22l-.17-2.2h4.17l.3 2.2z`}),(0,d.jsx)(`path`,{d:`M65 102.22l-.01-2.2h4.16l.15 2.2z`}),(0,d.jsx)(`path`,{d:`M58.36 102.22l.14-2.2h4.17l-.01 2.2z`}),(0,d.jsx)(`path`,{d:`M51.71 102.22l.3-2.2h4.17l-.17 2.2z`}),(0,d.jsx)(`path`,{d:`M45.07 102.22l.46-2.2h4.16l-.32 2.2z`}),(0,d.jsx)(`path`,{d:`M38.43 102.22l.61-2.2h4.17l-.48 2.2z`}),(0,d.jsx)(`path`,{d:`M31.78 102.22l.77-2.2h4.17l-.63 2.2z`}),(0,d.jsx)(`path`,{d:`M97.47 102.22l-.82-2.2h8.75l.95 2.2z`})]})]}),(0,d.jsx)(`path`,{d:`M124.73 117.88L110.39 92.4c-.71-1.07-1.98-1.84-3.25-1.84c0 0 1.22 1.1 1.59 1.63l12.59 23.59c.56 1.02-.18 2.26-1.34 2.26H7.96c-1.15 0-1.89-1.23-1.35-2.24l11.95-23.18c.35-.6 1.88-1.99 1.88-1.99h-.45c-1.27 0-2.54.77-3.25 1.99L3.28 117.88c-.59.88-.01 2.12.99 2.12h119.46c1.01 0 1.59-1.24 1-2.12z`,fill:`#b7d5e5`}),(0,d.jsx)(`path`,{fill:`none`,stroke:`#eee`,strokeWidth:`2.936`,strokeLinecap:`round`,strokeMiterlimit:`10`,d:`M25.97 28.02h13.21`}),(0,d.jsx)(`path`,{d:`M109.37 30.11c0-1.04-1.01-1.12-1.01.11v55.8c0 1.34-1.09 2.43-2.43 2.43H22.08c-1.34 0-2.43-1.09-2.43-2.43v-55.8c0-1.23-1.01-1.15-1.01-.11l-.95 55.91c0 2.42 1.24 4.39 4.39 4.39h83.85c2.73 0 4.39-1.97 4.39-4.39l-.95-55.91z`,fill:`#75a7bc`})]})}var z=[{code:`general`,icon:M,name:`Web`},{code:`news`,icon:N,name:`News`},{code:`videos`,icon:P,name:`Videos`},{code:`images`,icon:F,name:`Images`},{code:`science`,icon:I,name:`Academic`},{code:`files`,icon:L,name:`Files`},{code:`it`,icon:R,name:`Tech`}],ee=z.filter(e=>[`general`,`news`,`videos`,`images`,`science`,`files`].includes(e.code)),te=({sources:e,query:t})=>{let[r,i]=(0,n.useState)(`general`),[a,o]=(0,n.useState)(e),[u,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(1),[_,v]=(0,n.useState)(!0),[y,b]=(0,n.useState)(!1),x=(0,n.useRef)(null),S=(0,n.useRef)(!1),C=(0,n.useRef)(!1),{openPanel:w,isOpen:T}=A(),[D,k]=(0,n.useState)({});(0,n.useEffect)(()=>{let e=()=>{b(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{o(e),i(`general`),g(1),v(!0),k({}),j(e)},[e]);let j=(0,n.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,c.getArticle)({query:{url:e.metadata.url}});t?.cached&&t?.article?.html&&k(t=>({...t,[e.metadata.url]:`loaded`}))}catch{}},[]);(0,n.useEffect)(()=>{if(typeof window<`u`){let e=new URLSearchParams(window.location.search).get(`extract`);e&&(w(decodeURIComponent(e),``),C.current=!1)}},[w]),(0,n.useEffect)(()=>{C.current=!1},[e]),(0,n.useEffect)(()=>{S.current&&!T&&(C.current=!0),S.current=T},[T]),(0,n.useEffect)(()=>{if(y&&a&&a.length>0&&!T&&!C.current){let e=a[0];e?.metadata?.url&&w(e.metadata.url,``)}},[a,y]);let M=async(e,t)=>{e.preventDefault(),C.current=!1,k(e=>({...e,[t]:`loading`})),w(t,``);try{await(0,c.getArticle)({query:{url:t}}),k(e=>({...e,[t]:`loaded`}))}catch{k(e=>({...e,[t]:`loaded`}))}},N=(0,n.useCallback)(async()=>{if(!t||p||!_)return;m(!0);let e=h+1,{data:n}=await(0,c.agentSearch)({query:{q:t,cat:r,page:e}}),i=n?.results??[];if(i.length===0){v(!1),m(!1);return}let a=i.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{pageContent:e.snippet||e.content||``,metadata:{title:e.title||``,source:e.source||``,thumbnail:e.thumbnail||``,url:e.url||``,...e.thumbnail&&{thumbnail:e.thumbnail}}}});o(e=>[...e,...a]),g(e),m(!1)},[t,r,h,p,_]),P=async e=>{if(!(e===r||!t)){i(e),f(!0),g(1),v(!0);try{let{data:n}=await(0,c.agentSearch)({query:{q:t,cat:e,page:1}}),r=(n?.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{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.thumbnail&&{thumbnail:e.thumbnail},...e.iframe_src&&{iframe_src:e.iframe_src}}}});o(r)}catch(e){console.error(`Error searching:`,e)}finally{f(!1)}}};(0,n.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<100&&N()};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[N]);let F=(e,t)=>{let n=r===`images`,i=r===`videos`,a=e.metadata.img_src||e.metadata.thumbnail;if(n&&a)return(0,d.jsx)(`div`,{className:`relative rounded-lg group`,children:(0,d.jsxs)(`a`,{className:`relative block overflow-hidden rounded-lg cursor-pointer`,href:e.metadata.url,onClick:t=>M(t,e.metadata.url),children:[(0,d.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,d.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,d.jsx)(`p`,{className:`text-xs text-white line-clamp-2`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)}),(0,d.jsx)(`p`,{className:`text-[10px] text-white/70 truncate mt-0.5`,children:e.metadata.source})]})]})},t);if(i&&a)return(0,d.jsxs)(`div`,{className:`relative rounded-xl`,children:[(0,d.jsx)(O,{spread:40,glow:!0,disabled:!1,proximity:64,inactiveZone:.01,borderWidth:2}),(0,d.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:e.metadata.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`img`,{src:a,alt:e.metadata.title,className:`w-full h-24 object-cover`}),(0,d.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,d.jsx)(`div`,{className:`w-10 h-10 bg-black/60 rounded-full flex items-center justify-center`,children:(0,d.jsx)(s.Video,{size:18,className:`text-white ml-0.5`})})})]}),(0,d.jsx)(`p`,{className:`text-xs line-clamp-2 p-2 text-muted-foreground`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]},t);let o=D[e.metadata.url];return(0,d.jsxs)(`div`,{className:`relative rounded-xl group h-full`,children:[(0,d.jsx)(O,{spread:40,glow:!0,disabled:!1,proximity:64,inactiveZone:.01,borderWidth:2}),(0,d.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=>M(t,e.metadata.url),children:[o&&(0,d.jsx)(`div`,{className:`absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]`,children:o===`loading`?(0,d.jsx)(s.Loader2,{size:14,className:`text-primary animate-spin`}):(0,d.jsx)(s.FileText,{size:14,className:`text-green-500`})}),(0,d.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,d.jsx)(s.ExternalLink,{size:12,className:`text-muted-foreground`})}),(0,d.jsxs)(`p`,{className:`text-xs line-clamp-4 text-muted-foreground`,children:[(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle`,children:[e.metadata.url===`File`?(0,d.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0`,children:(0,d.jsx)(s.File,{size:10,className:`text-muted-foreground`})}):(0,d.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,d.jsx)(`span`,{className:`align-middle`,children:(0,l.convertURLSafeHTMLToHTML)(e.metadata.title)})]})]})]},t)};return(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex items-center gap-1 mb-3 overflow-x-auto pb-1`,children:ee.map(e=>(0,d.jsxs)(`button`,{onClick:()=>P(e.code),disabled:u,className:E(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap`,r===e.code?`bg-primary text-primary-foreground`:`bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground`),children:[(0,d.jsx)(e.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:e.name})]},e.code))}),(0,d.jsx)(`div`,{ref:x,className:E(`overflow-y-auto pb-2 pr-1`,r===`images`?`max-h-[400px] lg:max-h-[500px]`:`max-h-[180px] lg:max-h-[280px]`),children:u?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(s.Loader2,{className:`w-6 h-6 animate-spin text-muted-foreground`})}):a.length>0?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:E(r===`images`?`columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid`:E(`grid gap-3 auto-rows-fr`,T&&y?`grid-cols-2`:`grid-cols-3`)),children:a.map((e,t)=>F(e,t))}),p&&(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,d.jsx)(s.Loader2,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),!_&&a.length>0&&(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4 text-muted-foreground text-xs`,children:`No more results`})]}):(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`No results found`})})]})},B={extract:`Extract`,arxiv:`ArXiv`,"google scholar":`Scholar`,pubmed:`PubMed`,wolframalpha:`Wolfram`,youtube:`YouTube`,Web:`Web`};function ne(e){return e?B[e]??e:`Web`}function V({queries:e,loading:t}){let n=e.filter(e=>e.status===`done`).length,r=e.length,i=t&&e.some(e=>e.status===`running`);return t?(0,d.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/50`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[i?(0,d.jsx)(s.Loader2,{className:`w-3.5 h-3.5 animate-spin`}):(0,d.jsx)(s.Search,{className:`w-3.5 h-3.5`}),(0,d.jsx)(`span`,{className:`font-medium text-foreground`,children:i?`Running analysis…`:`Analysis complete`})]}),r>0&&(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n,`/`,r,` searches`]})]}),e.length>0&&(0,d.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map((e,t)=>(0,d.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2`,children:[e.status===`running`?(0,d.jsx)(s.Loader2,{className:`w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0`}):(0,d.jsx)(s.Search,{className:E(`w-3.5 h-3.5 flex-shrink-0`,e.status===`done`?`text-muted-foreground`:`text-muted-foreground/40`)}),(0,d.jsxs)(`div`,{className:`flex items-baseline gap-1.5 min-w-0 flex-1`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap flex-shrink-0`,children:[ne(e.category),` ·`]}),(0,d.jsx)(`span`,{className:`text-foreground/80 truncate`,children:e.query})]})]},t))})]}):null}function H(e,t){let[r,i]=(0,n.useState)(`stopped`),a=(0,n.useRef)(null),o=(0,n.useRef)(null),s=(0,n.useRef)(null),c=(0,n.useRef)(t);c.current=t;let l=(0,n.useCallback)(()=>{a.current&&=(a.current.pause(),a.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(a.current.src),null),s.current?.abort(),s.current=null},[]),u=(0,n.useCallback)(()=>{if(!(`speechSynthesis`in window))return!1;try{window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);return o.current=t,t.onend=()=>{o.current=null,i(`stopped`)},t.onerror=()=>{o.current=null,i(`stopped`)},window.speechSynthesis.speak(t),i(`started`),!0}catch{return!1}},[e]);return{speechStatus:r,start:(0,n.useCallback)(async()=>{if(!e?.trim())return;l(),window.speechSynthesis?.cancel(),o.current=null,i(`started`);let t=new AbortController;s.current=t;try{let n=await(0,f.default)(`/api/agent/tts`,{method:`POST`,body:{text:e.slice(0,5e3),speaker:localStorage.getItem(`ttsSpeaker`)||`angus`},signal:t.signal}),r=typeof n.blob==`function`?await n.blob():n;if(!r||r.size===0){u()||i(`stopped`);return}let o=URL.createObjectURL(r),s=new Audio(o);a.current=s,s.onended=()=>{i(`stopped`),URL.revokeObjectURL(o),a.current=null},s.onerror=()=>{URL.revokeObjectURL(o),a.current=null,u()||i(`stopped`)},await s.play()}catch{u()||i(`stopped`)}},[e,l,u]),stop:(0,n.useCallback)(()=>{l(),o.current=null,window.speechSynthesis?.cancel(),i(`stopped`)},[l])}}var re=async(e,t,n)=>{let r=localStorage.getItem(`chatModelKey`),i=localStorage.getItem(`chatModelProviderId`),a=(await(0,f.default)(`/api/agent/providers`))?.providers||[];if(!a||a.length===0){t(!0);return}let o=a.find(e=>e.id===i&&(e.chatModels?.length??0)>0);if(o||=a.find(e=>e.name.toLowerCase().includes(`openrouter`)&&(e.chatModels?.length??0)>0)||a.find(e=>e.name.toLowerCase().includes(`nvidia`)&&(e.chatModels?.length??0)>0)||a.find(e=>(e.chatModels?.length??0)>0),!o){t(!0);return}i=o.id;let s=o.chatModels.find(e=>e.key===r);if(s||(o.name.toLowerCase().includes(`openrouter`)&&(s=o.chatModels.find(e=>e.key===`openrouter/free`)),!s&&o.name.toLowerCase().includes(`openrouter`)&&(s=o.chatModels.find(e=>e.key===`nvidia/nemotron-3-super-120b-a12b:free`)),s||=o.chatModels.find(e=>(e.key.toLowerCase().includes(`nemotron-3-super`)||e.name.toLowerCase().includes(`nemotron 3 super`))&&e.key.toLowerCase().includes(`120b`)),s||=o.chatModels.find(e=>e.key.toLowerCase().includes(`nemotron`)||e.name.toLowerCase().includes(`nemotron`)),s||=o.chatModels[0]),!s){t(!0);return}r=s.key,localStorage.setItem(`chatModelKey`,r),localStorage.setItem(`chatModelProviderId`,i),e({key:r,providerId:i}),t(!0)},U=`qwksearch_guest_chats`,W=typeof window<`u`;function G(){if(!W)return[];try{let e=localStorage.getItem(U);return e?JSON.parse(e).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()):[]}catch(e){return console.error(`Failed to get guest chats:`,e),[]}}function K(e){return W&&G().find(t=>t.id===e)||null}function ie(e){if(W)try{let t=G(),n=t.findIndex(t=>t.id===e.id);n>=0?t[n]=e:t.push(e),localStorage.setItem(U,JSON.stringify(t))}catch(e){console.error(`Failed to save guest chat:`,e)}}function ae(e){if(W)try{let t=G().filter(t=>t.id!==e);localStorage.setItem(U,JSON.stringify(t))}catch(e){console.error(`Failed to delete guest chat:`,e)}}function oe(){if(W)try{localStorage.removeItem(U)}catch(e){console.error(`Failed to clear guest chats:`,e)}}var se=async(e,t,n,r,i,a,o,s,l)=>{if(!t){let t=K(e);if(t){n(t.messages);let e=t.messages.filter(e=>e.role===`user`||e.role===`assistant`),o=e.map(e=>[e.role,e.content]);e.length>0&&(document.title=e[0].content),s(t.files||[]),l((t.files||[]).map(e=>e.fileId)),i(o),a(t.focusMode),r(!0);return}try{let{data:t,error:u}=await(0,c.getChatById)({path:{id:e}});if(u){let e=u.status;if(e===404||e===403){o(!0),r(!0);return}throw Error(`Failed to load chat: ${u.message}`)}let{messages:d,chat:f}=t||{};if(!d||!f){o(!0),r(!0);return}n(d);let p=d.filter(e=>e.role===`user`||e.role===`assistant`),m=p.map(e=>[e.role,e.content]);p.length>0&&(document.title=p[0].content);let h=f.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(h),l(h.map(e=>e.fileId)),i(m),a(f.focusMode),r(!0);return}catch(e){console.error(`[chatMessages] Failed to load public chat:`,e),o(!0),r(!0);return}}try{let{data:t,error:u}=await(0,c.getChatById)({path:{id:e}});if(u){let e=u.status;if(e===404||e===401||e===403){o(!0),r(!0);return}throw Error(`Failed to load chat: ${u.message}`)}let{messages:d,chat:f}=t||{};if(!d||!f){o(!0),r(!0);return}n(d);let p=d.filter(e=>e.role===`user`||e.role===`assistant`),m=p.map(e=>[e.role,e.content]);console.debug(new Date,`app:messages_loaded`),p.length>0&&(document.title=p[0].content);let h=f.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(h),l(h.map(e=>e.fileId)),i(m),a(f.focusMode),r(!0)}catch(e){console.error(`[chatMessages] Failed to load chat:`,e),o(!0),r(!0)}},ce=e=>{let t=[];return e.forEach((n,r)=>{if(n.role===`user`){let i=e.findIndex((e,t)=>t>r&&e.role===`user`),a=e.find((e,t)=>t>r&&e.role===`assistant`&&(i===-1||t<i)),o=e.find((e,t)=>t>r&&e.role===`source`&&e.sources&&(i===-1||t<i)),s=e.find((e,t)=>t>r&&e.role===`searching`&&(i===-1||t<i)),c=!1,l=a?.content??``,u=a?.content??``,d=[];if(a){let t=/\[([^\]]+)\]/g,n=/\[(\d+)\]/g;if(l.includes(`<think>`)){let e=l.match(/<think>/g)?.length||0,t=l.match(/<\/think>/g)?.length||0;e&&!t&&(l+=`</think> <a> </a>`)}a.content.includes(`</think>`)&&(c=!0),o&&o.sources&&o.sources.length>0?(l=l.replace(t,(e,t)=>t.split(`,`).map(e=>e.trim()).map(e=>{let t=parseInt(e);if(isNaN(t)||t<=0)return`[${e}]`;let n=(o.sources?.[t-1])?.metadata?.url;return n?`<citation href="${n}">${e}</citation>`:``}).join(``)),u=a.content.replace(n,``)):(l=l.replace(n,``),u=a.content.replace(n,``));let s=e.find((e,t)=>t>r&&e.role===`suggestion`&&(i===-1||t<i));s&&s.suggestions.length>0&&(d=s.suggestions)}t.push({userMessage:n,assistantMessage:a,sourceMessage:o,searchingMessage:s,parsedAssistantMessage:l,speechMessage:u,thinkingEnded:c,suggestions:d})}}),t},le=async e=>{let t=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`),r=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),i=e.filter(e=>e.role===`user`||e.role===`assistant`);try{let e=await(0,f.default)(`agent/suggestions`,{method:`POST`,body:JSON.stringify({chatHistory:i,chatModel:{providerId:n,key:t},maxQuestions:r})});return Array.isArray(e.suggestions)?e.suggestions:[]}catch{return[]}},ue=3,de=()=>Array.from(crypto.getRandomValues(new Uint8Array(7)),e=>e.toString(16).padStart(2,`0`)).join(``),fe=`sourceExtractionEnabled`,pe=`thinkingTimeLimit`;async function me(e,n){let{message:r,messageId:i,rewrite:a=!1}=e,{chatId:o,loading:s,messages:l,fileIds:u,focusMode:d,category:m,optimizationMode:h,chatHistory:g,chatModelProvider:_,isAuthenticated:v,messagesRef:y,abortControllerRef:b,setLoading:x,setMessageAppeared:S,setMessages:C,setChatHistory:w,setChatModelProvider:T}=n,E=typeof window<`u`&&localStorage.getItem(fe)===`true`,D=typeof window<`u`&&Number(localStorage.getItem(pe)??`0`)||0;if(s||!r)return;let O=new AbortController;b.current=O,x(!0),S(!1),l.length<=1&&window.history.replaceState(null,``,`/c/${o}`);let k=``,A=!1,j=!1,M=[],N=Date.now(),P=D>0,F=``,I=``,L=i??de();C(e=>[...e,{content:r,messageId:L,chatId:o,role:`user`,createdAt:new Date}]);let R=async e=>{if(e.type===`error`){let t=e.data;typeof t==`string`&&(t.includes(`no longer available`)||t.includes(`deprecated`)||t.includes(`410`))&&(localStorage.removeItem(`chatModelKey`),localStorage.removeItem(`chatModelProviderId`),T?.({key:``,providerId:``})),p.toast.error(t),x(!1);return}if(e.type===`searching`){let t=e.data;C(n=>{let r=n.findIndex(t=>t.messageId===e.messageId&&t.role===`searching`);return r===-1?[...n,{role:`searching`,messageId:e.messageId,chatId:o,createdAt:new Date,queries:[{query:t.query,category:t.category,status:t.status}]}]:n.map((e,n)=>{if(n!==r)return e;let i=e,a=i.queries.findIndex(e=>e.query===t.query);if(a===-1)return{...i,queries:[...i.queries,{query:t.query,category:t.category,status:t.status}]};let o=i.queries.map((e,n)=>n===a?{...e,status:t.status}:e);return{...i,queries:o}})})}if(e.type===`sources`&&(M=e.data||[],C(t=>[...t,{messageId:e.messageId,chatId:o,role:`source`,sources:M,createdAt:new Date}]),M.length>0&&(S(!0),M.slice(0,ue).forEach(e=>{let t=e?.metadata?.url;t&&t!==`File`&&(0,f.default)(`doc/article?url=${encodeURIComponent(t)}`).catch(()=>{})}))),e.type===`message`&&(k+=e.data,P?(F+=e.data,I||=e.messageId,A=!0):A?C(t=>t.map(t=>t.messageId===e.messageId&&t.role===`assistant`?{...t,content:t.content+e.data}:t)):(C(t=>[...t,{content:e.data,messageId:e.messageId,chatId:o,role:`assistant`,createdAt:new Date}]),A=!0,S(!0))),e.type===`messageEnd`){let e=async()=>{P&&F&&(C(e=>[...e,{content:F,messageId:I,chatId:o,role:`assistant`,createdAt:new Date}]),S(!0)),w(e=>[...e,[`human`,r],[`assistant`,k]]),x(!1);let e=y.current[y.current.length-1];if(t.researchAgentUIConfig.getAutoMediaSearch()&&(document.getElementById(`search-images-${e.messageId}`)?.click(),document.getElementById(`search-videos-${e.messageId}`)?.click()),!j){j=!0;let e=await le(y.current),t=de();if(C(n=>[...n,{role:`suggestion`,suggestions:e,chatId:o,createdAt:new Date,messageId:t}]),v&&e.length>0)try{await(0,c.saveMessage)({body:{chatId:o,messageId:t,role:`suggestion`,suggestions:e}})}catch(e){console.error(`Failed to save suggestions:`,e)}}};if(P){let e=Date.now()-N,t=D*1e3-e;t>0&&await new Promise(e=>setTimeout(e,t))}await e()}},z=l.findIndex(e=>e.messageId===L);try{let{stream:e}=await(0,c.agentChat)({signal:O.signal,body:{message:{messageId:L,chatId:o,content:r},optimizationMode:h,focusMode:d,category:m,history:a?g.slice(0,z===-1?void 0:z):g,files:u,chatModel:{key:_.key,providerId:_.providerId},sourceExtractionEnabled:E,thinkingTimeLimit:D,systemInstructions:localStorage.getItem(`systemInstructions`)??void 0},onSseError:e=>{if((e instanceof Error?e.message:String(e)).includes(`401`)&&v){p.toast.error(`Your session has expired. Please sign in again.`),x(!1),window.location.href=`/`;return}p.toast.error(`Failed to send message. Please try again.`),x(!1)}});for await(let t of e)await R(t)}catch(e){if(e.name===`AbortError`){P&&F&&(C(e=>[...e,{content:F,messageId:I,chatId:o,role:`assistant`,createdAt:new Date}]),S(!0)),k&&w(e=>[...e,[`human`,r],[`assistant`,k]]),x(!1),b.current=null;return}throw e}b.current=null}function he(e){let[t,r]=(0,n.useState)(e),[i,a]=(0,n.useState)(!1),[o,s]=(0,n.useState)(!1),[c,l]=(0,n.useState)(!1),[u,d]=(0,n.useState)(!1),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!1),[b,x]=(0,n.useState)([]),[S,C]=(0,n.useState)([]),[w,T]=(0,n.useState)([]),[E,D]=(0,n.useState)([]),[O,k]=(0,n.useState)(`webSearch`),[A,j]=(0,n.useState)(`general`),[M,N]=(0,n.useState)(`speed`),[P,F]=(0,n.useState)({key:``,providerId:``}),I=(0,n.useRef)([]),L=(0,n.useMemo)(()=>S.filter(e=>e.role===`user`||e.role===`assistant`),[S]),R=(0,n.useMemo)(()=>ce(S),[S]);return{state:{chatId:t,newChatCreated:i,loading:o,messageAppeared:c,chatHistory:b,messages:S,files:w,fileIds:E,focusMode:O,category:A,optimizationMode:M,isMessagesLoaded:u,notFound:v,chatModelProvider:P,isConfigReady:f,hasError:m,isReady:g},setters:{setChatId:r,setNewChatCreated:a,setLoading:s,setMessageAppeared:l,setChatHistory:x,setMessages:C,setFiles:T,setFileIds:D,setFocusMode:k,setCategory:j,setOptimizationMode:N,setIsMessagesLoaded:d,setNotFound:y,setChatModelProvider:F,setIsConfigReady:p,setHasError:h,setIsReady:_},messagesRef:I,chatTurns:L,sections:R}}var ge=(0,n.createContext)({chatHistory:[],chatId:``,fileIds:[],files:[],focusMode:``,category:``,hasError:!1,isMessagesLoaded:!1,isReady:!1,loading:!1,messageAppeared:!1,messages:[],chatTurns:[],sections:[],notFound:!1,optimizationMode:``,chatModelProvider:{key:``,providerId:``},rewrite:()=>{},sendMessage:async()=>{},setFileIds:()=>{},setFiles:()=>{},setFocusMode:()=>{},setCategory:()=>{},setOptimizationMode:()=>{},setChatModelProvider:()=>{},stopStreaming:()=>{},newChat:()=>{},incognito:!1,setIncognito:()=>{}});function q(){return(0,n.useContext)(ge)}var _e=(0,n.createContext)({user:null,isLoading:!0,isAuthenticated:!1,signIn:()=>{},signOut:async()=>{}});function ve({children:e,authClient:t}){let[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{(async()=>{try{let{data:e}=await t.getSession();i(e?.user??null)}catch(e){console.error(`Failed to fetch session:`,e),i(null)}finally{o(!1)}})()},[]),(0,n.useEffect)(()=>{a||r||t.oneTap({fetchOptions:{onSuccess:async()=>{let{data:e}=await t.getSession();i(e?.user??null)}}})},[a,r]),(0,d.jsx)(_e.Provider,{value:{user:r,isLoading:a,isAuthenticated:!!r,signIn:()=>{t.signIn.social({provider:`google`,callbackURL:`/`})},signOut:async()=>{try{await t.signOut({fetchOptions:{onSuccess:()=>{i(null),window.location.href=`/`}}})}catch(e){console.error(`Sign out failed:`,e)}}},children:e})}function ye(){let e=(0,n.useContext)(_e);if(!e)throw Error(`useSession must be used within SessionProvider`);return e}function be({children:e}){let t=(0,r.useParams)(),i=(0,r.useSearchParams)(),a=(0,r.useRouter)(),o=i.get(`q`),{isAuthenticated:s,isLoading:c}=ye(),{state:l,setters:u,messagesRef:f,chatTurns:p,sections:m}=he(t.chatId),h=(0,n.useRef)(null),[g,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{re(u.setChatModelProvider,u.setIsConfigReady,u.setHasError)},[]),(0,n.useEffect)(()=>{t.chatId&&t.chatId!==l.chatId&&(u.setChatId(t.chatId),u.setMessages([]),u.setChatHistory([]),u.setFiles([]),u.setFileIds([]),u.setIsMessagesLoaded(!1),u.setNotFound(!1),u.setNewChatCreated(!1))},[t.chatId,l.chatId]),(0,n.useEffect)(()=>{if(l.chatId&&!l.newChatCreated&&!l.isMessagesLoaded&&l.messages.length===0){if(c)return;se(l.chatId,s,u.setMessages,u.setIsMessagesLoaded,u.setChatHistory,u.setFocusMode,u.setNotFound,u.setFiles,u.setFileIds)}else l.chatId||(u.setNewChatCreated(!0),u.setIsMessagesLoaded(!0),u.setChatId(crypto.randomUUID()))},[l.chatId,l.isMessagesLoaded,l.newChatCreated,l.messages.length,s,c]),(0,n.useEffect)(()=>{if(!g&&!s&&l.chatId&&l.messages.length>0){let e=l.messages.filter(e=>e.role===`user`||e.role===`assistant`);if(e.length>0){let t=e[0].content.slice(0,50);ie({id:l.chatId,title:t,createdAt:new Date().toISOString(),focusMode:l.focusMode,files:l.files,messages:l.messages})}}},[l.messages,l.chatId,s,l.focusMode,l.files]),(0,n.useEffect)(()=>{f.current=l.messages},[l.messages]),(0,n.useEffect)(()=>{l.isMessagesLoaded&&l.isConfigReady?(u.setIsReady(!0),console.debug(new Date,`app:ready`)):u.setIsReady(!1)},[l.isMessagesLoaded,l.isConfigReady]),(0,n.useEffect)(()=>{l.isReady&&o&&l.isConfigReady&&v(o)},[l.isConfigReady,l.isReady,o]);let v=(0,n.useCallback)(async(e,t,n=!1)=>{l.chatId&&await me({message:e,messageId:t,rewrite:n},{chatId:l.chatId,loading:l.loading,messages:l.messages,fileIds:l.fileIds,focusMode:l.focusMode,category:l.category,optimizationMode:l.optimizationMode,chatHistory:l.chatHistory,chatModelProvider:l.chatModelProvider,isAuthenticated:s,messagesRef:f,abortControllerRef:h,setLoading:u.setLoading,setMessageAppeared:u.setMessageAppeared,setMessages:u.setMessages,setChatHistory:u.setChatHistory,setChatModelProvider:u.setChatModelProvider})},[l.chatId,l.loading,l.messages,l.fileIds,l.focusMode,l.category,l.optimizationMode,l.chatHistory,l.chatModelProvider,s,f]),y=(0,n.useCallback)(e=>{let t=l.messages.findIndex(t=>t.messageId===e),n=p.findIndex(t=>t.messageId===e);if(t===-1)return;let r=p[n-1];u.setMessages(e=>[...e.slice(0,l.messages.length>2?l.messages.indexOf(r):0)]),u.setChatHistory(e=>[...e.slice(0,p.length>2?n-1:0)]),v(r.content,r.messageId,!0)},[l.messages,p,v]),b=(0,n.useCallback)(()=>{h.current&&=(h.current.abort(),null)},[]),x=(0,n.useCallback)(()=>{b(),u.setMessages([]),u.setChatHistory([]),u.setFiles([]),u.setFileIds([]),u.setChatId(void 0),u.setNewChatCreated(!1),u.setIsMessagesLoaded(!1),u.setNotFound(!1),a.push(`/`)},[b,a]),S={messages:l.messages,chatTurns:p,sections:m,chatHistory:l.chatHistory,files:l.files,fileIds:l.fileIds,focusMode:l.focusMode,category:l.category,chatId:l.chatId,hasError:l.hasError,isMessagesLoaded:l.isMessagesLoaded,isReady:l.isReady,loading:l.loading,messageAppeared:l.messageAppeared,notFound:l.notFound,optimizationMode:l.optimizationMode,chatModelProvider:l.chatModelProvider,incognito:g,setFileIds:u.setFileIds,setFiles:u.setFiles,setFocusMode:u.setFocusMode,setCategory:u.setCategory,setOptimizationMode:u.setOptimizationMode,rewrite:y,sendMessage:v,setChatModelProvider:u.setChatModelProvider,stopStreaming:b,newChat:x,setIncognito:_};return(0,d.jsx)(ge.Provider,{value:S,children:e})}function xe({delayDuration:e=0,...t}){return(0,d.jsx)(m.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function J({...e}){return(0,d.jsx)(xe,{children:(0,d.jsx)(m.Root,{"data-slot":`tooltip`,...e})})}function Y({...e}){return(0,d.jsx)(m.Trigger,{"data-slot":`tooltip-trigger`,...e})}function X({className:e,sideOffset:t=0,children:n,...r}){return(0,d.jsx)(m.Portal,{children:(0,d.jsxs)(m.Content,{"data-slot":`tooltip-content`,sideOffset:t,className:E(`bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,d.jsx)(m.Arrow,{className:`bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var Se=({href:e,children:t,sources:r})=>{let{openPanel:i}=A(),a=(0,n.useMemo)(()=>!r||!e?null:r.find(t=>t.metadata?.url===e)??null,[r,e]),o=(0,n.useMemo)(()=>{try{return new URL(e).hostname.replace(`www.`,``)}catch{return a?.metadata?.source||``}},[e,a]),s=a?.metadata?.title||``,c=`https://s2.googleusercontent.com/s2/favicons?domain_url=${e}`;return(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.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,d.jsx)(X,{side:`top`,className:`max-w-72 p-2.5`,children:(0,d.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,d.jsx)(`img`,{src:c,alt:``,width:16,height:16,className:`rounded flex-shrink-0 mt-0.5`}),(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium leading-snug line-clamp-2`,children:s||o}),s&&(0,d.jsx)(`p`,{className:`text-[10px] opacity-70 truncate mt-0.5`,children:o})]})]})})]})},Ce=({content:e,thinkingEnded:t})=>{let[r,i]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{i(!t)},[t]),(0,d.jsxs)(`div`,{className:`my-4 bg-secondary/50 rounded-xl border border-border overflow-hidden`,children:[(0,d.jsxs)(`button`,{onClick:()=>i(!r),className:`w-full flex items-center justify-between px-4 py-1 text-foreground/90 hover:bg-secondary transition duration-200`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(s.BrainCircuit,{size:20,className:`text-accent-foreground`}),(0,d.jsx)(`p`,{className:`font-medium text-sm`,children:`Thinking Process`})]}),r?(0,d.jsx)(s.ChevronUp,{size:18,className:`text-muted-foreground`}):(0,d.jsx)(s.ChevronDown,{size:18,className:`text-muted-foreground`})]}),r&&(0,d.jsx)(`div`,{className:`px-4 py-3 text-foreground/80 text-sm border-t border-border bg-muted/50 whitespace-pre-wrap`,children:e})]})},we=({children:e,thinkingEnded:t})=>(0,d.jsx)(Ce,{content:e,thinkingEnded:t}),Te=({section:e,isExpanded:t,setIsExpanded:r,isEditing:i,setIsEditing:a,editText:o,setEditText:c,handleEditSubmit:l,copiedUserMsg:u,handleCopyUserMsg:f})=>{let p=(0,n.useRef)(null);return(0,d.jsxs)(`div`,{className:`w-full pt-8 break-words`,children:[(0,d.jsxs)(`button`,{onClick:()=>r(!t),className:`flex items-center gap-3 group text-left w-full`,children:[(0,d.jsx)(`div`,{className:`flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200`,children:t?(0,d.jsx)(s.ChevronDown,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`}):(0,d.jsx)(s.ChevronRight,{size:18,className:`text-muted-foreground group-hover:text-foreground transition-colors`})}),(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-0.5 mt-1 ml-10`,children:[(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:f,className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,d.jsx)(`span`,{className:E(`flex items-center transition-all duration-300`,u?`scale-110`:`scale-100`),children:u?(0,d.jsx)(s.Check,{size:14,className:`text-green-500`}):(0,d.jsx)(s.ClipboardList,{size:14})})})}),(0,d.jsx)(X,{side:`bottom`,children:u?`Copied!`:`Copy prompt`})]}),(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:()=>{c(e.userMessage.content),a(!0),setTimeout(()=>p.current?.focus(),50)},className:`p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground`,children:(0,d.jsx)(s.Pencil,{size:14})})}),(0,d.jsx)(X,{side:`bottom`,children:`Edit & resubmit`})]})]}),i&&(0,d.jsxs)(`div`,{className:`mt-3 ml-10 flex flex-col gap-2`,children:[(0,d.jsx)(`textarea`,{ref:p,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),l()),e.key===`Escape`&&a(!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,d.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,d.jsx)(`button`,{onClick:()=>a(!1),className:`px-3 py-1.5 text-sm text-muted-foreground rounded-lg hover:bg-secondary transition-colors duration-200`,children:`Cancel`}),(0,d.jsx)(`button`,{onClick:l,disabled:!o.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`})]})]})]})};function Ee({...e}){return(0,d.jsx)(h.Root,{"data-slot":`dropdown-menu`,...e})}function De({...e}){return(0,d.jsx)(h.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function Oe({className:e,sideOffset:t=4,...n}){return(0,d.jsx)(h.Portal,{children:(0,d.jsx)(h.Content,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:E(`bg-card 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 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl border p-1 shadow-md`,e),...n})})}function Z({className:e,inset:t,variant:n=`default`,...r}){return(0,d.jsx)(h.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:E(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function ke({className:e,children:t,checked:n,...r}){return(0,d.jsxs)(h.CheckboxItem,{"data-slot":`dropdown-menu-checkbox-item`,className:E(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-2xl py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,d.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,d.jsx)(h.ItemIndicator,{children:(0,d.jsx)(s.CheckIcon,{className:`size-4`})})}),t]})}function Ae({className:e,inset:t,...n}){return(0,d.jsx)(h.Label,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:E(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Q({className:e,...t}){return(0,d.jsx)(h.Separator,{"data-slot":`dropdown-menu-separator`,className:E(`bg-border -mx-1 my-1 h-px`,e),...t})}function je({...e}){return(0,d.jsx)(h.Sub,{"data-slot":`dropdown-menu-sub`,...e})}function Me({className:e,inset:t,children:n,...r}){return(0,d.jsxs)(h.SubTrigger,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:E(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8`,e),...r,children:[n,(0,d.jsx)(s.ChevronRightIcon,{className:`ml-auto size-4`})]})}function Ne({className:e,...t}){return(0,d.jsx)(h.SubContent,{"data-slot":`dropdown-menu-sub-content`,className:E(`bg-card 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 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl border p-1 shadow-lg`,e),...t})}var Pe=({section:e,initialMessage:t})=>{let[r,i]=(0,n.useState)(!1);return(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.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,d.jsx)(s.Check,{size:18}):(0,d.jsx)(s.ClipboardList,{size:18})})}),(0,d.jsx)(X,{side:`bottom`,children:r?`Copied!`:`Copy`})]})};function Fe({...e}){return(0,d.jsx)(g.Root,{"data-slot":`popover`,...e})}function Ie({...e}){return(0,d.jsx)(g.Trigger,{"data-slot":`popover-trigger`,...e})}function Le({className:e,align:t=`center`,sideOffset:n=4,container:r,...i}){return(0,d.jsx)(g.Portal,{container:r,children:(0,d.jsx)(g.Content,{"data-slot":`popover-content`,align:t,sideOffset:n,className:E(`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),...i})})}var $={Plus:s.Plus,Paperclip:s.Paperclip,Cloud:s.Cloud,Upload:s.Upload,File:s.File,SquarePen:s.SquarePen,Thinking:e=>(0,d.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,d.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})}),SelectArrow:s.ChevronDown,ArrowUp:s.ArrowUp,X:s.X,FileText:s.FileText,Loader2:s.Loader2,Check:s.Check,Archive:s.Archive,Mic:s.Mic,Stop:s.Square,Clock:e=>(0,d.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,...e,children:(0,d.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})})},Re=({messageId:e})=>{let{rewrite:t,chatModelProvider:r,setChatModelProvider:i}=q(),[a,o]=(0,n.useState)([]),[l,u]=(0,n.useState)(!0),[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{m&&(async()=>{try{u(!0);let{data:e}=await(0,c.listProviders)();o(e?.providers??[])}catch(e){console.error(`Error loading providers:`,e)}finally{u(!1)}})()},[m]);let g=(0,n.useMemo)(()=>{if(!r?.providerId)return a;let e=a.findIndex(e=>e.id===r.providerId);return e===-1?a:[a[e],...a.filter((t,n)=>n!==e)]},[a,r]).map(e=>({...e,chatModels:(e.chatModels??[]).filter(t=>t.name.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase()))})).filter(e=>e.chatModels.length>0),_=(0,n.useMemo)(()=>{if(!r.key)return`Rewrite`;for(let e of a){let t=e.chatModels.find(e=>e.key===r.key);if(t)return t.name}return r.key},[a,r.key]),v=(n,r)=>{i({providerId:n,key:r}),localStorage.setItem(`chatModelProviderId`,n),localStorage.setItem(`chatModelKey`,r),h(!1),t(e)};return(0,d.jsxs)(Fe,{open:m,onOpenChange:h,children:[(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(Ie,{asChild:!0,children:(0,d.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,d.jsx)(s.ArrowLeftRight,{size:18})})})}),(0,d.jsxs)(X,{side:`bottom`,children:[`Rewrite with `,_]})]}),(0,d.jsx)(Le,{className:`w-[280px] p-0`,align:`start`,side:`top`,sideOffset:8,children:(0,d.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,d.jsx)(`div`,{className:`p-3 border-b border-[#EEEEEE] dark:border-[#30302E]`,children:(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-text-400 dark:text-[#999999]`}),(0,d.jsx)(`input`,{type:`text`,placeholder:`Search models...`,value:f,onChange:e=>p(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,d.jsx)(`div`,{className:`max-h-[320px] overflow-y-auto`,children:l?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,d.jsx)($.Loader2,{className:`animate-spin text-text-400 dark:text-[#999999]`,size:20})}):g.length===0?(0,d.jsx)(`div`,{className:`text-center py-12 px-4 text-text-400 dark:text-[#999999] text-sm`,children:f?`No models found`:`No chat models configured`}):(0,d.jsx)(`div`,{className:`flex flex-col`,children:g.map((e,t)=>(0,d.jsxs)(`div`,{children:[(0,d.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,d.jsx)(`p`,{className:`text-[11px] text-text-400 dark:text-[#999999] uppercase tracking-wider font-medium`,children:e.name})}),(0,d.jsx)(`div`,{className:`flex flex-col px-1.5 py-1.5 space-y-0.5`,children:e.chatModels.map(t=>(0,d.jsxs)(`button`,{onClick:()=>v(e.id,t.key),type:`button`,className:E(`px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group`,r?.providerId===e.id&&r?.key===t.key?`bg-sky-50 dark:bg-sky-500/10`:`hover:bg-bg-100 dark:hover:bg-[#30302E]`),children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2.5 min-w-0 flex-1`,children:[(0,d.jsx)(s.Cpu,{size:14,className:E(`shrink-0`,r?.providerId===e.id&&r?.key===t.key?`text-sky-500`:`text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]`)}),(0,d.jsx)(`p`,{className:E(`text-[13px] truncate`,r?.providerId===e.id&&r?.key===t.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:t.name})]}),r?.providerId===e.id&&r?.key===t.key&&(0,d.jsx)($.Check,{className:`w-4 h-4 text-sky-500 shrink-0`})]},t.key))}),t<g.length-1&&(0,d.jsx)(`div`,{className:`h-px bg-[#EEEEEE] dark:bg-[#30302E] mx-2`})]},e.id))})})]})})]})},ze=new Map;function Be(e){if(typeof window>`u`)return Promise.reject(Error(`CDN scripts require a browser environment`));let t=ze.get(e);if(t)return t;let n=new Promise((t,n)=>{let r=document.querySelector(`script[data-cdn-loader="${e}"]`);if(r){r.dataset.loaded===`true`?t():(r.addEventListener(`load`,()=>t(),{once:!0}),r.addEventListener(`error`,()=>n(Error(`Failed to load ${e}`)),{once:!0}));return}let i=document.createElement(`script`);i.src=e,i.async=!0,i.dataset.cdnLoader=e,i.onload=()=>{i.dataset.loaded=`true`,t()},i.onerror=()=>{ze.delete(e),n(Error(`Failed to load ${e}`))},document.head.appendChild(i)});return ze.set(e,n),n}var Ve=`https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js`,He=`https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js`;async function Ue(){await Be(Ve);let e=window.jspdf?.jsPDF;if(!e)throw Error(`jsPDF global not found after CDN load`);return e}async function We(){await Be(He);let e=window.docx;if(!e)throw Error(`docx global not found after CDN load`);return e}async function Ge(e,t){Ye(`# ${e}\n\n${new v.default({headingStyle:`atx`,codeBlockStyle:`fenced`}).turndown(t)}`,`${e}.md`,`text/markdown`)}async function Ke(e,t){let{Document:n,Paragraph:r,TextRun:i,HeadingLevel:a,Packer:o}=await We(),s=new DOMParser().parseFromString(t,`text/html`),c=[];c.push(new r({text:e,heading:a.HEADING_1,spacing:{after:200}}));let l=e=>{if(e.nodeType===Node.TEXT_NODE){let t=e.textContent?.trim();t&&c.push(new r({children:[new i(t)]}))}else if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.tagName.toLowerCase();switch(n){case`h1`:c.push(new r({text:t.textContent||``,heading:a.HEADING_1}));break;case`h2`:c.push(new r({text:t.textContent||``,heading:a.HEADING_2}));break;case`h3`:c.push(new r({text:t.textContent||``,heading:a.HEADING_3}));break;case`p`:let e=[];t.childNodes.forEach(t=>{if(t.nodeType===Node.TEXT_NODE)e.push(new i(t.textContent||``));else if(t.nodeType===Node.ELEMENT_NODE){let n=t,r={text:n.textContent||``};(n.tagName===`STRONG`||n.tagName===`B`)&&(r.bold=!0),(n.tagName===`EM`||n.tagName===`I`)&&(r.italics=!0),n.tagName===`U`&&(r.underline={}),n.tagName===`CODE`&&(r.font=`Courier New`),e.push(new i(r))}}),e.length>0?c.push(new r({children:e})):c.push(new r({text:t.textContent||``}));break;case`ul`:case`ol`:t.querySelectorAll(`li`).forEach(e=>{c.push(new r({text:e.textContent||``,bullet:n===`ul`?{level:0}:void 0,numbering:n===`ol`?{reference:`default`,level:0}:void 0}))});break;case`blockquote`:c.push(new r({children:[new i({text:t.textContent||``,italics:!0})],indent:{left:720}}));break;default:t.childNodes.forEach(l)}}};s.body.childNodes.forEach(l);let u=new n({sections:[{properties:{},children:c}]}),d=await o.toBlob(u),f=URL.createObjectURL(d),p=document.createElement(`a`);p.href=f,p.download=`${e}.docx`,p.click(),URL.revokeObjectURL(f)}async function qe(e,t){let n=document.createElement(`div`);n.style.position=`absolute`,n.style.left=`-9999px`,n.style.width=`210mm`,n.style.padding=`20mm`,n.style.backgroundColor=`white`,n.style.fontFamily=`Arial, sans-serif`,n.style.fontSize=`12pt`,n.style.lineHeight=`1.6`,n.innerHTML=`
18
18
  <h1 style="font-size: 24pt; margin-bottom: 20px;">${e}</h1>
19
19
  ${t}
20
- `,document.body.appendChild(n);try{let t=await Ue(),r=await(0,_.default)(n,{scale:2,useCORS:!0,logging:!1}),i=r.toDataURL(`image/png`),a=new t({orientation:`portrait`,unit:`mm`,format:`a4`}),o=r.height*210/r.width,s=o,c=0;for(a.addImage(i,`PNG`,0,c,210,o),s-=297;s>=0;)c=s-o,a.addPage(),a.addImage(i,`PNG`,0,c,210,o),s-=297;a.save(`${e}.pdf`)}finally{document.body.removeChild(n)}}async function Je(e,t){try{let n=`${e}\n\n${new v.default().turndown(t)}`;await navigator.clipboard.writeText(n),window.open(`https://docs.google.com/document/create`,`_blank`),alert(`Content copied to clipboard! Paste it into the new Google Doc.`)}catch(e){console.error(`Failed to export to Google Docs:`,e),alert(`Failed to copy content to clipboard. Please try again.`)}}function Ye(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}var Xe=({section:e,speechStatus:t,start:n,stop:r,handleOpenInLLM:i})=>e.assistantMessage?(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2`,children:(0,d.jsxs)(`div`,{className:`flex flex-row items-center space-x-1`,children:[(0,d.jsx)(Re,{messageId:e.assistantMessage.messageId}),(0,d.jsx)(Pe,{initialMessage:e.assistantMessage.content,section:e}),(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:()=>{t===`started`?r():n()},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:t===`started`?(0,d.jsx)(s.StopCircle,{size:18}):(0,d.jsx)(s.Volume2,{size:18})})}),(0,d.jsx)(xe,{side:`bottom`,children:t===`started`?`Stop`:`Read aloud`})]}),(0,d.jsxs)(Ee,{children:[(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(De,{asChild:!0,children:(0,d.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,d.jsx)(s.Download,{size:18})})})}),(0,d.jsx)(xe,{side:`bottom`,children:`Export`})]}),(0,d.jsxs)(Oe,{align:`end`,side:`top`,children:[(0,d.jsxs)(Z,{onClick:()=>Ge(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileText,{size:16}),`Markdown`]}),(0,d.jsxs)(Z,{onClick:()=>qe(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileType,{size:16}),`PDF`]}),(0,d.jsxs)(Z,{onClick:()=>Ke(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileDown,{size:16}),`DOCX`]}),(0,d.jsxs)(Z,{onClick:()=>Je(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileSpreadsheet,{size:16}),`Google Docs`]})]})]}),(0,d.jsxs)(Ee,{children:[(0,d.jsxs)(Y,{children:[(0,d.jsx)(X,{asChild:!0,children:(0,d.jsx)(De,{asChild:!0,children:(0,d.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,d.jsx)(s.ExternalLink,{size:18})})})}),(0,d.jsx)(xe,{side:`bottom`,children:`Open in LLM`})]}),(0,d.jsxs)(Oe,{align:`end`,side:`top`,children:[(0,d.jsx)(Z,{onClick:()=>i(`qwksearch`),children:`QwkSearch`}),(0,d.jsx)(Z,{onClick:()=>i(`claude`),children:`Claude`}),(0,d.jsx)(Z,{onClick:()=>i(`perplexity`),children:`Perplexity`}),(0,d.jsx)(Z,{onClick:()=>i(`gemini`),children:`Google Gemini`}),(0,d.jsx)(Z,{onClick:()=>i(`chatgpt`),children:`ChatGPT`})]})]})]})}):null,Ze=(0,b.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 Qe({className:e,variant:t,asChild:n=!1,...r}){return(0,d.jsx)(n?y.Slot:`span`,{"data-slot":`badge`,className:E(Ze({variant:t}),e),...r})}var $e=({section:e,isLast:t,loading:r,sendMessage:i})=>{let a=(0,n.useRef)([]);return(0,n.useEffect)(()=>{e.suggestions&&e.suggestions.length>0&&(a.current=e.suggestions.slice(0,5))},[e.suggestions]),(0,n.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&&a.current.length>=r&&(e.preventDefault(),i(a.current[r-1]))};if(t&&a.current.length>0)return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]),!e.suggestions||e.suggestions.length===0||!e.assistantMessage?null:(0,d.jsx)(`div`,{className:`mt-8 pt-6 border-t border-border/50`,children:(0,d.jsx)(`div`,{className:`space-y-2`,children:e.suggestions?.slice(0,5).map((e,t)=>(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(Qe,{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,d.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,d.jsx)(s.Plus,{size:18,className:`text-muted-foreground/60 group-hover:text-primary transition-colors duration-200 flex-shrink-0`})]})},t))})})},et=({section:e,dividerRef:t,isLast:r})=>{let{loading:i,sendMessage:a}=J(),[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(!1),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(e.userMessage.content),g=()=>{navigator.clipboard.writeText(e.userMessage.content),u(!0),setTimeout(()=>u(!1),1500)},_=()=>{m.trim()&&(a(m.trim()),p(!1))},v=e.parsedAssistantMessage||``,y=e.speechMessage||``,b=e.thinkingEnded,{speechStatus:x,start:S,stop:C}=ne(y,{enableInterrupt:!0}),w=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`)},T={overrides:{think:{component:we,props:{thinkingEnded:b}},citation:{component:Se,props:{sources:e.sourceMessage?.sources||[]}},table:{component:({children:e,...t})=>(0,d.jsx)(`div`,{className:`not-prose -mx-2 my-4 max-w-full overflow-x-auto sm:mx-0`,children:(0,d.jsx)(`table`,{...t,className:`w-max min-w-full border-collapse text-sm`,children:e})})}}};return(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsx)(Te,{section:e,isExpanded:s,setIsExpanded:c,isEditing:f,setIsEditing:p,editText:m,setEditText:h,handleEditSubmit:_,copiedUserMsg:l,handleCopyUserMsg:g}),(0,d.jsx)(`div`,{className:E(`flex flex-col space-y-3 overflow-hidden transition-all duration-300 ease-in-out`,s?`max-h-[100000px] opacity-100`:`max-h-0 opacity-0`),children:(0,d.jsxs)(`div`,{ref:t,className:`flex flex-col space-y-6 w-full`,children:[e.searchingMessage&&e.searchingMessage.queries.length>0&&(0,d.jsx)(H,{queries:e.searchingMessage.queries,loading:i&&r}),e.sourceMessage&&e.sourceMessage.sources.length>0&&(0,d.jsx)(`div`,{className:`flex flex-col space-y-2`,children:(0,d.jsx)(B,{sources:e.sourceMessage.sources,query:e.userMessage.content})}),(0,d.jsx)(`div`,{className:`flex min-w-0 flex-col space-y-2`,children:e.assistantMessage&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o.default,{className:E(`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:T,children:v}),i&&r?null:(0,d.jsx)(Xe,{section:e,speechStatus:x,start:S,stop:C,handleOpenInLLM:w}),(0,d.jsx)($e,{section:e,isLast:r,loading:i,sendMessage:a})]})})]})})]})},tt=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(2))+` `+n[r]},nt=({file:e,onRemove:t})=>(0,d.jsxs)(`div`,{className:`relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400`,children:[e.type.startsWith(`image/`)&&e.preview?(0,d.jsxs)(`div`,{className:`w-full h-full relative`,children:[(0,d.jsx)(`img`,{src:e.preview,alt:e.file.name,className:`w-full h-full object-cover`}),(0,d.jsx)(`div`,{className:`absolute inset-0 bg-black/20 group-hover:bg-black/0 transition-colors`})]}):(0,d.jsxs)(`div`,{className:`w-full h-full p-3 flex flex-col justify-between`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`p-1.5 bg-bg-300 rounded`,children:(0,d.jsx)($.FileText,{className:`w-4 h-4 text-text-300`})}),(0,d.jsx)(`span`,{className:`text-[10px] font-medium text-text-400 uppercase tracking-wider truncate`,children:e.file.name.split(`.`).pop()})]}),(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-text-200 truncate`,title:e.file.name,children:e.file.name}),(0,d.jsx)(`p`,{className:`text-[10px] text-text-500`,children:tt(e.file.size)})]})]}),(0,d.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-1 right-1 p-1 bg-black/50 hover:bg-black/70 rounded-full text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,d.jsx)($.X,{className:`w-3 h-3`})}),e.uploadStatus===`uploading`&&(0,d.jsx)(`div`,{className:`absolute inset-0 bg-black/40 flex items-center justify-center`,children:(0,d.jsx)($.Loader2,{className:`w-5 h-5 text-white animate-spin`})}),e.uploadStatus===`error`&&(0,d.jsx)(`div`,{className:`absolute inset-0 bg-red-900/60 flex items-center justify-center`,children:(0,d.jsx)($.X,{className:`w-5 h-5 text-red-300`})})]}),rt=({content:e,onRemove:t})=>(0,d.jsxs)(`div`,{className:`relative group flex-shrink-0 w-28 h-28 rounded-2xl overflow-hidden border border-[#E5E5E5] dark:border-[#30302E] bg-white dark:bg-[#20201F] animate-fade-in p-3 flex flex-col justify-between shadow-[0_1px_2px_rgba(0,0,0,0.05)]`,children:[(0,d.jsx)(`div`,{className:`overflow-hidden w-full`,children:(0,d.jsx)(`p`,{className:`text-[10px] text-[#9CA3AF] leading-[1.4] font-mono break-words whitespace-pre-wrap line-clamp-4 select-none`,children:e.content})}),(0,d.jsx)(`div`,{className:`flex items-center justify-between w-full mt-2`,children:(0,d.jsx)(`div`,{className:`inline-flex items-center justify-center px-1.5 py-[2px] rounded border border-[#E5E5E5] dark:border-[#404040] bg-white dark:bg-transparent`,children:(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-[#6B7280] dark:text-[#9CA3AF] uppercase tracking-wider font-sans`,children:`PASTED`})})}),(0,d.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-2 right-2 p-[3px] bg-white dark:bg-[#30302E] border border-[#E5E5E5] dark:border-[#404040] rounded-full text-[#9CA3AF] hover:text-[#6B7280] dark:hover:text-white transition-colors shadow-sm opacity-0 group-hover:opacity-100`,children:(0,d.jsx)($.X,{className:`w-2 h-2`})})]});function it(e,t){let[r,i]=(0,n.useState)(!1),a=(0,n.useRef)(null),o=(0,n.useRef)(null),s=(0,n.useRef)(null),c=(0,n.useRef)([]),l=(0,n.useRef)(!1),u=(0,n.useRef)(!1),d=typeof window<`u`?window.SpeechRecognition||window.webkitSpeechRecognition:null,m=()=>{let e=o.current;e&&e.state!==`inactive`?e.stop():(s.current?.getTracks().forEach(e=>e.stop()),s.current=null,o.current=null,i(!1),t())},h=async e=>{let t=new FormData;return t.append(`file`,e,`speech-input.webm`),t.append(`languageCode`,`en`),((await(0,f.default)(`/api/agent/transcript`,{method:`POST`,body:t}))?.text??``).trim()},g=async()=>{if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){p.toast.error(`Speech input is not supported in this browser`,{duration:5e3}),i(!1),t();return}try{let n=await navigator.mediaDevices.getUserMedia({audio:!0}),r=new MediaRecorder(n);c.current=[],s.current=n,o.current=r,r.ondataavailable=e=>{e.data.size>0&&c.current.push(e.data)},r.onstart=()=>{i(!0)},r.onstop=async()=>{try{let n=new Blob(c.current,{type:`audio/webm`});if(c.current=[],s.current?.getTracks().forEach(e=>e.stop()),s.current=null,o.current=null,i(!1),n.size===0){t();return}let r=await h(n);r?e(r):p.toast.error(`No speech detected. Please try again.`)}catch{p.toast.error(`Unable to transcribe audio.`)}finally{t()}},r.start()}catch{p.toast.error(`Microphone access is required for speech input.`),i(!1),t()}},_=async()=>{if(r){a.current?.stop(),m();return}if(u.current=!1,l.current=!1,!d){await g();return}let n=new d;n.continuous=!1,n.interimResults=!1,n.lang=`en-US`,n.onstart=()=>i(!0),n.onresult=t=>{let n=t.results[0][0].transcript;l.current=!0,e(n)},n.onend=async()=>{if(i(!1),a.current=null,u.current){u.current=!1;return}t()},n.onerror=async e=>{i(!1),a.current=null;let t=e?.error;if(!l.current&&t!==`aborted`){u.current=!0,await g();return}},a.current=n;try{n.start()}catch{a.current=null,i(!1),await g()}};(0,n.useEffect)(()=>{let e=e=>{e.ctrlKey&&e.key==="`"&&(e.preventDefault(),_())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),a.current?.stop(),m()}},[r]);let v=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`;return{isListening:r,toggleSpeech:_,isSpeechSupported:!!d||v}}var at=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],ot=10,st=50*1024*1024,ct=(e,t)=>{if(e&&typeof e==`object`){let t=e.message??e.error??e.data?.message;if(typeof t==`string`&&t.length>0)return t}return typeof e==`string`&&e.length>0?e:t};function lt({setMessage:e,contextFiles:t,contextFileIds:r,setContextFiles:i,setContextFileIds:a}){let[o,s]=(0,n.useState)([]),[l,u]=(0,n.useState)([]),[d,f]=(0,n.useState)(!1),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(async e=>{let n=Array.from(e);n.length>ot&&(p.toast.error(`You can attach up to ${ot} files at a time.`),n=n.slice(0,ot));let o=n.filter(e=>e.size>st);if(o.length>0&&(p.toast.error(`${o.map(e=>e.name).join(`, `)} exceed${o.length===1?`s`:``} the 50 MB per-file limit.`),n=n.filter(e=>e.size<=st)),n.length===0)return;let l=n.map(e=>{let t=e.type.startsWith(`image/`)||/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name),n=e.name.split(`.`).pop()?.toLowerCase()??``,r=at.includes(n);return{id:Math.random().toString(36).substr(2,9),file:e,type:t?`image/unknown`:e.type||`application/octet-stream`,preview:t?URL.createObjectURL(e):null,uploadStatus:r?`uploading`:`pending`,_ext:n}});s(e=>[...e,...l]),l.filter(e=>!at.includes(e._ext)).forEach(e=>{setTimeout(()=>{s(t=>t.map(t=>t.id===e.id?{...t,uploadStatus:`complete`}:t))},600+Math.random()*600)});let u=l.filter(e=>at.includes(e._ext));if(u.length!==0)try{let{data:e,error:n}=await(0,c.uploadFiles)({body:{files:u.map(e=>e.file)}});if(n||!e?.files)throw Error(ct(n??e,`Upload failed.`));s(e=>e.map(e=>u.some(t=>t.id===e.id)?{...e,uploadStatus:`complete`}:e)),i([...t,...e.files]),a([...r,...e.files.map(e=>e.fileId)])}catch(e){p.toast.error(ct(e,`Failed to upload files.`)),s(e=>e.map(e=>u.some(t=>t.id===e.id)?{...e,uploadStatus:`error`}:e))}},[e,t,r,i,a]);return{files:o,setFiles:s,pastedContent:l,setPastedContent:u,isDragging:d,isExtractingUrl:m,handleFiles:g,extractUrl:(0,n.useCallback)(async e=>{let n=e.trim();if(!/^https?:\/\//i.test(n))return p.toast.error(`Enter a valid http(s) URL.`),!1;h(!0);try{let e=await(await fetch(`/api/doc/uploads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:n})})).json();if(!e?.files||e.files.length===0)throw Error(ct(e,`Could not extract content from ${n}`));return i([...t,...e.files]),a([...r,...e.files.map(e=>e.fileId)]),p.toast.success(`Added "${e.files[0].fileName}" as context.`),!0}catch(e){return p.toast.error(ct(e,`Failed to extract URL.`)),!1}finally{h(!1)}},[t,r,i,a]),onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:e=>{e.preventDefault(),f(!1)},onDrop:e=>{e.preventDefault(),f(!1),e.dataTransfer.files&&g(e.dataTransfer.files)},handlePaste:e=>{let t=e.clipboardData.items,n=[];for(let e=0;e<t.length;e++)if(t[e].kind===`file`){let r=t[e].getAsFile();r&&n.push(r)}if(n.length>0){e.preventDefault(),g(n);return}let r=e.clipboardData.getData(`text`);if(r.length>300){e.preventDefault();let t={id:Math.random().toString(36).substr(2,9),content:r,timestamp:new Date};u(e=>[...e,t])}},resetAttachments:()=>{s([]),u([]),i([]),a([])}}}var ut=()=>window.gapi,dt=()=>window.google,ft=()=>{let e=(0,n.useRef)(!1),r=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{ut()?r.current=!0:(()=>{let e=document.createElement(`script`);e.src=`https://apis.google.com/js/api.js`,e.onload=()=>{ut()?.load(`client:picker`,()=>{r.current=!0})},document.body.appendChild(e)})(),dt()?.picker?e.current=!0:(()=>{let t=document.createElement(`script`);t.src=`https://www.google.com/jsapi`,t.onload=()=>{e.current=!0},document.body.appendChild(t)})()},[]),{openPicker:async(e,n,i)=>{let a=dt();if(!r.current||!a?.picker){i?.(`Google Picker API not loaded yet. Please try again.`);return}try{let{picker:r}=a;new r.PickerBuilder().addView(r.ViewId.DOCS).addView(r.ViewId.DOCS_IMAGES).addView(r.ViewId.DOCS_VIDEOS).addView(new r.DocsView().setIncludeFolders(!0).setMimeTypes(`application/pdf,application/vnd.google-apps.document,application/vnd.google-apps.spreadsheet,text/plain,image/jpeg,image/png`)).setOAuthToken(e).setDeveloperKey(t.researchAgentUIConfig.googleApiKey).setCallback(e=>{if(e.action===r.Action.PICKED){let t=e.docs;t&&n(t)}else e.action===r.Action.CANCEL&&console.log(`User cancelled picker`)}).build().setVisible(!0)}catch(e){i?.(e.message||`Failed to open Google Picker`)}}}},pt=()=>{let{chatModelProvider:e,setChatModelProvider:t}=J(),[i,a]=(0,n.useState)([]),[o,l]=(0,n.useState)(!0),u=(0,r.useRouter)();(0,n.useEffect)(()=>{(async()=>{try{l(!0);let{data:n}=await(0,c.listProviders)(),r=n?.providers??[];if(a(r),!e.key&&r.length>0){let e=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`);if(e&&n)t({key:e,providerId:n});else{let e=r.find(e=>e.chatModels.length>0);e&&t({key:e.chatModels[0].key,providerId:e.id})}}}catch(e){console.error(`Error loading providers:`,e)}finally{l(!1)}})()},[]);let f=(0,n.useMemo)(()=>{if(!e.key)return`Select`;for(let t of i){let n=t.chatModels.find(t=>t.key===e.key);if(n)return n.name}return e.key},[i,e.key]),p=(e,n)=>{t({providerId:e,key:n}),localStorage.setItem(`chatModelProviderId`,e),localStorage.setItem(`chatModelKey`,n)};return(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Cpu,{className:`w-4 h-4 flex-shrink-0 text-sky-500`}),(0,d.jsx)(`span`,{children:`Model`}),(0,d.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground truncate max-w-[55px]`,children:f})]}),(0,d.jsxs)(Ne,{className:`w-52 max-h-[400px] overflow-y-auto`,children:[o?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,d.jsx)(s.Loader2,{className:`h-4 w-4 animate-spin text-muted-foreground`})}):i.length===0?(0,d.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No models configured`}):i.map((t,n)=>(0,d.jsxs)(`div`,{children:[(0,d.jsx)(Ae,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:t.name}),t.chatModels.map(n=>(0,d.jsxs)(Z,{onSelect:()=>p(t.id,n.key),className:E(`gap-2`,e?.providerId===t.id&&e?.key===n.key&&`bg-secondary`),children:[(0,d.jsx)(s.Cpu,{className:E(`h-3.5 w-3.5 flex-shrink-0`,e?.providerId===t.id&&e?.key===n.key?`text-sky-500`:`text-muted-foreground`)}),(0,d.jsx)(`span`,{className:`truncate`,children:n.name}),e?.providerId===t.id&&e?.key===n.key&&(0,d.jsx)(`svg`,{className:`w-3 h-3 text-primary ml-auto shrink-0`,fill:`none`,viewBox:`0 0 10 10`,children:(0,d.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},n.key)),n<i.length-1&&(0,d.jsx)(Q,{})]},t.id)),(0,d.jsx)(Q,{}),(0,d.jsxs)(Z,{onSelect:()=>u.push(`/settings?section=models`),className:`gap-2`,children:[(0,d.jsx)(s.Plus,{className:`h-3.5 w-3.5 text-sky-500 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Add model`})]})]})]})},mt=[{label:`5s`,value:5},{label:`15s`,value:15},{label:`30s`,value:30},{label:`45s`,value:45},{label:`60s`,value:60},{label:`Unlimited`,value:0}],ht=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],gt=`markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org`.split(`.`),_t=({onFileSelect:e,disabled:t=!1})=>{let i=(0,r.useRouter)(),{category:a,setCategory:o,incognito:l,setIncognito:u,sections:f,chatId:m}=J(),{isAuthenticated:h}=ve(),g=a?a.split(`,`).filter(Boolean):[`general`],_=z.find(e=>e.code===g[0])||z[0],v=e=>{let t=a?a.split(`,`).filter(Boolean):[`general`],n=t.includes(e)?t.filter(t=>t!==e):[...t,e];o(n.length>0?n.join(`,`):`general`)},[y,b]=(0,n.useState)(!1),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,D]=(0,n.useState)(!1),[O,k]=(0,n.useState)(()=>{if(typeof window>`u`)return 5;let e=Number(localStorage.getItem(`thinkingTimeLimit`)??`5`);return Number.isFinite(e)?e:5}),A=n.default.useRef(null),{openPicker:j}=ft();(0,n.useEffect)(()=>{M()},[]);let M=async()=>{try{let{data:e}=await(0,c.googleDocsAuthStatus)();b(e?.isConnected||!1)}catch{}},N=e=>{k(e),localStorage.setItem(`thinkingTimeLimit`,String(e))},P=async()=>{if(`showOpenFilePicker`in window)try{let t=await window.showOpenFilePicker({multiple:!0,types:[{description:`Supported files`,accept:{"application/pdf":[`.pdf`],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[`.docx`],"text/plain":[`.txt`],"text/markdown":[`.md`],"text/html":[`.html`,`.htm`],"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]}}]}),n=await Promise.all(t.map(e=>e.getFile()));n.length>0&&e(n)}catch(e){e?.name!==`AbortError`&&(console.error(`Failed to open file picker:`,e),A.current?.click())}else A.current?.click()};async function F(e,t=``){let n=[];for await(let r of e.values())if(r.kind===`file`){let e=await r.getFile(),i=e.name.split(`.`).pop()?.toLowerCase()??``;if(ht.includes(i))n.push(e);else if(gt.includes(i))try{let r=await e.text(),i=t?`${t}/${e.name}`:e.name;n.push(new File([r],`${i.replace(/[/\\]/g,`_`)}.txt`,{type:`text/plain`}))}catch{}}else if(r.kind===`directory`){let e=r;if(e.name.startsWith(`.`)||e.name===`node_modules`||e.name===`__pycache__`)continue;n.push(...await F(e,t?`${t}/${e.name}`:e.name))}return n}let I=async()=>{if(!(`showDirectoryPicker`in window)){alert(`Your browser does not support the File System Access API. Please use Chrome or Edge.`);return}D(!0);try{let t=await F(await window.showDirectoryPicker({mode:`read`}));t.length>0?e(t):alert(`No supported files found in the selected folder.`)}catch(e){e?.name!==`AbortError`&&console.error(`Failed to access folder:`,e)}finally{D(!1)}},L=async()=>{S(!0);try{let{data:e}=await(0,c.googleDocsAuth)();if(e?.success&&e?.data?.authUrl){let t=e.data.authUrl,n=window.screenX+(window.outerWidth-600)/2,r=window.screenY+(window.outerHeight-700)/2,i=window.open(t,`Google Drive Authorization`,`width=600,height=700,left=${n},top=${r}`),a=e=>{e.data.type===`google-drive-connected`&&(b(!0),i?.close(),window.removeEventListener(`message`,a))};window.addEventListener(`message`,a)}}catch{console.error(`Failed to connect to Google Drive`)}finally{S(!1)}},R=async()=>{try{let{data:t}=await(0,c.getGoogleToken)();if(!t?.success||!t.accessToken)throw Error(`Failed to get access token`);await j(t.accessToken,async t=>{w(!0);try{let n=[];for(let e of t){let{data:t}=await(0,c.getGoogleDriveFile)({query:{fileId:e.id}});if(t?.success&&t?.file){let e=atob(t.file.content),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);n.push(new File([new Blob([r],{type:t.file.mimeType})],t.file.name,{type:t.file.mimeType}))}}n.length>0&&e(n)}catch{alert(`Failed to load files from Google Drive`)}finally{w(!1)}},e=>{console.error(`Google Picker error:`,e),alert(e)})}catch(e){alert(e.message||`Failed to open Google Drive picker`)}},ee=mt.find(e=>e.value===O)?.label??`Unlimited`;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`relative flex shrink min-w-8 !shrink-0 group`,children:[(0,d.jsxs)(Ee,{children:[(0,d.jsx)(De,{asChild:!0,children:(0,d.jsx)(`button`,{disabled:t,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-8 w-8 rounded-lg active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,type:`button`,"aria-label":`Search options`,children:(0,d.jsx)(s.SlidersHorizontal,{className:`w-5 h-5`})})}),(0,d.jsxs)(Oe,{align:`start`,side:`top`,sideOffset:8,className:`w-44`,children:[(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[_&&(0,d.jsx)(_.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Category`})]}),(0,d.jsxs)(Ne,{className:`w-44`,children:[(0,d.jsxs)(ke,{checked:g.length===0,onCheckedChange:()=>o(`general`),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,d.jsx)(`div`,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`None`})]}),(0,d.jsx)(Q,{}),z.map(e=>(0,d.jsxs)(ke,{checked:g.includes(e.code),onCheckedChange:()=>v(e.code),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[e.icon&&(0,d.jsx)(e.icon,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:e.name})]},e.code))]})]}),(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Clock,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Speed`}),(0,d.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:ee})]}),(0,d.jsx)(Ne,{className:`w-36`,children:mt.map(e=>(0,d.jsxs)(Z,{onSelect:()=>N(e.value),className:E(`justify-between`,O===e.value&&`bg-secondary`),children:[(0,d.jsx)(`span`,{children:e.label}),O===e.value&&(0,d.jsx)(`svg`,{className:`w-3 h-3 text-primary`,fill:`none`,viewBox:`0 0 10 10`,children:(0,d.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},e.value))})]}),(0,d.jsx)(Q,{}),(0,d.jsx)(pt,{}),(0,d.jsx)(Q,{}),(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Upload,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Upload`})]}),(0,d.jsxs)(Ne,{className:`w-44`,children:[(0,d.jsxs)(Z,{onSelect:P,className:`gap-2`,children:[(0,d.jsx)(s.Upload,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Your Device`})]}),(0,d.jsxs)(Z,{onSelect:I,disabled:T,className:`gap-2`,children:[T?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.FolderOpen,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:T?`Scanning…`:`Local Folder`})]}),(0,d.jsx)(Q,{}),(0,d.jsx)(Ae,{className:`text-xs font-normal text-muted-foreground`,children:`Cloud`}),y?(0,d.jsxs)(Z,{onSelect:R,disabled:C,className:`gap-2`,children:[C?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:C?`Loading…`:`Google Drive`})]}):(0,d.jsxs)(Z,{onSelect:L,disabled:x,className:`gap-2`,children:[x?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:x?`Connecting…`:`Connect Google Drive`})]})]})]}),(0,d.jsx)(Q,{}),(0,d.jsxs)(ke,{checked:l,onCheckedChange:u,onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,d.jsx)(s.EyeOff,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Private`})]}),(0,d.jsx)(Q,{}),f.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Share2,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Share`})]}),(0,d.jsxs)(Ne,{className:`w-48`,children:[(0,d.jsxs)(Z,{onSelect:async()=>{if(!m){p.toast.error(`No chat to share`);return}if(!h){p.toast.error(`Please sign in to share chats`);return}try{let{data:e,error:t}=await(0,c.shareChat)({body:{chatId:m}});if(!t&&e?.success&&e?.data?.shareUrl)await navigator.clipboard.writeText(e.data.shareUrl),p.toast.success(`Chat is now public - link copied to clipboard`);else throw Error(t?.error||`Failed to share chat`)}catch(e){console.error(`Error sharing chat:`,e);let t=e instanceof Error?e.message:`Failed to share chat`;p.toast.error(t)}},className:`gap-2`,children:[(0,d.jsx)(s.Link,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Copy link`})]}),(0,d.jsxs)(Z,{onSelect:async()=>{let e=f[0]?.userMessage?.content||`Chat`,t=f.map(e=>`## ${e.userMessage.content}\n\n${e.assistantMessage?.content||``}`).join(`
20
+ `,document.body.appendChild(n);try{let t=await Ue(),r=await(0,_.default)(n,{scale:2,useCORS:!0,logging:!1}),i=r.toDataURL(`image/png`),a=new t({orientation:`portrait`,unit:`mm`,format:`a4`}),o=r.height*210/r.width,s=o,c=0;for(a.addImage(i,`PNG`,0,c,210,o),s-=297;s>=0;)c=s-o,a.addPage(),a.addImage(i,`PNG`,0,c,210,o),s-=297;a.save(`${e}.pdf`)}finally{document.body.removeChild(n)}}async function Je(e,t){try{let n=`${e}\n\n${new v.default().turndown(t)}`;await navigator.clipboard.writeText(n),window.open(`https://docs.google.com/document/create`,`_blank`),alert(`Content copied to clipboard! Paste it into the new Google Doc.`)}catch(e){console.error(`Failed to export to Google Docs:`,e),alert(`Failed to copy content to clipboard. Please try again.`)}}function Ye(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}var Xe=({section:e,speechStatus:t,start:n,stop:r,handleOpenInLLM:i})=>e.assistantMessage?(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2`,children:(0,d.jsxs)(`div`,{className:`flex flex-row items-center space-x-1`,children:[(0,d.jsx)(Re,{messageId:e.assistantMessage.messageId}),(0,d.jsx)(Pe,{initialMessage:e.assistantMessage.content,section:e}),(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(`button`,{onClick:()=>{t===`started`?r():n()},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:t===`started`?(0,d.jsx)(s.StopCircle,{size:18}):(0,d.jsx)(s.Volume2,{size:18})})}),(0,d.jsx)(X,{side:`bottom`,children:t===`started`?`Stop`:`Read aloud`})]}),(0,d.jsxs)(Ee,{children:[(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(De,{asChild:!0,children:(0,d.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,d.jsx)(s.Download,{size:18})})})}),(0,d.jsx)(X,{side:`bottom`,children:`Export`})]}),(0,d.jsxs)(Oe,{align:`end`,side:`top`,children:[(0,d.jsxs)(Z,{onClick:()=>Ge(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileText,{size:16}),`Markdown`]}),(0,d.jsxs)(Z,{onClick:()=>qe(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileType,{size:16}),`PDF`]}),(0,d.jsxs)(Z,{onClick:()=>Ke(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileDown,{size:16}),`DOCX`]}),(0,d.jsxs)(Z,{onClick:()=>Je(e.userMessage.content,e.assistantMessage.content),children:[(0,d.jsx)(s.FileSpreadsheet,{size:16}),`Google Docs`]})]})]}),(0,d.jsxs)(Ee,{children:[(0,d.jsxs)(J,{children:[(0,d.jsx)(Y,{asChild:!0,children:(0,d.jsx)(De,{asChild:!0,children:(0,d.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,d.jsx)(s.ExternalLink,{size:18})})})}),(0,d.jsx)(X,{side:`bottom`,children:`Open in LLM`})]}),(0,d.jsxs)(Oe,{align:`end`,side:`top`,children:[(0,d.jsx)(Z,{onClick:()=>i(`qwksearch`),children:`QwkSearch`}),(0,d.jsx)(Z,{onClick:()=>i(`claude`),children:`Claude`}),(0,d.jsx)(Z,{onClick:()=>i(`perplexity`),children:`Perplexity`}),(0,d.jsx)(Z,{onClick:()=>i(`gemini`),children:`Google Gemini`}),(0,d.jsx)(Z,{onClick:()=>i(`chatgpt`),children:`ChatGPT`})]})]})]})}):null,Ze=(0,b.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 Qe({className:e,variant:t,asChild:n=!1,...r}){return(0,d.jsx)(n?y.Slot:`span`,{"data-slot":`badge`,className:E(Ze({variant:t}),e),...r})}var $e=({section:e,isLast:t,loading:r,sendMessage:i})=>{let a=(0,n.useRef)([]);return(0,n.useEffect)(()=>{e.suggestions&&e.suggestions.length>0&&(a.current=e.suggestions.slice(0,5))},[e.suggestions]),(0,n.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&&a.current.length>=r&&(e.preventDefault(),i(a.current[r-1]))};if(t&&a.current.length>0)return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i]),!e.suggestions||e.suggestions.length===0||!e.assistantMessage?null:(0,d.jsx)(`div`,{className:`mt-8 pt-6 border-t border-border/50`,children:(0,d.jsx)(`div`,{className:`space-y-2`,children:e.suggestions?.slice(0,5).map((e,t)=>(0,d.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,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(Qe,{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,d.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,d.jsx)(s.Plus,{size:18,className:`text-muted-foreground/60 group-hover:text-primary transition-colors duration-200 flex-shrink-0`})]})},t))})})},et=({section:e,dividerRef:t,isLast:r})=>{let{loading:i,sendMessage:a}=q(),[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(!1),[f,p]=(0,n.useState)(!1),[m,h]=(0,n.useState)(e.userMessage.content),g=()=>{navigator.clipboard.writeText(e.userMessage.content),u(!0),setTimeout(()=>u(!1),1500)},_=()=>{m.trim()&&(a(m.trim()),p(!1))},v=e.parsedAssistantMessage||``,y=e.speechMessage||``,b=e.thinkingEnded,{speechStatus:x,start:S,stop:C}=H(y,{enableInterrupt:!0}),w=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`)},T={overrides:{think:{component:we,props:{thinkingEnded:b}},citation:{component:Se,props:{sources:e.sourceMessage?.sources||[]}},table:{component:({children:e,...t})=>(0,d.jsx)(`div`,{className:`not-prose -mx-2 my-4 max-w-full overflow-x-auto sm:mx-0`,children:(0,d.jsx)(`table`,{...t,className:`w-max min-w-full border-collapse text-sm`,children:e})})}}};return(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsx)(Te,{section:e,isExpanded:s,setIsExpanded:c,isEditing:f,setIsEditing:p,editText:m,setEditText:h,handleEditSubmit:_,copiedUserMsg:l,handleCopyUserMsg:g}),(0,d.jsx)(`div`,{className:E(`flex flex-col space-y-3 overflow-hidden transition-all duration-300 ease-in-out`,s?`max-h-[100000px] opacity-100`:`max-h-0 opacity-0`),children:(0,d.jsxs)(`div`,{ref:t,className:`flex flex-col space-y-6 w-full`,children:[e.searchingMessage&&e.searchingMessage.queries.length>0&&(0,d.jsx)(V,{queries:e.searchingMessage.queries,loading:i&&r}),e.sourceMessage&&e.sourceMessage.sources.length>0&&(0,d.jsx)(`div`,{className:`flex flex-col space-y-2`,children:(0,d.jsx)(te,{sources:e.sourceMessage.sources,query:e.userMessage.content})}),(0,d.jsx)(`div`,{className:`flex min-w-0 flex-col space-y-2`,children:e.assistantMessage&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o.default,{className:E(`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:T,children:v}),i&&r?null:(0,d.jsx)(Xe,{section:e,speechStatus:x,start:S,stop:C,handleOpenInLLM:w}),(0,d.jsx)($e,{section:e,isLast:r,loading:i,sendMessage:a})]})})]})})]})},tt=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(2))+` `+n[r]},nt=({file:e,onRemove:t})=>(0,d.jsxs)(`div`,{className:`relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400`,children:[e.type.startsWith(`image/`)&&e.preview?(0,d.jsxs)(`div`,{className:`w-full h-full relative`,children:[(0,d.jsx)(`img`,{src:e.preview,alt:e.file.name,className:`w-full h-full object-cover`}),(0,d.jsx)(`div`,{className:`absolute inset-0 bg-black/20 group-hover:bg-black/0 transition-colors`})]}):(0,d.jsxs)(`div`,{className:`w-full h-full p-3 flex flex-col justify-between`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`div`,{className:`p-1.5 bg-bg-300 rounded`,children:(0,d.jsx)($.FileText,{className:`w-4 h-4 text-text-300`})}),(0,d.jsx)(`span`,{className:`text-[10px] font-medium text-text-400 uppercase tracking-wider truncate`,children:e.file.name.split(`.`).pop()})]}),(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-text-200 truncate`,title:e.file.name,children:e.file.name}),(0,d.jsx)(`p`,{className:`text-[10px] text-text-500`,children:tt(e.file.size)})]})]}),(0,d.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-1 right-1 p-1 bg-black/50 hover:bg-black/70 rounded-full text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,d.jsx)($.X,{className:`w-3 h-3`})}),e.uploadStatus===`uploading`&&(0,d.jsx)(`div`,{className:`absolute inset-0 bg-black/40 flex items-center justify-center`,children:(0,d.jsx)($.Loader2,{className:`w-5 h-5 text-white animate-spin`})}),e.uploadStatus===`error`&&(0,d.jsx)(`div`,{className:`absolute inset-0 bg-red-900/60 flex items-center justify-center`,children:(0,d.jsx)($.X,{className:`w-5 h-5 text-red-300`})})]}),rt=({content:e,onRemove:t})=>(0,d.jsxs)(`div`,{className:`relative group flex-shrink-0 w-28 h-28 rounded-2xl overflow-hidden border border-[#E5E5E5] dark:border-[#30302E] bg-white dark:bg-[#20201F] animate-fade-in p-3 flex flex-col justify-between shadow-[0_1px_2px_rgba(0,0,0,0.05)]`,children:[(0,d.jsx)(`div`,{className:`overflow-hidden w-full`,children:(0,d.jsx)(`p`,{className:`text-[10px] text-[#9CA3AF] leading-[1.4] font-mono break-words whitespace-pre-wrap line-clamp-4 select-none`,children:e.content})}),(0,d.jsx)(`div`,{className:`flex items-center justify-between w-full mt-2`,children:(0,d.jsx)(`div`,{className:`inline-flex items-center justify-center px-1.5 py-[2px] rounded border border-[#E5E5E5] dark:border-[#404040] bg-white dark:bg-transparent`,children:(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-[#6B7280] dark:text-[#9CA3AF] uppercase tracking-wider font-sans`,children:`PASTED`})})}),(0,d.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-2 right-2 p-[3px] bg-white dark:bg-[#30302E] border border-[#E5E5E5] dark:border-[#404040] rounded-full text-[#9CA3AF] hover:text-[#6B7280] dark:hover:text-white transition-colors shadow-sm opacity-0 group-hover:opacity-100`,children:(0,d.jsx)($.X,{className:`w-2 h-2`})})]});function it(e,t){let[r,i]=(0,n.useState)(!1),a=(0,n.useRef)(null),o=(0,n.useRef)(null),s=(0,n.useRef)(null),c=(0,n.useRef)([]),l=(0,n.useRef)(!1),u=(0,n.useRef)(!1),d=typeof window<`u`?window.SpeechRecognition||window.webkitSpeechRecognition:null,m=()=>{let e=o.current;e&&e.state!==`inactive`?e.stop():(s.current?.getTracks().forEach(e=>e.stop()),s.current=null,o.current=null,i(!1),t())},h=async e=>{let t=new FormData;return t.append(`file`,e,`speech-input.webm`),t.append(`languageCode`,`en`),((await(0,f.default)(`/api/agent/transcript`,{method:`POST`,body:t}))?.text??``).trim()},g=async()=>{if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){p.toast.error(`Speech input is not supported in this browser`,{duration:5e3}),i(!1),t();return}try{let n=await navigator.mediaDevices.getUserMedia({audio:!0}),r=new MediaRecorder(n);c.current=[],s.current=n,o.current=r,r.ondataavailable=e=>{e.data.size>0&&c.current.push(e.data)},r.onstart=()=>{i(!0)},r.onstop=async()=>{try{let n=new Blob(c.current,{type:`audio/webm`});if(c.current=[],s.current?.getTracks().forEach(e=>e.stop()),s.current=null,o.current=null,i(!1),n.size===0){t();return}let r=await h(n);r?e(r):p.toast.error(`No speech detected. Please try again.`)}catch{p.toast.error(`Unable to transcribe audio.`)}finally{t()}},r.start()}catch{p.toast.error(`Microphone access is required for speech input.`),i(!1),t()}},_=async()=>{if(r){a.current?.stop(),m();return}if(u.current=!1,l.current=!1,!d){await g();return}let n=new d;n.continuous=!1,n.interimResults=!1,n.lang=`en-US`,n.onstart=()=>i(!0),n.onresult=t=>{let n=t.results[0][0].transcript;l.current=!0,e(n)},n.onend=async()=>{if(i(!1),a.current=null,u.current){u.current=!1;return}t()},n.onerror=async e=>{i(!1),a.current=null;let t=e?.error;if(!l.current&&t!==`aborted`){u.current=!0,await g();return}},a.current=n;try{n.start()}catch{a.current=null,i(!1),await g()}};(0,n.useEffect)(()=>{let e=e=>{e.ctrlKey&&e.key==="`"&&(e.preventDefault(),_())};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),a.current?.stop(),m()}},[r]);let v=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`;return{isListening:r,toggleSpeech:_,isSpeechSupported:!!d||v}}var at=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],ot=10,st=50*1024*1024,ct=(e,t)=>{if(e&&typeof e==`object`){let t=e.message??e.error??e.data?.message;if(typeof t==`string`&&t.length>0)return t}return typeof e==`string`&&e.length>0?e:t};function lt({setMessage:e,contextFiles:t,contextFileIds:r,setContextFiles:i,setContextFileIds:a}){let[o,s]=(0,n.useState)([]),[l,u]=(0,n.useState)([]),[d,f]=(0,n.useState)(!1),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(async e=>{let n=Array.from(e);n.length>ot&&(p.toast.error(`You can attach up to ${ot} files at a time.`),n=n.slice(0,ot));let o=n.filter(e=>e.size>st);if(o.length>0&&(p.toast.error(`${o.map(e=>e.name).join(`, `)} exceed${o.length===1?`s`:``} the 50 MB per-file limit.`),n=n.filter(e=>e.size<=st)),n.length===0)return;let l=n.map(e=>{let t=e.type.startsWith(`image/`)||/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name),n=e.name.split(`.`).pop()?.toLowerCase()??``,r=at.includes(n);return{id:Math.random().toString(36).substr(2,9),file:e,type:t?`image/unknown`:e.type||`application/octet-stream`,preview:t?URL.createObjectURL(e):null,uploadStatus:r?`uploading`:`pending`,_ext:n}});s(e=>[...e,...l]),l.filter(e=>!at.includes(e._ext)).forEach(e=>{setTimeout(()=>{s(t=>t.map(t=>t.id===e.id?{...t,uploadStatus:`complete`}:t))},600+Math.random()*600)});let u=l.filter(e=>at.includes(e._ext));if(u.length!==0)try{let{data:e,error:n}=await(0,c.uploadFiles)({body:{files:u.map(e=>e.file)}});if(n||!e?.files)throw Error(ct(n??e,`Upload failed.`));s(e=>e.map(e=>u.some(t=>t.id===e.id)?{...e,uploadStatus:`complete`}:e)),i([...t,...e.files]),a([...r,...e.files.map(e=>e.fileId)])}catch(e){p.toast.error(ct(e,`Failed to upload files.`)),s(e=>e.map(e=>u.some(t=>t.id===e.id)?{...e,uploadStatus:`error`}:e))}},[e,t,r,i,a]);return{files:o,setFiles:s,pastedContent:l,setPastedContent:u,isDragging:d,isExtractingUrl:m,handleFiles:g,extractUrl:(0,n.useCallback)(async e=>{let n=e.trim();if(!/^https?:\/\//i.test(n))return p.toast.error(`Enter a valid http(s) URL.`),!1;h(!0);try{let e=await(await fetch(`/api/doc/uploads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:n})})).json();if(!e?.files||e.files.length===0)throw Error(ct(e,`Could not extract content from ${n}`));return i([...t,...e.files]),a([...r,...e.files.map(e=>e.fileId)]),p.toast.success(`Added "${e.files[0].fileName}" as context.`),!0}catch(e){return p.toast.error(ct(e,`Failed to extract URL.`)),!1}finally{h(!1)}},[t,r,i,a]),onDragOver:e=>{e.preventDefault(),f(!0)},onDragLeave:e=>{e.preventDefault(),f(!1)},onDrop:e=>{e.preventDefault(),f(!1),e.dataTransfer.files&&g(e.dataTransfer.files)},handlePaste:e=>{let t=e.clipboardData.items,n=[];for(let e=0;e<t.length;e++)if(t[e].kind===`file`){let r=t[e].getAsFile();r&&n.push(r)}if(n.length>0){e.preventDefault(),g(n);return}let r=e.clipboardData.getData(`text`);if(r.length>300){e.preventDefault();let t={id:Math.random().toString(36).substr(2,9),content:r,timestamp:new Date};u(e=>[...e,t])}},resetAttachments:()=>{s([]),u([]),i([]),a([])}}}var ut=()=>window.gapi,dt=()=>window.google,ft=()=>{let e=(0,n.useRef)(!1),r=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{ut()?r.current=!0:(()=>{let e=document.createElement(`script`);e.src=`https://apis.google.com/js/api.js`,e.onload=()=>{ut()?.load(`client:picker`,()=>{r.current=!0})},document.body.appendChild(e)})(),dt()?.picker?e.current=!0:(()=>{let t=document.createElement(`script`);t.src=`https://www.google.com/jsapi`,t.onload=()=>{e.current=!0},document.body.appendChild(t)})()},[]),{openPicker:async(e,n,i)=>{let a=dt();if(!r.current||!a?.picker){i?.(`Google Picker API not loaded yet. Please try again.`);return}try{let{picker:r}=a;new r.PickerBuilder().addView(r.ViewId.DOCS).addView(r.ViewId.DOCS_IMAGES).addView(r.ViewId.DOCS_VIDEOS).addView(new r.DocsView().setIncludeFolders(!0).setMimeTypes(`application/pdf,application/vnd.google-apps.document,application/vnd.google-apps.spreadsheet,text/plain,image/jpeg,image/png`)).setOAuthToken(e).setDeveloperKey(t.researchAgentUIConfig.googleApiKey).setCallback(e=>{if(e.action===r.Action.PICKED){let t=e.docs;t&&n(t)}else e.action===r.Action.CANCEL&&console.log(`User cancelled picker`)}).build().setVisible(!0)}catch(e){i?.(e.message||`Failed to open Google Picker`)}}}},pt=()=>{let{chatModelProvider:e,setChatModelProvider:t}=q(),[i,a]=(0,n.useState)([]),[o,l]=(0,n.useState)(!0),u=(0,r.useRouter)();(0,n.useEffect)(()=>{(async()=>{try{l(!0);let{data:n}=await(0,c.listProviders)(),r=n?.providers??[];if(a(r),!e.key&&r.length>0){let e=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`);if(e&&n)t({key:e,providerId:n});else{let e=r.find(e=>e.chatModels.length>0);e&&t({key:e.chatModels[0].key,providerId:e.id})}}}catch(e){console.error(`Error loading providers:`,e)}finally{l(!1)}})()},[]);let f=(0,n.useMemo)(()=>{if(!e.key)return`Select`;for(let t of i){let n=t.chatModels.find(t=>t.key===e.key);if(n)return n.name}return e.key},[i,e.key]),p=(e,n)=>{t({providerId:e,key:n}),localStorage.setItem(`chatModelProviderId`,e),localStorage.setItem(`chatModelKey`,n)};return(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Cpu,{className:`w-4 h-4 flex-shrink-0 text-sky-500`}),(0,d.jsx)(`span`,{children:`Model`}),(0,d.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground truncate max-w-[55px]`,children:f})]}),(0,d.jsxs)(Ne,{className:`w-52 max-h-[400px] overflow-y-auto`,children:[o?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,d.jsx)(s.Loader2,{className:`h-4 w-4 animate-spin text-muted-foreground`})}):i.length===0?(0,d.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No models configured`}):i.map((t,n)=>(0,d.jsxs)(`div`,{children:[(0,d.jsx)(Ae,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:t.name}),t.chatModels.map(n=>(0,d.jsxs)(Z,{onSelect:()=>p(t.id,n.key),className:E(`gap-2`,e?.providerId===t.id&&e?.key===n.key&&`bg-secondary`),children:[(0,d.jsx)(s.Cpu,{className:E(`h-3.5 w-3.5 flex-shrink-0`,e?.providerId===t.id&&e?.key===n.key?`text-sky-500`:`text-muted-foreground`)}),(0,d.jsx)(`span`,{className:`truncate`,children:n.name}),e?.providerId===t.id&&e?.key===n.key&&(0,d.jsx)(`svg`,{className:`w-3 h-3 text-primary ml-auto shrink-0`,fill:`none`,viewBox:`0 0 10 10`,children:(0,d.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},n.key)),n<i.length-1&&(0,d.jsx)(Q,{})]},t.id)),(0,d.jsx)(Q,{}),(0,d.jsxs)(Z,{onSelect:()=>u.push(`/settings?section=models`),className:`gap-2`,children:[(0,d.jsx)(s.Plus,{className:`h-3.5 w-3.5 text-sky-500 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Add model`})]})]})]})},mt=[{label:`5s`,value:5},{label:`15s`,value:15},{label:`30s`,value:30},{label:`45s`,value:45},{label:`60s`,value:60},{label:`Unlimited`,value:0}],ht=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],gt=`markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org`.split(`.`),_t=({onFileSelect:e,disabled:t=!1})=>{let i=(0,r.useRouter)(),{category:a,setCategory:o,incognito:l,setIncognito:u,sections:f,chatId:m}=q(),{isAuthenticated:h}=ye(),g=a?a.split(`,`).filter(Boolean):[`general`],_=z.find(e=>e.code===g[0])||z[0],v=e=>{let t=a?a.split(`,`).filter(Boolean):[`general`],n=t.includes(e)?t.filter(t=>t!==e):[...t,e];o(n.length>0?n.join(`,`):`general`)},[y,b]=(0,n.useState)(!1),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),[T,D]=(0,n.useState)(!1),[O,k]=(0,n.useState)(()=>{if(typeof window>`u`)return 5;let e=Number(localStorage.getItem(`thinkingTimeLimit`)??`5`);return Number.isFinite(e)?e:5}),A=n.default.useRef(null),{openPicker:j}=ft();(0,n.useEffect)(()=>{M()},[]);let M=async()=>{try{let{data:e}=await(0,c.googleDocsAuthStatus)();b(e?.isConnected||!1)}catch{}},N=e=>{k(e),localStorage.setItem(`thinkingTimeLimit`,String(e))},P=async()=>{if(`showOpenFilePicker`in window)try{let t=await window.showOpenFilePicker({multiple:!0,types:[{description:`Supported files`,accept:{"application/pdf":[`.pdf`],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[`.docx`],"text/plain":[`.txt`],"text/markdown":[`.md`],"text/html":[`.html`,`.htm`],"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]}}]}),n=await Promise.all(t.map(e=>e.getFile()));n.length>0&&e(n)}catch(e){e?.name!==`AbortError`&&(console.error(`Failed to open file picker:`,e),A.current?.click())}else A.current?.click()};async function F(e,t=``){let n=[];for await(let r of e.values())if(r.kind===`file`){let e=await r.getFile(),i=e.name.split(`.`).pop()?.toLowerCase()??``;if(ht.includes(i))n.push(e);else if(gt.includes(i))try{let r=await e.text(),i=t?`${t}/${e.name}`:e.name;n.push(new File([r],`${i.replace(/[/\\]/g,`_`)}.txt`,{type:`text/plain`}))}catch{}}else if(r.kind===`directory`){let e=r;if(e.name.startsWith(`.`)||e.name===`node_modules`||e.name===`__pycache__`)continue;n.push(...await F(e,t?`${t}/${e.name}`:e.name))}return n}let I=async()=>{if(!(`showDirectoryPicker`in window)){alert(`Your browser does not support the File System Access API. Please use Chrome or Edge.`);return}D(!0);try{let t=await F(await window.showDirectoryPicker({mode:`read`}));t.length>0?e(t):alert(`No supported files found in the selected folder.`)}catch(e){e?.name!==`AbortError`&&console.error(`Failed to access folder:`,e)}finally{D(!1)}},L=async()=>{S(!0);try{let{data:e}=await(0,c.googleDocsAuth)();if(e?.success&&e?.data?.authUrl){let t=e.data.authUrl,n=window.screenX+(window.outerWidth-600)/2,r=window.screenY+(window.outerHeight-700)/2,i=window.open(t,`Google Drive Authorization`,`width=600,height=700,left=${n},top=${r}`),a=e=>{e.data.type===`google-drive-connected`&&(b(!0),i?.close(),window.removeEventListener(`message`,a))};window.addEventListener(`message`,a)}}catch{console.error(`Failed to connect to Google Drive`)}finally{S(!1)}},R=async()=>{try{let{data:t}=await(0,c.getGoogleToken)();if(!t?.success||!t.accessToken)throw Error(`Failed to get access token`);await j(t.accessToken,async t=>{w(!0);try{let n=[];for(let e of t){let{data:t}=await(0,c.getGoogleDriveFile)({query:{fileId:e.id}});if(t?.success&&t?.file){let e=atob(t.file.content),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);n.push(new File([new Blob([r],{type:t.file.mimeType})],t.file.name,{type:t.file.mimeType}))}}n.length>0&&e(n)}catch{alert(`Failed to load files from Google Drive`)}finally{w(!1)}},e=>{console.error(`Google Picker error:`,e),alert(e)})}catch(e){alert(e.message||`Failed to open Google Drive picker`)}},ee=mt.find(e=>e.value===O)?.label??`Unlimited`;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`relative flex shrink min-w-8 !shrink-0 group`,children:[(0,d.jsxs)(Ee,{children:[(0,d.jsx)(De,{asChild:!0,children:(0,d.jsx)(`button`,{disabled:t,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-8 w-8 rounded-lg active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,type:`button`,"aria-label":`Search options`,children:(0,d.jsx)(s.SlidersHorizontal,{className:`w-5 h-5`})})}),(0,d.jsxs)(Oe,{align:`start`,side:`top`,sideOffset:8,className:`w-44`,children:[(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[_&&(0,d.jsx)(_.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Category`})]}),(0,d.jsxs)(Ne,{className:`w-44`,children:[(0,d.jsxs)(ke,{checked:g.length===0,onCheckedChange:()=>o(`general`),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,d.jsx)(`div`,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`None`})]}),(0,d.jsx)(Q,{}),z.map(e=>(0,d.jsxs)(ke,{checked:g.includes(e.code),onCheckedChange:()=>v(e.code),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[e.icon&&(0,d.jsx)(e.icon,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:e.name})]},e.code))]})]}),(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Clock,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Speed`}),(0,d.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:ee})]}),(0,d.jsx)(Ne,{className:`w-36`,children:mt.map(e=>(0,d.jsxs)(Z,{onSelect:()=>N(e.value),className:E(`justify-between`,O===e.value&&`bg-secondary`),children:[(0,d.jsx)(`span`,{children:e.label}),O===e.value&&(0,d.jsx)(`svg`,{className:`w-3 h-3 text-primary`,fill:`none`,viewBox:`0 0 10 10`,children:(0,d.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},e.value))})]}),(0,d.jsx)(Q,{}),(0,d.jsx)(pt,{}),(0,d.jsx)(Q,{}),(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Upload,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Upload`})]}),(0,d.jsxs)(Ne,{className:`w-44`,children:[(0,d.jsxs)(Z,{onSelect:P,className:`gap-2`,children:[(0,d.jsx)(s.Upload,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Your Device`})]}),(0,d.jsxs)(Z,{onSelect:I,disabled:T,className:`gap-2`,children:[T?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.FolderOpen,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:T?`Scanning…`:`Local Folder`})]}),(0,d.jsx)(Q,{}),(0,d.jsx)(Ae,{className:`text-xs font-normal text-muted-foreground`,children:`Cloud`}),y?(0,d.jsxs)(Z,{onSelect:R,disabled:C,className:`gap-2`,children:[C?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:C?`Loading…`:`Google Drive`})]}):(0,d.jsxs)(Z,{onSelect:L,disabled:x,className:`gap-2`,children:[x?(0,d.jsx)(s.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,d.jsx)(s.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,d.jsx)(`span`,{children:x?`Connecting…`:`Connect Google Drive`})]})]})]}),(0,d.jsx)(Q,{}),(0,d.jsxs)(ke,{checked:l,onCheckedChange:u,onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,d.jsx)(s.EyeOff,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Private`})]}),(0,d.jsx)(Q,{}),f.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(je,{children:[(0,d.jsxs)(Me,{className:`gap-2`,children:[(0,d.jsx)(s.Share2,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Share`})]}),(0,d.jsxs)(Ne,{className:`w-48`,children:[(0,d.jsxs)(Z,{onSelect:async()=>{if(!m){p.toast.error(`No chat to share`);return}if(!h){p.toast.error(`Please sign in to share chats`);return}try{let{data:e,error:t}=await(0,c.shareChat)({body:{chatId:m}});if(!t&&e?.success&&e?.data?.shareUrl)await navigator.clipboard.writeText(e.data.shareUrl),p.toast.success(`Chat is now public - link copied to clipboard`);else throw Error(t?.error||`Failed to share chat`)}catch(e){console.error(`Error sharing chat:`,e);let t=e instanceof Error?e.message:`Failed to share chat`;p.toast.error(t)}},className:`gap-2`,children:[(0,d.jsx)(s.Link,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Copy link`})]}),(0,d.jsxs)(Z,{onSelect:async()=>{let e=f[0]?.userMessage?.content||`Chat`,t=f.map(e=>`## ${e.userMessage.content}\n\n${e.assistantMessage?.content||``}`).join(`
21
21
 
22
22
  ---
23
23
 
@@ -25,12 +25,12 @@
25
25
  `))},className:`gap-2`,children:[(0,d.jsx)(s.FileText,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Export as Markdown`})]}),(0,d.jsxs)(Z,{onSelect:()=>{qe(f[0]?.userMessage?.content||`Chat`,f.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
26
26
  `))},className:`gap-2`,children:[(0,d.jsx)(s.FileType,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Export as PDF`})]}),(0,d.jsxs)(Z,{onSelect:()=>{Ke(f[0]?.userMessage?.content||`Chat`,f.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
27
27
  `))},className:`gap-2`,children:[(0,d.jsx)(s.FileDown,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Export as DOCX`})]}),(0,d.jsxs)(Z,{onSelect:()=>{Je(f[0]?.userMessage?.content||`Chat`,f.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
28
- `))},className:`gap-2`,children:[(0,d.jsx)(s.FileSpreadsheet,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Export to Google Docs`})]})]})]}),(0,d.jsx)(Q,{})]}),(0,d.jsxs)(Z,{onSelect:()=>i.push(`/library`),className:`gap-2`,children:[(0,d.jsx)(s.History,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Z,{onSelect:()=>i.push(`/settings`),className:`gap-2`,children:[(0,d.jsx)(s.Settings,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Settings`})]})]})]}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Search options`})})]}),(0,d.jsxs)(`div`,{className:`relative hidden sm:flex shrink-0 group -ml-1`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:t,onClick:P,"aria-label":`Attach files`,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-7 w-7 rounded-md active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,children:(0,d.jsx)(s.Paperclip,{className:`w-[18px] h-[18px]`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Attach files`})})]}),(0,d.jsx)(`input`,{ref:A,type:`file`,multiple:!0,onChange:t=>{t.target.files&&(e(t.target.files),t.target.value=``)},className:`hidden`})]})},vt=(0,n.forwardRef)(({active:e=!1,processing:t=!1,barWidth:r=3,barHeight:i=4,barGap:a=1,barRadius:o=1.5,barColor:s,fadeEdges:c=!0,fadeWidth:l=24,height:u=64,sensitivity:f=1,smoothingTimeConstant:p=.8,fftSize:m=256,historySize:h=60,updateRate:g=30,mode:_=`static`,onError:v,onStreamReady:y,onStreamEnd:b,className:x,...S},C)=>{let w=(0,n.useRef)(null),T=(0,n.useRef)(null),E=(0,n.useRef)(null),D=(0,n.useRef)(null),O=(0,n.useRef)(null),k=(0,n.useRef)(0),A=(0,n.useRef)([]),j=(0,n.useRef)(0),M=(0,n.useRef)(0),N=(0,n.useCallback)(()=>{k.current&&=(cancelAnimationFrame(k.current),0),O.current&&=(O.current.disconnect(),null),D.current&&=(D.current.getTracks().forEach(e=>e.stop()),null),T.current&&=(T.current.close().catch(()=>{}),null),E.current=null,A.current=[],b?.()},[b]),P=(0,n.useCallback)((e,t,n,s,c)=>{let l=r+a,u=Math.floor(t/c/l),d=u*l-a,p=(t/c-d)/2,m=s.length;for(let t=0;t<u;t++){let a=s[Math.floor(t/u*m)]/255*f,d=Math.max(i,n/c*a),h=p+t*l,g=(n/c-d)/2;e.beginPath(),e.roundRect(h*c,g*c,r*c,d*c,o*c),e.fill()}},[r,a,i,o,f]),F=(0,n.useCallback)((e,t,n,s)=>{let c=A.current,l=r+a,u=Math.min(c.length,h),d=t/s-u*l;for(let t=0;t<u;t++){let a=c[c.length-u+t]*f,p=Math.max(i,n/s*a),m=d+t*l,h=(n/s-p)/2;e.beginPath(),e.roundRect(m*s,h*s,r*s,p*s,o*s),e.fill()}},[r,a,i,o,f,h]),I=(0,n.useCallback)((e,t,n,s,c)=>{let l=r+a,u=Math.floor(t/s/l),d=u*l-a,f=(t/s-d)/2;for(let t=0;t<u;t++){let a=Math.sin(t/u*Math.PI*2+c)*.5+.5,d=Math.max(i,n/s*a*.6),p=f+t*l,m=(n/s-d)/2;e.beginPath(),e.roundRect(p*s,m*s,r*s,d*s,o*s),e.fill()}},[r,a,i,o]),L=(0,n.useCallback)((e,t,n)=>{if(!c)return;e.save(),e.globalCompositeOperation=`destination-in`;let r=e.createLinearGradient(0,0,t,0);r.addColorStop(0,`rgba(0,0,0,0)`),r.addColorStop(Math.min(l/(t||1),.3),`rgba(0,0,0,1)`),r.addColorStop(Math.max(1-l/(t||1),.7),`rgba(0,0,0,1)`),r.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=r,e.fillRect(0,0,t,n),e.restore()},[c,l]);return(0,n.useEffect)(()=>{if(!e&&!t){let e=w.current;if(e){let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height)}return}let n=!0,r=i=>{if(!n)return;let a=w.current;if(!a){k.current=requestAnimationFrame(r);return}if(i-M.current<g){k.current=requestAnimationFrame(r);return}M.current=i;let o=window.devicePixelRatio||1,c=a.getBoundingClientRect(),l=c.width*o,u=c.height*o;(a.width!==l||a.height!==u)&&(a.width=l,a.height=u);let d=a.getContext(`2d`);if(!d){k.current=requestAnimationFrame(r);return}if(d.clearRect(0,0,l,u),d.fillStyle=s||getComputedStyle(a).getPropertyValue(`color`)||`#888`,d.save(),d.setTransform(1,0,0,1,0,0),t&&!e)j.current+=.06,I(d,l,u,o,j.current);else if(e&&E.current){let e=new Uint8Array(E.current.frequencyBinCount);if(E.current.getByteFrequencyData(e),_===`scrolling`){let t=0;for(let n=0;n<e.length;n++)t+=e[n];let n=t/e.length/255;A.current.push(n),A.current.length>h*2&&(A.current=A.current.slice(-h)),F(d,l,u,o)}else P(d,l,u,e,o)}L(d,l,u),d.restore(),k.current=requestAnimationFrame(r)};return k.current=requestAnimationFrame(r),()=>{n=!1,k.current&&=(cancelAnimationFrame(k.current),0)}},[e,t,_,s,g,h,P,F,I,L]),(0,n.useEffect)(()=>{if(!e){N();return}let t=!1;return(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(t){e.getTracks().forEach(e=>e.stop());return}let n=new AudioContext,r=n.createAnalyser();r.fftSize=m,r.smoothingTimeConstant=p;let i=n.createMediaStreamSource(e);i.connect(r),T.current=n,E.current=r,D.current=e,O.current=i,y?.(e)}catch(e){t||v?.(e instanceof Error?e:Error(String(e)))}})(),()=>{t=!0,N()}},[e,m,p,N,v,y]),(0,d.jsx)(`div`,{ref:C,className:x,style:{height:typeof u==`number`?`${u}px`:u,width:`100%`,position:`relative`},...S,children:(0,d.jsx)(`canvas`,{ref:w,style:{width:`100%`,height:`100%`,display:`block`,color:s||`currentColor`}})})});vt.displayName=`LiveWaveform`;var yt=[`What are you curious to research?`,`Search the latest news...`,`Analyze a video, doc, or URL...`,`Find academic research on...`,`Compare products to buy...`],bt={initial:{},animate:{transition:{staggerChildren:.025}},exit:{transition:{staggerChildren:.015,staggerDirection:-1}}},xt={initial:{opacity:0,filter:`blur(12px)`,y:10},animate:{opacity:1,filter:`blur(0px)`,y:0,transition:{opacity:{duration:.25},filter:{duration:.4},y:{type:`spring`,stiffness:80,damping:20}}},exit:{opacity:0,filter:`blur(12px)`,y:-10,transition:{opacity:{duration:.2},filter:{duration:.3},y:{type:`spring`,stiffness:80,damping:20}}}},St=({onNewChat:e})=>{let{loading:t,sendMessage:r,stopStreaming:i,files:a,fileIds:o,setFiles:c,setFileIds:l,newChat:f,sections:p}=J(),[m,h]=(0,n.useState)(``),g=(0,n.useRef)(null),_=(0,n.useRef)(null),{files:v,setFiles:y,pastedContent:b,setPastedContent:x,isDragging:S,handleFiles:C,onDragOver:w,onDragLeave:T,onDrop:E,handlePaste:D,resetAttachments:O}=lt({setMessage:h,contextFiles:a,contextFileIds:o,setContextFiles:c,setContextFileIds:l}),k=()=>{h(``),O(),g.current&&(g.current.style.height=`auto`)},{isListening:A,toggleSpeech:j,isSpeechSupported:M}=it(e=>h(e),()=>{h(e=>(e.trim()&&setTimeout(()=>{r(e),k()},0),e))}),[N,P]=(0,n.useState)(0),[F,I]=(0,n.useState)(!0),[L,R]=(0,n.useState)(!1),[z,ee]=(0,n.useState)([]),[B,te]=(0,n.useState)([]),[V,H]=(0,n.useState)(-1),[ne,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(`below`),K=(0,n.useRef)(!1),re=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(K.current){K.current=!1;return}let{query:e}=ie(m);if(!L||e.length<2){ee([]),te([]),U(!1),H(-1);return}let t=setTimeout(async()=>{re.current?.abort();let t=new AbortController;re.current=t;try{let n=await fetch(`/api/agent/autocomplete?q=${encodeURIComponent(e)}&limit=8`,{signal:t.signal});if(!n.ok)return;let r=await n.json(),i=Array.isArray(r?.suggestions)?r.suggestions:[],a=Array.isArray(r?.domains)?r.domains:[];if(ee(i),te(a),i.length+a.length>0){if(_.current){let e=_.current.getBoundingClientRect(),t=window.innerHeight-e.bottom,n=e.top;t<Math.min(288,(i.length+a.length)*36)&&n>t?G(`above`):G(`below`)}U(!0)}else U(!1);H(-1)}catch(e){e?.name!==`AbortError`&&console.error(`Autocomplete fetch failed`,e)}},180);return()=>clearTimeout(t)},[m,L]);let ie=e=>{let t=e.trimEnd();if(!t)return{prefix:``,query:``};let n=t.split(/\s+/),r=Math.min(4,n.length),i=n.slice(-r).join(` `);return{prefix:n.length>r?n.slice(0,-r).join(` `)+` `:``,query:i}},ae=e=>{K.current=!0;let{prefix:t}=ie(m);h(t+e),ee([]),te([]),U(!1),H(-1),g.current?.focus()},oe=e=>{U(!1),H(-1),window.location.href=`https://${e.domain}`},se=B.length+z.length,ce=e=>{e<B.length?oe(B[e]):ae(z[e-B.length])};(0,n.useEffect)(()=>{if(L||m)return;let e=setInterval(()=>{I(!1),setTimeout(()=>{P(e=>(e+1)%yt.length),I(!0)},400)},3e3);return()=>clearInterval(e)},[L,m]),(0,n.useEffect)(()=>{let e=e=>{_.current&&!_.current.contains(e.target)&&(m||R(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]),(0,n.useEffect)(()=>{g.current&&(g.current.style.height=`auto`,g.current.style.height=Math.min(g.current.scrollHeight,384)+`px`)},[m]);let le=()=>{t||!m.trim()&&v.length===0&&b.length===0||(r(m),k())},ue=e=>{if(ne&&se>0){if(e.key===`ArrowDown`){e.preventDefault(),H(e=>(e+1)%se);return}if(e.key===`ArrowUp`){e.preventDefault(),H(e=>e<=0?se-1:e-1);return}if(e.key===`Escape`){e.preventDefault(),U(!1),H(-1);return}if(e.key===`Tab`&&V>=0){e.preventDefault(),ce(V);return}if(e.key===`Enter`&&!e.shiftKey&&V>=0){e.preventDefault(),ce(V);return}let t=parseInt(e.key,10);if(t>=1&&t<=se&&t<=9){e.preventDefault(),ce(t-1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),le())},q=!!(m.trim()||v.length>0||b.length>0);return(0,d.jsxs)(`div`,{className:`relative w-full max-w-2xl mx-auto transition-all duration-300 font-sans`,onDragOver:w,onDragLeave:T,onDrop:E,children:[(0,d.jsxs)(u.motion.div,{ref:_,className:`!box-content flex flex-col mx-2 md:mx-0 items-stretch relative z-10 rounded-[28px] bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent cursor-text font-sans antialiased`,animate:{boxShadow:L||m?`0 8px 32px 0 rgba(0,0,0,0.16)`:`0 2px 8px 0 rgba(0,0,0,0.08)`},transition:{type:`spring`,stiffness:120,damping:18},onClick:()=>R(!0),children:[(v.length>0||b.length>0)&&(0,d.jsxs)(`div`,{className:`flex gap-3 overflow-x-auto custom-scrollbar px-3 pt-3 pb-1`,children:[b.map(e=>(0,d.jsx)(rt,{content:e,onRemove:e=>x(t=>t.filter(t=>t.id!==e))},e.id)),v.map(e=>(0,d.jsx)(nt,{file:e,onRemove:e=>y(t=>t.filter(t=>t.id!==e))},e.id))]}),A&&(0,d.jsx)(`div`,{className:`px-3 pt-2`,children:(0,d.jsx)(vt,{active:A,mode:`static`,height:48,barWidth:3,barGap:2,barColor:`gray`,fadeEdges:!0,sensitivity:1.2,className:`w-full rounded-lg`})}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2 p-3`,children:[(0,d.jsx)(_t,{onFileSelect:C,disabled:t}),(0,d.jsxs)(`div`,{className:`relative flex-1`,children:[(0,d.jsx)(`div`,{className:`max-h-96 w-full overflow-y-auto custom-scrollbar`,children:(0,d.jsx)(`textarea`,{ref:g,value:m,onChange:e=>h(e.target.value),onPaste:D,onKeyDown:ue,onFocus:()=>R(!0),className:`w-full bg-transparent border-0 outline-none text-text-200 dark:text-text-100 text-[16px] resize-none overflow-hidden py-1 leading-relaxed block font-normal antialiased`,rows:1,autoFocus:!0,style:{minHeight:`1.5em`}})}),(0,d.jsx)(`div`,{className:`absolute left-0 top-0 w-full h-full pointer-events-none flex items-center`,children:(0,d.jsx)(u.AnimatePresence,{mode:`wait`,children:F&&!L&&!m&&(0,d.jsx)(u.motion.span,{className:`absolute left-0 top-1/2 -translate-y-1/2 text-text-400 select-none pointer-events-none text-[16px] font-normal`,style:{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},variants:bt,initial:`initial`,animate:`animate`,exit:`exit`,children:yt[N].split(``).map((e,t)=>(0,d.jsx)(u.motion.span,{variants:xt,style:{display:`inline-block`},children:e===` `?`\xA0`:e},t))},N)})})]}),M&&(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),j()},disabled:t,className:`transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95
29
- ${A?`text-red-500 bg-red-500/10 animate-pulse`:`text-text-400 hover:text-text-200 hover:bg-bg-200`}
30
- `,"aria-label":A?`Stop listening`:`Voice input`,children:(0,d.jsx)($.Mic,{className:`w-5 h-5`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:A?`Stop listening`:`Voice input`})})]}),p.length>0&&(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,d.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,d.jsx)($.SquarePen,{className:`w-5 h-5`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`New chat`})})]}),(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[t?(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},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,d.jsx)($.Stop,{className:`w-3.5 h-3.5 fill-current`})}):(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),le()},disabled:!q,className:`inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
31
- ${q?`bg-accent text-bg-0 hover:bg-accent-hover shadow-md`:`bg-bg-300 text-text-400 cursor-default opacity-50`}
32
- `,type:`button`,"aria-label":`Send message`,children:(0,d.jsx)($.ArrowUp,{className:`w-4 h-4`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,d.jsx)(u.AnimatePresence,{children:ne&&se>0&&(0,d.jsx)(u.motion.div,{ref:e=>{e&&_.current&&_.current.contains(e)},initial:{opacity:0,y:W===`above`?4:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:W===`above`?4:-4},transition:{duration:.12},className:`absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${W===`above`?`bottom-full`:`top-full`}`,onMouseDown:e=>e.preventDefault(),children:(0,d.jsxs)(`ul`,{className:`max-h-72 overflow-y-auto custom-scrollbar py-1`,children:[B.map((e,t)=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>H(t),onClick:()=>oe(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t===V?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:t+1}),(0,d.jsx)(`img`,{src:e.favicon,alt:``,className:`w-4 h-4 rounded-sm shrink-0`}),(0,d.jsx)(`span`,{className:`truncate font-medium`,children:e.name||e.domain}),(0,d.jsx)(`span`,{className:`truncate text-[13px] text-text-400 shrink-0`,children:e.domain})]})},`domain-${e.domain}`)),z.map((e,t)=>{let n=B.length+t;return(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>H(n),onClick:()=>ae(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n===V?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:n+1}),(0,d.jsx)(s.Search,{className:`w-4 h-4 text-text-400 shrink-0`}),(0,d.jsx)(`span`,{className:`truncate`,children:e})]})},`${e}-${t}`)})]})})}),S&&(0,d.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,d.jsx)($.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,d.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})};function Ct({...e}){return(0,d.jsx)(S.Root,{"data-slot":`dialog`,...e})}function wt({...e}){return(0,d.jsx)(S.Trigger,{"data-slot":`dialog-trigger`,...e})}function Tt({...e}){return(0,d.jsx)(S.Portal,{"data-slot":`dialog-portal`,...e})}function Et({className:e,...t}){return(0,d.jsx)(S.Overlay,{"data-slot":`dialog-overlay`,className:E(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs`,e),...t})}function Dt({className:e,children:t,hideCloseButton:n=!1,...r}){return(0,d.jsxs)(Tt,{"data-slot":`dialog-portal`,children:[(0,d.jsx)(Et,{}),(0,d.jsxs)(S.Content,{"data-slot":`dialog-content`,"aria-describedby":r[`aria-describedby`]??void 0,className:E(`z-[9999] bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200`,e),...r,children:[t,!n&&(0,d.jsxs)(S.Close,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,d.jsx)(s.XIcon,{}),(0,d.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Ot({className:e,...t}){return(0,d.jsx)(S.Title,{"data-slot":`dialog-title`,className:E(`text-lg leading-none font-semibold`,e),...t})}function kt({className:e,...t}){return(0,d.jsx)(S.Description,{"data-slot":`dialog-description`,className:E(`text-muted-foreground text-sm`,e),...t})}var At=n.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`span`,{ref:n,className:E(`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%)`},...t}));At.displayName=`VisuallyHidden`;var jt=({onClose:e})=>(0,d.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,d.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,d.jsx)(s.X,{className:`h-5 w-5`})})}),Mt=(0,b.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 Nt({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,d.jsx)(r?y.Slot:`button`,{"data-slot":`button`,className:E(Mt({variant:t,size:n,className:e})),...i})}var Pt=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:r,isHighlightMode:i,onAskClick:a,onSuggestClick:o,onCopyClick:c,onFavoriteClick:l,onHighlightToggle:u})=>(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,d.jsxs)(Nt,{onClick:a,disabled:e,variant:`ghost`,size:`sm`,className:E(`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,d.jsx)(s.Bot,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]}),(0,d.jsxs)(Nt,{onClick:o,disabled:t,variant:`ghost`,size:`sm`,className:E(`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,d.jsx)(s.MessageCircleQuestion,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]}),(0,d.jsx)(Nt,{onClick:c,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,d.jsx)(s.Clipboard,{className:`size-4`})}),(0,d.jsx)(Nt,{onClick:u,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,i?`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`),title:i?`Disable highlighting`:`Enable highlighting`,children:(0,d.jsx)(s.Highlighter,{className:`size-4`})}),(0,d.jsx)(Nt,{onClick:l,disabled:n,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,r?`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`),title:r?`Remove from favorites`:`Add to favorites`,children:(0,d.jsx)(s.Star,{className:E(`size-4`,r&&`fill-yellow-400`)})})]}),Ft=({value:e,onChange:t,onSubmit:n})=>(0,d.jsx)(`div`,{className:`relative`,children:(0,d.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`})}),It=({questions:e,isLoading:r,error:i,onQuestionClick:a})=>{let o=n.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,d.jsxs)(d.Fragment,{children:[o.length>0&&(0,d.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.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}),o.map((e,t)=>(0,d.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))]})]}),r&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),i&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:i})]})},Lt=({response:e,isLoading:t,error:n})=>(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,d.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Rt=({html:e,isHighlightMode:t=!1})=>{let[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{i(C.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,d.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t?`select-text`:``}`,dangerouslySetInnerHTML:{__html:r}})},zt=({article:e,isHighlightMode:t})=>(0,d.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.url&&(0,d.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 mb-3 text-sm text-primary hover:underline truncate max-w-full`,children:[(0,d.jsx)(s.ExternalLink,{className:`flex-shrink-0 size-3.5`}),(0,d.jsx)(`span`,{className:`truncate`,children:e.url})]}),e.cite&&(0,d.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,d.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,d.jsxs)(`p`,{children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,d.jsx)(`div`,{id:`article-content`,children:(0,d.jsx)(Rt,{html:e.html||``,isHighlightMode:t})})]})}),Bt=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,Vt=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function Ht(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 Ut(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function Wt(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(Vt.lastIndex=0;(r=Vt.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(Bt.lastIndex=0;(a=Bt.exec(t))!==null;){let e=a[0],n=a.index;if(Vt.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}Ht(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=Ut(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function Gt(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function Kt(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function qt({code:e}){let[t,r]=(0,n.useState)(!1);return(0,d.jsx)(`button`,{onClick:(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]),className:E(`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,d.jsx)(s.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,d.jsx)(s.Copy,{className:`h-4 w-4`})})}function Jt({children:e}){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;i(t.trim())}}},[e]),(0,d.jsxs)(`div`,{className:`relative group my-5`,children:[(0,d.jsx)(`pre`,{ref:t,className:E(`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}),r&&(0,d.jsx)(qt,{code:r})]})}var Yt=n.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,d.jsx)(`div`,{className:E(`text-muted-foreground text-sm`,t),children:`No content`});let r=Wt(e);return(0,d.jsx)(`div`,{className:E(`kortix-markdown`,t),children:(0,d.jsx)(T.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,d.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,d.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,d.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,d.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,d.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,d.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,d.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,d.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,d.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,d.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=Gt(e),r=e?.startsWith(`#`),i=E(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return r?(0,d.jsx)(`a`,{href:e,onClick:t=>Kt(t,e),className:i,children:t}):n?(0,d.jsx)(w.default,{href:e||`#`,className:i,children:t}):(0,d.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:i,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,d.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,d.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,d.jsx)(Jt,{children:e}),blockquote:({children:e})=>(0,d.jsx)(`blockquote`,{className:E(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,d.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,d.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,d.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,d.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,d.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,d.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,d.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,d.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,d.jsxs)(`span`,{className:`block my-5`,children:[(0,d.jsx)(`img`,{src:e,alt:t||``,className:E(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,d.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,d.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,d.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,d.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,d.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:E(`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,...r})=>(0,d.jsx)(`div`,{className:E(`text-sm text-foreground`,n),style:t,...r,children:e}),span:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`span`,{className:E(`text-foreground`,n),style:t,...r,children:e})},children:r})})});Yt.displayName=`UnifiedMarkdown`;var Xt=e=>{let{isOpen:r,url:i,searchText:a,panelWidth:o,setPanelWidth:s,closePanel:l}=A(),{isAuthenticated:u}=ve(),f=e.isOpen===void 0?r:e.isOpen,m=e.onClose||l,h=e.url||i,g=e.searchText===void 0?a:e.searchText,[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)([]),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(t.researchAgentUIConfig.defaultSummarizePrompt),[T,E]=(0,n.useState)(!1),[D,O]=(0,n.useState)(!1),[k,j]=(0,n.useState)(!1),[M,N]=(0,n.useState)(``),[P,F]=(0,n.useState)(``),[I,L]=(0,n.useState)([]),[R,z]=(0,n.useState)(``),[ee,B]=(0,n.useState)(!1),[te,V]=(0,n.useState)(!1),[H,ne]=(0,n.useState)(!1),[U,W]=(0,n.useState)(!1),[G,K]=(0,n.useState)(o),[re,ie]=(0,n.useState)(!1),[ae,oe]=(0,n.useState)(!1),se=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=()=>{W(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(!re)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));K(n),s(n)},t=()=>{ie(!1)};return re&&(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=``}},[re,s]),(0,n.useEffect)(()=>{f&&h?(oe(!1),ce()):f||oe(!1)},[f,h]);let ce=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,h);try{let e=new URL(h);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(h))){p.toast.error(`Cannot extract articles from search result pages`),E(!1),oe(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,h),p.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,h,e)}E(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:h}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:h}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:h}}),i=r?.article;i&&(v(i),i.followUpQuestions?.length>0&&L(i.followUpQuestions)),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(v(t),t?.followUpQuestions&&t.followUpQuestions.length>0&&L(t.followUpQuestions)),u&&le()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),p.toast.error(`Failed to load article`)}finally{E(!1),oe(!0)}},le=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===h);B(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},ue=async()=>{if(_){V(!0);try{ee?(await(0,c.removeFavorite)({query:{url:h}}),B(!1),p.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:_.url||h,title:_.title,cite:_.cite,author:_.author,author_cite:_.author_cite,date:_.date,source:_.source,word_count:_.word_count,html:_.html}}),B(!0),p.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),p.toast.error(`Failed to toggle favorite`)}finally{V(!1)}}},q=async e=>{if(!_)return;let n=_.html?.replace(/<[^>]*>?/g,``).slice(0,t.researchAgentUIConfig.maxArticleLength),r=e===`question`,i=r?O:j,a=r?F:z;i(!0),a(``);try{if(r){let{data:e,error:t}=await(0,c.articleQa)({body:{article:n,question:[g,C].filter(Boolean).join(`
33
- `),chatHistory:y.slice(-5),provider:`groq`}});if(t)throw Error(t.error||`Article QA failed`);let r=e?.content||``;N(r),b(e=>[...e,{role:`user`,content:C,time:new Date().toISOString()},{role:`assistant`,content:r,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:h,question:C,answer:r}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),{data:t,error:r}=await(0,c.articleFollowups)({body:{article:n,chatHistory:y.slice(-5),maxQuestions:e,provider:`groq`}});if(r)throw Error(r.error||`Article followups failed`);let i=t?.extract||[];L(i);try{await(0,c.updateArticle)({body:{url:h,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),a(`Failed to get AI response`)}finally{i(!1)}},de=e=>{w(e),q(`question`)},fe=async()=>{if(!_)return;let e=`${M}\n\n\n${_.cite||``}\n\n\n${_.html}`;try{await navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},pe=()=>(0,d.jsxs)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:[(0,d.jsx)(jt,{onClose:m}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,d.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(Pt,{isLoadingAI:D,isLoadingFollowups:k,isLoadingFavorite:te,isFavorited:ee,isHighlightMode:H,onAskClick:()=>q(`question`),onSuggestClick:()=>q(`suggest-followups`),onCopyClick:fe,onFavoriteClick:ue,onHighlightToggle:()=>ne(!H)}),x&&(0,d.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),(0,d.jsx)(Ft,{value:C,onChange:w,onSubmit:()=>q(`question`)}),(0,d.jsx)(It,{questions:I,isLoading:k,error:R,onQuestionClick:de}),y.length>0&&(0,d.jsx)(`div`,{className:`space-y-4`,children:y.map((e,t)=>(0,d.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,d.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,d.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,d.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,d.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(D||M&&y.length===0)&&(0,d.jsx)(Lt,{response:M,isLoading:D,error:P}),P&&!D&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:P})]}),_&&(0,d.jsx)(zt,{article:_,isHighlightMode:H})]})})]});return!f||!ae?null:U?(0,d.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${G}px`},children:[(0,d.jsx)(`div`,{ref:se,onMouseDown:()=>ie(!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,d.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`})}),pe()]}):(0,d.jsx)(Ct,{open:f,onOpenChange:e=>!e&&m(),children:(0,d.jsxs)(Dt,{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,d.jsx)(At,{children:(0,d.jsx)(Ot,{children:`Article Details`})}),(0,d.jsx)(`div`,{className:`h-full overflow-y-auto`,children:pe()})]})})},Zt=()=>{let{sections:e,chatTurns:r,loading:i,messageAppeared:a,newChat:o,chatId:s}=J(),{isOpen:c,panelWidth:l}=A(),{isAuthenticated:u}=ve(),[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=()=>{p(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{if(r.length===1&&(document.title=`${r[0].content.substring(0,30)} - ${t.researchAgentUIConfig.appName}`),r[r.length-1]?.role===`user`){g.current=!0,h.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{g.current=!1},100);return}},[r]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:f&&c?{width:`calc(100% - ${l}px)`}:{},children:[(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${f&&!c?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,r)=>{let i=r===e.length-1;return(0,d.jsxs)(n.Fragment,{children:[(0,d.jsx)(et,{section:t,sectionIndex:r,dividerRef:i?m:void 0,isLast:i}),!i&&(0,d.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),i&&!a&&(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})})}),(0,d.jsx)(`div`,{ref:h,className:`h-0`})]}),(0,d.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,d.jsx)(St,{})})]}),(0,d.jsx)(Xt,{})]})};function Qt({radius:e=60,opacityDecay:t=.025,backgroundColor:r=`transparent`,color:i,colorGenerator:a}){let o=(0,n.useRef)(null),s=(0,n.useRef)({x:0,y:0}),c=(0,n.useRef)([]),l=()=>[Math.floor(Math.random()*130+10),Math.floor(.5*Math.random()*50),Math.floor(.5*Math.random()*255)],u=()=>i||a?.()||l();return(0,n.useEffect)(()=>{let n=o.current;if(!n)return;let i=n.getContext(`2d`);if(!i)return;let a=()=>{n.width=window.innerWidth,n.height=window.innerHeight};a();let l=()=>{i.globalCompositeOperation=`source-over`,r===`transparent`?i.clearRect(0,0,n.width,n.height):(i.fillStyle=r,i.fillRect(0,0,n.width,n.height)),i.globalCompositeOperation=`lighter`;let a={col:u(),x:s.current.x,y:s.current.y,grdblur:i.createRadialGradient(s.current.x,s.current.y,0,s.current.x,s.current.y,e),alpha:1};c.current.push(a);let o=[];for(let n=0;n<c.current.length;n++){let r=c.current[n];r.grdblur.addColorStop(0,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`),r.grdblur.addColorStop(.2,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`),r.grdblur.addColorStop(.5,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`),r.grdblur.addColorStop(1,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`),i.beginPath(),i.fillStyle=r.grdblur,i.globalAlpha=r.alpha,i.arc(r.x,r.y,e,0,Math.PI*2),i.fill(),r.alpha-=t,r.alpha<=0&&o.push(n)}for(let e=o.length-1;e>=0;e--)c.current.splice(o[e],1);i.globalAlpha=1,requestAnimationFrame(l)},d=e=>{s.current.x=e.pageX,s.current.y=e.pageY},f=e=>{s.current.x=e.touches[0].pageX,s.current.y=e.touches[0].pageY};return window.addEventListener(`mousemove`,d),window.addEventListener(`touchmove`,f,{passive:!0}),window.addEventListener(`resize`,a),l(),()=>{window.removeEventListener(`mousemove`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`resize`,a)}},[e,t,r,i,a]),(0,d.jsx)(`div`,{className:`relative w-full h-screen overflow-hidden pointer-events-none`,children:(0,d.jsx)(`canvas`,{ref:o,className:`absolute inset-0`,style:{background:`transparent`}})})}var $t=`qwksearch_pinned_chats`;function en(){if(typeof window>`u`)return[];try{let e=localStorage.getItem($t);return e?JSON.parse(e):[]}catch{return[]}}function tn(e){typeof window>`u`||localStorage.setItem($t,JSON.stringify(e))}function nn(){let[e,t]=(0,n.useState)([]),[r,i]=(0,n.useState)(!0),[a,o]=(0,n.useState)(!1),[s,c]=(0,n.useState)(null),[l,u]=(0,n.useState)(!1),[d,f]=(0,n.useState)(!1),[m,h]=(0,n.useState)(!1),[g,_]=(0,n.useState)([]),[v,y]=(0,n.useState)(``),[b,x]=(0,n.useState)([]),[S,C]=(0,n.useState)(!1),{isAuthenticated:w,isLoading:T}=ve(),{incognito:E,setIncognito:D}=J();(0,n.useEffect)(()=>{_(en())},[]);let O=(0,n.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),_(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return tn(n),n})},[]),k=(0,n.useMemo)(()=>[...e].sort((e,t)=>{let n=g.includes(e.id),r=g.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,g]),A=(0,n.useMemo)(()=>v.trim()?b:k,[v,b,k]),j=(0,n.useCallback)(async()=>{if(!T){i(!0);try{if(w){let e=await fetch(`/api/agent/chats`,{credentials:`include`,headers:{"Content-Type":`application/json`}});if(e.status===401){let e=K().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e);return}if(!e.ok)throw Error(`HTTP ${e.status}: ${e.statusText}`);let n=await e.json();t(Array.isArray(n?.chats)?n.chats:[])}else{let e=K().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([]),p.toast.error(`Failed to load chat history`)}finally{i(!1)}}},[w,T]);(0,n.useEffect)(()=>{j()},[j]);let M=(e,t)=>{e.preventDefault(),e.stopPropagation(),c(t),o(!0)},N=async()=>{if(s){u(!0);try{if(w){let e=await fetch(`/api/agent/chats/${s}`,{method:`DELETE`,credentials:`include`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}: ${e.statusText}`)}else ae(s);t(e=>e.filter(e=>e.id!==s)),p.toast.success(`Chat deleted`)}catch(e){p.toast.error(e.message||`Failed to delete chat`)}finally{o(!1),c(null),u(!1)}}},P=()=>{f(!0)},F=async()=>{h(!0);try{if(w){let e=await fetch(`/api/agent/chats`,{method:`DELETE`,credentials:`include`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`HTTP ${e.status}: ${e.statusText}`)}else oe();t([]),p.toast.success(`All history cleared`)}catch(e){p.toast.error(e.message||`Failed to clear history`)}finally{f(!1),h(!1)}},I=()=>{D(!E),p.toast.success(E?`Private mode off`:`Private mode on — messages won't be saved`)},L=(0,n.useCallback)(async e=>{if(!e.trim()){x([]),C(!1);return}C(!0);try{if(w){let t=await fetch(`/api/agent/chats/search?q=${encodeURIComponent(e)}`,{credentials:`include`,headers:{"Content-Type":`application/json`}});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();x(Array.isArray(n?.chats)?n.chats:[])}else{let t=K().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});x(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0})))}}catch(e){console.error(`Failed to search chat history:`,e),x([]),p.toast.error(`Failed to search chat history`)}finally{C(!1)}},[w]);return(0,n.useEffect)(()=>{let e=setTimeout(()=>{L(v)},300);return()=>clearTimeout(e)},[v,L]),{chats:e,sortedChats:k,displayChats:A,loading:r,pinnedIds:g,togglePin:O,incognito:E,toggleIncognito:I,searchQuery:v,searchResults:b,searching:S,handleSearchChange:(0,n.useCallback)(e=>{y(e)},[]),deleteDialogOpen:a,setDeleteDialogOpen:o,chatToDelete:s,setChatToDelete:c,deleting:l,handleDeleteClick:M,handleConfirmDelete:N,clearAllDialogOpen:d,setClearAllDialogOpen:f,clearingAll:m,handleClearAllClick:P,handleConfirmClearAll:F}}function rn({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,d.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.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,d.jsx)(s.Lock,{size:12}),(0,d.jsx)(`span`,{children:`Private`})]}),n&&(0,d.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,d.jsx)(s.Trash2,{size:12}),(0,d.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,d.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,d.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,d.jsx)(s.X,{size:14})})]})]})}function an({chat:e,isPinned:t,onTogglePin:n,onDelete:r}){let i=e.messageCount??0;return(0,d.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,d.jsxs)(w.default,{href:`/c/${e.id}`,className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[i>0&&(0,d.jsxs)(Qe,{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:[i,`Q`]}),(0,d.jsx)(Qe,{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:D(new Date,e.createdAt)})]}),(0,d.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[t&&(0,d.jsx)(s.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,d.jsx)(`button`,{onClick:t=>n(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${t?`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:t?`Unpin chat`:`Pin chat`,children:(0,d.jsx)(s.Pin,{size:14})}),(0,d.jsx)(`button`,{onClick:t=>r(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,d.jsx)(s.Trash,{size:14})})]})}function on({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,loadingLabel:a,loading:o,onConfirm:s}){return(0,d.jsx)(Ct,{open:e,onOpenChange:e=>{!e&&!o&&t(!1)},children:(0,d.jsxs)(Dt,{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,d.jsx)(Ot,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,d.jsx)(kt,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:r}),(0,d.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,d.jsx)(`button`,{onClick:()=>{o||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,d.jsx)(`button`,{onClick:s,disabled:o,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:o?a:i})]})]})})}function sn({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:o,setClearAllDialogOpen:s,clearingAll:c,onConfirmClearAll:l}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(on,{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,d.jsx)(on,{open:o,onOpenChange:s,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:c,onConfirm:l})]})}var cn={Today:(0,d.jsx)(s.Sun,{size:12}),Yesterday:(0,d.jsx)(s.Clock,{size:12}),"This Week":(0,d.jsx)(s.CalendarDays,{size:12}),Older:(0,d.jsx)(s.Archive,{size:12})};function ln(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()-6*864e5),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 un=({showLabel:e=!1})=>{let t=nn();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(Ct,{children:[(0,d.jsxs)(wt,{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,d.jsx)(s.History,{size:e?14:18}),e&&(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Dt,{className:`max-w-[420px] p-3`,children:[(0,d.jsx)(Ot,{className:`sr-only`,children:`Chat History`}),(0,d.jsx)(rn,{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,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.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,d.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,d.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,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,d.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,d.jsx)(an,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):ln(t.displayChats).map(({label:e,chats:n})=>(0,d.jsxs)(`div`,{children:[(0,d.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:[cn[e],e]}),n.map(e=>(0,d.jsx)(an,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,d.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,d.jsx)(w.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,d.jsx)(sn,{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})]})};function dn(){let{chats:e,loading:t}=nn(),n=[...e].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,3);return t?null:(0,d.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,d.jsx)(un,{showLabel:!0}),n.map(e=>(0,d.jsx)(w.default,{href:`/c/${e.id}`,className:`px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 truncate max-w-[160px]`,title:e.title,children:e.title},e.id))]})}function fn({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:n=`bg-black/40`}){return(0,d.jsx)(`div`,{className:`absolute bottom-2 left-1/2 -translate-x-1/2 text-slate-200 text-xs z-20 ${n} rounded-lg px-2 py-1 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 flex flex-wrap items-center justify-center gap-x-6 max-w-[90vw]`,children:(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto grid grid-cols-3 gap-2`,children:e.map(({url:e,text:n,icon:r})=>{let i=r?s[r]:null,a=e.startsWith(`http`),o=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,d.jsxs)(d.Fragment,{children:[t&&i&&(0,d.jsx)(i,{size:14}),(0,d.jsx)(`span`,{className:`font-semibold tracking-wide text-md`,style:{fontVariant:`small-caps`},children:n}),(0,d.jsx)(`span`,{className:`absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return a?(0,d.jsx)(`a`,{href:e,...o,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e):(0,d.jsx)(w.default,{href:e,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e)})})})}function pn(){let e=`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(`,`);return`https://i.imgur.com/`+e[Math.floor(Math.random()*e.length)]}function mn(){let{sendMessage:e}=J(),[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)({os:``});(0,n.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;i(pn());let e=setInterval(()=>{let e=pn();o(e),c(!0),setTimeout(()=>{i(e),c(!1),o(null)},1e3)},2e4);return()=>clearInterval(e)},[]),(0,n.useEffect)(()=>{if(typeof window<`u`){let e=window.navigator.userAgent.toLowerCase();e.includes(`win`)?u({os:`Windows`}):e.includes(`mac`)?u({os:`MacOS`}):u({os:`Other`})}},[]);let f=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),p=(e,t)=>f(e)?(0,d.jsx)(`video`,{src:e,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e):(0,d.jsx)(`img`,{src:e,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e);return(0,d.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,d.jsxs)(`div`,{className:`fixed inset-0 z-0`,children:[r&&p(r,s?`opacity-0`:`opacity-30`),a&&p(a,s?`opacity-30`:`opacity-0`),(0,d.jsx)(Qt,{})]}),(0,d.jsx)(`div`,{className:`relative z-10`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-screen max-w-screen-sm mx-auto p-2 pb-20 md:pb-2`,children:[(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,d.jsxs)(`p`,{className:`text-lg text-gray-500 text-center justify-center mt-4`,children:[(0,d.jsx)(`a`,{"aria-label":`Chrome Web Store`,className:`download-chrome download-btn text-center justify-center`,target:`_blank`,href:t.researchAgentUIConfig.downloadChromeUrl}),(0,d.jsx)(`a`,{"aria-label":`Microsoft Store`,className:`download-windows download-btn text-center justify-center`,target:`_blank`,href:l.os==`Windows`?`ms-windows-store://pdp/?productid=${t.researchAgentUIConfig.downloadWindowsStoreId}`:`https://apps.microsoft.com/detail/${t.researchAgentUIConfig.downloadWindowsStoreId}?rtc=1`})]}),(0,d.jsxs)(`div`,{className:`w-full max-w-2xl mt-8 space-y-2`,children:[(0,d.jsx)(dn,{}),(0,d.jsx)(St,{})]})]})}),(0,d.jsx)(fn,{listFooterLinks:t.researchAgentUIConfig.footerLinks})]})}var hn=()=>(0,d.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,d.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,d.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 gn(){return(0,d.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,d.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,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,d.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,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,d.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,d.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,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,d.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
28
+ `))},className:`gap-2`,children:[(0,d.jsx)(s.FileSpreadsheet,{className:`w-4 h-4 flex-shrink-0`}),(0,d.jsx)(`span`,{children:`Export to Google Docs`})]})]})]}),(0,d.jsx)(Q,{})]}),(0,d.jsxs)(Z,{onSelect:()=>i.push(`/library`),className:`gap-2`,children:[(0,d.jsx)(s.History,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Z,{onSelect:()=>i.push(`/settings`),className:`gap-2`,children:[(0,d.jsx)(s.Settings,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,d.jsx)(`span`,{children:`Settings`})]})]})]}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Search options`})})]}),(0,d.jsxs)(`div`,{className:`relative hidden sm:flex shrink-0 group -ml-1`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:t,onClick:P,"aria-label":`Attach files`,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-7 w-7 rounded-md active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,children:(0,d.jsx)(s.Paperclip,{className:`w-[18px] h-[18px]`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Attach files`})})]}),(0,d.jsx)(`input`,{ref:A,type:`file`,multiple:!0,onChange:t=>{t.target.files&&(e(t.target.files),t.target.value=``)},className:`hidden`})]})},vt=(0,n.forwardRef)(({active:e=!1,processing:t=!1,barWidth:r=3,barHeight:i=4,barGap:a=1,barRadius:o=1.5,barColor:s,fadeEdges:c=!0,fadeWidth:l=24,height:u=64,sensitivity:f=1,smoothingTimeConstant:p=.8,fftSize:m=256,historySize:h=60,updateRate:g=30,mode:_=`static`,onError:v,onStreamReady:y,onStreamEnd:b,className:x,...S},C)=>{let w=(0,n.useRef)(null),T=(0,n.useRef)(null),E=(0,n.useRef)(null),D=(0,n.useRef)(null),O=(0,n.useRef)(null),k=(0,n.useRef)(0),A=(0,n.useRef)([]),j=(0,n.useRef)(0),M=(0,n.useRef)(0),N=(0,n.useCallback)(()=>{k.current&&=(cancelAnimationFrame(k.current),0),O.current&&=(O.current.disconnect(),null),D.current&&=(D.current.getTracks().forEach(e=>e.stop()),null),T.current&&=(T.current.close().catch(()=>{}),null),E.current=null,A.current=[],b?.()},[b]),P=(0,n.useCallback)((e,t,n,s,c)=>{let l=r+a,u=Math.floor(t/c/l),d=u*l-a,p=(t/c-d)/2,m=s.length;for(let t=0;t<u;t++){let a=s[Math.floor(t/u*m)]/255*f,d=Math.max(i,n/c*a),h=p+t*l,g=(n/c-d)/2;e.beginPath(),e.roundRect(h*c,g*c,r*c,d*c,o*c),e.fill()}},[r,a,i,o,f]),F=(0,n.useCallback)((e,t,n,s)=>{let c=A.current,l=r+a,u=Math.min(c.length,h),d=t/s-u*l;for(let t=0;t<u;t++){let a=c[c.length-u+t]*f,p=Math.max(i,n/s*a),m=d+t*l,h=(n/s-p)/2;e.beginPath(),e.roundRect(m*s,h*s,r*s,p*s,o*s),e.fill()}},[r,a,i,o,f,h]),I=(0,n.useCallback)((e,t,n,s,c)=>{let l=r+a,u=Math.floor(t/s/l),d=u*l-a,f=(t/s-d)/2;for(let t=0;t<u;t++){let a=Math.sin(t/u*Math.PI*2+c)*.5+.5,d=Math.max(i,n/s*a*.6),p=f+t*l,m=(n/s-d)/2;e.beginPath(),e.roundRect(p*s,m*s,r*s,d*s,o*s),e.fill()}},[r,a,i,o]),L=(0,n.useCallback)((e,t,n)=>{if(!c)return;e.save(),e.globalCompositeOperation=`destination-in`;let r=e.createLinearGradient(0,0,t,0);r.addColorStop(0,`rgba(0,0,0,0)`),r.addColorStop(Math.min(l/(t||1),.3),`rgba(0,0,0,1)`),r.addColorStop(Math.max(1-l/(t||1),.7),`rgba(0,0,0,1)`),r.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=r,e.fillRect(0,0,t,n),e.restore()},[c,l]);return(0,n.useEffect)(()=>{if(!e&&!t){let e=w.current;if(e){let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height)}return}let n=!0,r=i=>{if(!n)return;let a=w.current;if(!a){k.current=requestAnimationFrame(r);return}if(i-M.current<g){k.current=requestAnimationFrame(r);return}M.current=i;let o=window.devicePixelRatio||1,c=a.getBoundingClientRect(),l=c.width*o,u=c.height*o;(a.width!==l||a.height!==u)&&(a.width=l,a.height=u);let d=a.getContext(`2d`);if(!d){k.current=requestAnimationFrame(r);return}if(d.clearRect(0,0,l,u),d.fillStyle=s||getComputedStyle(a).getPropertyValue(`color`)||`#888`,d.save(),d.setTransform(1,0,0,1,0,0),t&&!e)j.current+=.06,I(d,l,u,o,j.current);else if(e&&E.current){let e=new Uint8Array(E.current.frequencyBinCount);if(E.current.getByteFrequencyData(e),_===`scrolling`){let t=0;for(let n=0;n<e.length;n++)t+=e[n];let n=t/e.length/255;A.current.push(n),A.current.length>h*2&&(A.current=A.current.slice(-h)),F(d,l,u,o)}else P(d,l,u,e,o)}L(d,l,u),d.restore(),k.current=requestAnimationFrame(r)};return k.current=requestAnimationFrame(r),()=>{n=!1,k.current&&=(cancelAnimationFrame(k.current),0)}},[e,t,_,s,g,h,P,F,I,L]),(0,n.useEffect)(()=>{if(!e){N();return}let t=!1;return(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(t){e.getTracks().forEach(e=>e.stop());return}let n=new AudioContext,r=n.createAnalyser();r.fftSize=m,r.smoothingTimeConstant=p;let i=n.createMediaStreamSource(e);i.connect(r),T.current=n,E.current=r,D.current=e,O.current=i,y?.(e)}catch(e){t||v?.(e instanceof Error?e:Error(String(e)))}})(),()=>{t=!0,N()}},[e,m,p,N,v,y]),(0,d.jsx)(`div`,{ref:C,className:x,style:{height:typeof u==`number`?`${u}px`:u,width:`100%`,position:`relative`},...S,children:(0,d.jsx)(`canvas`,{ref:w,style:{width:`100%`,height:`100%`,display:`block`,color:s||`currentColor`}})})});vt.displayName=`LiveWaveform`;var yt=[`What are you curious to research?`,`Search the latest news...`,`Analyze a video, doc, or URL...`,`Find academic research on...`,`Compare products to buy...`],bt={initial:{},animate:{transition:{staggerChildren:.025}},exit:{transition:{staggerChildren:.015,staggerDirection:-1}}},xt={initial:{opacity:0,filter:`blur(12px)`,y:10},animate:{opacity:1,filter:`blur(0px)`,y:0,transition:{opacity:{duration:.25},filter:{duration:.4},y:{type:`spring`,stiffness:80,damping:20}}},exit:{opacity:0,filter:`blur(12px)`,y:-10,transition:{opacity:{duration:.2},filter:{duration:.3},y:{type:`spring`,stiffness:80,damping:20}}}},St=({onNewChat:e})=>{let{loading:t,sendMessage:r,stopStreaming:i,files:a,fileIds:o,setFiles:l,setFileIds:f,newChat:p,sections:m}=q(),[h,g]=(0,n.useState)(``),_=(0,n.useRef)(null),v=(0,n.useRef)(null),{files:y,setFiles:b,pastedContent:x,setPastedContent:S,isDragging:C,handleFiles:w,onDragOver:T,onDragLeave:E,onDrop:D,handlePaste:O,resetAttachments:k}=lt({setMessage:g,contextFiles:a,contextFileIds:o,setContextFiles:l,setContextFileIds:f}),A=()=>{g(``),k(),_.current&&(_.current.style.height=`auto`)},{isListening:j,toggleSpeech:M,isSpeechSupported:N}=it(e=>g(e),()=>{g(e=>(e.trim()&&setTimeout(()=>{r(e),A()},0),e))}),[P,F]=(0,n.useState)(0),[I,L]=(0,n.useState)(!0),[R,z]=(0,n.useState)(!1),[ee,te]=(0,n.useState)([]),[B,ne]=(0,n.useState)([]),[V,H]=(0,n.useState)(-1),[re,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(`below`),K=(0,n.useRef)(!1),ie=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(K.current){K.current=!1;return}let{query:e}=ae(h);if(!R||e.length<2){te([]),ne([]),U(!1),H(-1);return}let t=setTimeout(async()=>{ie.current?.abort();let t=new AbortController;ie.current=t;try{let{data:n,error:r}=await(0,c.autocomplete)({query:{q:e,limit:8},signal:t.signal});if(r)return;let i=Array.isArray(n?.suggestions)?n.suggestions:[],a=Array.isArray(n?.domains)?n.domains:[];if(te(i),ne(a),i.length+a.length>0){if(v.current){let e=v.current.getBoundingClientRect(),t=window.innerHeight-e.bottom,n=e.top;t<Math.min(288,(i.length+a.length)*36)&&n>t?G(`above`):G(`below`)}U(!0)}else U(!1);H(-1)}catch(e){e?.name!==`AbortError`&&console.error(`Autocomplete fetch failed`,e)}},180);return()=>clearTimeout(t)},[h,R]);let ae=e=>{let t=e.trimEnd();if(!t)return{prefix:``,query:``};let n=t.split(/\s+/),r=Math.min(4,n.length),i=n.slice(-r).join(` `);return{prefix:n.length>r?n.slice(0,-r).join(` `)+` `:``,query:i}},oe=e=>{K.current=!0;let{prefix:t}=ae(h);g(t+e),te([]),ne([]),U(!1),H(-1),_.current?.focus()},se=e=>{U(!1),H(-1),window.location.href=`https://${e.domain}`},ce=B.length+ee.length,le=e=>{e<B.length?se(B[e]):oe(ee[e-B.length])};(0,n.useEffect)(()=>{if(R||h)return;let e=setInterval(()=>{L(!1),setTimeout(()=>{F(e=>(e+1)%yt.length),L(!0)},400)},3e3);return()=>clearInterval(e)},[R,h]),(0,n.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&(h||z(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]),(0,n.useEffect)(()=>{_.current&&(_.current.style.height=`auto`,_.current.style.height=Math.min(_.current.scrollHeight,384)+`px`)},[h]);let ue=()=>{t||!h.trim()&&y.length===0&&x.length===0||(r(h),A())},de=e=>{if(re&&ce>0){if(e.key===`ArrowDown`){e.preventDefault(),H(e=>(e+1)%ce);return}if(e.key===`ArrowUp`){e.preventDefault(),H(e=>e<=0?ce-1:e-1);return}if(e.key===`Escape`){e.preventDefault(),U(!1),H(-1);return}if(e.key===`Tab`&&V>=0){e.preventDefault(),le(V);return}if(e.key===`Enter`&&!e.shiftKey&&V>=0){e.preventDefault(),le(V);return}let t=parseInt(e.key,10);if(t>=1&&t<=ce&&t<=9){e.preventDefault(),le(t-1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ue())},fe=!!(h.trim()||y.length>0||x.length>0);return(0,d.jsxs)(`div`,{className:`relative w-full max-w-2xl mx-auto transition-all duration-300 font-sans`,onDragOver:T,onDragLeave:E,onDrop:D,children:[(0,d.jsxs)(u.motion.div,{ref:v,className:`!box-content flex flex-col mx-2 md:mx-0 items-stretch relative z-10 rounded-[28px] bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent cursor-text font-sans antialiased`,animate:{boxShadow:R||h?`0 8px 32px 0 rgba(0,0,0,0.16)`:`0 2px 8px 0 rgba(0,0,0,0.08)`},transition:{type:`spring`,stiffness:120,damping:18},onClick:()=>z(!0),children:[(y.length>0||x.length>0)&&(0,d.jsxs)(`div`,{className:`flex gap-3 overflow-x-auto custom-scrollbar px-3 pt-3 pb-1`,children:[x.map(e=>(0,d.jsx)(rt,{content:e,onRemove:e=>S(t=>t.filter(t=>t.id!==e))},e.id)),y.map(e=>(0,d.jsx)(nt,{file:e,onRemove:e=>b(t=>t.filter(t=>t.id!==e))},e.id))]}),j&&(0,d.jsx)(`div`,{className:`px-3 pt-2`,children:(0,d.jsx)(vt,{active:j,mode:`static`,height:48,barWidth:3,barGap:2,barColor:`gray`,fadeEdges:!0,sensitivity:1.2,className:`w-full rounded-lg`})}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2 p-3`,children:[(0,d.jsx)(_t,{onFileSelect:w,disabled:t}),(0,d.jsxs)(`div`,{className:`relative flex-1`,children:[(0,d.jsx)(`div`,{className:`max-h-96 w-full overflow-y-auto custom-scrollbar`,children:(0,d.jsx)(`textarea`,{ref:_,value:h,onChange:e=>g(e.target.value),onPaste:O,onKeyDown:de,onFocus:()=>z(!0),className:`w-full bg-transparent border-0 outline-none text-text-200 dark:text-text-100 text-[16px] resize-none overflow-hidden py-1 leading-relaxed block font-normal antialiased`,rows:1,autoFocus:!0,style:{minHeight:`1.5em`}})}),(0,d.jsx)(`div`,{className:`absolute left-0 top-0 w-full h-full pointer-events-none flex items-center`,children:(0,d.jsx)(u.AnimatePresence,{mode:`wait`,children:I&&!R&&!h&&(0,d.jsx)(u.motion.span,{className:`absolute left-0 top-1/2 -translate-y-1/2 text-text-400 select-none pointer-events-none text-[16px] font-normal`,style:{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},variants:bt,initial:`initial`,animate:`animate`,exit:`exit`,children:yt[P].split(``).map((e,t)=>(0,d.jsx)(u.motion.span,{variants:xt,style:{display:`inline-block`},children:e===` `?`\xA0`:e},t))},P)})})]}),N&&(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),M()},disabled:t,className:`transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95
29
+ ${j?`text-red-500 bg-red-500/10 animate-pulse`:`text-text-400 hover:text-text-200 hover:bg-bg-200`}
30
+ `,"aria-label":j?`Stop listening`:`Voice input`,children:(0,d.jsx)($.Mic,{className:`w-5 h-5`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:j?`Stop listening`:`Voice input`})})]}),m.length>0&&(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),p()},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,d.jsx)($.SquarePen,{className:`w-5 h-5`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`New chat`})})]}),(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[t?(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},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,d.jsx)($.Stop,{className:`w-3.5 h-3.5 fill-current`})}):(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue()},disabled:!fe,className:`inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
31
+ ${fe?`bg-accent text-bg-0 hover:bg-accent-hover shadow-md`:`bg-bg-300 text-text-400 cursor-default opacity-50`}
32
+ `,type:`button`,"aria-label":`Send message`,children:(0,d.jsx)($.ArrowUp,{className:`w-4 h-4`})}),(0,d.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,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,d.jsx)(u.AnimatePresence,{children:re&&ce>0&&(0,d.jsx)(u.motion.div,{ref:e=>{e&&v.current&&v.current.contains(e)},initial:{opacity:0,y:W===`above`?4:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:W===`above`?4:-4},transition:{duration:.12},className:`absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${W===`above`?`bottom-full`:`top-full`}`,onMouseDown:e=>e.preventDefault(),children:(0,d.jsxs)(`ul`,{className:`max-h-72 overflow-y-auto custom-scrollbar py-1`,children:[B.map((e,t)=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>H(t),onClick:()=>se(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t===V?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:t+1}),(0,d.jsx)(`img`,{src:e.favicon,alt:``,className:`w-4 h-4 rounded-sm shrink-0`}),(0,d.jsx)(`span`,{className:`truncate font-medium`,children:e.name||e.domain}),(0,d.jsx)(`span`,{className:`truncate text-[13px] text-text-400 shrink-0`,children:e.domain})]})},`domain-${e.domain}`)),ee.map((e,t)=>{let n=B.length+t;return(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>H(n),onClick:()=>oe(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n===V?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:n+1}),(0,d.jsx)(s.Search,{className:`w-4 h-4 text-text-400 shrink-0`}),(0,d.jsx)(`span`,{className:`truncate`,children:e})]})},`${e}-${t}`)})]})})}),C&&(0,d.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,d.jsx)($.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,d.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})};function Ct({...e}){return(0,d.jsx)(S.Root,{"data-slot":`dialog`,...e})}function wt({...e}){return(0,d.jsx)(S.Trigger,{"data-slot":`dialog-trigger`,...e})}function Tt({...e}){return(0,d.jsx)(S.Portal,{"data-slot":`dialog-portal`,...e})}function Et({className:e,...t}){return(0,d.jsx)(S.Overlay,{"data-slot":`dialog-overlay`,className:E(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs`,e),...t})}function Dt({className:e,children:t,hideCloseButton:n=!1,...r}){return(0,d.jsxs)(Tt,{"data-slot":`dialog-portal`,children:[(0,d.jsx)(Et,{}),(0,d.jsxs)(S.Content,{"data-slot":`dialog-content`,"aria-describedby":r[`aria-describedby`]??void 0,className:E(`z-[9999] bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200`,e),...r,children:[t,!n&&(0,d.jsxs)(S.Close,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,d.jsx)(s.XIcon,{}),(0,d.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Ot({className:e,...t}){return(0,d.jsx)(S.Title,{"data-slot":`dialog-title`,className:E(`text-lg leading-none font-semibold`,e),...t})}function kt({className:e,...t}){return(0,d.jsx)(S.Description,{"data-slot":`dialog-description`,className:E(`text-muted-foreground text-sm`,e),...t})}var At=n.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`span`,{ref:n,className:E(`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%)`},...t}));At.displayName=`VisuallyHidden`;var jt=({onClose:e})=>(0,d.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,d.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,d.jsx)(s.X,{className:`h-5 w-5`})})}),Mt=(0,b.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 Nt({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,d.jsx)(r?y.Slot:`button`,{"data-slot":`button`,className:E(Mt({variant:t,size:n,className:e})),...i})}var Pt=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:r,isHighlightMode:i,onAskClick:a,onSuggestClick:o,onCopyClick:c,onFavoriteClick:l,onHighlightToggle:u})=>(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,d.jsxs)(Nt,{onClick:a,disabled:e,variant:`ghost`,size:`sm`,className:E(`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,d.jsx)(s.Bot,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]}),(0,d.jsxs)(Nt,{onClick:o,disabled:t,variant:`ghost`,size:`sm`,className:E(`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,d.jsx)(s.MessageCircleQuestion,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]}),(0,d.jsx)(Nt,{onClick:c,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:(0,d.jsx)(s.Clipboard,{className:`size-4`})}),(0,d.jsx)(Nt,{onClick:u,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,i?`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`),title:i?`Disable highlighting`:`Enable highlighting`,children:(0,d.jsx)(s.Highlighter,{className:`size-4`})}),(0,d.jsx)(Nt,{onClick:l,disabled:n,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,r?`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`),title:r?`Remove from favorites`:`Add to favorites`,children:(0,d.jsx)(s.Star,{className:E(`size-4`,r&&`fill-yellow-400`)})})]}),Ft=({value:e,onChange:t,onSubmit:n})=>(0,d.jsx)(`div`,{className:`relative`,children:(0,d.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`})}),It=({questions:e,isLoading:r,error:i,onQuestionClick:a})=>{let o=n.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,d.jsxs)(d.Fragment,{children:[o.length>0&&(0,d.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.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}),o.map((e,t)=>(0,d.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))]})]}),r&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),i&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:i})]})},Lt=({response:e,isLoading:t,error:n})=>(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,d.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Rt=({html:e,isHighlightMode:t=!1})=>{let[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{i(C.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,d.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t?`select-text`:``}`,dangerouslySetInnerHTML:{__html:r}})},zt=({article:e,isHighlightMode:t})=>(0,d.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.url&&(0,d.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 mb-3 text-sm text-primary hover:underline truncate max-w-full`,children:[(0,d.jsx)(s.ExternalLink,{className:`flex-shrink-0 size-3.5`}),(0,d.jsx)(`span`,{className:`truncate`,children:e.url})]}),e.cite&&(0,d.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,d.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,d.jsxs)(`p`,{children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,d.jsx)(`div`,{id:`article-content`,children:(0,d.jsx)(Rt,{html:e.html||``,isHighlightMode:t})})]})}),Bt=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,Vt=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function Ht(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 Ut(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function Wt(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(Vt.lastIndex=0;(r=Vt.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(Bt.lastIndex=0;(a=Bt.exec(t))!==null;){let e=a[0],n=a.index;if(Vt.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}Ht(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=Ut(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function Gt(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function Kt(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function qt({code:e}){let[t,r]=(0,n.useState)(!1);return(0,d.jsx)(`button`,{onClick:(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]),className:E(`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,d.jsx)(s.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,d.jsx)(s.Copy,{className:`h-4 w-4`})})}function Jt({children:e}){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;i(t.trim())}}},[e]),(0,d.jsxs)(`div`,{className:`relative group my-5`,children:[(0,d.jsx)(`pre`,{ref:t,className:E(`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}),r&&(0,d.jsx)(qt,{code:r})]})}var Yt=n.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,d.jsx)(`div`,{className:E(`text-muted-foreground text-sm`,t),children:`No content`});let r=Wt(e);return(0,d.jsx)(`div`,{className:E(`kortix-markdown`,t),children:(0,d.jsx)(T.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,d.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,d.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,d.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,d.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,d.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,d.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,d.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,d.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,d.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,d.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=Gt(e),r=e?.startsWith(`#`),i=E(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return r?(0,d.jsx)(`a`,{href:e,onClick:t=>Kt(t,e),className:i,children:t}):n?(0,d.jsx)(w.default,{href:e||`#`,className:i,children:t}):(0,d.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:i,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,d.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,d.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,d.jsx)(Jt,{children:e}),blockquote:({children:e})=>(0,d.jsx)(`blockquote`,{className:E(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,d.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,d.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,d.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,d.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,d.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,d.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,d.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,d.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,d.jsxs)(`span`,{className:`block my-5`,children:[(0,d.jsx)(`img`,{src:e,alt:t||``,className:E(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,d.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,d.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,d.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,d.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,d.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:E(`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,...r})=>(0,d.jsx)(`div`,{className:E(`text-sm text-foreground`,n),style:t,...r,children:e}),span:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`span`,{className:E(`text-foreground`,n),style:t,...r,children:e})},children:r})})});Yt.displayName=`UnifiedMarkdown`;var Xt=e=>{let{isOpen:r,url:i,searchText:a,panelWidth:o,setPanelWidth:s,closePanel:l}=A(),{isAuthenticated:u}=ye(),f=e.isOpen===void 0?r:e.isOpen,m=e.onClose||l,h=e.url||i,g=e.searchText===void 0?a:e.searchText,[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)([]),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(t.researchAgentUIConfig.defaultSummarizePrompt),[T,E]=(0,n.useState)(!1),[D,O]=(0,n.useState)(!1),[k,j]=(0,n.useState)(!1),[M,N]=(0,n.useState)(``),[P,F]=(0,n.useState)(``),[I,L]=(0,n.useState)([]),[R,z]=(0,n.useState)(``),[ee,te]=(0,n.useState)(!1),[B,ne]=(0,n.useState)(!1),[V,H]=(0,n.useState)(!1),[re,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(o),[K,ie]=(0,n.useState)(!1),[ae,oe]=(0,n.useState)(!1),se=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=()=>{U(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(!K)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));G(n),s(n)},t=()=>{ie(!1)};return K&&(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=``}},[K,s]),(0,n.useEffect)(()=>{f&&h?(oe(!1),ce()):f||oe(!1)},[f,h]);let ce=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,h);try{let e=new URL(h);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(h))){p.toast.error(`Cannot extract articles from search result pages`),E(!1),oe(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,h),p.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,h,e)}E(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:h}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:h}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:h}}),i=r?.article;i&&(v(i),i.followUpQuestions?.length>0&&L(i.followUpQuestions)),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(v(t),t?.followUpQuestions&&t.followUpQuestions.length>0&&L(t.followUpQuestions)),u&&le()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),p.toast.error(`Failed to load article`)}finally{E(!1),oe(!0)}},le=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===h);te(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},ue=async()=>{if(_){ne(!0);try{ee?(await(0,c.removeFavorite)({query:{url:h}}),te(!1),p.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:_.url||h,title:_.title,cite:_.cite,author:_.author,author_cite:_.author_cite,date:_.date,source:_.source,word_count:_.word_count,html:_.html}}),te(!0),p.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),p.toast.error(`Failed to toggle favorite`)}finally{ne(!1)}}},de=async e=>{if(!_)return;let n=_.html?.replace(/<[^>]*>?/g,``).slice(0,t.researchAgentUIConfig.maxArticleLength),r=e===`question`,i=r?O:j,a=r?F:z;i(!0),a(``);try{if(r){let{data:e,error:t}=await(0,c.articleQa)({body:{article:n,question:[g,C].filter(Boolean).join(`
33
+ `),chatHistory:y.slice(-5),provider:`groq`}});if(t)throw Error(t.error||`Article QA failed`);let r=e?.content||``;N(r),b(e=>[...e,{role:`user`,content:C,time:new Date().toISOString()},{role:`assistant`,content:r,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:h,question:C,answer:r}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),{data:t,error:r}=await(0,c.articleFollowups)({body:{article:n,chatHistory:y.slice(-5),maxQuestions:e,provider:`groq`}});if(r)throw Error(r.error||`Article followups failed`);let i=t?.extract||[];L(i);try{await(0,c.updateArticle)({body:{url:h,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),a(`Failed to get AI response`)}finally{i(!1)}},fe=e=>{w(e),de(`question`)},pe=async()=>{if(!_)return;let e=`${M}\n\n\n${_.cite||``}\n\n\n${_.html}`;try{await navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},me=()=>(0,d.jsxs)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:[(0,d.jsx)(jt,{onClose:m}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,d.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(Pt,{isLoadingAI:D,isLoadingFollowups:k,isLoadingFavorite:B,isFavorited:ee,isHighlightMode:V,onAskClick:()=>de(`question`),onSuggestClick:()=>de(`suggest-followups`),onCopyClick:pe,onFavoriteClick:ue,onHighlightToggle:()=>H(!V)}),x&&(0,d.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),(0,d.jsx)(Ft,{value:C,onChange:w,onSubmit:()=>de(`question`)}),(0,d.jsx)(It,{questions:I,isLoading:k,error:R,onQuestionClick:fe}),y.length>0&&(0,d.jsx)(`div`,{className:`space-y-4`,children:y.map((e,t)=>(0,d.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,d.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,d.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,d.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,d.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(D||M&&y.length===0)&&(0,d.jsx)(Lt,{response:M,isLoading:D,error:P}),P&&!D&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:P})]}),_&&(0,d.jsx)(zt,{article:_,isHighlightMode:V})]})})]});return!f||!ae?null:re?(0,d.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${W}px`},children:[(0,d.jsx)(`div`,{ref:se,onMouseDown:()=>ie(!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,d.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`})}),me()]}):(0,d.jsx)(Ct,{open:f,onOpenChange:e=>!e&&m(),children:(0,d.jsxs)(Dt,{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,d.jsx)(At,{children:(0,d.jsx)(Ot,{children:`Article Details`})}),(0,d.jsx)(`div`,{className:`h-full overflow-y-auto`,children:me()})]})})},Zt=()=>{let{sections:e,chatTurns:r,loading:i,messageAppeared:a,newChat:o,chatId:s}=q(),{isOpen:c,panelWidth:l}=A(),{isAuthenticated:u}=ye(),[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=()=>{p(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{if(r.length===1&&(document.title=`${r[0].content.substring(0,30)} - ${t.researchAgentUIConfig.appName}`),r[r.length-1]?.role===`user`){g.current=!0,h.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{g.current=!1},100);return}},[r]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:f&&c?{width:`calc(100% - ${l}px)`}:{},children:[(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${f&&!c?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,r)=>{let i=r===e.length-1;return(0,d.jsxs)(n.Fragment,{children:[(0,d.jsx)(et,{section:t,sectionIndex:r,dividerRef:i?m:void 0,isLast:i}),!i&&(0,d.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),i&&!a&&(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})})}),(0,d.jsx)(`div`,{ref:h,className:`h-0`})]}),(0,d.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,d.jsx)(St,{})})]}),(0,d.jsx)(Xt,{})]})};function Qt({radius:e=60,opacityDecay:t=.025,backgroundColor:r=`transparent`,color:i,colorGenerator:a}){let o=(0,n.useRef)(null),s=(0,n.useRef)({x:0,y:0}),c=(0,n.useRef)([]),l=()=>[Math.floor(Math.random()*130+10),Math.floor(.5*Math.random()*50),Math.floor(.5*Math.random()*255)],u=()=>i||a?.()||l();return(0,n.useEffect)(()=>{let n=o.current;if(!n)return;let i=n.getContext(`2d`);if(!i)return;let a=()=>{n.width=window.innerWidth,n.height=window.innerHeight};a();let l=()=>{i.globalCompositeOperation=`source-over`,r===`transparent`?i.clearRect(0,0,n.width,n.height):(i.fillStyle=r,i.fillRect(0,0,n.width,n.height)),i.globalCompositeOperation=`lighter`;let a={col:u(),x:s.current.x,y:s.current.y,grdblur:i.createRadialGradient(s.current.x,s.current.y,0,s.current.x,s.current.y,e),alpha:1};c.current.push(a);let o=[];for(let n=0;n<c.current.length;n++){let r=c.current[n];r.grdblur.addColorStop(0,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`),r.grdblur.addColorStop(.2,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`),r.grdblur.addColorStop(.5,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`),r.grdblur.addColorStop(1,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`),i.beginPath(),i.fillStyle=r.grdblur,i.globalAlpha=r.alpha,i.arc(r.x,r.y,e,0,Math.PI*2),i.fill(),r.alpha-=t,r.alpha<=0&&o.push(n)}for(let e=o.length-1;e>=0;e--)c.current.splice(o[e],1);i.globalAlpha=1,requestAnimationFrame(l)},d=e=>{s.current.x=e.pageX,s.current.y=e.pageY},f=e=>{s.current.x=e.touches[0].pageX,s.current.y=e.touches[0].pageY};return window.addEventListener(`mousemove`,d),window.addEventListener(`touchmove`,f,{passive:!0}),window.addEventListener(`resize`,a),l(),()=>{window.removeEventListener(`mousemove`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`resize`,a)}},[e,t,r,i,a]),(0,d.jsx)(`div`,{className:`relative w-full h-screen overflow-hidden pointer-events-none`,children:(0,d.jsx)(`canvas`,{ref:o,className:`absolute inset-0`,style:{background:`transparent`}})})}var $t=`qwksearch_pinned_chats`;function en(){if(typeof window>`u`)return[];try{let e=localStorage.getItem($t);return e?JSON.parse(e):[]}catch{return[]}}function tn(e){typeof window>`u`||localStorage.setItem($t,JSON.stringify(e))}function nn(){let[e,t]=(0,n.useState)([]),[r,i]=(0,n.useState)(!0),[a,o]=(0,n.useState)(!1),[s,l]=(0,n.useState)(null),[u,d]=(0,n.useState)(!1),[f,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)([]),[y,b]=(0,n.useState)(``),[x,S]=(0,n.useState)([]),[C,w]=(0,n.useState)(!1),{isAuthenticated:T,isLoading:E}=ye(),{incognito:D,setIncognito:O}=q();(0,n.useEffect)(()=>{v(en())},[]);let k=(0,n.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),v(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return tn(n),n})},[]),A=(0,n.useMemo)(()=>[...e].sort((e,t)=>{let n=_.includes(e.id),r=_.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,_]),j=(0,n.useMemo)(()=>y.trim()?x:A,[y,x,A]),M=(0,n.useCallback)(async()=>{if(!E){i(!0);try{if(T){let{data:e,error:n}=await(0,c.listChats)();if(n&&n.status===401){let e=G().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${n.message}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=G().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([]),p.toast.error(`Failed to load chat history`)}finally{i(!1)}}},[T,E]);(0,n.useEffect)(()=>{M()},[M]);let N=(e,t)=>{e.preventDefault(),e.stopPropagation(),l(t),o(!0)},P=async()=>{if(s){d(!0);try{if(T){let{error:e}=await(0,c.deleteChatById)({path:{id:s}});if(e)throw Error(`Failed to delete chat: ${e.message}`)}else ae(s);t(e=>e.filter(e=>e.id!==s)),p.toast.success(`Chat deleted`)}catch(e){p.toast.error(e.message||`Failed to delete chat`)}finally{o(!1),l(null),d(!1)}}},F=()=>{m(!0)},I=async()=>{g(!0);try{if(T){let{error:e}=await(0,c.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${e.message}`)}else oe();t([]),p.toast.success(`All history cleared`)}catch(e){p.toast.error(e.message||`Failed to clear history`)}finally{m(!1),g(!1)}},L=()=>{O(!D),p.toast.success(D?`Private mode off`:`Private mode on — messages won't be saved`)},R=(0,n.useCallback)(async e=>{if(!e.trim()){S([]),w(!1);return}w(!0);try{if(T){let{data:t,error:n}=await(0,c.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${n.message}`);S(Array.isArray(t?.chats)?t.chats:[])}else{let t=G().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});S(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0})))}}catch(e){console.error(`Failed to search chat history:`,e),S([]),p.toast.error(`Failed to search chat history`)}finally{w(!1)}},[T]);return(0,n.useEffect)(()=>{let e=setTimeout(()=>{R(y)},300);return()=>clearTimeout(e)},[y,R]),{chats:e,sortedChats:A,displayChats:j,loading:r,pinnedIds:_,togglePin:k,incognito:D,toggleIncognito:L,searchQuery:y,searchResults:x,searching:C,handleSearchChange:(0,n.useCallback)(e=>{b(e)},[]),deleteDialogOpen:a,setDeleteDialogOpen:o,chatToDelete:s,setChatToDelete:l,deleting:u,handleDeleteClick:N,handleConfirmDelete:P,clearAllDialogOpen:f,setClearAllDialogOpen:m,clearingAll:h,handleClearAllClick:F,handleConfirmClearAll:I}}function rn({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,d.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.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,d.jsx)(s.Lock,{size:12}),(0,d.jsx)(`span`,{children:`Private`})]}),n&&(0,d.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,d.jsx)(s.Trash2,{size:12}),(0,d.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,d.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,d.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,d.jsx)(s.X,{size:14})})]})]})}function an({chat:e,isPinned:t,onTogglePin:n,onDelete:r}){let i=e.messageCount??0;return(0,d.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,d.jsxs)(w.default,{href:`/c/${e.id}`,className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[i>0&&(0,d.jsxs)(Qe,{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:[i,`Q`]}),(0,d.jsx)(Qe,{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:D(new Date,e.createdAt)})]}),(0,d.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[t&&(0,d.jsx)(s.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,d.jsx)(`button`,{onClick:t=>n(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${t?`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:t?`Unpin chat`:`Pin chat`,children:(0,d.jsx)(s.Pin,{size:14})}),(0,d.jsx)(`button`,{onClick:t=>r(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,d.jsx)(s.Trash,{size:14})})]})}function on({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,loadingLabel:a,loading:o,onConfirm:s}){return(0,d.jsx)(Ct,{open:e,onOpenChange:e=>{!e&&!o&&t(!1)},children:(0,d.jsxs)(Dt,{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,d.jsx)(Ot,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,d.jsx)(kt,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:r}),(0,d.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,d.jsx)(`button`,{onClick:()=>{o||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,d.jsx)(`button`,{onClick:s,disabled:o,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:o?a:i})]})]})})}function sn({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:o,setClearAllDialogOpen:s,clearingAll:c,onConfirmClearAll:l}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(on,{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,d.jsx)(on,{open:o,onOpenChange:s,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:c,onConfirm:l})]})}var cn={Today:(0,d.jsx)(s.Sun,{size:12}),Yesterday:(0,d.jsx)(s.Clock,{size:12}),"This Week":(0,d.jsx)(s.CalendarDays,{size:12}),Older:(0,d.jsx)(s.Archive,{size:12})};function ln(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()-6*864e5),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 un=({showLabel:e=!1})=>{let t=nn();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(Ct,{children:[(0,d.jsxs)(wt,{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,d.jsx)(s.History,{size:e?14:18}),e&&(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Dt,{className:`max-w-[420px] p-3`,children:[(0,d.jsx)(Ot,{className:`sr-only`,children:`Chat History`}),(0,d.jsx)(rn,{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,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.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,d.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,d.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,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,d.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,d.jsx)(an,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):ln(t.displayChats).map(({label:e,chats:n})=>(0,d.jsxs)(`div`,{children:[(0,d.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:[cn[e],e]}),n.map(e=>(0,d.jsx)(an,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,d.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,d.jsx)(w.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,d.jsx)(sn,{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})]})};function dn(){let{chats:e,loading:t}=nn(),n=[...e].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,3);return t?null:(0,d.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,d.jsx)(un,{showLabel:!0}),n.map(e=>(0,d.jsx)(w.default,{href:`/c/${e.id}`,className:`px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 truncate max-w-[160px]`,title:e.title,children:e.title},e.id))]})}function fn({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:n=`bg-black/40`}){return(0,d.jsx)(`div`,{className:`absolute bottom-2 left-1/2 -translate-x-1/2 text-slate-200 text-xs z-20 ${n} rounded-lg px-2 py-1 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 flex flex-wrap items-center justify-center gap-x-6 max-w-[90vw]`,children:(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto grid grid-cols-3 gap-2`,children:e.map(({url:e,text:n,icon:r})=>{let i=r?s[r]:null,a=e.startsWith(`http`),o=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,d.jsxs)(d.Fragment,{children:[t&&i&&(0,d.jsx)(i,{size:14}),(0,d.jsx)(`span`,{className:`font-semibold tracking-wide text-md`,style:{fontVariant:`small-caps`},children:n}),(0,d.jsx)(`span`,{className:`absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return a?(0,d.jsx)(`a`,{href:e,...o,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e):(0,d.jsx)(w.default,{href:e,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e)})})})}function pn(){let e=`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(`,`);return`https://i.imgur.com/`+e[Math.floor(Math.random()*e.length)]}function mn(){let{sendMessage:e}=q(),[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)({os:``});(0,n.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;i(pn());let e=setInterval(()=>{let e=pn();o(e),c(!0),setTimeout(()=>{i(e),c(!1),o(null)},1e3)},2e4);return()=>clearInterval(e)},[]),(0,n.useEffect)(()=>{if(typeof window<`u`){let e=window.navigator.userAgent.toLowerCase();e.includes(`win`)?u({os:`Windows`}):e.includes(`mac`)?u({os:`MacOS`}):u({os:`Other`})}},[]);let f=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),p=(e,t)=>f(e)?(0,d.jsx)(`video`,{src:e,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e):(0,d.jsx)(`img`,{src:e,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e);return(0,d.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,d.jsxs)(`div`,{className:`fixed inset-0 z-0`,children:[r&&p(r,s?`opacity-0`:`opacity-30`),a&&p(a,s?`opacity-30`:`opacity-0`),(0,d.jsx)(Qt,{})]}),(0,d.jsx)(`div`,{className:`relative z-10`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-screen max-w-screen-sm mx-auto p-2 pb-20 md:pb-2`,children:[(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,d.jsxs)(`p`,{className:`text-lg text-gray-500 text-center justify-center mt-4`,children:[(0,d.jsx)(`a`,{"aria-label":`Chrome Web Store`,className:`download-chrome download-btn text-center justify-center`,target:`_blank`,href:t.researchAgentUIConfig.downloadChromeUrl}),(0,d.jsx)(`a`,{"aria-label":`Microsoft Store`,className:`download-windows download-btn text-center justify-center`,target:`_blank`,href:l.os==`Windows`?`ms-windows-store://pdp/?productid=${t.researchAgentUIConfig.downloadWindowsStoreId}`:`https://apps.microsoft.com/detail/${t.researchAgentUIConfig.downloadWindowsStoreId}?rtc=1`})]}),(0,d.jsxs)(`div`,{className:`w-full max-w-2xl mt-8 space-y-2`,children:[(0,d.jsx)(dn,{}),(0,d.jsx)(St,{})]})]})}),(0,d.jsx)(fn,{listFooterLinks:t.researchAgentUIConfig.footerLinks})]})}var hn=()=>(0,d.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,d.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,d.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 gn(){return(0,d.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,d.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,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,d.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,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,d.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,d.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,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,d.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
34
34
  DATABASE_URL=file:./data/qwksearch.db
35
35
 
36
36
  # Auth (generate: openssl rand -base64 32)
@@ -48,4 +48,4 @@ OPENAI_API_KEY=sk-your_key_here
48
48
  OPENAI_BASE_URL=https://api.openai.com/v1
49
49
 
50
50
  # Or Anthropic
51
- ANTHROPIC_API_KEY=sk-ant-your_key_here`})]}),(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`3. Restart the server`}),(0,d.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs`,children:`Ctrl+C, then: npm run dev`})]})]}),(0,d.jsxs)(`div`,{className:`pt-4 border-t border-black/10 dark:border-white/10`,children:[(0,d.jsx)(`h3`,{className:`font-medium text-black dark:text-white mb-2`,children:`Get API Keys:`}),(0,d.jsxs)(`ul`,{className:`space-y-2 text-sm text-black/70 dark:text-white/70`,children:[(0,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`Groq`}),` (FREE): `,(0,d.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,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`OpenAI`}),`: `,(0,d.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,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`Anthropic`}),`: `,(0,d.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,d.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,d.jsx)(`code`,{children:`SETUP_INSTRUCTIONS.md`}),` in the project root for full details.`]})]})})}var _n=()=>{let e=(0,r.useRouter)(),{hasError:t,isReady:i,notFound:a,messages:o}=J(),{isAuthenticated:s}=ve();return(0,n.useEffect)(()=>{i&&a&&!s&&e.replace(`/`)},[i,a,s,e]),t?(0,d.jsx)(gn,{}):i&&a&&!s?(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,d.jsx)(hn,{})}):i?a?(0,d.jsxs)(`div`,{className:`flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,d.jsx)(`p`,{className:`text-sm text-black/70 dark:text-white/70`,children:`This chat could not be found.`}),(0,d.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,d.jsx)(`div`,{children:o.length>0?(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(Zt,{})}):(0,d.jsx)(mn,{})}):(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,d.jsx)(hn,{})})};exports.ArticleAIResponse=Lt,exports.ArticleActionButtons=Pt,exports.ArticleContent=zt,exports.ArticleFollowupQuestions=It,exports.ArticlePanelHeader=jt,exports.ArticlePromptInput=Ft,exports.ChatProvider=ye,exports.ChatWindow=_n,exports.ExtractPanelProvider=j,exports.HistoryDialogs=sn,exports.HistoryDropdown=un,exports.LexicalArticleViewer=Rt,exports.SessionProvider=_e,exports.UnifiedMarkdown=Yt,exports.cn=E,exports.configureResearchAgentUI=t.configureResearchAgentUI,exports.formatTimeDifference=D,exports.researchAgentUIConfig=t.researchAgentUIConfig,exports.useChat=J,exports.useChatState=me,exports.useExtractPanel=A,exports.useHistoryState=nn,exports.useSession=ve;
51
+ ANTHROPIC_API_KEY=sk-ant-your_key_here`})]}),(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`3. Restart the server`}),(0,d.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs`,children:`Ctrl+C, then: npm run dev`})]})]}),(0,d.jsxs)(`div`,{className:`pt-4 border-t border-black/10 dark:border-white/10`,children:[(0,d.jsx)(`h3`,{className:`font-medium text-black dark:text-white mb-2`,children:`Get API Keys:`}),(0,d.jsxs)(`ul`,{className:`space-y-2 text-sm text-black/70 dark:text-white/70`,children:[(0,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`Groq`}),` (FREE): `,(0,d.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,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`OpenAI`}),`: `,(0,d.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,d.jsxs)(`li`,{children:[(0,d.jsx)(`strong`,{children:`Anthropic`}),`: `,(0,d.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,d.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,d.jsx)(`code`,{children:`SETUP_INSTRUCTIONS.md`}),` in the project root for full details.`]})]})})}var _n=()=>{let e=(0,r.useRouter)(),{hasError:t,isReady:i,notFound:a,messages:o}=q(),{isAuthenticated:s}=ye();return(0,n.useEffect)(()=>{i&&a&&!s&&e.replace(`/`)},[i,a,s,e]),t?(0,d.jsx)(gn,{}):i&&a&&!s?(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,d.jsx)(hn,{})}):i?a?(0,d.jsxs)(`div`,{className:`flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,d.jsx)(`p`,{className:`text-sm text-black/70 dark:text-white/70`,children:`This chat could not be found.`}),(0,d.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,d.jsx)(`div`,{children:o.length>0?(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(Zt,{})}):(0,d.jsx)(mn,{})}):(0,d.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,d.jsx)(hn,{})})};exports.ArticleAIResponse=Lt,exports.ArticleActionButtons=Pt,exports.ArticleContent=zt,exports.ArticleFollowupQuestions=It,exports.ArticlePanelHeader=jt,exports.ArticlePromptInput=Ft,exports.ChatProvider=be,exports.ChatWindow=_n,exports.ExtractPanelProvider=j,exports.HistoryDialogs=sn,exports.HistoryDropdown=un,exports.LexicalArticleViewer=Rt,exports.SessionProvider=ve,exports.UnifiedMarkdown=Yt,exports.cn=E,exports.configureResearchAgentUI=t.configureResearchAgentUI,exports.formatTimeDifference=D,exports.researchAgentUIConfig=t.researchAgentUIConfig,exports.useChat=q,exports.useChatState=he,exports.useExtractPanel=A,exports.useHistoryState=nn,exports.useSession=ye;