tarsk 0.4.26 → 0.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/index.js +197 -51
  2. package/dist/public/assets/account-view-BFhjAYmz.js +1 -0
  3. package/dist/public/assets/alert-dialog--tUzAWFm.js +1 -0
  4. package/dist/public/assets/api-BBbysRIh.js +1 -0
  5. package/dist/public/assets/{browser-tab-BNkQAd5u.js → browser-tab-DlzO5cMP.js} +1 -1
  6. package/dist/public/assets/chat-input-container-B_qVOGzW.js +21 -0
  7. package/dist/public/assets/context-menu-D5slxFcc.js +1 -0
  8. package/dist/public/assets/conversation-history-view-B4zHwyrw.js +1 -0
  9. package/dist/public/assets/{dialogs-config-BEsTbY1C.js → dialogs-config-DZFG2IQM.js} +3 -3
  10. package/dist/public/assets/diff-view-fOVqrHQW.js +3 -0
  11. package/dist/public/assets/explorer-tab-view-MLrWJ1Y0.js +2 -0
  12. package/dist/public/assets/{explorer-tree-KuYjR6r9.js → explorer-tree-8TyBYuC7.js} +1 -1
  13. package/dist/public/assets/{explorer-view-Cj6fyxMP.js → explorer-view-5U70mfAJ.js} +1 -1
  14. package/dist/public/assets/history-view-BR8scGnM.js +1 -0
  15. package/dist/public/assets/index-0BuHfewk.css +1 -0
  16. package/dist/public/assets/index-BTbiyooe.js +37 -0
  17. package/dist/public/assets/mcp-server-card-DupwHcKT.js +1 -0
  18. package/dist/public/assets/onboarding-Cn5RqOCa.js +1 -0
  19. package/dist/public/assets/onboarding-dialog-BXsvjU1t.js +1 -0
  20. package/dist/public/assets/{page-toolbar-DM-x5q1_.js → page-toolbar-TvYsDwUY.js} +1 -1
  21. package/dist/public/assets/{project-settings-view-wkrbmymL.js → project-settings-view-C7GW_R0m.js} +1 -1
  22. package/dist/public/assets/providers-list-view-AVt5I1WB.js +1 -0
  23. package/dist/public/assets/radio-group-Mifbn8sU.js +1 -0
  24. package/dist/public/assets/react-vendor-Bao-KYKs.js +22 -0
  25. package/dist/public/assets/resizable-DzrIos_Y.js +1 -0
  26. package/dist/public/assets/{run-stop-button-CZ62jJDn.js → run-stop-button-k1LeM0M-.js} +2 -2
  27. package/dist/public/assets/settings-instructions-view-CgfWSPmK.js +1 -0
  28. package/dist/public/assets/settings-mcp-servers-view-Becs_RxN.js +5 -0
  29. package/dist/public/assets/settings-models-view-BqdD_7GR.js +1 -0
  30. package/dist/public/assets/settings-rules-view-D7j5OHUi.js +8 -0
  31. package/dist/public/assets/settings-skills-view-aPv03-bO.js +2 -0
  32. package/dist/public/assets/settings-slash-commands-view-DLMWXQXA.js +1 -0
  33. package/dist/public/assets/settings-subagents-view-DBYzNE4W.js +2 -0
  34. package/dist/public/assets/settings-view-CccwUKkf.js +2 -0
  35. package/dist/public/assets/{side-panel-container-DVnN8vFb.js → side-panel-container-oMcXib2A.js} +2 -2
  36. package/dist/public/assets/skeleton-Bc0U0oGc.js +1 -0
  37. package/dist/public/assets/{standard-list-item-ByRgCvKd.js → standard-list-item-D2lbPXa1.js} +1 -1
  38. package/dist/public/assets/{store-Dyy2UFdD.js → store-CwvBC-YP.js} +1 -1
  39. package/dist/public/assets/{tab-context-DBrXMyNd.js → tab-context-CCvlrC0o.js} +1 -1
  40. package/dist/public/assets/{tabs-DxQZhlZp.js → tabs-Mb_cjIfE.js} +1 -1
  41. package/dist/public/assets/{terminal-panel-COYGYBV5.js → terminal-panel-GuO2XygM.js} +2 -2
  42. package/dist/public/assets/{textarea-CUYwgm5q.js → textarea-DpXOZLt8.js} +1 -1
  43. package/dist/public/assets/todos-view-C4GMi1Np.js +1 -0
  44. package/dist/public/assets/{use-toast-BqYP6xbg.js → use-toast-DqmC-mB5.js} +1 -1
  45. package/dist/public/assets/{utils-BavofGRh.js → utils-Cy2s2TEb.js} +1 -1
  46. package/dist/public/assets/whisper-wasm-Clnf-l-9.js +2 -0
  47. package/dist/public/index.html +21 -20
  48. package/dist/public/wasm/libmain-CWYJvMY5.js +3318 -0
  49. package/dist/public/wasm/libmain-D9-QM3iM.mjs +3301 -0
  50. package/package.json +4 -3
  51. package/dist/public/assets/account-view-g3bIVa-z.js +0 -1
  52. package/dist/public/assets/alert-dialog-DXEB8gMn.js +0 -1
  53. package/dist/public/assets/api-DQLZE-zX.js +0 -1
  54. package/dist/public/assets/chat-input-container-C8o4YcJZ.js +0 -1
  55. package/dist/public/assets/context-menu-CThafUml.js +0 -1
  56. package/dist/public/assets/conversation-history-view-64T6FDPb.js +0 -1
  57. package/dist/public/assets/diff-view-DgR-WEkB.js +0 -3
  58. package/dist/public/assets/explorer-tab-view-B53xe5xM.js +0 -2
  59. package/dist/public/assets/history-view-_L50vkTM.js +0 -1
  60. package/dist/public/assets/index-CAoVFXj2.css +0 -1
  61. package/dist/public/assets/index-Q5OqmtNF.js +0 -50
  62. package/dist/public/assets/onboarding-C_q_uRK0.js +0 -1
  63. package/dist/public/assets/onboarding-dialog-Cum5S2wE.js +0 -1
  64. package/dist/public/assets/provider-details-view-jc3yYdzr.js +0 -1
  65. package/dist/public/assets/providers-sidebar-B796hXzU.js +0 -1
  66. package/dist/public/assets/react-vendor-QkuITxN7.js +0 -17
  67. package/dist/public/assets/resizable-GT3fWOfA.js +0 -1
  68. package/dist/public/assets/settings-view-BbL7i34u.js +0 -2
  69. package/dist/public/assets/todos-view-DB99PEKH.js +0 -1
  70. /package/dist/public/assets/{dist-CIGnaqp2.js → dist-BI23Ei33.js} +0 -0
  71. /package/dist/public/assets/{monaco-c-HyCuEi.js → monaco-DDfTQM3i.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "description": "CLI for Tarsk - Project Threads Manager",
5
5
  "keywords": [
6
6
  "cli",
@@ -22,9 +22,10 @@
22
22
  "scripts": {
23
23
  "build:app-assets": "cd ../app && bun run build",
24
24
  "build:server": "rm -rf dist && bun scripts/bundle.ts && cp src/scaffold-templates.json dist/",
25
- "dev": "bun run build:app-assets && electrobun dev",
25
+ "dev": "bun run sync-models && bun run build:app-assets && electrobun dev",
26
+ "sync-models": "cd ../ai-data && bun run sync-models",
26
27
  "dev:watch": "bun run build:app-assets && electrobun dev --watch",
27
- "build": "bun run build:app-assets && bun run build:server && electrobun build",
28
+ "build": "bun run build:app-assets && bun run build:server && electrobun build --targets macos-arm64",
28
29
  "start": "bun run dev",
29
30
  "lint": "bunx tsgo --noEmit",
30
31
  "test": "vp test run",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Gt as n,Pn as r,Vi as i,Wn as a,Z as o,da as s,la as c,pi as l,ta as u}from"./dialogs-config-BEsTbY1C.js";import{t as d}from"./use-toast-BqYP6xbg.js";var f=e(s(),1),p=c(),m=t();function h(e){let t=(0,p.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=a(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,m.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o}function g(){let[e,t]=(0,f.useState)(null),[a,s]=(0,f.useState)(!0);(0,f.useEffect)(()=>{c();let e=()=>{document.visibilityState===`visible`&&c()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function c(){s(!0);try{t(await o())}catch(e){d({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{s(!1)}}function p(){n(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){n(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(a)return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(h,{className:`h-8 w-32 mb-2`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsx)(h,{className:`h-4 w-20`}),(0,m.jsx)(h,{className:`h-9 w-28`})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsx)(h,{className:`h-6 w-32`}),(0,m.jsx)(h,{className:`h-4 w-full`})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(h,{className:`h-4 w-24`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-28`}),(0,m.jsx)(h,{className:`h-4 w-64`})]}),(0,m.jsx)(h,{className:`h-9 w-28 shrink-0`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,m.jsx)(h,{className:`h-5 w-36`}),(0,m.jsx)(h,{className:`h-4 w-56`}),(0,m.jsx)(h,{className:`h-4 w-32`})]}),(0,m.jsx)(h,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,m.jsxs)(`div`,{className:`mb-6`,children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`flex gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(l,{className:`h-4 w-4`}),`Balance`]}),(0,m.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,m.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,m.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,m.jsx)(i,{className:`h-4 w-4`}),`Current Plan`]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,m.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_?`You have unlimited prompts with no restrictions.`:`Purchase prompts as needed. Upgrade to Pro for unlimited access.`})]})]}),!_&&(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,m.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,m.jsx)(r,{onClick:p,className:`shrink-0`,children:`Top Up Balance`})]}),(0,m.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,m.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,m.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(u,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,m.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(u,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,m.jsx)(r,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{g as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Fn as n,Wn as r,da as i,la as a}from"./dialogs-config-BEsTbY1C.js";import{at as o,ct as s,it as c,lt as l,ot as u,rt as d,st as f,ut as p}from"./react-vendor-QkuITxN7.js";var m=a(),h=e(i(),1),g=t(),_=l,v=s,y=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(f,{className:o,...a,ref:t}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});y.displayName=f.displayName;var b=h.forwardRef((e,t)=>{let n=(0,m.c)(10),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let s;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,g.jsx)(y,{}),n[3]=s):s=n[3];let c;n[4]===i?c=n[5]:(c=r(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,i),n[4]=i,n[5]=c);let l;return n[6]!==a||n[7]!==t||n[8]!==c?(l=(0,g.jsxs)(v,{children:[s,(0,g.jsx)(o,{ref:t,className:c,...a})]}),n[6]=a,n[7]=t,n[8]=c,n[9]=l):l=n[9],l});b.displayName=o.displayName;var x=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col space-y-2 text-center sm:text-left`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let t=(0,m.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-lg font-semibold`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(p,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});C.displayName=p.displayName;var w=h.forwardRef((e,t)=>{let n=(0,m.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`text-sm text-muted-foreground`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,g.jsx)(u,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});w.displayName=u.displayName;var T=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==t||i[7]!==s?(c=(0,g.jsx)(d,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=c):c=i[8],c});T.displayName=d.displayName;var E=h.forwardRef((e,t)=>{let i=(0,m.c)(9),a,o;i[0]===e?(a=i[1],o=i[2]):({className:a,...o}=e,i[0]=e,i[1]=a,i[2]=o);let s;i[3]===a?s=i[4]:(s=r(n({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=s);let l;return i[5]!==o||i[6]!==t||i[7]!==s?(l=(0,g.jsx)(c,{ref:t,className:s,...o}),i[5]=o,i[6]=t,i[7]=s,i[8]=l):l=i[8],l});E.displayName=c.displayName;export{w as a,C as c,b as i,T as n,S as o,E as r,x as s,_ as t};
@@ -1 +0,0 @@
1
- import{Cn as e,Dn as t,En as n,On as r,Sn as i,Tn as a,wn as o}from"./dialogs-config-BEsTbY1C.js";async function s(t,n){return o(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function c(t,n){return o(`api/threads/${e(t)}/ai-file?path=${encodeURIComponent(n)}`)}async function l(t,n,i){return r(`api/threads/${e(t)}/ai-file`,{path:n,content:i})}async function u(t,n){return i(`api/threads/${e(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(t,r,i){return n(`api/threads/${e(t)}/explorer`,{path:r,newName:i})}async function f(n,r,i){return t(`api/threads/${e(n)}/explorer/file`,{dirPath:r,name:i})}function p(t,n){return`${a()}/api/threads/${e(t)}/explorer/media?path=${encodeURIComponent(n)}`}async function m(n,r,i){return t(`api/threads/${e(n)}/explorer/folder`,{dirPath:r,name:i})}export{p as a,l as c,c as i,m as n,s as o,u as r,d as s,f as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$r as n,Ci as r,Cr as i,D as a,Di as o,Fi as s,Hn as c,Jr as l,Ki as u,Lr as d,Lt as f,Mt as p,Nr as m,Or as h,Pi as g,Pn as _,Q as v,Qi as y,Qr as b,Rn as x,Tn as S,Tt as C,Un as w,Vr as T,Wn as E,Y as D,Yi as O,Yt as k,Zi as A,_i as j,aa as M,bn as N,cn as P,d as F,da as I,di as L,fi as R,fn as z,gi as ee,ji as te,jt as ne,ki as re,kr as ie,kt as ae,la as B,m as oe,ni as V,nt as H,on as U,pn as W,qi as G,ta as K,tt as q,vi as se,w as J,xi as ce,xn as le,y as ue,zn as de}from"./dialogs-config-BEsTbY1C.js";import{B as fe,G as pe,H as me,J as he,K as ge,L as _e,R as ve,U as ye,V as be,X as xe,Y as Se,Z as Ce,gt as we,q as Te}from"./react-vendor-QkuITxN7.js";import{a as Ee,l as Y,s as De,t as X,u as Oe}from"./store-Dyy2UFdD.js";import{c as ke,s as Ae,u as je}from"./history-view-_L50vkTM.js";import{t as Me}from"./use-toast-BqYP6xbg.js";import{a as Ne,c as Pe,i as Fe,o as Ie,s as Le,t as Re}from"./alert-dialog-DXEB8gMn.js";import{n as ze}from"./tab-context-DBrXMyNd.js";import{r as Be}from"./onboarding-C_q_uRK0.js";var Z=B(),Q=e(I(),1),$=i();function Ve(e){let t=(0,Z.c)(30),{node:n,level:r,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u}=e,d=!!(n.children&&n.children.length>0),f,p,m;if(t[0]!==a||t[1]!==u||t[2]!==d||t[3]!==r||t[4]!==n||t[5]!==l||t[6]!==c||t[7]!==i){f=u?.has(n.id)||(c[n.id]??a);let e;t[11]!==n.id||t[12]!==l?(e=()=>l(n.id),t[11]=n.id,t[12]=l,t[13]=e):e=t[13];let o=e;p=`min-w-0`,m=i(n,{isOpen:f,level:r,toggle:o,hasChildren:d}),t[0]=a,t[1]=u,t[2]=d,t[3]=r,t[4]=n,t[5]=l,t[6]=c,t[7]=i,t[8]=f,t[9]=p,t[10]=m}else f=t[8],p=t[9],m=t[10];let h;t[14]!==s||t[15]!==a||t[16]!==u||t[17]!==d||t[18]!==o||t[19]!==f||t[20]!==r||t[21]!==n.children||t[22]!==l||t[23]!==c||t[24]!==i?(h=d&&f&&(0,$.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,$.jsx)(Ve,{node:e,level:r+1,renderNode:i,defaultOpen:a,indent:o,childContainerClassName:s,openState:c,onToggle:l,forceOpenIds:u},e.id))}),t[14]=s,t[15]=a,t[16]=u,t[17]=d,t[18]=o,t[19]=f,t[20]=r,t[21]=n.children,t[22]=l,t[23]=c,t[24]=i,t[25]=h):h=t[25];let g;return t[26]!==p||t[27]!==m||t[28]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function He(e){let t=(0,Z.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:a,forceOpenIds:o,indent:s,childContainerClassName:c,className:l}=e,u=a===void 0?!1:a,d=s===void 0?16:s,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Q.useState)(f),[h,g]=(0,Q.useState)(i);i!==h&&(g(i),m({}));let _;t[1]===o?_=t[2]:(_=o?new Set(o):void 0,t[1]=o,t[2]=_);let v=_,y;t[3]===u?y=t[4]:(y=e=>{m(t=>({...t,[e]:!(t[e]??u)}))},t[3]=u,t[4]=y);let b=y,x;t[5]===l?x=t[6]:(x=E(`min-w-0`,l),t[5]=l,t[6]=x);let S;if(t[7]!==c||t[8]!==u||t[9]!==v||t[10]!==b||t[11]!==d||t[12]!==n||t[13]!==p||t[14]!==r){let e;t[16]!==c||t[17]!==u||t[18]!==v||t[19]!==b||t[20]!==d||t[21]!==p||t[22]!==r?(e=e=>(0,$.jsx)(Ve,{node:e,level:0,renderNode:r,defaultOpen:u,indent:d,childContainerClassName:c,openState:p,onToggle:b,forceOpenIds:v},e.id),t[16]=c,t[17]=u,t[18]=v,t[19]=b,t[20]=d,t[21]=p,t[22]=r,t[23]=e):e=t[23],S=n.map(e),t[7]=c,t[8]=u,t[9]=v,t[10]=b,t[11]=d,t[12]=n,t[13]=p,t[14]=r,t[15]=S}else S=t[15];let C;return t[24]!==x||t[25]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[24]=x,t[25]=S,t[26]=C):C=t[26],C}var Ue=(0,Q.createContext)({todos:[],setTodos:()=>{}});function We(e){let t=(0,Z.c)(10),{children:n,threadId:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],t[0]=i):i=t[0];let[a,o]=(0,Q.useState)(i),s=(0,Q.useRef)(-1),c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(e,t)=>{t>=s.current&&(s.current=t,o(e))},t[1]=c):c=t[1];let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{s.current=-1,o([])},t[2]=u):u=t[2];let d;t[3]===r?d=t[4]:(d=[r],t[3]=r,t[4]=d),(0,Q.useEffect)(u,d);let f;t[5]===a?f=t[6]:(f={todos:a,setTodos:l},t[5]=a,t[6]=f);let p;return t[7]!==n||t[8]!==f?(p=(0,$.jsx)(Ue.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function Ge(e){let t=[e.result,e.content],n=[];for(let e of t)if(typeof e==`string`)n.push(e);else if(Array.isArray(e))for(let t of e)typeof t==`object`&&t&&`text`in t&&typeof t.text==`string`&&n.push(t.text);for(let e of n){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);if(e&&Array.isArray(e.todos))return e.todos}catch(e){console.error(`Failed to parse todo JSON:`,e)}}return null}function Ke(e){let t=(0,Z.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Q.useContext)(Ue),a,o;return t[0]!==r||t[1]!==i||t[2]!==n?(a=()=>{i(n,r)},o=[n,i,r],t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o):(a=t[3],o=t[4]),(0,Q.useEffect)(a,o),null}var qe=new Map,Je=new Map;function Ye(e){return qe.get(e)}function Xe(e,t){let n=Je.get(e);return n||(n=new Set,Je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Je.delete(e)}}function Ze(e){let t=Je.get(e);if(t)for(let e of t)e()}function Qe(e,t){return async function(n,r){let i=await fetch(e+`/api/browser-js/execute-tool`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({threadId:t,toolName:n,params:r})});if(!i.ok){let e=await i.text();try{let t=JSON.parse(e).error||{};e=t.details||t.message||e}catch{}return{text:null,error:`Tool `+n+` failed: `+e}}let a=await i.json();return{text:a.content&&a.content[0]?a.content[0].text:null,error:null}}}function $e(e,t,n){if(qe.has(e))return;qe.set(e,{status:`running`}),Ze(e);let r=S();(async()=>{try{let i=Qe(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;qe.set(e,{status:`success`,result:s}),Ze(e),await z(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);qe.set(e,{status:`error`,error:n}),Ze(e);try{await z(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}var et=()=>{if(typeof window>`u`)return null;let e=window.SpeechRecognition||window.webkitSpeechRecognition;return e?new e:null};function tt(){let e=(0,Z.c)(14),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)(``),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{try{let e=et();e?(e.continuous=!0,e.interimResults=!0,e.lang=`en-US`,e.onstart=()=>{n(!0),o(null),u.current=``},e.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n][0].transcript;e.results[n].isFinal?i(e=>e+r+` `):t+=r}u.current=t},e.onerror=e=>{console.error(`Speech recognition error:`,e.error),o(e.error||`An error occurred during speech recognition`)},e.onend=()=>{n(!1)},l.current=e,c(!0)):(c(!1),o(`Speech Recognition API is not supported in your browser`))}catch(e){console.error(`Failed to initialize speech recognition:`,e),c(!1),o(`Failed to initialize speech recognition`)}return()=>{l.current&&l.current.abort()}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Q.useEffect)(d,f);let p;e[2]===t?p=e[3]:(p=()=>{l.current&&!t&&l.current.start()},e[2]=t,e[3]=p);let m=p,h;e[4]===t?h=e[5]:(h=()=>{l.current&&t&&l.current.stop()},e[4]=t,e[5]=h);let g=h,_;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{i(``),u.current=``},e[6]=_):_=e[6];let v=_,y;return e[7]!==a||e[8]!==t||e[9]!==s||e[10]!==m||e[11]!==g||e[12]!==r?(y={isListening:t,transcript:r,error:a,startListening:m,stopListening:g,resetTranscript:v,isSupported:s},e[7]=a,e[8]=t,e[9]=s,e[10]=m,e[11]=g,e[12]=r,e[13]=y):y=e[13],y}function nt({initialValue:e}={}){let{state:n,dispatch:r}=Ee(),[i,a]=(0,Q.useState)(e??``),[o,s]=(0,Q.useState)(-1),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(0),[f,p]=(0,Q.useState)([]),[m,h]=(0,Q.useState)(()=>(n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0)??null),g=(0,Q.useRef)(m?.id??``),_=(0,Q.useRef)(m?.provider??``),y=(0,Q.useRef)(null),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)([]),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)([]),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)([]),[ee,te]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(``),[ie,ae]=(0,Q.useState)(0),[B,oe]=(0,Q.useState)([]),[V,H]=(0,Q.useState)([]),[U,W]=(0,Q.useState)(!1),[G,K]=(0,Q.useState)(``),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null),fe=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{g.current=m?.id??``,_.current=m?.provider??``},[m?.id,m?.provider]);let pe=(0,Q.useCallback)((e,t)=>{h(e);let i=n.selectedThreadId;if(!i||(r({type:X.SetProjectModel,threadId:i,model:e}),t?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;y.current!==a&&(y.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),N(i,{model:e.id,modelProvider:e.provider}).then(()=>{y.current===a&&(y.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{y.current===a&&(y.current=null),console.error(`Failed to save model to thread:`,e)}))},[n.selectedThreadId,r]);(0,Q.useEffect)(()=>{(async()=>{let e=n.selectedProjectId?n.projects.find(e=>e.projectId===n.selectedProjectId)?.threads.find(e=>e.threadId===n.selectedThreadId):void 0,r=n.selectedThreadId?n.projectModelSelections[n.selectedThreadId]:void 0,i=e?.model??r?.id??null,a=e?.modelProvider??r?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:n.selectedThreadId,projectId:n.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:r?{id:r.id,provider:r.provider}:void 0,savedModelId:i,savedModelProvider:a});try{let e=await t(),n=Object.values(e).flat();if(n.length===0){p([]),h(null);return}p(n);let r=i&&a?n.find(e=>e.id===i&&e.provider===a)??null:null,o=n[0],s=r??o,c=!r&&!!(i||a),l=g.current===s.id&&_.current===s.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:r?{id:r.id}:null,fallbackModel:{id:o.id},modelToSelect:{id:s.id},shouldPersistFallback:c,hasSameSelection:l,currentSelected:{id:g.current,provider:_.current}}),l||pe(s,{persist:c})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[n.selectedThreadId,n.selectedProjectId,n.projects,pe]);let me=(0,Q.useRef)(pe);(0,Q.useEffect)(()=>{me.current=pe},[pe]),(0,Q.useEffect)(()=>{n.configUpdatedAt!==0&&(async()=>{try{let e=await t(),n=Object.values(e).flat();if(n.length>0){p(n);let e=g.current,t=_.current;n.some(n=>n.id===e&&n.provider===t)||me.current(n[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[n.configUpdatedAt]),(0,Q.useEffect)(()=>{!j||P.length>0||(async()=>{try{let e=await v(),t=Object.values(e).flat();t.length>0&&(F(t),L(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[j,P.length]);let[he,ge]=(0,Q.useState)(n.selectedThreadId);return(0,Q.useEffect)(()=>{n.selectedThreadId!==he&&setTimeout(()=>{ge(n.selectedThreadId),z([]),te(!1),oe([]),H([]),W(!1),O(!1),M(!1),A(!1)},0)},[n.selectedThreadId,he]),(0,Q.useEffect)(()=>{n.selectedThreadId&&C(n.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),oe(e),H(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[n.selectedThreadId]),(0,Q.useEffect)(()=>{n.focusChatInput&&n.selectedThreadId&&!n.isStreaming&&(ce.current?.focus(),r({type:X.ClearFocusChatInput}))},[n.focusChatInput,n.selectedThreadId,n.isStreaming,r]),(0,Q.useEffect)(()=>{let e=e=>{le.current&&!le.current.contains(e.target)&&x(!1),ue.current&&!ue.current.contains(e.target)&&w(!1)};if(b||S)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[b,S]),{message:i,setMessage:a,historyIndex:o,setHistoryIndex:s,draftMessage:c,setDraftMessage:l,cursorPosition:u,setCursorPosition:d,availableModels:f,setAvailableModels:p,selectedModel:m,setSelectedModel:pe,selectedModelIdRef:g,showModelMenu:b,setShowModelMenu:x,showPlusMenu:S,setShowPlusMenu:w,attachments:T,setAttachments:E,planMode:D,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:P,setAvailableImageModels:F,selectedImageModel:I,setSelectedImageModel:L,allFiles:R,setAllFiles:z,showSuggestions:ee,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:re,selectedIndex:ie,setSelectedIndex:ae,slashCommands:B,setSlashCommands:oe,skills:V,setSkills:H,showCommandSuggestions:U,setShowCommandSuggestions:W,commandQuery:G,setCommandQuery:K,fileInputRef:se,textareaRef:ce,modelMenuRef:le,plusMenuRef:ue,suggestionsRef:de,commandSuggestionsRef:fe,handleNewChat:async()=>{if(n.selectedThreadId)try{let e=await J(n.selectedThreadId);r({type:X.ClearMessages}),console.log(`New conversation started:`,e);let t=await q(n.selectedThreadId);r({type:X.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:n,dispatch:r}}var rt=e=>{F(e)};function it(e){let t=(0,Z.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:f,historyIndex:p,setHistoryIndex:m,draftMessage:h,setDraftMessage:g,cursorPosition:_,setCursorPosition:v,showSuggestions:y,setShowSuggestions:b,suggestionQuery:x,setSuggestionQuery:S,allFiles:C,setAllFiles:w,selectedIndex:T,setSelectedIndex:E,showCommandSuggestions:D,setShowCommandSuggestions:O,commandQuery:k,setCommandQuery:A,slashCommands:j,skills:M,textareaRef:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,selectedImageModel:te}=e,ne;t[0]!==i||t[1]!==f||t[2]!==z||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==F||t[8]!==L||t[9]!==d||t[10]!==te||t[11]!==a||t[12]!==c||t[13]!==P||t[14]!==g||t[15]!==m||t[16]!==r||t[17]!==u||t[18]!==N?(ne=()=>{if(!n.trim()&&i.length===0||!c)return;let e=z?te:a;e&&(l&&(u(),d()),s?f({type:X.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:F,imageMode:z,ralphMode:L}}):o(n,e.id,i,e.provider,F,z,L),rt(n),r(``),P([]),m(-1),g(``),N.current&&(N.current.style.height=`auto`))},t[0]=i,t[1]=f,t[2]=z,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=F,t[8]=L,t[9]=d,t[10]=te,t[11]=a,t[12]=c,t[13]=P,t[14]=g,t[15]=m,t[16]=r,t[17]=u,t[18]=N,t[19]=ne):ne=t[19];let re=ne,ie;t[20]!==_||t[21]!==n||t[22]!==r||t[23]!==b||t[24]!==x||t[25]!==N?(ie=e=>{let t=n.substring(0,_-x.length-1);r(`${t}${e} ${n.substring(_)}`),b(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.length+1;N.current.setSelectionRange(n,n)}},0)},t[20]=_,t[21]=n,t[22]=r,t[23]=b,t[24]=x,t[25]=N,t[26]=ie):ie=t[26];let B=ie,V;t[27]!==k||t[28]!==_||t[29]!==n||t[30]!==ee||t[31]!==r||t[32]!==I||t[33]!==R||t[34]!==O||t[35]!==N?(V=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_);r(`${t}${e.content}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let n=t.length+e.content.length;N.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(I(!0),R(!1),ee(!1)):e.metadata.mode===`ralph`&&(R(!0),I(!1),ee(!1))},t[27]=k,t[28]=_,t[29]=n,t[30]=ee,t[31]=r,t[32]=I,t[33]=R,t[34]=O,t[35]=N,t[36]=V):V=t[36];let H=V,U;t[37]!==k||t[38]!==_||t[39]!==n||t[40]!==r||t[41]!==O||t[42]!==N?(U=e=>{let t=n.substring(0,_-k.length-1),i=n.substring(_),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),O(!1),setTimeout(()=>{if(N.current){N.current.focus();let e=t.length+a.length;N.current.setSelectionRange(e,e)}},0)},t[37]=k,t[38]=_,t[39]=n,t[40]=r,t[41]=O,t[42]=N,t[43]=U):U=t[43];let W=U,G,K,q,se;if(t[44]!==C||t[45]!==k||t[46]!==h||t[47]!==re||t[48]!==p||t[49]!==H||t[50]!==B||t[51]!==W||t[52]!==n||t[53]!==T||t[54]!==c||t[55]!==w||t[56]!==A||t[57]!==v||t[58]!==g||t[59]!==m||t[60]!==r||t[61]!==E||t[62]!==O||t[63]!==b||t[64]!==S||t[65]!==D||t[66]!==y||t[67]!==M||t[68]!==j||t[69]!==x){q=e=>{if(D){if(e.key===`ArrowDown`){e.preventDefault(),E((T+1)%G.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E((T-1+G.length)%G.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=G[T];t&&(t.type===`command`?H(t.data):W(t.data));return}if(e.key===`Escape`){O(!1);return}}if(y){let t=K.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),E((T+1)%K.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),E((T-1+K.length)%K.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),K[T]&&B(K[T]);return}if(e.key===`Escape`){b(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),re();return}let t=oe();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),p===-1?(g(n),m(t.length-1),r(t[t.length-1])):p>0&&(m(p-1),r(t[p-1]))):e.key===`ArrowDown`&&(e.preventDefault(),p>0?(m(p-1),r(t[p-1])):p===0&&(m(-1),r(h))))};let e;t[74]!==C||t[75]!==c||t[76]!==w||t[77]!==A||t[78]!==v||t[79]!==r||t[80]!==E||t[81]!==O||t[82]!==b||t[83]!==S?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),v(n);let i=t.substring(0,n),a=i.lastIndexOf(`/`);if(a!==-1){let e=a>0?i[a-1]:``;if(a===0||/\s/.test(e)){let e=i.substring(a+1);e.includes(` `)?O(!1):(A(e),O(!0),b(!1),E(0))}else O(!1)}else{O(!1);let e=i.lastIndexOf(`#`);if(e!==-1){let t=e>0?i[e-1]:``;if(e===0||/\s/.test(t)){let t=i.substring(e+1);t.includes(` `)?b(!1):(S(t),b(!0),E(0),C.length===0&&c&&ae(c).then(e=>{w(e)}).catch(st))}else b(!1)}else b(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=C,t[75]=c,t[76]=w,t[77]=A,t[78]=v,t[79]=r,t[80]=E,t[81]=O,t[82]=b,t[83]=S,t[84]=e):e=t[84],se=e;let i;if(t[85]!==k||t[86]!==M||t[87]!==j){let e;t[89]===k?e=t[90]:(e=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[89]=k,t[90]=e);let n=j.filter(e),r;t[91]===k?r=t[92]:(r=e=>e.name.toLowerCase().includes(k.toLowerCase()),t[91]=k,t[92]=r);let a=M.filter(r);i=[...n.map(ot),...a.map(at)],t[85]=k,t[86]=M,t[87]=j,t[88]=i}else i=t[88];G=i.slice(0,10),K=y?C.filter(e=>e.toLowerCase().includes(x.toLowerCase())).slice(0,10):[],t[44]=C,t[45]=k,t[46]=h,t[47]=re,t[48]=p,t[49]=H,t[50]=B,t[51]=W,t[52]=n,t[53]=T,t[54]=c,t[55]=w,t[56]=A,t[57]=v,t[58]=g,t[59]=m,t[60]=r,t[61]=E,t[62]=O,t[63]=b,t[64]=S,t[65]=D,t[66]=y,t[67]=M,t[68]=j,t[69]=x,t[70]=G,t[71]=K,t[72]=q,t[73]=se}else G=t[70],K=t[71],q=t[72],se=t[73];let J;return t[93]!==G||t[94]!==K||t[95]!==q||t[96]!==re||t[97]!==se||t[98]!==H||t[99]!==B||t[100]!==W?(J={handleSend:re,handleKeyDown:q,handleTextareaInput:se,insertFileReference:B,insertCommand:H,insertSkill:W,allSuggestions:G,fileSuggestions:K},t[93]=G,t[94]=K,t[95]=q,t[96]=re,t[97]=se,t[98]=H,t[99]=B,t[100]=W,t[101]=J):J=t[101],J}function at(e){return{type:`skill`,data:e}}function ot(e){return{type:`command`,data:e}}function st(e){return console.error(`Failed to fetch files:`,e)}function ct(e){let t=(0,Z.c)(21),{visible:n,commands:r,skills:i,query:a,selectedIndex:o,onSelectCommand:s,onSelectSkill:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n)return null;let f;if(t[0]!==r||t[1]!==a||t[2]!==i){let e;t[4]===a?e=t[5]:(e=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[4]=a,t[5]=e);let n=r.filter(e),o;t[6]===a?o=t[7]:(o=e=>e.name.toLowerCase().includes(a.toLowerCase()),t[6]=a,t[7]=o);let s=i.filter(o);f=[...n.map(ut),...s.map(lt)].slice(0,10),t[0]=r,t[1]=a,t[2]=i,t[3]=f}else f=t[3];let p=f,m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(d,{className:`h-3 w-3`}),t[8]=m):m=t[8];let g=a&&` matching "${a}"`,_;t[9]===g?_=t[10]:(_=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[m,`Commands & Skills`,g]}),t[9]=g,t[10]=_);let v;t[11]!==p||t[12]!==l||t[13]!==s||t[14]!==c||t[15]!==o?(v=p.length>0?p.map((e,t)=>{let n=t===o;if(e.type===`command`){let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>s(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),r.metadata.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full flex-col gap-1 rounded-lg px-3 py-2 text-left transition-colors`,n?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(r),onMouseEnter:()=>l(t),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(h,{className:`h-3 w-3 text-amber-500`}),(0,$.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,$.jsx)(`span`,{className:`ml-auto text-[10px] rounded-full bg-amber-500/10 px-1.5 py-0.5 text-amber-700 dark:text-amber-400`,children:`skill`}),r.scope===`project`&&(0,$.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,$.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,$.jsx)(`br`,{}),(0,$.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,$.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=p,t[12]=l,t[13]=s,t[14]=c,t[15]=o,t[16]=v):v=t[16];let y;return t[17]!==u||t[18]!==_||t[19]!==v?(y=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[_,v]}),t[17]=u,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function lt(e){return{type:`skill`,data:e}}function ut(e){return{type:`command`,data:e}}function dt(e){return e.startsWith(`image/`)}function ft(e){let t=(0,Z.c)(7),{attachments:n,onRemove:r}=e;if(n.length===0)return null;let i;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=(e,t)=>(0,$.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:dt(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-foreground text-background opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(ie,{className:`h-2.5 w-2.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,$.jsx)(V,{className:`h-3 w-3`}),e.fileName,(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,$.jsx)(ie,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]})},t),t[3]=r,t[4]=e),i=n.map(e),t[0]=n,t[1]=r,t[2]=i}else i=t[2];let a;return t[5]===i?a=t[6]:(a=(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function pt(e,t){let n=e.target.files;if(!n||n.length===0)return;let r=Array.from(n),i=r.length,a=Array.from({length:i}),o=0;e.target.value=``,r.forEach((e,n)=>{let r=new FileReader;r.onload=()=>{let s=r.result.split(`,`)[1];a[n]={fileName:e.name,content:s,mimeType:e.type||`application/octet-stream`},o+=1,o===i&&t(a)},r.readAsDataURL(e)})}function mt(e){let t=(0,Z.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:a,onSelectFile:o,onMouseEnterSuggestion:c,containerRef:u}=e;if(!n||r.length===0)return null;let d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(l,{className:`h-3 w-3`}),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs font-semibold text-muted-foreground border-b border-border/50 mb-1 flex items-center gap-2`,children:[d,`Files matching "`,i,`"`]}),t[1]=i,t[2]=f);let p;if(t[3]!==r||t[4]!==c||t[5]!==o||t[6]!==a){let e;t[8]!==c||t[9]!==o||t[10]!==a?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,$.jsxs)(`button`,{type:`button`,className:E(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===a?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>o(e),onMouseEnter:()=>c(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,$.jsx)(s,{className:`h-4 w-4 text-blue-500`}):(0,$.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,$.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=c,t[9]=o,t[10]=a,t[11]=e):e=t[11],p=r.map(e),t[3]=r,t[4]=c,t[5]=o,t[6]=a,t[7]=p}else p=t[7];let m;return t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(`div`,{ref:u,className:`absolute bottom-full left-0 mb-2 w-full max-h-64 overflow-y-auto rounded-xl border border-border bg-popover p-1 shadow-lg z-50 animate-in fade-in slide-in-from-bottom-2`,children:[f,p]}),t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15],m}function ht(e){let t=(0,Z.c)(3),{provider:n}=e;if(!n)return null;let r=`https://models.tarsk.io/svg/${n}.svg`,i=`${n} logo`,a;return t[0]!==r||t[1]!==i?(a=(0,$.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0`,onError:gt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function gt(e){e.currentTarget.style.visibility=`hidden`}function _t(e){let t=(0,Z.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Q.useState(!1),s=Q.useRef(null),c,l;t[0]===a?(c=t[1],l=t[2]):(c=()=>{let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};if(a)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},l=[a],t[0]=a,t[1]=c,t[2]=l),Q.useEffect(c,l);let u;t[3]===i?u=t[4]:(u=e=>{i(e),o(!1)},t[3]=i,t[4]=u);let d=u,f;t[5]===a?f=t[6]:(f=()=>o(!a),t[5]=a,t[6]=f);let p=r?.provider,m;t[7]===p?m=t[8]:(m=(0,$.jsx)(ht,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?Be(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(A,{className:`h-3 w-3`}),t[13]=v):v=t[13];let y;t[14]!==f||t[15]!==m||t[16]!==g?(y=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,v]}),t[14]=f,t[15]=m,t[16]=g,t[17]=y):y=t[17];let b;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(b=a&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-80 max-h-80 overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:Object.entries(n.reduce(vt,{})).map(e=>{let[t,n]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[(0,$.jsx)(ht,{provider:t}),t]}),n.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`flex w-full items-center whitespace-nowrap rounded-md px-3 py-1.5 pl-8 text-sm text-popover-foreground hover:bg-accent ${e.id===r?.id?`bg-accent font-medium`:``}`,onClick:()=>d(e),children:Be(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[y,b]}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x}function vt(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var yt=[{value:`build`,label:`Build`,icon:r},{value:`plan`,label:`Plan`,icon:se},{value:`image`,label:`Image`,icon:ce},{value:`ralph`,label:`Ralph`,icon:b}];function bt(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function xt(e){let t=(0,Z.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Q.useState(!1),u=Q.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=bt(n,r,i),t[0]=r,t[1]=n,t[2]=i,t[3]=d):d=t[3];let f=d,p;t[4]===f?p=t[5]:(p=yt.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,v;t[6]===c?(g=t[7],v=t[8]):(g=()=>{let e=function(e){u.current&&!u.current.contains(e.target)&&l(!1)};if(c)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},v=[c],t[6]=c,t[7]=g,t[8]=v),Q.useEffect(g,v);let y;t[9]!==o||t[10]!==a||t[11]!==s?(y=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=y):y=t[12];let b=y,x;t[13]===c?x=t[14]:(x=()=>l(!c),t[13]=c,t[14]=x);let S;t[15]===h?S=t[16]:(S=(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=S);let C;t[17]===m.label?C=t[18]:(C=(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=C);let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(A,{className:`h-3 w-3`}),t[19]=w):w=t[19];let T;t[20]!==x||t[21]!==S||t[22]!==C?(T=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:x,children:[S,C,w]}),t[20]=x,t[21]=S,t[22]=C,t[23]=T):T=t[23];let E;t[24]!==f||t[25]!==c||t[26]!==b?(E=c&&(0,$.jsx)(`div`,{className:`absolute bottom-full right-0 mb-1 w-40 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:yt.map(e=>{let t=e.icon,n=e.value===f;return(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:()=>b(e.value),children:[(0,$.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,$.jsx)(K,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=b,t[27]=E):E=t[27];let D;return t[28]!==T||t[29]!==E?(D=(0,$.jsxs)(`div`,{className:`relative`,ref:u,children:[T,E]}),t[28]=T,t[29]=E,t[30]=D):D=t[30],D}function St(e){let t=(0,Z.c)(17),{onFileAttach:r}=e,[i,a]=Q.useState(!1),o=Q.useRef(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};if(i)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},c=[i],t[0]=i,t[1]=s,t[2]=c),Q.useEffect(s,c);let l;t[3]===r?l=t[4]:(l=function(){r(),a(!1)},t[3]=r,t[4]=l);let u=l,d;t[5]===i?d=t[6]:(d=()=>a(!i),t[5]=i,t[6]=d);let f,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(n,{}),p=(0,$.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=f,t[8]=p):(f=t[7],p=t[8]);let m;t[9]===d?m=t[10]:(m=(0,$.jsxs)(_,{variant:`action`,size:`icon-sm`,onClick:d,children:[f,p]}),t[9]=d,t[10]=m);let h;t[11]!==u||t[12]!==i?(h=i&&(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 w-48 rounded-lg border border-border bg-popover p-1 shadow-md z-50`,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-sm text-popover-foreground hover:bg-accent`,onClick:u,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=u,t[12]=i,t[13]=h):h=t[13];let g;return t[14]!==m||t[15]!==h?(g=(0,$.jsxs)(`div`,{className:`relative`,ref:o,children:[m,h]}),t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function Ct(e){let t=(0,Z.c)(14),{onToggleSpeech:n}=e,{isListening:r,isSupported:i}=tt();if(!i)return null;let a=r?`bg-red-500/20 text-red-500 hover:bg-red-500/30`:`text-muted-foreground hover:text-background`,o;t[0]===r?o=t[1]:(o=r?(0,$.jsx)(R,{}):(0,$.jsx)(L,{}),t[0]=r,t[1]=o);let s=r?`Stop listening`:`Start listening`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`span`,{className:`sr-only`,children:s}),t[2]=s,t[3]=c);let l;t[4]!==n||t[5]!==a||t[6]!==o||t[7]!==c?(l=(0,$.jsx)(je,{asChild:!0,children:(0,$.jsxs)(_,{variant:`ghost`,size:`icon-sm`,className:a,onClick:n,children:[o,c]})}),t[4]=n,t[5]=a,t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=r?`Stop listening`:`Start listening`,d;t[9]===u?d=t[10]:(d=(0,$.jsx)(ke,{side:`top`,className:`bg-popover text-popover-foreground`,children:u}),t[9]=u,t[10]=d);let f;return t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(Ae,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13],f}function wt(e){let t=(0,Z.c)(8),{queuedMessages:n,onRemoveQueuedMessage:r}=e;if(n.length===0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Queued messages`}),t[0]=i):i=t[0];let a;if(t[1]!==r||t[2]!==n){let e;t[4]===r?e=t[5]:(e=e=>(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border/60 bg-background px-3 py-2 text-sm`,children:[(0,$.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-full p-1 text-muted-foreground transition-colors hover:bg-foreground hover:text-background`,onClick:()=>r(e.id),"aria-label":`Remove queued message`,children:(0,$.jsx)(ie,{className:`h-3.5 w-3.5`})})]},e.id),t[4]=r,t[5]=e),a=n.map(e),t[1]=r,t[2]=n,t[3]=a}else a=t[3];let o;return t[6]===a?o=t[7]:(o=(0,$.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function Tt(e){let t=(0,Z.c)(146),{onSend:n,onStop:r,isStreaming:i,disabled:a,initialValue:o,queuedMessages:s,onRemoveQueuedMessage:c,isOverlay:l}=e,u=i===void 0?!1:i,d=l===void 0?!1:l,{isListening:f,transcript:p,startListening:h,stopListening:g,resetTranscript:v}=tt(),y;t[0]===o?y=t[1]:(y={initialValue:o},t[0]=o,t[1]=y);let{message:b,setMessage:x,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,availableModels:k,selectedModel:A,setSelectedModel:j,attachments:N,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,availableImageModels:te,selectedImageModel:ne,setSelectedImageModel:re,allFiles:ie,setAllFiles:ae,showSuggestions:B,setShowSuggestions:oe,suggestionQuery:V,setSuggestionQuery:H,selectedIndex:U,setSelectedIndex:W,slashCommands:G,skills:K,showCommandSuggestions:q,setShowCommandSuggestions:se,commandQuery:J,setCommandQuery:ce,fileInputRef:le,textareaRef:ue,suggestionsRef:de,commandSuggestionsRef:fe,state:pe,dispatch:me}=nt(y),he=z?ne:A,ge=z?te:k,_e=pe.selectedThreadId??void 0,ve;t[2]!==ie||t[3]!==N||t[4]!==J||t[5]!==D||t[6]!==me||t[7]!==w||t[8]!==S||t[9]!==z||t[10]!==f||t[11]!==u||t[12]!==b||t[13]!==n||t[14]!==F||t[15]!==L||t[16]!==v||t[17]!==ne||t[18]!==U||t[19]!==A||t[20]!==ae||t[21]!==P||t[22]!==ce||t[23]!==O||t[24]!==E||t[25]!==C||t[26]!==ee||t[27]!==x||t[28]!==I||t[29]!==R||t[30]!==W||t[31]!==se||t[32]!==oe||t[33]!==H||t[34]!==q||t[35]!==B||t[36]!==K||t[37]!==G||t[38]!==g||t[39]!==V||t[40]!==_e||t[41]!==ue?(ve={message:b,setMessage:x,attachments:N,selectedModel:A,onSend:n,isStreaming:u,selectedThreadId:_e,isListening:f,stopListening:g,resetTranscript:v,dispatch:me,historyIndex:S,setHistoryIndex:C,draftMessage:w,setDraftMessage:E,cursorPosition:D,setCursorPosition:O,showSuggestions:B,setShowSuggestions:oe,suggestionQuery:V,setSuggestionQuery:H,allFiles:ie,setAllFiles:ae,selectedIndex:U,setSelectedIndex:W,showCommandSuggestions:q,setShowCommandSuggestions:se,commandQuery:J,setCommandQuery:ce,slashCommands:G,skills:K,textareaRef:ue,setAttachments:P,planMode:F,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:z,setImageMode:ee,selectedImageModel:ne},t[2]=ie,t[3]=N,t[4]=J,t[5]=D,t[6]=me,t[7]=w,t[8]=S,t[9]=z,t[10]=f,t[11]=u,t[12]=b,t[13]=n,t[14]=F,t[15]=L,t[16]=v,t[17]=ne,t[18]=U,t[19]=A,t[20]=ae,t[21]=P,t[22]=ce,t[23]=O,t[24]=E,t[25]=C,t[26]=ee,t[27]=x,t[28]=I,t[29]=R,t[30]=W,t[31]=se,t[32]=oe,t[33]=H,t[34]=q,t[35]=B,t[36]=K,t[37]=G,t[38]=g,t[39]=V,t[40]=_e,t[41]=ue,t[42]=ve):ve=t[42];let{handleSend:ye,handleKeyDown:be,handleTextareaInput:xe,insertFileReference:Se,insertCommand:Ce,insertSkill:we,fileSuggestions:Te}=it(ve),Ee=Q.useRef(``),Y,De;t[43]!==x||t[44]!==p?(Y=()=>{if(p&&p!==Ee.current){let e=p.substring(Ee.current.length);x(t=>(t.endsWith(` `),t+e)),Ee.current=p}},De=[p,x],t[43]=x,t[44]=p,t[45]=Y,t[46]=De):(Y=t[45],De=t[46]),Q.useEffect(Y,De);let X;t[47]===P?X=t[48]:(X=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(Dt);if(n.length!==0){e.preventDefault();for(let e of n){let t=e.getAsFile();if(!t)continue;let n=new FileReader;n.onload=()=>{let e=n.result.split(`,`)[1];P(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[47]=P,t[48]=X);let Oe=X,ke;t[49]!==f||t[50]!==v||t[51]!==h||t[52]!==g?(ke=()=>{f?(g(),v()):(v(),h())},t[49]=f,t[50]=v,t[51]=h,t[52]=g,t[53]=ke):ke=t[53];let Ae=ke,je=d?`absolute inset-x-0 bottom-0 mx-auto w-full max-w-3xl px-4 pb-4 pointer-events-none`:`relative mx-auto w-full max-w-3xl px-4 pb-4`,Me=`flex flex-col rounded-2xl border focus-within:ring-2 focus-within:ring-brand pointer-events-auto ${d?`border-border/50 bg-background/80 shadow-lg backdrop-blur-sm`:`border-border bg-background shadow-2xl`}`,Ne;t[54]!==c||t[55]!==s?(Ne=(0,$.jsx)(wt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[54]=c,t[55]=s,t[56]=Ne):Ne=t[56];let Pe=L?`Describe stories for Ralph to implement autonomously...`:F?`Describe what you want Tarsk to plan...`:z?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,Fe;t[57]!==a||t[58]!==be||t[59]!==Oe||t[60]!==xe||t[61]!==b||t[62]!==Pe||t[63]!==ue?(Fe=(0,$.jsx)(`textarea`,{ref:ue,value:b,onChange:xe,onKeyDown:be,onPaste:Oe,placeholder:Pe,rows:1,className:`w-full resize-none bg-transparent px-6 pt-4 pb-4 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none`,disabled:a}),t[57]=a,t[58]=be,t[59]=Oe,t[60]=xe,t[61]=b,t[62]=Pe,t[63]=ue,t[64]=Fe):Fe=t[64];let Ie;t[65]!==J||t[66]!==fe||t[67]!==Ce||t[68]!==we||t[69]!==U||t[70]!==W||t[71]!==q||t[72]!==K||t[73]!==G?(Ie=(0,$.jsx)(ct,{visible:q,commands:G,skills:K,query:J,selectedIndex:U,onSelectCommand:Ce,onSelectSkill:we,onMouseEnterSuggestion:W,containerRef:fe}),t[65]=J,t[66]=fe,t[67]=Ce,t[68]=we,t[69]=U,t[70]=W,t[71]=q,t[72]=K,t[73]=G,t[74]=Ie):Ie=t[74];let Le;t[75]!==Te||t[76]!==Se||t[77]!==U||t[78]!==W||t[79]!==B||t[80]!==V||t[81]!==de?(Le=(0,$.jsx)(mt,{showSuggestions:B,fileSuggestions:Te,suggestionQuery:V,selectedIndex:U,onSelectFile:Se,onMouseEnterSuggestion:W,containerRef:de}),t[75]=Te,t[76]=Se,t[77]=U,t[78]=W,t[79]=B,t[80]=V,t[81]=de,t[82]=Le):Le=t[82];let Re;t[83]!==N||t[84]!==A?.id||t[85]!==A?.name||t[86]!==A?.supportsImages||t[87]!==P?(Re=N.length>0&&(0,$.jsxs)(`div`,{className:`px-4`,children:[(0,$.jsx)(ft,{attachments:N,onRemove:e=>P(t=>t.filter((t,n)=>n!==e))}),N.some(Et)&&A?.supportsImages===!1&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,$.jsx)(m,{className:`h-3 w-3 shrink-0`}),(0,$.jsxs)(`span`,{children:[`Images are not supported by `,A?.name||A?.id]})]})]}),t[83]=N,t[84]=A?.id,t[85]=A?.name,t[86]=A?.supportsImages,t[87]=P,t[88]=Re):Re=t[88];let ze;t[89]===le?ze=t[90]:(ze=(0,$.jsx)(St,{onFileAttach:()=>le.current?.click()}),t[89]=le,t[90]=ze);let Be;t[91]===Ae?Be=t[92]:(Be=(0,$.jsx)(Ct,{onToggleSpeech:Ae}),t[91]=Ae,t[92]=Be);let Ve=z?re:j,He;t[93]!==ge||t[94]!==he||t[95]!==Ve?(He=(0,$.jsx)(_t,{availableModels:ge,selectedModel:he,onModelSelect:Ve}),t[93]=ge,t[94]=he,t[95]=Ve,t[96]=He):He=t[96];let Ue;t[97]!==ze||t[98]!==Be||t[99]!==He?(Ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ze,Be,He]}),t[97]=ze,t[98]=Be,t[99]=He,t[100]=Ue):Ue=t[100];let We;t[101]!==z||t[102]!==F||t[103]!==L||t[104]!==ee||t[105]!==I||t[106]!==R?(We=(0,$.jsx)(xt,{planMode:F,imageMode:z,ralphMode:L,setPlanMode:I,setImageMode:ee,setRalphMode:R}),t[101]=z,t[102]=F,t[103]=L,t[104]=ee,t[105]=I,t[106]=R,t[107]=We):We=t[107];let Ge=u?r:ye,Ke;t[108]!==N.length||t[109]!==a||t[110]!==he||t[111]!==u||t[112]!==b?(Ke=!u&&((a??!1)||!b.trim()&&N.length===0||!he),t[108]=N.length,t[109]=a,t[110]=he,t[111]=u,t[112]=b,t[113]=Ke):Ke=t[113];let qe;t[114]===u?qe=t[115]:(qe=u?(0,$.jsx)(T,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(M,{className:`h-3 w-3`}),t[114]=u,t[115]=qe);let Je=u?`Stop generation`:`Send message`,Ye;t[116]===Je?Ye=t[117]:(Ye=(0,$.jsx)(`span`,{className:`sr-only`,children:Je}),t[116]=Je,t[117]=Ye);let Xe;t[118]!==Ge||t[119]!==Ke||t[120]!==qe||t[121]!==Ye?(Xe=(0,$.jsxs)(_,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:Ge,disabled:Ke,children:[qe,Ye]}),t[118]=Ge,t[119]=Ke,t[120]=qe,t[121]=Ye,t[122]=Xe):Xe=t[122];let Ze;t[123]!==We||t[124]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[We,Xe]}),t[123]=We,t[124]=Xe,t[125]=Ze):Ze=t[125];let Qe;t[126]!==Ue||t[127]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Ue,Ze]}),t[126]=Ue,t[127]=Ze,t[128]=Qe):Qe=t[128];let $e;t[129]!==Me||t[130]!==Ne||t[131]!==Fe||t[132]!==Ie||t[133]!==Le||t[134]!==Re||t[135]!==Qe?($e=(0,$.jsxs)(`div`,{className:Me,children:[Ne,Fe,Ie,Le,Re,Qe]}),t[129]=Me,t[130]=Ne,t[131]=Fe,t[132]=Ie,t[133]=Le,t[134]=Re,t[135]=Qe,t[136]=$e):$e=t[136];let et;t[137]===P?et=t[138]:(et=e=>pt(e,e=>P(t=>[...t,...e])),t[137]=P,t[138]=et);let rt;t[139]!==le||t[140]!==et?(rt=(0,$.jsx)(`input`,{ref:le,type:`file`,multiple:!0,className:`hidden`,onChange:et}),t[139]=le,t[140]=et,t[141]=rt):rt=t[141];let at;return t[142]!==je||t[143]!==$e||t[144]!==rt?(at=(0,$.jsxs)(`div`,{className:je,children:[$e,rt]}),t[142]=je,t[143]=$e,t[144]=rt,t[145]=at):at=t[145],at}function Et(e){return e.mimeType.startsWith(`image/`)}function Dt(e){return e.type.startsWith(`image/`)}var Ot=ge,kt=Ce,At=he,jt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=a&&`pl-8`,c;n[5]!==i||n[6]!==s?(c=E(`flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,s,i),n[5]=i,n[6]=s,n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(y,{className:`ml-auto`}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==c?(u=(0,$.jsxs)(xe,{ref:t,className:c,...o,children:[r,l]}),n[9]=r,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});jt.displayName=xe.displayName;var Mt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=E(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Se,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Mt.displayName=Se.displayName;var Nt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=E(`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`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,$.jsx)(ye,{children:(0,$.jsx)(ve,{ref:t,sideOffset:o,className:s,...i})}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});Nt.displayName=ve.displayName;var Pt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=E(`relative flex cursor-default select-none items-center gap-2 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(fe,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Pt.displayName=fe.displayName;var Ft=Q.forwardRef((e,t)=>{let n=(0,Z.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=E(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(be,{children:(0,$.jsx)(K,{className:`h-4 w-4`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,$.jsxs)(_e,{ref:t,className:s,checked:r,...o,children:[c,i]}),n[8]=r,n[9]=i,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});Ft.displayName=_e.displayName;var It=Q.forwardRef((e,t)=>{let n=(0,Z.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=E(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,$.jsx)(be,{children:(0,$.jsx)(G,{className:`h-2 w-2 fill-current`})})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,$.jsxs)(pe,{ref:t,className:o,...a,children:[s,r]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});It.displayName=pe.displayName;var Lt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i&&`pl-8`,s;n[4]!==r||n[5]!==o?(s=E(`px-2 py-1.5 text-sm font-semibold`,o,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==a||n[8]!==t||n[9]!==s?(c=(0,$.jsx)(me,{ref:t,className:s,...a}),n[7]=a,n[8]=t,n[9]=s,n[10]=c):c=n[10],c});Lt.displayName=me.displayName;var Rt=Q.forwardRef((e,t)=>{let n=(0,Z.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=E(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,$.jsx)(Te,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Rt.displayName=Te.displayName;var zt=e=>{let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=E(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a};zt.displayName=`DropdownMenuShortcut`;function Bt(e){let t=(0,Z.c)(17),{currentBranch:n,availableBranches:r,isLoadingBranches:i,isCheckingOut:a,onLoadBranches:o,onCheckoutBranch:s}=e,c;t[0]===o?c=t[1]:(c=e=>{e&&o()},t[0]=o,t[1]=c);let l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=l):l=t[2];let u=n||`Unknown`,d;t[3]===u?d=t[4]:(d=(0,$.jsx)(kt,{asChild:!0,children:(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background gap-1.5 border-none text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:[l,u]})}),t[3]=u,t[4]=d);let f;t[5]!==r||t[6]!==n||t[7]!==a||t[8]!==i||t[9]!==s?(f=i?(0,$.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,$.jsx)(ee,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):r.length===0?(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):r.map(e=>(0,$.jsxs)(Pt,{disabled:e===n||a,onClick:()=>s(e),children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,$.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=r,t[6]=n,t[7]=a,t[8]=i,t[9]=s,t[10]=f):f=t[10];let p;t[11]===f?p=t[12]:(p=(0,$.jsx)(Nt,{align:`start`,children:f}),t[11]=f,t[12]=p);let m;return t[13]!==c||t[14]!==d||t[15]!==p?(m=(0,$.jsxs)(Ot,{onOpenChange:c,children:[d,p]}),t[13]=c,t[14]=d,t[15]=p,t[16]=m):m=t[16],m}var Vt=3e4;function Ht(e){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(void 0),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(`Up to date`),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(void 0),[D,O]=(0,Q.useState)(void 0),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=(0,Q.useRef)(!0),P=(0,Q.useCallback)(e=>{n(e.hasChanges),i(e.changedFilesCount),o(e.hasUnpushedCommits),c(e.currentBranch),v(e.hasRemoteBranch),u(e.isOnGitHub),f(e.remoteUrl),m(e.canCreateRepo),g(e.repoUrl),b(e.status),S(e.defaultBranch??null),w(e.prExists),E(e.prUrl),O(e.prState),A(e.commitsAheadOfDefault??!1)},[]),F=(0,Q.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>M(!0),100);try{let n=`unified-git-status-${e}`;t&&le.invalidate(n),P(await le.get(n,()=>ne(e,t),Vt))}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),M(!1)}},[e,P]);return(0,Q.useEffect)(()=>{e&&(async()=>{if(N.current){let t=`unified-git-status-${e}`,n=le.getSync(t);n&&P(n),N.current=!1}await F()})()},[e,F,P]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:C,prUrl:T,prState:D,commitsAheadOfDefault:k,isRefreshing:j,fetchUnifiedStatus:F}}function Ut(e){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=Ht(e);async function c(){if(!(!e||r)){i(!0);try{n((await f(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await p(e,t),await s.fetchUnifiedStatus(!0),Me({title:`Switched to branch "${t}"`})}catch(e){Me({title:`Failed to switch branch`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{o(!1)}}}return{currentBranch:s.currentBranch,availableBranches:t,isLoadingBranches:r,isCheckingOut:a,loadBranches:c,checkoutBranch:l,fetchUnifiedStatus:s.fetchUnifiedStatus}}function Wt({threadId:e}){let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(null),a=Ut(e);return(0,Q.useEffect)(()=>{e&&H(e).then(i).catch(()=>{})},[e]),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,$.jsx)(Bt,{currentBranch:a.currentBranch,availableBranches:a.availableBranches,isLoadingBranches:a.isLoadingBranches,isCheckingOut:a.isCheckingOut,onLoadBranches:a.loadBranches,onCheckoutBranch:a.checkoutBranch}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:e&&(0,$.jsxs)(Ae,{children:[(0,$.jsx)(je,{asChild:!0,children:(0,$.jsx)(_,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs bg-background`,onClick:async()=>{if(!(!e||t)){n(!0);try{let t=await H(e);await navigator.clipboard.writeText(t)}finally{n(!1)}}},disabled:t,"aria-label":`Copy repository folder path`,children:(0,$.jsx)(te,{className:`h-3.5 w-3.5 mr-1`})})}),(0,$.jsxs)(ke,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,$.jsx)(`div`,{children:`Copy repository folder path`}),r&&(0,$.jsx)(`div`,{className:`opacity-70 text-xs`,children:r})]})]})})]})}function Gt(e,t){if(!(!t||!e.includes(`"run_js"`)))try{let n=JSON.parse(e.trim());if(!Array.isArray(n))return;for(let e of n)e?.type===`tool_use`&&e?.name===`run_js`&&e?.id&&e?.input?.code&&$e(e.id,e.input.code,t)}catch{}}function Kt(){let{state:e,dispatch:t}=Ee(),[n,r]=(0,Q.useState)(null),[i,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(``),c=(0,Q.useRef)(``),l=(0,Q.useRef)([]),u=(0,Q.useRef)(!1),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(()=>{}),[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useRef)(null),b=(0,Q.useRef)(null),{selectedThreadId:x,selectedProjectId:S,messages:C,queuedChatMessages:w,isStreaming:T,streamingModel:E,processingThreadIds:O}=e,A=!!(x&&O.includes(x)),j=(0,Q.useCallback)(n=>{if(d.current=null,f.current=null,g.current){g.current=!1;return}let r=l.current,i=De(r)||`...`;if(v.current&&(r.length===0||i===`...`)){let r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${v.current}`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};t({type:X.AddMessage,message:r}),t({type:X.ResetStream}),x&&t({type:X.RemoveProcessingThread,threadId:x}),v.current=null;return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:e.streamingModel||n,isThinking:!1};s.current=``,c.current=``,l.current=[],v.current=null,t({type:X.AddMessage,message:a}),t({type:X.ResetStream}),x&&(t({type:X.MarkThreadCompleted,threadId:x}),t({type:X.RemoveProcessingThread,threadId:x}))},[e.streamingModel,t,x]);(0,Q.useEffect)(()=>{p.current=j},[j]);let M=(0,Q.useCallback)(()=>{x&&h(x),g.current=!0,x&&P(x),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],v.current=null;let n={messageId:`msg-${Date.now()}-stopped`,sender:`agent`,content:`I've stopped working on your request.`,contentType:`text`,timestamp:new Date().toISOString(),model:e.streamingModel||`default`,isThinking:!1};t({type:X.AddMessage,message:n}),t({type:X.ResetStream}),x&&(t({type:X.MarkThreadCompleted,threadId:x}),t({type:X.RemoveProcessingThread,threadId:x}))},[x,t,e.streamingModel]);(0,Q.useEffect)(()=>{_.current&&!T&&d.current&&(d.current.abort(),d.current=null,f.current&&=(f.current(),null),p.current(E||`default`)),_.current=T},[T,E]),(0,Q.useEffect)(()=>{if(y.current&&=(clearTimeout(y.current),null),T){let e=12e4,t=n=>{y.current&&=(clearTimeout(y.current),null),y.current=setTimeout(()=>{let n=Date.now(),r=b?.current??null;if(r!=null){let i=n-r;if(i<e){t(e-i);return}}console.warn(`[stream-safety] Streaming stuck for 2 minutes with no activity, auto-finalizing`),d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),p.current(E||`default`)},n)},n=e;if(b?.current!=null){let t=Date.now()-b.current;n=t>=e?0:e-t}t(n)}return()=>{y.current&&=(clearTimeout(y.current),null)}},[T,E]),(0,Q.useEffect)(()=>()=>{d.current&&=(d.current.abort(),null),f.current&&=(f.current(),null),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,t({type:X.ResetStream})},[x,t]),(0,Q.useEffect)(()=>{if(!x)return;let e=!1;async function n(){try{let n=await q(x);e||t({type:X.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:X.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[x,S,t]),(0,Q.useEffect)(()=>{if(!x||!A||T)return;let e=new AbortController;return d.current=e,t({type:X.ResetStream}),t({type:X.SetStreaming,isStreaming:!0}),s.current=``,c.current=``,l.current=[],u.current=!1,v.current=null,W(x,e.signal).then(n=>{if(!n||e.signal.aborted){p.current(`default`);return}f.current=k(n,e=>{if(t({type:X.IncrementStreamEventCount}),e.type===`error`){let t=e.content||`Unknown error occurred`;v.current=t,r(t);return}if(e.type!==`message`){if(e.type===`toolcall_delta`){e.partial?.content?.[0]?.id&&e.delta&&t({type:X.UpdateToolCallProgress,toolCallId:e.partial.content[0].id,progress:{toolCallId:e.partial.content[0].id,toolName:e.partial.content[0].name,delta:e.delta,partial:e.partial}});return}if(e.model&&t({type:X.SetStreamModel,model:e.model}),e.type===`thinking`||e.isThinking){let n=e.content??``;Gt(n,x),c.current+=n;let r=Y(l.current,`thinking`,n);l.current=r,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:n,segments:r})}else if(e.type===`result`)u.current=!0,s.current=e.content??``,l.current=Oe(l.current,e.content??``),t({type:X.SetStreamContent,content:e.content??``});else{if(u.current)return;s.current+=e.content??``;let n=Y(l.current,`content`,e.content??``);l.current=n,t({type:X.AppendStreamChunk,chunkType:`content`,content:e.content??``,segments:n})}}},()=>{p.current(`default`)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(`default`);return}v.current=e,r(e)},e=>{if(t({type:X.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=Y(l.current,`thinking`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=Oe(l.current,r),t({type:X.SetStreamContent,content:r});else{s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}).catch(e=>{if(e instanceof Error&&e.name===`AbortError`){t({type:X.ResetStream});return}if(e instanceof Error&&e.message.includes(`not currently processing`)){t({type:X.ResetStream});return}console.error(`Failed to subscribe to chat stream:`,e),t({type:X.ResetStream})}),()=>{e.abort(),f.current&&=(f.current(),null)}},[x,A]);let F=(0,Q.useCallback)(async(n,i,m,g,_,y,b)=>{if(!x)return;r(null),h(null),d.current&&d.current.abort(),f.current&&f.current();let C=`msg-${Date.now()}`,w;try{let e=await a(x,C);e.success&&e.stashed&&e.checkpointRef&&(w=e.checkpointRef)}catch{}let T={messageId:C,sender:`user`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,attachments:m.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:w};t({type:X.AddMessage,message:T});let E=n.trim().replace(/\n/g,` `).slice(0,100);if(S&&x&&(N(x,{title:E}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:X.UpdateThreadTitle,projectId:S,threadId:x,title:E})),y){let e=g??void 0;if(!e&&typeof i==`string`){let t=i.split(/[:/]/)[0]?.trim();t&&(e=t)}if(!e){let e={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Image generation is not available because no provider is configured for the selected model.`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:X.AddMessage,message:e}),t({type:X.ResetStream});return}t({type:X.SetStreaming,isStreaming:!0});try{let r=await D(n,i,e,x),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:n,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1,generatedImageUrl:r.imageUrl,generatedImageData:r.imageData};t({type:X.AddMessage,message:a})}catch(e){let n=e instanceof Error?e.message:`Image generation failed`,r={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${n}`,contentType:`text`,timestamp:new Date().toISOString(),model:i,isThinking:!1};t({type:X.AddMessage,message:r})}finally{t({type:X.ResetStream})}return}t({type:X.ResetStream}),t({type:X.SetStreaming,isStreaming:!0}),s.current=``,u.current=!1;let O=new AbortController;d.current=O;try{let a=await U(x,n,i,m,O.signal,g,_,b);if(!a){p.current(i);return}f.current=k(a,n=>{if(t({type:X.IncrementStreamEventCount}),n.type===`error`){let e=n.content||`Unknown error occurred`;v.current=e,r(e);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){if(n.partial?.content?.[0]?.id&&n.delta){let e=n.partial.content[0].id,r=n.partial.content[0].name;t({type:X.UpdateToolCallProgress,toolCallId:e,progress:{toolCallId:e,toolName:r,delta:n.delta,partial:n.partial}})}return}if(n.model&&t({type:X.SetStreamModel,model:n.model}),n.type===`thinking`||n.isThinking){let r=n.content??``;Gt(r,e.selectedThreadId),c.current+=r;let i=Y(l.current,`thinking`,r);l.current=i,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:i})}else if(n.type===`result`)u.current=!0,s.current=n.content??``,l.current=Oe(l.current,n.content??``),t({type:X.SetStreamContent,content:n.content??``});else{if(u.current)return;s.current+=n.content??``;let e=Y(l.current,`content`,n.content??``);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:n.content??``,segments:e})}}},()=>{p.current(i)},e=>{if(e.includes(`AbortError`)||e.includes(`canceled`)||e.includes(`BodyStreamBuffer was aborted`)){p.current(i);return}v.current=e,r(e)},e=>{if(t({type:X.IncrementStreamEventCount}),e.role===`assistant`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(e.isThinking??!1){c.current+=r;let e=Y(l.current,`thinking`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`thinking`,content:r,segments:e});return}let i=!1;if(typeof n==`object`&&Array.isArray(n)&&n.length>0)i=!0;else if(typeof r==`string`&&r.trim().startsWith(`[`))try{let e=JSON.parse(r);i=Array.isArray(e)&&e.length>0}catch{}if(i)u.current=!0,s.current=r,l.current=Oe(l.current,r),t({type:X.SetStreamContent,content:r});else{s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}else if(e.role===`tool`){let n=e.content??``,r=typeof n==`string`?n:JSON.stringify(n);if(r){s.current+=r;let e=Y(l.current,`content`,r);l.current=e,t({type:X.AppendStreamChunk,chunkType:`content`,content:r,segments:e})}}})}catch(e){if(e instanceof Error&&e.name===`AbortError`||e instanceof Error&&e.message.includes(`BodyStreamBuffer was aborted`))return;if(e instanceof ue){t({type:X.ResetStream}),o(!0);return}r(e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`),v.current=e instanceof Error?e.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`,t({type:X.ResetStream})}},[x,S,t]);(0,Q.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||T||n.threadId!==x)return;let r=setTimeout(()=>{t({type:X.ClearPendingChatMessage}),F(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,T,x,t,F]);let I=(0,Q.useMemo)(()=>x?w.filter(e=>e.threadId===x):[],[x,w]),L=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(T||!x||I.length===0||L.current)return;let[e]=I;L.current=!0,t({type:X.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{F(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),L.current=!1},0);return()=>{clearTimeout(n),L.current=!1}},[t,F,T,I,x]),{error:n,setError:r,handleSend:F,handleStop:M,isStreaming:T,selectedThreadId:x,queuedMessagesForThread:I,handleRemoveQueuedMessage:(0,Q.useCallback)(e=>{let n=I.find(t=>t.id===e);t({type:X.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||T||C.length>0||!x)&&F(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,F,T,C.length,I,x]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:o}}function qt(e){let t=(0,Z.c)(10),{open:n,onClose:r}=e,i=we(),a;t[0]===r?a=t[1]:(a=e=>{e||r()},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(Le,{children:[(0,$.jsx)(Pe,{children:`Balance empty`}),(0,$.jsx)(Ne,{children:`You have no prompts remaining. Purchase additional prompts to continue.`})]}),t[2]=o):o=t[2];let s;t[3]!==i||t[4]!==r?(s=(0,$.jsxs)(Fe,{children:[o,(0,$.jsx)(Ie,{children:(0,$.jsx)(_,{onClick:()=>{r(),i(`/settings/account`)},children:`Go to Account`})})]}),t[3]=i,t[4]=r,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Re,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Jt(e){let t=(0,Z.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(Xt),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No todo items.`}),t[2]=n.length,t[3]=a);let o;t[4]===n?o=t[5]:(o=n.map(Yt),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-1`,children:[i,`/`,n.length,` completed`]}),t[6]=i,t[7]=n.length,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function Yt(e){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,$.jsx)(O,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,$.jsx)(u,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,$.jsx)(G,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function Xt(e){return e.status===`done`}function Zt(){let e=(0,Z.c)(16),{todos:t}=(0,Q.useContext)(Ue),[n,r]=(0,Q.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Qt),e[0]=t,e[1]=i);let a=i.length;if(t.length-a<=0)return null;let o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r(!0),s=(0,$.jsx)(j,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=s):(o=e[2],s=e[3]);let l;e[4]!==a||e[5]!==t.length?(l=(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2 bg-background ml-2`,onClick:o,children:[s,a,` of `,t.length,` complete`]}),e[4]=a,e[5]=t.length,e[6]=l):l=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(c,{children:(0,$.jsx)(w,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,$.jsxs)(de,{className:`max-w-md`,children:[u,(0,$.jsx)(Jt,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,$.jsx)(x,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==l||e[14]!==f?(p=(0,$.jsxs)($.Fragment,{children:[l,f]}),e[13]=l,e[14]=f,e[15]=p):p=e[15],p}function Qt(e){return e.status===`done`}function $t(e){let t=(0,Z.c)(34),{messages:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?[]:r,t[0]=r,t[1]=i);let a=i,{state:s,dispatch:c}=Ee(),{isCreatingProject:l,selectedThreadId:u}=s,{handleSend:d,handleStop:f,isStreaming:p,queuedMessagesForThread:m,handleRemoveQueuedMessage:h,showEmptyBalanceDialog:g,setShowEmptyBalanceDialog:v}=Kt(),y=s.pendingChatMessage?.threadId===u,b=p||y,x=a.length>0,{hasChanges:S,changedFilesCount:C}=Ht(u??void 0),{setActiveMainTab:w}=ze(),T;t[2]!==c||t[3]!==u?(T=async()=>{if(u)try{let e=await J(u);c({type:X.ClearMessages}),console.log(`New conversation started:`,e);let t=await q(u);c({type:X.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=c,t[3]=u,t[4]=T):T=t[4];let E=T,D;t[5]===v?D=t[6]:(D=()=>v(!1),t[5]=v,t[6]=D);let O;t[7]!==g||t[8]!==D?(O=(0,$.jsx)(qt,{open:g,onClose:D}),t[7]=g,t[8]=D,t[9]=O):O=t[9];let k;t[10]!==C||t[11]!==E||t[12]!==S||t[13]!==x||t[14]!==w?(k=x&&(0,$.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8`,children:[(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:E,children:[(0,$.jsx)(n,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),S&&(0,$.jsxs)(_,{variant:`outline`,size:`sm`,className:`gap-2 ml-2`,onClick:()=>w(`review`),children:[(0,$.jsx)(o,{className:`h-4 w-4 shrink-0`}),C,` `,C===1?`File`:`Files`,` Changed`]}),(0,$.jsx)(Zt,{})]}),t[10]=C,t[11]=E,t[12]=S,t[13]=x,t[14]=w,t[15]=k):k=t[15];let A=!u&&!l,j;t[16]!==b||t[17]!==h||t[18]!==d||t[19]!==f||t[20]!==m||t[21]!==A?(j=(0,$.jsx)(Tt,{onSend:d,onStop:f,isStreaming:b,disabled:A,initialValue:``,queuedMessages:m,onRemoveQueuedMessage:h,isOverlay:!1}),t[16]=b,t[17]=h,t[18]=d,t[19]=f,t[20]=m,t[21]=A,t[22]=j):j=t[22];let M;t[23]!==k||t[24]!==j?(M=(0,$.jsxs)(`div`,{className:`relative`,children:[k,j]}),t[23]=k,t[24]=j,t[25]=M):M=t[25];let N=u??void 0,P;t[26]===N?P=t[27]:(P=(0,$.jsx)(Wt,{threadId:N}),t[26]=N,t[27]=P);let F;t[28]!==P||t[29]!==M?(F=(0,$.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[M,P]}),t[28]=P,t[29]=M,t[30]=F):F=t[30];let I;return t[31]!==F||t[32]!==O?(I=(0,$.jsxs)($.Fragment,{children:[O,F]}),t[31]=F,t[32]=O,t[33]=I):I=t[33],I}export{He as _,Pt as a,Mt as c,$e as d,Ye as f,Ge as g,We as h,Nt as i,jt as l,Ke as m,Ht as n,Rt as o,Xe as p,Ot as r,At as s,$t as t,kt as u};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,Qi as n,Wn as r,da as i,la as a,qi as o,ta as s}from"./dialogs-config-BEsTbY1C.js";import{a as c,d as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,s as _,t as v,u as y}from"./react-vendor-QkuITxN7.js";var b=a(),x=e(i(),1),S=t(),C=y,w=u,T=x.forwardRef((e,t)=>{let i=(0,b.c)(14),a,o,s,c;i[0]===e?(a=i[1],o=i[2],s=i[3],c=i[4]):({className:o,inset:s,children:a,...c}=e,i[0]=e,i[1]=a,i[2]=o,i[3]=s,i[4]=c);let l=s&&`pl-8`,u;i[5]!==o||i[6]!==l?(u=r(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground`,l,o),i[5]=o,i[6]=l,i[7]=u):u=i[7];let d;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(n,{className:`ml-auto h-4 w-4`}),i[8]=d):d=i[8];let f;return i[9]!==a||i[10]!==c||i[11]!==t||i[12]!==u?(f=(0,S.jsxs)(p,{ref:t,className:u,...c,children:[a,d]}),i[9]=a,i[10]=c,i[11]=t,i[12]=u,i[13]=f):f=i[13],f});T.displayName=p.displayName;var E=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(g,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});E.displayName=g.displayName;var D=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 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`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(_,{children:(0,S.jsx)(m,{ref:t,className:o,...a})}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});D.displayName=m.displayName;var O=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(d,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});O.displayName=d.displayName;var k=x.forwardRef((e,t)=>{let n=(0,b.c)(14),i,a,o,l;n[0]===e?(i=n[1],a=n[2],o=n[3],l=n[4]):({className:o,children:a,checked:i,...l}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o,n[4]=l);let u;n[5]===o?u=n[6]:(u=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,o),n[5]=o,n[6]=u);let d;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(s,{className:`h-4 w-4`})})}),n[7]=d):d=n[7];let f;return n[8]!==i||n[9]!==a||n[10]!==l||n[11]!==t||n[12]!==u?(f=(0,S.jsxs)(v,{ref:t,className:u,checked:i,...l,children:[d,a]}),n[8]=i,n[9]=a,n[10]=l,n[11]=t,n[12]=u,n[13]=f):f=n[13],f});k.displayName=v.displayName;var A=x.forwardRef((e,t)=>{let n=(0,b.c)(12),i,a,s;n[0]===e?(i=n[1],a=n[2],s=n[3]):({className:a,children:i,...s}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=s);let l;n[4]===a?l=n[5]:(l=r(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,a),n[4]=a,n[5]=l);let u;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(c,{children:(0,S.jsx)(o,{className:`h-2 w-2 fill-current`})})}),n[6]=u):u=n[6];let d;return n[7]!==i||n[8]!==s||n[9]!==t||n[10]!==l?(d=(0,S.jsxs)(f,{ref:t,className:l,...s,children:[u,i]}),n[7]=i,n[8]=s,n[9]=t,n[10]=l,n[11]=d):d=n[11],d});A.displayName=f.displayName;var j=x.forwardRef((e,t)=>{let n=(0,b.c)(11),i,a,o;n[0]===e?(i=n[1],a=n[2],o=n[3]):({className:i,inset:a,...o}=e,n[0]=e,n[1]=i,n[2]=a,n[3]=o);let s=a&&`pl-8`,c;n[4]!==i||n[5]!==s?(c=r(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),n[4]=i,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,S.jsx)(h,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});j.displayName=h.displayName;var M=x.forwardRef((e,t)=>{let n=(0,b.c)(9),i,a;n[0]===e?(i=n[1],a=n[2]):({className:i,...a}=e,n[0]=e,n[1]=i,n[2]=a);let o;n[3]===i?o=n[4]:(o=r(`-mx-1 my-1 h-px bg-border`,i),n[3]=i,n[4]=o);let s;return n[5]!==a||n[6]!==t||n[7]!==o?(s=(0,S.jsx)(l,{ref:t,className:o,...a}),n[5]=a,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});M.displayName=l.displayName;var N=e=>{let t=(0,b.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`ml-auto text-xs tracking-widest text-muted-foreground`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,S.jsx)(`span`,{className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o};N.displayName=`ContextMenuShortcut`;export{w as a,M as i,D as n,O as r,C as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./history-view-_L50vkTM.js";export{e as ConversationHistoryView,e as default};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$ as t,$i as n,Ai as r,Bt as i,Cr as a,Et as o,Hn as s,Ni as c,Pn as l,Qi as u,Rn as d,Un as f,Vn as p,Wn as m,Zr as h,at as g,bn as _,da as v,gi as y,ii as b,ji as x,kn as S,la as C,mi as w,pi as T,q as E,ri as D,ui as O,zn as ee}from"./dialogs-config-BEsTbY1C.js";import{_ as k}from"./react-vendor-QkuITxN7.js";import{a as A,t as j}from"./store-Dyy2UFdD.js";import{t as M}from"./textarea-CUYwgm5q.js";import{c as N,s as P,u as te}from"./history-view-_L50vkTM.js";import{_ as ne,t as re}from"./chat-input-container-C8o4YcJZ.js";import{t as F}from"./standard-list-item-ByRgCvKd.js";import{n as ie}from"./utils-BavofGRh.js";import{t as ae}from"./page-toolbar-DM-x5q1_.js";import{n as oe,r as se,t as I}from"./resizable-GT3fWOfA.js";import{a as L,n as R,r as ce,t as z}from"./context-menu-CThafUml.js";var B=e(v(),1),V=C(),H=a();function U(e){let t=(0,V.c)(17),{children:n,title:r,headerAction:i,footer:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,H.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:r}),t[0]=r,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:o}),t[2]=o,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,H.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:`flex items-center justify-between border-b border-sidebar-border px-4 py-6`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=(0,H.jsx)(S,{className:`flex-1`,children:n}),t[9]=n,t[10]=u);let d;t[11]===a?d=t[12]:(d=a&&(0,H.jsx)(`div`,{className:`border-t border-sidebar-border`,children:a}),t[11]=a,t[12]=d);let f;return t[13]!==l||t[14]!==u||t[15]!==d?(f=(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[l,u,d]}),t[13]=l,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function le(e){let t=[],n={};return e.forEach((e,r)=>{let i=e.path.split(`/`),a=t,o=``;for(let e=0;e<i.length-1;e++){if(o=o?`${o}/${i[e]}`:i[e],!n[o]){let t={id:`dir:${o}`,name:i[e],children:[]};n[o]=t,a.push(t)}a=n[o].children}a.push({id:`file:${e.path}`,name:i[i.length-1],fileIndex:r,status:e.status})}),t}var W={added:`text-green-500`,deleted:`text-red-500`,untracked:`text-green-500`,renamed:`text-blue-500`,modified:`text-orange-500`},G={added:`A`,deleted:`D`,untracked:`U`,renamed:`R`,modified:`M`};function K(e){return m(`status-badge font-mono text-xs font-semibold`,W[e]??`text-orange-500`)}function ue(e){return G[e]??`M`}function de(e){let t=(0,V.c)(37),{treeData:n,files:i,isLoading:a,error:o,selectedFileIndex:s,onFileSelect:l,onRevertFile:d}=e,f;t[0]===i?f=t[1]:(f=i.reduce(pe,0),t[0]=i,t[1]=f);let p=f,g;t[2]===i?g=t[3]:(g=i.reduce(q,0),t[2]=i,t[3]=g);let _=g,v=i.length===1?``:`s`,b;t[4]!==i.length||t[5]!==v?(b=(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.length,` file`,v]}),t[4]=i.length,t[5]=v,t[6]=b):b=t[6];let S;t[7]===p?S=t[8]:(S=(0,H.jsxs)(`span`,{className:`text-xs text-green-500`,children:[`+`,p]}),t[7]=p,t[8]=S);let C;t[9]===_?C=t[10]:(C=(0,H.jsxs)(`span`,{className:`text-xs text-red-500`,children:[`-`,_]}),t[9]=_,t[10]=C);let w;t[11]!==b||t[12]!==S||t[13]!==C?(w=(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b,S,C]}),t[11]=b,t[12]=S,t[13]=C,t[14]=w):w=t[14];let T=w;if(a){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center pt-3 pb-2`,children:(0,H.jsx)(y,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),t[15]=e):e=t[15];let n;return t[16]===T?n=t[17]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[16]=T,t[17]=n),n}if(o){let e;t[18]===o?e=t[19]:(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-destructive text-xs text-center`,children:o})}),t[18]=o,t[19]=e);let n;return t[20]!==T||t[21]!==e?(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[20]=T,t[21]=e,t[22]=n):n=t[22],n}if(i.length===0){let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4 pt-7 pb-2`,children:(0,H.jsx)(`p`,{className:`text-muted-foreground text-xs text-center`,children:`No changes to review`})}),t[23]=e):e=t[23];let n;return t[24]===T?n=t[25]:(n=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:e}),t[24]=T,t[25]=n),n}let E;t[26]!==i||t[27]!==l||t[28]!==d||t[29]!==s?(E=(e,t)=>{let{isOpen:n,toggle:a}=t,o=!!e.children,f=(0,H.jsxs)(F,{onClick:()=>{o?a():e.fileIndex!==void 0&&l(e.fileIndex)},selected:!o&&e.fileIndex===s,className:`gap-1.5`,children:[o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(u,{className:m(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)}),n?(0,H.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,H.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}):(0,H.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`truncate flex-1 min-w-0`,children:e.name}),!o&&e.status&&(0,H.jsx)(`span`,{className:K(e.status),children:ue(e.status)})]});return o?f:(0,H.jsxs)(z,{children:[(0,H.jsx)(L,{asChild:!0,children:f}),(0,H.jsx)(R,{children:(0,H.jsxs)(ce,{onClick:()=>{e.fileIndex!==void 0&&d?.(i[e.fileIndex])},children:[(0,H.jsx)(h,{className:`mr-2 h-3.5 w-3.5`}),`Revert Change`]})})]})},t[26]=i,t[27]=l,t[28]=d,t[29]=s,t[30]=E):E=t[30];let D;t[31]!==E||t[32]!==n?(D=(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto pt-3 pb-2 px-1`,children:(0,H.jsx)(ne,{nodes:n,defaultOpen:!0,resetKey:n,indent:16,childContainerClassName:`ml-4 border-l border-sidebar-border pl-2`,renderNode:E})}),t[31]=E,t[32]=n,t[33]=D):D=t[33];let O;return t[34]!==T||t[35]!==D?(O=(0,H.jsx)(U,{title:`Review Changes`,headerAction:T,children:D}),t[34]=T,t[35]=D,t[36]=O):O=t[36],O}function q(e,t){return e+t.hunks.reduce(J,0)}function J(e,t){return e+t.changes.filter(fe).length}function fe(e){return e.type===`delete`}function pe(e,t){return e+t.hunks.reduce(Y,0)}function Y(e,t){return e+t.changes.filter(me).length}function me(e){return e.type===`add`}function he(e){let t=(0,V.c)(2),{isOpen:n}=e,r=n===void 0||n?`ml-[-40px]`:``,i;return t[0]===r?i=t[1]:(i=(0,H.jsx)(I,{withHandle:!0,className:r}),t[0]=r,t[1]=i),i}function ge(e){let t=(0,V.c)(35),{open:n,lineNumber:r,lineContent:i,initialComment:a,isEditing:o,onSave:c,onDelete:u,onClose:m}=e,[h,g]=(0,B.useState)((a===void 0?``:a)??``),_;t[0]!==c||t[1]!==h?(_=()=>{h.trim()&&c(h.trim())},t[0]=c,t[1]=h,t[2]=_):_=t[2];let v=_,y;t[3]===v?y=t[4]:(y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),v())},t[3]=v,t[4]=y);let b=y,x;t[5]===m?x=t[6]:(x=e=>{e||m()},t[5]=m,t[6]=x);let S;t[7]===r?S=t[8]:(S=(0,H.jsx)(s,{children:(0,H.jsxs)(f,{className:`text-sm font-medium`,children:[`Comment on line `,r]})}),t[7]=r,t[8]=S);let C=i||` `,w;t[9]===C?w=t[10]:(w=(0,H.jsx)(`div`,{className:`rounded bg-muted px-3 py-2 font-mono text-xs text-muted-foreground overflow-x-auto whitespace-pre`,children:C}),t[9]=C,t[10]=w);let T;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>g(e.target.value),t[11]=T):T=t[11];let E;t[12]!==b||t[13]!==h?(E=(0,H.jsx)(M,{autoFocus:!0,placeholder:`Add a comment... (Cmd+Enter to save)`,value:h,onChange:T,onKeyDown:b,rows:12,className:`resize-none text-sm`}),t[12]=b,t[13]=h,t[14]=E):E=t[14];let D;t[15]!==o||t[16]!==u?(D=o&&u&&(0,H.jsx)(l,{variant:`destructive`,size:`sm`,onClick:u,className:`mr-auto`,children:`Delete`}),t[15]=o,t[16]=u,t[17]=D):D=t[17];let O;t[18]===h?O=t[19]:(O=h.trim(),t[18]=h,t[19]=O);let k=!O,A;t[20]!==v||t[21]!==k?(A=(0,H.jsx)(l,{size:`sm`,onClick:v,disabled:k,children:`Save`}),t[20]=v,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==D||t[24]!==A?(j=(0,H.jsxs)(p,{className:`gap-2 sm:gap-0`,children:[D,A]}),t[23]=D,t[24]=A,t[25]=j):j=t[25];let N;t[26]!==j||t[27]!==S||t[28]!==w||t[29]!==E?(N=(0,H.jsxs)(ee,{className:`max-w-2xl`,children:[S,w,E,j]}),t[26]=j,t[27]=S,t[28]=w,t[29]=E,t[30]=N):N=t[30];let P;return t[31]!==n||t[32]!==N||t[33]!==x?(P=(0,H.jsx)(d,{open:n,onOpenChange:x,children:N}),t[31]=n,t[32]=N,t[33]=x,t[34]=P):P=t[34],P}function X({threadId:e,onExit:r}){let{state:a,dispatch:s}=A(),{resolvedTheme:c}=ie(),[d,f]=(0,B.useState)([]),[p,h]=(0,B.useState)(!0),[v,y]=(0,B.useState)(null),[x,S]=(0,B.useState)(0),[C,ee]=(0,B.useState)(!1),[M,ne]=(0,B.useState)(!1),F=(0,B.useRef)(null),I=(0,B.useMemo)(()=>a.diffComments[e]??[],[a.diffComments,e]),L=(0,B.useCallback)(t=>{let n=a.diffComments[e]??[],r=typeof t==`function`?t(n):t;s({type:j.SetDiffComments,threadId:e,comments:r})},[s,e,a.diffComments]),[R,ce]=(0,B.useState)(null),[z,V]=(0,B.useState)(null),[U,W]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(I),ue=(0,B.useRef)(R),q=(0,B.useRef)({isFullView:C,selectedFileIndex:x,files:d}),J=(0,B.useRef)({original:[],modified:[]}),fe=(0,B.useRef)(!0);(0,B.useEffect)(()=>{K.current=I},[I]),(0,B.useEffect)(()=>{ue.current=R},[R]),(0,B.useEffect)(()=>{q.current={isFullView:C,selectedFileIndex:x,files:d}},[C,x,d]);let pe=(0,B.useCallback)(()=>{F.current&&(M?F.current.expand():F.current.collapse())},[M]),Y=(0,B.useCallback)(async()=>{if(e){h(!0),y(null);try{f((await g(e)).files||[]),S(0)}catch(e){y(e instanceof Error?e.message:`Failed to load diff`)}finally{h(!1)}}},[e]);(0,B.useEffect)(()=>{Y()},[Y]);let me=(0,B.useCallback)(async t=>{try{await i(e,t.path),await Y()}catch(e){y(e instanceof Error?e.message:`Failed to revert file`)}},[e,Y]),X=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if((a.diffComments[e]??[]).length>0){X.current=!0;return}o(e).then(t=>{t.diffComments&&t.diffComments.length>0&&s({type:j.SetDiffComments,threadId:e,comments:t.diffComments}),X.current=!0}).catch(()=>{X.current=!0})},[e]),(0,B.useEffect)(()=>{X.current&&_(e,{diffComments:I}).catch(()=>{})},[e,I]);let _e=(0,B.useMemo)(()=>le(d),[d]),Z=e=>{if(e.hunks.length===0)return null;let t=1/0,n=0;return e.hunks.forEach(e=>{let r=Math.min(e.oldStart,e.newStart),i=e.oldStart+e.oldLines,a=e.newStart+e.newLines,o=Math.max(i,a);t=Math.min(t,r),n=Math.max(n,o)}),t===1/0?null:{startLine:Math.max(1,t-2),endLine:n+2}},ve=(e,t,n)=>e.split(`
2
- `).slice(t-1,n).join(`
3
- `),ye=e=>{let t=Z(e);return t?t.startLine<=1:!0},be=e=>({ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,scss:`scss`,html:`html`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,kt:`kotlin`,swift:`swift`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sh:`shell`,yaml:`yaml`,yml:`yaml`,xml:`xml`,sql:`sql`})[e.split(`.`).pop()??``]||`plaintext`,Q=d[x],xe=Q?C?Q.oldContent:(()=>{let e=Z(Q);return e?ve(Q.oldContent,e.startLine,e.endLine):Q.oldContent})():``,Se=Q?C?Q.newContent:(()=>{let e=Z(Q);return e?ve(Q.newContent,e.startLine,e.endLine):Q.newContent})():``,$=(0,B.useCallback)(()=>{if(!fe.current)return;let e=G.current;if(!e)return;let{isFullView:t,selectedFileIndex:n,files:r}=q.current,i=K.current,a=ue.current,o=r[n];if(!o)return;let s=(e,r)=>{let s=t?null:Z(o),c=i.filter(e=>e.fileIndex===n&&e.side===r).map(e=>{let t=s?e.lineNumber-s.startLine+1:e.lineNumber;if(t<1)return null;let n=i.indexOf(e)===a;return{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:n?`diff-comment-active-line`:`diff-comment-marked-line`,glyphMarginHoverMessage:{value:e.comment}}}}).filter(e=>e!==null),l=r===`original`?J.current.original:J.current.modified,u=e.deltaDecorations(l,c);r===`original`?J.current.original=u:J.current.modified=u};s(e.getOriginalEditor(),`original`),s(e.getModifiedEditor(),`modified`)},[]);(0,B.useEffect)(()=>{$()},[$,I,R,x,C,Q]),(0,B.useEffect)(()=>()=>{G.current=null,J.current={original:[],modified:[]}},[x]),(0,B.useEffect)(()=>()=>{fe.current=!1,G.current&&=(G.current.getOriginalEditor().getModel()?.dispose(),G.current.getModifiedEditor().getModel()?.dispose(),G.current.dispose(),null),J.current={original:[],modified:[]}},[]);let Ce=(0,B.useCallback)(e=>{G.current=e;let t=(e,t)=>{e.onMouseDown(n=>{if(!n.target?.position)return;let r=n.target.position.lineNumber,{isFullView:i,selectedFileIndex:a,files:o}=q.current,s=o[a];if(!s)return;let c=i?null:Z(s),l=c?c.startLine+r-1:r,u=e.getModel()?.getLineContent(r)??``,d=K.current.find(e=>e.fileIndex===a&&e.lineNumber===l&&e.side===t);d?W(d):V({lineNumber:l,lineContent:u,side:t})})};t(e.getOriginalEditor(),`original`),t(e.getModifiedEditor(),`modified`),setTimeout(()=>{G.current===e&&$()},150)},[$]),we=(0,B.useCallback)(e=>{if(z&&Q){let t={id:`comment-${Date.now()}`,filePath:Q.path,fileIndex:x,lineNumber:z.lineNumber,lineContent:z.lineContent,comment:e,side:z.side};L(e=>[...e,t]),V(null)}else U&&(L(t=>t.map(t=>t.id===U.id?{...t,comment:e}:t)),W(null))},[z,U,Q,x,L]),Te=(0,B.useCallback)(()=>{U&&(L(e=>e.filter(e=>e.id!==U.id)),W(null))},[U,L]),Ee=(0,B.useCallback)(e=>{if(I.length===0)return;let t=(e%I.length+I.length)%I.length,n=I[t];ce(t),S(n.fileIndex),setTimeout(()=>{let e=G.current;if(!e)return;let t=d[n.fileIndex];if(!t)return;let r=C?null:Z(t),i=r?n.lineNumber-r.startLine+1:n.lineNumber;(n.side===`original`?e.getOriginalEditor():e.getModifiedEditor()).revealLineInCenter(Math.max(1,i)),$()},100)},[I,d,C,$]),De=(0,B.useCallback)(()=>{Ee((R??0)-1)},[Ee,R]),Oe=(0,B.useCallback)(()=>{Ee((R??-1)+1)},[Ee,R]),ke=(0,B.useCallback)(async()=>{let n=a.projectModelSelections[e];if(!n)try{let e=await t(),r=Object.values(e).flat();if(r.length>0)n=r[0];else{console.error(`No models available to process comments`);return}}catch(e){console.error(`Failed to load models:`,e);return}let i=n.id,o=n.provider;try{let{prompt:t}=await E(e,I);L([]),s({type:j.SetPendingChatMessage,message:{threadId:e,message:t,model:i,provider:o}}),r()}catch(e){console.error(`Failed to fix comments:`,e),typeof window<`u`&&window.alert(`Failed to process comments. Please try again.`)}},[I,a.projectModelSelections,s,e,r,L]),Ae={readOnly:!0,renderSideBySide:!0,ignoreTrimWhitespace:!1,renderOverviewRuler:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},folding:!1,lineNumbers:Q&&(C||ye(Q))?`on`:`off`,diffWordWrap:`on`,originalEditable:!1,automaticLayout:!0};return(0,H.jsxs)(`div`,{className:`diff-view-root flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`diff-body flex flex-1 overflow-hidden`,children:(0,H.jsxs)(se,{direction:`horizontal`,children:[(0,H.jsx)(oe,{ref:F,defaultSize:25,minSize:12,maxSize:40,collapsible:!0,collapsedSize:0,onCollapse:()=>ne(!0),onExpand:()=>ne(!1),className:`border-r border-transparent`,children:(0,H.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,H.jsx)(de,{treeData:_e,files:d,isLoading:p,error:v,selectedFileIndex:x,onFileSelect:S,onRevertFile:me})})}),(0,H.jsx)(he,{isOpen:!M}),(0,H.jsx)(oe,{className:`overflow-hidden bg-transparent`,children:(0,H.jsxs)(`div`,{className:`diff-editor-panel flex h-full bg-transparent flex-col overflow-hidden`,children:[(0,H.jsxs)(ae,{className:m(`bg-transparent`,M&&`h-auto py-3 flex-col items-start gap-3 md:flex-row md:items-center md:h-[71px] md:py-0 md:gap-2 justify-between`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground shrink-0`,onClick:pe,children:[M?(0,H.jsx)(D,{className:`h-4 w-4`}):(0,H.jsx)(b,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Toggle file tree`})]}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:Q?Q.path:`Review Changes`})]}),(0,H.jsxs)(`div`,{className:m(`flex items-center gap-2`,M&&`ml-0`,!M&&`ml-auto`,`md:ml-auto`),children:[(0,H.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>ee(e=>!e),disabled:!Q,className:`h-8 gap-1 px-2 text-xs`,children:C?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(O,{className:`h-3 w-3`}),` Show changes only`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(w,{className:`h-3 w-3`}),` Show full file`]})}),I.length>0&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:De,disabled:(R??0)===0,children:(0,H.jsx)(n,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Previous comment`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:I.length===1?`1 Comment`:`Comment ${(R??0)+1} of ${I.length}`}),(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsx)(l,{variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-full`,onClick:Oe,disabled:(R??0)===I.length-1,children:(0,H.jsx)(u,{className:`h-3 w-3`})})}),(0,H.jsx)(N,{children:`Next comment`})]})]}),I.length>0&&(0,H.jsxs)(P,{children:[(0,H.jsx)(te,{asChild:!0,children:(0,H.jsxs)(l,{size:`sm`,onClick:ke,className:`h-8 gap-1 px-3 text-xs bg-foreground text-background hover:bg-foreground/90`,children:[(0,H.jsx)(T,{className:`h-3 w-3`}),`Fix all comments`]})}),(0,H.jsx)(N,{children:`Send all comments to Tarsk for resolution`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex-1 bg-transparent relative`,children:[(0,H.jsx)(k,{height:`100%`,language:be(Q?.path||``),original:xe,modified:Se,theme:c===`dark`?`vs-dark`:`vs-light`,onMount:Ce,options:Ae},`diff-${x}`),(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0`,children:(0,H.jsx)(re,{})})]})]})})]})}),(0,H.jsx)(ge,{open:z!==null||U!==null,lineNumber:U?.lineNumber??z?.lineNumber??0,lineContent:U?.lineContent??z?.lineContent??``,initialComment:U?.comment,isEditing:U!==null,onSave:we,onDelete:Te,onClose:()=>{V(null),W(null)}},`${U?.id??``}-${z?.lineNumber??``}-${z?.side??``}`)]})}export{X as DiffView,X as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/explorer-tree-KuYjR6r9.js","assets/rolldown-runtime-B1FJdls4.js","assets/dialogs-config-BEsTbY1C.js","assets/api-DQLZE-zX.js","assets/alert-dialog-DXEB8gMn.js","assets/react-vendor-QkuITxN7.js","assets/history-view-_L50vkTM.js","assets/monaco-c-HyCuEi.js","assets/context-menu-CThafUml.js","assets/standard-list-item-ByRgCvKd.js","assets/use-toast-BqYP6xbg.js","assets/tab-context-DBrXMyNd.js","assets/explorer-view-Cj6fyxMP.js","assets/page-toolbar-DM-x5q1_.js","assets/store-Dyy2UFdD.js","assets/utils-BavofGRh.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Cr as t,da as n,kn as r,la as i}from"./dialogs-config-BEsTbY1C.js";import{vt as a}from"./react-vendor-QkuITxN7.js";import{a as o}from"./store-Dyy2UFdD.js";import{n as s}from"./tab-context-DBrXMyNd.js";import{n as c,r as l,t as u}from"./resizable-GT3fWOfA.js";var d=i(),f=e(n(),1),p=t(),m=(0,f.lazy)(()=>a(()=>import(`./explorer-tree-KuYjR6r9.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),h=(0,f.lazy)(()=>a(()=>import(`./explorer-view-Cj6fyxMP.js`),__vite__mapDeps([12,1,5,6,2,7,3,13,10,14,15])));function g(){let e=(0,d.c)(17),{state:t}=o(),n=t.selectedThreadId,[i,a]=(0,f.useState)(null),{pendingExplorerPath:g,setPendingExplorerPath:v,explorerClearPath:y,setExplorerClearPath:b}=s(),x,S;e[0]!==g||e[1]!==v?(x=()=>{g&&(a({name:g.split(`/`).pop()??g,type:`file`,path:g}),v(null))},S=[g,v],e[0]=g,e[1]=v,e[2]=x,e[3]=S):(x=e[2],S=e[3]),(0,f.useEffect)(x,S);let C,w;e[4]!==y||e[5]!==b?(C=()=>{y&&(a(e=>e&&(e.path===y||e.path.startsWith(y+`/`)?null:e)),b(null))},w=[y,b],e[4]=y,e[5]=b,e[6]=C,e[7]=w):(C=e[6],w=e[7]),(0,f.useEffect)(C,w);let T;e[8]!==i?.path||e[9]!==n?(T=(0,p.jsx)(c,{defaultSize:25,minSize:15,maxSize:50,className:`overflow-hidden border-r border-border`,children:(0,p.jsx)(r,{className:`h-full`,children:n?(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`space-y-1 px-2 py-2`,children:[1,2,3].map(_)}),children:(0,p.jsx)(m,{threadId:n,selectedPath:i?.path??null,onFileSelect:a})}):(0,p.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No thread selected.`})})}),e[8]=i?.path,e[9]=n,e[10]=T):T=e[10];let E;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(u,{withHandle:!0}),e[11]=E):E=e[11];let D;e[12]===i?D=e[13]:(D=(0,p.jsx)(c,{className:`overflow-hidden`,children:(0,p.jsx)(f.Suspense,{fallback:null,children:(0,p.jsx)(h,{selectedFile:i})})}),e[12]=i,e[13]=D);let O;return e[14]!==T||e[15]!==D?(O=(0,p.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,p.jsxs)(l,{direction:`horizontal`,className:`flex-1 overflow-hidden`,children:[T,E,D]})}),e[14]=T,e[15]=D,e[16]=O):O=e[16],O}function _(e){return(0,p.jsx)(`div`,{className:`animate-pulse h-7 bg-muted rounded-full`},e)}export{g as default};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,An as n,Cr as r,Er as i,Hi as a,Ki as o,Pn as s,Qi as c,Sr as l,Tr as u,Wn as d,Zi as f,_r as p,a as m,ar as h,br as g,cr as _,da as v,ea as y,fr as b,hr as x,i as S,jn as C,kn as w,kr as T,la as E,lr as D,mr as O,n as k,or as A,r as j,rt as M,sr as N,ta as P,u as ee,ua as te,ur as ne,vr as re,xr as F,yr as ie}from"./dialogs-config-BEsTbY1C.js";var I=e(v(),1),L=e(te(),1),R=E(),z=r(),ae=[`top`,`right`,`bottom`,`left`],B=Math.min,V=Math.max,oe=Math.round,se=Math.floor,H=e=>({x:e,y:e}),ce={left:`right`,right:`left`,bottom:`top`,top:`bottom`},le={start:`end`,end:`start`};function ue(e,t,n){return V(e,B(t,n))}function U(e,t){return typeof e==`function`?e(t):e}function W(e){return e.split(`-`)[0]}function de(e){return e.split(`-`)[1]}function fe(e){return e===`x`?`y`:`x`}function pe(e){return e===`y`?`height`:`width`}var me=new Set([`top`,`bottom`]);function G(e){return me.has(W(e))?`y`:`x`}function he(e){return fe(G(e))}function ge(e,t,n){n===void 0&&(n=!1);let r=de(e),i=he(e),a=pe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Te(o)),[o,Te(o)]}function _e(e){let t=Te(e);return[ve(e),t,ve(t)]}function ve(e){return e.replace(/start|end/g,e=>le[e])}var ye=[`left`,`right`],be=[`right`,`left`],xe=[`top`,`bottom`],Se=[`bottom`,`top`];function Ce(e,t,n){switch(e){case`top`:case`bottom`:return n?t?be:ye:t?ye:be;case`left`:case`right`:return t?xe:Se;default:return[]}}function we(e,t,n,r){let i=de(e),a=Ce(W(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ve)))),a}function Te(e){return e.replace(/left|right|bottom|top/g,e=>ce[e])}function Ee(e){return{top:0,right:0,bottom:0,left:0,...e}}function De(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ee(e)}function Oe(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ke(e,t,n){let{reference:r,floating:i}=e,a=G(t),o=he(t),s=pe(o),c=W(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(de(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Ae(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=U(t,e),p=De(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Oe(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Oe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var je=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ke(l,r,c),f=r,p={},m=0;for(let n=0;n<s.length;n++){let{name:a,fn:h}=s[n],{x:g,y:_,data:v,reset:y}=await h({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:p,rects:l,platform:{...o,detectOverflow:o.detectOverflow??Ae},elements:{reference:e,floating:t}});u=g??u,d=_??d,p={...p,[a]:{...p[a],...v}},y&&m<=50&&(m++,typeof y==`object`&&(y.placement&&(f=y.placement),y.rects&&(l=y.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):y.rects),{x:u,y:d}=ke(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},Me=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=U(e,t)||{};if(l==null)return{};let d=De(u),f={x:n,y:r},p=he(i),m=pe(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=B(d[_],T),D=B(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=ue(O,A,k),M=!c.arrow&&de(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Ne=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=U(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=W(r),_=G(o),v=W(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Te(o)]:_e(o)),x=p!==`none`;!d&&x&&b.push(...we(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ge(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==G(t))||T.every(e=>G(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=G(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Pe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Fe(e){return ae.some(t=>e[t]>=0)}var Ie=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=U(e,t);switch(i){case`referenceHidden`:{let e=Pe(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Fe(e)}}}case`escaped`:{let e=Pe(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Fe(e)}}}default:return{}}}}},Le=new Set([`left`,`top`]);async function Re(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=W(n),s=de(n),c=G(n)===`y`,l=Le.has(o)?-1:1,u=a&&c?-1:1,d=U(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ze=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Re(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Be=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=U(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=G(W(i)),p=fe(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=ue(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=ue(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},Ve=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=U(e,t),u={x:n,y:r},d=G(i),f=fe(d),p=u[f],m=u[d],h=U(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Le.has(W(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},He=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=U(e,t),u=await o.detectOverflow(t,l),d=W(i),f=de(i),p=G(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=B(h-u[g],v),x=B(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=V(u.left,0),t=V(u.right,0),n=V(u.top,0),r=V(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:V(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:V(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ue(){return typeof window<`u`}function We(e){return Ge(e)?(e.nodeName||``).toLowerCase():`#document`}function K(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function q(e){return((Ge(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ge(e){return Ue()?e instanceof Node||e instanceof K(e).Node:!1}function J(e){return Ue()?e instanceof Element||e instanceof K(e).Element:!1}function Y(e){return Ue()?e instanceof HTMLElement||e instanceof K(e).HTMLElement:!1}function Ke(e){return!Ue()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof K(e).ShadowRoot}var qe=new Set([`inline`,`contents`]);function Je(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qe.has(i)}var Ye=new Set([`table`,`td`,`th`]);function Xe(e){return Ye.has(We(e))}var Ze=[`:popover-open`,`:modal`];function Qe(e){return Ze.some(t=>{try{return e.matches(t)}catch{return!1}})}var $e=[`transform`,`translate`,`scale`,`rotate`,`perspective`],et=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],tt=[`paint`,`layout`,`strict`,`content`];function nt(e){let t=it(),n=J(e)?X(e):e;return $e.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||et.some(e=>(n.willChange||``).includes(e))||tt.some(e=>(n.contain||``).includes(e))}function rt(e){let t=Z(e);for(;Y(t)&&!ot(t);){if(nt(t))return t;if(Qe(t))return null;t=Z(t)}return null}function it(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var at=new Set([`html`,`body`,`#document`]);function ot(e){return at.has(We(e))}function X(e){return K(e).getComputedStyle(e)}function st(e){return J(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(We(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ke(e)&&e.host||q(e);return Ke(t)?t.host:t}function ct(e){let t=Z(e);return ot(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&Je(t)?t:ct(t)}function lt(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ct(e),i=r===e.ownerDocument?.body,a=K(r);if(i){let e=ut(a);return t.concat(a,a.visualViewport||[],Je(r)?r:[],e&&n?lt(e):[])}return t.concat(r,lt(r,[],n))}function ut(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function dt(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Y(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=oe(n)!==a||oe(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ft(e){return J(e)?e:e.contextElement}function pt(e){let t=ft(e);if(!Y(t))return H(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=dt(t),o=(a?oe(n.width):n.width)/r,s=(a?oe(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var mt=H(0);function ht(e){let t=K(e);return!it()||!t.visualViewport?mt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function gt(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==K(e)?!1:t}function _t(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ft(e),o=H(1);t&&(r?J(r)&&(o=pt(r)):o=pt(e));let s=gt(a,n,r)?ht(a):H(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=K(a),t=r&&J(r)?K(r):r,n=e,i=ut(n);for(;i&&r&&t!==n;){let e=pt(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=K(i),i=ut(n)}}return Oe({width:u,height:d,x:c,y:l})}function vt(e,t){let n=st(e).scrollLeft;return t?t.left+n:_t(q(e)).left+n}function yt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-vt(e,n),y:n.top+t.scrollTop}}function bt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=q(r),s=t?Qe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=H(1),u=H(0),d=Y(r);if((d||!d&&!a)&&((We(r)!==`body`||Je(o))&&(c=st(r)),Y(r))){let e=_t(r);l=pt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?yt(o,c):H(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function xt(e){return Array.from(e.getClientRects())}function St(e){let t=q(e),n=st(e),r=e.ownerDocument.body,i=V(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=V(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+vt(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=V(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ct=25;function wt(e,t){let n=K(e),r=q(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=it();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=vt(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ct&&(a-=o)}else l<=Ct&&(a+=l);return{width:a,height:o,x:s,y:c}}var Tt=new Set([`absolute`,`fixed`]);function Et(e,t){let n=_t(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Y(e)?pt(e):H(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Dt(e,t,n){let r;if(t===`viewport`)r=wt(e,n);else if(t===`document`)r=St(q(e));else if(J(t))r=Et(t,n);else{let n=ht(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Oe(r)}function Ot(e,t){let n=Z(e);return n===t||!J(n)||ot(n)?!1:X(n).position===`fixed`||Ot(n,t)}function kt(e,t){let n=t.get(e);if(n)return n;let r=lt(e,[],!1).filter(e=>J(e)&&We(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;J(o)&&!ot(o);){let t=X(o),n=nt(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Tt.has(i.position)||Je(o)&&!n&&Ot(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function At(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Qe(t)?[]:kt(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=Dt(t,n,i);return e.top=V(r.top,e.top),e.right=B(r.right,e.right),e.bottom=B(r.bottom,e.bottom),e.left=V(r.left,e.left),e},Dt(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function jt(e){let{width:t,height:n}=dt(e);return{width:t,height:n}}function Mt(e,t,n){let r=Y(t),i=q(t),a=n===`fixed`,o=_t(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=H(0);function l(){c.x=vt(i)}if(r||!r&&!a)if((We(t)!==`body`||Je(i))&&(s=st(t)),r){let e=_t(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?yt(i,s):H(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Nt(e){return X(e).position===`static`}function Pt(e,t){if(!Y(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return q(e)===n&&(n=n.ownerDocument.body),n}function Ft(e,t){let n=K(e);if(Qe(e))return n;if(!Y(e)){let t=Z(e);for(;t&&!ot(t);){if(J(t)&&!Nt(t))return t;t=Z(t)}return n}let r=Pt(e,t);for(;r&&Xe(r)&&Nt(r);)r=Pt(r,t);return r&&ot(r)&&Nt(r)&&!nt(r)?n:r||rt(e)||n}var It=async function(e){let t=this.getOffsetParent||Ft,n=this.getDimensions,r=await n(e.floating);return{reference:Mt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lt(e){return X(e).direction===`rtl`}var Rt={convertOffsetParentRelativeRectToViewportRelativeRect:bt,getDocumentElement:q,getClippingRect:At,getOffsetParent:Ft,getElementRects:It,getClientRects:xt,getDimensions:jt,getScale:pt,isElement:J,isRTL:Lt};function zt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bt(e,t){let n=null,r,i=q(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=se(d),h=se(i.clientWidth-(u+f)),g=se(i.clientHeight-(d+p)),_=se(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:V(0,B(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!zt(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Vt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=ft(e),u=i||a?[...l?lt(l):[],...lt(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Bt(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?_t(e):null;c&&g();function g(){let t=_t(e);h&&!zt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ht=ze,Ut=Be,Wt=Ne,Gt=He,Kt=Ie,qt=Me,Jt=Ve,Yt=(e,t,n)=>{let r=new Map,i={platform:Rt,...n},a={...i.platform,_c:r};return je(e,t,{...i,platform:a})},Xt=typeof document<`u`?I.useLayoutEffect:function(){};function Zt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Zt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Qt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $t(e,t){let n=Qt(e);return Math.round(t*n)/n}function en(e){let t=I.useRef(e);return Xt(()=>{t.current=e}),t}function tn(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=I.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=I.useState(r);Zt(f,r)||p(r);let[m,h]=I.useState(null),[g,_]=I.useState(null),v=I.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=I.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=I.useRef(null),C=I.useRef(null),w=I.useRef(u),T=c!=null,E=en(c),D=en(i),O=en(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Yt(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Zt(w.current,t)&&(w.current=t,L.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Xt(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);Xt(()=>(A.current=!0,()=>{A.current=!1}),[]),Xt(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=I.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=I.useMemo(()=>({reference:b,floating:x}),[b,x]),N=I.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=$t(M.floating,u.x),r=$t(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Qt(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return I.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var nn=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:qt({element:r.current,padding:i}).fn(n):r?qt({element:r,padding:i}).fn(n):{}}}},rn=(e,t)=>({...Ht(e),options:[e,t]}),an=(e,t)=>({...Ut(e),options:[e,t]}),on=(e,t)=>({...Jt(e),options:[e,t]}),sn=(e,t)=>({...Wt(e),options:[e,t]}),cn=(e,t)=>({...Gt(e),options:[e,t]}),ln=(e,t)=>({...Kt(e),options:[e,t]}),un=(e,t)=>({...nn(e),options:[e,t]}),dn=`Arrow`,fn=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,z.jsx)(x.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,z.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});fn.displayName=dn;var pn=fn;function mn(e){let[t,n]=I.useState(void 0);return F(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var hn=`Popper`,[gn,_n]=l(hn),[vn,yn]=gn(hn),bn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null);return(0,z.jsx)(vn,{scope:t,anchor:r,onAnchorChange:i,children:n})};bn.displayName=hn;var xn=`PopperAnchor`,Sn=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=yn(xn,n),o=I.useRef(null),s=u(t,o),c=I.useRef(null);return I.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,z.jsx)(x.div,{...i,ref:s})});Sn.displayName=xn;var Cn=`PopperContent`,[wn,Tn]=gn(Cn),En=I.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f=`partial`,hideWhenDetached:p=!1,updatePositionStrategy:m=`optimized`,onPlaced:h,...g}=e,_=yn(Cn,n),[v,y]=I.useState(null),b=u(t,e=>y(e)),[S,C]=I.useState(null),w=mn(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),k=typeof d==`number`?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(l)?l:[l],j=A.length>0,M={padding:k,boundary:A.filter(An),altBoundary:j},{refs:N,floatingStyles:P,placement:ee,isPositioned:te,middlewareData:ne}=tn({strategy:`fixed`,placement:D,whileElementsMounted:(...e)=>Vt(...e,{animationFrame:m===`always`}),elements:{reference:_.anchor},middleware:[rn({mainAxis:i+E,alignmentAxis:o}),c&&an({mainAxis:!0,crossAxis:!1,limiter:f===`partial`?on():void 0,...M}),c&&sn({...M}),cn({...M,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),S&&un({element:S,padding:s}),jn({arrowWidth:T,arrowHeight:E}),p&&ln({strategy:`referenceHidden`,...M})]}),[re,ie]=Mn(ee),L=O(h);F(()=>{te&&L?.()},[te,L]);let R=ne.arrow?.x,ae=ne.arrow?.y,B=ne.arrow?.centerOffset!==0,[V,oe]=I.useState();return F(()=>{v&&oe(window.getComputedStyle(v).zIndex)},[v]),(0,z.jsx)(`div`,{ref:N.setFloating,"data-radix-popper-content-wrapper":``,style:{...P,transform:te?P.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:V,"--radix-popper-transform-origin":[ne.transformOrigin?.x,ne.transformOrigin?.y].join(` `),...ne.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,z.jsx)(wn,{scope:n,placedSide:re,onArrowChange:C,arrowX:R,arrowY:ae,shouldHideArrow:B,children:(0,z.jsx)(x.div,{"data-side":re,"data-align":ie,...g,ref:b,style:{...g.style,animation:te?void 0:`none`}})})})});En.displayName=Cn;var Dn=`PopperArrow`,On={top:`bottom`,right:`left`,bottom:`top`,left:`right`},kn=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Tn(Dn,n),a=On[i.placedSide];return(0,z.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,z.jsx)(pn,{...r,ref:t,style:{...r.style,display:`block`}})})});kn.displayName=Dn;function An(e){return e!==null}var jn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Mn(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Mn(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Nn=bn,Pn=Sn,Fn=En,In=kn,Ln=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`}),Rn=`VisuallyHidden`,zn=I.forwardRef((e,t)=>(0,z.jsx)(x.span,{...e,ref:t,style:{...Ln,...e.style}}));zn.displayName=Rn;var Bn=zn,[Vn,Hn]=l(`Tooltip`,[_n]),Un=_n(),Wn=`TooltipProvider`,Gn=700,Kn=`tooltip.open`,[qn,Jn]=Vn(Wn),Yn=e=>{let{__scopeTooltip:t,delayDuration:n=Gn,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=I.useRef(!0),s=I.useRef(!1),c=I.useRef(0);return I.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(qn,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:I.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:I.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:I.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Yn.displayName=Wn;var Xn=`Tooltip`,[Zn,Qn]=Vn(Xn),$n=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Jn(Xn,e.__scopeTooltip),l=Un(t),[u,d]=I.useState(null),f=g(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,_=I.useRef(!1),[v,y]=ie({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Kn))):c.onClose(),a?.(e)},caller:Xn}),b=I.useMemo(()=>v?_.current?`delayed-open`:`instant-open`:`closed`,[v]),x=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_.current=!1,y(!0)},[y]),S=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y(!1)},[y]),C=I.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{_.current=!0,y(!0),p.current=0},h)},[h,y]);return I.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,z.jsx)(Nn,{...l,children:(0,z.jsx)(Zn,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:I.useCallback(()=>{c.isOpenDelayedRef.current?C():x()},[c.isOpenDelayedRef,C,x]),onTriggerLeave:I.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:x,onClose:S,disableHoverableContent:m,children:n})})};$n.displayName=Xn;var er=`TooltipTrigger`,tr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,a=Qn(er,n),o=Jn(er,n),s=Un(n),c=u(t,I.useRef(null),a.onTriggerChange),l=I.useRef(!1),d=I.useRef(!1),f=I.useCallback(()=>l.current=!1,[]);return I.useEffect(()=>()=>document.removeEventListener(`pointerup`,f),[f]),(0,z.jsx)(Pn,{asChild:!0,...s,children:(0,z.jsx)(x.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:c,onPointerMove:i(e.onPointerMove,e=>{e.pointerType!==`touch`&&!d.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:i(e.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:i(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,f,{once:!0})}),onFocus:i(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:i(e.onBlur,a.onClose),onClick:i(e.onClick,a.onClose)})})});tr.displayName=er;var nr=`TooltipPortal`,[rr,ir]=Vn(nr,{forceMount:void 0}),ar=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Qn(nr,t);return(0,z.jsx)(rr,{scope:t,forceMount:n,children:(0,z.jsx)(_,{present:n||a.open,children:(0,z.jsx)(D,{asChild:!0,container:i,children:r})})})};ar.displayName=nr;var or=`TooltipContent`,sr=I.forwardRef((e,t)=>{let n=ir(or,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Qn(or,e.__scopeTooltip);return(0,z.jsx)(_,{present:r||o.open,children:o.disableHoverableContent?(0,z.jsx)(fr,{side:i,...a,ref:t}):(0,z.jsx)(cr,{side:i,...a,ref:t})})}),cr=I.forwardRef((e,t)=>{let n=Qn(or,e.__scopeTooltip),r=Jn(or,e.__scopeTooltip),i=I.useRef(null),a=u(t,i),[o,s]=I.useState(null),{trigger:c,onClose:l}=n,d=i.current,{onPointerInTransitChange:f}=r,p=I.useCallback(()=>{s(null),f(!1)},[f]),m=I.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=gr(r,hr(r,n.getBoundingClientRect())),a=_r(t.getBoundingClientRect());s(yr([...i,...a])),f(!0)},[f]);return I.useEffect(()=>()=>p(),[p]),I.useEffect(()=>{if(c&&d){let e=e=>m(e,d),t=e=>m(e,c);return c.addEventListener(`pointerleave`,e),d.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),d.removeEventListener(`pointerleave`,t)}}},[c,d,m,p]),I.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||d?.contains(t),i=!vr(n,o);r?p():i&&(p(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,d,o,l,p]),(0,z.jsx)(fr,{...e,ref:a})}),[lr,ur]=Vn(Xn,{isInside:!1}),dr=re(`TooltipContent`),fr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Qn(or,n),l=Un(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(Kn,u),()=>document.removeEventListener(Kn,u)),[u]),I.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(b,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(Fn,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.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,z.jsx)(dr,{children:r}),(0,z.jsx)(lr,{scope:n,isInside:!0,children:(0,z.jsx)(Bn,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});sr.displayName=or;var pr=`TooltipArrow`,mr=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Un(n);return ur(pr,n).isInside?null:(0,z.jsx)(In,{...i,...r,ref:t})});mr.displayName=pr;function hr(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function gr(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _r(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function vr(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function yr(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:+(e.y>t.y)),br(t)}function br(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var xr=Yn,Sr=$n,Cr=tr,wr=sr,Tr=xr,Er=Sr,Dr=Cr,Or=I.forwardRef((e,t)=>{let n=(0,R.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,sideOffset:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0?4:a,s;n[4]===r?s=n[5]:(s=d(`z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md 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`,r),n[4]=r,n[5]=s);let c;return n[6]!==i||n[7]!==t||n[8]!==o||n[9]!==s?(c=(0,z.jsx)(wr,{ref:t,sideOffset:o,className:s,...i}),n[6]=i,n[7]=t,n[8]=o,n[9]=s,n[10]=c):c=n[10],c});Or.displayName=wr.displayName;function kr(e){let t=I.useRef({value:e,previous:e});return I.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ar=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`w-full caption-bottom text-sm`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,z.jsx)(`table`,{ref:t,className:a,...i})}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ar.displayName=`Table`;var jr=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`[&_tr]:border-b`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`thead`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});jr.displayName=`TableHeader`;var Mr=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`[&_tr:last-child]:border-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`tbody`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Mr.displayName=`TableBody`;var Nr=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`tfoot`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Nr.displayName=`TableFooter`;var Pr=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`tr`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Pr.displayName=`TableRow`;var Q=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`th`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Q.displayName=`TableHead`;var Fr=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`td`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Fr.displayName=`TableCell`;var Ir=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`mt-4 text-sm text-muted-foreground`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(`caption`,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ir.displayName=`TableCaption`;var Lr=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Rr=[` `,`Enter`],zr=`Select`,[Br,Vr,Hr]=ee(zr),[Ur,Wr]=l(zr,[Hr,_n]),Gr=_n(),[Kr,qr]=Ur(zr),[Jr,Yr]=Ur(zr),Xr=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Gr(t),[_,v]=I.useState(null),[y,b]=I.useState(null),[x,S]=I.useState(!1),w=C(l),[T,E]=ie({prop:r,defaultProp:i??!1,onChange:a,caller:zr}),[D,O]=ie({prop:o,defaultProp:s,onChange:c,caller:zr}),k=I.useRef(null),A=_?m||!!_.closest(`form`):!0,[j,M]=I.useState(new Set),N=Array.from(j).map(e=>e.props.value).join(`;`);return(0,z.jsx)(Nn,{...h,children:(0,z.jsxs)(Kr,{required:p,scope:t,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:g(),value:D,onValueChange:O,open:T,onOpenChange:E,dir:w,triggerPointerDownPosRef:k,disabled:f,children:[(0,z.jsx)(Br.Provider,{scope:t,children:(0,z.jsx)(Jr,{scope:e.__scopeSelect,onNativeOptionAdd:I.useCallback(e=>{M(t=>new Set(t).add(e))},[]),onNativeOptionRemove:I.useCallback(e=>{M(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),A?(0,z.jsxs)(Wi,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:D,onChange:e=>O(e.target.value),disabled:f,form:m,children:[D===void 0?(0,z.jsx)(`option`,{value:``}):null,Array.from(j)]},N):null]})})};Xr.displayName=zr;var Zr=`SelectTrigger`,Qr=I.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...a}=e,o=Gr(n),s=qr(Zr,n),c=s.disabled||r,l=u(t,s.onTriggerChange),d=Vr(n),f=I.useRef(`touch`),[p,m,h]=Ki(e=>{let t=d().filter(e=>!e.disabled),n=qi(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),g=e=>{c||(s.onOpenChange(!0),h()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,z.jsx)(Pn,{asChild:!0,...o,children:(0,z.jsx)(x.button,{type:`button`,role:`combobox`,"aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":Gi(s.value)?``:void 0,...a,ref:l,onClick:i(a.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:i(a.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:i(a.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&Lr.includes(e.key)&&(g(),e.preventDefault())})})})});Qr.displayName=Zr;var $r=`SelectValue`,ei=I.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=qr($r,n),{onValueNodeHasChildrenChange:l}=c,d=a!==void 0,f=u(t,c.onValueNodeChange);return F(()=>{l(d)},[l,d]),(0,z.jsx)(x.span,{...s,ref:f,style:{pointerEvents:`none`},children:Gi(c.value)?(0,z.jsx)(z.Fragment,{children:o}):a})});ei.displayName=$r;var ti=`SelectIcon`,ni=I.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,z.jsx)(x.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ni.displayName=ti;var ri=`SelectPortal`,ii=e=>(0,z.jsx)(D,{asChild:!0,...e});ii.displayName=ri;var ai=`SelectContent`,oi=I.forwardRef((e,t)=>{let n=qr(ai,e.__scopeSelect),[r,i]=I.useState();if(F(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?L.createPortal((0,z.jsx)(si,{scope:e.__scopeSelect,children:(0,z.jsx)(Br.Slot,{scope:e.__scopeSelect,children:(0,z.jsx)(`div`,{children:e.children})})}),t):null}return(0,z.jsx)(di,{...e,ref:t})});oi.displayName=ai;var $=10,[si,ci]=Ur(ai),li=`SelectContentImpl`,ui=p(`SelectContent.RemoveScroll`),di=I.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y,...x}=e,S=qr(ai,n),[C,w]=I.useState(null),[T,E]=I.useState(null),D=u(t,e=>w(e)),[O,k]=I.useState(null),[j,M]=I.useState(null),P=Vr(n),[ee,te]=I.useState(!1),re=I.useRef(!1);I.useEffect(()=>{if(C)return h(C)},[C]),N();let F=I.useCallback(e=>{let[t,...n]=P().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==i))return},[P,T]),ie=I.useCallback(()=>F([O,C]),[F,O,C]);I.useEffect(()=>{ee&&ie()},[ee,ie]);let{onOpenChange:L,triggerPointerDownPosRef:R}=S;I.useEffect(()=>{if(C){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(R.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(R.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():C.contains(n.target)||L(!1),document.removeEventListener(`pointermove`,t),R.current=null};return R.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[C,L,R]),I.useEffect(()=>{let e=()=>L(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[L]);let[ae,B]=Ki(e=>{let t=P().filter(e=>!e.disabled),n=qi(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),V=I.useCallback((e,t,n)=>{let r=!re.current&&!n;(S.value!==void 0&&S.value===t||r)&&(k(e),r&&(re.current=!0))},[S.value]),oe=I.useCallback(()=>C?.focus(),[C]),se=I.useCallback((e,t,n)=>{let r=!re.current&&!n;(S.value!==void 0&&S.value===t||r)&&M(e)},[S.value]),H=r===`popper`?hi:pi,ce=H===hi?{side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y}:{};return(0,z.jsx)(si,{scope:n,content:C,viewport:T,onViewportChange:E,itemRefCallback:V,selectedItem:O,onItemLeave:oe,itemTextRefCallback:se,focusSelectedItem:ie,selectedItemText:j,position:r,isPositioned:ee,searchRef:ae,children:(0,z.jsx)(A,{as:ui,allowPinchZoom:!0,children:(0,z.jsx)(ne,{asChild:!0,trapped:S.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:i(a,e=>{S.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,z.jsx)(b,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:(0,z.jsx)(H,{role:`listbox`,id:S.contentId,"data-state":S.open?`open`:`closed`,dir:S.dir,onContextMenu:e=>e.preventDefault(),...x,...ce,onPlaced:()=>te(!0),ref:D,style:{display:`flex`,flexDirection:`column`,outline:`none`,...x.style},onKeyDown:i(x.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&B(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=P().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})});di.displayName=li;var fi=`SelectItemAlignedPosition`,pi=I.forwardRef((e,t)=>{let{__scopeSelect:r,onPlaced:i,...a}=e,o=qr(ai,r),s=ci(ai,r),[c,l]=I.useState(null),[d,f]=I.useState(null),p=u(t,e=>f(e)),m=Vr(r),h=I.useRef(!1),g=I.useRef(!0),{viewport:_,selectedItem:v,selectedItemText:y,focusSelectedItem:b}=s,S=I.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&d&&_&&v&&y){let e=o.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),r=o.valueNode.getBoundingClientRect(),a=y.getBoundingClientRect();if(o.dir!==`rtl`){let i=a.left-t.left,o=r.left-i,s=e.left-o,l=e.width+s,u=Math.max(l,t.width),d=window.innerWidth-$,f=n(o,[$,Math.max($,d-u)]);c.style.minWidth=l+`px`,c.style.left=f+`px`}else{let i=t.right-a.right,o=window.innerWidth-r.right-i,s=window.innerWidth-e.right-o,l=e.width+s,u=Math.max(l,t.width),d=window.innerWidth-$,f=n(o,[$,Math.max($,d-u)]);c.style.minWidth=l+`px`,c.style.right=f+`px`}let s=m(),l=window.innerHeight-$*2,u=_.scrollHeight,f=window.getComputedStyle(d),p=parseInt(f.borderTopWidth,10),g=parseInt(f.paddingTop,10),b=parseInt(f.borderBottomWidth,10),x=parseInt(f.paddingBottom,10),S=p+g+u+x+b,C=Math.min(v.offsetHeight*5,S),w=window.getComputedStyle(_),T=parseInt(w.paddingTop,10),E=parseInt(w.paddingBottom,10),D=e.top+e.height/2-$,O=l-D,k=v.offsetHeight/2,A=v.offsetTop+k,j=p+g+A,M=S-j;if(j<=D){let e=s.length>0&&v===s[s.length-1].ref.current;c.style.bottom=`0px`;let t=d.clientHeight-_.offsetTop-_.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+b);c.style.height=n+`px`}else{let e=s.length>0&&v===s[0].ref.current;c.style.top=`0px`;let t=Math.max(D,p+_.offsetTop+(e?T:0)+k)+M;c.style.height=t+`px`,_.scrollTop=j-D+_.offsetTop}c.style.margin=`${$}px 0`,c.style.minHeight=C+`px`,c.style.maxHeight=l+`px`,i?.(),requestAnimationFrame(()=>h.current=!0)}},[m,o.trigger,o.valueNode,c,d,_,v,y,o.dir,i]);F(()=>S(),[S]);let[C,w]=I.useState();return F(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]),(0,z.jsx)(gi,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:I.useCallback(e=>{e&&g.current===!0&&(S(),b?.(),g.current=!1)},[S,b]),children:(0,z.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,z.jsx)(x.div,{...a,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.style}})})})});pi.displayName=fi;var mi=`SelectPopperPosition`,hi=I.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=$,...a}=e,o=Gr(n);return(0,z.jsx)(Fn,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});hi.displayName=mi;var[gi,_i]=Ur(ai,{}),vi=`SelectViewport`,yi=I.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...a}=e,o=ci(vi,n),s=_i(vi,n),c=u(t,o.onViewportChange),l=I.useRef(0);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,z.jsx)(Br.Slot,{scope:n,children:(0,z.jsx)(x.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:i(a.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-$*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})});yi.displayName=vi;var bi=`SelectGroup`,[xi,Si]=Ur(bi),Ci=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=g();return(0,z.jsx)(xi,{scope:n,id:i,children:(0,z.jsx)(x.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Ci.displayName=bi;var wi=`SelectLabel`,Ti=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Si(wi,n);return(0,z.jsx)(x.div,{id:i.id,...r,ref:t})});Ti.displayName=wi;var Ei=`SelectItem`,[Di,Oi]=Ur(Ei),ki=I.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:a=!1,textValue:o,...s}=e,c=qr(Ei,n),l=ci(Ei,n),d=c.value===r,[f,p]=I.useState(o??``),[m,h]=I.useState(!1),_=u(t,e=>l.itemRefCallback?.(e,r,a)),v=g(),y=I.useRef(`touch`),b=()=>{a||(c.onValueChange(r),c.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,z.jsx)(Di,{scope:n,value:r,disabled:a,textId:v,isSelected:d,onItemTextChange:I.useCallback(e=>{p(t=>t||(e?.textContent??``).trim())},[]),children:(0,z.jsx)(Br.ItemSlot,{scope:n,value:r,disabled:a,textValue:f,children:(0,z.jsx)(x.div,{role:`option`,"aria-labelledby":v,"data-highlighted":m?``:void 0,"aria-selected":d&&m,"data-state":d?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...s,ref:_,onFocus:i(s.onFocus,()=>h(!0)),onBlur:i(s.onBlur,()=>h(!1)),onClick:i(s.onClick,()=>{y.current!==`mouse`&&b()}),onPointerUp:i(s.onPointerUp,()=>{y.current===`mouse`&&b()}),onPointerDown:i(s.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:i(s.onPointerMove,e=>{y.current=e.pointerType,a?l.onItemLeave?.():y.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:i(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:i(s.onKeyDown,e=>{l.searchRef?.current!==``&&e.key===` `||(Rr.includes(e.key)&&b(),e.key===` `&&e.preventDefault())})})})})});ki.displayName=Ei;var Ai=`SelectItemText`,ji=I.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=qr(Ai,n),s=ci(Ai,n),c=Oi(Ai,n),l=Yr(Ai,n),[d,f]=I.useState(null),p=u(t,e=>f(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),m=d?.textContent,h=I.useMemo(()=>(0,z.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return F(()=>(g(h),()=>_(h)),[g,_,h]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(x.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?L.createPortal(a.children,o.valueNode):null]})});ji.displayName=Ai;var Mi=`SelectItemIndicator`,Ni=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Oi(Mi,n).isSelected?(0,z.jsx)(x.span,{"aria-hidden":!0,...r,ref:t}):null});Ni.displayName=Mi;var Pi=`SelectScrollUpButton`,Fi=I.forwardRef((e,t)=>{let n=ci(Pi,e.__scopeSelect),r=_i(Pi,e.__scopeSelect),[i,a]=I.useState(!1),o=u(t,r.onScrollButtonChange);return F(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,z.jsx)(Ri,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Fi.displayName=Pi;var Ii=`SelectScrollDownButton`,Li=I.forwardRef((e,t)=>{let n=ci(Ii,e.__scopeSelect),r=_i(Ii,e.__scopeSelect),[i,a]=I.useState(!1),o=u(t,r.onScrollButtonChange);return F(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,z.jsx)(Ri,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Li.displayName=Ii;var Ri=I.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...a}=e,o=ci(`SelectScrollButton`,n),s=I.useRef(null),c=Vr(n),l=I.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return I.useEffect(()=>()=>l(),[l]),F(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,z.jsx)(x.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:i(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:i(a.onPointerMove,()=>{o.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:i(a.onPointerLeave,()=>{l()})})}),zi=`SelectSeparator`,Bi=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,z.jsx)(x.div,{"aria-hidden":!0,...r,ref:t})});Bi.displayName=zi;var Vi=`SelectArrow`,Hi=I.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Gr(n),a=qr(Vi,n),o=ci(Vi,n);return a.open&&o.position===`popper`?(0,z.jsx)(In,{...i,...r,ref:t}):null});Hi.displayName=Vi;var Ui=`SelectBubbleInput`,Wi=I.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=I.useRef(null),a=u(r,i),o=kr(t);return I.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,z.jsx)(x.select,{...n,style:{...Ln,...n.style},ref:a,defaultValue:t})});Wi.displayName=Ui;function Gi(e){return e===``||e===void 0}function Ki(e){let t=O(e),n=I.useRef(``),r=I.useRef(0),i=I.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=I.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function qi(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ji(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ji(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yi=Xr,Xi=Qr,Zi=ei,Qi=ni,$i=ii,ea=oi,ta=yi,na=Ti,ra=ki,ia=ji,aa=Ni,oa=Fi,sa=Li,ca=Bi,la=Yi,ua=Zi,da=I.forwardRef((e,t)=>{let n=(0,R.c)(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=d(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(Qi,{asChild:!0,children:(0,z.jsx)(y,{className:`h-4 w-4 opacity-50`})}),n[6]=s):s=n[6];let c;return n[7]!==r||n[8]!==a||n[9]!==t||n[10]!==o?(c=(0,z.jsxs)(Xi,{ref:t,className:o,...a,children:[r,s]}),n[7]=r,n[8]=a,n[9]=t,n[10]=o,n[11]=c):c=n[11],c});da.displayName=Xi.displayName;var fa=I.forwardRef((e,t)=>{let n=(0,R.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`flex cursor-default items-center justify-center py-1`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(f,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,z.jsx)(oa,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});fa.displayName=oa.displayName;var pa=I.forwardRef((e,t)=>{let n=(0,R.c)(10),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`flex cursor-default items-center justify-center py-1`,r),n[3]=r,n[4]=a);let o;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(y,{className:`h-4 w-4`}),n[5]=o):o=n[5];let s;return n[6]!==i||n[7]!==t||n[8]!==a?(s=(0,z.jsx)(sa,{ref:t,className:a,...i,children:o}),n[6]=i,n[7]=t,n[8]=a,n[9]=s):s=n[9],s});pa.displayName=sa.displayName;var ma=I.forwardRef((e,t)=>{let n=(0,R.c)(21),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,children:r,position:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?`popper`:o,c=s===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,l;n[5]!==i||n[6]!==c?(l=d(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,c,i),n[5]=i,n[6]=c,n[7]=l):l=n[7];let u;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,z.jsx)(fa,{}),n[8]=u):u=n[8];let f=s===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`,p;n[9]===f?p=n[10]:(p=d(`p-1`,f),n[9]=f,n[10]=p);let m;n[11]!==r||n[12]!==p?(m=(0,z.jsx)(ta,{className:p,children:r}),n[11]=r,n[12]=p,n[13]=m):m=n[13];let h;n[14]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,z.jsx)(pa,{}),n[14]=h):h=n[14];let g;return n[15]!==s||n[16]!==a||n[17]!==t||n[18]!==l||n[19]!==m?(g=(0,z.jsx)($i,{children:(0,z.jsxs)(ea,{ref:t,className:l,position:s,...a,children:[u,m,h]})}),n[15]=s,n[16]=a,n[17]=t,n[18]=l,n[19]=m,n[20]=g):g=n[20],g});ma.displayName=ea.displayName;var ha=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`py-1.5 pl-8 pr-2 text-sm font-semibold`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(na,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});ha.displayName=na.displayName;var ga=I.forwardRef((e,t)=>{let n=(0,R.c)(14),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=d(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,i),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,z.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,z.jsx)(aa,{children:(0,z.jsx)(P,{className:`h-4 w-4`})})}),n[6]=s):s=n[6];let c;n[7]===r?c=n[8]:(c=(0,z.jsx)(ia,{children:r}),n[7]=r,n[8]=c);let l;return n[9]!==a||n[10]!==t||n[11]!==o||n[12]!==c?(l=(0,z.jsxs)(ra,{ref:t,className:o,...a,children:[s,c]}),n[9]=a,n[10]=t,n[11]=o,n[12]=c,n[13]=l):l=n[13],l});ga.displayName=ra.displayName;var _a=I.forwardRef((e,t)=>{let n=(0,R.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=d(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,z.jsx)(ca,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});_a.displayName=ca.displayName;var va=`__ALL_PROJECTS__`;function ya(e){let t=(0,R.c)(8),{text:n,maxLength:r}=e,i=r===void 0?100:r;if(n.length<=i){let e;return t[0]===n?e=t[1]:(e=(0,z.jsx)(z.Fragment,{children:n}),t[0]=n,t[1]=e),e}let a;t[2]!==i||t[3]!==n?(a=n.substring(0,i),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,z.jsx)(`span`,{className:`text-muted-foreground ml-2`,children:`...`}),t[5]=o):o=t[5];let s;return t[6]===a?s=t[7]:(s=(0,z.jsxs)(z.Fragment,{children:[a,o]}),t[6]=a,t[7]=s),s}function ba(e,t){let n=`${t} - `,r=e.title??e.threadId;return r.startsWith(n)?r.slice(n.length):r}async function xa(e){let t=[],n=new Set,r=``;for(let i of e)try{let e=await M(i.threadId);e?.messages&&(t.push(...e.messages),e.conversationIds&&e.conversationIds.forEach(e=>n.add(e)),e.lastUpdated>r&&(r=e.lastUpdated))}catch(e){console.warn(`Failed to load history for thread ${i.threadId}:`,e)}return t.sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),{messages:t,conversationIds:Array.from(n),lastUpdated:r??new Date().toISOString()}}function Sa({isOpen:e,onClose:n,initialFilter:r,projects:i,inline:l}){let[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(!1),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(0),[y,b]=(0,I.useState)(``),[x,C]=(0,I.useState)(``),E=(0,I.useCallback)(async e=>{p(!0),g(null);try{d(await M(e))}catch(e){g(e instanceof Error?e.message:`Failed to load conversation history`)}finally{p(!1)}},[]),D=(0,I.useCallback)(async e=>{if(e){p(!0),g(null);try{let t=i.find(t=>t.projectId===e);if(!t||t.threads.length===0){d({threadId:e,messages:[],lastUpdated:new Date().toISOString(),conversationIds:[]});return}d({threadId:e,...await xa(t.threads)})}catch(e){g(e instanceof Error?e.message:`Failed to load project history`)}finally{p(!1)}}},[i]),O=(0,I.useCallback)(async()=>{p(!0),g(null);try{d({threadId:va,...await xa(i.flatMap(e=>e.threads))})}catch(e){g(e instanceof Error?e.message:`Failed to load all projects history`)}finally{p(!1)}},[i]);(0,I.useEffect)(()=>{e&&r?r.type===`thread`?(C(r.id),b(``),v(0),E(r.id)):r.type===`project`&&(b(r.id),C(``),v(0),D(r.id)):e||(d(null),C(``),b(``),v(0),g(null))},[e,r,E,D]);let A=e=>{C(e),b(``),v(0),E(e)},N=e=>{b(e),C(``),v(0),e===va?O():D(e)},P=e=>new Date(e).toLocaleString(),ee=(e,t)=>{let n=new Date(e),r=new Date(t).getTime()-n.getTime();if(r<0)return{display:`0:00`,tooltip:`0 seconds`};let i=Math.floor(r/1e3),a=Math.floor(i/60),o=i%60,s=`${a}:${o.toString().padStart(2,`0`)}`,c;return c=a===0?`${o} second${o===1?``:`s`}`:o===0?`${a} minute${a===1?``:`s`}`:`${a} minute${a===1?``:`s`} ${o} second${o===1?``:`s`}`,{display:s,tooltip:c}},te=e=>({inputTokens:e.inputTokens??0,outputTokens:e.outputTokens??0});return e?(0,z.jsx)(`div`,{className:l?`h-full bg-background`:`fixed inset-0 z-50 bg-background`,children:(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[!l&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Conversation History`}),r?.type===`thread`&&(0,z.jsxs)(la,{value:x,onValueChange:A,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select thread`})}),(0,z.jsx)(ma,{children:i.flatMap(e=>e.threads.map(t=>(0,z.jsx)(ga,{value:t.threadId,children:ba(t,e.name??e.projectId)},t.threadId)))})]}),(0,z.jsxs)(la,{value:y,onValueChange:N,children:[(0,z.jsx)(da,{className:`w-48`,children:(0,z.jsx)(ua,{placeholder:`Select project`})}),(0,z.jsxs)(ma,{children:[(0,z.jsx)(ga,{value:va,children:`All Projects`}),i.map(e=>(0,z.jsx)(ga,{value:e.projectId,children:e.name??e.projectId},e.projectId))]})]})]}),(0,z.jsx)(s,{variant:`action`,size:`icon-sm`,onClick:n,children:(0,z.jsx)(T,{})})]}),u?.messages&&u.messages.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>{_>0&&v(_-1)},disabled:_===0,children:(0,z.jsx)(t,{className:`h-4 w-4 mr-1`})}),(0,z.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>{u?.messages&&_<u.messages.length-1&&v(_+1)},disabled:!u||_>=u.messages.length-1,children:(0,z.jsx)(c,{className:`h-4 w-4 ml-1`})})]}),(0,z.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[_+1,` of `,u?.messages.length??0,` messages`]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:f?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,z.jsxs)(`div`,{className:`text-center`,children:[(0,z.jsx)(o,{className:`h-8 w-8 animate-spin mx-auto mb-2`}),(0,z.jsx)(`p`,{children:`Loading conversation history...`})]})}):h?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,z.jsxs)(k,{className:`max-w-md`,children:[(0,z.jsx)(S,{children:(0,z.jsx)(m,{className:`text-destructive`,children:`Error`})}),(0,z.jsxs)(j,{children:[(0,z.jsx)(`p`,{children:h}),(0,z.jsx)(s,{onClick:n,className:`mt-4`,children:`Close`})]})]})}):u?.messages?.length&&u.messages.length>0?(0,z.jsx)(w,{className:`h-full`,children:(0,z.jsx)(`div`,{className:`p-4`,children:(0,z.jsxs)(Ar,{children:[(0,z.jsx)(jr,{children:(0,z.jsxs)(Pr,{children:[(0,z.jsx)(Q,{children:`Prompt`}),(0,z.jsx)(Q,{children:`Answer`}),(0,z.jsx)(Q,{className:`w-24`,children:`Model`}),(0,z.jsx)(Q,{className:`w-24 text-right`,children:`Duration`}),(0,z.jsx)(Q,{className:`w-20 text-right`,children:`Input Tokens`}),(0,z.jsx)(Q,{className:`w-20 text-right`,children:`Output Tokens`}),(0,z.jsx)(Q,{className:`w-32 text-right`,children:`Timestamp`})]})}),(0,z.jsx)(Mr,{children:u.messages.map((e,t)=>{let{inputTokens:n,outputTokens:r}=te(e);return(0,z.jsxs)(Pr,{className:t===_?`bg-muted/50`:``,children:[(0,z.jsx)(Fr,{className:`max-w-md`,children:(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)(ya,{text:e.request.message})})}),(0,z.jsx)(Fr,{className:`max-w-md`,children:e.response?(0,z.jsx)(`div`,{className:`text-sm`,children:(0,z.jsx)(ya,{text:e.response.content})}):(0,z.jsx)(`span`,{className:`text-muted-foreground italic`,children:`No response`})}),(0,z.jsx)(Fr,{className:`text-sm`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(a,{className:`h-3 w-3 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.request.model})]})}),(0,z.jsx)(Fr,{className:`text-sm text-right`,children:e.response?(0,z.jsx)(Tr,{children:(0,z.jsxs)(Er,{children:[(0,z.jsx)(Dr,{asChild:!0,children:(0,z.jsx)(`div`,{className:`cursor-help`,children:ee(e.timestamp,e.response.completedAt).display})}),(0,z.jsx)(Or,{children:(0,z.jsx)(`p`,{children:ee(e.timestamp,e.response.completedAt).tooltip})})]})}):(0,z.jsx)(`span`,{className:`text-muted-foreground italic`,children:`-`})}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:n>0?n.toLocaleString():`-`}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:r>0?r.toLocaleString():`-`}),(0,z.jsx)(Fr,{className:`text-sm text-muted-foreground text-right`,children:P(e.timestamp)})]},e.id)})})]})})}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,z.jsxs)(`div`,{className:`max-w-md text-center space-y-2`,children:[(0,z.jsx)(`h3`,{className:`text-lg font-semibold`,children:`No History`}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`No conversation history found for this thread.`})]})})})]})}):null}export{mn as _,da as a,Or as c,zn as d,Pn as f,_n as g,Nn as h,ga as i,Tr as l,Fn as m,la as n,kr as o,In as p,ma as r,Er as s,Sa as t,Dr as u};