dexto 1.0.2 → 1.1.0
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/README.md +1 -1
- package/agents/agent-registry.json +53 -0
- package/agents/database-agent/README.md +35 -0
- package/agents/database-agent/data/example.db +0 -0
- package/agents/database-agent/database-agent-example.sql +98 -0
- package/agents/database-agent/database-agent.yml +116 -0
- package/agents/database-agent/setup-database.sh +64 -0
- package/agents/{agent.yml → default-agent.yml} +1 -1
- package/agents/image-editor-agent/Lenna.webp +0 -0
- package/agents/image-editor-agent/README.md +435 -0
- package/agents/image-editor-agent/image-editor-agent.yml +45 -0
- package/agents/music-agent/README.md +294 -0
- package/agents/music-agent/music-agent.yml +43 -0
- package/agents/product-name-researcher/README.md +98 -0
- package/agents/product-name-researcher/product-name-researcher.yml +161 -0
- package/agents/talk2pdf-agent/README.md +166 -0
- package/agents/talk2pdf-agent/talk2pdf-agent.yml +42 -0
- package/agents/triage-demo/README.md +337 -0
- package/agents/triage-demo/billing-agent.yml +76 -0
- package/agents/triage-demo/docs/billing-policies.md +246 -0
- package/agents/triage-demo/docs/company-overview.md +94 -0
- package/agents/triage-demo/docs/escalation-policies.md +301 -0
- package/agents/triage-demo/docs/product-features.md +253 -0
- package/agents/triage-demo/docs/technical-documentation.md +226 -0
- package/agents/triage-demo/escalation-agent.yml +82 -0
- package/agents/triage-demo/product-info-agent.yml +86 -0
- package/agents/triage-demo/technical-support-agent.yml +71 -0
- package/agents/triage-demo/test-scenarios.md +209 -0
- package/agents/triage-demo/triage-agent.yml +172 -0
- package/dist/src/app/chunk-CLDYRNV6.js +10139 -0
- package/dist/src/app/chunk-DYNVXGAH.js +137 -0
- package/dist/src/app/chunk-PW2PHCHR.js +83 -0
- package/dist/src/app/chunk-R4Q522DR.js +205 -0
- package/dist/src/app/chunk-UXCBS3TR.js +281 -0
- package/dist/src/app/chunk-X6LEX724.js +108 -0
- package/dist/src/app/chunk-Y33BS5SA.js +39 -0
- package/dist/src/app/{cli-confirmation-handler-EZF6AMUS.js → cli-confirmation-handler-GJHPLGOL.js} +4 -1
- package/dist/src/app/errors-5MNETGOV.js +8 -0
- package/dist/src/app/index.js +1604 -8978
- package/dist/src/app/loader-EFMKWNNQ.js +20 -0
- package/dist/src/app/path-7FT4SZMO.js +23 -0
- package/dist/src/app/{postgres-backend-7HVVW3RL.js → postgres-backend-U5MIIMUY.js} +12 -1
- package/dist/src/app/{redis-backend-2YBZSSSV.js → redis-backend-NGI67ILT.js} +38 -9
- package/dist/src/app/registry-RALMVM3P.js +14 -0
- package/dist/src/app/sqlite-backend-752UUBD4.js +245 -0
- package/dist/src/app/webui/.next/standalone/.next/BUILD_ID +1 -1
- package/dist/src/app/webui/.next/standalone/.next/app-build-manifest.json +20 -21
- package/dist/src/app/webui/.next/standalone/.next/app-path-routes-manifest.json +0 -1
- package/dist/src/app/webui/.next/standalone/.next/build-manifest.json +4 -4
- package/dist/src/app/webui/.next/standalone/.next/prerender-manifest.json +4 -82
- package/dist/src/app/webui/.next/standalone/.next/required-server-files.json +2 -3
- package/dist/src/app/webui/.next/standalone/.next/routes-manifest.json +0 -6
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/page.js +7 -3
- package/dist/src/app/webui/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js +8 -8
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js.nft.json +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page_client-reference-manifest.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app-paths-manifest.json +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/176.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/195.js +24 -0
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/620.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/80.js +5 -0
- package/dist/src/app/webui/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/pages/500.html +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/pages-manifest.json +1 -2
- package/dist/src/app/webui/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/src/app/webui/.next/standalone/.next/server/webpack-runtime.js +1 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
- package/dist/src/app/webui/.next/standalone/.next/static/css/af71306827be150e.css +3 -0
- package/dist/src/app/webui/.next/standalone/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
- package/dist/src/app/webui/.next/standalone/package.json +4 -3
- package/dist/src/app/webui/.next/standalone/public/favicon2.ico +0 -0
- package/dist/src/app/webui/.next/standalone/public/logo.svg +1 -0
- package/dist/src/app/webui/.next/standalone/public/logo_no_text.png +0 -0
- package/dist/src/app/webui/.next/standalone/server.js +1 -1
- package/dist/src/app/webui/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
- package/dist/src/app/webui/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
- package/dist/src/app/webui/.next/static/css/af71306827be150e.css +3 -0
- package/dist/src/app/webui/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
- package/dist/src/app/webui/package.json +4 -3
- package/dist/src/app/webui/public/favicon2.ico +0 -0
- package/dist/src/app/webui/public/logo.svg +1 -0
- package/dist/src/app/webui/public/logo_no_text.png +0 -0
- package/dist/src/core/chunk-7A6NQKQ3.js +193 -0
- package/dist/src/core/chunk-CZIXQNMZ.js +12191 -0
- package/dist/src/core/index.cjs +10605 -8030
- package/dist/src/core/index.d.cts +4339 -3927
- package/dist/src/core/index.d.ts +4339 -3927
- package/dist/src/core/index.js +113 -8381
- package/dist/src/core/{postgres-backend-ERZ6DP76.js → postgres-backend-LOLKTD2T.js} +9 -2
- package/dist/src/core/{redis-backend-46O7Y44C.js → redis-backend-APZ576PJ.js} +35 -10
- package/dist/src/core/sqlite-backend-KQ75DPR7.js +245 -0
- package/package.json +18 -11
- package/dist/src/app/chunk-W7G44EAE.js +0 -463
- package/dist/src/app/sqlite-backend-VRXGIKHQ.js +0 -180
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.html +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.meta +0 -8
- package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.rsc +0 -21
- package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js.nft.json +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.body +0 -0
- package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.meta +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/index.html +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/index.meta +0 -7
- package/dist/src/app/webui/.next/standalone/.next/server/app/index.rsc +0 -22
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground.html +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground.meta +0 -7
- package/dist/src/app/webui/.next/standalone/.next/server/app/playground.rsc +0 -25
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/447.js +0 -20
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/504.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/54.js +0 -5
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/624.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/server/chunks/985.js +0 -5
- package/dist/src/app/webui/.next/standalone/.next/server/pages/404.html +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/687-3e614f30982093f6.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
- package/dist/src/app/webui/.next/standalone/.next/static/css/d44f09bc2605dc76.css +0 -3
- package/dist/src/app/webui/.next/standalone/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js +0 -19
- package/dist/src/app/webui/.next/standalone/public/favicon.svg +0 -26
- package/dist/src/app/webui/.next/standalone/public/logo.png +0 -0
- package/dist/src/app/webui/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/687-3e614f30982093f6.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
- package/dist/src/app/webui/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
- package/dist/src/app/webui/.next/static/css/d44f09bc2605dc76.css +0 -3
- package/dist/src/app/webui/public/favicon.svg +0 -26
- package/dist/src/app/webui/public/logo.png +0 -0
- package/dist/src/core/chunk-6VYPSHEV.js +0 -2153
- package/dist/src/core/chunk-BYHW25EA.js +0 -41
- package/dist/src/core/sqlite-backend-M2ZPSSIZ.js +0 -184
- /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
- /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
- /package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
- /package/dist/src/app/webui/.next/standalone/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
- /package/dist/src/app/webui/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
- /package/dist/src/app/webui/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
- /package/dist/src/app/webui/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
- /package/dist/src/app/webui/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
(()=>{var e={};e.id=974,e.ids=[974],e.modules={597:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(7413),a=r(6730);function n(){return(0,s.jsx)(a.default,{})}},846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},2750:(e,t,r)=>{"use strict";r.d(t,{default:()=>r0});var s,a,n=r(687),i=r(3210),l=r.n(i),o=r(2765),d=r(6241),c=r(8043),u=r(2688);let m=(0,u.A)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),p=(0,u.A)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),h=(0,u.A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var x=r(3589);let f=(0,u.A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var g=r(3649),v=r(5336);let y=(0,u.A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),j=(0,u.A)("file-audio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]),b=(0,u.A)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),w=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function N(e){return/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/i.test(e)}function C({messages:e}){let t=(0,i.useRef)(null),[r,s]=(0,i.useState)({});return((0,i.useRef)(null),e&&0!==e.length)?(0,n.jsxs)("div",{id:"message-list-container",className:"flex flex-col space-y-3 px-4 py-2",children:[e.map((t,a)=>{let i=t.id??`msg-${a}`,l="user"===t.role,o="assistant"===t.role,u="system"===t.role,C=a===e.length-1,k=!!(t.toolName&&t.toolArgs),E=!!(t.toolName&&t.toolResult),S=k||E,A=S&&C||!!r[t.id],P=l?m:p,R=(0,d.cn)("flex items-end w-full",l?"justify-end":"justify-start",u&&"justify-center"),T=(0,d.cn)("tool"===t.role?"w-full text-muted-foreground/70 bg-secondary border border-muted/30 rounded-md text-sm":l?"p-3 rounded-xl shadow-sm max-w-[75%] bg-primary text-primary-foreground rounded-br-none text-sm":o?"p-3 rounded-xl shadow-sm max-w-[75%] bg-card text-card-foreground border border-border rounded-bl-none text-sm":u?"p-3 shadow-none w-full bg-transparent text-xs text-muted-foreground italic text-center border-none":""),D=w(t.createdAt);return(0,n.jsxs)("div",{className:R,children:[o&&(0,n.jsx)(P,{className:"h-7 w-7 mr-2 mb-1 text-muted-foreground self-start flex-shrink-0"}),"tool"===t.role&&(0,n.jsx)(h,{className:"h-7 w-7 p-1 mr-3 mt-1 rounded-full border border-border text-muted-foreground self-start flex-shrink-0"}),(0,n.jsxs)("div",{className:(0,d.cn)("flex flex-col",l?"items-end":"items-start",u&&"w-full items-center"),children:[(0,n.jsx)("div",{className:T,children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[t.toolName?(0,n.jsxs)("div",{className:"p-2 rounded border border-border bg-muted/30 hover:bg-muted/60 cursor-pointer w-full",onClick:()=>{S&&s(e=>({...e,[t.id]:!e[t.id]}))},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between text-xs font-medium",children:[(0,n.jsxs)("span",{className:"flex items-center",children:[A?(0,n.jsx)(x.A,{className:"h-4 w-4 mr-2 text-primary"}):(0,n.jsx)(f,{className:"h-4 w-4 mr-2 text-primary"}),"Tool: ",t.toolName]}),t.toolResult?(0,c.KU)(t.toolResult)?(0,n.jsx)(g.A,{className:"mx-2 h-4 w-4 text-red-500"}):(0,n.jsx)(v.A,{className:"mx-2 h-4 w-4 text-green-500"}):(0,n.jsx)(y,{className:"mx-2 h-4 w-4 animate-spin text-muted-foreground"})]}),A&&(0,n.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs font-medium",children:"Arguments:"}),(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(t.toolArgs,null,2)})]}),t.toolResult&&(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs font-medium",children:"Result:"}),(0,c.KU)(t.toolResult)?(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-red-100 text-red-700 p-2 rounded text-xs",children:"object"==typeof t.toolResult.error?JSON.stringify(t.toolResult.error,null,2):String(t.toolResult.error)}):(0,c.P2)(t.toolResult)?t.toolResult.content.map((e,t)=>{if((0,c.j0)(e)){let r=e.base64&&e.mimeType?`data:${e.mimeType};base64,${e.base64}`:e.base64;return r&&r.startsWith("data:")&&!N(r)?null:(0,n.jsx)("img",{src:r,alt:"Tool result image",className:"my-1 max-h-48 w-auto rounded border border-border"},t)}return(0,c.PI)(e)?(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:e.text},t):(0,c.EQ)(e)?(0,n.jsxs)("div",{className:"my-1 flex items-center gap-2 p-2 rounded border border-border bg-muted/50",children:[(0,n.jsx)(j,{className:"h-4 w-4 text-muted-foreground"}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.filename||"File attachment"," (",e.mimeType,")"]})]},t):(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:"object"==typeof e?JSON.stringify(e,null,2):String(e)},t)}):(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:"string"==typeof t.toolResult&&t.toolResult.startsWith("data:image")?N(t.toolResult)?(0,n.jsx)("img",{src:t.toolResult,alt:"Tool result image",className:"my-1 max-h-48 w-auto rounded border border-border"}):"Invalid image data":"object"==typeof t.toolResult?JSON.stringify(t.toolResult,null,2):String(t.toolResult)})]})]})]}):(0,n.jsxs)(n.Fragment,{children:["string"==typeof t.content&&""!==t.content.trim()&&(0,n.jsx)("p",{className:"whitespace-pre-wrap",children:t.content}),t.content&&"object"==typeof t.content&&!Array.isArray(t.content)&&(0,n.jsx)("pre",{className:"whitespace-pre-wrap overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(t.content,null,2)}),Array.isArray(t.content)&&t.content.map((e,t)=>{let r=`${i}-part-${t}`;if("text"===e.type)return(0,n.jsx)("p",{className:"whitespace-pre-wrap",children:e.text},r);if("image"===e.type&&"base64"in e&&"mimeType"in e){let t=`data:${e.mimeType};base64,${e.base64}`;return N(t)?(0,n.jsx)("img",{src:t,alt:"attachment",className:"my-2 max-h-60 w-full rounded-lg border border-border object-contain"},r):null}if("file"===e.type&&"data"in e&&"mimeType"in e){if(!e.mimeType.startsWith("audio/"))return(0,n.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(b,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm font-medium",children:e.filename||`${e.mimeType} file`}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e.mimeType})]},r);{let t=`data:${e.mimeType};base64,${e.data}`;return(0,n.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(j,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("audio",{controls:!0,src:t,className:"flex-1 h-8"}),e.filename&&(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:e.filename})]},r)}}return null}),u&&!t.content&&(0,n.jsx)("p",{className:"italic",children:"System message"})]}),t.imageData&&!Array.isArray(t.content)&&(()=>{let e=`data:${t.imageData.mimeType};base64,${t.imageData.base64}`;return N(e)?(0,n.jsx)("img",{src:e,alt:"attachment",className:"mt-2 max-h-60 w-full rounded-lg border border-border object-contain"}):null})(),t.fileData&&!Array.isArray(t.content)&&(0,n.jsx)("div",{className:"mt-2",children:t.fileData.mimeType.startsWith("audio/")?(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(j,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("audio",{controls:!0,src:`data:${t.fileData.mimeType};base64,${t.fileData.base64}`,className:"flex-1 h-8"}),t.fileData.filename&&(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:t.fileData.filename})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(b,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm font-medium",children:t.fileData.filename||`${t.fileData.mimeType} file`}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t.fileData.mimeType})]})})]})}),!u&&!S&&(0,n.jsxs)("div",{className:"text-xs text-muted-foreground mt-1 px-1 flex items-center gap-2",children:[(0,n.jsx)("span",{children:D}),o&&t.tokenCount&&(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/50 text-xs",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),t.tokenCount," tokens"]}),o&&t.model&&(0,n.jsx)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/30 text-xs",children:t.model})]})]}),l&&(0,n.jsx)(P,{className:"h-7 w-7 ml-2 mb-1 text-muted-foreground self-start flex-shrink-0"})]},i)}),(0,n.jsx)("div",{ref:t,className:"h-px"},"end-anchor")]}):null}var k=r(5616),E=r(4934),S=r(569),A=r(8599),P=r(1273),R=r(1215);function T(e){let t=function(e){let t=i.forwardRef((e,t)=>{var r;let s,a,{children:n,...l}=e,o=i.isValidElement(n)?(r=n,(a=(s=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.ref:(a=(s=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.props.ref:r.props.ref||r.ref):void 0,d=(0,A.s)(o,t);if(i.isValidElement(n)){let e=function(e,t){let r={...t};for(let s in t){let a=e[s],n=t[s];/^on[A-Z]/.test(s)?a&&n?r[s]=(...e)=>{let t=n(...e);return a(...e),t}:a&&(r[s]=a):"style"===s?r[s]={...a,...n}:"className"===s&&(r[s]=[a,n].filter(Boolean).join(" "))}return{...e,...r}}(l,n.props);return n.type!==i.Fragment&&(e.ref=d),i.cloneElement(n,e)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}(e),r=i.forwardRef((e,r)=>{let{children:s,...a}=e,l=i.Children.toArray(s),o=l.find(O);if(o){let e=o.props.children,s=l.map(t=>t!==o?t:i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null);return(0,n.jsx)(t,{...a,ref:r,children:i.isValidElement(e)?i.cloneElement(e,void 0,s):null})}return(0,n.jsx)(t,{...a,ref:r,children:s})});return r.displayName=`${e}.Slot`,r}var D=Symbol("radix.slottable");function O(e){return i.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===D}var $=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=T(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),L=r(3495),F=r(6309),M="dismissableLayer.update",I=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),z=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:o,onInteractOutside:d,onDismiss:c,...u}=e,m=i.useContext(I),[p,h]=i.useState(null),x=p?.ownerDocument??globalThis?.document,[,f]=i.useState({}),g=(0,A.s)(t,e=>h(e)),v=Array.from(m.layers),[y]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(y),b=p?v.indexOf(p):-1,w=m.layersWithOutsidePointerEventsDisabled.size>0,N=b>=j,C=function(e,t=globalThis?.document){let r=(0,L.c)(e),s=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!s.current){let s=function(){_("dismissableLayer.pointerDownOutside",r,n,{discrete:!0})},n={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=s,t.addEventListener("click",a.current,{once:!0})):s()}else t.removeEventListener("click",a.current);s.current=!1},n=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(n),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}(e=>{let t=e.target,r=[...m.branches].some(e=>e.contains(t));N&&!r&&(l?.(e),d?.(e),e.defaultPrevented||c?.())},x),k=function(e,t=globalThis?.document){let r=(0,L.c)(e),s=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!s.current&&_("dismissableLayer.focusOutside",r,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{let t=e.target;![...m.branches].some(e=>e.contains(t))&&(o?.(e),d?.(e),e.defaultPrevented||c?.())},x);return(0,F.U)(e=>{b===m.layers.size-1&&(a?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},x),i.useEffect(()=>{if(p)return r&&(0===m.layersWithOutsidePointerEventsDisabled.size&&(s=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),q(),()=>{r&&1===m.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=s)}},[p,x,r,m]),i.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),q())},[p,m]),i.useEffect(()=>{let e=()=>f({});return document.addEventListener(M,e),()=>document.removeEventListener(M,e)},[]),(0,n.jsx)($.div,{...u,ref:g,style:{pointerEvents:w?N?"auto":"none":void 0,...e.style},onFocusCapture:(0,S.m)(e.onFocusCapture,k.onFocusCapture),onBlurCapture:(0,S.m)(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:(0,S.m)(e.onPointerDownCapture,C.onPointerDownCapture)})});function q(){let e=new CustomEvent(M);document.dispatchEvent(e)}function _(e,t,r,{discrete:s}){let a=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});if(t&&a.addEventListener(e,t,{once:!0}),s)a&&R.flushSync(()=>a.dispatchEvent(n));else a.dispatchEvent(n)}z.displayName="DismissableLayer",i.forwardRef((e,t)=>{let r=i.useContext(I),s=i.useRef(null),a=(0,A.s)(t,s);return i.useEffect(()=>{let e=s.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,n.jsx)($.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var B=r(1359),U="focusScope.autoFocusOnMount",W="focusScope.autoFocusOnUnmount",H={bubbles:!1,cancelable:!0},V=i.forwardRef((e,t)=>{let{loop:r=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...o}=e,[d,c]=i.useState(null),u=(0,L.c)(a),m=(0,L.c)(l),p=i.useRef(null),h=(0,A.s)(t,e=>c(e)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let e=function(e){if(x.paused||!d)return;let t=e.target;d.contains(t)?p.current=t:K(p.current,{select:!0})},t=function(e){if(x.paused||!d)return;let t=e.relatedTarget;null!==t&&(d.contains(t)||K(p.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let r=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&K(d)});return d&&r.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[s,d,x.paused]),i.useEffect(()=>{if(d){Y.add(x);let e=document.activeElement;if(!d.contains(e)){let t=new CustomEvent(U,H);d.addEventListener(U,u),d.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let r=document.activeElement;for(let s of e)if(K(s,{select:t}),document.activeElement!==r)return}(J(d).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&K(d))}return()=>{d.removeEventListener(U,u),setTimeout(()=>{let t=new CustomEvent(W,H);d.addEventListener(W,m),d.dispatchEvent(t),t.defaultPrevented||K(e??document.body,{select:!0}),d.removeEventListener(W,m),Y.remove(x)},0)}}},[d,u,m,x]);let f=i.useCallback(e=>{if(!r&&!s||x.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){let t=e.currentTarget,[s,n]=function(e){let t=J(e);return[G(t,e),G(t.reverse(),e)]}(t);s&&n?e.shiftKey||a!==n?e.shiftKey&&a===s&&(e.preventDefault(),r&&K(n,{select:!0})):(e.preventDefault(),r&&K(s,{select:!0})):a===t&&e.preventDefault()}},[r,s,x.paused]);return(0,n.jsx)($.div,{tabIndex:-1,...o,ref:h,onKeyDown:f})});function J(e){let t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function G(e,t){for(let r of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(r,{upTo:t}))return r}function K(e,{select:t=!1}={}){if(e&&e.focus){var r;let s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&(r=e)instanceof HTMLInputElement&&"select"in r&&t&&e.select()}}V.displayName="FocusScope";var Y=function(){let e=[];return{add(t){let r=e[0];t!==r&&r?.pause(),(e=X(e,t)).unshift(t)},remove(t){e=X(e,t),e[0]?.resume()}}}();function X(e,t){let r=[...e],s=r.indexOf(t);return -1!==s&&r.splice(s,1),r}var Z=r(6963),Q=r(4503),ee=r(5605),et=i.forwardRef((e,t)=>{let{children:r,width:s=10,height:a=5,...i}=e;return(0,n.jsx)($.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:(0,n.jsx)("polygon",{points:"0,0 30,0 15,10"})})});et.displayName="Arrow";var er=r(6156),es=r(8853),ea="Popper",[en,ei]=(0,P.A)(ea),[el,eo]=en(ea),ed=e=>{let{__scopePopper:t,children:r}=e,[s,a]=i.useState(null);return(0,n.jsx)(el,{scope:t,anchor:s,onAnchorChange:a,children:r})};ed.displayName=ea;var ec="PopperAnchor",eu=i.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:s,...a}=e,l=eo(ec,r),o=i.useRef(null),d=(0,A.s)(t,o);return i.useEffect(()=>{l.onAnchorChange(s?.current||o.current)}),s?null:(0,n.jsx)($.div,{...a,ref:d})});eu.displayName=ec;var em="PopperContent",[ep,eh]=en(em),ex=i.forwardRef((e,t)=>{let{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:x="optimized",onPlaced:f,...g}=e,v=eo(em,r),[y,j]=i.useState(null),b=(0,A.s)(t,e=>j(e)),[w,N]=i.useState(null),C=(0,es.X)(w),k=C?.width??0,E=C?.height??0,S="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(u)?u:[u],R=P.length>0,T={padding:S,boundary:P.filter(ey),altBoundary:R},{refs:D,floatingStyles:O,placement:F,isPositioned:M,middlewareData:I}=(0,Q.we)({strategy:"fixed",placement:s+("center"!==l?"-"+l:""),whileElementsMounted:(...e)=>(0,ee.ll)(...e,{animationFrame:"always"===x}),elements:{reference:v.anchor},middleware:[(0,Q.cY)({mainAxis:a+E,alignmentAxis:o}),c&&(0,Q.BN)({mainAxis:!0,crossAxis:!1,limiter:"partial"===p?(0,Q.ER)():void 0,...T}),c&&(0,Q.UU)({...T}),(0,Q.Ej)({...T,apply:({elements:e,rects:t,availableWidth:r,availableHeight:s})=>{let{width:a,height:n}=t.reference,i=e.floating.style;i.setProperty("--radix-popper-available-width",`${r}px`),i.setProperty("--radix-popper-available-height",`${s}px`),i.setProperty("--radix-popper-anchor-width",`${a}px`),i.setProperty("--radix-popper-anchor-height",`${n}px`)}}),w&&(0,Q.UE)({element:w,padding:d}),ej({arrowWidth:k,arrowHeight:E}),h&&(0,Q.jD)({strategy:"referenceHidden",...T})]}),[z,q]=eb(F),_=(0,L.c)(f);(0,er.N)(()=>{M&&_?.()},[M,_]);let B=I.arrow?.x,U=I.arrow?.y,W=I.arrow?.centerOffset!==0,[H,V]=i.useState();return(0,er.N)(()=>{y&&V(window.getComputedStyle(y).zIndex)},[y]),(0,n.jsx)("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:M?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,n.jsx)(ep,{scope:r,placedSide:z,onArrowChange:N,arrowX:B,arrowY:U,shouldHideArrow:W,children:(0,n.jsx)($.div,{"data-side":z,"data-align":q,...g,ref:b,style:{...g.style,animation:M?void 0:"none"}})})})});ex.displayName=em;var ef="PopperArrow",eg={top:"bottom",right:"left",bottom:"top",left:"right"},ev=i.forwardRef(function(e,t){let{__scopePopper:r,...s}=e,a=eh(ef,r),i=eg[a.placedSide];return(0,n.jsx)("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:(0,n.jsx)(et,{...s,ref:t,style:{...s.style,display:"block"}})})});function ey(e){return null!==e}ev.displayName=ef;var ej=e=>({name:"transformOrigin",options:e,fn(t){let{placement:r,rects:s,middlewareData:a}=t,n=a.arrow?.centerOffset!==0,i=n?0:e.arrowWidth,l=n?0:e.arrowHeight,[o,d]=eb(r),c={start:"0%",center:"50%",end:"100%"}[d],u=(a.arrow?.x??0)+i/2,m=(a.arrow?.y??0)+l/2,p="",h="";return"bottom"===o?(p=n?c:`${u}px`,h=`${-l}px`):"top"===o?(p=n?c:`${u}px`,h=`${s.floating.height+l}px`):"right"===o?(p=`${-l}px`,h=n?c:`${m}px`):"left"===o&&(p=`${s.floating.width+l}px`,h=n?c:`${m}px`),{data:{x:p,y:h}}}});function eb(e){let[t,r="center"]=e.split("-");return[t,r]}var ew=i.forwardRef((e,t)=>{let{container:r,...s}=e,[a,l]=i.useState(!1);(0,er.N)(()=>l(!0),[]);let o=r||a&&globalThis?.document?.body;return o?R.createPortal((0,n.jsx)($.div,{...s,ref:t}),o):null});ew.displayName="Portal";var eN=r(6059),eC=r(5551),ek=r(3376),eE=r(2247),eS="Popover",[eA,eP]=(0,P.A)(eS,[ei]),eR=ei(),[eT,eD]=eA(eS),eO=e=>{let{__scopePopover:t,children:r,open:s,defaultOpen:a,onOpenChange:l,modal:o=!1}=e,d=eR(t),c=i.useRef(null),[u,m]=i.useState(!1),[p,h]=(0,eC.i)({prop:s,defaultProp:a??!1,onChange:l,caller:eS});return(0,n.jsx)(ed,{...d,children:(0,n.jsx)(eT,{scope:t,contentId:(0,Z.B)(),triggerRef:c,open:p,onOpenChange:h,onOpenToggle:i.useCallback(()=>h(e=>!e),[h]),hasCustomAnchor:u,onCustomAnchorAdd:i.useCallback(()=>m(!0),[]),onCustomAnchorRemove:i.useCallback(()=>m(!1),[]),modal:o,children:r})})};eO.displayName=eS;var e$="PopoverAnchor";i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=eD(e$,r),l=eR(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:d}=a;return i.useEffect(()=>(o(),()=>d()),[o,d]),(0,n.jsx)(eu,{...l,...s,ref:t})}).displayName=e$;var eL="PopoverTrigger",eF=i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=eD(eL,r),i=eR(r),l=(0,A.s)(t,a.triggerRef),o=(0,n.jsx)($.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":eG(a.open),...s,ref:l,onClick:(0,S.m)(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?o:(0,n.jsx)(eu,{asChild:!0,...i,children:o})});eF.displayName=eL;var eM="PopoverPortal",[eI,ez]=eA(eM,{forceMount:void 0}),eq=e=>{let{__scopePopover:t,forceMount:r,children:s,container:a}=e,i=eD(eM,t);return(0,n.jsx)(eI,{scope:t,forceMount:r,children:(0,n.jsx)(eN.C,{present:r||i.open,children:(0,n.jsx)(ew,{asChild:!0,container:a,children:s})})})};eq.displayName=eM;var e_="PopoverContent",eB=i.forwardRef((e,t)=>{let r=ez(e_,e.__scopePopover),{forceMount:s=r.forceMount,...a}=e,i=eD(e_,e.__scopePopover);return(0,n.jsx)(eN.C,{present:s||i.open,children:i.modal?(0,n.jsx)(eW,{...a,ref:t}):(0,n.jsx)(eH,{...a,ref:t})})});eB.displayName=e_;var eU=T("PopoverContent.RemoveScroll"),eW=i.forwardRef((e,t)=>{let r=eD(e_,e.__scopePopover),s=i.useRef(null),a=(0,A.s)(t,s),l=i.useRef(!1);return i.useEffect(()=>{let e=s.current;if(e)return(0,ek.Eq)(e)},[]),(0,n.jsx)(eE.A,{as:eU,allowPinchZoom:!0,children:(0,n.jsx)(eV,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,S.m)(e.onCloseAutoFocus,e=>{e.preventDefault(),l.current||r.triggerRef.current?.focus()}),onPointerDownOutside:(0,S.m)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;l.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:(0,S.m)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),eH=i.forwardRef((e,t)=>{let r=eD(e_,e.__scopePopover),s=i.useRef(!1),a=i.useRef(!1);return(0,n.jsx)(eV,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(s.current||r.triggerRef.current?.focus(),t.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,"pointerdown"===t.detail.originalEvent.type&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&a.current&&t.preventDefault()}})}),eV=i.forwardRef((e,t)=>{let{__scopePopover:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEscapeKeyDown:o,onPointerDownOutside:d,onFocusOutside:c,onInteractOutside:u,...m}=e,p=eD(e_,r),h=eR(r);return(0,B.Oh)(),(0,n.jsx)(V,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:(0,n.jsx)(z,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:u,onEscapeKeyDown:o,onPointerDownOutside:d,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:(0,n.jsx)(ex,{"data-state":eG(p.open),role:"dialog",id:p.contentId,...h,...m,ref:t,style:{...m.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),eJ="PopoverClose";function eG(e){return e?"open":"closed"}function eK({...e}){return(0,n.jsx)(eO,{"data-slot":"popover",...e})}function eY({className:e,align:t="center",sideOffset:r=4,...s}){return(0,n.jsx)(eq,{children:(0,n.jsx)(eB,{"data-slot":"popover-content",align:t,sideOffset:r,className:(0,d.cn)("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-md border p-4 shadow-md outline-hidden",e),...s})})}i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=eD(eJ,r);return(0,n.jsx)($.button,{type:"button",...s,ref:t,onClick:(0,S.m)(e.onClick,()=>a.onOpenChange(!1))})}).displayName=eJ,i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=eR(r);return(0,n.jsx)(ev,{...a,...s,ref:t})}).displayName="PopoverArrow";let eX=({children:e,...t})=>(0,n.jsx)(eK,{...t,children:e}),eZ=function({...e}){return(0,n.jsx)(eF,{"data-slot":"popover-trigger",...e})},eQ=i.forwardRef(({className:e,align:t="end",sideOffset:r=4,...s},a)=>(0,n.jsx)(eY,{ref:a,align:t,sideOffset:r,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s}));eQ.displayName="DropdownMenuContent";let e0=i.forwardRef(({className:e,disabled:t,...r},s)=>(0,n.jsx)("div",{ref:s,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pointer-events-none opacity-50",!t&&"hover:bg-accent hover:text-accent-foreground cursor-pointer",e),...r}));e0.displayName="DropdownMenuItem";let e1=i.forwardRef(({className:e,...t},r)=>(0,n.jsx)("div",{ref:r,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));e1.displayName="DropdownMenuSeparator";let e2=(0,u.A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);var e4=r(1860);let e5=(0,u.A)("paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]),e3=(0,u.A)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),e8=(0,u.A)("mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),e6=(0,u.A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var e7=r(5891);let e9=(0,u.A)("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);var te=r(3018),tt=r(3721),tr=Symbol("radix.slottable");function ts(e){return i.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===tr}var ta=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=function(e){let t=function(e){let t=i.forwardRef((e,t)=>{let{children:r,...s}=e;if(i.isValidElement(r)){var a;let e,n,l=(a=r,(n=(e=Object.getOwnPropertyDescriptor(a.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.ref:(n=(e=Object.getOwnPropertyDescriptor(a,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.props.ref:a.props.ref||a.ref),o=function(e,t){let r={...t};for(let s in t){let a=e[s],n=t[s];/^on[A-Z]/.test(s)?a&&n?r[s]=(...e)=>{let t=n(...e);return a(...e),t}:a&&(r[s]=a):"style"===s?r[s]={...a,...n}:"className"===s&&(r[s]=[a,n].filter(Boolean).join(" "))}return{...e,...r}}(s,r.props);return r.type!==i.Fragment&&(o.ref=t?(0,A.t)(t,l):l),i.cloneElement(r,o)}return i.Children.count(r)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}(e),r=i.forwardRef((e,r)=>{let{children:s,...a}=e,l=i.Children.toArray(s),o=l.find(ts);if(o){let e=o.props.children,s=l.map(t=>t!==o?t:i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null);return(0,n.jsx)(t,{...a,ref:r,children:i.isValidElement(e)?i.cloneElement(e,void 0,s):null})}return(0,n.jsx)(t,{...a,ref:r,children:s})});return r.displayName=`${e}.Slot`,r}(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),tn="Switch",[ti,tl]=(0,P.A)(tn),[to,td]=ti(tn),tc=i.forwardRef((e,t)=>{let{__scopeSwitch:r,name:s,checked:a,defaultChecked:l,required:o,disabled:d,value:c="on",onCheckedChange:u,form:m,...p}=e,[h,x]=i.useState(null),f=(0,A.s)(t,e=>x(e)),g=i.useRef(!1),v=!h||m||!!h.closest("form"),[y,j]=(0,eC.i)({prop:a,defaultProp:l??!1,onChange:u,caller:tn});return(0,n.jsxs)(to,{scope:r,checked:y,disabled:d,children:[(0,n.jsx)(ta.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":th(y),"data-disabled":d?"":void 0,disabled:d,value:c,...p,ref:f,onClick:(0,S.m)(e.onClick,e=>{j(e=>!e),v&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),v&&(0,n.jsx)(tp,{control:h,bubbles:!g.current,name:s,value:c,checked:y,required:o,disabled:d,form:m,style:{transform:"translateX(-100%)"}})]})});tc.displayName=tn;var tu="SwitchThumb",tm=i.forwardRef((e,t)=>{let{__scopeSwitch:r,...s}=e,a=td(tu,r);return(0,n.jsx)(ta.span,{"data-state":th(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t})});tm.displayName=tu;var tp=i.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:s=!0,...a},l)=>{let o=i.useRef(null),d=(0,A.s)(o,l),c=(0,tt.Z)(r),u=(0,es.X)(t);return i.useEffect(()=>{let e=o.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(c!==r&&t){let a=new Event("click",{bubbles:s});t.call(e,r),e.dispatchEvent(a)}},[c,r,s]),(0,n.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:d,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function th(e){return e?"checked":"unchecked"}tp.displayName="SwitchBubbleInput";let tx=i.forwardRef(({className:e,...t},r)=>(0,n.jsx)(tc,{className:(0,d.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:r,children:(0,n.jsx)(tm,{className:(0,d.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));tx.displayName=tc.displayName;var tf=Symbol("radix.slottable");function tg(e){return i.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===tf}var tv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=function(e){let t=function(e){let t=i.forwardRef((e,t)=>{let{children:r,...s}=e;if(i.isValidElement(r)){var a;let e,n,l=(a=r,(n=(e=Object.getOwnPropertyDescriptor(a.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.ref:(n=(e=Object.getOwnPropertyDescriptor(a,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?a.props.ref:a.props.ref||a.ref),o=function(e,t){let r={...t};for(let s in t){let a=e[s],n=t[s];/^on[A-Z]/.test(s)?a&&n?r[s]=(...e)=>{let t=n(...e);return a(...e),t}:a&&(r[s]=a):"style"===s?r[s]={...a,...n}:"className"===s&&(r[s]=[a,n].filter(Boolean).join(" "))}return{...e,...r}}(s,r.props);return r.type!==i.Fragment&&(o.ref=t?(0,A.t)(t,l):l),i.cloneElement(r,o)}return i.Children.count(r)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}(e),r=i.forwardRef((e,r)=>{let{children:s,...a}=e,l=i.Children.toArray(s),o=l.find(tg);if(o){let e=o.props.children,s=l.map(t=>t!==o?t:i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null);return(0,n.jsx)(t,{...a,ref:r,children:i.isValidElement(e)?i.cloneElement(e,void 0,s):null})}return(0,n.jsx)(t,{...a,ref:r,children:s})});return r.displayName=`${e}.Slot`,r}(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),ty="dismissableLayer.update",tj=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tb=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:o,onInteractOutside:d,onDismiss:c,...u}=e,m=i.useContext(tj),[p,h]=i.useState(null),x=p?.ownerDocument??globalThis?.document,[,f]=i.useState({}),g=(0,A.s)(t,e=>h(e)),v=Array.from(m.layers),[y]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(y),b=p?v.indexOf(p):-1,w=m.layersWithOutsidePointerEventsDisabled.size>0,N=b>=j,C=function(e,t=globalThis?.document){let r=(0,L.c)(e),s=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!s.current){let s=function(){tN("dismissableLayer.pointerDownOutside",r,n,{discrete:!0})},n={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=s,t.addEventListener("click",a.current,{once:!0})):s()}else t.removeEventListener("click",a.current);s.current=!1},n=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(n),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}(e=>{let t=e.target,r=[...m.branches].some(e=>e.contains(t));N&&!r&&(l?.(e),d?.(e),e.defaultPrevented||c?.())},x),k=function(e,t=globalThis?.document){let r=(0,L.c)(e),s=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!s.current&&tN("dismissableLayer.focusOutside",r,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{let t=e.target;![...m.branches].some(e=>e.contains(t))&&(o?.(e),d?.(e),e.defaultPrevented||c?.())},x);return(0,F.U)(e=>{b===m.layers.size-1&&(s?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},x),i.useEffect(()=>{if(p)return r&&(0===m.layersWithOutsidePointerEventsDisabled.size&&(a=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),tw(),()=>{r&&1===m.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=a)}},[p,x,r,m]),i.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),tw())},[p,m]),i.useEffect(()=>{let e=()=>f({});return document.addEventListener(ty,e),()=>document.removeEventListener(ty,e)},[]),(0,n.jsx)(tv.div,{...u,ref:g,style:{pointerEvents:w?N?"auto":"none":void 0,...e.style},onFocusCapture:(0,S.m)(e.onFocusCapture,k.onFocusCapture),onBlurCapture:(0,S.m)(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:(0,S.m)(e.onPointerDownCapture,C.onPointerDownCapture)})});function tw(){let e=new CustomEvent(ty);document.dispatchEvent(e)}function tN(e,t,r,{discrete:s}){let a=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});if(t&&a.addEventListener(e,t,{once:!0}),s)a&&R.flushSync(()=>a.dispatchEvent(n));else a.dispatchEvent(n)}tb.displayName="DismissableLayer",i.forwardRef((e,t)=>{let r=i.useContext(tj),s=i.useRef(null),a=(0,A.s)(t,s);return i.useEffect(()=>{let e=s.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,n.jsx)(tv.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var tC=i.forwardRef((e,t)=>{let{children:r,width:s=10,height:a=5,...i}=e;return(0,n.jsx)(tv.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:(0,n.jsx)("polygon",{points:"0,0 30,0 15,10"})})});tC.displayName="Arrow";var tk="Popper",[tE,tS]=(0,P.A)(tk),[tA,tP]=tE(tk),tR=e=>{let{__scopePopper:t,children:r}=e,[s,a]=i.useState(null);return(0,n.jsx)(tA,{scope:t,anchor:s,onAnchorChange:a,children:r})};tR.displayName=tk;var tT="PopperAnchor",tD=i.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:s,...a}=e,l=tP(tT,r),o=i.useRef(null),d=(0,A.s)(t,o);return i.useEffect(()=>{l.onAnchorChange(s?.current||o.current)}),s?null:(0,n.jsx)(tv.div,{...a,ref:d})});tD.displayName=tT;var tO="PopperContent",[t$,tL]=tE(tO),tF=i.forwardRef((e,t)=>{let{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:o=0,arrowPadding:d=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:x="optimized",onPlaced:f,...g}=e,v=tP(tO,r),[y,j]=i.useState(null),b=(0,A.s)(t,e=>j(e)),[w,N]=i.useState(null),C=(0,es.X)(w),k=C?.width??0,E=C?.height??0,S="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(u)?u:[u],R=P.length>0,T={padding:S,boundary:P.filter(tq),altBoundary:R},{refs:D,floatingStyles:O,placement:$,isPositioned:F,middlewareData:M}=(0,Q.we)({strategy:"fixed",placement:s+("center"!==l?"-"+l:""),whileElementsMounted:(...e)=>(0,ee.ll)(...e,{animationFrame:"always"===x}),elements:{reference:v.anchor},middleware:[(0,Q.cY)({mainAxis:a+E,alignmentAxis:o}),c&&(0,Q.BN)({mainAxis:!0,crossAxis:!1,limiter:"partial"===p?(0,Q.ER)():void 0,...T}),c&&(0,Q.UU)({...T}),(0,Q.Ej)({...T,apply:({elements:e,rects:t,availableWidth:r,availableHeight:s})=>{let{width:a,height:n}=t.reference,i=e.floating.style;i.setProperty("--radix-popper-available-width",`${r}px`),i.setProperty("--radix-popper-available-height",`${s}px`),i.setProperty("--radix-popper-anchor-width",`${a}px`),i.setProperty("--radix-popper-anchor-height",`${n}px`)}}),w&&(0,Q.UE)({element:w,padding:d}),t_({arrowWidth:k,arrowHeight:E}),h&&(0,Q.jD)({strategy:"referenceHidden",...T})]}),[I,z]=tB($),q=(0,L.c)(f);(0,er.N)(()=>{F&&q?.()},[F,q]);let _=M.arrow?.x,B=M.arrow?.y,U=M.arrow?.centerOffset!==0,[W,H]=i.useState();return(0,er.N)(()=>{y&&H(window.getComputedStyle(y).zIndex)},[y]),(0,n.jsx)("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:F?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(" "),...M.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,n.jsx)(t$,{scope:r,placedSide:I,onArrowChange:N,arrowX:_,arrowY:B,shouldHideArrow:U,children:(0,n.jsx)(tv.div,{"data-side":I,"data-align":z,...g,ref:b,style:{...g.style,animation:F?void 0:"none"}})})})});tF.displayName=tO;var tM="PopperArrow",tI={top:"bottom",right:"left",bottom:"top",left:"right"},tz=i.forwardRef(function(e,t){let{__scopePopper:r,...s}=e,a=tL(tM,r),i=tI[a.placedSide];return(0,n.jsx)("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:(0,n.jsx)(tC,{...s,ref:t,style:{...s.style,display:"block"}})})});function tq(e){return null!==e}tz.displayName=tM;var t_=e=>({name:"transformOrigin",options:e,fn(t){let{placement:r,rects:s,middlewareData:a}=t,n=a.arrow?.centerOffset!==0,i=n?0:e.arrowWidth,l=n?0:e.arrowHeight,[o,d]=tB(r),c={start:"0%",center:"50%",end:"100%"}[d],u=(a.arrow?.x??0)+i/2,m=(a.arrow?.y??0)+l/2,p="",h="";return"bottom"===o?(p=n?c:`${u}px`,h=`${-l}px`):"top"===o?(p=n?c:`${u}px`,h=`${s.floating.height+l}px`):"right"===o?(p=`${-l}px`,h=n?c:`${m}px`):"left"===o&&(p=`${s.floating.width+l}px`,h=n?c:`${m}px`),{data:{x:p,y:h}}}});function tB(e){let[t,r="center"]=e.split("-");return[t,r]}var tU=i.forwardRef((e,t)=>{let{container:r,...s}=e,[a,l]=i.useState(!1);(0,er.N)(()=>l(!0),[]);let o=r||a&&globalThis?.document?.body;return o?R.createPortal((0,n.jsx)(tv.div,{...s,ref:t}),o):null});tU.displayName="Portal";var tW=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),tH=i.forwardRef((e,t)=>(0,n.jsx)(tv.span,{...e,ref:t,style:{...tW,...e.style}}));tH.displayName="VisuallyHidden";var[tV,tJ]=(0,P.A)("Tooltip",[tS]),tG=tS(),tK="TooltipProvider",tY="tooltip.open",[tX,tZ]=tV(tK),tQ=e=>{let{__scopeTooltip:t,delayDuration:r=700,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:l}=e,o=i.useRef(!0),d=i.useRef(!1),c=i.useRef(0);return i.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,n.jsx)(tX,{scope:t,isOpenDelayedRef:o,delayDuration:r,onOpen:i.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,s)},[s]),isPointerInTransitRef:d,onPointerInTransitChange:i.useCallback(e=>{d.current=e},[]),disableHoverableContent:a,children:l})};tQ.displayName=tK;var t0="Tooltip",[t1,t2]=tV(t0),t4=e=>{let{__scopeTooltip:t,children:r,open:s,defaultOpen:a,onOpenChange:l,disableHoverableContent:o,delayDuration:d}=e,c=tZ(t0,e.__scopeTooltip),u=tG(t),[m,p]=i.useState(null),h=(0,Z.B)(),x=i.useRef(0),f=o??c.disableHoverableContent,g=d??c.delayDuration,v=i.useRef(!1),[y,j]=(0,eC.i)({prop:s,defaultProp:a??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(tY))):c.onClose(),l?.(e)},caller:t0}),b=i.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),w=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,v.current=!1,j(!0)},[j]),N=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,j(!1)},[j]),C=i.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{v.current=!0,j(!0),x.current=0},g)},[g,j]);return i.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),(0,n.jsx)(tR,{...u,children:(0,n.jsx)(t1,{scope:t,contentId:h,open:y,stateAttribute:b,trigger:m,onTriggerChange:p,onTriggerEnter:i.useCallback(()=>{c.isOpenDelayedRef.current?C():w()},[c.isOpenDelayedRef,C,w]),onTriggerLeave:i.useCallback(()=>{f?N():(window.clearTimeout(x.current),x.current=0)},[N,f]),onOpen:w,onClose:N,disableHoverableContent:f,children:r})})};t4.displayName=t0;var t5="TooltipTrigger",t3=i.forwardRef((e,t)=>{let{__scopeTooltip:r,...s}=e,a=t2(t5,r),l=tZ(t5,r),o=tG(r),d=i.useRef(null),c=(0,A.s)(t,d,a.onTriggerChange),u=i.useRef(!1),m=i.useRef(!1),p=i.useCallback(()=>u.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),(0,n.jsx)(tD,{asChild:!0,...o,children:(0,n.jsx)(tv.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:c,onPointerMove:(0,S.m)(e.onPointerMove,e=>{"touch"!==e.pointerType&&(m.current||l.isPointerInTransitRef.current||(a.onTriggerEnter(),m.current=!0))}),onPointerLeave:(0,S.m)(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:(0,S.m)(e.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:(0,S.m)(e.onFocus,()=>{u.current||a.onOpen()}),onBlur:(0,S.m)(e.onBlur,a.onClose),onClick:(0,S.m)(e.onClick,a.onClose)})})});t3.displayName=t5;var t8="TooltipPortal",[t6,t7]=tV(t8,{forceMount:void 0}),t9=e=>{let{__scopeTooltip:t,forceMount:r,children:s,container:a}=e,i=t2(t8,t);return(0,n.jsx)(t6,{scope:t,forceMount:r,children:(0,n.jsx)(eN.C,{present:r||i.open,children:(0,n.jsx)(tU,{asChild:!0,container:a,children:s})})})};t9.displayName=t8;var re="TooltipContent",rt=i.forwardRef((e,t)=>{let r=t7(re,e.__scopeTooltip),{forceMount:s=r.forceMount,side:a="top",...i}=e,l=t2(re,e.__scopeTooltip);return(0,n.jsx)(eN.C,{present:s||l.open,children:l.disableHoverableContent?(0,n.jsx)(ri,{side:a,...i,ref:t}):(0,n.jsx)(rr,{side:a,...i,ref:t})})}),rr=i.forwardRef((e,t)=>{let r=t2(re,e.__scopeTooltip),s=tZ(re,e.__scopeTooltip),a=i.useRef(null),l=(0,A.s)(t,a),[o,d]=i.useState(null),{trigger:c,onClose:u}=r,m=a.current,{onPointerInTransitChange:p}=s,h=i.useCallback(()=>{d(null),p(!1)},[p]),x=i.useCallback((e,t)=>{let r=e.currentTarget,s={x:e.clientX,y:e.clientY},a=function(e,t){let r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),n=Math.abs(t.left-e.x);switch(Math.min(r,s,a,n)){case n:return"left";case a:return"right";case r:return"top";case s:return"bottom";default:throw Error("unreachable")}}(s,r.getBoundingClientRect());d(function(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:1*!!(e.y>t.y)),function(e){if(e.length<=1)return e.slice();let t=[];for(let r=0;r<e.length;r++){let s=e[r];for(;t.length>=2;){let e=t[t.length-1],r=t[t.length-2];if((e.x-r.x)*(s.y-r.y)>=(e.y-r.y)*(s.x-r.x))t.pop();else break}t.push(s)}t.pop();let r=[];for(let t=e.length-1;t>=0;t--){let s=e[t];for(;r.length>=2;){let e=r[r.length-1],t=r[r.length-2];if((e.x-t.x)*(s.y-t.y)>=(e.y-t.y)*(s.x-t.x))r.pop();else break}r.push(s)}return(r.pop(),1===t.length&&1===r.length&&t[0].x===r[0].x&&t[0].y===r[0].y)?t:t.concat(r)}(t)}([...function(e,t,r=5){let s=[];switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r})}return s}(s,a),...function(e){let{top:t,right:r,bottom:s,left:a}=e;return[{x:a,y:t},{x:r,y:t},{x:r,y:s},{x:a,y:s}]}(t.getBoundingClientRect())])),p(!0)},[p]);return i.useEffect(()=>()=>h(),[h]),i.useEffect(()=>{if(c&&m){let e=e=>x(e,m),t=e=>x(e,c);return c.addEventListener("pointerleave",e),m.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),m.removeEventListener("pointerleave",t)}}},[c,m,x,h]),i.useEffect(()=>{if(o){let e=e=>{let t=e.target,r={x:e.clientX,y:e.clientY},s=c?.contains(t)||m?.contains(t),a=!function(e,t){let{x:r,y:s}=e,a=!1;for(let e=0,n=t.length-1;e<t.length;n=e++){let i=t[e],l=t[n],o=i.x,d=i.y,c=l.x,u=l.y;d>s!=u>s&&r<(c-o)*(s-d)/(u-d)+o&&(a=!a)}return a}(r,o);s?h():a&&(h(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,m,o,u,h]),(0,n.jsx)(ri,{...e,ref:l})}),[rs,ra]=tV(t0,{isInside:!1}),rn=function(e){let t=({children:e})=>(0,n.jsx)(n.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=tf,t}("TooltipContent"),ri=i.forwardRef((e,t)=>{let{__scopeTooltip:r,children:s,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:o,...d}=e,c=t2(re,r),u=tG(r),{onClose:m}=c;return i.useEffect(()=>(document.addEventListener(tY,m),()=>document.removeEventListener(tY,m)),[m]),i.useEffect(()=>{if(c.trigger){let e=e=>{let t=e.target;t?.contains(c.trigger)&&m()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,m]),(0,n.jsx)(tb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:m,children:(0,n.jsxs)(tF,{"data-state":c.stateAttribute,...u,...d,ref:t,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,n.jsx)(rn,{children:s}),(0,n.jsx)(rs,{scope:r,isInside:!0,children:(0,n.jsx)(tH,{id:c.contentId,role:"tooltip",children:a||s})})]})})});rt.displayName=re;var rl="TooltipArrow",ro=i.forwardRef((e,t)=>{let{__scopeTooltip:r,...s}=e,a=tG(r);return ra(rl,r).isInside?null:(0,n.jsx)(tz,{...a,...s,ref:t})});function rd({delayDuration:e=0,...t}){return(0,n.jsx)(tQ,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function rc({...e}){return(0,n.jsx)(rd,{children:(0,n.jsx)(t4,{"data-slot":"tooltip",...e})})}function ru({...e}){return(0,n.jsx)(t3,{"data-slot":"tooltip-trigger",...e})}function rm({className:e,sideOffset:t=0,children:r,...s}){return(0,n.jsx)(t9,{children:(0,n.jsxs)(rt,{"data-slot":"tooltip-content",sideOffset:t,className:(0,d.cn)("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-md px-3 py-1.5 text-xs text-balance",e),...s,children:[r,(0,n.jsx)(ro,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function rp({onSend:e,isSending:t}){let[r,s]=(0,i.useState)(""),a=(0,i.useRef)(null),[l,d]=(0,i.useState)(null),[c,u]=(0,i.useState)(null),m=(0,i.useRef)(null),h=(0,i.useRef)(null),x=(0,i.useRef)(null),[f,g]=(0,i.useState)(!1),v=(0,i.useRef)(null),{currentSessionId:w,isStreaming:N,setStreaming:C}=(0,o.v)(),[S,A]=(0,i.useState)("Loading..."),[P,R]=(0,i.useState)(!1),[T,D]=(0,i.useState)(null),[O,$]=(0,i.useState)(null),L=e=>{$(e),setTimeout(()=>$(null),5e3)};(0,i.useCallback)(()=>{if(a.current){a.current.style.height="auto";let e=a.current.scrollHeight;a.current.style.height=`${Math.min(e,120)}px`,a.current.style.overflowY=e>120?"auto":"hidden"}},[]);let F=()=>{let t=r.trim();(t||l||c)&&(e(t,l??void 0,c??void 0),s(""),d(null),u(null),a.current&&(a.current.style.height="auto",a.current.style.overflowY="hidden"))},M=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e);v.current=t;let r=[];t.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},t.onstop=()=>{let s=new Blob(r,{type:t.mimeType}),a=new FileReader;a.onloadend=()=>{try{let e=a.result,r=e.indexOf(","),s=e.substring(r+1),n=t.mimeType||"audio/webm",i={"audio/mp3":"mp3","audio/mpeg":"mp3","audio/wav":"wav","audio/x-wav":"wav","audio/wave":"wav","audio/webm":"webm","audio/ogg":"ogg","audio/m4a":"m4a","audio/aac":"aac"}[n]||n.split("/")[1]||"webm";u({base64:s,mimeType:n,filename:`recording.${i}`})}catch(e){L("Failed to process audio recording. Please try again."),u(null)}},a.readAsDataURL(s),e.getTracks().forEach(e=>e.stop())},t.start(),g(!0)}catch(e){L("Failed to start audio recording. Please check microphone permissions.")}},I=async e=>{R(!0),D(null);try{let t={provider:e.provider,model:e.model,router:"vercel"};w&&(t.sessionId=w);let r=await fetch("/api/llm/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await r.json();if(s.ok)A(e.name),D(null);else{let e="Failed to switch model";if(s.issues&&s.issues.length>0){let t=s.issues.filter(e=>"error"===e.severity);t.length>0&&(e=t[0].message)}else s.error&&(e=s.error);console.error("Failed to switch model:",e),D(e),setTimeout(()=>D(null),1e4)}}catch(e){console.error("Network error while switching model:",e),D("Network error while switching model"),setTimeout(()=>D(null),1e4)}finally{R(!1)}},z=r.length>0||!!l||!!c;return(0,n.jsxs)("div",{id:"input-area",className:"flex flex-col gap-2 w-full",children:[T&&(0,n.jsxs)(te.Fc,{variant:"destructive",className:"mb-2",children:[(0,n.jsx)(e2,{className:"h-4 w-4"}),(0,n.jsxs)(te.TN,{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{children:T}),(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:()=>D(null),className:"h-auto p-1 ml-2",children:(0,n.jsx)(e4.A,{className:"h-3 w-3"})})]})]}),O&&(0,n.jsxs)(te.Fc,{variant:"destructive",className:"mb-2",children:[(0,n.jsx)(e2,{className:"h-4 w-4"}),(0,n.jsxs)(te.TN,{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{children:O}),(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:()=>$(null),className:"h-auto p-1 ml-2",children:(0,n.jsx)(e4.A,{className:"h-3 w-3"})})]})]}),(0,n.jsxs)("div",{className:"flex items-end gap-2 w-full",children:[(0,n.jsxs)(eX,{children:[(0,n.jsx)(eZ,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"outline",size:"icon",className:"flex-shrink-0 text-muted-foreground hover:text-primary rounded-full p-2","aria-label":"Attach File",children:(0,n.jsx)(e5,{className:"h-8 w-8"})})}),(0,n.jsxs)(eQ,{side:"top",align:"start",children:[(0,n.jsxs)(e0,{onClick:()=>m.current?.click(),children:[(0,n.jsx)(e5,{className:"h-4 w-4 mr-2"})," Image"]}),(0,n.jsxs)(e0,{onClick:()=>h.current?.click(),children:[(0,n.jsx)(b,{className:"h-4 w-4 mr-2"})," PDF"]}),(0,n.jsxs)(e0,{onClick:()=>x.current?.click(),children:[(0,n.jsx)(j,{className:"h-4 w-4 mr-2"})," Audio file"]})]})]}),(0,n.jsx)(E.$,{variant:"outline",size:"icon",onClick:f?()=>{v.current?.stop(),g(!1)}:M,className:"flex-shrink-0 text-muted-foreground hover:text-primary rounded-full p-2","aria-label":f?"Stop recording":"Record audio",children:f?(0,n.jsx)(e3,{className:"h-8 w-8 text-red-500"}):(0,n.jsx)(e8,{className:"h-8 w-8"})}),(0,n.jsx)("input",{ref:m,type:"file",id:"image-upload",accept:"image/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){L("Image file too large. Maximum size is 64MB."),e.target.value="";return}if(!t.type.startsWith("image/")){L("Please select a valid image file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(",");if(-1===s)throw Error("Invalid Data URL format");let a=e.substring(0,s),n=e.substring(s+1),i=a.match(/data:(.*);base64/),l=i?i[1]:t.type;if(!l)throw Error("Could not determine MIME type");d({base64:n,mimeType:l}),$(null)}catch(e){L("Failed to process image file. Please try again."),d(null)}},r.onerror=e=>{L("Failed to read image file. Please try again."),d(null)},r.readAsDataURL(t),e.target.value=""}}),(0,n.jsx)("input",{ref:h,type:"file",id:"pdf-upload",accept:"application/pdf",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){L("PDF file too large. Maximum size is 64MB."),e.target.value="";return}if("application/pdf"!==t.type){L("Please select a valid PDF file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(","),a=e.substring(s+1);u({base64:a,mimeType:"application/pdf",filename:t.name}),$(null)}catch(e){L("Failed to process PDF file. Please try again."),u(null)}},r.onerror=e=>{L("Failed to read PDF file. Please try again."),u(null)},r.readAsDataURL(t),e.target.value=""}}),(0,n.jsx)("input",{ref:x,type:"file",id:"audio-upload",accept:"audio/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){L("Audio file too large. Maximum size is 64MB."),e.target.value="";return}if(!t.type.startsWith("audio/")){L("Please select a valid audio file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(","),a=e.substring(s+1);u({base64:a,mimeType:t.type,filename:t.name}),$(null)}catch(e){L("Failed to process audio file. Please try again."),u(null)}},r.onerror=e=>{L("Failed to read audio file. Please try again."),u(null)},r.readAsDataURL(t),e.target.value=""}}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col w-full",children:[l&&(0,n.jsxs)("div",{className:"relative mb-1.5 w-fit border border-border rounded-lg p-1 bg-muted/50 group",children:[(0,n.jsx)("img",{src:`data:${l.mimeType};base64,${l.base64}`,alt:"preview",className:"h-20 w-auto rounded-md"}),(0,n.jsx)(E.$,{variant:"destructive",size:"icon",onClick:()=>d(null),className:"absolute -top-2 -right-2 h-5 w-5 rounded-full bg-destructive text-destructive-foreground opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove image",children:(0,n.jsx)(e4.A,{className:"h-3 w-3"})})]}),c&&(0,n.jsxs)("div",{className:"relative mb-1.5 w-fit border border-border rounded-lg p-2 bg-muted/50 group flex items-center gap-2",children:[c.mimeType.startsWith("audio")?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j,{className:"h-6 w-6"}),(0,n.jsx)("audio",{controls:!0,src:`data:${c.mimeType};base64,${c.base64}`,className:"h-10"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b,{className:"h-6 w-6"}),(0,n.jsx)("span",{className:"text-sm font-medium max-w-[120px] truncate",children:c.filename||"attachment"})]}),(0,n.jsx)(E.$,{variant:"destructive",size:"icon",onClick:()=>u(null),className:"absolute -top-2 -right-2 h-5 w-5 rounded-full bg-destructive text-destructive-foreground opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove attachment",children:(0,n.jsx)(e4.A,{className:"h-3 w-3"})})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(k.T,{ref:a,value:r,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),F())},placeholder:"Ask Dexto anything...",rows:1,className:"resize-none min-h-[42px] w-full border-input bg-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0 rounded-lg p-2.5 pr-32 text-sm"}),(0,n.jsxs)("div",{className:"absolute bottom-1.5 right-2 flex items-center gap-2",children:[(0,n.jsx)(rd,{children:(0,n.jsxs)(rc,{children:[(0,n.jsx)(ru,{asChild:!0,children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5 cursor-pointer",children:[(0,n.jsx)(e6,{className:`h-3 w-3 ${N?"text-blue-500":"text-muted-foreground"}`}),(0,n.jsx)(tx,{checked:N,onCheckedChange:C,className:"scale-75","aria-label":"Toggle streaming"})]})}),(0,n.jsxs)(rm,{side:"top",children:[(0,n.jsx)("p",{children:N?"Streaming enabled":"Streaming disabled"}),(0,n.jsx)("p",{className:"text-xs opacity-75",children:N?"Responses will stream in real-time":"Responses will arrive all at once"})]})]})}),(0,n.jsxs)(eX,{children:[(0,n.jsx)(eZ,{asChild:!0,children:(0,n.jsxs)(E.$,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50",disabled:P,children:[(0,n.jsx)(p,{className:"h-3 w-3 mr-1"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:P?"...":S}),(0,n.jsx)(e7.A,{className:"h-3 w-3 ml-1"})]})}),(0,n.jsxs)(eQ,{align:"end",children:[[{name:"Claude 4 Sonnet",provider:"anthropic",model:"claude-4-sonnet-20250514"},{name:"GPT-4o",provider:"openai",model:"gpt-4o"},{name:"GPT-4.1 Mini",provider:"openai",model:"gpt-4.1-mini"},{name:"Gemini 2.5 Pro",provider:"google",model:"gemini-2.5-pro"}].map(e=>(0,n.jsxs)(e0,{onClick:()=>I(e),children:[(0,n.jsx)(p,{className:"h-4 w-4 mr-2"}),e.name]},e.model)),(0,n.jsx)(e1,{}),(0,n.jsx)(e0,{onClick:()=>{console.log("View all models clicked")},children:"View all models"})]})]})]})]})]}),(0,n.jsx)(E.$,{type:"submit",size:"icon",onClick:F,disabled:!r.trim()&&!l&&!c,className:"flex-shrink-0 bg-primary text-primary-foreground hover:bg-primary/90 rounded-full p-2 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-70","aria-label":"Send message",children:(0,n.jsx)(e9,{className:"h-5 w-5"})}),z&&!t&&(0,n.jsx)(E.$,{variant:"ghost",size:"icon",onClick:()=>{s(""),d(null),u(null),a.current&&(a.current.style.height="auto",a.current.style.overflowY="hidden")},className:"flex-shrink-0 text-muted-foreground hover:text-destructive rounded-full p-2 ml-1","aria-label":"Clear input",children:(0,n.jsx)(e4.A,{className:"h-5 w-5"})}),t&&(0,n.jsx)("div",{className:"flex-shrink-0 p-2 ml-1",children:(0,n.jsx)(y,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})]})}ro.displayName=rl;var rh=r(3737);class rx{constructor(){this.registryEntries=[],this.isInitialized=!1}static getInstance(){return rx.instance||(rx.instance=new rx),rx.instance}async initialize(){this.isInitialized||(this.registryEntries=this.getBuiltinEntries(),await this.loadCustomEntries(),this.isInitialized=!0)}async getEntries(e){await this.initialize();let t=[...this.registryEntries];if(e?.category&&(t=t.filter(t=>t.category===e.category)),e?.tags?.length&&(t=t.filter(t=>e.tags.some(e=>t.tags.includes(e)))),e?.search){let r=e.search.toLowerCase();t=t.filter(e=>e.name.toLowerCase().includes(r)||e.description.toLowerCase().includes(r)||e.tags.some(e=>e.toLowerCase().includes(r)))}return e?.installed!==void 0&&(t=t.filter(t=>t.isInstalled===e.installed)),e?.official!==void 0&&(t=t.filter(t=>t.isOfficial===e.official)),t.sort((e,t)=>e.isInstalled!==t.isInstalled?e.isInstalled?-1:1:e.isOfficial!==t.isOfficial?e.isOfficial?-1:1:e.popularity!==t.popularity?(t.popularity||0)-(e.popularity||0):e.name.localeCompare(t.name))}async addCustomEntry(e){let t={...e,id:`custom-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,isOfficial:!1,lastUpdated:new Date};return this.registryEntries.push(t),await this.saveCustomEntries(),t}async updateEntry(e,t){let r=this.registryEntries.findIndex(t=>t.id===e);return -1!==r&&(this.registryEntries[r]={...this.registryEntries[r],...t,lastUpdated:new Date},await this.saveCustomEntries(),!0)}async setInstalled(e,t){return this.updateEntry(e,{isInstalled:t})}async getServerConfig(e){return await this.initialize(),this.registryEntries.find(t=>t.id===e)||null}getBuiltinEntries(){return[{id:"filesystem",name:"File System",description:"Secure file operations with configurable access controls for reading and writing files",category:"productivity",icon:"\uD83D\uDCC1",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path/to/allowed/directory"],timeout:3e4},tags:["file","directory","filesystem","io"],isOfficial:!0,isInstalled:!1,popularity:95,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"github",name:"GitHub",description:"Repository management, file operations, search repositories, manage issues and pull requests",category:"development",icon:"\uD83D\uDC19",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:""},timeout:3e4},tags:["git","repository","version-control","issues","pr"],isOfficial:!0,isInstalled:!1,popularity:92,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"GitHub",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"brave-search",name:"Brave Search",description:"Web and local search using Brave's Search API for real-time information retrieval",category:"research",icon:"\uD83D\uDD0D",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"],env:{BRAVE_SEARCH_API_KEY:""},timeout:3e4},tags:["search","web","research","information"],isOfficial:!0,isInstalled:!1,popularity:88,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"sqlite",name:"SQLite",description:"Database interaction and business intelligence capabilities for SQLite databases",category:"data",icon:"\uD83D\uDDC4️",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite","/path/to/database.db"],timeout:3e4},tags:["database","sql","sqlite","query"],isOfficial:!0,isInstalled:!1,popularity:85,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"puppeteer",name:"Puppeteer",description:"Browser automation and web scraping with Puppeteer for automated testing and data extraction",category:"research",icon:"\uD83C\uDFAD",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"],timeout:3e4},tags:["browser","automation","scraping","web","testing"],isOfficial:!0,isInstalled:!1,popularity:80,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"postgresql",name:"PostgreSQL",description:"Read-only database access with schema inspection for PostgreSQL databases",category:"data",icon:"\uD83D\uDC18",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres","postgresql://localhost/mydb"],timeout:3e4},tags:["database","sql","postgresql","postgres","query"],isOfficial:!0,isInstalled:!1,popularity:83,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"slack",name:"Slack",description:"Channel management and messaging capabilities for Slack workspaces",category:"communication",icon:"\uD83D\uDCAC",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-slack"],env:{SLACK_BOT_TOKEN:""},timeout:3e4},tags:["slack","messaging","team","communication","channels"],isOfficial:!0,isInstalled:!1,popularity:75,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"fetch",name:"Fetch",description:"Web content fetching and conversion for efficient LLM usage",category:"research",icon:"\uD83C\uDF10",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"],timeout:3e4},tags:["web","fetch","content","http","download"],isOfficial:!0,isInstalled:!1,popularity:78,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"http-example",name:"HTTP MCP Server",description:"Example HTTP-based MCP server for API integrations",category:"development",icon:"\uD83C\uDF10",config:{type:"http",baseUrl:"http://localhost:8080",headers:{Authorization:"Bearer your-api-key","Content-Type":"application/json"},timeout:3e4},tags:["http","api","integration","web"],isOfficial:!1,isInstalled:!1,popularity:70,lastUpdated:new Date,requirements:{platform:"all"},author:"Community",version:"1.0.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"memory",name:"Memory",description:"Knowledge graph-based persistent memory system for storing and retrieving information",category:"productivity",icon:"\uD83E\uDDE0",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"],timeout:3e4},tags:["memory","knowledge","graph","persistence","storage"],isOfficial:!0,isInstalled:!1,popularity:87,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"google-drive",name:"Google Drive",description:"File access and search capabilities for Google Drive integration",category:"productivity",icon:"\uD83D\uDCCB",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-gdrive"],env:{GOOGLE_APPLICATION_CREDENTIALS:""},timeout:3e4},tags:["google","drive","files","cloud","storage"],isOfficial:!0,isInstalled:!1,popularity:82,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"git",name:"Git",description:"Tools to read, search, and manipulate Git repositories",category:"development",icon:"\uD83C\uDF3F",config:{type:"stdio",command:"uvx",args:["mcp-server-git","--repository","/path/to/git/repo"],timeout:3e4},tags:["git","version-control","repository","commits","diff"],isOfficial:!0,isInstalled:!1,popularity:90,lastUpdated:new Date,requirements:{platform:"all",python:">=3.8"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"}]}async saveCustomEntries(){this.registryEntries.filter(e=>!e.isOfficial)}async loadCustomEntries(){}}let rf=rx.getInstance();var rg=r(7826),rv=r(8988),ry=r(9390),rj=r(3974),rb=r(6474);let rw=(0,u.A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var rN=r(3563);function rC({isOpen:e,onClose:t,onAddServer:r}){let[s,a]=(0,i.useState)({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),[l,o]=(0,i.useState)(""),[d,c]=(0,i.useState)(""),[u,m]=(0,i.useState)(""),[p,h]=(0,i.useState)([]),[x,f]=(0,i.useState)(""),[g,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(!1),b=async e=>{e.preventDefault(),v(null),j(!0);try{let e=l.split(",").map(e=>e.trim()).filter(Boolean),n=d.split(",").map(e=>e.trim()).filter(Boolean),i=x.split(",").map(e=>e.trim()).filter(Boolean),g={};if(u.trim())for(let e of u.split("\n")){let t=e.trim();if(!t)continue;let r=t.indexOf("=");if(r>0){let e=t.substring(0,r).trim(),s=t.substring(r+1).trim();e&&(g[e]=s)}}let v={};if(p.forEach(e=>{e.key.trim()&&e.value.trim()&&(v[e.key.trim()]=e.value.trim())}),!s.name.trim())throw Error("Server name is required");if(!s.description.trim())throw Error("Description is required");if("stdio"===s.config.type&&!s.config.command.trim())throw Error("Command is required for stdio servers");if("sse"===s.config.type&&!s.config.url.trim())throw Error("URL is required for SSE servers");if("http"===s.config.type&&!s.config.url.trim())throw Error("URL is required for HTTP servers");let y={...s,config:{...s.config,args:e,env:g,headers:v},tags:n,requirements:{...s.requirements,dependencies:i}};await r(y),t(),a({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),o(""),c(""),m(""),h([]),f("")}catch(e){v(e.message||"Failed to add custom server")}finally{j(!1)}},w=e=>{let{name:t,value:r}=e.target;a(e=>({...e,config:{...e.config,[t]:r}}))};return(0,n.jsx)(rg.lG,{open:e,onOpenChange:t,children:(0,n.jsxs)(rg.Cf,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,n.jsxs)(rg.c7,{children:[(0,n.jsxs)(rg.L3,{className:"flex items-center gap-2",children:[(0,n.jsx)(rb.A,{className:"h-5 w-5"}),"Add Custom Server to Registry"]}),(0,n.jsx)(rg.rr,{children:"Add your own custom MCP server configuration to the registry for easy reuse."})]}),(0,n.jsxs)("form",{onSubmit:b,className:"space-y-4",children:[g&&(0,n.jsx)(te.Fc,{variant:"destructive",children:(0,n.jsx)(te.TN,{children:g})}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"name",children:"Server Name *"}),(0,n.jsx)(rv.p,{id:"name",value:s.name,onChange:e=>a(t=>({...t,name:e.target.value})),placeholder:"My Custom Server",required:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"category",children:"Category"}),(0,n.jsxs)(rj.l6,{value:s.category,onValueChange:e=>a(t=>({...t,category:e})),children:[(0,n.jsx)(rj.bq,{id:"category",children:(0,n.jsx)(rj.yv,{})}),(0,n.jsx)(rj.gC,{children:[{value:"productivity",label:"Productivity"},{value:"development",label:"Development"},{value:"research",label:"Research"},{value:"creative",label:"Creative"},{value:"data",label:"Data"},{value:"communication",label:"Communication"},{value:"custom",label:"Custom"}].map(e=>(0,n.jsx)(rj.eb,{value:e.value,children:e.label},e.value))})]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"description",children:"Description *"}),(0,n.jsx)(k.T,{id:"description",value:s.description,onChange:e=>a(t=>({...t,description:e.target.value})),placeholder:"Describe what this server does...",required:!0})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Server Configuration"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"serverType",children:"Server Type"}),(0,n.jsxs)(rj.l6,{value:s.config.type,onValueChange:e=>a(t=>({...t,config:{...t.config,type:e}})),children:[(0,n.jsx)(rj.bq,{id:"serverType",children:(0,n.jsx)(rj.yv,{})}),(0,n.jsxs)(rj.gC,{children:[(0,n.jsx)(rj.eb,{value:"stdio",children:"stdio"}),(0,n.jsx)(rj.eb,{value:"sse",children:"sse"}),(0,n.jsx)(rj.eb,{value:"http",children:"http"})]})]})]}),"stdio"===s.config.type?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"command",children:"Command *"}),(0,n.jsx)(rv.p,{id:"command",value:s.config.command,onChange:e=>a(t=>({...t,config:{...t.config,command:e.target.value}})),placeholder:"npx or python",required:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"args",children:"Arguments"}),(0,n.jsx)(rv.p,{id:"args",value:l,onChange:e=>o(e.target.value),placeholder:"Comma-separated: -m,script.py,--port,8080"})]})]}):"sse"===s.config.type?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(ry.J,{htmlFor:"url",children:"URL *"}),(0,n.jsx)(rv.p,{id:"url",name:"url",value:s.config.url,onChange:w,placeholder:"http://localhost:8080/sse",required:!0})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(ry.J,{htmlFor:"url",children:"URL *"}),(0,n.jsx)(rv.p,{id:"url",name:"url",value:s.config.url,onChange:w,placeholder:"https://example.com",required:!0})]}),"stdio"===s.config.type&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"env",children:"Environment Variables"}),(0,n.jsx)(k.T,{id:"env",value:u,onChange:e=>m(e.target.value),placeholder:`KEY1=value1
|
|
2
|
-
KEY2=value2`,rows:3})]}),("sse"===s.config.type||"http"===s.config.type)&&(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsx)(rN.w,{label:"Headers",pairs:p,onChange:h,placeholder:{key:"Authorization",value:"Bearer your-token"},keyLabel:"Header",valueLabel:"Value"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"tags",children:"Tags"}),(0,n.jsx)(rv.p,{id:"tags",value:d,onChange:e=>c(e.target.value),placeholder:"Comma-separated: file, database, api"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"icon",children:"Icon (Emoji)"}),(0,n.jsx)(rv.p,{id:"icon",value:s.icon,onChange:e=>a(t=>({...t,icon:e.target.value})),placeholder:"⚡",maxLength:2})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"version",children:"Version"}),(0,n.jsx)(rv.p,{id:"version",value:s.version,onChange:e=>a(t=>({...t,version:e.target.value})),placeholder:"1.0.0"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"author",children:"Author"}),(0,n.jsx)(rv.p,{id:"author",value:s.author,onChange:e=>a(t=>({...t,author:e.target.value})),placeholder:"Your Name"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"homepage",children:"Homepage URL"}),(0,n.jsx)(rv.p,{id:"homepage",value:s.homepage,onChange:e=>a(t=>({...t,homepage:e.target.value})),placeholder:"https://github.com/youruser/yourserver"})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Requirements"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"platform",children:"Platform"}),(0,n.jsxs)(rj.l6,{value:s.requirements.platform,onValueChange:e=>a(t=>({...t,requirements:{...t.requirements,platform:e}})),children:[(0,n.jsx)(rj.bq,{id:"platform",children:(0,n.jsx)(rj.yv,{})}),(0,n.jsx)(rj.gC,{children:[{value:"all",label:"All Platforms"},{value:"win32",label:"Windows"},{value:"darwin",label:"macOS"},{value:"linux",label:"Linux"}].map(e=>(0,n.jsx)(rj.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"dependencies",children:"Dependencies"}),(0,n.jsx)(rv.p,{id:"dependencies",value:x,onChange:e=>f(e.target.value),placeholder:"Comma-separated: package1, package2"})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"nodeVersion",children:"Node.js Version"}),(0,n.jsx)(rv.p,{id:"nodeVersion",value:s.requirements.node,onChange:e=>a(t=>({...t,requirements:{...t.requirements,node:e.target.value}})),placeholder:">=16.0.0"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(ry.J,{htmlFor:"pythonVersion",children:"Python Version"}),(0,n.jsx)(rv.p,{id:"pythonVersion",value:s.requirements.python,onChange:e=>a(t=>({...t,requirements:{...t.requirements,python:e.target.value}})),placeholder:">=3.8"})]})]})]}),(0,n.jsxs)(rg.Es,{className:"flex gap-2",children:[(0,n.jsx)(E.$,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),(0,n.jsx)(E.$,{type:"submit",disabled:y,children:y?"Adding...":(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(rw,{className:"h-4 w-4 mr-2"}),"Add to Registry"]})})]})]})]})})}var rk=r(9821);let rE=(0,u.A)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),rS=(0,u.A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function rA({isOpen:e,onClose:t,onInstallServer:r}){let[s,a]=(0,i.useState)([]),[l,o]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[m,p]=(0,i.useState)(null),[h,x]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[v,y]=(0,i.useState)({}),[j,b]=(0,i.useState)("");(0,i.useRef)(null);let w=(0,i.useRef)(!0);(0,i.useRef)(null),(0,i.useCallback)(async(e,t)=>{if(w.current)try{let r=await rf.getEntries({...e,search:t||void 0});w.current&&o(r)}catch(e){w.current&&p(e instanceof Error?e.message:"Failed to filter entries")}},[]);let N=async e=>{if(w.current){x(e.id);try{await r(e),await rf.setInstalled(e.id,!0),w.current&&a(t=>t.map(t=>t.id===e.id?{...t,isInstalled:!0}:t))}catch(e){w.current&&p(e instanceof Error?e.message:"Failed to install server")}finally{w.current&&x(null)}}},C=async e=>{if(w.current)try{let t=await rf.addCustomEntry(e);w.current&&(a(e=>[t,...e]),g(!1))}catch(e){w.current&&p(e instanceof Error?e.message:"Failed to add custom server")}};return(0,n.jsxs)(rg.lG,{open:e,onOpenChange:t,children:[(0,n.jsxs)(rg.Cf,{className:"max-w-2xl max-h-[70vh] overflow-hidden flex flex-col border-0 shadow-2xl",children:[(0,n.jsxs)(rg.c7,{className:"pb-6",children:[(0,n.jsxs)(rg.L3,{className:"flex items-center gap-3 text-lg",children:[(0,n.jsx)("div",{className:"p-2 rounded-lg bg-primary/10",children:(0,n.jsx)(rE,{className:"h-5 w-5 text-primary"})}),"Browse Tools"]}),(0,n.jsx)(rg.rr,{className:"text-muted-foreground",children:"Discover and add new capabilities to your AI assistant"})]}),(0,n.jsxs)("div",{className:"relative mb-6",children:[(0,n.jsx)(rS,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,n.jsx)(rv.p,{placeholder:"Search for tools and integrations...",value:j,onChange:e=>b(e.target.value),className:"pl-10 h-11 border-border/50 focus:border-primary/50 bg-background/50"})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto -mx-1 px-1",children:[m&&(0,n.jsx)(te.Fc,{variant:"destructive",className:"mb-4",children:(0,n.jsx)(te.TN,{children:m})}),c?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,n.jsx)("div",{className:"h-8 w-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin"}),(0,n.jsx)("div",{className:"text-sm text-muted-foreground",children:"Discovering tools..."})]})}):0===l.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,n.jsx)("div",{className:"p-3 rounded-full bg-muted/50 mb-4",children:(0,n.jsx)(rE,{className:"h-8 w-8 text-muted-foreground"})}),(0,n.jsx)("div",{className:"text-muted-foreground",children:0===s.length?"No tools available in the registry":"No tools match your search"}),j&&(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:()=>b(""),className:"mt-2",children:"Clear search"})]}):(0,n.jsx)("div",{className:"space-y-3",children:l.map((e,t)=>(0,n.jsxs)("div",{className:"group relative flex items-center justify-between p-4 border border-border/50 rounded-xl hover:border-border hover:shadow-sm bg-card/50 hover:bg-card transition-all duration-200",style:{animationDelay:`${Math.min(50*t,500)}ms`},children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"flex-shrink-0 text-2xl p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.icon||"⚡"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsx)("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors",children:e.name}),e.isOfficial&&(0,n.jsx)(rk.E,{variant:"secondary",className:"text-xs font-medium px-2",children:"Official"}),e.isInstalled&&(0,n.jsx)(rk.E,{className:"text-xs font-medium px-2 bg-green-100 text-green-800 border-green-200",children:"Added"})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-1 leading-relaxed",children:e.description})]})]}),(0,n.jsx)(E.$,{onClick:()=>N(e),disabled:e.isInstalled||h===e.id,size:"sm",variant:e.isInstalled?"outline":"default",className:(0,d.cn)("flex-shrink-0 ml-3 min-w-[80px] transition-all",!e.isInstalled&&"hover:shadow-sm",h===e.id&&"opacity-70"),children:h===e.id?(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"h-3 w-3 border border-current border-t-transparent rounded-full animate-spin"}),(0,n.jsx)("span",{children:"Adding..."})]}):e.isInstalled?"Added":"Add"})]},e.id))})]})]}),(0,n.jsx)(rC,{isOpen:f,onClose:()=>g(!1),onAddServer:C})]})}let rP=(0,u.A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),rR=(0,u.A)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),rT=(0,u.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var rD=r(8233);let rO=(0,u.A)("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]),r$="/api";function rL({isOpen:e,onClose:t,onOpenConnectModal:r,variant:s="overlay"}){let[a,l]=(0,i.useState)([]),[o,c]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[p,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),[j,b]=(0,i.useState)(null),[w,N]=(0,i.useState)(!1),[C,k]=(0,i.useState)(null),[S,A]=(0,i.useState)(!1),P=(e,t)=>{console.error(`ServersPanel Error (${t}):`,e),"servers"===t&&y(e),"tools"===t&&b(e)},R=(0,i.useCallback)(async e=>{h(!0),y(null),l([]),c(null),m([]),b(null);try{let t=await fetch(`${r$}/mcp/servers`,e?{signal:e}:{});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to fetch servers"}));throw Error(e.message||e.error||`Server List: ${t.statusText}`)}let r=(await t.json()).servers||[];if(l(r),r.length>0){let e=r.find(e=>"connected"===e.status);e?c(e.id):r.length>0&&c(r[0].id)}else console.log("No MCP servers found or returned from API.")}catch(e){"AbortError"!==e.name&&P(e.message,"servers")}finally{e?.aborted||h(!1)}},[]),T=async e=>{A(!1);let t={type:e.config.type,command:e.config.command,args:e.config.args||[],url:e.config.url,env:e.config.env||{},headers:e.config.headers||{},timeout:e.config.timeout||3e4};try{let r=await fetch("/api/connect-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,config:t})}),s=await r.json();if(!r.ok)throw Error(s.error||`Server returned status ${r.status}`);await R()}catch(e){throw Error(e.message||"Failed to install server")}},D=async e=>{let t=a.find(t=>t.id===e);if(t&&window.confirm(`Are you sure you want to remove server "${t.name}"?`)){k(e),y(null);try{let t=await fetch(`${r$}/mcp/servers/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to remove server"}));throw Error(e.message||e.error||`Server Removal: ${t.statusText}`)}o===e&&(c(null),m([])),await R()}catch(e){P(e.message,"servers")}finally{k(null)}}};(0,i.useCallback)(async(e,t)=>{let r=a.find(t=>t.id===e);if(m([]),b(null),!r||"connected"!==r.status)return void console.warn(`Server "${r?.name||e}" is not connected or not found. Cannot fetch tools.`);f(!0);try{let s=await fetch(`${r$}/mcp/servers/${e}/tools`,t?{signal:t}:{});if(!s.ok){let e=await s.json().catch(()=>({error:`Failed to fetch tools for ${r.name}`}));throw Error(e.message||e.error||`Tool List (${r.name}): ${s.statusText}`)}let a=await s.json();t?.aborted||m(a.tools||[]),a.tools&&0!==a.tools.length||console.log(`No tools found for server "${r.name}".`)}catch(e){"AbortError"!==e.name&&P(e.message,"tools")}finally{t?.aborted||f(!1)}},[a]);let O=a.find(e=>e.id===o);if("overlay"===s&&!e)return null;let $=(0,d.cn)("fixed top-0 right-0 z-40 h-screen w-80 bg-card border-l border-border shadow-xl transition-transform transform flex flex-col",e?"translate-x-0":"translate-x-full"),L=(0,d.cn)("h-full w-full flex flex-col bg-card");return(0,n.jsxs)("aside",{className:"overlay"===s?$:L,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50 bg-card/50 backdrop-blur-sm",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Tools & Servers"}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:()=>R(),disabled:p,className:"h-8 w-8 p-0",children:(0,n.jsx)(rP,{className:(0,d.cn)("h-3.5 w-3.5",p&&"animate-spin")})}),"overlay"===s&&(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,n.jsx)(e4.A,{className:"h-3.5 w-3.5"})})]})]}),(0,n.jsxs)("div",{className:"px-4 py-3 space-y-2 border-b border-border/30",children:[(0,n.jsxs)(E.$,{onClick:r,className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,n.jsx)(rR,{className:"mr-2 h-4 w-4"}),"Connect Server"]}),(0,n.jsxs)(E.$,{onClick:()=>A(!0),variant:"outline",className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,n.jsx)(rT,{className:"mr-2 h-4 w-4"}),"Browse Registry"]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsxs)("div",{className:"p-4 border-b border-border/30",children:[(0,n.jsx)("div",{className:"flex items-center justify-between mb-3",children:(0,n.jsxs)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:["Connected Servers (",a.length,")"]})}),p&&(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,n.jsx)(rP,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading servers..."})]})}),v&&(0,n.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,n.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,n.jsx)(g.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Connection Error"}),(0,n.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:v})]})]})}),!p&&0===a.length&&!v&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)(rE,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"No servers connected"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Connect or browse the registry"})]}),a.map(e=>(0,n.jsx)("div",{onClick:()=>c(e.id),className:(0,d.cn)("p-3 rounded-lg border cursor-pointer transition-all duration-200 mb-2 last:mb-0",o===e.id?"bg-primary/5 border-primary/20 shadow-sm":"bg-background hover:bg-muted/50 border-border/50 hover:border-border"),children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:(0,d.cn)("w-2 h-2 rounded-full flex-shrink-0","connected"===e.status?"bg-green-500":"error"===e.status?"bg-red-500":"bg-yellow-500")}),(0,n.jsx)("h4",{className:"text-sm font-medium truncate",children:e.name})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1 capitalize",children:e.status})]}),C===e.id?(0,n.jsx)(rP,{className:"h-4 w-4 animate-spin text-muted-foreground"}):(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),D(e.id)},className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",children:(0,n.jsx)(rD.A,{className:"h-3.5 w-3.5"})})]})},e.id))]}),O&&(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsx)("div",{className:"px-4 py-3 border-b border-border/30",children:(0,n.jsxs)("button",{onClick:()=>N(!w),className:"flex items-center justify-between w-full text-left",children:[(0,n.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Available Tools"}),(0,n.jsx)(e7.A,{className:(0,d.cn)("h-3.5 w-3.5 transition-transform text-muted-foreground",w&&"rotate-180")})]})}),w&&(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[x&&(0,n.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,n.jsx)(rP,{className:"h-4 w-4 animate-spin text-muted-foreground"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading tools..."})]})}),j&&(0,n.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,n.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,n.jsx)(g.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Tools Error"}),(0,n.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:j})]})]})}),!x&&0===u.length&&!j&&"connected"===O.status&&(0,n.jsxs)("div",{className:"text-center py-6",children:[(0,n.jsx)(rO,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"No tools available"})]}),"connected"!==O.status&&(0,n.jsxs)("div",{className:"text-center py-6",children:[(0,n.jsx)(g.A,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Server not connected"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Tools unavailable"})]}),u.map(e=>(0,n.jsxs)("div",{className:"p-3 rounded-lg border border-border/50 bg-background hover:bg-muted/30 transition-colors mb-2 last:mb-0",children:[(0,n.jsx)("h4",{className:"text-sm font-medium mb-1",children:e.name}),e.description&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-2",children:e.description}),e.inputSchema?.properties&&(0,n.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[Object.keys(e.inputSchema.properties).slice(0,3).map(e=>(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-muted text-xs font-medium",children:e},e)),Object.keys(e.inputSchema.properties).length>3&&(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",Object.keys(e.inputSchema.properties).length-3," more"]})]})]},e.name))]})]})]}),(0,n.jsx)(rA,{isOpen:S,onClose:()=>A(!1),onInstallServer:T})]})}let rF=i.forwardRef(({className:e,children:t,...r},s)=>(0,n.jsx)("div",{ref:s,className:(0,d.cn)("relative overflow-auto",e),...r,children:t}));rF.displayName="ScrollArea";let rM=(0,u.A)("message-square",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),rI=(0,u.A)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var rz=r(6349);let rq=(0,u.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);function r_({isOpen:e,onClose:t,currentSessionId:r,onSessionChange:s,returnToWelcome:a,variant:l="modal"}){let[o,c]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[p,h]=(0,i.useState)(null),[x,f]=(0,i.useState)(!1),[v,y]=(0,i.useState)(""),[j,b]=(0,i.useState)(null),[w,N]=(0,i.useState)(!1),[C,k]=(0,i.useState)(null),[S,A]=(0,i.useState)(!1),P=(0,i.useCallback)(async()=>{m(!0),h(null);try{let e=await fetch("/api/sessions");if(!e.ok)throw Error("Failed to fetch sessions");let t=await e.json();c(t.sessions||[])}catch(e){console.error("Error fetching sessions:",e),h(e instanceof Error?e.message:"Failed to fetch sessions")}finally{m(!1)}},[]),R=async()=>{try{let e=await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:v.trim()||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create session")}let t=await e.json();c(e=>[...e,t.session]),y(""),f(!1),s(t.session.id)}catch(e){console.error("Error creating session:",e),h(e instanceof Error?e.message:"Failed to create session")}},T=async e=>{b(e);try{let t=await fetch(`/api/sessions/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete session")}c(t=>t.filter(t=>t.id!==e)),r===e&&a()}catch(e){console.error("Error deleting session:",e),h(e instanceof Error?e.message:"Failed to delete session")}finally{b(null)}},D=async()=>{if(C){A(!0);try{if(!(await fetch(`/api/sessions/${C}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to delete conversation");c(e=>e.filter(e=>e.id!==C)),r===C&&a(),N(!1),k(null)}catch(e){console.error("Error deleting conversation:",e),h(e instanceof Error?e.message:"Failed to delete conversation")}finally{A(!1)}}},O=e=>{if(!e)return"Unknown";let t=new Date(e);return t.toLocaleDateString()+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},$=e=>{if(!e)return"Unknown";let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),a=Math.floor(r/36e5),n=Math.floor(r/864e5);return s<1?"Just now":s<60?`${s}m ago`:a<24?`${a}h ago`:`${n}d ago`},L=(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border/50",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)(rM,{className:"h-5 w-5"}),(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Sessions"})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:P,disabled:u,className:"h-8 w-8 p-0",children:(0,n.jsx)(rP,{className:(0,d.cn)("h-4 w-4",u&&"animate-spin")})}),(0,n.jsxs)(E.$,{variant:"outline",size:"sm",onClick:()=>f(!0),className:"h-8",children:[(0,n.jsx)(rb.A,{className:"h-4 w-4 mr-1"}),"New Session"]})]})]}),p&&(0,n.jsx)("div",{className:"p-4",children:(0,n.jsxs)(te.Fc,{variant:"destructive",children:[(0,n.jsx)(g.A,{className:"h-4 w-4"}),(0,n.jsx)(te.TN,{children:p})]})}),(0,n.jsx)(rF,{className:"flex-1 p-4",children:(0,n.jsx)("div",{className:"space-y-2",children:u?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)(rP,{className:"h-6 w-6 animate-spin"})}):0===o.length?(0,n.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,n.jsx)(rM,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,n.jsx)("p",{children:"No active sessions"}),(0,n.jsx)("p",{className:"text-sm",children:"Create a new session to get started"})]}):o.map(e=>(0,n.jsx)("div",{className:(0,d.cn)("group p-3 rounded-lg border border-border/50 bg-card hover:bg-muted/50 transition-all cursor-pointer",r===e.id&&"ring-2 ring-primary bg-primary/5"),onClick:()=>s(e.id),children:(0,n.jsxs)("div",{className:"flex items-start justify-between",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,n.jsx)("h3",{className:"font-medium text-sm truncate",children:e.id}),r===e.id&&(0,n.jsx)(rk.E,{variant:"secondary",className:"text-xs",children:"Active"})]}),(0,n.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(rI,{className:"h-3 w-3"}),(0,n.jsxs)("span",{children:[e.messageCount," messages"]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(rz.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:$(e.lastActivity)})]})]}),e.createdAt&&(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(rq,{className:"h-3 w-3"}),(0,n.jsxs)("span",{children:["Created ",O(e.createdAt)]})]})]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[e.messageCount>0&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),k(e.id),N(!0)},className:"h-8 w-8 p-0",title:"Delete Conversation",children:(0,n.jsx)(rD.A,{className:"h-4 w-4 text-destructive"})})}),0===e.messageCount&&(0,n.jsx)(E.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),T(e.id)},disabled:j===e.id,className:"h-8 w-8 p-0",title:"Delete Session",children:(0,n.jsx)(rD.A,{className:"h-4 w-4 text-destructive"})})]})]})},e.id))})}),(0,n.jsx)(rg.lG,{open:x,onOpenChange:f,children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-md",children:[(0,n.jsx)(rg.c7,{children:(0,n.jsx)(rg.L3,{children:"Create New Session"})}),(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(ry.J,{htmlFor:"sessionId",children:"Session ID"}),(0,n.jsx)(rv.p,{id:"sessionId",value:v,onChange:e=>y(e.target.value),placeholder:"e.g., user-123, project-alpha",className:"font-mono"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Leave empty to auto-generate a unique ID"})]})}),(0,n.jsxs)(rg.Es,{children:[(0,n.jsx)(E.$,{variant:"outline",onClick:()=>f(!1),children:"Cancel"}),(0,n.jsx)(E.$,{onClick:R,children:"Create Session"})]})]})}),(0,n.jsx)(rg.lG,{open:w,onOpenChange:N,children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-md",children:[(0,n.jsxs)(rg.c7,{children:[(0,n.jsxs)(rg.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(rD.A,{className:"h-5 w-5 text-destructive"}),(0,n.jsx)("span",{children:"Delete Conversation"})]}),(0,n.jsxs)(rg.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",C&&(0,n.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,n.jsx)("span",{className:"font-mono",children:C})]})]})]}),(0,n.jsxs)(rg.Es,{children:[(0,n.jsx)(E.$,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),(0,n.jsxs)(E.$,{variant:"destructive",onClick:D,disabled:S,className:"flex items-center space-x-2",children:[(0,n.jsx)(rD.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:S?"Deleting...":"Delete Conversation"})]})]})]})})]});return"inline"===l?(0,n.jsx)("div",{className:"h-full",children:L}):(0,n.jsx)(rg.lG,{open:e,onOpenChange:t,children:(0,n.jsx)(rg.Cf,{className:"sm:max-w-lg h-[600px] flex flex-col p-0",children:L})})}var rB=r(3437);function rU({websocket:e}){let[t,r]=(0,i.useState)(null),[s,a]=(0,i.useState)(!1),[o,d]=(0,i.useState)(!1),c=l().useRef([]),u=(0,i.useCallback)(n=>{if(!t||!e)return;let i={type:"toolConfirmationResponse",data:{executionId:t.executionId,approved:n,rememberChoice:s,sessionId:t.sessionId}};if(console.debug("[WebUI] Sending toolConfirmationResponse",i),e.send(JSON.stringify(i)),d(!1),r(null),a(!1),c.current.length>0){let e=c.current.shift();setTimeout(()=>{r(e),d(!0)},0)}},[t,s,e]);return t?(0,n.jsx)(rg.lG,{open:o,onOpenChange:e=>{e||u(!1)},children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-[600px]",children:[(0,n.jsx)(rg.c7,{children:(0,n.jsxs)(rg.L3,{className:"flex items-center gap-2",children:[(0,n.jsx)(g.A,{className:"h-5 w-5 text-yellow-500"}),"Tool Execution Confirmation"]})}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(h,{className:"h-4 w-4 text-blue-500"}),(0,n.jsx)("span",{className:"font-medium",children:"Tool:"}),(0,n.jsx)(rk.E,{variant:"outline",children:t.toolName})]}),t.description&&(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"font-medium",children:"Description:"}),(0,n.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:t.description})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"font-medium",children:"Arguments:"}),(0,n.jsx)("pre",{className:"bg-background/50 p-3 rounded-md text-xs overflow-auto max-h-48 mt-1 text-muted-foreground",children:(e=>{if(!e)return"No arguments";try{return JSON.stringify(e,null,2)}catch{return String(e)}})(t.args)})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[(0,n.jsx)(rz.A,{className:"h-4 w-4"}),(0,n.jsxs)("span",{children:["Requested at: ",t.timestamp.toLocaleString()]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)(rB.S,{id:"remember",checked:s,onCheckedChange:e=>a(!0===e)}),(0,n.jsx)("label",{htmlFor:"remember",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Approve future executions of this tool for this session"})]}),(0,n.jsx)("div",{className:"bg-yellow-50 p-3 rounded-md",children:(0,n.jsxs)("p",{className:"text-sm text-yellow-800",children:[(0,n.jsx)("strong",{children:"Security Notice:"})," Only approve tools you trust. Tools can access your system and data according to their permissions."]})})]}),(0,n.jsxs)(rg.Es,{className:"gap-2",children:[(0,n.jsx)(E.$,{variant:"outline",onClick:()=>u(!1),className:"bg-red-50 hover:bg-red-100 text-red-700 border-red-200",children:"Deny"}),(0,n.jsx)(E.$,{onClick:()=>u(!0),className:"bg-green-600 hover:bg-green-700",children:"Approve"})]})]})}):null}let rW=(0,u.A)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function rH({isOpen:e,onClose:t,onNavigateToSession:r}){let[s,a]=(0,i.useState)(""),[l,o]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),[g,v]=(0,i.useState)(0);(0,i.useCallback)(async e=>{if(!e.trim()){o([]),x(null);return}u(!0),x(null);try{let t=new URLSearchParams({q:e,limit:"10",offset:"0"}),r=await fetch(`/api/search/messages?${t}`);if(!r.ok){let e=await r.text();throw Error(`Search failed: ${r.status} ${e}`)}let s=await r.json();o(s.results),v(0)}catch(e){console.error("Search error:",e),o([]),x(e instanceof Error?e.message:"Search failed")}finally{u(!1)}},[]);let y=e=>{r(e.sessionId,e.messageIndex),t()},j=e=>{switch(e){case"user":return(0,n.jsx)(m,{className:"w-4 h-4"});case"assistant":return(0,n.jsx)(p,{className:"w-4 h-4"});case"system":return(0,n.jsx)(rW,{className:"w-4 h-4"});default:return(0,n.jsx)(rM,{className:"w-4 h-4"})}},b=e=>{switch(e){case"user":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"assistant":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"system":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}},w=(e,t)=>{if(!t)return e;let r=t.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&"),s=RegExp(`(${r})`,"gi");return e.split(s).map((e,t)=>s.test(e)?(0,n.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-800 font-medium rounded px-1",children:e},t):e)};return(0,n.jsx)(rg.lG,{open:e,onOpenChange:t,children:(0,n.jsx)(rg.Cf,{className:"max-w-2xl p-0 top-[20%] transform translate-y-0",children:(0,n.jsxs)("div",{className:"flex flex-col max-h-[70vh]",children:[(0,n.jsx)("div",{className:"p-6 pb-4",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(rS,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),(0,n.jsx)(rv.p,{placeholder:"Search conversations...",value:s,onChange:e=>a(e.target.value),className:"pl-12 text-lg border-0 shadow-none focus-visible:ring-0 bg-transparent",autoFocus:!0})]})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden border-t",children:c?(0,n.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,n.jsx)(rP,{className:"h-6 w-6 animate-spin mr-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"Searching..."})]}):h?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)(rS,{className:"w-12 h-12 mx-auto mb-4 text-destructive opacity-50"}),(0,n.jsx)("p",{className:"text-destructive font-medium",children:"Search Error"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:h}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Try again or check your connection."})]})}):(0,n.jsx)(rF,{className:"h-full",children:(0,n.jsx)("div",{className:"p-2",children:l.length>0?(0,n.jsx)("div",{className:"space-y-1",children:l.map((e,t)=>(0,n.jsxs)("div",{className:(0,d.cn)("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-colors",t===g?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onClick:()=>y(e),children:[(0,n.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,n.jsx)(rk.E,{className:(0,d.cn)("text-xs",b(e.message.role)),children:j(e.message.role)})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:e.sessionId.length>20?`${e.sessionId.slice(0,20)}...`:e.sessionId}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e.message.role})]}),(0,n.jsx)("div",{className:"text-sm text-muted-foreground line-clamp-2",children:w(e.context,s)})]}),(0,n.jsx)(f,{className:"w-4 h-4 text-muted-foreground flex-shrink-0 mt-1"})]},t))}):s?(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)(rS,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,n.jsx)("p",{className:"text-muted-foreground",children:"No messages found matching your search."}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:"Try different keywords."})]}):(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)(rS,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,n.jsx)("p",{className:"text-muted-foreground",children:"Start typing to search your conversations."}),(0,n.jsxs)("div",{className:"flex items-center justify-center gap-4 mt-4 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↑"}),(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↓"}),(0,n.jsx)("span",{children:"to navigate"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Enter"}),(0,n.jsx)("span",{children:"to select"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Esc"}),(0,n.jsx)("span",{children:"to close"})]})]})]})})})})]})})})}let rV=(0,u.A)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),rJ=(0,u.A)("download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),rG=(0,u.A)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);var rK=r(5814),rY=r.n(rK);let rX=(0,u.A)("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),rZ=(0,u.A)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function rQ(){let{theme:e,toggleTheme:t,hasMounted:r}=function(){let[e,t]=(0,i.useState)("light"),[r,s]=(0,i.useState)(!1);return{theme:e,toggleTheme:e=>{t(e?"dark":"light")},hasMounted:r}}();if(!r)return null;let s="dark"===e;return(0,n.jsx)(tc,{checked:s,onCheckedChange:t,className:"w-12 h-6 bg-gray-300 dark:bg-gray-700 rounded-full relative transition-colors flex items-center px-0.5","aria-label":"Toggle dark mode",children:(0,n.jsx)(tm,{className:`
|
|
1
|
+
(()=>{var e={};e.id=974,e.ids=[974],e.modules={597:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});var s=r(7413),a=r(6730);function n(){return(0,s.jsx)(a.default,{})}},846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},1708:e=>{"use strict";e.exports=require("node:process")},3033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},3136:e=>{"use strict";e.exports=require("node:url")},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3873:e=>{"use strict";e.exports=require("path")},4610:(e,t,r)=>{Promise.resolve().then(r.bind(r,7677))},4858:(e,t,r)=>{Promise.resolve().then(r.bind(r,6730))},6730:(e,t,r)=>{"use strict";r.d(t,{default:()=>s});let s=(0,r(2907).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/dexto/dexto/src/app/webui/components/ChatApp.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/dexto/dexto/src/app/webui/components/ChatApp.tsx","default")},6760:e=>{"use strict";e.exports=require("node:path")},6918:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>i.a,__next_app__:()=>u,pages:()=>c,routeModule:()=>m,tree:()=>d});var s=r(5239),a=r(8088),n=r(8170),i=r.n(n),o=r(893),l={};for(let e in o)0>["default","tree","pages","GlobalError","__next_app__","routeModule"].indexOf(e)&&(l[e]=()=>o[e]);r.d(t,l);let d=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,597)),"/home/runner/work/dexto/dexto/src/app/webui/app/page.tsx"]}]},{layout:[()=>Promise.resolve().then(r.bind(r,8014)),"/home/runner/work/dexto/dexto/src/app/webui/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,7398,23)),"next/dist/client/components/not-found-error"],forbidden:[()=>Promise.resolve().then(r.t.bind(r,9999,23)),"next/dist/client/components/forbidden-error"],unauthorized:[()=>Promise.resolve().then(r.t.bind(r,5284,23)),"next/dist/client/components/unauthorized-error"]}],c=["/home/runner/work/dexto/dexto/src/app/webui/app/page.tsx"],u={require:r,loadChunk:()=>Promise.resolve()},m=new s.AppPageRouteModule({definition:{kind:a.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},7677:(e,t,r)=>{"use strict";r.d(t,{default:()=>sU});var s,a,n=r(687),i=r(3210),o=r.n(i),l=r(2765),d=r(6241),c=r(4314),u=r(3649),m=r(3589),h=r(5891),p=r(1860),x=r(3964),f=r(615),g=!!("undefined"!=typeof window&&window.document&&window.document.createElement);function v(e,t,{checkForDefaultPrevented:r=!0}={}){return function(s){if(e?.(s),!1===r||!s.defaultPrevented)return t?.(s)}}var y=r(8599),b=r(1273),j=r(1215),w=r(8730),N=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=(0,w.TL)(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),k=r(3495),C=r(6309),S="dismissableLayer.update",E=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),A=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:d,onDismiss:c,...u}=e,m=i.useContext(E),[h,p]=i.useState(null),x=h?.ownerDocument??globalThis?.document,[,f]=i.useState({}),g=(0,y.s)(t,e=>p(e)),b=Array.from(m.layers),[j]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),w=b.indexOf(j),A=h?b.indexOf(h):-1,P=m.layersWithOutsidePointerEventsDisabled.size>0,O=A>=w,D=function(e,t=globalThis?.document){let r=(0,k.c)(e),s=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!s.current){let s=function(){R("dismissableLayer.pointerDownOutside",r,n,{discrete:!0})},n={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=s,t.addEventListener("click",a.current,{once:!0})):s()}else t.removeEventListener("click",a.current);s.current=!1},n=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(n),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}(e=>{let t=e.target,r=[...m.branches].some(e=>e.contains(t));O&&!r&&(o?.(e),d?.(e),e.defaultPrevented||c?.())},x),M=function(e,t=globalThis?.document){let r=(0,k.c)(e),s=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!s.current&&R("dismissableLayer.focusOutside",r,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{let t=e.target;![...m.branches].some(e=>e.contains(t))&&(l?.(e),d?.(e),e.defaultPrevented||c?.())},x);return(0,C.U)(e=>{A===m.layers.size-1&&(a?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},x),i.useEffect(()=>{if(h)return r&&(0===m.layersWithOutsidePointerEventsDisabled.size&&(s=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),T(),()=>{r&&1===m.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=s)}},[h,x,r,m]),i.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),T())},[h,m]),i.useEffect(()=>{let e=()=>f({});return document.addEventListener(S,e),()=>document.removeEventListener(S,e)},[]),(0,n.jsx)(N.div,{...u,ref:g,style:{pointerEvents:P?O?"auto":"none":void 0,...e.style},onFocusCapture:v(e.onFocusCapture,M.onFocusCapture),onBlurCapture:v(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:v(e.onPointerDownCapture,D.onPointerDownCapture)})});function T(){let e=new CustomEvent(S);document.dispatchEvent(e)}function R(e,t,r,{discrete:s}){let a=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});if(t&&a.addEventListener(e,t,{once:!0}),s)a&&j.flushSync(()=>a.dispatchEvent(n));else a.dispatchEvent(n)}A.displayName="DismissableLayer",i.forwardRef((e,t)=>{let r=i.useContext(E),s=i.useRef(null),a=(0,y.s)(t,s);return i.useEffect(()=>{let e=s.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,n.jsx)(N.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var P=r(6963),O=r(4503),D=r(5605),M=i.forwardRef((e,t)=>{let{children:r,width:s=10,height:a=5,...i}=e;return(0,n.jsx)(N.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:(0,n.jsx)("polygon",{points:"0,0 30,0 15,10"})})});M.displayName="Arrow";var L=r(6156),F=r(8853),I="Popper",[$,z]=(0,b.A)(I),[q,_]=$(I),U=e=>{let{__scopePopper:t,children:r}=e,[s,a]=i.useState(null);return(0,n.jsx)(q,{scope:t,anchor:s,onAnchorChange:a,children:r})};U.displayName=I;var B="PopperAnchor",H=i.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:s,...a}=e,o=_(B,r),l=i.useRef(null),d=(0,y.s)(t,l),c=i.useRef(null);return i.useEffect(()=>{let e=c.current;c.current=s?.current||l.current,e!==c.current&&o.onAnchorChange(c.current)}),s?null:(0,n.jsx)(N.div,{...a,ref:d})});H.displayName=B;var W="PopperContent",[V,J]=$(W),G=i.forwardRef((e,t)=>{let{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:d=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:x="optimized",onPlaced:f,...g}=e,v=_(W,r),[b,j]=i.useState(null),w=(0,y.s)(t,e=>j(e)),[C,S]=i.useState(null),E=(0,F.X)(C),A=E?.width??0,T=E?.height??0,R="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(u)?u:[u],M=P.length>0,I={padding:R,boundary:P.filter(Z),altBoundary:M},{refs:$,floatingStyles:z,placement:q,isPositioned:U,middlewareData:B}=(0,O.we)({strategy:"fixed",placement:s+("center"!==o?"-"+o:""),whileElementsMounted:(...e)=>(0,D.ll)(...e,{animationFrame:"always"===x}),elements:{reference:v.anchor},middleware:[(0,O.cY)({mainAxis:a+T,alignmentAxis:l}),c&&(0,O.BN)({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?(0,O.ER)():void 0,...I}),c&&(0,O.UU)({...I}),(0,O.Ej)({...I,apply:({elements:e,rects:t,availableWidth:r,availableHeight:s})=>{let{width:a,height:n}=t.reference,i=e.floating.style;i.setProperty("--radix-popper-available-width",`${r}px`),i.setProperty("--radix-popper-available-height",`${s}px`),i.setProperty("--radix-popper-anchor-width",`${a}px`),i.setProperty("--radix-popper-anchor-height",`${n}px`)}}),C&&(0,O.UE)({element:C,padding:d}),Q({arrowWidth:A,arrowHeight:T}),p&&(0,O.jD)({strategy:"referenceHidden",...I})]}),[H,J]=ee(q),G=(0,k.c)(f);(0,L.N)(()=>{U&&G?.()},[U,G]);let K=B.arrow?.x,Y=B.arrow?.y,X=B.arrow?.centerOffset!==0,[et,er]=i.useState();return(0,L.N)(()=>{b&&er(window.getComputedStyle(b).zIndex)},[b]),(0,n.jsx)("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:U?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:et,"--radix-popper-transform-origin":[B.transformOrigin?.x,B.transformOrigin?.y].join(" "),...B.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,n.jsx)(V,{scope:r,placedSide:H,onArrowChange:S,arrowX:K,arrowY:Y,shouldHideArrow:X,children:(0,n.jsx)(N.div,{"data-side":H,"data-align":J,...g,ref:w,style:{...g.style,animation:U?void 0:"none"}})})})});G.displayName=W;var K="PopperArrow",Y={top:"bottom",right:"left",bottom:"top",left:"right"},X=i.forwardRef(function(e,t){let{__scopePopper:r,...s}=e,a=J(K,r),i=Y[a.placedSide];return(0,n.jsx)("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:(0,n.jsx)(M,{...s,ref:t,style:{...s.style,display:"block"}})})});function Z(e){return null!==e}X.displayName=K;var Q=e=>({name:"transformOrigin",options:e,fn(t){let{placement:r,rects:s,middlewareData:a}=t,n=a.arrow?.centerOffset!==0,i=n?0:e.arrowWidth,o=n?0:e.arrowHeight,[l,d]=ee(r),c={start:"0%",center:"50%",end:"100%"}[d],u=(a.arrow?.x??0)+i/2,m=(a.arrow?.y??0)+o/2,h="",p="";return"bottom"===l?(h=n?c:`${u}px`,p=`${-o}px`):"top"===l?(h=n?c:`${u}px`,p=`${s.floating.height+o}px`):"right"===l?(h=`${-o}px`,p=n?c:`${m}px`):"left"===l&&(h=`${s.floating.width+o}px`,p=n?c:`${m}px`),{data:{x:h,y:p}}}});function ee(e){let[t,r="center"]=e.split("-");return[t,r]}var et=i.forwardRef((e,t)=>{let{container:r,...s}=e,[a,o]=i.useState(!1);(0,L.N)(()=>o(!0),[]);let l=r||a&&globalThis?.document?.body;return l?j.createPortal((0,n.jsx)(N.div,{...s,ref:t}),l):null});et.displayName="Portal";var er=e=>{let{present:t,children:r}=e,s=function(e){var t,r;let[s,a]=i.useState(),n=i.useRef(null),o=i.useRef(e),l=i.useRef("none"),[d,c]=(t=e?"mounted":"unmounted",r={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},i.useReducer((e,t)=>r[e][t]??e,t));return i.useEffect(()=>{let e=es(n.current);l.current="mounted"===d?e:"none"},[d]),(0,L.N)(()=>{let t=n.current,r=o.current;if(r!==e){let s=l.current,a=es(t);e?c("MOUNT"):"none"===a||t?.display==="none"?c("UNMOUNT"):r&&s!==a?c("ANIMATION_OUT"):c("UNMOUNT"),o.current=e}},[e,c]),(0,L.N)(()=>{if(s){let e,t=s.ownerDocument.defaultView??window,r=r=>{let a=es(n.current).includes(CSS.escape(r.animationName));if(r.target===s&&a&&(c("ANIMATION_END"),!o.current)){let r=s.style.animationFillMode;s.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===s.style.animationFillMode&&(s.style.animationFillMode=r)})}},a=e=>{e.target===s&&(l.current=es(n.current))};return s.addEventListener("animationstart",a),s.addEventListener("animationcancel",r),s.addEventListener("animationend",r),()=>{t.clearTimeout(e),s.removeEventListener("animationstart",a),s.removeEventListener("animationcancel",r),s.removeEventListener("animationend",r)}}c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:i.useCallback(e=>{n.current=e?getComputedStyle(e):null,a(e)},[])}}(t),a="function"==typeof r?r({present:s.isPresent}):i.Children.only(r),n=(0,y.s)(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(r=(t=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning)?e.props.ref:e.props.ref||e.ref}(a));return"function"==typeof r||s.isPresent?i.cloneElement(a,{ref:n}):null};function es(e){return e?.animationName||"none"}er.displayName="Presence";var ea=r(5551),en=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ei=i.forwardRef((e,t)=>(0,n.jsx)(N.span,{...e,ref:t,style:{...en,...e.style}}));ei.displayName="VisuallyHidden";var[eo,el]=(0,b.A)("Tooltip",[z]),ed=z(),ec="TooltipProvider",eu="tooltip.open",[em,eh]=eo(ec),ep=e=>{let{__scopeTooltip:t,delayDuration:r=700,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:o}=e,l=i.useRef(!0),d=i.useRef(!1),c=i.useRef(0);return i.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,n.jsx)(em,{scope:t,isOpenDelayedRef:l,delayDuration:r,onOpen:i.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,s)},[s]),isPointerInTransitRef:d,onPointerInTransitChange:i.useCallback(e=>{d.current=e},[]),disableHoverableContent:a,children:o})};ep.displayName=ec;var ex="Tooltip",[ef,eg]=eo(ex),ev=e=>{let{__scopeTooltip:t,children:r,open:s,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:d}=e,c=eh(ex,e.__scopeTooltip),u=ed(t),[m,h]=i.useState(null),p=(0,P.B)(),x=i.useRef(0),f=l??c.disableHoverableContent,g=d??c.delayDuration,v=i.useRef(!1),[y,b]=(0,ea.i)({prop:s,defaultProp:a??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(eu))):c.onClose(),o?.(e)},caller:ex}),j=i.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),w=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,v.current=!1,b(!0)},[b]),N=i.useCallback(()=>{window.clearTimeout(x.current),x.current=0,b(!1)},[b]),k=i.useCallback(()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>{v.current=!0,b(!0),x.current=0},g)},[g,b]);return i.useEffect(()=>()=>{x.current&&(window.clearTimeout(x.current),x.current=0)},[]),(0,n.jsx)(U,{...u,children:(0,n.jsx)(ef,{scope:t,contentId:p,open:y,stateAttribute:j,trigger:m,onTriggerChange:h,onTriggerEnter:i.useCallback(()=>{c.isOpenDelayedRef.current?k():w()},[c.isOpenDelayedRef,k,w]),onTriggerLeave:i.useCallback(()=>{f?N():(window.clearTimeout(x.current),x.current=0)},[N,f]),onOpen:w,onClose:N,disableHoverableContent:f,children:r})})};ev.displayName=ex;var ey="TooltipTrigger",eb=i.forwardRef((e,t)=>{let{__scopeTooltip:r,...s}=e,a=eg(ey,r),o=eh(ey,r),l=ed(r),d=i.useRef(null),c=(0,y.s)(t,d,a.onTriggerChange),u=i.useRef(!1),m=i.useRef(!1),h=i.useCallback(()=>u.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),(0,n.jsx)(H,{asChild:!0,...l,children:(0,n.jsx)(N.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:c,onPointerMove:v(e.onPointerMove,e=>{"touch"!==e.pointerType&&(m.current||o.isPointerInTransitRef.current||(a.onTriggerEnter(),m.current=!0))}),onPointerLeave:v(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:v(e.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:v(e.onFocus,()=>{u.current||a.onOpen()}),onBlur:v(e.onBlur,a.onClose),onClick:v(e.onClick,a.onClose)})})});eb.displayName=ey;var ej="TooltipPortal",[ew,eN]=eo(ej,{forceMount:void 0}),ek=e=>{let{__scopeTooltip:t,forceMount:r,children:s,container:a}=e,i=eg(ej,t);return(0,n.jsx)(ew,{scope:t,forceMount:r,children:(0,n.jsx)(er,{present:r||i.open,children:(0,n.jsx)(et,{asChild:!0,container:a,children:s})})})};ek.displayName=ej;var eC="TooltipContent",eS=i.forwardRef((e,t)=>{let r=eN(eC,e.__scopeTooltip),{forceMount:s=r.forceMount,side:a="top",...i}=e,o=eg(eC,e.__scopeTooltip);return(0,n.jsx)(er,{present:s||o.open,children:o.disableHoverableContent?(0,n.jsx)(eP,{side:a,...i,ref:t}):(0,n.jsx)(eE,{side:a,...i,ref:t})})}),eE=i.forwardRef((e,t)=>{let r=eg(eC,e.__scopeTooltip),s=eh(eC,e.__scopeTooltip),a=i.useRef(null),o=(0,y.s)(t,a),[l,d]=i.useState(null),{trigger:c,onClose:u}=r,m=a.current,{onPointerInTransitChange:h}=s,p=i.useCallback(()=>{d(null),h(!1)},[h]),x=i.useCallback((e,t)=>{let r=e.currentTarget,s={x:e.clientX,y:e.clientY},a=function(e,t){let r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),n=Math.abs(t.left-e.x);switch(Math.min(r,s,a,n)){case n:return"left";case a:return"right";case r:return"top";case s:return"bottom";default:throw Error("unreachable")}}(s,r.getBoundingClientRect());d(function(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:1*!!(e.y>t.y)),function(e){if(e.length<=1)return e.slice();let t=[];for(let r=0;r<e.length;r++){let s=e[r];for(;t.length>=2;){let e=t[t.length-1],r=t[t.length-2];if((e.x-r.x)*(s.y-r.y)>=(e.y-r.y)*(s.x-r.x))t.pop();else break}t.push(s)}t.pop();let r=[];for(let t=e.length-1;t>=0;t--){let s=e[t];for(;r.length>=2;){let e=r[r.length-1],t=r[r.length-2];if((e.x-t.x)*(s.y-t.y)>=(e.y-t.y)*(s.x-t.x))r.pop();else break}r.push(s)}return(r.pop(),1===t.length&&1===r.length&&t[0].x===r[0].x&&t[0].y===r[0].y)?t:t.concat(r)}(t)}([...function(e,t,r=5){let s=[];switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r})}return s}(s,a),...function(e){let{top:t,right:r,bottom:s,left:a}=e;return[{x:a,y:t},{x:r,y:t},{x:r,y:s},{x:a,y:s}]}(t.getBoundingClientRect())])),h(!0)},[h]);return i.useEffect(()=>()=>p(),[p]),i.useEffect(()=>{if(c&&m){let e=e=>x(e,m),t=e=>x(e,c);return c.addEventListener("pointerleave",e),m.addEventListener("pointerleave",t),()=>{c.removeEventListener("pointerleave",e),m.removeEventListener("pointerleave",t)}}},[c,m,x,p]),i.useEffect(()=>{if(l){let e=e=>{let t=e.target,r={x:e.clientX,y:e.clientY},s=c?.contains(t)||m?.contains(t),a=!function(e,t){let{x:r,y:s}=e,a=!1;for(let e=0,n=t.length-1;e<t.length;n=e++){let i=t[e],o=t[n],l=i.x,d=i.y,c=o.x,u=o.y;d>s!=u>s&&r<(c-l)*(s-d)/(u-d)+l&&(a=!a)}return a}(r,l);s?p():a&&(p(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,m,l,u,p]),(0,n.jsx)(eP,{...e,ref:o})}),[eA,eT]=eo(ex,{isInside:!1}),eR=(0,w.Dc)("TooltipContent"),eP=i.forwardRef((e,t)=>{let{__scopeTooltip:r,children:s,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...d}=e,c=eg(eC,r),u=ed(r),{onClose:m}=c;return i.useEffect(()=>(document.addEventListener(eu,m),()=>document.removeEventListener(eu,m)),[m]),i.useEffect(()=>{if(c.trigger){let e=e=>{let t=e.target;t?.contains(c.trigger)&&m()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,m]),(0,n.jsx)(A,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:m,children:(0,n.jsxs)(G,{"data-state":c.stateAttribute,...u,...d,ref:t,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,n.jsx)(eR,{children:s}),(0,n.jsx)(eA,{scope:r,isInside:!0,children:(0,n.jsx)(ei,{id:c.contentId,role:"tooltip",children:a||s})})]})})});eS.displayName=eC;var eO="TooltipArrow",eD=i.forwardRef((e,t)=>{let{__scopeTooltip:r,...s}=e,a=ed(r);return eT(eO,r).isInside?null:(0,n.jsx)(X,{...a,...s,ref:t})});function eM({delayDuration:e=0,...t}){return(0,n.jsx)(ep,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function eL({...e}){return(0,n.jsx)(eM,{children:(0,n.jsx)(ev,{"data-slot":"tooltip",...e})})}function eF({...e}){return(0,n.jsx)(eb,{"data-slot":"tooltip-trigger",...e})}function eI({className:e,sideOffset:t=0,children:r,...s}){return(0,n.jsx)(ek,{children:(0,n.jsxs)(eS,{"data-slot":"tooltip-content",sideOffset:t,className:(0,d.cn)("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-md px-3 py-1.5 text-xs text-balance",e),...s,children:[r,(0,n.jsx)(eD,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}eD.displayName=eO;var e$=r(4934);let ez=(0,i.forwardRef)(({children:e,tooltip:t,side:r="bottom",className:s,...a},i)=>(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsxs)(e$.$,{variant:"ghost",size:"icon",...a,className:(0,d.cn)("size-6 p-1",s),ref:i,children:[e,(0,n.jsx)("span",{className:"sr-only",children:t})]})}),(0,n.jsx)(eI,{side:r,children:t})]}));function eq({value:e,tooltip:t="Copy",copiedTooltip:r="Copied!",className:s,size:a=12}){let[o,l]=(0,i.useState)(!1);return(0,n.jsx)(ez,{tooltip:o?r:t,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)}).catch(()=>{})},className:s,children:o?(0,n.jsx)(x.A,{size:a}):(0,n.jsx)(f.A,{size:a})})}ez.displayName="TooltipIconButton";var e_=r(2688);let eU=(0,e_.A)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),eB=(0,e_.A)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);class eH{get supported(){return!1}constructor(){if(this._speaking=!1,this.subscribers=new Set,this.utterance=null,this.voices=[],this.voiceSubscribers=new Set,this.preferredVoiceName=null,this.supported){try{let e=window.localStorage.getItem("ttsVoiceName");this.preferredVoiceName=e&&e.length?e:null}catch{}let e=()=>{try{let e=window.speechSynthesis.getVoices()||[];(e.length!==this.voices.length||e.some((e,t)=>e.name!==this.voices[t]?.name))&&(this.voices=e,this.voiceSubscribers.forEach(e=>e()))}catch{}};e();try{window.speechSynthesis.addEventListener("voiceschanged",e)}catch{}}}isSpeaking(){return this._speaking}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}subscribeVoices(e){return this.voiceSubscribers.add(e),()=>{this.voiceSubscribers.delete(e)}}notify(){for(let e of this.subscribers)try{e()}catch{}}stop(){if(this.supported){try{window.speechSynthesis.cancel()}catch{}this.utterance=null,this._speaking&&(this._speaking=!1,this.notify())}}speak(e,t){if(!this.supported||!e||!e.trim())return;this.stop();let r=new window.SpeechSynthesisUtterance(e);t?.rate!=null&&(r.rate=t.rate),t?.pitch!=null&&(r.pitch=t.pitch);let s=this.resolveVoice();if(s)try{r.voice=s,t?.lang?r.lang=t.lang:s.lang&&(r.lang=s.lang)}catch{}else t?.lang&&(r.lang=t.lang);r.onstart=()=>{this.utterance===r&&(this._speaking=!0,this.notify())};let a=()=>{this.utterance===r&&(this._speaking=!1,this.utterance=null,this.notify())};r.onend=a,r.onerror=a;try{this.utterance=r,window.speechSynthesis.speak(r),this._speaking||(this._speaking=!0,this.notify())}catch{a()}}getVoices(){return this.voices}setPreferredVoice(e){this.preferredVoiceName=e&&e.length?e:null;try{this.preferredVoiceName?window.localStorage.setItem("ttsVoiceName",this.preferredVoiceName):window.localStorage.removeItem("ttsVoiceName")}catch{}this.voiceSubscribers.forEach(e=>e())}getPreferredVoiceName(){return this.preferredVoiceName}resolveVoice(){if(!this.voices.length)return null;let e=this.preferredVoiceName?this.voices.find(e=>e.name===this.preferredVoiceName):null;if(e)return e;let t=this.voices.find(e=>"google uk english female"===e.name.toLowerCase()||e.name.toLowerCase().includes("google uk english female")&&e.lang?.toLowerCase().startsWith("en-gb"));if(t)return t;let r=e=>{let t=e.name.toLowerCase(),r=(e.lang??"").toLowerCase(),s=0;return("en"===r||r.startsWith("en-"))&&(s+=3),t.includes("google")&&(s+=5),(t.includes("microsoft")||t.includes("azure"))&&(s+=4),(t.includes("natural")||t.includes("neural")||t.includes("premium"))&&(s+=4),t.includes("siri")&&(s+=3),t.includes("female")&&(s+=1),s};return[...this.voices].sort((e,t)=>r(t)-r(e))[0]||this.voices[0]||null}}let eW=globalThis,eV=eW.__speechController??(eW.__speechController=new eH);function eJ({value:e,tooltip:t="Speak",stopTooltip:r="Stop",className:s,rate:a=1,pitch:o=1,lang:l}){let[d,c]=(0,i.useState)(!1),u=eV.supported,m=(e??"").trim().length>0;return(0,n.jsx)(ez,{tooltip:d?r:t,onClick:()=>{if(u&&m){if(d)return eV.stop();eV.speak(e,{rate:a,pitch:o,lang:l})}},className:s,disabled:!u||!m,children:d?(0,n.jsx)(eU,{size:12}):(0,n.jsx)(eB,{size:12})})}function eG({error:e,onDismiss:t}){let[r,s]=(0,i.useState)(!1),a=e.detailedIssues?.[0],o=a?.context&&"object"==typeof a.context&&"detailedIssues"in a.context?a.context.detailedIssues:[],l=o.length>0?`${e.message}
|
|
2
|
+
|
|
3
|
+
Details:
|
|
4
|
+
${o.map(e=>{let t=e.message;if(e.context){let r="string"==typeof e.context?e.context:JSON.stringify(e.context,null,2);t+=`
|
|
5
|
+
Context: ${r}`}return t}).join("\n\n")}`:e.message;return(0,n.jsx)("div",{className:"w-full rounded-lg p-4 mb-4 border shadow-sm bg-destructive/10 border-destructive/40",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(u.A,{className:"h-5 w-5 text-destructive mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-destructive",children:"Error"}),e.context&&(0,n.jsx)("span",{className:"text-xs bg-destructive/15 text-destructive px-2 py-0.5 rounded-full",children:e.context})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[o.length>0&&(0,n.jsx)("button",{onClick:()=>s(!r),className:"p-1 hover:bg-destructive/15 rounded text-destructive",title:r?"Collapse":"Expand",children:r?(0,n.jsx)(m.A,{className:"h-4 w-4"}):(0,n.jsx)(h.A,{className:"h-4 w-4"})}),(0,n.jsx)(eq,{value:l,tooltip:"Copy error",className:"p-1 hover:bg-destructive/15 rounded text-destructive",size:16}),(0,n.jsx)(eJ,{value:l,tooltip:"Read error",className:"p-1 hover:bg-destructive/15 rounded text-destructive"}),(0,n.jsx)("button",{onClick:t,className:"p-1 hover:bg-destructive/15 rounded text-destructive",title:"Dismiss",children:(0,n.jsx)(p.A,{className:"h-4 w-4"})})]})]}),(0,n.jsx)("div",{className:"mt-2 text-sm text-destructive",children:e.message}),r&&o.length>0&&(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)("div",{className:"text-xs text-destructive bg-destructive/10 p-3 rounded border border-destructive/30 overflow-auto max-h-60",children:o.map((e,t)=>(0,n.jsxs)("div",{className:"mb-2 last:mb-0",children:[(0,n.jsx)("div",{className:"font-medium",children:e.message}),null!=e.context&&(0,n.jsx)("div",{className:"text-destructive/70 mt-1",children:"string"==typeof e.context?e.context:JSON.stringify(e.context,null,2)})]},t))})})]})]})})}let eK=(0,e_.A)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),eY=(0,e_.A)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),eX=(0,e_.A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),eZ=(0,e_.A)("brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]),eQ=(0,e_.A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var e0=r(5336);let e1=(0,e_.A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),e2=(0,e_.A)("file-audio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]),e4=(0,e_.A)("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),e3=(0,e_.A)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),e5=(0,e_.A)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var e8=r(1736),e6=r(5629);let e7=(0,i.memo)(({children:e})=>(0,n.jsx)("div",{className:"prose max-w-none dark:prose-invert [&>p]:my-5 [&>p]:leading-7 [&>p]:first:mt-0 [&>p]:last:mb-0 [&>h1]:mb-8 [&>h1]:text-4xl [&>h1]:font-extrabold [&>h1]:tracking-tight [&>h1]:last:mb-0 [&>h2]:mb-4 [&>h2]:mt-8 [&>h2]:text-3xl [&>h2]:font-semibold [&>h2]:tracking-tight [&>h2]:first:mt-0 [&>h2]:last:mb-0 [&>h3]:mb-4 [&>h3]:mt-6 [&>h3]:text-2xl [&>h3]:font-semibold [&>h3]:tracking-tight [&>h3]:first:mt-0 [&>h3]:last:mb-0 [&>h4]:mb-4 [&>h4]:mt-6 [&>h4]:text-xl [&>h4]:font-semibold [&>h4]:tracking-tight [&>h4]:first:mt-0 [&>h4]:last:mb-0 [&>ul]:my-5 [&>ul]:ml-6 [&>ul]:list-disc [&>ul>li]:mt-2 [&>ol]:my-5 [&>ol]:ml-6 [&>ol]:list-decimal [&>ol>li]:mt-2 [&_ul]:my-5 [&_ul]:ml-6 [&_ul]:list-disc [&_ul>li]:mt-2 [&_ol]:my-5 [&_ol]:ml-6 [&_ol]:list-decimal [&_ol>li]:mt-2 [&>blockquote]:border-l-2 [&>blockquote]:pl-6 [&>blockquote]:italic [&>hr]:my-5 [&>hr]:border-b",children:(0,n.jsx)(e8.oz,{remarkPlugins:[e6.A],skipHtml:!0,components:{table:({className:e,children:t,...r})=>(0,n.jsx)("div",{className:"my-4 overflow-x-auto -mx-1 px-1",children:(0,n.jsx)("table",{className:["w-full border-separate border-spacing-0",e].filter(Boolean).join(" "),...r,children:t})}),thead:({className:e,...t})=>(0,n.jsx)("thead",{className:e,...t}),tr:({className:e,...t})=>(0,n.jsx)("tr",{className:["m-0 border-b first:border-t","[&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e].filter(Boolean).join(" "),...t}),th:({className:e,...t})=>(0,n.jsx)("th",{className:["bg-muted text-left font-bold align-top","px-4 py-2 first:rounded-tl-lg last:rounded-tr-lg","[&[align=center]]:text-center [&[align=right]]:text-right",e].filter(Boolean).join(" "),...t}),td:({className:e,...t})=>(0,n.jsx)("td",{className:["border-b border-l last:border-r text-left align-top","px-4 py-2 whitespace-normal break-words","[&[align=center]]:text-center [&[align=right]]:text-right",e].filter(Boolean).join(" "),...t}),code:({className:e,children:t,...r})=>{let[s,a]=(0,i.useState)(!1),o=String(t??"").replace(/\n$/,"");return e?(0,n.jsxs)("div",{className:"relative group my-4",children:[(0,n.jsx)(ez,{tooltip:s?"Copied!":"Copy code",onClick:()=>{navigator.clipboard.writeText(o).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)}).catch(()=>{})},className:"absolute right-2 top-2 z-10 opacity-70 hover:opacity-100 transition-opacity bg-background/80 hover:bg-background",children:s?(0,n.jsx)(x.A,{size:14}):(0,n.jsx)(f.A,{size:14})}),(0,n.jsx)("pre",{className:"overflow-auto bg-muted p-3 rounded-lg text-sm",children:(0,n.jsx)("code",{className:e,children:o})})]}):(0,n.jsx)("code",{className:"text-xs px-1.5 py-0.5 bg-muted rounded font-mono",...r,children:t})}},children:e})})),e9=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function te(e){return/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/i.test(e)}function tt(e){try{let t=new URL(e);return("https:"===t.protocol||"http:"===t.protocol)&&"localhost"!==t.hostname}catch{return!1}}function tr(e){if(e.base64&&e.mimeType)return`data:${e.mimeType};base64,${e.base64}`;if("string"==typeof e.base64)return e.base64;let t=e.url??e.image??e.audio;return"string"==typeof t?t:""}function ts({messages:e,activeError:t,onDismissError:r,outerRef:s}){let a=(0,i.useRef)(null),[o,l]=(0,i.useState)({}),[x,f]=(0,i.useState)({}),[g,v]=(0,i.useState)(null);(0,i.useRef)(null);let[y,b]=(0,i.useState)({isOpen:!1,src:"",alt:""}),j=(e,t)=>{b({isOpen:!0,src:e,alt:t})};if(!e||0===e.length)return null;let w=e=>"string"==typeof e.content?e.content:Array.isArray(e.content)?e.content.map(e=>(0,c.PI)(e)?e.text:"").filter(Boolean).join("\n"):e.content&&"object"==typeof e.content?JSON.stringify(e.content,null,2):"",N=e=>e?(0,c.KU)(e)?"object"==typeof e.error?JSON.stringify(e.error,null,2):String(e.error):(0,c.P2)(e)?e.content.map(e=>(0,c.PI)(e)?e.text:"object"==typeof e?"":String(e)).filter(Boolean).join("\n"):"object"==typeof e?JSON.stringify(e,null,2):String(e):"";return(0,n.jsxs)("div",{id:"message-list-container",ref:s,className:"flex flex-col space-y-3 px-4 py-2",children:[e.map((s,a)=>{let i=s.id??`msg-${a}`,p="user"===s.role,g="assistant"===s.role,v="system"===s.role,y=a===e.length-1,b=!!(s.toolName&&s.toolArgs),k=!!(s.toolName&&s.toolResult),C=b||k,S=C&&y||!!o[i],E=[],A=[];k&&s.toolResult&&(0,c.P2)(s.toolResult)&&s.toolResult.content.forEach((e,t)=>{if((0,c.j0)(e)){let r=tr(e);r&&(r.startsWith("data:")&&te(r)||r.startsWith("blob:")||tt(r))&&E.push({src:r,alt:`Tool result image ${t+1}`,index:t})}else if((0,c.kz)(e)){let r=tr(e);r&&(r.startsWith("data:audio/")||r.startsWith("blob:")||tt(r))&&A.push({src:r,filename:e.filename,index:t})}});let T=p?eK:eY,R=(0,d.cn)(p?"grid w-full grid-cols-[1fr_auto] gap-x-2 items-start":"grid w-full grid-cols-[auto_1fr] gap-x-2 items-start"),P=(0,d.cn)("tool"===s.role?"w-full text-muted-foreground/70 bg-secondary border border-muted/30 rounded-md text-base":p?"p-3 rounded-xl shadow-sm w-fit max-w-[75%] bg-primary text-primary-foreground rounded-br-none text-base break-normal hyphens-none":g?"p-3 rounded-xl shadow-sm w-fit max-w-[90%] bg-card text-card-foreground border border-border rounded-bl-none text-base break-normal hyphens-none":v?"p-3 shadow-none w-full bg-transparent text-xs text-muted-foreground italic text-center border-none":""),O=e9(s.createdAt),D=!!(t&&t.anchorMessageId===s.id);return(0,n.jsxs)("div",{className:"w-full","data-role":s.role,id:s.id?`message-${s.id}`:void 0,children:[(0,n.jsxs)("div",{className:R,children:[g&&(0,n.jsx)(T,{className:"h-7 w-7 mt-1 text-muted-foreground col-start-1"}),"tool"===s.role&&(0,n.jsx)(eX,{className:"h-7 w-7 p-1 mt-1 rounded-full border border-border text-muted-foreground col-start-1"}),(0,n.jsxs)("div",{className:(0,d.cn)("flex flex-col group w-full",v?"col-span-2 items-center":p?"col-start-1 justify-self-end items-end":"col-start-2 justify-self-start items-start"),children:[(0,n.jsx)("div",{className:P,children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[g&&"string"==typeof s.reasoning&&s.reasoning.trim().length>0&&(0,n.jsxs)("div",{className:"mb-3 border border-orange-200/50 dark:border-orange-400/20 rounded-lg bg-gradient-to-br from-orange-50/30 to-amber-50/20 dark:from-orange-900/20 dark:to-amber-900/10",children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-orange-200/30 dark:border-orange-400/20 bg-orange-100/50 dark:bg-orange-900/30 rounded-t-lg flex items-center justify-between",children:[(0,n.jsxs)("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-orange-700 dark:text-orange-300 hover:text-orange-800 dark:hover:text-orange-200 transition-colors group",onClick:()=>f(e=>({...e,[s.id]:!e[s.id]})),children:[(0,n.jsx)(eZ,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"AI Reasoning"}),x[s.id]??!0?(0,n.jsx)(m.A,{className:"h-3 w-3 group-hover:scale-110 transition-transform"}):(0,n.jsx)(h.A,{className:"h-3 w-3 group-hover:scale-110 transition-transform"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(eq,{value:s.reasoning,tooltip:"Copy reasoning",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,n.jsx)(eJ,{value:s.reasoning,tooltip:"Speak reasoning",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]}),(x[s.id]??!0)&&(0,n.jsx)("div",{className:"px-3 py-2",children:(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs text-orange-800/80 dark:text-orange-200/70 leading-relaxed font-mono",children:s.reasoning})})]}),s.toolName?(0,n.jsxs)("div",{className:"p-2 rounded border border-border bg-muted/30 hover:bg-muted/60 cursor-pointer w-full",onClick:()=>{C&&l(e=>({...e,[i]:!e[i]}))},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between text-xs font-medium",children:[(0,n.jsxs)("span",{className:"flex items-center",children:[S?(0,n.jsx)(m.A,{className:"h-4 w-4 mr-2 text-primary"}):(0,n.jsx)(eQ,{className:"h-4 w-4 mr-2 text-primary"}),"Tool: ",s.toolName]}),s.toolResult?(0,c.KU)(s.toolResult)?(0,n.jsx)(u.A,{className:"mx-2 h-4 w-4 text-red-500"}):(0,n.jsx)(e0.A,{className:"mx-2 h-4 w-4 text-green-500"}):(0,n.jsx)(e1,{className:"mx-2 h-4 w-4 animate-spin text-muted-foreground"})]}),S&&(0,n.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"text-xs font-medium",children:"Arguments:"}),(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(s.toolArgs,null,2)})]}),s.toolResult&&(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"text-xs font-medium flex items-center justify-between",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("span",{children:"Result:"}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(eq,{value:N(s.toolResult),tooltip:"Copy result",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,n.jsx)(eJ,{value:N(s.toolResult),tooltip:"Speak result",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]}),(0,c.KU)(s.toolResult)?(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-red-100 text-red-700 p-2 rounded text-xs",children:"object"==typeof s.toolResult.error?JSON.stringify(s.toolResult.error,null,2):String(s.toolResult.error)}):(0,c.P2)(s.toolResult)?s.toolResult.content.map((e,t)=>(0,c.j0)(e)||(0,c.kz)(e)?null:(0,c.PI)(e)?(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:e.text},t):(0,c.EQ)(e)?(0,n.jsxs)("div",{className:"my-1 flex items-center gap-2 p-2 rounded border border-border bg-muted/50",children:[(0,n.jsx)(e2,{className:"h-4 w-4 text-muted-foreground"}),(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.filename||"File attachment"," (",e.mimeType,")"]})]},t):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:"object"==typeof e?JSON.stringify(e,null,2):String(e)},t)):(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:"string"==typeof s.toolResult&&s.toolResult.startsWith("data:image")?te(s.toolResult)?(0,n.jsx)("img",{src:s.toolResult,alt:"Tool result image",className:"my-1 max-h-48 w-auto rounded border border-border"}):"Invalid image data":"object"==typeof s.toolResult?JSON.stringify(s.toolResult,null,2):String(s.toolResult)})]})]})]}):(0,n.jsxs)(n.Fragment,{children:["string"==typeof s.content&&""!==s.content.trim()&&(0,n.jsx)("div",{className:"relative",children:p?(0,n.jsx)("p",{className:"text-base whitespace-pre-line break-normal",children:s.content}):(0,n.jsx)(e7,{children:s.content})}),s.content&&"object"==typeof s.content&&!Array.isArray(s.content)&&(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(s.content,null,2)}),Array.isArray(s.content)&&s.content.map((e,t)=>{let r=`${i}-part-${t}`;if("text"===e.type)return(0,n.jsx)("div",{className:"relative",children:p?(0,n.jsx)("p",{className:"text-base whitespace-pre-line break-normal",children:e.text}):(0,n.jsx)(e7,{children:e.text})},r);if((0,c.EQ)(e)){if(!e.mimeType.startsWith("audio/"))return(0,n.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(e4,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm font-medium",children:e.filename||`${e.mimeType} file`}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e.mimeType})]},r);{let t=`data:${e.mimeType};base64,${e.data}`;return(0,n.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(e2,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("audio",{controls:!0,src:t,className:"flex-1 h-8"}),e.filename&&(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:e.filename})]},r)}}return null}),v&&!s.content&&(0,n.jsx)("p",{className:"italic",children:"System message"})]}),s.imageData&&!Array.isArray(s.content)&&(()=>{let e=`data:${s.imageData.mimeType};base64,${s.imageData.base64}`;return te(e)?(0,n.jsx)("img",{src:e,alt:"attachment",className:"mt-2 max-h-60 w-full rounded-lg border border-border object-contain"}):null})(),s.fileData&&!Array.isArray(s.content)&&(0,n.jsx)("div",{className:"mt-2",children:s.fileData.mimeType.startsWith("audio/")?(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(e2,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("audio",{controls:!0,src:`data:${s.fileData.mimeType};base64,${s.fileData.base64}`,className:"flex-1 h-8"}),s.fileData.filename&&(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:s.fileData.filename})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,n.jsx)(e4,{className:"h-5 w-5 text-muted-foreground"}),(0,n.jsx)("span",{className:"text-sm font-medium",children:s.fileData.filename||`${s.fileData.mimeType} file`}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:s.fileData.mimeType})]})})]})}),!v&&!C&&(0,n.jsxs)("div",{className:"text-xs text-muted-foreground mt-1 px-1 flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{children:O}),g&&s.tokenUsage?.totalTokens!==void 0&&(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/50 text-xs cursor-default",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),s.tokenUsage.totalTokens," tokens"]})}),(0,n.jsx)(eI,{children:(0,n.jsxs)("div",{className:"flex flex-col gap-0.5",children:[void 0!==s.tokenUsage.inputTokens&&(0,n.jsxs)("div",{children:["Input: ",s.tokenUsage.inputTokens]}),void 0!==s.tokenUsage.outputTokens&&(0,n.jsxs)("div",{children:["Output: ",s.tokenUsage.outputTokens]}),void 0!==s.tokenUsage.reasoningTokens&&(0,n.jsxs)("div",{children:["Reasoning: ",s.tokenUsage.reasoningTokens]}),(0,n.jsxs)("div",{className:"font-medium mt-0.5",children:["Total: ",s.tokenUsage.totalTokens]})]})})]}),g&&s.model&&(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{children:(0,n.jsx)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/30 text-xs cursor-default",children:s.model})}),(0,n.jsx)(eI,{children:(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("div",{className:"font-medium",children:["Model: ",s.model]}),s.router&&(0,n.jsxs)("div",{className:"text-muted-foreground",children:["Router: ",s.router]})]})})]})]}),(g||p)&&(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(eq,{value:w(s),tooltip:"Copy message",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,n.jsx)(eJ,{value:w(s),tooltip:"Speak",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]})]}),p&&(0,n.jsx)(T,{className:"h-7 w-7 mt-1 text-muted-foreground col-start-2"})]}),E.map((e,t)=>(0,n.jsx)("div",{className:"w-full mt-2",children:(0,n.jsxs)("div",{className:"flex items-end w-full justify-start",children:[(0,n.jsx)(e3,{className:"h-7 w-7 mr-2 mb-1 text-muted-foreground self-start flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex flex-col items-start",children:[(0,n.jsx)("div",{className:"p-3 rounded-xl shadow-sm max-w-[75%] bg-card text-card-foreground border border-border rounded-bl-none text-sm",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)(e3,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:"Tool Result Image"})]}),(0,n.jsxs)("div",{className:"relative group cursor-pointer",onClick:()=>j(e.src,e.alt),children:[(0,n.jsx)("img",{src:e.src,alt:e.alt,className:"max-h-80 w-auto rounded border border-border object-contain transition-transform group-hover:scale-[1.02]"}),(0,n.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors rounded border border-border flex items-center justify-center",children:(0,n.jsx)(e5,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity drop-shadow-lg"})})]})]})}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-1 px-1",children:(0,n.jsx)("span",{children:O})})]})]})},`${i}-image-${t}`)),A.map((e,t)=>(0,n.jsx)("div",{className:"w-full mt-2",children:(0,n.jsxs)("div",{className:"flex items-end w-full justify-start",children:[(0,n.jsx)(eB,{className:"h-7 w-7 mr-2 mb-1 text-muted-foreground self-start flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex flex-col items-start",children:[(0,n.jsx)("div",{className:"p-3 rounded-xl shadow-sm max-w-[75%] bg-card text-card-foreground border border-border rounded-bl-none text-sm overflow-hidden",children:(0,n.jsxs)("div",{className:"flex flex-col gap-2 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)(eB,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:"Tool Result Audio"})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-2 p-2 rounded border border-border bg-muted/30 min-w-0 audio-controls-container",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)(e2,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("audio",{controls:!0,src:e.src,className:"flex-1 min-w-0"})]}),e.filename&&(0,n.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:e.filename})})]})]})}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-1 px-1",children:(0,n.jsx)("span",{children:O})})]})]})},`${i}-audio-${t}`)),D&&(0,n.jsx)("div",{className:"mt-2 ml-12 mr-4",children:(0,n.jsx)(eG,{error:t,onDismiss:r||(()=>{})})})]},i)}),(0,n.jsx)("div",{ref:a,className:"h-px"},"end-anchor"),y.isOpen&&(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,n.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh] bg-background rounded-lg shadow-2xl border border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,n.jsx)("h3",{className:"text-lg font-semibold",children:"Tool Result Image"}),(0,n.jsx)("button",{onClick:()=>{b({isOpen:!1,src:"",alt:""})},className:"p-2 hover:bg-muted rounded-md transition-colors","aria-label":"Close modal",children:(0,n.jsx)(p.A,{className:"h-5 w-5"})})]}),(0,n.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,n.jsx)("img",{src:y.src,alt:y.alt,className:"max-w-full max-h-[70vh] object-contain rounded"})}),(0,n.jsx)("div",{className:"p-4 border-t border-border text-sm text-muted-foreground",children:(0,n.jsx)("p",{children:y.alt})})]})})]})}function ta(){return(ta=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e}).apply(null,arguments)}var tn="undefined"!=typeof document?i.useLayoutEffect:function(){},ti=function(e){var t=o().useRef(e);return tn(function(){t.current=e}),t},to=function(e,t){if("function"==typeof e)return void e(t);e.current=t},tl=function(e,t){var r=o().useRef();return o().useCallback(function(s){e.current=s,r.current&&to(r.current,null),r.current=t,t&&to(t,s)},[t])},td="undefined"!=typeof document,tc={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},tu=function(e){Object.keys(tc).forEach(function(t){e.style.setProperty(t,tc[t],"important")})},tm=null,th=function(e,t){var r=e.scrollHeight;return"border-box"===t.sizingStyle.boxSizing?r+t.borderSize:r-t.paddingSize},tp=function(){},tx=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],tf=!!td&&!!document.documentElement.currentStyle,tg=function(e){var t=window.getComputedStyle(e);if(null===t)return null;var r=tx.reduce(function(e,r){return e[r]=t[r],e},{}),s=r.boxSizing;if(""===s)return null;tf&&"border-box"===s&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var a=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),n=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:a,borderSize:n}};function tv(e,t,r){var s=ti(r);i.useLayoutEffect(function(){var r=function(e){return s.current(e)};if(e)return e.addEventListener(t,r),function(){return e.removeEventListener(t,r)}},[])}var ty=function(e,t){tv(document.body,"reset",function(r){e.current.form===r.target&&t(r)})},tb=function(e){tv(window,"resize",e)},tj=function(e){tv(document.fonts,"loadingdone",e)},tw=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],tN=i.forwardRef(function(e,t){var r=e.cacheMeasurements,s=e.maxRows,a=e.minRows,n=e.onChange,o=void 0===n?tp:n,l=e.onHeightChange,d=void 0===l?tp:l,c=function(e,t){if(null==e)return{};var r={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;r[s]=e[s]}return r}(e,tw),u=void 0!==c.value,m=i.useRef(null),h=tl(m,t),p=i.useRef(0),x=i.useRef(),f=function(){var e=m.current,t=r&&x.current?x.current:tg(e);if(t){x.current=t;var n,i,o,l,c,u,h,f,g,v,y,b=(n=e.value||e.placeholder||"x",void 0===(i=a)&&(i=1),void 0===(o=s)&&(o=1/0),tm||((tm=document.createElement("textarea")).setAttribute("tabindex","-1"),tm.setAttribute("aria-hidden","true"),tu(tm)),null===tm.parentNode&&document.body.appendChild(tm),l=t.paddingSize,c=t.borderSize,h=(u=t.sizingStyle).boxSizing,Object.keys(u).forEach(function(e){tm.style[e]=u[e]}),tu(tm),tm.value=n,f=th(tm,t),tm.value=n,f=th(tm,t),tm.value="x",v=(g=tm.scrollHeight-l)*i,"border-box"===h&&(v=v+l+c),f=Math.max(v,f),y=g*o,"border-box"===h&&(y=y+l+c),[f=Math.min(y,f),g]),j=b[0],w=b[1];p.current!==j&&(p.current=j,e.style.setProperty("height",j+"px","important"),d(j,{rowHeight:w}))}};return td?(i.useLayoutEffect(f),ty(m,function(){if(!u){var e=m.current.value;requestAnimationFrame(function(){var t=m.current;t&&e!==t.value&&f()})}}),tb(f),tj(f),i.createElement("textarea",ta({},c,{onChange:function(e){u||f(),o(e)},ref:h}))):i.createElement("textarea",ta({},c,{onChange:o,ref:h}))});function tk({children:e,className:t}){return(0,n.jsx)("div",{className:(0,d.cn)("relative","w-full","flex flex-col overflow-hidden","max-h-[max(35svh,5rem)]","border-2 border-border/50","bg-background","rounded-3xl shadow-sm","transition-all duration-200",t),children:e})}function tC({leftButtons:e,rightButtons:t,className:r}){return(0,n.jsxs)("div",{className:(0,d.cn)("flex items-center justify-between","h-12 px-2",r),children:[(0,n.jsx)("div",{className:"flex items-center gap-2",children:e}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:t})]})}let tS=(0,e_.A)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var tE=r(569),tA=r(3721),tT=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=(0,w.TL)(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),tR="Switch",[tP,tO]=(0,b.A)(tR),[tD,tM]=tP(tR),tL=i.forwardRef((e,t)=>{let{__scopeSwitch:r,name:s,checked:a,defaultChecked:o,required:l,disabled:d,value:c="on",onCheckedChange:u,form:m,...h}=e,[p,x]=i.useState(null),f=(0,y.s)(t,e=>x(e)),g=i.useRef(!1),v=!p||m||!!p.closest("form"),[b,j]=(0,ea.i)({prop:a,defaultProp:o??!1,onChange:u,caller:tR});return(0,n.jsxs)(tD,{scope:r,checked:b,disabled:d,children:[(0,n.jsx)(tT.button,{type:"button",role:"switch","aria-checked":b,"aria-required":l,"data-state":tz(b),"data-disabled":d?"":void 0,disabled:d,value:c,...h,ref:f,onClick:(0,tE.m)(e.onClick,e=>{j(e=>!e),v&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),v&&(0,n.jsx)(t$,{control:p,bubbles:!g.current,name:s,value:c,checked:b,required:l,disabled:d,form:m,style:{transform:"translateX(-100%)"}})]})});tL.displayName=tR;var tF="SwitchThumb",tI=i.forwardRef((e,t)=>{let{__scopeSwitch:r,...s}=e,a=tM(tF,r);return(0,n.jsx)(tT.span,{"data-state":tz(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t})});tI.displayName=tF;var t$=i.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:s=!0,...a},o)=>{let l=i.useRef(null),d=(0,y.s)(l,o),c=(0,tA.Z)(r),u=(0,F.X)(t);return i.useEffect(()=>{let e=l.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(c!==r&&t){let a=new Event("click",{bubbles:s});t.call(e,r),e.dispatchEvent(a)}},[c,r,s]),(0,n.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:d,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function tz(e){return e?"checked":"unchecked"}t$.displayName="SwitchBubbleInput";let tq=i.forwardRef(({className:e,...t},r)=>(0,n.jsx)(tL,{className:(0,d.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:r,children:(0,n.jsx)(tI,{className:(0,d.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));function t_({isStreaming:e,onStreamingChange:t,className:r}){return(0,n.jsx)(eM,{children:(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsxs)("div",{className:`flex items-center gap-1.5 cursor-pointer ${r||""}`,children:[(0,n.jsx)(tS,{className:`h-3 w-3 ${e?"text-blue-500":"text-muted-foreground"}`}),(0,n.jsx)(tq,{checked:e,onCheckedChange:t,className:"scale-75","aria-label":"Toggle streaming"})]})}),(0,n.jsxs)(eI,{side:"top",children:[(0,n.jsx)("p",{children:e?"Streaming enabled":"Streaming disabled"}),(0,n.jsx)("p",{className:"text-xs opacity-75",children:e?"Responses will stream in real-time":"Responses will arrive all at once"})]})]})})}tq.displayName=tL.displayName;var tU=!!("undefined"!=typeof window&&window.document&&window.document.createElement);function tB(e,t,{checkForDefaultPrevented:r=!0}={}){return function(s){if(e?.(s),!1===r||!s.defaultPrevented)return t?.(s)}}var tH=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let r=(0,w.TL)(`Primitive.${t}`),s=i.forwardRef((e,s)=>{let{asChild:a,...i}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(a?r:t,{...i,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),tW="dismissableLayer.update",tV=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tJ=i.forwardRef((e,t)=>{let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:d,onDismiss:c,...u}=e,m=i.useContext(tV),[h,p]=i.useState(null),x=h?.ownerDocument??globalThis?.document,[,f]=i.useState({}),g=(0,y.s)(t,e=>p(e)),v=Array.from(m.layers),[b]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(b),w=h?v.indexOf(h):-1,N=m.layersWithOutsidePointerEventsDisabled.size>0,S=w>=j,E=function(e,t=globalThis?.document){let r=(0,k.c)(e),s=i.useRef(!1),a=i.useRef(()=>{});return i.useEffect(()=>{let e=e=>{if(e.target&&!s.current){let s=function(){tK("dismissableLayer.pointerDownOutside",r,n,{discrete:!0})},n={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",a.current),a.current=s,t.addEventListener("click",a.current,{once:!0})):s()}else t.removeEventListener("click",a.current);s.current=!1},n=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(n),t.removeEventListener("pointerdown",e),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}(e=>{let t=e.target,r=[...m.branches].some(e=>e.contains(t));S&&!r&&(o?.(e),d?.(e),e.defaultPrevented||c?.())},x),A=function(e,t=globalThis?.document){let r=(0,k.c)(e),s=i.useRef(!1);return i.useEffect(()=>{let e=e=>{e.target&&!s.current&&tK("dismissableLayer.focusOutside",r,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{let t=e.target;![...m.branches].some(e=>e.contains(t))&&(l?.(e),d?.(e),e.defaultPrevented||c?.())},x);return(0,C.U)(e=>{w===m.layers.size-1&&(s?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},x),i.useEffect(()=>{if(h)return r&&(0===m.layersWithOutsidePointerEventsDisabled.size&&(a=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),tG(),()=>{r&&1===m.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=a)}},[h,x,r,m]),i.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),tG())},[h,m]),i.useEffect(()=>{let e=()=>f({});return document.addEventListener(tW,e),()=>document.removeEventListener(tW,e)},[]),(0,n.jsx)(tH.div,{...u,ref:g,style:{pointerEvents:N?S?"auto":"none":void 0,...e.style},onFocusCapture:tB(e.onFocusCapture,A.onFocusCapture),onBlurCapture:tB(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:tB(e.onPointerDownCapture,E.onPointerDownCapture)})});function tG(){let e=new CustomEvent(tW);document.dispatchEvent(e)}function tK(e,t,r,{discrete:s}){let a=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});if(t&&a.addEventListener(e,t,{once:!0}),s)a&&j.flushSync(()=>a.dispatchEvent(n));else a.dispatchEvent(n)}tJ.displayName="DismissableLayer",i.forwardRef((e,t)=>{let r=i.useContext(tV),s=i.useRef(null),a=(0,y.s)(t,s);return i.useEffect(()=>{let e=s.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),(0,n.jsx)(tH.div,{...e,ref:a})}).displayName="DismissableLayerBranch";var tY=0;function tX(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tZ="focusScope.autoFocusOnMount",tQ="focusScope.autoFocusOnUnmount",t0={bubbles:!1,cancelable:!0},t1=i.forwardRef((e,t)=>{let{loop:r=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[d,c]=i.useState(null),u=(0,k.c)(a),m=(0,k.c)(o),h=i.useRef(null),p=(0,y.s)(t,e=>c(e)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let e=function(e){if(x.paused||!d)return;let t=e.target;d.contains(t)?h.current=t:t3(h.current,{select:!0})},t=function(e){if(x.paused||!d)return;let t=e.relatedTarget;null!==t&&(d.contains(t)||t3(h.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let r=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&t3(d)});return d&&r.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[s,d,x.paused]),i.useEffect(()=>{if(d){t5.add(x);let e=document.activeElement;if(!d.contains(e)){let t=new CustomEvent(tZ,t0);d.addEventListener(tZ,u),d.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){let r=document.activeElement;for(let s of e)if(t3(s,{select:t}),document.activeElement!==r)return}(t2(d).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&t3(d))}return()=>{d.removeEventListener(tZ,u),setTimeout(()=>{let t=new CustomEvent(tQ,t0);d.addEventListener(tQ,m),d.dispatchEvent(t),t.defaultPrevented||t3(e??document.body,{select:!0}),d.removeEventListener(tQ,m),t5.remove(x)},0)}}},[d,u,m,x]);let f=i.useCallback(e=>{if(!r&&!s||x.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){let t=e.currentTarget,[s,n]=function(e){let t=t2(e);return[t4(t,e),t4(t.reverse(),e)]}(t);s&&n?e.shiftKey||a!==n?e.shiftKey&&a===s&&(e.preventDefault(),r&&t3(n,{select:!0})):(e.preventDefault(),r&&t3(s,{select:!0})):a===t&&e.preventDefault()}},[r,s,x.paused]);return(0,n.jsx)(tH.div,{tabIndex:-1,...l,ref:p,onKeyDown:f})});function t2(e){let t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function t4(e,t){for(let r of e)if(!function(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===t||e!==t);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(r,{upTo:t}))return r}function t3(e,{select:t=!1}={}){if(e&&e.focus){var r;let s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&(r=e)instanceof HTMLInputElement&&"select"in r&&t&&e.select()}}t1.displayName="FocusScope";var t5=function(){let e=[];return{add(t){let r=e[0];t!==r&&r?.pause(),(e=t8(e,t)).unshift(t)},remove(t){e=t8(e,t),e[0]?.resume()}}}();function t8(e,t){let r=[...e],s=r.indexOf(t);return -1!==s&&r.splice(s,1),r}var t6=i.forwardRef((e,t)=>{let{children:r,width:s=10,height:a=5,...i}=e;return(0,n.jsx)(tH.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:(0,n.jsx)("polygon",{points:"0,0 30,0 15,10"})})});t6.displayName="Arrow";var t7="Popper",[t9,re]=(0,b.A)(t7),[rt,rr]=t9(t7),rs=e=>{let{__scopePopper:t,children:r}=e,[s,a]=i.useState(null);return(0,n.jsx)(rt,{scope:t,anchor:s,onAnchorChange:a,children:r})};rs.displayName=t7;var ra="PopperAnchor",rn=i.forwardRef((e,t)=>{let{__scopePopper:r,virtualRef:s,...a}=e,o=rr(ra,r),l=i.useRef(null),d=(0,y.s)(t,l),c=i.useRef(null);return i.useEffect(()=>{let e=c.current;c.current=s?.current||l.current,e!==c.current&&o.onAnchorChange(c.current)}),s?null:(0,n.jsx)(tH.div,{...a,ref:d})});rn.displayName=ra;var ri="PopperContent",[ro,rl]=t9(ri),rd=i.forwardRef((e,t)=>{let{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:d=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:x="optimized",onPlaced:f,...g}=e,v=rr(ri,r),[b,j]=i.useState(null),w=(0,y.s)(t,e=>j(e)),[N,C]=i.useState(null),S=(0,F.X)(N),E=S?.width??0,A=S?.height??0,T="number"==typeof m?m:{top:0,right:0,bottom:0,left:0,...m},R=Array.isArray(u)?u:[u],P=R.length>0,M={padding:T,boundary:R.filter(rh),altBoundary:P},{refs:I,floatingStyles:$,placement:z,isPositioned:q,middlewareData:_}=(0,O.we)({strategy:"fixed",placement:s+("center"!==o?"-"+o:""),whileElementsMounted:(...e)=>(0,D.ll)(...e,{animationFrame:"always"===x}),elements:{reference:v.anchor},middleware:[(0,O.cY)({mainAxis:a+A,alignmentAxis:l}),c&&(0,O.BN)({mainAxis:!0,crossAxis:!1,limiter:"partial"===h?(0,O.ER)():void 0,...M}),c&&(0,O.UU)({...M}),(0,O.Ej)({...M,apply:({elements:e,rects:t,availableWidth:r,availableHeight:s})=>{let{width:a,height:n}=t.reference,i=e.floating.style;i.setProperty("--radix-popper-available-width",`${r}px`),i.setProperty("--radix-popper-available-height",`${s}px`),i.setProperty("--radix-popper-anchor-width",`${a}px`),i.setProperty("--radix-popper-anchor-height",`${n}px`)}}),N&&(0,O.UE)({element:N,padding:d}),rp({arrowWidth:E,arrowHeight:A}),p&&(0,O.jD)({strategy:"referenceHidden",...M})]}),[U,B]=rx(z),H=(0,k.c)(f);(0,L.N)(()=>{q&&H?.()},[q,H]);let W=_.arrow?.x,V=_.arrow?.y,J=_.arrow?.centerOffset!==0,[G,K]=i.useState();return(0,L.N)(()=>{b&&K(window.getComputedStyle(b).zIndex)},[b]),(0,n.jsx)("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:q?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[_.transformOrigin?.x,_.transformOrigin?.y].join(" "),..._.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,n.jsx)(ro,{scope:r,placedSide:U,onArrowChange:C,arrowX:W,arrowY:V,shouldHideArrow:J,children:(0,n.jsx)(tH.div,{"data-side":U,"data-align":B,...g,ref:w,style:{...g.style,animation:q?void 0:"none"}})})})});rd.displayName=ri;var rc="PopperArrow",ru={top:"bottom",right:"left",bottom:"top",left:"right"},rm=i.forwardRef(function(e,t){let{__scopePopper:r,...s}=e,a=rl(rc,r),i=ru[a.placedSide];return(0,n.jsx)("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:(0,n.jsx)(t6,{...s,ref:t,style:{...s.style,display:"block"}})})});function rh(e){return null!==e}rm.displayName=rc;var rp=e=>({name:"transformOrigin",options:e,fn(t){let{placement:r,rects:s,middlewareData:a}=t,n=a.arrow?.centerOffset!==0,i=n?0:e.arrowWidth,o=n?0:e.arrowHeight,[l,d]=rx(r),c={start:"0%",center:"50%",end:"100%"}[d],u=(a.arrow?.x??0)+i/2,m=(a.arrow?.y??0)+o/2,h="",p="";return"bottom"===l?(h=n?c:`${u}px`,p=`${-o}px`):"top"===l?(h=n?c:`${u}px`,p=`${s.floating.height+o}px`):"right"===l?(h=`${-o}px`,p=n?c:`${m}px`):"left"===l&&(h=`${s.floating.width+o}px`,p=n?c:`${m}px`),{data:{x:h,y:p}}}});function rx(e){let[t,r="center"]=e.split("-");return[t,r]}var rf=i.forwardRef((e,t)=>{let{container:r,...s}=e,[a,o]=i.useState(!1);(0,L.N)(()=>o(!0),[]);let l=r||a&&globalThis?.document?.body;return l?j.createPortal((0,n.jsx)(tH.div,{...s,ref:t}),l):null});rf.displayName="Portal";var rg=e=>{let{present:t,children:r}=e,s=function(e){var t,r;let[s,a]=i.useState(),n=i.useRef(null),o=i.useRef(e),l=i.useRef("none"),[d,c]=(t=e?"mounted":"unmounted",r={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},i.useReducer((e,t)=>r[e][t]??e,t));return i.useEffect(()=>{let e=rv(n.current);l.current="mounted"===d?e:"none"},[d]),(0,L.N)(()=>{let t=n.current,r=o.current;if(r!==e){let s=l.current,a=rv(t);e?c("MOUNT"):"none"===a||t?.display==="none"?c("UNMOUNT"):r&&s!==a?c("ANIMATION_OUT"):c("UNMOUNT"),o.current=e}},[e,c]),(0,L.N)(()=>{if(s){let e,t=s.ownerDocument.defaultView??window,r=r=>{let a=rv(n.current).includes(CSS.escape(r.animationName));if(r.target===s&&a&&(c("ANIMATION_END"),!o.current)){let r=s.style.animationFillMode;s.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===s.style.animationFillMode&&(s.style.animationFillMode=r)})}},a=e=>{e.target===s&&(l.current=rv(n.current))};return s.addEventListener("animationstart",a),s.addEventListener("animationcancel",r),s.addEventListener("animationend",r),()=>{t.clearTimeout(e),s.removeEventListener("animationstart",a),s.removeEventListener("animationcancel",r),s.removeEventListener("animationend",r)}}c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:i.useCallback(e=>{n.current=e?getComputedStyle(e):null,a(e)},[])}}(t),a="function"==typeof r?r({present:s.isPresent}):i.Children.only(r),n=(0,y.s)(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(r=(t=Object.getOwnPropertyDescriptor(e,"ref")?.get)&&"isReactWarning"in t&&t.isReactWarning)?e.props.ref:e.props.ref||e.ref}(a));return"function"==typeof r||s.isPresent?i.cloneElement(a,{ref:n}):null};function rv(e){return e?.animationName||"none"}rg.displayName="Presence";var ry=r(3376),rb=r(2247),rj="Popover",[rw,rN]=(0,b.A)(rj,[re]),rk=re(),[rC,rS]=rw(rj),rE=e=>{let{__scopePopover:t,children:r,open:s,defaultOpen:a,onOpenChange:o,modal:l=!1}=e,d=rk(t),c=i.useRef(null),[u,m]=i.useState(!1),[h,p]=(0,ea.i)({prop:s,defaultProp:a??!1,onChange:o,caller:rj});return(0,n.jsx)(rs,{...d,children:(0,n.jsx)(rC,{scope:t,contentId:(0,P.B)(),triggerRef:c,open:h,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(e=>!e),[p]),hasCustomAnchor:u,onCustomAnchorAdd:i.useCallback(()=>m(!0),[]),onCustomAnchorRemove:i.useCallback(()=>m(!1),[]),modal:l,children:r})})};rE.displayName=rj;var rA="PopoverAnchor";i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=rS(rA,r),o=rk(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:d}=a;return i.useEffect(()=>(l(),()=>d()),[l,d]),(0,n.jsx)(rn,{...o,...s,ref:t})}).displayName=rA;var rT="PopoverTrigger",rR=i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=rS(rT,r),i=rk(r),o=(0,y.s)(t,a.triggerRef),l=(0,n.jsx)(tH.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":rU(a.open),...s,ref:o,onClick:tB(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:(0,n.jsx)(rn,{asChild:!0,...i,children:l})});rR.displayName=rT;var rP="PopoverPortal",[rO,rD]=rw(rP,{forceMount:void 0}),rM=e=>{let{__scopePopover:t,forceMount:r,children:s,container:a}=e,i=rS(rP,t);return(0,n.jsx)(rO,{scope:t,forceMount:r,children:(0,n.jsx)(rg,{present:r||i.open,children:(0,n.jsx)(rf,{asChild:!0,container:a,children:s})})})};rM.displayName=rP;var rL="PopoverContent",rF=i.forwardRef((e,t)=>{let r=rD(rL,e.__scopePopover),{forceMount:s=r.forceMount,...a}=e,i=rS(rL,e.__scopePopover);return(0,n.jsx)(rg,{present:s||i.open,children:i.modal?(0,n.jsx)(r$,{...a,ref:t}):(0,n.jsx)(rz,{...a,ref:t})})});rF.displayName=rL;var rI=(0,w.TL)("PopoverContent.RemoveScroll"),r$=i.forwardRef((e,t)=>{let r=rS(rL,e.__scopePopover),s=i.useRef(null),a=(0,y.s)(t,s),o=i.useRef(!1);return i.useEffect(()=>{let e=s.current;if(e)return(0,ry.Eq)(e)},[]),(0,n.jsx)(rb.A,{as:rI,allowPinchZoom:!0,children:(0,n.jsx)(rq,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:tB(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:tB(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;o.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:tB(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),rz=i.forwardRef((e,t)=>{let r=rS(rL,e.__scopePopover),s=i.useRef(!1),a=i.useRef(!1);return(0,n.jsx)(rq,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(s.current||r.triggerRef.current?.focus(),t.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,"pointerdown"===t.detail.originalEvent.type&&(a.current=!0));let n=t.target;r.triggerRef.current?.contains(n)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&a.current&&t.preventDefault()}})}),rq=i.forwardRef((e,t)=>{let{__scopePopover:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:m,...h}=e,p=rS(rL,r),x=rk(r);return i.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??tX()),document.body.insertAdjacentElement("beforeend",e[1]??tX()),tY++,()=>{1===tY&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),tY--}},[]),(0,n.jsx)(t1,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:(0,n.jsx)(tJ,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:d,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:(0,n.jsx)(rd,{"data-state":rU(p.open),role:"dialog",id:p.contentId,...x,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),r_="PopoverClose";function rU(e){return e?"open":"closed"}function rB({...e}){return(0,n.jsx)(rE,{"data-slot":"popover",...e})}function rH({className:e,align:t="center",sideOffset:r=4,...s}){return(0,n.jsx)(rM,{children:(0,n.jsx)(rF,{"data-slot":"popover-content",align:t,sideOffset:r,className:(0,d.cn)("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-md border p-4 shadow-md outline-hidden",e),...s})})}i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=rS(r_,r);return(0,n.jsx)(tH.button,{type:"button",...s,ref:t,onClick:tB(e.onClick,()=>a.onOpenChange(!1))})}).displayName=r_,i.forwardRef((e,t)=>{let{__scopePopover:r,...s}=e,a=rk(r);return(0,n.jsx)(rm,{...a,...s,ref:t})}).displayName="PopoverArrow";let rW=({children:e,...t})=>(0,n.jsx)(rB,{...t,children:e}),rV=function({...e}){return(0,n.jsx)(rR,{"data-slot":"popover-trigger",...e})},rJ=i.forwardRef(({className:e,align:t="end",sideOffset:r=4,...s},a)=>(0,n.jsx)(rH,{ref:a,align:t,sideOffset:r,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s}));rJ.displayName="DropdownMenuContent";let rG=i.forwardRef(({className:e,disabled:t,...r},s)=>(0,n.jsx)("div",{ref:s,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pointer-events-none opacity-50",!t&&"hover:bg-accent hover:text-accent-foreground cursor-pointer",e),...r}));rG.displayName="DropdownMenuItem";let rK=i.forwardRef(({className:e,...t},r)=>(0,n.jsx)("div",{ref:r,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));function rY({currentModel:e,isLoading:t,models:r,onModelChange:s,className:a}){return(0,n.jsxs)(rW,{children:[(0,n.jsx)(rV,{asChild:!0,children:(0,n.jsxs)(e$.$,{variant:"ghost",size:"sm",className:(0,d.cn)("h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full",a),disabled:t,children:[(0,n.jsx)(eY,{className:"h-3 w-3 mr-1.5"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:t?"...":e?.name??"Select model"}),(0,n.jsx)(h.A,{className:"h-3 w-3 ml-1"})]})}),(0,n.jsx)(rJ,{align:"end",children:r.map(e=>(0,n.jsxs)(rG,{onClick:()=>s(e),children:[(0,n.jsx)(eY,{className:"h-4 w-4 mr-2"}),e.name]},e.model))})]})}rK.displayName="DropdownMenuSeparator";let rX=(0,e_.A)("paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);function rZ({onImageAttach:e,onPdfAttach:t,onAudioAttach:r,className:s}){return(0,n.jsxs)(rW,{children:[(0,n.jsx)(rV,{asChild:!0,children:(0,n.jsxs)(e$.$,{variant:"ghost",size:"sm",className:`h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full ${s||""}`,"aria-label":"Attach File",children:[(0,n.jsx)(rX,{className:"h-3 w-3 mr-1.5"}),"Attach"]})}),(0,n.jsxs)(rJ,{side:"top",align:"start",children:[(0,n.jsxs)(rG,{onClick:e,children:[(0,n.jsx)(rX,{className:"h-4 w-4 mr-2"})," Image"]}),(0,n.jsxs)(rG,{onClick:t,children:[(0,n.jsx)(e4,{className:"h-4 w-4 mr-2"})," PDF"]}),(0,n.jsxs)(rG,{onClick:r,children:[(0,n.jsx)(e2,{className:"h-4 w-4 mr-2"})," Audio file"]})]})]})}let rQ=(0,e_.A)("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),r0=(0,e_.A)("mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);function r1({isRecording:e,onToggleRecording:t,className:r}){return(0,n.jsxs)(e$.$,{variant:"ghost",size:"sm",onClick:t,className:`h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full ${r||""}`,"aria-label":e?"Stop recording":"Record audio",children:[e?(0,n.jsx)(rQ,{className:"h-3 w-3 mr-1.5 text-red-500"}):(0,n.jsx)(r0,{className:"h-3 w-3 mr-1.5"}),e?"Stop":"Record"]})}let r2=(0,e_.A)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),r4=(0,e_.A)("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);var r3=r(3018);function r5({onSend:e,isSending:t,variant:r="chat"}){let[s,a]=(0,i.useState)(""),o=(0,i.useRef)(null),[d,c]=(0,i.useState)(null),[u,m]=(0,i.useState)(null),h=(0,i.useRef)(null),x=(0,i.useRef)(null),f=(0,i.useRef)(null),g=function(){let[e,t]=(0,i.useState)(!1);return e}(),[v,y]=(0,i.useState)(!1),b=(0,i.useRef)(null),{currentSessionId:j,isStreaming:w,setStreaming:N}=(0,l.v)(),[k,C]=(0,i.useState)(null),[S,E]=(0,i.useState)(!1),[A,T]=(0,i.useState)(null),[R,P]=(0,i.useState)(null),O=e=>{P(e),setTimeout(()=>P(null),5e3)},D=()=>{let t=s.trim();(t||d||u)&&(e(t,d??void 0,u??void 0),a(""),c(null),m(null))},M=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),D())},L=e=>{try{return btoa(unescape(encodeURIComponent(e)))}catch{return btoa(e)}},F=e=>{let t=e.clipboardData.getData("text/plain");if(t&&!(t.length<=2e4))if(e.preventDefault(),window.confirm("Large text detected. Attach as a file instead of inflating the input?\n(OK = attach as file, Cancel = paste truncated preview)"))m({base64:L(t),mimeType:"text/plain",filename:"pasted.txt"});else{let e=t.slice(0,2e4);a(t=>t+e)}},I=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e);b.current=t;let r=[];t.ondataavailable=e=>{e.data.size>0&&r.push(e.data)},t.onstop=()=>{let s=new Blob(r,{type:t.mimeType}),a=new FileReader;a.onloadend=()=>{try{let e=a.result,r=e.indexOf(","),s=e.substring(r+1),n=t.mimeType||"audio/webm",i={"audio/mp3":"mp3","audio/mpeg":"mp3","audio/wav":"wav","audio/x-wav":"wav","audio/wave":"wav","audio/webm":"webm","audio/ogg":"ogg","audio/m4a":"m4a","audio/aac":"aac"}[n]||n.split("/")[1]||"webm";m({base64:s,mimeType:n,filename:`recording.${i}`})}catch(e){O("Failed to process audio recording. Please try again."),m(null)}},a.readAsDataURL(s),e.getTracks().forEach(e=>e.stop())},t.start(),y(!0)}catch(e){O("Failed to start audio recording. Please check microphone permissions.")}},$=async e=>{E(!0),T(null);try{let t={provider:e.provider,model:e.model};j&&(t.sessionId=j);let r=await fetch("/api/llm/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await r.json();if(r.ok)C(e),T(null);else{let e="Failed to switch model";if(s.issues&&s.issues.length>0){let t=s.issues.filter(e=>"error"===e.severity);t.length>0&&(e=t[0].message)}else s.error&&(e=s.error);console.error("Failed to switch model:",e),T(e),setTimeout(()=>T(null),1e4)}}catch(e){console.error("Network error while switching model:",e),T("Network error while switching model"),setTimeout(()=>T(null),1e4)}finally{E(!1)}};return s.length,(0,n.jsxs)("div",{id:"input-area",className:"flex flex-col gap-2 w-full",children:[A&&(0,n.jsxs)(r3.Fc,{variant:"destructive",className:"mb-2",children:[(0,n.jsx)(r2,{className:"h-4 w-4"}),(0,n.jsxs)(r3.TN,{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{children:A}),(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>T(null),className:"h-auto p-1 ml-2",children:(0,n.jsx)(p.A,{className:"h-3 w-3"})})]})]}),R&&(0,n.jsxs)(r3.Fc,{variant:"destructive",className:"mb-2",children:[(0,n.jsx)(r2,{className:"h-4 w-4"}),(0,n.jsxs)(r3.TN,{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{children:R}),(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>P(null),className:"h-auto p-1 ml-2",children:(0,n.jsx)(p.A,{className:"h-3 w-3"})})]})]}),(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsx)("form",{onSubmit:e=>{e.preventDefault(),D()},children:(0,n.jsxs)(tk,{children:[(d||u)&&(0,n.jsx)("div",{className:"px-4 pt-4",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,n.jsxs)("div",{className:"relative w-fit border border-border rounded-lg p-1 bg-muted/50 group",children:[(0,n.jsx)("img",{src:`data:${d.mimeType};base64,${d.base64}`,alt:"preview",className:"h-12 w-auto rounded-md"}),(0,n.jsx)(e$.$,{variant:"destructive",size:"icon",onClick:()=>c(null),className:"absolute -top-1 -right-1 h-4 w-4 rounded-full bg-destructive text-destructive-foreground opacity-100 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove image",children:(0,n.jsx)(p.A,{className:"h-2 w-2"})})]}),u&&(0,n.jsxs)("div",{className:"relative w-fit border border-border rounded-lg p-2 bg-muted/50 flex items-center gap-2 group",children:[u.mimeType.startsWith("audio")?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e2,{className:"h-4 w-4"}),(0,n.jsx)("audio",{controls:!0,src:`data:${u.mimeType};base64,${u.base64}`,className:"h-8"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e4,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"text-xs font-medium max-w-[160px] truncate",children:u.filename||"attachment"})]}),(0,n.jsx)(e$.$,{variant:"destructive",size:"icon",onClick:()=>m(null),className:"absolute -top-1 -right-1 h-4 w-4 rounded-full bg-destructive text-destructive-foreground opacity-100 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove attachment",children:(0,n.jsx)(p.A,{className:"h-2 w-2"})})]})]})}),(0,n.jsx)("div",{className:"flex-auto overflow-y-auto",children:g?(0,n.jsx)(tN,{ref:o,value:s,onChange:e=>a(e.target.value),onKeyDown:M,onPaste:F,placeholder:"Ask Dexto anything...",minRows:1,maxRows:8,className:"w-full px-4 pt-4 pb-1 text-lg leading-7 placeholder:text-lg bg-transparent border-none resize-none outline-none ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none max-h-full"}):(0,n.jsx)("textarea",{ref:o,rows:1,value:s,onChange:e=>a(e.target.value),onKeyDown:M,onPaste:F,placeholder:"Ask Dexto anything...",className:"w-full px-4 pt-4 pb-1 text-lg leading-7 placeholder:text-lg bg-transparent border-none resize-none outline-none ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none"})}),(0,n.jsx)(tC,{leftButtons:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(rZ,{onImageAttach:()=>h.current?.click(),onPdfAttach:()=>x.current?.click(),onAudioAttach:()=>f.current?.click()}),(0,n.jsx)(r1,{isRecording:v,onToggleRecording:v?()=>{b.current?.stop(),y(!1)}:I})]}),rightButtons:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(t_,{isStreaming:w,onStreamingChange:N}),(0,n.jsx)(rY,{currentModel:k,isLoading:S,models:[{name:"Claude 4 Sonnet",provider:"anthropic",model:"claude-4-sonnet-20250514"},{name:"GPT-4o",provider:"openai",model:"gpt-4o"},{name:"GPT-4.1 Mini",provider:"openai",model:"gpt-4.1-mini"},{name:"Gemini 2.5 Pro",provider:"google",model:"gemini-2.5-pro"}],onModelChange:$}),(0,n.jsx)(e$.$,{type:"submit",disabled:!s.trim()&&!d&&!u||t,className:"h-10 w-10 p-0 rounded-full shadow-sm hover:shadow-md transition-shadow","aria-label":"Send message",children:t?(0,n.jsx)(e1,{className:"h-4 w-4 animate-spin"}):(0,n.jsx)(r4,{className:"h-4 w-4"})})]})})]})}),(0,n.jsx)("input",{ref:h,type:"file",id:"image-upload",accept:"image/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){O("Image file too large. Maximum size is 64MB."),e.target.value="";return}if(!t.type.startsWith("image/")){O("Please select a valid image file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(",");if(-1===s)throw Error("Invalid Data URL format");let a=e.substring(0,s),n=e.substring(s+1),i=a.match(/data:(.*);base64/),o=i?i[1]:t.type;if(!o)throw Error("Could not determine MIME type");c({base64:n,mimeType:o}),P(null)}catch(e){O("Failed to process image file. Please try again."),c(null)}},r.onerror=e=>{O("Failed to read image file. Please try again."),c(null)},r.readAsDataURL(t),e.target.value=""}}),(0,n.jsx)("input",{ref:x,type:"file",id:"pdf-upload",accept:"application/pdf",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){O("PDF file too large. Maximum size is 64MB."),e.target.value="";return}if("application/pdf"!==t.type){O("Please select a valid PDF file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(","),a=e.substring(s+1);m({base64:a,mimeType:"application/pdf",filename:t.name}),P(null)}catch(e){O("Failed to process PDF file. Please try again."),m(null)}},r.onerror=e=>{O("Failed to read PDF file. Please try again."),m(null)},r.readAsDataURL(t),e.target.value=""}}),(0,n.jsx)("input",{ref:f,type:"file",id:"audio-upload",accept:"audio/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];if(!t)return;if(t.size>0x4000000){O("Audio file too large. Maximum size is 64MB."),e.target.value="";return}if(!t.type.startsWith("audio/")){O("Please select a valid audio file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,s=e.indexOf(","),a=e.substring(s+1);m({base64:a,mimeType:t.type,filename:t.name}),P(null)}catch(e){O("Failed to process audio file. Please try again."),m(null)}},r.onerror=e=>{O("Failed to read audio file. Please try again."),m(null)},r.readAsDataURL(t),e.target.value=""}})]})]})}var r8=r(3737);class r6{constructor(){this.registryEntries=[],this.isInitialized=!1}static getInstance(){return r6.instance||(r6.instance=new r6),r6.instance}async initialize(){this.isInitialized||(this.registryEntries=this.getBuiltinEntries(),await this.loadCustomEntries(),this.isInitialized=!0)}async getEntries(e){await this.initialize();let t=[...this.registryEntries];if(e?.category&&(t=t.filter(t=>t.category===e.category)),e?.tags?.length&&(t=t.filter(t=>e.tags.some(e=>t.tags.includes(e)))),e?.search){let r=e.search.toLowerCase();t=t.filter(e=>e.name.toLowerCase().includes(r)||e.description.toLowerCase().includes(r)||e.tags.some(e=>e.toLowerCase().includes(r)))}return e?.installed!==void 0&&(t=t.filter(t=>t.isInstalled===e.installed)),e?.official!==void 0&&(t=t.filter(t=>t.isOfficial===e.official)),t.sort((e,t)=>e.isInstalled!==t.isInstalled?e.isInstalled?-1:1:e.isOfficial!==t.isOfficial?e.isOfficial?-1:1:e.popularity!==t.popularity?(t.popularity||0)-(e.popularity||0):e.name.localeCompare(t.name))}async addCustomEntry(e){let t={...e,id:`custom-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,isOfficial:!1,lastUpdated:new Date};return this.registryEntries.push(t),await this.saveCustomEntries(),t}async updateEntry(e,t){let r=this.registryEntries.findIndex(t=>t.id===e);return -1!==r&&(this.registryEntries[r]={...this.registryEntries[r],...t,lastUpdated:new Date},await this.saveCustomEntries(),!0)}async setInstalled(e,t){return this.updateEntry(e,{isInstalled:t})}async getServerConfig(e){return await this.initialize(),this.registryEntries.find(t=>t.id===e)||null}getBuiltinEntries(){return[{id:"filesystem",name:"File System",description:"Secure file operations with configurable access controls for reading and writing files",category:"productivity",icon:"\uD83D\uDCC1",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path/to/allowed/directory"],timeout:3e4},tags:["file","directory","filesystem","io"],isOfficial:!0,isInstalled:!1,popularity:95,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"github",name:"GitHub",description:"Repository management, file operations, search repositories, manage issues and pull requests",category:"development",icon:"\uD83D\uDC19",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:""},timeout:3e4},tags:["git","repository","version-control","issues","pr"],isOfficial:!0,isInstalled:!1,popularity:92,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"GitHub",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"brave-search",name:"Brave Search",description:"Web and local search using Brave's Search API for real-time information retrieval",category:"research",icon:"\uD83D\uDD0D",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"],env:{BRAVE_SEARCH_API_KEY:""},timeout:3e4},tags:["search","web","research","information"],isOfficial:!0,isInstalled:!1,popularity:88,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"sqlite",name:"SQLite",description:"Database interaction and business intelligence capabilities for SQLite databases",category:"data",icon:"\uD83D\uDDC4️",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite","/path/to/database.db"],timeout:3e4},tags:["database","sql","sqlite","query"],isOfficial:!0,isInstalled:!1,popularity:85,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"puppeteer",name:"Puppeteer",description:"Browser automation and web scraping with Puppeteer for automated testing and data extraction",category:"research",icon:"\uD83C\uDFAD",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"],timeout:3e4},tags:["browser","automation","scraping","web","testing"],isOfficial:!0,isInstalled:!1,popularity:80,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"postgresql",name:"PostgreSQL",description:"Read-only database access with schema inspection for PostgreSQL databases",category:"data",icon:"\uD83D\uDC18",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres","postgresql://localhost/mydb"],timeout:3e4},tags:["database","sql","postgresql","postgres","query"],isOfficial:!0,isInstalled:!1,popularity:83,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"slack",name:"Slack",description:"Channel management and messaging capabilities for Slack workspaces",category:"communication",icon:"\uD83D\uDCAC",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-slack"],env:{SLACK_BOT_TOKEN:""},timeout:3e4},tags:["slack","messaging","team","communication","channels"],isOfficial:!0,isInstalled:!1,popularity:75,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"fetch",name:"Fetch",description:"Web content fetching and conversion for efficient LLM usage",category:"research",icon:"\uD83C\uDF10",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"],timeout:3e4},tags:["web","fetch","content","http","download"],isOfficial:!0,isInstalled:!1,popularity:78,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"http-example",name:"HTTP MCP Server",description:"Example HTTP-based MCP server for API integrations",category:"development",icon:"\uD83C\uDF10",config:{type:"http",baseUrl:"http://localhost:8080",headers:{Authorization:"Bearer your-api-key","Content-Type":"application/json"},timeout:3e4},tags:["http","api","integration","web"],isOfficial:!1,isInstalled:!1,popularity:70,lastUpdated:new Date,requirements:{platform:"all"},author:"Community",version:"1.0.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"memory",name:"Memory",description:"Knowledge graph-based persistent memory system for storing and retrieving information",category:"productivity",icon:"\uD83E\uDDE0",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"],timeout:3e4},tags:["memory","knowledge","graph","persistence","storage"],isOfficial:!0,isInstalled:!1,popularity:87,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"google-drive",name:"Google Drive",description:"File access and search capabilities for Google Drive integration",category:"productivity",icon:"\uD83D\uDCCB",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-gdrive"],env:{GOOGLE_APPLICATION_CREDENTIALS:""},timeout:3e4},tags:["google","drive","files","cloud","storage"],isOfficial:!0,isInstalled:!1,popularity:82,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"git",name:"Git",description:"Tools to read, search, and manipulate Git repositories",category:"development",icon:"\uD83C\uDF3F",config:{type:"stdio",command:"uvx",args:["mcp-server-git","--repository","/path/to/git/repo"],timeout:3e4},tags:["git","version-control","repository","commits","diff"],isOfficial:!0,isInstalled:!1,popularity:90,lastUpdated:new Date,requirements:{platform:"all",python:">=3.8"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"}]}async saveCustomEntries(){this.registryEntries.filter(e=>!e.isOfficial)}async loadCustomEntries(){}}let r7=r6.getInstance();var r9=r(7826),se=r(8988),st=r(9390),sr=r(5616),ss=r(3974),sa=r(6474);let sn=(0,e_.A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var si=r(3563);function so({isOpen:e,onClose:t,onAddServer:r}){let[s,a]=(0,i.useState)({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(""),[u,m]=(0,i.useState)(""),[h,p]=(0,i.useState)([]),[x,f]=(0,i.useState)(""),[g,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(!1),j=async e=>{e.preventDefault(),v(null),b(!0);try{let e=o.split(",").map(e=>e.trim()).filter(Boolean),n=d.split(",").map(e=>e.trim()).filter(Boolean),i=x.split(",").map(e=>e.trim()).filter(Boolean),g={};if(u.trim())for(let e of u.split("\n")){let t=e.trim();if(!t)continue;let r=t.indexOf("=");if(r>0){let e=t.substring(0,r).trim(),s=t.substring(r+1).trim();e&&(g[e]=s)}}let v={};if(h.forEach(e=>{e.key.trim()&&e.value.trim()&&(v[e.key.trim()]=e.value.trim())}),!s.name.trim())throw Error("Server name is required");if(!s.description.trim())throw Error("Description is required");if("stdio"===s.config.type&&!s.config.command.trim())throw Error("Command is required for stdio servers");if("sse"===s.config.type&&!s.config.url.trim())throw Error("URL is required for SSE servers");if("http"===s.config.type&&!s.config.url.trim())throw Error("URL is required for HTTP servers");let y={...s,config:{...s.config,args:e,env:g,headers:v},tags:n,requirements:{...s.requirements,dependencies:i}};await r(y),t(),a({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),l(""),c(""),m(""),p([]),f("")}catch(e){v(e.message||"Failed to add custom server")}finally{b(!1)}},w=e=>{let{name:t,value:r}=e.target;a(e=>({...e,config:{...e.config,[t]:r}}))};return(0,n.jsx)(r9.lG,{open:e,onOpenChange:t,children:(0,n.jsxs)(r9.Cf,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,n.jsxs)(r9.c7,{children:[(0,n.jsxs)(r9.L3,{className:"flex items-center gap-2",children:[(0,n.jsx)(sa.A,{className:"h-5 w-5"}),"Add Custom Server to Registry"]}),(0,n.jsx)(r9.rr,{children:"Add your own custom MCP server configuration to the registry for easy reuse."})]}),(0,n.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[g&&(0,n.jsx)(r3.Fc,{variant:"destructive",children:(0,n.jsx)(r3.TN,{children:g})}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"name",children:"Server Name *"}),(0,n.jsx)(se.p,{id:"name",value:s.name,onChange:e=>a(t=>({...t,name:e.target.value})),placeholder:"My Custom Server",required:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"category",children:"Category"}),(0,n.jsxs)(ss.l6,{value:s.category,onValueChange:e=>a(t=>({...t,category:e})),children:[(0,n.jsx)(ss.bq,{id:"category",children:(0,n.jsx)(ss.yv,{})}),(0,n.jsx)(ss.gC,{children:[{value:"productivity",label:"Productivity"},{value:"development",label:"Development"},{value:"research",label:"Research"},{value:"creative",label:"Creative"},{value:"data",label:"Data"},{value:"communication",label:"Communication"},{value:"custom",label:"Custom"}].map(e=>(0,n.jsx)(ss.eb,{value:e.value,children:e.label},e.value))})]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"description",children:"Description *"}),(0,n.jsx)(sr.T,{id:"description",value:s.description,onChange:e=>a(t=>({...t,description:e.target.value})),placeholder:"Describe what this server does...",required:!0})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Server Configuration"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"serverType",children:"Server Type"}),(0,n.jsxs)(ss.l6,{value:s.config.type,onValueChange:e=>a(t=>({...t,config:{...t.config,type:e}})),children:[(0,n.jsx)(ss.bq,{id:"serverType",children:(0,n.jsx)(ss.yv,{})}),(0,n.jsxs)(ss.gC,{children:[(0,n.jsx)(ss.eb,{value:"stdio",children:"stdio"}),(0,n.jsx)(ss.eb,{value:"sse",children:"sse"}),(0,n.jsx)(ss.eb,{value:"http",children:"http"})]})]})]}),"stdio"===s.config.type?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"command",children:"Command *"}),(0,n.jsx)(se.p,{id:"command",value:s.config.command,onChange:e=>a(t=>({...t,config:{...t.config,command:e.target.value}})),placeholder:"npx or python",required:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"args",children:"Arguments"}),(0,n.jsx)(se.p,{id:"args",value:o,onChange:e=>l(e.target.value),placeholder:"Comma-separated: -m,script.py,--port,8080"})]})]}):"sse"===s.config.type?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(st.J,{htmlFor:"url",children:"URL *"}),(0,n.jsx)(se.p,{id:"url",name:"url",value:s.config.url,onChange:w,placeholder:"http://localhost:8080/sse",required:!0})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(st.J,{htmlFor:"url",children:"URL *"}),(0,n.jsx)(se.p,{id:"url",name:"url",value:s.config.url,onChange:w,placeholder:"https://example.com",required:!0})]}),"stdio"===s.config.type&&(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"env",children:"Environment Variables"}),(0,n.jsx)(sr.T,{id:"env",value:u,onChange:e=>m(e.target.value),placeholder:`KEY1=value1
|
|
6
|
+
KEY2=value2`,rows:3})]}),("sse"===s.config.type||"http"===s.config.type)&&(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsx)(si.w,{label:"Headers",pairs:h,onChange:p,placeholder:{key:"Authorization",value:"Bearer your-token"},keyLabel:"Header",valueLabel:"Value"})})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"tags",children:"Tags"}),(0,n.jsx)(se.p,{id:"tags",value:d,onChange:e=>c(e.target.value),placeholder:"Comma-separated: file, database, api"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"icon",children:"Icon (Emoji)"}),(0,n.jsx)(se.p,{id:"icon",value:s.icon,onChange:e=>a(t=>({...t,icon:e.target.value})),placeholder:"⚡",maxLength:2})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"version",children:"Version"}),(0,n.jsx)(se.p,{id:"version",value:s.version,onChange:e=>a(t=>({...t,version:e.target.value})),placeholder:"1.0.0"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"author",children:"Author"}),(0,n.jsx)(se.p,{id:"author",value:s.author,onChange:e=>a(t=>({...t,author:e.target.value})),placeholder:"Your Name"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"homepage",children:"Homepage URL"}),(0,n.jsx)(se.p,{id:"homepage",value:s.homepage,onChange:e=>a(t=>({...t,homepage:e.target.value})),placeholder:"https://github.com/youruser/yourserver"})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Requirements"}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"platform",children:"Platform"}),(0,n.jsxs)(ss.l6,{value:s.requirements.platform,onValueChange:e=>a(t=>({...t,requirements:{...t.requirements,platform:e}})),children:[(0,n.jsx)(ss.bq,{id:"platform",children:(0,n.jsx)(ss.yv,{})}),(0,n.jsx)(ss.gC,{children:[{value:"all",label:"All Platforms"},{value:"win32",label:"Windows"},{value:"darwin",label:"macOS"},{value:"linux",label:"Linux"}].map(e=>(0,n.jsx)(ss.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"dependencies",children:"Dependencies"}),(0,n.jsx)(se.p,{id:"dependencies",value:x,onChange:e=>f(e.target.value),placeholder:"Comma-separated: package1, package2"})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"nodeVersion",children:"Node.js Version"}),(0,n.jsx)(se.p,{id:"nodeVersion",value:s.requirements.node,onChange:e=>a(t=>({...t,requirements:{...t.requirements,node:e.target.value}})),placeholder:">=16.0.0"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(st.J,{htmlFor:"pythonVersion",children:"Python Version"}),(0,n.jsx)(se.p,{id:"pythonVersion",value:s.requirements.python,onChange:e=>a(t=>({...t,requirements:{...t.requirements,python:e.target.value}})),placeholder:">=3.8"})]})]})]}),(0,n.jsxs)(r9.Es,{className:"flex gap-2",children:[(0,n.jsx)(e$.$,{type:"button",variant:"outline",onClick:t,children:"Cancel"}),(0,n.jsx)(e$.$,{type:"submit",disabled:y,children:y?"Adding...":(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(sn,{className:"h-4 w-4 mr-2"}),"Add to Registry"]})})]})]})]})})}var sl=r(9821);let sd=(0,e_.A)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),sc=(0,e_.A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function su({isOpen:e,onClose:t,onInstallServer:r}){let[s,a]=(0,i.useState)([]),[o,l]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[p,x]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[v,y]=(0,i.useState)({}),[b,j]=(0,i.useState)("");(0,i.useRef)(null);let w=(0,i.useRef)(!0);(0,i.useRef)(null),(0,i.useCallback)(async(e,t)=>{if(w.current)try{let r=await r7.getEntries({...e,search:t||void 0});w.current&&l(r)}catch(e){w.current&&h(e instanceof Error?e.message:"Failed to filter entries")}},[]);let N=async e=>{if(w.current){x(e.id);try{await r(e),await r7.setInstalled(e.id,!0),w.current&&a(t=>t.map(t=>t.id===e.id?{...t,isInstalled:!0}:t))}catch(e){w.current&&h(e instanceof Error?e.message:"Failed to install server")}finally{w.current&&x(null)}}},k=async e=>{if(w.current)try{let t=await r7.addCustomEntry(e);w.current&&(a(e=>[t,...e]),g(!1))}catch(e){w.current&&h(e instanceof Error?e.message:"Failed to add custom server")}};return(0,n.jsxs)(r9.lG,{open:e,onOpenChange:t,children:[(0,n.jsxs)(r9.Cf,{className:"max-w-2xl max-h-[70vh] overflow-hidden flex flex-col border-0 shadow-2xl",children:[(0,n.jsxs)(r9.c7,{className:"pb-6",children:[(0,n.jsxs)(r9.L3,{className:"flex items-center gap-3 text-lg",children:[(0,n.jsx)("div",{className:"p-2 rounded-lg bg-primary/10",children:(0,n.jsx)(sd,{className:"h-5 w-5 text-primary"})}),"Browse Tools"]}),(0,n.jsx)(r9.rr,{className:"text-muted-foreground",children:"Discover and add new capabilities to your AI assistant"})]}),(0,n.jsxs)("div",{className:"relative mb-6",children:[(0,n.jsx)(sc,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,n.jsx)(se.p,{placeholder:"Search for tools and integrations...",value:b,onChange:e=>j(e.target.value),className:"pl-10 h-11 border-border/50 focus:border-primary/50 bg-background/50"})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto -mx-1 px-1",children:[m&&(0,n.jsx)(r3.Fc,{variant:"destructive",className:"mb-4",children:(0,n.jsx)(r3.TN,{children:m})}),c?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,n.jsx)("div",{className:"h-8 w-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin"}),(0,n.jsx)("div",{className:"text-sm text-muted-foreground",children:"Discovering tools..."})]})}):0===o.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,n.jsx)("div",{className:"p-3 rounded-full bg-muted/50 mb-4",children:(0,n.jsx)(sd,{className:"h-8 w-8 text-muted-foreground"})}),(0,n.jsx)("div",{className:"text-muted-foreground",children:0===s.length?"No tools available in the registry":"No tools match your search"}),b&&(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>j(""),className:"mt-2",children:"Clear search"})]}):(0,n.jsx)("div",{className:"space-y-3",children:o.map((e,t)=>(0,n.jsxs)("div",{className:"group relative flex items-center justify-between p-4 border border-border/50 rounded-xl hover:border-border hover:shadow-sm bg-card/50 hover:bg-card transition-all duration-200",style:{animationDelay:`${Math.min(50*t,500)}ms`},children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"flex-shrink-0 text-2xl p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.icon||"⚡"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsx)("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors",children:e.name}),e.isOfficial&&(0,n.jsx)(sl.E,{variant:"secondary",className:"text-xs font-medium px-2",children:"Official"}),e.isInstalled&&(0,n.jsx)(sl.E,{className:"text-xs font-medium px-2 bg-green-100 text-green-800 border-green-200",children:"Added"})]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-1 leading-relaxed",children:e.description})]})]}),(0,n.jsx)(e$.$,{onClick:()=>N(e),disabled:e.isInstalled||p===e.id,size:"sm",variant:e.isInstalled?"outline":"default",className:(0,d.cn)("flex-shrink-0 ml-3 min-w-[80px] transition-all",!e.isInstalled&&"hover:shadow-sm",p===e.id&&"opacity-70"),children:p===e.id?(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"h-3 w-3 border border-current border-t-transparent rounded-full animate-spin"}),(0,n.jsx)("span",{children:"Adding..."})]}):e.isInstalled?"Added":"Add"})]},e.id))})]})]}),(0,n.jsx)(so,{isOpen:f,onClose:()=>g(!1),onAddServer:k})]})}let sm=(0,e_.A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),sh=(0,e_.A)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),sp=(0,e_.A)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);var sx=r(8233);let sf=(0,e_.A)("list-checks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]),sg="/api";function sv({isOpen:e,onClose:t,onOpenConnectModal:r,variant:s="overlay",refreshTrigger:a}){let[o,l]=(0,i.useState)([]),[c,m]=(0,i.useState)(null),[x,f]=(0,i.useState)([]),[g,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(!1),[j,w]=(0,i.useState)(null),[N,k]=(0,i.useState)(null),[C,S]=(0,i.useState)(!1),[E,A]=(0,i.useState)(null),[T,R]=(0,i.useState)(!1),P=(e,t)=>{console.error(`ServersPanel Error (${t}):`,e),"servers"===t&&w(e),"tools"===t&&k(e)},O=(0,i.useCallback)(async e=>{v(!0),w(null),l([]),m(null),f([]),k(null);try{let t=await fetch(`${sg}/mcp/servers`,e?{signal:e}:{});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to fetch servers"}));throw Error(e.message||e.error||`Server List: ${t.statusText}`)}let r=(await t.json()).servers||[];if(l(r),r.length>0){let e=r.find(e=>"connected"===e.status);e?m(e.id):r.length>0&&m(r[0].id)}else console.log("No MCP servers found or returned from API.")}catch(e){"AbortError"!==e.name&&P(e.message,"servers")}finally{e?.aborted||v(!1)}},[]),D=async e=>{R(!1);let t={type:e.config.type,command:e.config.command,args:e.config.args||[],url:e.config.url,env:e.config.env||{},headers:e.config.headers||{},timeout:e.config.timeout||3e4};try{let r=await fetch("/api/connect-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,config:t})}),s=await r.json();if(!r.ok)throw Error(s.error||`Server returned status ${r.status}`);await O()}catch(e){throw Error(e.message||"Failed to install server")}},M=async e=>{let t=o.find(t=>t.id===e);if(t&&window.confirm(`Are you sure you want to remove server "${t.name}"?`)){A(e),w(null);try{let t=await fetch(`${sg}/mcp/servers/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to remove server"}));throw Error(e.message||e.error||`Server Removal: ${t.statusText}`)}c===e&&(m(null),f([])),await O()}catch(e){P(e.message,"servers")}finally{A(null)}}};(0,i.useCallback)(async(e,t)=>{let r=o.find(t=>t.id===e);if(f([]),k(null),!r||"connected"!==r.status)return void console.warn(`Server "${r?.name||e}" is not connected or not found. Cannot fetch tools.`);b(!0);try{let s=await fetch(`${sg}/mcp/servers/${e}/tools`,t?{signal:t}:{});if(!s.ok){let e=await s.json().catch(()=>({error:`Failed to fetch tools for ${r.name}`}));throw Error(e.message||e.error||`Tool List (${r.name}): ${s.statusText}`)}let a=await s.json();t?.aborted||f(a.tools||[]),a.tools&&0!==a.tools.length||console.log(`No tools found for server "${r.name}".`)}catch(e){"AbortError"!==e.name&&P(e.message,"tools")}finally{t?.aborted||b(!1)}},[o]);let L=o.find(e=>e.id===c);if("overlay"===s&&!e)return null;let F=(0,d.cn)("fixed top-0 right-0 z-40 h-screen w-80 bg-card border-l border-border shadow-xl transition-transform transform flex flex-col",e?"translate-x-0":"translate-x-full"),I=(0,d.cn)("h-full w-full flex flex-col bg-card");return(0,n.jsxs)("aside",{className:"overlay"===s?F:I,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50 bg-card/50 backdrop-blur-sm",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Tools & Servers"}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>O(),disabled:g,className:"h-8 w-8 p-0",children:(0,n.jsx)(sm,{className:(0,d.cn)("h-3.5 w-3.5",g&&"animate-spin")})}),"overlay"===s&&(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:(0,n.jsx)(p.A,{className:"h-3.5 w-3.5"})})]})]}),(0,n.jsxs)("div",{className:"px-4 py-3 space-y-2 border-b border-border/30",children:[(0,n.jsxs)(e$.$,{onClick:r,className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,n.jsx)(sh,{className:"mr-2 h-4 w-4"}),"Connect Server"]}),(0,n.jsxs)(e$.$,{onClick:()=>R(!0),variant:"outline",className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,n.jsx)(sp,{className:"mr-2 h-4 w-4"}),"Browse Registry"]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsxs)("div",{className:"p-4 border-b border-border/30",children:[(0,n.jsx)("div",{className:"flex items-center justify-between mb-3",children:(0,n.jsxs)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:["Connected Servers (",o.length,")"]})}),g&&(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,n.jsx)(sm,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading servers..."})]})}),j&&(0,n.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,n.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,n.jsx)(u.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Connection Error"}),(0,n.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:j})]})]})}),!g&&0===o.length&&!j&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)(sd,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"No servers connected"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Connect or browse the registry"})]}),o.map(e=>(0,n.jsx)("div",{onClick:()=>m(e.id),className:(0,d.cn)("p-3 rounded-lg border cursor-pointer transition-all duration-200 mb-2 last:mb-0",c===e.id?"bg-primary/5 border-primary/20 shadow-sm":"bg-background hover:bg-muted/50 border-border/50 hover:border-border"),children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:(0,d.cn)("w-2 h-2 rounded-full flex-shrink-0","connected"===e.status?"bg-green-500":"error"===e.status?"bg-red-500":"bg-yellow-500")}),(0,n.jsx)("h4",{className:"text-sm font-medium truncate",children:e.name})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1 capitalize",children:e.status})]}),E===e.id?(0,n.jsx)(sm,{className:"h-4 w-4 animate-spin text-muted-foreground"}):(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),M(e.id)},className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",children:(0,n.jsx)(sx.A,{className:"h-3.5 w-3.5"})})]})},e.id))]}),L&&(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsx)("div",{className:"px-4 py-3 border-b border-border/30",children:(0,n.jsxs)("button",{onClick:()=>S(!C),className:"flex items-center justify-between w-full text-left",children:[(0,n.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Available Tools"}),(0,n.jsx)(h.A,{className:(0,d.cn)("h-3.5 w-3.5 transition-transform text-muted-foreground",C&&"rotate-180")})]})}),C&&(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[y&&(0,n.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,n.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,n.jsx)(sm,{className:"h-4 w-4 animate-spin text-muted-foreground"}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading tools..."})]})}),N&&(0,n.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,n.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,n.jsx)(u.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Tools Error"}),(0,n.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:N})]})]})}),!y&&0===x.length&&!N&&"connected"===L.status&&(0,n.jsxs)("div",{className:"text-center py-6",children:[(0,n.jsx)(sf,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"No tools available"})]}),"connected"!==L.status&&(0,n.jsxs)("div",{className:"text-center py-6",children:[(0,n.jsx)(u.A,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Server not connected"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Tools unavailable"})]}),x.map(e=>(0,n.jsxs)("div",{className:"p-3 rounded-lg border border-border/50 bg-background hover:bg-muted/30 transition-colors mb-2 last:mb-0",children:[(0,n.jsx)("h4",{className:"text-sm font-medium mb-1",children:e.name}),e.description&&(0,n.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-2",children:e.description}),e.inputSchema?.properties&&(0,n.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[Object.keys(e.inputSchema.properties).slice(0,3).map(e=>(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-muted text-xs font-medium",children:e},e)),Object.keys(e.inputSchema.properties).length>3&&(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",Object.keys(e.inputSchema.properties).length-3," more"]})]})]},e.name))]})]})]}),(0,n.jsx)(su,{isOpen:T,onClose:()=>R(!1),onInstallServer:D})]})}let sy=i.forwardRef(({className:e,children:t,...r},s)=>(0,n.jsx)("div",{ref:s,className:(0,d.cn)("relative overflow-auto",e),...r,children:t}));sy.displayName="ScrollArea";let sb=(0,e_.A)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),sj=(0,e_.A)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var sw=r(6349);let sN=(0,e_.A)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);function sk({isOpen:e,onClose:t,currentSessionId:r,onSessionChange:s,returnToWelcome:a,variant:o="modal",onSearchOpen:l}){let[c,m]=(0,i.useState)([]),[h,p]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),[g,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(""),[j,w]=(0,i.useState)(null),[N,k]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[E,A]=(0,i.useState)(!1);(0,i.useCallback)(async()=>{p(!0),f(null);try{let e=await fetch("/api/sessions");if(!e.ok)throw Error("Failed to fetch sessions");let t=await e.json();m(t.sessions||[])}catch(e){console.error("Error fetching sessions:",e),f(e instanceof Error?e.message:"Failed to fetch sessions")}finally{p(!1)}},[]);let T=async()=>{try{let e=await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:y.trim()||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create session")}let t=await e.json();m(e=>[...e,t.session]),b(""),v(!1),s(t.session.id)}catch(e){console.error("Error creating session:",e),f(e instanceof Error?e.message:"Failed to create session")}},R=async e=>{w(e);try{let t=await fetch(`/api/sessions/${e}`,{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete session")}m(t=>t.filter(t=>t.id!==e)),r===e&&a()}catch(e){console.error("Error deleting session:",e),f(e instanceof Error?e.message:"Failed to delete session")}finally{w(null)}},P=async()=>{if(C){A(!0);try{if(!(await fetch(`/api/sessions/${C}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to delete conversation");m(e=>e.filter(e=>e.id!==C)),r===C&&a(),k(!1),S(null)}catch(e){console.error("Error deleting conversation:",e),f(e instanceof Error?e.message:"Failed to delete conversation")}finally{A(!1)}}},O=e=>{if(!e)return"Unknown";let t=new Date(e);return t.toLocaleDateString()+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},D=e=>{if(!e)return"Unknown";let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),a=Math.floor(r/36e5),n=Math.floor(r/864e5);return s<1?"Just now":s<60?`${s}m ago`:a<24?`${a}h ago`:`${n}d ago`},M=(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-border/50",children:[(0,n.jsx)("div",{className:"flex items-center space-x-2",children:(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Chat History"})}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[l&&(0,n.jsx)(e$.$,{variant:"outline",size:"sm",onClick:l,className:"h-7 w-7 p-0",title:"Search Conversations (⌘⇧S)",children:(0,n.jsx)(sc,{className:"h-3.5 w-3.5"})}),(0,n.jsxs)(e$.$,{variant:"outline",size:"sm",onClick:()=>v(!0),className:"h-7 px-2",children:[(0,n.jsx)(sa.A,{className:"h-3.5 w-3.5 mr-1"}),(0,n.jsx)("span",{className:"text-xs",children:"New"})]})]})]}),x&&(0,n.jsx)("div",{className:"p-4",children:(0,n.jsxs)(r3.Fc,{variant:"destructive",children:[(0,n.jsx)(u.A,{className:"h-4 w-4"}),(0,n.jsx)(r3.TN,{children:x})]})}),(0,n.jsx)(sy,{className:"flex-1 p-4",children:(0,n.jsx)("div",{className:"space-y-2",children:h?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)(sm,{className:"h-6 w-6 animate-spin"})}):0===c.length?(0,n.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,n.jsx)(sb,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,n.jsx)("p",{children:"No chat history"}),(0,n.jsx)("p",{className:"text-sm",children:"Start a conversation to see it here"})]}):c.map(e=>(0,n.jsx)("div",{className:(0,d.cn)("group p-3 rounded-lg border border-border/50 bg-card hover:bg-muted/50 transition-all cursor-pointer",r===e.id&&"ring-2 ring-primary bg-primary/5"),onClick:()=>s(e.id),children:(0,n.jsxs)("div",{className:"flex items-start justify-between",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,n.jsx)("h3",{className:"font-medium text-sm truncate",children:e.id}),r===e.id&&(0,n.jsx)(sl.E,{variant:"secondary",className:"text-xs",children:"Active"})]}),(0,n.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(sj,{className:"h-3 w-3"}),(0,n.jsxs)("span",{children:[e.messageCount," messages"]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(sw.A,{className:"h-3 w-3"}),(0,n.jsx)("span",{children:D(e.lastActivity)})]})]}),e.createdAt&&(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(sN,{className:"h-3 w-3"}),(0,n.jsxs)("span",{children:["Created ",O(e.createdAt)]})]})]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[e.messageCount>0&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),S(e.id),k(!0)},className:"h-8 w-8 p-0",title:"Delete Conversation",children:(0,n.jsx)(sx.A,{className:"h-4 w-4 text-destructive"})})}),0===e.messageCount&&(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),R(e.id)},disabled:j===e.id,className:"h-8 w-8 p-0",title:"Delete Session",children:(0,n.jsx)(sx.A,{className:"h-4 w-4 text-destructive"})})]})]})},e.id))})}),(0,n.jsx)(r9.lG,{open:g,onOpenChange:v,children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-md",children:[(0,n.jsx)(r9.c7,{children:(0,n.jsx)(r9.L3,{children:"Start New Chat"})}),(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(st.J,{htmlFor:"sessionId",children:"Chat ID"}),(0,n.jsx)(se.p,{id:"sessionId",value:y,onChange:e=>b(e.target.value),placeholder:"e.g., user-123, project-alpha",className:"font-mono"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Leave empty to auto-generate a unique ID"})]})}),(0,n.jsxs)(r9.Es,{children:[(0,n.jsx)(e$.$,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),(0,n.jsx)(e$.$,{onClick:T,children:"Start Chat"})]})]})}),(0,n.jsx)(r9.lG,{open:N,onOpenChange:k,children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-md",children:[(0,n.jsxs)(r9.c7,{children:[(0,n.jsxs)(r9.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(sx.A,{className:"h-5 w-5 text-destructive"}),(0,n.jsx)("span",{children:"Delete Conversation"})]}),(0,n.jsxs)(r9.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",C&&(0,n.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,n.jsx)("span",{className:"font-mono",children:C})]})]})]}),(0,n.jsxs)(r9.Es,{children:[(0,n.jsx)(e$.$,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),(0,n.jsxs)(e$.$,{variant:"destructive",onClick:P,disabled:E,className:"flex items-center space-x-2",children:[(0,n.jsx)(sx.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:E?"Deleting...":"Delete Conversation"})]})]})]})})]});return"inline"===o?(0,n.jsx)("div",{className:"h-full",children:M}):(0,n.jsx)(r9.lG,{open:e,onOpenChange:t,children:(0,n.jsx)(r9.Cf,{className:"sm:max-w-lg h-[600px] flex flex-col p-0",children:M})})}var sC=r(3437);function sS({websocket:e}){let[t,r]=(0,i.useState)(null),[s,a]=(0,i.useState)(!1),[l,d]=(0,i.useState)(!1),c=o().useRef([]),m=(0,i.useCallback)(n=>{if(!t||!e)return;let i={type:"toolConfirmationResponse",data:{executionId:t.executionId,approved:n,rememberChoice:s,sessionId:t.sessionId}};if(console.debug("[WebUI] Sending toolConfirmationResponse",i),e.send(JSON.stringify(i)),d(!1),r(null),a(!1),c.current.length>0){let e=c.current.shift();setTimeout(()=>{r(e),d(!0)},0)}},[t,s,e]);return t?(0,n.jsx)(r9.lG,{open:l,onOpenChange:e=>{e||m(!1)},children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-[800px] max-w-[95vw] max-h-[90vh] overflow-hidden flex flex-col",children:[(0,n.jsx)(r9.c7,{children:(0,n.jsxs)(r9.L3,{className:"flex items-center gap-2",children:[(0,n.jsx)(u.A,{className:"h-5 w-5 text-yellow-500"}),"Tool Execution Confirmation"]})}),(0,n.jsxs)("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(eX,{className:"h-4 w-4 text-blue-500"}),(0,n.jsx)("span",{className:"font-medium",children:"Tool:"}),(0,n.jsx)(sl.E,{variant:"outline",children:t.toolName})]}),t.description&&(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"font-medium",children:"Description:"}),(0,n.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:t.description})]}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("span",{className:"font-medium mb-2",children:"Arguments:"}),(0,n.jsx)("div",{className:"bg-background/50 p-3 rounded-md text-xs overflow-auto max-h-80 min-h-16 text-muted-foreground border",children:(0,n.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono",children:(e=>{if(!e)return"No arguments";try{return JSON.stringify(e,null,2)}catch{return String(e)}})(t.args)})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[(0,n.jsx)(sw.A,{className:"h-4 w-4"}),(0,n.jsxs)("span",{children:["Requested at: ",t.timestamp.toLocaleString()]})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)(sC.S,{id:"remember",checked:s,onCheckedChange:e=>a(!0===e)}),(0,n.jsx)("label",{htmlFor:"remember",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Approve future executions of this tool for this session"})]}),(0,n.jsx)("div",{className:"bg-yellow-50 p-3 rounded-md",children:(0,n.jsxs)("p",{className:"text-sm text-yellow-800",children:[(0,n.jsx)("strong",{children:"Security Notice:"})," Only approve tools you trust. Tools can access your system and data according to their permissions."]})})]}),(0,n.jsxs)(r9.Es,{className:"gap-2 flex-shrink-0 mt-4 pt-4 border-t",children:[(0,n.jsx)(e$.$,{variant:"outline",onClick:()=>m(!1),className:"bg-red-50 hover:bg-red-100 text-red-700 border-red-200",children:"Deny"}),(0,n.jsx)(e$.$,{onClick:()=>m(!0),className:"bg-green-600 hover:bg-green-700",children:"Approve"})]})]})}):null}let sE=(0,e_.A)("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),sA=(0,e_.A)("message-square",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);function sT({isOpen:e,onClose:t,onNavigateToSession:r}){let[s,a]=(0,i.useState)(""),[o,l]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[p,x]=(0,i.useState)(0);(0,i.useCallback)(async e=>{if(!e.trim()){l([]),h(null);return}u(!0),h(null);try{let t=new URLSearchParams({q:e,limit:"10",offset:"0"}),r=await fetch(`/api/search/messages?${t}`);if(!r.ok){let e=await r.text();throw Error(`Search failed: ${r.status} ${e}`)}let s=await r.json();l(s.results),x(0)}catch(e){console.error("Search error:",e),l([]),h(e instanceof Error?e.message:"Search failed")}finally{u(!1)}},[]);let f=e=>{r(e.sessionId,e.messageIndex),t()},g=e=>{switch(e){case"user":return(0,n.jsx)(eK,{className:"w-4 h-4"});case"assistant":return(0,n.jsx)(eY,{className:"w-4 h-4"});case"system":return(0,n.jsx)(sE,{className:"w-4 h-4"});default:return(0,n.jsx)(sA,{className:"w-4 h-4"})}},v=e=>{switch(e){case"user":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"assistant":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"system":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}},y=(e,t)=>{if(!t)return e;let r=t.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&"),s=RegExp(`(${r})`,"gi");return e.split(s).map((e,t)=>s.test(e)?(0,n.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-800 font-medium rounded px-1",children:e},t):e)};return(0,n.jsx)(r9.lG,{open:e,onOpenChange:t,children:(0,n.jsx)(r9.Cf,{className:"max-w-2xl p-0 top-[20%] transform translate-y-0",children:(0,n.jsxs)("div",{className:"flex flex-col max-h-[70vh]",children:[(0,n.jsx)("div",{className:"p-6 pb-4",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(sc,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),(0,n.jsx)(se.p,{placeholder:"Search conversations...",value:s,onChange:e=>a(e.target.value),className:"pl-12 text-lg border-0 shadow-none focus-visible:ring-0 bg-transparent",autoFocus:!0})]})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden border-t",children:c?(0,n.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,n.jsx)(sm,{className:"h-6 w-6 animate-spin mr-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:"Searching..."})]}):m?(0,n.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)(sc,{className:"w-12 h-12 mx-auto mb-4 text-destructive opacity-50"}),(0,n.jsx)("p",{className:"text-destructive font-medium",children:"Search Error"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:m}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Try again or check your connection."})]})}):(0,n.jsx)(sy,{className:"h-full",children:(0,n.jsx)("div",{className:"p-2",children:o.length>0?(0,n.jsx)("div",{className:"space-y-1",children:o.map((e,t)=>(0,n.jsxs)("div",{className:(0,d.cn)("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-colors",t===p?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onClick:()=>f(e),children:[(0,n.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,n.jsx)(sl.E,{className:(0,d.cn)("text-xs",v(e.message.role)),children:g(e.message.role)})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsx)("span",{className:"text-sm font-medium",children:e.sessionId.length>20?`${e.sessionId.slice(0,20)}...`:e.sessionId}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:e.message.role})]}),(0,n.jsx)("div",{className:"text-sm text-muted-foreground line-clamp-2",children:y(e.context,s)})]}),(0,n.jsx)(eQ,{className:"w-4 h-4 text-muted-foreground flex-shrink-0 mt-1"})]},t))}):s?(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)(sc,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,n.jsx)("p",{className:"text-muted-foreground",children:"No messages found matching your search."}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:"Try different keywords."})]}):(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)(sc,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,n.jsx)("p",{className:"text-muted-foreground",children:"Start typing to search your conversations."}),(0,n.jsxs)("div",{className:"flex items-center justify-center gap-4 mt-4 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↑"}),(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↓"}),(0,n.jsx)("span",{children:"to navigate"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Enter"}),(0,n.jsx)("span",{children:"to select"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Esc"}),(0,n.jsx)("span",{children:"to close"})]})]})]})})})})]})})})}let sR=(0,e_.A)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),sP=(0,e_.A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),sO=(0,e_.A)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),sD=(0,e_.A)("download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]),sM=(0,e_.A)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);var sL=r(5814),sF=r.n(sL);let sI=(0,e_.A)("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),s$=(0,e_.A)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function sz(){let{theme:e,toggleTheme:t}=function(){let[e,t]=(0,i.useState)(()=>"undefined"!=typeof document?document.documentElement.classList.contains("dark")?"dark":"light":"dark");return{theme:e,toggleTheme:e=>{t(e?"dark":"light")},hasMounted:!0}}(),r="dark"===e;return(0,n.jsx)(tL,{checked:r,onCheckedChange:t,className:"w-12 h-6 bg-gray-300 dark:bg-gray-700 rounded-full relative transition-colors flex items-center px-0.5","aria-label":"Toggle dark mode",children:(0,n.jsx)(tI,{className:`
|
|
3
7
|
w-5 h-5 rounded-full shadow flex items-center justify-center
|
|
4
8
|
transition-transform transform
|
|
5
9
|
translate-x-0.5 data-[state=checked]:translate-x-[1.375rem]
|
|
6
10
|
bg-white dark:bg-gray-100
|
|
7
|
-
`,children:s?(0,n.jsx)(rX,{className:"w-3.5 h-3.5 text-gray-700"}):(0,n.jsx)(rZ,{className:"w-3.5 h-3.5 text-yellow-500"})})})}function r0(){let{messages:e,sendMessage:t,currentSessionId:r,switchSession:s,isWelcomeState:a,returnToWelcome:l,websocket:c}=(0,o.v)(),[u,m]=(0,i.useState)(!1),[p,x]=(0,i.useState)(!1),[f,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(!1),[b,w]=(0,i.useState)(!1),[N,S]=(0,i.useState)(!1),[A,P]=(0,i.useState)("dexto-config"),[R,T]=(0,i.useState)(null),[D,O]=(0,i.useState)(""),[$,L]=(0,i.useState)(!1),[F,M]=(0,i.useState)(!1),[I,z]=(0,i.useState)(!1),[q,_]=(0,i.useState)(null),[B,U]=(0,i.useState)(!1),[W,H]=(0,i.useState)(!1),V=(0,i.useCallback)(async()=>{try{let e=r?`/api/config.yaml?sessionId=${r}`:"/api/config.yaml",t=await fetch(e);if(!t.ok)throw Error("Failed to fetch configuration");let s=await t.text(),a=new Blob([s],{type:"application/x-yaml"}),n=URL.createObjectURL(a),i=document.createElement("a");i.href=n,i.download=r?`${A}-${r}.yml`:`${A}.yml`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n),S(!1),T(null)}catch(e){console.error("Export failed:",e),T(e instanceof Error?e.message:"Export failed")}},[A,r]),J=(0,i.useCallback)(async()=>{try{let e=r?`/api/config.yaml?sessionId=${r}`:"/api/config.yaml",t=await fetch(e);if(!t.ok)throw Error("Failed to fetch configuration");let s=await t.text();await navigator.clipboard.writeText(s),L(!0),setTimeout(()=>L(!1),2e3),T(null)}catch(e){console.error("Copy failed:",e),T(e instanceof Error?e.message:"Copy failed")}},[L,T,r]),G=(0,i.useCallback)(async e=>{console.log("Installing server:",e),x(!1)},[]),K=(0,i.useCallback)(async(e,r,s)=>{M(!0);try{await t(e,r,s)}catch(e){console.error("Error sending message:",e)}finally{M(!1)}},[t]),Y=(0,i.useCallback)(async e=>{try{await s(e),j(!1)}catch(e){console.error("Error switching session:",e)}},[s]),X=(0,i.useCallback)(async()=>{if(r){H(!0);try{if(!(await fetch(`/api/sessions/${r}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to delete conversation");U(!1),l()}catch(e){console.error("Error deleting conversation:",e)}finally{H(!1)}}},[r,l]),Z=[{title:"What can you do?",description:"See current capabilities",action:()=>K("What tools and capabilities do you have available right now?"),icon:"\uD83E\uDD14"},{title:"Create Snake Game",description:"Build a game and open it",action:()=>K("Create a snake game in a new directory with HTML, CSS, and JavaScript, then open it in the browser for me to play."),icon:"\uD83D\uDC0D"},{title:"Connect new tools",description:"Browse and add MCP servers",action:()=>v(!0),icon:"\uD83D\uDD27"},{title:"Test existing tools",description:"Try out connected capabilities",action:()=>K("Show me how to use one of your available tools. Pick an interesting one and demonstrate it."),icon:"\uD83E\uDDEA"}];return(0,n.jsxs)("div",{className:"flex h-screen bg-background",children:[(0,n.jsxs)("main",{className:"flex-1 flex flex-col relative",children:[(0,n.jsx)("header",{className:"shrink-0 border-b border-border/50 bg-background/80 backdrop-blur-xl",children:(0,n.jsxs)("div",{className:"flex justify-between items-center px-4 py-3",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,n.jsx)("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg border border-border/50 text-primary-foreground",children:(0,n.jsx)("img",{src:"/logo.png",alt:"Dexto",className:"w-4 h-4"})}),(0,n.jsx)("h1",{className:"text-base font-semibold tracking-tight",children:"Dexto"})]}),r&&!a&&(0,n.jsx)("div",{className:"flex items-center space-x-2",children:(0,n.jsx)(rk.E,{variant:"outline",className:"text-xs",children:r})})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(rQ,{}),(0,n.jsxs)(rc,{children:[(0,n.jsx)(ru,{asChild:!0,children:(0,n.jsxs)(E.$,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-8 px-2 text-xs transition-colors",children:[(0,n.jsx)(rS,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Search"})]})}),(0,n.jsx)(rm,{children:"Search conversations (⌘⇧S)"})]}),(0,n.jsxs)(rc,{children:[(0,n.jsx)(ru,{asChild:!0,children:(0,n.jsxs)(E.$,{variant:"ghost",size:"sm",onClick:()=>j(!y),className:(0,d.cn)("h-8 px-2 text-xs transition-colors",y&&"bg-muted"),children:[(0,n.jsx)(rM,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Sessions"})]})}),(0,n.jsx)(rm,{children:"Toggle sessions panel (⌘H)"})]}),(0,n.jsxs)(rc,{children:[(0,n.jsx)(ru,{asChild:!0,children:(0,n.jsxs)(E.$,{variant:"ghost",size:"sm",onClick:()=>v(!f),className:(0,d.cn)("h-8 px-2 text-xs transition-colors",f&&"bg-muted"),children:[(0,n.jsx)(rE,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"MCP Servers"})]})}),(0,n.jsx)(rm,{children:"Toggle tools panel (⌘J)"})]}),(0,n.jsxs)(rc,{children:[(0,n.jsx)(ru,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"ghost",size:"sm",asChild:!0,className:"h-8 px-2 text-xs",children:(0,n.jsxs)(rY(),{href:"/playground",target:"_blank",children:[(0,n.jsx)(h,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"MCP Playground"})]})})}),(0,n.jsx)(rm,{children:"Open playground (⌘L)"})]}),(0,n.jsxs)(eX,{children:[(0,n.jsx)(eZ,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:(0,n.jsx)(rV,{className:"h-3.5 w-3.5"})})}),(0,n.jsxs)(eQ,{align:"end",children:[(0,n.jsxs)(e0,{onClick:()=>x(!0),children:[(0,n.jsx)(rE,{className:"h-4 w-4 mr-2"}),"Browse MCP Registry"]}),(0,n.jsxs)(e0,{onClick:()=>S(!0),children:[(0,n.jsx)(rJ,{className:"h-4 w-4 mr-2"}),"Export Config"]}),(0,n.jsxs)(e0,{onClick:()=>z(!0),children:[(0,n.jsx)(rG,{className:"h-4 w-4 mr-2"}),"Shortcuts"]}),r&&!a&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e1,{}),(0,n.jsxs)(e0,{onClick:()=>U(!0),className:"text-destructive focus:text-destructive",children:[(0,n.jsx)(rD.A,{className:"h-4 w-4 mr-2"}),"Delete Conversation"]})]})]})]})]})]})}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[q&&(0,n.jsx)("div",{className:"absolute top-4 right-4 z-50 bg-destructive text-destructive-foreground px-4 py-2 rounded-md shadow-lg",children:q}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col",children:[a||0===e.length?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,n.jsxs)("div",{className:"w-full max-w-md space-y-8",children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("div",{className:"flex items-center justify-center w-16 h-16 mx-auto rounded-2xl bg-primary/10 text-primary",children:(0,n.jsx)("img",{src:"/logo.png",alt:"Dexto",className:"w-8 h-8"})}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h2",{className:"text-2xl font-semibold tracking-tight font-mono bg-gradient-to-r from-primary to-primary/70 bg-clip-text text-transparent text-center",children:"Hello, Welcome to Dexto!"}),(0,n.jsx)("p",{className:"text-muted-foreground text-base text-center",children:"Ask anything or connect new tools to expand what you can do."})]})]}),(0,n.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-lg mx-auto",children:Z.map((e,t)=>(0,n.jsx)("button",{onClick:e.action,className:"group p-4 text-left rounded-xl border border-border/50 bg-card hover:bg-muted/50 transition-all duration-200 hover:border-border hover:shadow-minimal",children:(0,n.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,n.jsx)("span",{className:"text-lg",children:e.icon}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h3",{className:"font-medium text-sm group-hover:text-foreground transition-colors",children:e.title}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.description})]})]})},t))}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground space-y-1 text-center",children:(0,n.jsxs)("p",{children:["\uD83D\uDCA1 Try ",(0,n.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-xs",children:"⌘K"})," for new chat, ",(0,n.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-xs",children:"⌘J"})," for tools, ",(0,n.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-xs",children:"⌘L"})," for playground, ",(0,n.jsx)("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-xs",children:"⌘/"})," for shortcuts"]})})]})}):(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,n.jsx)("div",{className:"h-full overflow-y-auto",children:(0,n.jsx)(C,{messages:e})})}),(0,n.jsx)("div",{className:"shrink-0 border-t border-border/50 bg-background/80 backdrop-blur-xl",children:(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)(rp,{onSend:K,isSending:F})})})]}),(0,n.jsx)("div",{className:(0,d.cn)("shrink-0 transition-all duration-300 ease-in-out border-l border-border/50 bg-card",y?"w-80":"w-0 overflow-hidden"),children:y&&(0,n.jsx)(r_,{isOpen:y,onClose:()=>j(!1),currentSessionId:r,onSessionChange:Y,returnToWelcome:l,variant:"inline"})}),(0,n.jsx)("div",{className:(0,d.cn)("shrink-0 transition-all duration-300 ease-in-out border-l border-border/50 bg-card",f?"w-80":"w-0 overflow-hidden"),children:f&&(0,n.jsx)(rL,{isOpen:f,onClose:()=>v(!1),onOpenConnectModal:()=>m(!0),variant:"inline"})})]}),(0,n.jsx)(rh.A,{isOpen:u,onClose:()=>m(!1)}),(0,n.jsx)(rA,{isOpen:p,onClose:()=>x(!1),onInstallServer:G}),(0,n.jsx)(rg.lG,{open:N,onOpenChange:S,children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-2xl",children:[(0,n.jsxs)(rg.c7,{children:[(0,n.jsxs)(rg.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(rJ,{className:"h-5 w-5"}),(0,n.jsx)("span",{children:"Export Configuration"})]}),(0,n.jsxs)(rg.rr,{children:["Download your tool configuration for Claude Desktop or other MCP clients",r&&(0,n.jsxs)("span",{className:"block mt-1 text-sm text-muted-foreground",children:["Including session-specific settings for: ",(0,n.jsx)("span",{className:"font-mono",children:r})]})]})]}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(ry.J,{htmlFor:"filename",children:"File name"}),(0,n.jsx)(rv.p,{id:"filename",value:A,onChange:e=>P(e.target.value),placeholder:"dexto-config",className:"font-mono"})]}),R&&(0,n.jsxs)(te.Fc,{variant:"destructive",children:[(0,n.jsx)(g.A,{className:"h-4 w-4"}),(0,n.jsx)(te.XL,{children:"Export Error"}),(0,n.jsx)(te.TN,{children:R})]}),D&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(ry.J,{children:"Configuration Preview"}),(0,n.jsx)(k.T,{value:D,readOnly:!0,className:"h-32 font-mono text-xs bg-muted/30"})]})]}),(0,n.jsxs)(rg.Es,{children:[(0,n.jsx)(E.$,{variant:"outline",onClick:J,className:"flex items-center space-x-2",children:(0,n.jsx)("span",{children:$?"Copied!":"Copy"})}),(0,n.jsxs)(E.$,{onClick:V,className:"flex items-center space-x-2",children:[(0,n.jsx)(rJ,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:"Download"})]})]})]})}),(0,n.jsx)(rg.lG,{open:B,onOpenChange:U,children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-md",children:[(0,n.jsxs)(rg.c7,{children:[(0,n.jsxs)(rg.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(rD.A,{className:"h-5 w-5 text-destructive"}),(0,n.jsx)("span",{children:"Delete Conversation"})]}),(0,n.jsxs)(rg.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",r&&(0,n.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,n.jsx)("span",{className:"font-mono",children:r})]})]})]}),(0,n.jsxs)(rg.Es,{children:[(0,n.jsx)(E.$,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),(0,n.jsxs)(E.$,{variant:"destructive",onClick:X,disabled:W,className:"flex items-center space-x-2",children:[(0,n.jsx)(rD.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:W?"Deleting...":"Delete Conversation"})]})]})]})}),(0,n.jsx)(rg.lG,{open:I,onOpenChange:z,children:(0,n.jsxs)(rg.Cf,{className:"sm:max-w-md",children:[(0,n.jsx)(rg.c7,{children:(0,n.jsxs)(rg.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(rG,{className:"h-5 w-5"}),(0,n.jsx)("span",{children:"Keyboard Shortcuts"})]})}),(0,n.jsx)("div",{className:"space-y-3",children:[{key:"⌘H",desc:"Toggle sessions panel"},{key:"⌘K",desc:"Create new session"},{key:"⌘J",desc:"Toggle tools panel"},{key:"⌘⇧S",desc:"Search conversations"},{key:"⌘L",desc:"Open playground"},{key:"⌘⇧E",desc:"Export config"},{key:"⌘/",desc:"Show shortcuts"},{key:"Esc",desc:"Close panels"}].map((e,t)=>(0,n.jsxs)("div",{className:"flex justify-between items-center py-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:e.desc}),(0,n.jsx)(rk.E,{variant:"outline",className:"font-mono text-xs",children:e.key})]},t))}),(0,n.jsx)(rg.Es,{children:(0,n.jsx)(rg.HM,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"outline",children:"Close"})})})]})})]}),(0,n.jsx)(rH,{isOpen:b,onClose:()=>w(!1),onNavigateToSession:(e,t)=>{s(e),w(!1)}}),(0,n.jsx)(rU,{websocket:c})]})}},3033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3873:e=>{"use strict";e.exports=require("path")},4610:(e,t,r)=>{Promise.resolve().then(r.bind(r,2750))},4858:(e,t,r)=>{Promise.resolve().then(r.bind(r,6730))},6730:(e,t,r)=>{"use strict";r.d(t,{default:()=>s});let s=(0,r(2907).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/runner/work/dexto/dexto/src/app/webui/components/ChatApp.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/dexto/dexto/src/app/webui/components/ChatApp.tsx","default")},6918:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>i.a,__next_app__:()=>u,pages:()=>c,routeModule:()=>m,tree:()=>d});var s=r(5239),a=r(8088),n=r(8170),i=r.n(n),l=r(893),o={};for(let e in l)0>["default","tree","pages","GlobalError","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>l[e]);r.d(t,o);let d={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,597)),"/home/runner/work/dexto/dexto/src/app/webui/app/page.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,6055))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(r.bind(r,8014)),"/home/runner/work/dexto/dexto/src/app/webui/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,7398,23)),"next/dist/client/components/not-found-error"],forbidden:[()=>Promise.resolve().then(r.t.bind(r,9999,23)),"next/dist/client/components/forbidden-error"],unauthorized:[()=>Promise.resolve().then(r.t.bind(r,5284,23)),"next/dist/client/components/unauthorized-error"],metadata:{icon:[async e=>(await Promise.resolve().then(r.bind(r,6055))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]}.children,c=["/home/runner/work/dexto/dexto/src/app/webui/app/page.tsx"],u={require:r,loadChunk:()=>Promise.resolve()},m=new s.AppPageRouteModule({definition:{kind:a.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},9121:e=>{"use strict";e.exports=require("next/dist/server/app-render/action-async-storage.external.js")},9294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},9551:e=>{"use strict";e.exports=require("url")}};var t=require("../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[447,985,54,504,624],()=>r(6918));module.exports=s})();
|
|
11
|
+
`,children:r?(0,n.jsx)(sI,{className:"w-3.5 h-3.5 text-gray-700"}):(0,n.jsx)(s$,{className:"w-3.5 h-3.5 text-yellow-500"})})})}function sq({active:e=!1}){let{voices:t,selected:r,setSelected:s}=function(){let[e,t]=(0,i.useState)(eV.getVoices()),[r,s]=(0,i.useState)(eV.getPreferredVoiceName());return{voices:e,selected:r,setSelected:e=>{eV.setPreferredVoice(e),s(eV.getPreferredVoiceName())}}}(),[a,o]=(0,i.useState)(!1);return e?(0,n.jsxs)(ss.l6,{value:r??"auto",onValueChange:e=>{s("auto"===e?null:e)},children:[(0,n.jsx)(ss.bq,{className:"h-8 w-[12rem] text-xs",children:(0,n.jsx)(ss.yv,{placeholder:"Voice"})}),(0,n.jsxs)(ss.gC,{children:[(0,n.jsx)(ss.eb,{value:"auto",children:"Auto (best available)"}),a&&t.map(e=>(0,n.jsxs)(ss.eb,{value:e.name,children:[e.name," (",e.lang,")"]},`${e.name}-${e.lang}`))]})]}):null}function s_({isOpen:e,onClose:t}){return(0,n.jsx)(r9.lG,{open:e,onOpenChange:e=>!e&&t(),children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-lg",children:[(0,n.jsxs)(r9.c7,{children:[(0,n.jsx)(r9.L3,{children:"Settings"}),(0,n.jsx)(r9.rr,{children:"Configure preferences for speech and more."})]}),(0,n.jsx)("div",{className:"space-y-6 py-2",children:(0,n.jsxs)("section",{className:"space-y-2",children:[(0,n.jsx)(st.J,{className:"text-xs uppercase text-muted-foreground",children:"Voice"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose a preferred text-to-speech voice. “Auto” selects the best available voice on your device."}),(0,n.jsx)(sq,{active:e})]})})]})})}function sU(){let{messages:e,sendMessage:t,currentSessionId:r,switchSession:s,isWelcomeState:a,returnToWelcome:c,websocket:m,activeError:p,clearError:x}=(0,l.v)(),[f,g]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[b,j]=(0,i.useState)(!1),[w,N]=(0,i.useState)(!1),[k,C]=(0,i.useState)(!1),[S,E]=(0,i.useState)(!1),[A,T]=(0,i.useState)(!1),[R,P]=(0,i.useState)("dexto-config"),[O,D]=(0,i.useState)(null),[M,L]=(0,i.useState)(""),[F,I]=(0,i.useState)(!1),[$,z]=(0,i.useState)(!1),[q,_]=(0,i.useState)(!1),[U,B]=(0,i.useState)(null),[H,W]=(0,i.useState)(!1),[V,J]=(0,i.useState)(!1),[G,K]=(0,i.useState)(""),Y=o().useRef(null),X=o().useRef(null),[Z,Q]=(0,i.useState)(!0),[ee,et]=(0,i.useState)(!1),[er,es]=(0,i.useState)(!1);o().useRef(0);let[ea,en]=(0,i.useState)(!1);o().useRef(null);let[ei,eo]=(0,i.useState)(0);(0,i.useCallback)(()=>{let e=Y.current;e&&Q(e.scrollHeight-e.scrollTop<=e.clientHeight+1)},[]);let el=(0,i.useCallback)((e="auto")=>{let t=Y.current;t&&(et(!0),t.scrollTo({top:t.scrollHeight,behavior:e}),requestAnimationFrame(()=>et(!1)))},[]),ed=(0,i.useCallback)(()=>{let e=Y.current;if(!e)return;let t=e.querySelectorAll('[data-role="user"]'),r=t[t.length-1];if(!r)return void el("auto");let s=e.getBoundingClientRect(),a=Math.max(r.getBoundingClientRect().top-s.top+e.scrollTop-16,0);et(!0),e.scrollTo({top:a,behavior:"auto"}),requestAnimationFrame(()=>et(!1))},[el]),ec=(0,i.useCallback)(async()=>{try{let e=r?`/api/config.yaml?sessionId=${r}`:"/api/config.yaml",t=await fetch(e);if(!t.ok)throw Error("Failed to fetch configuration");let s=await t.text(),a=new Blob([s],{type:"application/x-yaml"}),n=URL.createObjectURL(a),i=document.createElement("a");i.href=n,i.download=r?`${R}-${r}.yml`:`${R}.yml`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n)}catch(e){console.error("Download failed:",e),D(e instanceof Error?e.message:"Download failed")}},[R,r]),eu=(0,i.useCallback)(async()=>{try{await navigator.clipboard.writeText(M),I(!0),setTimeout(()=>I(!1),2e3)}catch(e){console.error("Copy failed:",e),D("Failed to copy to clipboard")}},[M]),em=(0,i.useCallback)(async(e,r,s)=>{z(!0),B(null);try{await t(e,r,s),setTimeout(()=>{ed(),es(!0)},0)}catch(e){console.error("Failed to send message:",e),B(e instanceof Error?e.message:"Failed to send message"),setTimeout(()=>B(null),5e3)}finally{z(!1)}},[t,ed]),eh=(0,i.useCallback)(e=>{s(e),N(!1)},[s]),ep=(0,i.useCallback)(async e=>{try{if(!(await fetch("/api/mcp/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e.id})})).ok)throw Error("Failed to install server");y(!1),eo(e=>e+1)}catch(e){console.error("Failed to install server:",e),B(e instanceof Error?e.message:"Failed to install server"),setTimeout(()=>B(null),5e3)}},[b]),ex=(0,i.useCallback)(async()=>{if(r){J(!0);try{if(!(await fetch(`/api/sessions/${r}`,{method:"DELETE"})).ok)throw Error("Failed to delete conversation");W(!1),c()}catch(e){console.error("Failed to delete conversation:",e),B(e instanceof Error?e.message:"Failed to delete conversation"),setTimeout(()=>B(null),5e3)}finally{J(!1)}}},[r,c]);(0,i.useCallback)(e=>{e.preventDefault(),G.trim()&&(em(G.trim()),K(""))},[G,em]);let ef=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!e.ok){let t=`HTTP ${e.status}: ${e.statusText}`;try{let r=await e.json();t=r.message||r.error||t}catch{}throw Error(t)}let t=await e.json();eh(t.session.id)}catch(e){console.error("Error creating new session:",e),B("Failed to create new session. Please try again."),setTimeout(()=>B(null),5e3)}},[eh]),eg=[{title:"Help me get started",description:"Show me what you can do",action:()=>em("I'm new to Dexto. Can you show me your capabilities and help me understand how to work with you effectively?"),icon:"\uD83D\uDE80"},{title:"Create Snake Game",description:"Build a game and open it",action:()=>em("Create a snake game in a new directory with HTML, CSS, and JavaScript, then open it in the browser for me to play."),icon:"\uD83D\uDC0D"},{title:"Connect new tools",description:"Browse and add MCP servers",action:()=>j(!0),icon:"\uD83D\uDD27"},{title:"Demonstrate tools",description:"Show me your capabilities",action:()=>em("Pick one of your most interesting tools and demonstrate it with a practical example. Show me what it can do."),icon:"⚡"}];return(0,n.jsxs)("div",{className:"flex h-screen bg-background",children:[(0,n.jsx)("div",{className:(0,d.cn)("shrink-0 transition-all duration-300 ease-in-out border-r border-border/50 bg-card/50 backdrop-blur-sm",w?"w-80":"w-0 overflow-hidden"),children:w&&(0,n.jsx)(sk,{isOpen:w,onClose:()=>N(!1),currentSessionId:r,onSessionChange:eh,returnToWelcome:c,variant:"inline",onSearchOpen:()=>C(!0)})}),(0,n.jsxs)("main",{className:"flex-1 flex flex-col relative",style:{"--thread-max-width":"54rem"},children:[null,(0,n.jsx)("header",{className:"shrink-0 border-b border-border/50 bg-background/95 backdrop-blur-xl shadow-sm",children:(0,n.jsxs)("div",{className:"flex justify-between items-center px-4 py-3",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>N(!w),className:(0,d.cn)("h-8 w-8 p-0 transition-colors",w&&"bg-muted"),children:(0,n.jsx)(sR,{className:"h-4 w-4"})})}),(0,n.jsx)(eI,{children:"Chat History (⌘H)"})]}),!w&&(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"outline",size:"sm",onClick:ef,className:"h-8 w-8 p-0",children:(0,n.jsx)(sa.A,{className:"h-4 w-4"})})}),(0,n.jsx)(eI,{children:"New Chat (⌘K)"})]}),(0,n.jsxs)("a",{href:"https://dexto.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-3 hover:opacity-80 transition-opacity",children:[(0,n.jsx)("img",{src:"/logo.svg",alt:"Dexto",className:"h-8 w-auto"}),(0,n.jsx)("span",{className:"sr-only",children:"Dexto"})]}),r&&!a&&(0,n.jsx)("div",{className:"flex items-center space-x-2",children:(0,n.jsx)(sl.E,{variant:"secondary",className:"text-xs bg-muted/50 border-border/30",children:r})})]}),(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(sz,{}),(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",onClick:()=>T(!0),className:"h-8 w-8 p-0","aria-label":"Open settings",children:(0,n.jsx)(sE,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(eI,{children:"Settings"})]}),(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsxs)(e$.$,{variant:"ghost",size:"sm",onClick:()=>j(!b),className:(0,d.cn)("h-8 px-2 text-sm transition-colors",b&&"bg-muted"),children:[(0,n.jsx)(eX,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Tools"})]})}),(0,n.jsx)(eI,{children:"Toggle tools panel (⌘J)"})]}),(0,n.jsxs)(eL,{children:[(0,n.jsx)(eF,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",asChild:!0,className:"h-8 px-2 text-sm",children:(0,n.jsxs)(sF(),{href:"/playground",target:"_blank",rel:"noopener noreferrer",children:[(0,n.jsx)(sP,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Playground"})]})})}),(0,n.jsx)(eI,{children:"Open MCP playground (⌘L)"})]}),(0,n.jsxs)(rW,{children:[(0,n.jsx)(rV,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:(0,n.jsx)(sO,{className:"h-3.5 w-3.5"})})}),(0,n.jsxs)(rJ,{align:"end",children:[(0,n.jsxs)(rG,{onClick:()=>y(!0),children:[(0,n.jsx)(sd,{className:"h-4 w-4 mr-2"}),"Browse MCP Registry"]}),(0,n.jsxs)(rG,{onClick:()=>E(!0),children:[(0,n.jsx)(sD,{className:"h-4 w-4 mr-2"}),"Export Config"]}),(0,n.jsxs)(rG,{onClick:()=>_(!0),children:[(0,n.jsx)(sM,{className:"h-4 w-4 mr-2"}),"Shortcuts"]}),r&&!a&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(rK,{}),(0,n.jsxs)(rG,{onClick:()=>W(!0),className:"text-destructive focus:text-destructive",children:[(0,n.jsx)(sx.A,{className:"h-4 w-4 mr-2"}),"Delete Conversation"]})]})]})]})]})]})}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[U&&(0,n.jsx)("div",{className:"absolute top-4 right-4 z-50 bg-destructive text-destructive-foreground px-4 py-2 rounded-md shadow-lg",children:U}),(0,n.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:a||0===e.length?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-6 -mt-20",children:(0,n.jsxs)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto space-y-6",children:[(0,n.jsxs)("div",{className:"text-center space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,n.jsx)("img",{src:"/logo_no_text.png",alt:"Dexto",className:"h-8 w-auto"}),(0,n.jsx)("h2",{className:"text-2xl font-bold font-mono tracking-tight bg-gradient-to-r from-primary to-primary/70 bg-clip-text text-transparent",children:"Welcome to Dexto"})]}),(0,n.jsx)("p",{className:"text-base text-muted-foreground max-w-xl mx-auto leading-relaxed",children:"Your AI assistant with powerful tools. Ask anything or connect new capabilities."})]}),(0,n.jsx)("div",{className:"flex flex-wrap justify-center gap-2 max-w-[var(--thread-max-width)] mx-auto",children:eg.map((e,t)=>(0,n.jsx)("button",{onClick:e.action,className:"group px-3 py-2 text-left rounded-full bg-primary/5 hover:bg-primary/10 transition-all duration-200 hover:shadow-sm hover:scale-105",children:(0,n.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,n.jsx)("span",{className:"text-sm",children:e.icon}),(0,n.jsx)("span",{className:"font-medium text-sm text-primary group-hover:text-primary/80 transition-colors",children:e.title})]})},t))}),(0,n.jsx)("div",{className:"max-w-[var(--thread-max-width)] mx-auto",children:(0,n.jsx)(r5,{onSend:em,isSending:$,variant:"welcome"})}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground space-y-1 text-center",children:(0,n.jsxs)("p",{children:["\uD83D\uDCA1 Try ",(0,n.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘K"})," for new chat, ",(0,n.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘J"})," for tools, ",(0,n.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘L"})," for playground, ",(0,n.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘/"})," for shortcuts"]})})]})}):(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,n.jsx)("div",{ref:Y,className:"h-full overflow-y-auto overscroll-contain relative",children:(0,n.jsxs)("div",{className:"min-h-full grid grid-rows-[1fr_auto]",children:[(0,n.jsx)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto",children:(0,n.jsx)(ts,{messages:e,activeError:p,onDismissError:x,outerRef:X})}),(0,n.jsxs)("div",{className:"sticky bottom-0 z-10 px-4 pt-2 pb-[calc(env(safe-area-inset-bottom)+16px)] bg-background relative",children:[ea&&(0,n.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 -top-3 z-20 pointer-events-none",children:(0,n.jsxs)("button",{onClick:()=>{en(!1),el("smooth")},className:"pointer-events-auto px-3 py-1.5 rounded-full shadow-sm bg-background/95 border border-border/60 backdrop-blur supports-[backdrop-filter]:bg-background/80 text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1.5",children:[(0,n.jsx)("span",{children:"Scroll to bottom"}),(0,n.jsx)(h.A,{className:"h-3.5 w-3.5"})]})}),(0,n.jsx)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto pointer-events-auto",children:(0,n.jsx)(r5,{onSend:em,isSending:$,variant:"chat"})})]})]})})})}),(0,n.jsx)("div",{className:(0,d.cn)("shrink-0 transition-all duration-300 ease-in-out border-l border-border/50 bg-card/50 backdrop-blur-sm",b?"w-80":"w-0 overflow-hidden"),children:b&&(0,n.jsx)(sv,{isOpen:b,onClose:()=>j(!1),onOpenConnectModal:()=>g(!0),variant:"inline",refreshTrigger:ei})})]}),(0,n.jsx)(r8.A,{isOpen:f,onClose:()=>g(!1),onServerConnected:()=>{eo(e=>e+1)}}),(0,n.jsx)(su,{isOpen:v,onClose:()=>y(!1),onInstallServer:ep}),(0,n.jsx)(r9.lG,{open:S,onOpenChange:E,children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-2xl",children:[(0,n.jsxs)(r9.c7,{children:[(0,n.jsxs)(r9.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(sD,{className:"h-5 w-5"}),(0,n.jsx)("span",{children:"Export Configuration"})]}),(0,n.jsxs)(r9.rr,{children:["Download your tool configuration for Claude Desktop or other MCP clients",r&&(0,n.jsxs)("span",{className:"block mt-1 text-sm text-muted-foreground",children:["Including session-specific settings for: ",(0,n.jsx)("span",{className:"font-mono",children:r})]})]})]}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(st.J,{htmlFor:"filename",children:"File name"}),(0,n.jsx)(se.p,{id:"filename",value:R,onChange:e=>P(e.target.value),placeholder:"dexto-config",className:"font-mono"})]}),O&&(0,n.jsxs)(r3.Fc,{variant:"destructive",children:[(0,n.jsx)(u.A,{className:"h-4 w-4"}),(0,n.jsx)(r3.XL,{children:"Export Error"}),(0,n.jsx)(r3.TN,{children:O})]}),M&&(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(st.J,{children:"Configuration Preview"}),(0,n.jsx)(sr.T,{value:M,readOnly:!0,className:"h-32 font-mono text-xs bg-muted/30"})]})]}),(0,n.jsxs)(r9.Es,{children:[(0,n.jsx)(e$.$,{variant:"outline",onClick:eu,className:"flex items-center space-x-2",children:(0,n.jsx)("span",{children:F?"Copied!":"Copy"})}),(0,n.jsxs)(e$.$,{onClick:ec,className:"flex items-center space-x-2",children:[(0,n.jsx)(sD,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:"Download"})]})]})]})}),(0,n.jsx)(s_,{isOpen:A,onClose:()=>T(!1)}),(0,n.jsx)(r9.lG,{open:H,onOpenChange:W,children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-md",children:[(0,n.jsxs)(r9.c7,{children:[(0,n.jsxs)(r9.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(sx.A,{className:"h-5 w-5 text-destructive"}),(0,n.jsx)("span",{children:"Delete Conversation"})]}),(0,n.jsxs)(r9.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",r&&(0,n.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,n.jsx)("span",{className:"font-mono",children:r})]})]})]}),(0,n.jsxs)(r9.Es,{children:[(0,n.jsx)(e$.$,{variant:"outline",onClick:()=>W(!1),children:"Cancel"}),(0,n.jsxs)(e$.$,{variant:"destructive",onClick:ex,disabled:V,className:"flex items-center space-x-2",children:[(0,n.jsx)(sx.A,{className:"h-4 w-4"}),(0,n.jsx)("span",{children:V?"Deleting...":"Delete Conversation"})]})]})]})}),(0,n.jsx)(r9.lG,{open:q,onOpenChange:_,children:(0,n.jsxs)(r9.Cf,{className:"sm:max-w-md",children:[(0,n.jsx)(r9.c7,{children:(0,n.jsxs)(r9.L3,{className:"flex items-center space-x-2",children:[(0,n.jsx)(sM,{className:"h-5 w-5"}),(0,n.jsx)("span",{children:"Keyboard Shortcuts"})]})}),(0,n.jsx)("div",{className:"space-y-3",children:[{key:"⌘H",desc:"Toggle chat history panel"},{key:"⌘K",desc:"Create new chat"},{key:"⌘J",desc:"Toggle tools panel"},{key:"⌘⇧S",desc:"Search conversations"},{key:"⌘L",desc:"Open MCP playground"},{key:"⌘⇧E",desc:"Export config"},{key:"⌘/",desc:"Show shortcuts"},{key:"Esc",desc:"Close panels"}].map((e,t)=>(0,n.jsxs)("div",{className:"flex justify-between items-center py-1",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground",children:e.desc}),(0,n.jsx)(sl.E,{variant:"outline",className:"font-mono text-xs",children:e.key})]},t))}),(0,n.jsx)(r9.Es,{children:(0,n.jsx)(r9.HM,{asChild:!0,children:(0,n.jsx)(e$.$,{variant:"outline",children:"Close"})})})]})})]}),(0,n.jsx)(sT,{isOpen:k,onClose:()=>C(!1),onNavigateToSession:(e,t)=>{s(e),C(!1)}}),(0,n.jsx)(sS,{websocket:m})]})}},9121:e=>{"use strict";e.exports=require("next/dist/server/app-render/action-async-storage.external.js")},9294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")}};var t=require("../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[195,80,620,176],()=>r(6918));module.exports=s})();
|