tarsk 0.4.28 → 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +774 -373
- package/dist/public/assets/{account-view-DcpSNB3N.js → account-view-wqPOnMfW.js} +1 -1
- package/dist/public/assets/alert-dialog-Dj0hDlZC.js +1 -0
- package/dist/public/assets/api-RbLAI1bg.js +1 -0
- package/dist/public/assets/{browser-tab-CiAz6nc1.js → browser-tab-BjqSmZHm.js} +1 -1
- package/dist/public/assets/chat-input-container-BNOl7YtC.js +21 -0
- package/dist/public/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/public/assets/context-menu-XD6khGRr.js +1 -0
- package/dist/public/assets/conversation-history-view-BRSNoBYn.js +1 -0
- package/dist/public/assets/css.worker-DyDu5ynT.js +89 -0
- package/dist/public/assets/{dialogs-config-vkfELnGl.js → dialogs-config-BXDglGdB.js} +14 -14
- package/dist/public/assets/diff-view-DiNlWcSj.js +3 -0
- package/dist/public/assets/explorer-tab-view-DbMBihAH.js +2 -0
- package/dist/public/assets/{explorer-tree-DTFYhczJ.js → explorer-tree-D0P-HUYS.js} +1 -1
- package/dist/public/assets/{explorer-view-C0KcZ8NQ.js → explorer-view-CL_9lhkq.js} +1 -1
- package/dist/public/assets/history-view-i7fGKCkc.js +1 -0
- package/dist/public/assets/html.worker-IWNXhnIC.js +502 -0
- package/dist/public/assets/index-BeLCtY82.css +1 -0
- package/dist/public/assets/index-CZZ6Jb9i.js +29 -0
- package/dist/public/assets/json.worker-c4h5s80L.js +58 -0
- package/dist/public/assets/markdown-renderer-CPSKOcqK.js +10 -0
- package/dist/public/assets/mcp-server-card-DFATg_Ie.js +1 -0
- package/dist/public/assets/monaco-BGyhgQtx.js +1209 -0
- package/dist/public/assets/monaco-Br_kD0ds.css +1 -0
- package/dist/public/assets/onboarding-5CTkrfwe.js +1 -0
- package/dist/public/assets/onboarding-dialog-gcZ9aKKp.js +1 -0
- package/dist/public/assets/page-toolbar-CbwENcML.js +1 -0
- package/dist/public/assets/project-settings-view-CRRJPGNL.js +1 -0
- package/dist/public/assets/providers-list-view-D3CIB4ou.js +1 -0
- package/dist/public/assets/radio-group-qCcnwXV3.js +1 -0
- package/dist/public/assets/react-vendor-Bpg1hd5i.js +22 -0
- package/dist/public/assets/resizable-BLhzHL_f.js +1 -0
- package/dist/public/assets/{run-stop-button-DZ4JFwdL.js → run-stop-button-CIuDOHFg.js} +2 -2
- package/dist/public/assets/settings-general-view-7Y0c9534.js +1 -0
- package/dist/public/assets/{settings-instructions-view-DWzAH2yN.js → settings-instructions-view-B-uTQrNZ.js} +1 -1
- package/dist/public/assets/settings-mcp-servers-view-nAMQQWHb.js +5 -0
- package/dist/public/assets/settings-models-skeleton-CffyGIvJ.js +1 -0
- package/dist/public/assets/settings-models-view-CMZh5LlR.js +1 -0
- package/dist/public/assets/settings-rules-view-BaNccq1v.js +8 -0
- package/dist/public/assets/{settings-skills-view-DV40_L1o.js → settings-skills-view-DBX7obT7.js} +2 -2
- package/dist/public/assets/{settings-slash-commands-view-BEk3BgOY.js → settings-slash-commands-view-BoT1nCir.js} +1 -1
- package/dist/public/assets/{settings-subagents-view-d3P4ylDX.js → settings-subagents-view-Cy87X2bs.js} +2 -2
- package/dist/public/assets/settings-view-CS-RnV6J.js +2 -0
- package/dist/public/assets/side-panel-container-B33_hnhc.js +2 -0
- package/dist/public/assets/skeleton-n47_ST9G.js +1 -0
- package/dist/public/assets/standard-list-item-BLTOBGFa.js +1 -0
- package/dist/public/assets/store-B9rEO6q-.js +4 -0
- package/dist/public/assets/{tab-context-DWD20a4z.js → tab-context-BUUT3x3d.js} +1 -1
- package/dist/public/assets/tabs--5y6mYhG.js +1 -0
- package/dist/public/assets/{terminal-panel-CkIe2d2K.js → terminal-panel-BCHLDUbD.js} +2 -2
- package/dist/public/assets/textarea-CwXpBxom.js +1 -0
- package/dist/public/assets/todos-view-k0k8R9NT.js +1 -0
- package/dist/public/assets/ts.worker-BwM5Ha3L.js +67719 -0
- package/dist/public/assets/use-font-size-BJl84s49.js +1 -0
- package/dist/public/assets/{use-toast-yY7qQuQP.js → use-toast-C5s-Xnwi.js} +1 -1
- package/dist/public/assets/{utils-BKss67Vg.js → utils-CDrGT12s.js} +1 -1
- package/dist/public/assets/{whisper-wasm-B7iuRPFr.js → whisper-wasm-C_Ot631g.js} +1 -1
- package/dist/public/index.html +24 -22
- package/package.json +2 -2
- package/dist/public/assets/alert-dialog-CQRWdGnn.js +0 -1
- package/dist/public/assets/api-CH5gAPs5.js +0 -1
- package/dist/public/assets/chat-input-container-C6U_WFFu.js +0 -21
- package/dist/public/assets/context-menu-A9p22S7d.js +0 -1
- package/dist/public/assets/conversation-history-view-CD_uVRNY.js +0 -1
- package/dist/public/assets/diff-view-CjbcDB6m.js +0 -3
- package/dist/public/assets/explorer-tab-view-BfycKUUW.js +0 -2
- package/dist/public/assets/history-view-Dn0hQIKU.js +0 -1
- package/dist/public/assets/index-Bdde81Uo.css +0 -1
- package/dist/public/assets/index-DKQVo4Vz.js +0 -29
- package/dist/public/assets/markdown-renderer-CNuyXHcy.js +0 -10
- package/dist/public/assets/mcp-server-card-DBEBe3Qh.js +0 -1
- package/dist/public/assets/monaco-SWcefg0q.js +0 -11
- package/dist/public/assets/onboarding-DslO5AS6.js +0 -1
- package/dist/public/assets/onboarding-dialog-CE-GhoDt.js +0 -1
- package/dist/public/assets/page-toolbar-CloU_Kvo.js +0 -1
- package/dist/public/assets/project-settings-view-CxD9JZoB.js +0 -1
- package/dist/public/assets/providers-list-view-CNxVBJlM.js +0 -1
- package/dist/public/assets/radio-group-Co0Lg6se.js +0 -1
- package/dist/public/assets/react-vendor-DyE9sO8V.js +0 -22
- package/dist/public/assets/resizable-dToeUeVD.js +0 -1
- package/dist/public/assets/settings-mcp-servers-view-q6gGMMVX.js +0 -5
- package/dist/public/assets/settings-models-view-BDDFQWWC.js +0 -1
- package/dist/public/assets/settings-rules-view-DsEwgDFr.js +0 -8
- package/dist/public/assets/settings-view-ClTMPafQ.js +0 -2
- package/dist/public/assets/side-panel-container-BAYoMt7B.js +0 -2
- package/dist/public/assets/skeleton-DveUQR4w.js +0 -1
- package/dist/public/assets/standard-list-item-BLlgm1qW.js +0 -1
- package/dist/public/assets/store-BcwWHqYr.js +0 -4
- package/dist/public/assets/tabs-CgvpwOBj.js +0 -1
- package/dist/public/assets/textarea-C2UIAa7y.js +0 -1
- package/dist/public/assets/todos-view-C-awG1dZ.js +0 -1
- /package/dist/public/assets/{dist-Bjt_i1zi.js → dist-CAVGqbBm.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Ji as t,Nr as n,Qt as r,_a as i,it as a,sa as o,wr as s,xi as c}from"./dialogs-config-BXDglGdB.js";import{t as l}from"./use-toast-C5s-Xnwi.js";import{t as u}from"./skeleton-n47_ST9G.js";var d=e(i(),1),f=n();function p(){let[e,n]=(0,d.useState)(null),[i,p]=(0,d.useState)(!0);(0,d.useEffect)(()=>{m();let e=()=>{document.visibilityState===`visible`&&m()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);async function m(){p(!0);try{n(await a())}catch(e){l({title:`Error`,description:e instanceof Error?e.message:`Failed to load account info`,variant:`destructive`})}finally{p(!1)}}function h(){r(`https://buy.stripe.com/14AcN6feK0Jjbheb2H3Nm03?client_reference_id=${e?.clientReferenceId??``}`)}function g(){r(`https://buy.stripe.com/9B67sMd6CgIh70Y0o33Nm04?client_reference_id=${e?.clientReferenceId??``}`)}if(i)return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(u,{className:`h-8 w-32 mb-2`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsx)(u,{className:`h-4 w-20`}),(0,f.jsx)(u,{className:`h-9 w-28`})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsx)(u,{className:`h-6 w-32`}),(0,f.jsx)(u,{className:`h-4 w-full`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(u,{className:`h-4 w-24`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-28`}),(0,f.jsx)(u,{className:`h-4 w-64`})]}),(0,f.jsx)(u,{className:`h-9 w-28 shrink-0`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,f.jsx)(u,{className:`h-5 w-36`}),(0,f.jsx)(u,{className:`h-4 w-56`}),(0,f.jsx)(u,{className:`h-4 w-32`})]}),(0,f.jsx)(u,{className:`h-9 w-24 shrink-0`})]})]})]})]});let _=e?.plan===`unlimited-pro`;return(0,f.jsxs)(`div`,{className:`max-w-2xl mx-auto p-6`,children:[(0,f.jsxs)(`div`,{className:`mb-6`,children:[(0,f.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Account`}),(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage your Tarsk plan and prompt balance.`})]}),(0,f.jsxs)(`div`,{className:`space-y-6`,children:[(0,f.jsxs)(`div`,{className:`flex gap-4`,children:[(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(c,{className:`h-4 w-4`}),`Balance`]}),(0,f.jsx)(`div`,{className:`flex items-end gap-2`,children:_?(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:`Unlimited`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`text-3xl font-bold`,children:e?.promptsRemaining.toLocaleString()??0}),(0,f.jsx)(`span`,{className:`text-muted-foreground mb-1 text-sm`,children:`prompts remaining`})]})})]}),(0,f.jsxs)(`div`,{className:`flex-1 rounded-xl border bg-card p-5 space-y-3`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,f.jsx)(t,{className:`h-4 w-4`}),`Current Plan`]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`text-lg font-semibold`,children:_?`Unlimited Pro`:`Pay as you go`}),_&&(0,f.jsx)(`span`,{className:`rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:`Active`})]}),(0,f.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,f.jsxs)(`div`,{className:`space-y-3`,children:[(0,f.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wide`,children:`Add Prompts`}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,f.jsx)(`span`,{className:`font-semibold`,children:`1,000 Prompts`})}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Top up your balance with 1,000 additional prompts for $5.`})]}),(0,f.jsx)(s,{onClick:h,className:`shrink-0`,children:`Top Up Balance`})]}),(0,f.jsxs)(`div`,{className:`rounded-xl border bg-card p-5 flex items-center justify-between gap-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,f.jsx)(`span`,{className:`font-semibold`,children:`Unlimited Pro Plan`})]}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Unlimited prompts for $100 and lifetime access to Tarsk.`}),(0,f.jsxs)(`ul`,{className:`text-sm text-muted-foreground space-y-0.5`,children:[(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Unlimited prompts`]}),(0,f.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,f.jsx)(o,{className:`h-3 w-3 text-primary`}),`Priority access`]})]})]}),(0,f.jsx)(s,{onClick:g,className:`shrink-0`,children:`Purchase`})]})]})]})]})}export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{Er as t,Nr as n,Tr as r,_a as i,ha as a}from"./dialogs-config-BXDglGdB.js";import{_t as o,dt as s,ft as c,gt as l,ht as u,mt as d,pt as f,ut as p}from"./react-vendor-Bpg1hd5i.js";var m=a(),h=e(i(),1),g=n(),_=l,v=u,y=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`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),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(d,{className:o,...a,ref:n}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});y.displayName=d.displayName;var b=h.forwardRef((e,n)=>{let r=(0,m.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(y,{}),r[3]=o):o=r[3];let s;r[4]===i?s=r[5]:(s=t(`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),r[4]=i,r[5]=s);let l;return r[6]!==a||r[7]!==n||r[8]!==s?(l=(0,g.jsxs)(v,{children:[o,(0,g.jsx)(c,{ref:n,className:s,...a})]}),r[6]=a,r[7]=n,r[8]=s,r[9]=l):l=r[9],l});b.displayName=c.displayName;var x=e=>{let n=(0,m.c)(8),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=t(`flex flex-col space-y-2 text-center sm:text-left`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};x.displayName=`AlertDialogHeader`;var S=e=>{let n=(0,m.c)(8),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=t(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,g.jsx)(`div`,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o};S.displayName=`AlertDialogFooter`;var C=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let s;r[3]===i?s=r[4]:(s=t(`text-lg font-semibold`,i),r[3]=i,r[4]=s);let c;return r[5]!==a||r[6]!==n||r[7]!==s?(c=(0,g.jsx)(o,{ref:n,className:s,...a}),r[5]=a,r[6]=n,r[7]=s,r[8]=c):c=r[8],c});C.displayName=o.displayName;var w=h.forwardRef((e,n)=>{let r=(0,m.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=t(`text-sm text-muted-foreground`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==n||r[7]!==o?(s=(0,g.jsx)(f,{ref:n,className:o,...a}),r[5]=a,r[6]=n,r[7]=o,r[8]=s):s=r[8],s});w.displayName=f.displayName;var T=h.forwardRef((e,n)=>{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=t(r(),a),i[3]=a,i[4]=s);let c;return i[5]!==o||i[6]!==n||i[7]!==s?(c=(0,g.jsx)(p,{ref:n,className:s,...o}),i[5]=o,i[6]=n,i[7]=s,i[8]=c):c=i[8],c});T.displayName=p.displayName;var E=h.forwardRef((e,n)=>{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 c;i[3]===a?c=i[4]:(c=t(r({variant:`outline`}),`mt-2 sm:mt-0`,a),i[3]=a,i[4]=c);let l;return i[5]!==o||i[6]!==n||i[7]!==c?(l=(0,g.jsx)(s,{ref:n,className:c,...o}),i[5]=o,i[6]=n,i[7]=c,i[8]=l):l=i[8],l});E.displayName=s.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{An as e,Fn as t,In as n,Mn as r,Nn as i,Pn as a,jn as o}from"./dialogs-config-BXDglGdB.js";async function s(e,t){return r(`api/threads/${o(e)}/explorer?path=${encodeURIComponent(t)}`)}async function c(e,t){return r(`api/threads/${o(e)}/ai-file?path=${encodeURIComponent(t)}`)}async function l(e,t,r){return n(`api/threads/${o(e)}/ai-file`,{path:t,content:r})}async function u(t,n){return e(`api/threads/${o(t)}/explorer?path=${encodeURIComponent(n)}`)}async function d(e,t,n){return a(`api/threads/${o(e)}/explorer`,{path:t,newName:n})}async function f(e,n,r){return t(`api/threads/${o(e)}/explorer/file`,{dirPath:n,name:r})}function p(e,t){return`${i()}/api/threads/${o(e)}/explorer/media?path=${encodeURIComponent(t)}`}async function m(e,n,r){return t(`api/threads/${o(e)}/explorer/folder`,{dirPath:n,name:r})}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 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$r as t,
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$r as t,Gi as n,Jr as r,Nr as i,Qt as a,_a as o,_i as s,ai as c,ha as l}from"./dialogs-config-BXDglGdB.js";import{a as u}from"./store-B9rEO6q-.js";import{n as d}from"./tab-context-BUUT3x3d.js";import{t as f}from"./run-stop-button-CIuDOHFg.js";var p=l(),m=e(o(),1),h=i();function g(){let e=(0,p.c)(41),{devServerUrl:i,browserResetTrigger:o}=d(),{state:l}=u(),{selectedProjectId:g,projects:_}=l,v;if(e[0]!==_||e[1]!==g){let t;e[3]===g?t=e[4]:(t=e=>e.projectId===g,e[3]=g,e[4]=t),v=_.find(t),e[0]=_,e[1]=g,e[2]=v}else v=e[2];let y=v,[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`desktop`),E=(0,m.useRef)(null),D;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>{C(``),x(``),E.current&&(E.current.src=``)},e[5]=D):D=e[5];let O;e[6]===o?O=e[7]:(O=[o],e[6]=o,e[7]=O),(0,m.useEffect)(D,O);let k,A;e[8]===i?(k=e[9],A=e[10]):(k=()=>{i&&(x(i),C(i))},A=[i],e[8]=i,e[9]=k,e[10]=A),(0,m.useEffect)(k,A);let j;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{let t=e.trim();t&&(!t.startsWith(`http://`)&&!t.startsWith(`https://`)&&(t=`http://`+t),x(t),C(t))},e[11]=j):j=e[11];let M=j,N;e[12]===b?N=e[13]:(N=e=>{e.key===`Enter`&&M(b)},e[12]=b,e[13]=N);let P=N,F;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{if(E.current){let e=E.current.src;E.current.src=``,setTimeout(()=>{E.current&&(E.current.src=e)},0)}},e[14]=F):F=e[14];let I=F,L;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={desktop:{width:`100%`,height:`100%`},tablet:{width:`768px`,height:`1024px`},mobile:{width:`375px`,height:`667px`}},e[15]=L):L=e[15];let R=L[w],z;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x(e.target.value),e[16]=z):z=e[16];let B;e[17]!==P||e[18]!==b?(B=(0,h.jsx)(`input`,{type:`text`,value:b,onChange:z,onKeyDown:P,placeholder:`Enter URL...`,className:`flex-1 px-4 py-1.5 text-sm bg-muted rounded-full border border-border outline-none focus:ring-1 focus:ring-ring font-mono`,spellCheck:!1}),e[17]=P,e[18]=b,e[19]=B):B=e[19];let V;e[20]===S?V=e[21]:(V=S&&(0,h.jsx)(`button`,{onClick:I,title:`Refresh page`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(c,{size:15})}),e[20]=S,e[21]=V);let H;e[22]!==w||e[23]!==S?(H=S&&(0,h.jsxs)(`div`,{className:`flex items-center bg-muted rounded-md p-0.5`,children:[(0,h.jsx)(`button`,{onClick:()=>T(`desktop`),title:`Desktop view`,className:`p-1.5 rounded transition-colors ${w===`desktop`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(s,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`tablet`),title:`Tablet view`,className:`p-1.5 rounded transition-colors ${w===`tablet`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(r,{size:15})}),(0,h.jsx)(`button`,{onClick:()=>T(`mobile`),title:`Mobile view`,className:`p-1.5 rounded transition-colors ${w===`mobile`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground hover:bg-background/50`}`,children:(0,h.jsx)(t,{size:15})})]}),e[22]=w,e[23]=S,e[24]=H):H=e[24];let U;e[25]===S?U=e[26]:(U=S&&(0,h.jsx)(`button`,{onClick:()=>void a(S),title:`Open in external browser`,className:`p-1.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,children:(0,h.jsx)(n,{size:15})}),e[25]=S,e[26]=U);let W;e[27]!==B||e[28]!==V||e[29]!==H||e[30]!==U?(W=(0,h.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[B,V,H,U]}),e[27]=B,e[28]=V,e[29]=H,e[30]=U,e[31]=W):W=e[31];let G;e[32]!==R||e[33]!==w||e[34]!==S||e[35]!==y||e[36]!==g?(G=S?(0,h.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-background`,children:w===`desktop`?(0,h.jsx)(`iframe`,{ref:E,src:S,className:`flex-1 w-full h-full border-none`,title:`Browser`}):(0,h.jsx)(`div`,{className:`bg-white border border-border rounded-lg shadow-lg overflow-hidden transition-all duration-200`,style:{width:R.width,height:R.height,maxWidth:`100%`,maxHeight:`100%`},children:(0,h.jsx)(`iframe`,{ref:E,src:S,className:`w-full h-full border-none`,title:`Browser`})})}):(0,h.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-6 text-muted-foreground`,children:g&&y?.runCommand?(0,h.jsx)(f,{projectId:g,runCommand:y.runCommand,large:!0}):(0,h.jsx)(`p`,{className:`text-sm`,children:`Enter a URL to browse`})}),e[32]=R,e[33]=w,e[34]=S,e[35]=y,e[36]=g,e[37]=G):G=e[37];let K;return e[38]!==W||e[39]!==G?(K=(0,h.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[W,G]}),e[38]=W,e[39]=G,e[40]=K):K=e[40],K}export{g as BrowserTab};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,A as n,Ci as r,Di as i,Er as a,Gn as o,Hi as s,Ii as c,Jn as l,Kn as u,Lr as d,Lt as f,N as p,Nn as m,Nr as h,Nt as g,On as _,Pi as v,Pt as y,Qi as b,Ri as x,Rr as S,Rt as C,T as w,Ti as T,Un as E,Ur as D,Vi as O,Wn as k,Wr as A,Wt as j,Yr as M,Zr as N,_a as P,at as F,bi as ee,bn as I,ca as L,ci as R,ct as te,d as ne,da as re,fi as ie,gi as z,gn as B,h as ae,ha as V,ia as H,ki as U,kn as W,lt as G,mn as K,na as q,nn as oe,nt as se,ot as ce,qn as le,qr as ue,ra as de,ri as fe,sa as pe,si as me,ta as he,ut as ge,wi as _e,wr as J,xn as ve,zt as ye}from"./dialogs-config-BXDglGdB.js";import{$ as be,Ct as xe,G as Se,H as Ce,J as we,K as Te,Q as Ee,U as De,X as Oe,Z as ke,at as Ae,ct as je,et as Me,it as Ne,nt as Pe,ot as Fe,q as Ie,rt as Le,st as Re,tt as ze}from"./react-vendor-Bpg1hd5i.js";import{a as Be,l as Ve,s as He,t as Y,u as Ue}from"./store-B9rEO6q-.js";import{c as We,s as Ge,u as Ke}from"./history-view-i7fGKCkc.js";import{n as qe,t as Je}from"./use-toast-C5s-Xnwi.js";import{a as Ye,c as Xe,i as Ze,o as Qe,s as $e,t as et}from"./alert-dialog-Dj0hDlZC.js";import{n as tt}from"./tab-context-BUUT3x3d.js";import{s as nt}from"./onboarding-5CTkrfwe.js";import{i as rt,n as it,r as at,t as ot}from"./whisper-wasm-C_Ot631g.js";import{n as st}from"./utils-CDrGT12s.js";var X=V(),Z=e(P(),1),Q=h();function ct(e){let t=(0,X.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,Q.jsx)(`div`,{style:{paddingLeft:o},className:s,children:n.children.map(e=>(0,Q.jsx)(ct,{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,Q.jsxs)(`div`,{className:p,children:[m,h]}),t[26]=p,t[27]=m,t[28]=h,t[29]=g):g=t[29],g}function lt(e){let t=(0,X.c)(27),{nodes:n,renderNode:r,resetKey:i,defaultOpen:o,forceOpenIds:s,indent:c,childContainerClassName:l,className:u}=e,d=o===void 0?!1:o,f=c===void 0?16:c,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},t[0]=p):p=t[0];let[m,h]=(0,Z.useState)(p),[g,_]=(0,Z.useState)(i);i!==g&&(_(i),h({}));let v;t[1]===s?v=t[2]:(v=s?new Set(s):void 0,t[1]=s,t[2]=v);let y=v,b;t[3]===d?b=t[4]:(b=e=>{h(t=>({...t,[e]:!(t[e]??d)}))},t[3]=d,t[4]=b);let x=b,S;t[5]===u?S=t[6]:(S=a(`min-w-0`,u),t[5]=u,t[6]=S);let C;if(t[7]!==l||t[8]!==d||t[9]!==y||t[10]!==x||t[11]!==f||t[12]!==n||t[13]!==m||t[14]!==r){let e;t[16]!==l||t[17]!==d||t[18]!==y||t[19]!==x||t[20]!==f||t[21]!==m||t[22]!==r?(e=e=>(0,Q.jsx)(ct,{node:e,level:0,renderNode:r,defaultOpen:d,indent:f,childContainerClassName:l,openState:m,onToggle:x,forceOpenIds:y},e.id),t[16]=l,t[17]=d,t[18]=y,t[19]=x,t[20]=f,t[21]=m,t[22]=r,t[23]=e):e=t[23],C=n.map(e),t[7]=l,t[8]=d,t[9]=y,t[10]=x,t[11]=f,t[12]=n,t[13]=m,t[14]=r,t[15]=C}else C=t[15];let w;return t[24]!==S||t[25]!==C?(w=(0,Q.jsx)(`div`,{className:S,children:C}),t[24]=S,t[25]=C,t[26]=w):w=t[26],w}var ut=Re,dt=je,ft=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:r,align:o,sideOffset:s,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c=o===void 0?`center`:o,l=s===void 0?4:s,u;n[5]===r?u=n[6]:(u=a(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,r),n[5]=r,n[6]=u);let d;return n[7]!==c||n[8]!==i||n[9]!==t||n[10]!==l||n[11]!==u?(d=(0,Q.jsx)(Fe,{children:(0,Q.jsx)(Ae,{ref:t,align:c,sideOffset:l,className:u,...i})}),n[7]=c,n[8]=i,n[9]=t,n[10]=l,n[11]=u,n[12]=d):d=n[12],d});ft.displayName=Ae.displayName;var pt=(0,Z.createContext)({todos:[],setTodos:()=>{}});function mt(e){let t=(0,X.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,Z.useState)(i),s=(0,Z.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,Z.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,Q.jsx)(pt.Provider,{value:f,children:n}),t[7]=n,t[8]=f,t[9]=p):p=t[9],p}function ht(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 gt(e){let t=(0,X.c)(5),{todos:n,sequence:r}=e,{setTodos:i}=(0,Z.useContext)(pt),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,Z.useEffect)(a,o),null}var _t=new Map,vt=new Map;function yt(e){return _t.get(e)}function bt(e,t){let n=vt.get(e);return n||(n=new Set,vt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&vt.delete(e)}}function xt(e){let t=vt.get(e);if(t)for(let e of t)e()}function St(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 Ct(e,t,n){if(_t.has(e))return;_t.set(e,{status:`running`}),xt(e);let r=m();(async()=>{try{let i=St(r,n),a=Object.getPrototypeOf(async function(){}).constructor,o=await new a(`callTool`,t)(i),s=o===void 0?null:o;_t.set(e,{status:`success`,result:s}),xt(e),await I(e,s)}catch(t){let n=t instanceof Error?t.stack||t.message:String(t);_t.set(e,{status:`error`,error:n}),xt(e);try{await I(e,{error:n})}catch(e){console.error(`[browser-js-executor] failed to submit error result`,e)}}})()}function wt({initialValue:e}={}){let{state:t,dispatch:r}=Be(),[i,a]=(0,Z.useState)(()=>{let n=t.selectedThreadId;return n&&t.chatInputDrafts[n]?t.chatInputDrafts[n]:e??``}),[o,s]=(0,Z.useState)(-1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(0),f=(0,Z.useRef)(i);(0,Z.useEffect)(()=>{f.current=i},[i]);let p=(0,Z.useRef)(t.chatInputDrafts);(0,Z.useEffect)(()=>{p.current=t.chatInputDrafts},[t.chatInputDrafts]);let m=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let[h,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(()=>(t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0)??null),x=(0,Z.useRef)(y?.id??``),S=(0,Z.useRef)(y?.provider??``),C=(0,Z.useRef)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)([]),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,ee]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)([]),[R,ne]=(0,Z.useState)(null),[re,ie]=(0,Z.useState)([]),[z,B]=(0,Z.useState)(!1),[ae,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(0),[W,G]=(0,Z.useState)([]),[K,q]=(0,Z.useState)([]),[oe,se]=(0,Z.useState)(!1),[le,ue]=(0,Z.useState)(``),de=(0,Z.useRef)(null),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null),ge=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{x.current=y?.id??``,S.current=y?.provider??``},[y?.id,y?.provider]);let _e=(0,Z.useCallback)((e,n)=>{b(e);let i=t.selectedThreadId;if(!i||(r({type:Y.SetProjectModel,threadId:i,model:e}),n?.persist===!1))return;let a=`${i}:${e.provider??``}:${e.id}`;C.current!==a&&(C.current=a,console.log(`[useChatInputState] Persisting model to thread:`,{threadId:i,model:{id:e.id,provider:e.provider}}),_(i,{model:e.id,modelProvider:e.provider}).then(()=>{C.current===a&&(C.current=null),console.log(`[useChatInputState] Model persisted successfully`)}).catch(e=>{C.current===a&&(C.current=null),console.error(`Failed to save model to thread:`,e)}))},[t.selectedThreadId,r]);(0,Z.useEffect)(()=>{(async()=>{let e=t.selectedProjectId?t.projects.find(e=>e.projectId===t.selectedProjectId)?.threads.find(e=>e.threadId===t.selectedThreadId):void 0,n=t.selectedThreadId?t.projectModelSelections[t.selectedThreadId]:void 0,r=e?.model??n?.id??null,i=e?.modelProvider??n?.provider??null;console.log(`[useChatInputState] Loading models for thread:`,{threadId:t.selectedThreadId,projectId:t.selectedProjectId,currentThread:e?{model:e.model,modelProvider:e.modelProvider}:void 0,storedModel:n?{id:n.id,provider:n.provider}:void 0,savedModelId:r,savedModelProvider:i});try{let e=await ce(),t=Object.values(e).flat();if(t.length===0){v([]),b(null);return}v(t);let n=r&&i?t.find(e=>e.id===r&&e.provider===i)??null:null,a=t[0],o=n??a,s=!n&&!!(r||i),c=x.current===o.id&&S.current===o.provider;console.log(`[useChatInputState] Model selection decision:`,{matchedSavedModel:n?{id:n.id}:null,fallbackModel:{id:a.id},modelToSelect:{id:o.id},shouldPersistFallback:s,hasSameSelection:c,currentSelected:{id:x.current,provider:S.current}}),c||_e(o,{persist:s})}catch(e){console.error(`Failed to load enabled models:`,e)}})()},[t.selectedThreadId,t.selectedProjectId,t.projects,_e]);let J=(0,Z.useRef)(_e);(0,Z.useEffect)(()=>{J.current=_e},[_e]),(0,Z.useEffect)(()=>{t.configUpdatedAt!==0&&(async()=>{try{let e=await ce(),t=Object.values(e).flat();if(t.length>0){v(t);let e=x.current,n=S.current;t.some(t=>t.id===e&&t.provider===n)||J.current(t[0],{persist:!0})}}catch(e){console.error(`Failed to reload enabled models:`,e)}})()},[t.configUpdatedAt]),(0,Z.useEffect)(()=>{!P||I.length>0||(async()=>{try{let e=await F(),t=Object.values(e).flat();t.length>0&&(L(t),ne(e=>e??t[0]))}catch(e){console.error(`Failed to load image models:`,e)}})()},[P,I.length]);let[ve,ye]=(0,Z.useState)(t.selectedThreadId);return(0,Z.useEffect)(()=>{if(t.selectedThreadId!==ve){ve&&f.current.trim()&&p.current[ve]!==f.current&&r({type:Y.SetChatInputDraft,threadId:ve,draft:f.current});let e=!1;return queueMicrotask(()=>{e||!m.current||(ye(t.selectedThreadId),a(t.selectedThreadId?p.current[t.selectedThreadId]??``:``),ie([]),B(!1),G([]),q([]),se(!1),j(!1),ee(!1),N(!1))}),()=>{e=!0}}},[t.selectedThreadId,ve]),(0,Z.useEffect)(()=>{t.selectedThreadId&&g(t.selectedThreadId).then(({commands:e,skills:t})=>{console.log(`Loaded slash commands:`,e,`skills:`,t),G(e),q(t)}).catch(e=>console.error(`Failed to load slash commands and skills:`,e))},[t.selectedThreadId]),(0,Z.useEffect)(()=>{t.focusChatInput&&t.selectedThreadId&&!t.isStreaming&&(fe.current?.focus(),r({type:Y.ClearFocusChatInput}))},[t.focusChatInput,t.selectedThreadId,t.isStreaming,r]),(0,Z.useEffect)(()=>{let e=t.selectedThreadId;return()=>{e&&f.current.trim()&&p.current[e]!==f.current&&r({type:Y.SetChatInputDraft,threadId:e,draft:f.current})}},[t.selectedThreadId,r]),(0,Z.useEffect)(()=>{let e=e=>{pe.current&&!pe.current.contains(e.target)&&T(!1),me.current&&!me.current.contains(e.target)&&D(!1)};if(w||E)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[w,E]),{message:i,setMessage:a,historyIndex:o,setHistoryIndex:s,draftMessage:c,setDraftMessage:l,cursorPosition:u,setCursorPosition:d,availableModels:h,setAvailableModels:v,selectedModel:y,setSelectedModel:_e,selectedModelIdRef:x,showModelMenu:w,setShowModelMenu:T,showPlusMenu:E,setShowPlusMenu:D,attachments:O,setAttachments:k,planMode:A,setPlanMode:j,ralphMode:M,setRalphMode:N,imageMode:P,setImageMode:ee,availableImageModels:I,setAvailableImageModels:L,selectedImageModel:R,setSelectedImageModel:ne,allFiles:re,setAllFiles:ie,showSuggestions:z,setShowSuggestions:B,suggestionQuery:ae,setSuggestionQuery:V,selectedIndex:H,setSelectedIndex:U,slashCommands:W,setSlashCommands:G,skills:K,setSkills:q,showCommandSuggestions:oe,setShowCommandSuggestions:se,commandQuery:le,setCommandQuery:ue,fileInputRef:de,textareaRef:fe,modelMenuRef:pe,plusMenuRef:me,suggestionsRef:he,commandSuggestionsRef:ge,handleNewChat:async()=>{if(t.selectedThreadId)try{let e=await n(t.selectedThreadId);r({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let i=await te(t.selectedThreadId);r({type:Y.SetMessages,messages:i.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},state:t,dispatch:r}}var Tt=e=>{ne(e)};function Et(e){let t=(0,X.c)(102),{message:n,setMessage:r,attachments:i,selectedModel:a,onSend:o,isStreaming:s,selectedThreadId:c,isListening:l,stopListening:u,resetTranscript:d,dispatch:p,historyIndex:m,setHistoryIndex:h,draftMessage:g,setDraftMessage:_,cursorPosition:v,setCursorPosition:y,showSuggestions:b,setShowSuggestions:x,suggestionQuery:S,setSuggestionQuery:C,allFiles:w,setAllFiles:T,selectedIndex:E,setSelectedIndex:D,showCommandSuggestions:O,setShowCommandSuggestions:k,commandQuery:A,setCommandQuery:j,slashCommands:M,skills:N,textareaRef:P,setAttachments:F,planMode:ee,setPlanMode:I,ralphMode:L,setRalphMode:R,imageMode:te,setImageMode:ne,selectedImageModel:re}=e,ie;t[0]!==i||t[1]!==p||t[2]!==te||t[3]!==l||t[4]!==s||t[5]!==n||t[6]!==o||t[7]!==ee||t[8]!==L||t[9]!==d||t[10]!==re||t[11]!==a||t[12]!==c||t[13]!==F||t[14]!==_||t[15]!==h||t[16]!==r||t[17]!==u||t[18]!==P?(ie=()=>{if(!n.trim()&&i.length===0||!c)return;let e=te?re:a;e&&(l&&(u(),d()),s?p({type:Y.EnqueueChatMessage,message:{id:`queued-${Date.now()}`,threadId:c,message:n,model:e.id,attachments:i,provider:e.provider,planMode:ee,imageMode:te,ralphMode:L}}):o(n,e.id,i,e.provider,ee,te,L),Tt(n),r(``),F([]),h(-1),_(``),c&&p({type:Y.ClearChatInputDraft,threadId:c}),P.current&&(P.current.style.height=`auto`))},t[0]=i,t[1]=p,t[2]=te,t[3]=l,t[4]=s,t[5]=n,t[6]=o,t[7]=ee,t[8]=L,t[9]=d,t[10]=re,t[11]=a,t[12]=c,t[13]=F,t[14]=_,t[15]=h,t[16]=r,t[17]=u,t[18]=P,t[19]=ie):ie=t[19];let z=ie,B;t[20]!==v||t[21]!==n||t[22]!==r||t[23]!==x||t[24]!==S||t[25]!==P?(B=e=>{let t=n.substring(0,v-S.length-1);r(`${t}${e} ${n.substring(v)}`),x(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.length+1;P.current.setSelectionRange(n,n)}},0)},t[20]=v,t[21]=n,t[22]=r,t[23]=x,t[24]=S,t[25]=P,t[26]=B):B=t[26];let V=B,H;t[27]!==A||t[28]!==v||t[29]!==n||t[30]!==ne||t[31]!==r||t[32]!==I||t[33]!==R||t[34]!==k||t[35]!==P?(H=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v);r(`${t}${e.content}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let n=t.length+e.content.length;P.current.setSelectionRange(n,n)}},0),e.metadata.mode===`plan`?(I(!0),R(!1),ne(!1)):e.metadata.mode===`ralph`&&(R(!0),I(!1),ne(!1))},t[27]=A,t[28]=v,t[29]=n,t[30]=ne,t[31]=r,t[32]=I,t[33]=R,t[34]=k,t[35]=P,t[36]=H):H=t[36];let U=H,W;t[37]!==A||t[38]!==v||t[39]!==n||t[40]!==r||t[41]!==k||t[42]!==P?(W=e=>{let t=n.substring(0,v-A.length-1),i=n.substring(v),a=e.name.includes(` `)?`/"${e.name}"`:`/${e.name}`;r(`${t}${a}${i}`),k(!1),setTimeout(()=>{if(P.current){P.current.focus();let e=t.length+a.length;P.current.setSelectionRange(e,e)}},0)},t[37]=A,t[38]=v,t[39]=n,t[40]=r,t[41]=k,t[42]=P,t[43]=W):W=t[43];let G=W,K,q,oe,se;if(t[44]!==w||t[45]!==A||t[46]!==g||t[47]!==z||t[48]!==m||t[49]!==U||t[50]!==V||t[51]!==G||t[52]!==n||t[53]!==E||t[54]!==c||t[55]!==T||t[56]!==j||t[57]!==y||t[58]!==_||t[59]!==h||t[60]!==r||t[61]!==D||t[62]!==k||t[63]!==x||t[64]!==C||t[65]!==O||t[66]!==b||t[67]!==N||t[68]!==M||t[69]!==S){oe=e=>{if(O){if(e.key===`ArrowDown`){e.preventDefault(),D((E+1)%K.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D((E-1+K.length)%K.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=K[E];t&&(t.type===`command`?U(t.data):G(t.data));return}if(e.key===`Escape`){k(!1);return}}if(b){let t=q.length>0;if(e.key===`ArrowDown`&&t){e.preventDefault(),D((E+1)%q.length);return}if(e.key===`ArrowUp`&&t){e.preventDefault(),D((E-1+q.length)%q.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),q[E]&&V(q[E]);return}if(e.key===`Escape`){x(!1);return}}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),z();return}let t=ae();t.length!==0&&(e.key===`ArrowUp`?(e.preventDefault(),m===-1?(_(n),h(t.length-1),r(t[t.length-1])):m>0&&(h(m-1),r(t[m-1]))):e.key===`ArrowDown`&&(e.preventDefault(),m>0?(h(m-1),r(t[m-1])):m===0&&(h(-1),r(g))))};let e;t[74]!==w||t[75]!==c||t[76]!==T||t[77]!==j||t[78]!==y||t[79]!==r||t[80]!==D||t[81]!==k||t[82]!==x||t[83]!==C?(e=e=>{let t=e.target.value,n=e.target.selectionStart;r(t),y(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(` `)?k(!1):(j(e),k(!0),x(!1),D(0))}else k(!1)}else{k(!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(` `)?x(!1):(C(t),x(!0),D(0),w.length===0&&c&&f(c).then(e=>{T(e)}).catch(kt))}else x(!1)}else x(!1)}let o=e.target;o.style.height=`auto`,o.style.height=`${Math.min(o.scrollHeight,160)}px`},t[74]=w,t[75]=c,t[76]=T,t[77]=j,t[78]=y,t[79]=r,t[80]=D,t[81]=k,t[82]=x,t[83]=C,t[84]=e):e=t[84],se=e;let i;if(t[85]!==A||t[86]!==N||t[87]!==M){let e;t[89]===A?e=t[90]:(e=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[89]=A,t[90]=e);let n=M.filter(e),r;t[91]===A?r=t[92]:(r=e=>e.name.toLowerCase().includes(A.toLowerCase()),t[91]=A,t[92]=r);let a=N.filter(r);i=[...n.map(Ot),...a.map(Dt)],t[85]=A,t[86]=N,t[87]=M,t[88]=i}else i=t[88];K=i.slice(0,10),q=b?w.filter(e=>e.toLowerCase().includes(S.toLowerCase())).slice(0,10):[],t[44]=w,t[45]=A,t[46]=g,t[47]=z,t[48]=m,t[49]=U,t[50]=V,t[51]=G,t[52]=n,t[53]=E,t[54]=c,t[55]=T,t[56]=j,t[57]=y,t[58]=_,t[59]=h,t[60]=r,t[61]=D,t[62]=k,t[63]=x,t[64]=C,t[65]=O,t[66]=b,t[67]=N,t[68]=M,t[69]=S,t[70]=K,t[71]=q,t[72]=oe,t[73]=se}else K=t[70],q=t[71],oe=t[72],se=t[73];let ce;return t[93]!==K||t[94]!==q||t[95]!==oe||t[96]!==z||t[97]!==se||t[98]!==U||t[99]!==V||t[100]!==G?(ce={handleSend:z,handleKeyDown:oe,handleTextareaInput:se,insertFileReference:V,insertCommand:U,insertSkill:G,allSuggestions:K,fileSuggestions:q},t[93]=K,t[94]=q,t[95]=oe,t[96]=z,t[97]=se,t[98]=U,t[99]=V,t[100]=G,t[101]=ce):ce=t[101],ce}function Dt(e){return{type:`skill`,data:e}}function Ot(e){return{type:`command`,data:e}}function kt(e){return console.error(`Failed to fetch files:`,e)}function At(e){let t=(0,X.c)(21),{visible:n,commands:r,skills:i,query:o,selectedIndex:s,onSelectCommand:c,onSelectSkill:l,onMouseEnterSuggestion:u,containerRef:f}=e;if(!n)return null;let p;if(t[0]!==r||t[1]!==o||t[2]!==i){let e;t[4]===o?e=t[5]:(e=e=>e.name.toLowerCase().includes(o.toLowerCase()),t[4]=o,t[5]=e);let n=r.filter(e),a;t[6]===o?a=t[7]:(a=e=>e.name.toLowerCase().includes(o.toLowerCase()),t[6]=o,t[7]=a);let s=i.filter(a);p=[...n.map(Mt),...s.map(jt)].slice(0,10),t[0]=r,t[1]=o,t[2]=i,t[3]=p}else p=t[3];let m=p,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(ue,{className:`h-3 w-3`}),t[8]=h):h=t[8];let g=o&&` matching "${o}"`,_;t[9]===g?_=t[10]:(_=(0,Q.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:[h,`Commands & Skills`,g]}),t[9]=g,t[10]=_);let v;t[11]!==m||t[12]!==u||t[13]!==c||t[14]!==l||t[15]!==s?(v=m.length>0?m.map((e,t)=>{let n=t===s;if(e.type===`command`){let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`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:()=>u(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ue,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),r.metadata.argumentHint&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.argumentHint}),r.scope===`project`&&(0,Q.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,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.metadata.description})]},`cmd-${r.name}`)}else{let r=e.data;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`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:()=>l(r),onMouseEnter:()=>u(t),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(d,{className:`h-3 w-3 text-amber-500`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`/`,r.name]}),(0,Q.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,Q.jsx)(`span`,{className:`text-[10px] rounded-full bg-primary/10 px-1.5 py-0.5 text-primary`,children:`project`})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.description})]},`skill-${r.name}`)}}):(0,Q.jsxs)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:[`No commands or skills found.`,(0,Q.jsx)(`br`,{}),(0,Q.jsxs)(`span`,{className:`text-[10px]`,children:[`Create commands in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/commands/`}),` or skills in `,(0,Q.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`.agents/skills/`})]})]}),t[11]=m,t[12]=u,t[13]=c,t[14]=l,t[15]=s,t[16]=v):v=t[16];let y;return t[17]!==f||t[18]!==_||t[19]!==v?(y=(0,Q.jsxs)(`div`,{ref:f,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]=f,t[18]=_,t[19]=v,t[20]=y):y=t[20],y}function jt(e){return{type:`skill`,data:e}}function Mt(e){return{type:`command`,data:e}}function Nt(e){return e.startsWith(`image/`)}function Pt(e){let t=(0,X.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,Q.jsx)(`div`,{className:`group relative flex items-center gap-1 rounded-md bg-muted text-xs text-muted-foreground`,children:Nt(e.mimeType)?(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:e.fileName,className:`h-16 w-16 rounded-md object-cover`}),(0,Q.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,Q.jsx)(S,{className:`h-2.5 w-2.5`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Remove attachment`})]})]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[(0,Q.jsx)(ie,{className:`h-3 w-3`}),e.fileName,(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:`ml-1 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3 w-3`}),(0,Q.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,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:i}),t[5]=i,t[6]=a),a}function Ft(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 It(e){let t=(0,X.c)(16),{showSuggestions:n,fileSuggestions:r,suggestionQuery:i,selectedIndex:o,onSelectFile:c,onMouseEnterSuggestion:l,containerRef:u}=e;if(!n||r.length===0)return null;let d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(fe,{className:`h-3 w-3`}),t[0]=d):d=t[0];let f;t[1]===i?f=t[2]:(f=(0,Q.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]!==l||t[5]!==c||t[6]!==o){let e;t[8]!==l||t[9]!==c||t[10]!==o?(e=(e,t)=>{let n=e.split(`/`).pop()??e;return(0,Q.jsxs)(`button`,{type:`button`,className:a(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-left transition-colors`,t===o?`bg-accent text-accent-foreground`:`text-popover-foreground hover:bg-accent/50`),onClick:()=>c(e),onMouseEnter:()=>l(t),children:[e.endsWith(`.ts`)||e.endsWith(`.tsx`)||e.endsWith(`.js`)||e.endsWith(`.jsx`)?(0,Q.jsx)(s,{className:`h-4 w-4 text-blue-500`}):(0,Q.jsx)(O,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:n}),(0,Q.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground opacity-70`,children:e})]})]},e)},t[8]=l,t[9]=c,t[10]=o,t[11]=e):e=t[11],p=r.map(e),t[3]=r,t[4]=l,t[5]=c,t[6]=o,t[7]=p}else p=t[7];let m;return t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,Q.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 Lt(e){let t=(0,X.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,Q.jsx)(`img`,{src:r,alt:i,className:`h-3.5 w-3.5 flex-shrink-0 dark:invert`,onError:Rt}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Rt(e){e.currentTarget.style.visibility=`hidden`}function zt(e){let t=(0,X.c)(26),{availableModels:n,selectedModel:r,onModelSelect:i}=e,[a,o]=Z.useState(!1),s=Z.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),Z.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,Q.jsx)(Lt,{provider:p}),t[7]=p,t[8]=m);let h;t[9]===r?h=t[10]:(h=r?nt(r.id):`No model`,t[9]=r,t[10]=h);let g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:h}),t[11]=h,t[12]=g);let _;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(de,{className:`h-3 w-3`}),t[13]=_):_=t[13];let v;t[14]!==f||t[15]!==m||t[16]!==g?(v=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:f,children:[m,g,_]}),t[14]=f,t[15]=m,t[16]=g,t[17]=v):v=t[17];let y;t[18]!==n||t[19]!==d||t[20]!==r?.id||t[21]!==a?(y=a&&(0,Q.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(Bt,{})).map(e=>{let[t,n]=e;return(0,Q.jsxs)(`div`,{children:[(0,Q.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,Q.jsx)(Lt,{provider:t}),t]}),n.map(e=>(0,Q.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:nt(e.id)},e.id))]},t)})}),t[18]=n,t[19]=d,t[20]=r?.id,t[21]=a,t[22]=y):y=t[22];let b;return t[23]!==v||t[24]!==y?(b=(0,Q.jsxs)(`div`,{className:`relative`,ref:s,children:[v,y]}),t[23]=v,t[24]=y,t[25]=b):b=t[25],b}function Bt(e,t){let n=t.provider??`Other`;return e[n]||(e[n]=[]),e[n].push(t),e}var Vt=[{value:`build`,label:`Build`,icon:U},{value:`plan`,label:`Plan`,icon:T},{value:`image`,label:`Image`,icon:i},{value:`ralph`,label:`Ralph`,icon:me}];function Ht(e,t,n){return n?`ralph`:e?`plan`:t?`image`:`build`}function Ut(e){let t=(0,X.c)(31),{planMode:n,imageMode:r,ralphMode:i,setPlanMode:a,setImageMode:o,setRalphMode:s}=e,[c,l]=Z.useState(!1),u=Z.useRef(null),d;t[0]!==r||t[1]!==n||t[2]!==i?(d=Ht(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=Vt.find(e=>e.value===f),t[4]=f,t[5]=p);let m=p,h=m.icon,g,_;t[6]===c?(g=t[7],_=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)}},_=[c],t[6]=c,t[7]=g,t[8]=_),Z.useEffect(g,_);let v;t[9]!==o||t[10]!==a||t[11]!==s?(v=function(e){a(e===`plan`),o(e===`image`),s(e===`ralph`),l(!1)},t[9]=o,t[10]=a,t[11]=s,t[12]=v):v=t[12];let y=v,b;t[13]===c?b=t[14]:(b=()=>l(!c),t[13]=c,t[14]=b);let x;t[15]===h?x=t[16]:(x=(0,Q.jsx)(h,{className:`h-3.5 w-3.5`}),t[15]=h,t[16]=x);let S;t[17]===m.label?S=t[18]:(S=(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:m.label}),t[17]=m.label,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(de,{className:`h-3 w-3`}),t[19]=C):C=t[19];let w;t[20]!==b||t[21]!==x||t[22]!==S?(w=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,className:`gap-1 w-auto px-2`,onClick:b,children:[x,S,C]}),t[20]=b,t[21]=x,t[22]=S,t[23]=w):w=t[23];let T;t[24]!==f||t[25]!==c||t[26]!==y?(T=c&&(0,Q.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:Vt.map(e=>{let t=e.icon,n=e.value===f;return(0,Q.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:()=>y(e.value),children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),e.label,n&&(0,Q.jsx)(pe,{className:`ml-auto h-3.5 w-3.5`})]},e.value)})}),t[24]=f,t[25]=c,t[26]=y,t[27]=T):T=t[27];let E;return t[28]!==w||t[29]!==T?(E=(0,Q.jsxs)(`div`,{className:`relative`,ref:u,children:[w,T]}),t[28]=w,t[29]=T,t[30]=E):E=t[30],E}function Wt(e){let t=(0,X.c)(17),{onFileAttach:n}=e,[r,i]=Z.useState(!1),a=Z.useRef(null),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};if(r)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},s=[r],t[0]=r,t[1]=o,t[2]=s),Z.useEffect(o,s);let c;t[3]===n?c=t[4]:(c=function(){n(),i(!1)},t[3]=n,t[4]=c);let l=c,u;t[5]===r?u=t[6]:(u=()=>i(!r),t[5]=r,t[6]=u);let d,f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(R,{}),f=(0,Q.jsx)(`span`,{className:`sr-only`,children:`More options`}),t[7]=d,t[8]=f):(d=t[7],f=t[8]);let p;t[9]===u?p=t[10]:(p=(0,Q.jsxs)(J,{variant:`action`,size:`icon-sm`,onClick:u,children:[d,f]}),t[9]=u,t[10]=p);let m;t[11]!==l||t[12]!==r?(m=r&&(0,Q.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,Q.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:l,children:[(0,Q.jsx)(ie,{className:`h-3.5 w-3.5`}),`Attach File`]})}),t[11]=l,t[12]=r,t[13]=m):m=t[13];let h;return t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{className:`relative`,ref:a,children:[p,m]}),t[14]=p,t[15]=m,t[16]=h):h=t[16],h}var $=rt(`useWhisperSpeech`),Gt=`/api/voice-model/download`;function Kt(){let[e,t]=(0,Z.useState)(`idle`),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=!1;async function n(){t(`checking-support`),$.separator(`VOICE SESSION START`),$.info(`Checking WASM support`,{userAgent:navigator.userAgent,platform:navigator.platform});try{let n=new at;m.current=n;let i=await n.checkWasmSupport();if(e)return;if($.info(`WASM SIMD support check result`,{supported:i}),r(i),!i){$.error(`WASM SIMD not supported — voice input disabled`),t(`error`),d(`WebAssembly SIMD is not supported in this environment.`);return}let o=new it;h.current=o,$.info(`Checking IndexedDB model cache`,{url:Gt});try{let r=await o.loadModelByUrl(Gt);if(e||($.info(`Cached model found — initializing WASM`,{sizeBytes:r.byteLength,sizeMB:(r.byteLength/1024/1024).toFixed(2)}),a(!0),t(`initializing`),await n.initModel(r),e))return;$.info(`WASM model initialized from cache — ready`),t(`ready`)}catch(n){if(e)return;$.info(`Model not in cache — download required`,{reason:n instanceof Error?n.message:String(n)}),t(`needs-model`)}}catch(n){if(e)return;let r=n instanceof Error?n.message:`Unknown error`;$.error(`Failed to check speech recognition support`,{error:r}),t(`error`),d(`Failed to check speech recognition support: ${r}`)}}return n().catch(e=>{console.error(`Failed to check speech recognition support:`,e)}),()=>{e=!0,g.current&&g.current.getTracks().forEach(e=>e.stop())}},[]);let b=(0,Z.useCallback)(async()=>{if(!(!m.current||!h.current)){t(`downloading-model`),p(0),d(null),$.info(`Model download requested`,{url:Gt});try{let e=await h.current.loadModelByUrl(Gt,e=>{p(e),e%10==0&&$.debug(`Model download progress`,{progress:e})});$.info(`Model download complete — initializing WASM`,{sizeBytes:e.byteLength,sizeMB:(e.byteLength/1024/1024).toFixed(2)}),t(`initializing`),await m.current.initModel(e),$.info(`WASM model initialized after download — ready`),a(!0),t(`ready`)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred.`;$.error(`Model download or initialization failed`,{error:n}),t(`needs-model`),d(n)}}},[]),x=(0,Z.useCallback)(async()=>{if(!(!m.current||!i)){if(y.current=!1,t(`requesting-mic`),d(null),l(``),$.separator(`RECORDING START`),$.info(`Requesting microphone access`),!navigator.mediaDevices?.getUserMedia){$.error(`navigator.mediaDevices.getUserMedia not available in this environment`),t(`ready`),s(!1),d(`Microphone is not available in this environment.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),n=e.getAudioTracks();$.info(`Microphone access granted`,{trackCount:n.length,tracks:n.map(e=>({label:e.label,readyState:e.readyState,settings:e.getSettings()}))}),g.current=e,s(!0);let r=new AbortController;_.current=r,t(`recording`),$.info(`Recording started`),v.current=ot(e,{signal:r.signal,recordingDurationMs:12e4,logLevel:0},{onError:e=>{$.error(`Audio conversion error during recording`,{error:e instanceof Error?e.message:String(e)})}})}catch(e){if(t(`ready`),e instanceof DOMException&&e.name===`NotAllowedError`)$.error(`Microphone access denied (NotAllowedError)`),s(!1),d(`Microphone access was denied. Please allow microphone access to use voice input.`);else if(e instanceof DOMException&&e.name===`NotFoundError`)$.error(`No microphone found (NotFoundError)`),s(!1),d(`No microphone was found. Please connect a microphone to use voice input.`);else{let t=e instanceof Error?e.message:`Unknown error`;$.error(`Microphone error`,{error:t,type:e instanceof DOMException?e.name:typeof e}),d(`Microphone error: ${t}`)}}}},[i]),S=(0,Z.useCallback)(async()=>{if(!v.current){$.info(`stopListening called but no active recording`),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null),i&&t(`ready`);return}$.info(`Stopping recording — waiting for audio data`),_.current?.abort(),t(`transcribing`);try{let e=await v.current;if(y.current){$.info(`Transcription cancelled by user`),t(`ready`);return}let n=(e.audioData.length/16e3).toFixed(2);$.info(`Audio capture complete — starting transcription`,{sampleCount:e.audioData.length,durationSec:n,sampleRate:16e3}),g.current&&=(g.current.getTracks().forEach(e=>e.stop()),null);let r=Date.now(),i=typeof SharedArrayBuffer<`u`?4:1,a=m.current.createSession().streaming(e.audioData,{language:`en`,threads:i,translate:!1}),o=``,s=0;for await(let e of a){if(y.current)break;s++,o+=e.text.trim()+` `,$.debug(`Transcription segment received`,{index:s,text:e.text,timeStart:e.timeStart,timeEnd:e.timeEnd}),l(o.trim())}$.info(`Transcription complete`,{segmentCount:s,durationMs:Date.now()-r,textLength:o.trim().length,text:o.trim().slice(0,100)}),t(`ready`)}catch(e){if(y.current){t(`ready`);return}let n=e instanceof Error?e.message:`Unknown transcription error`;if($.error(`Transcription failed`,{error:n,errorType:e instanceof Error?e.constructor.name:typeof e,stack:e instanceof Error?e.stack?.split(`
|
|
2
|
+
`).slice(0,5).join(` | `):void 0}),m.current&&n.includes(`Aborted`)){$.info(`WASM aborted — reinitializing model for next attempt`),t(`initializing`);try{await m.current.restartModel(),$.info(`WASM reinitialized successfully`)}catch(e){$.error(`WASM reinitialization failed`,{error:e instanceof Error?e.message:String(e)})}}t(`ready`),d(`Transcription failed: ${n}`)}finally{v.current=null,_.current=null}},[i]),C=(0,Z.useCallback)(()=>{l(``),d(null)},[]);return{state:e,isSupported:n===!0,isWasmSupported:n,isModelLoaded:i,isMicrophoneAvailable:o,transcript:c,error:u,downloadProgress:f,startListening:x,stopListening:S,requestModelDownload:b,resetTranscript:C}}var qt=Z.forwardRef((e,t)=>{let n=(0,X.c)(13),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,value:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s;n[4]===r?s=n[5]:(s=a(`relative h-4 w-full overflow-hidden rounded-full bg-secondary`,r),n[4]=r,n[5]=s);let c=`translateX(-${100-(o||0)}%)`,l;n[6]===c?l=n[7]:(l=(0,Q.jsx)(Le,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:c}}),n[6]=c,n[7]=l);let u;return n[8]!==i||n[9]!==t||n[10]!==s||n[11]!==l?(u=(0,Q.jsx)(Ne,{ref:t,className:s,...i,children:l}),n[8]=i,n[9]=t,n[10]=s,n[11]=l,n[12]=u):u=n[12],u});qt.displayName=Ne.displayName;var Jt=75;function Yt(e){let t=(0,X.c)(11),{open:n,onOpenChange:r,onConfirm:i,downloading:a,progress:s,error:c}=e,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsxs)(le,{children:[(0,Q.jsx)(l,{children:`Download Voice Model`}),(0,Q.jsxs)(o,{children:[`To enable voice-to-text, a voice model needs to be downloaded. This is a one-time download of approximately `,Jt,`MB. The model will be cached locally for future use.`]})]}),t[0]=d):d=t[0];let f;t[1]!==a||t[2]!==c||t[3]!==i||t[4]!==r||t[5]!==s?(f=(0,Q.jsxs)(k,{children:[d,a?(0,Q.jsxs)(`div`,{className:`space-y-3 py-4`,children:[(0,Q.jsx)(qt,{value:s,className:`w-full`}),(0,Q.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:s<100?`Downloading model... ${s}%`:`Initializing model...`})]}):c?(0,Q.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,Q.jsx)(q,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{children:c})]}),(0,Q.jsxs)(u,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,children:`Try Again`})]})]}):(0,Q.jsxs)(u,{children:[(0,Q.jsx)(J,{variant:`outline`,onClick:()=>r(!1),children:`Cancel`}),(0,Q.jsx)(J,{onClick:i,children:`Download Model`})]})]}),t[1]=a,t[2]=c,t[3]=i,t[4]=r,t[5]=s,t[6]=f):f=t[6];let p;return t[7]!==r||t[8]!==n||t[9]!==f?(p=(0,Q.jsx)(E,{open:n,onOpenChange:r,children:f}),t[7]=r,t[8]=n,t[9]=f,t[10]=p):p=t[10],p}function Xt(e){let t=(0,X.c)(65),{onTranscript:n}=e,{state:i,isWasmSupported:a,transcript:o,error:s,downloadProgress:c,startListening:l,stopListening:u,requestModelDownload:d,resetTranscript:f}=Kt(),{toast:p}=qe(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(``),_=(0,Z.useRef)(null),v=i===`recording`,y=i===`transcribing`,b=v||y,x=i===`needs-model`,S=i===`downloading-model`||i===`initializing`,C=i===`checking-support`||i===`idle`,w,T;t[0]!==m||t[1]!==s||t[2]!==p?(w=()=>{s&&s!==_.current&&!m&&p({title:`Voice Input Error`,description:s,variant:`destructive`}),_.current=s},T=[s,m,p],t[0]=m,t[1]=s,t[2]=p,t[3]=w,t[4]=T):(w=t[3],T=t[4]),(0,Z.useEffect)(w,T);let E,D;t[5]!==n||t[6]!==o?(E=()=>{if(o&&o!==g.current){let e=o.substring(g.current.length);g.current=o,n(e)}},D=[o,n],t[5]=n,t[6]=o,t[7]=E,t[8]=D):(E=t[7],D=t[8]),(0,Z.useEffect)(E,D);let O,k;t[9]===o?(O=t[10],k=t[11]):(O=()=>{o||(g.current=``)},k=[o],t[9]=o,t[10]=O,t[11]=k),(0,Z.useEffect)(O,k);let A;t[12]!==b||t[13]!==x||t[14]!==f||t[15]!==l||t[16]!==i||t[17]!==u?(A=()=>{if(x){h(!0);return}b?u():i===`ready`&&(f(),l())},t[12]=b,t[13]=x,t[14]=f,t[15]=l,t[16]=i,t[17]=u,t[18]=A):A=t[18];let j=A,M;t[19]===d?M=t[20]:(M=()=>{d()},t[19]=d,t[20]=M);let N=M,P,F;if(t[21]!==m||t[22]!==i?(F=()=>{i===`ready`&&m&&h(!1)},P=[i,m],t[21]=m,t[22]=i,t[23]=P,t[24]=F):(P=t[23],F=t[24]),(0,Z.useEffect)(F,P),C)return null;if(a===!1){let e;return t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Ge,{children:[(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,disabled:!0,className:`text-muted-foreground`,children:[(0,Q.jsx)(ee,{className:`opacity-50`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Voice input not supported`})]})}),(0,Q.jsx)(We,{side:`top`,className:`bg-popover text-popover-foreground`,children:`Voice input not supported in this browser`})]}),t[25]=e):e=t[25],e}let I;t[26]!==s||t[27]!==S||t[28]!==v||t[29]!==y||t[30]!==x?(I=()=>s||(S?`Downloading speech model...`:y?`Transcribing...`:v?`Stop listening`:x?`Click to download speech model`:`Start listening`),t[26]=s,t[27]=S,t[28]=v,t[29]=y,t[30]=x,t[31]=I):I=t[31];let L=I,R;t[32]!==S||t[33]!==v||t[34]!==y?(R=()=>S||y?(0,Q.jsx)(r,{className:`animate-spin`}):v?(0,Q.jsxs)(`span`,{className:`recording-waveform`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`0ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`150ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`75ms`}}),(0,Q.jsx)(`span`,{className:`recording-waveform-bar`,style:{animationDelay:`225ms`}})]}):(0,Q.jsx)(ee,{}),t[32]=S,t[33]=v,t[34]=y,t[35]=R):R=t[35];let te=R,ne;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,Q.jsx)(`style`,{children:`
|
|
3
|
+
.recording-waveform {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: 2px;
|
|
7
|
+
height: 16px;
|
|
8
|
+
}
|
|
9
|
+
.recording-waveform-bar {
|
|
10
|
+
display: block;
|
|
11
|
+
width: 3px;
|
|
12
|
+
height: 4px;
|
|
13
|
+
border-radius: 2px;
|
|
14
|
+
background: currentColor;
|
|
15
|
+
animation: waveform-bounce 0.7s ease-in-out infinite alternate;
|
|
16
|
+
}
|
|
17
|
+
@keyframes waveform-bounce {
|
|
18
|
+
from { height: 3px; }
|
|
19
|
+
to { height: 14px; }
|
|
20
|
+
}
|
|
21
|
+
`}),t[36]=ne):ne=t[36];let re=v?`bg-primary text-primary-foreground hover:bg-primary/90`:y?`text-muted-foreground`:`text-muted-foreground hover:text-background`,ie=C||S||y,z;t[37]===te?z=t[38]:(z=te(),t[37]=te,t[38]=z);let B;t[39]===L?B=t[40]:(B=L(),t[39]=L,t[40]=B);let ae;t[41]===B?ae=t[42]:(ae=(0,Q.jsx)(`span`,{className:`sr-only`,children:B}),t[41]=B,t[42]=ae);let V;t[43]!==j||t[44]!==re||t[45]!==ie||t[46]!==z||t[47]!==ae?(V=(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:re,onClick:j,disabled:ie,children:[z,ae]})}),t[43]=j,t[44]=re,t[45]=ie,t[46]=z,t[47]=ae,t[48]=V):V=t[48];let H;t[49]===L?H=t[50]:(H=L(),t[49]=L,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Q.jsx)(We,{side:`top`,className:`bg-popover text-popover-foreground max-w-64`,children:H}),t[51]=H,t[52]=U);let W;t[53]!==V||t[54]!==U?(W=(0,Q.jsxs)(Ge,{children:[V,U]}),t[53]=V,t[54]=U,t[55]=W):W=t[55];let G;t[56]!==m||t[57]!==c||t[58]!==s||t[59]!==N||t[60]!==S?(G=(0,Q.jsx)(Yt,{open:m,onOpenChange:h,onConfirm:N,downloading:S,progress:c,error:s}),t[56]=m,t[57]=c,t[58]=s,t[59]=N,t[60]=S,t[61]=G):G=t[61];let K;return t[62]!==W||t[63]!==G?(K=(0,Q.jsxs)(Q.Fragment,{children:[ne,W,G]}),t[62]=W,t[63]=G,t[64]=K):K=t[64],K}function Zt(e){let t=(0,X.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,Q.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,Q.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,Q.jsx)(`p`,{className:`flex-1 whitespace-pre-wrap text-foreground`,children:e.message}),(0,Q.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,Q.jsx)(S,{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,Q.jsxs)(`div`,{className:`mb-3 rounded-lg border border-border/60 bg-muted/30 px-4 py-3`,children:[i,(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:a})]}),t[6]=a,t[7]=o),o}function Qt(e){let t=(0,X.c)(136),{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,f;t[0]===o?f=t[1]:(f={initialValue:o},t[0]=o,t[1]=f);let{message:p,setMessage:m,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,availableModels:x,selectedModel:S,setSelectedModel:C,attachments:w,setAttachments:T,planMode:E,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,availableImageModels:P,selectedImageModel:F,setSelectedImageModel:ee,allFiles:I,setAllFiles:L,showSuggestions:R,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:ie,selectedIndex:z,setSelectedIndex:B,slashCommands:ae,skills:V,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,fileInputRef:K,textareaRef:q,suggestionsRef:oe,commandSuggestionsRef:se,state:ce,dispatch:le}=wt(f),ue=j?F:S,de=j?P:x,fe=ce.selectedThreadId??void 0,pe;t[2]!==I||t[3]!==w||t[4]!==W||t[5]!==y||t[6]!==le||t[7]!==_||t[8]!==h||t[9]!==j||t[10]!==u||t[11]!==p||t[12]!==n||t[13]!==E||t[14]!==k||t[15]!==F||t[16]!==z||t[17]!==S||t[18]!==L||t[19]!==T||t[20]!==G||t[21]!==b||t[22]!==v||t[23]!==g||t[24]!==M||t[25]!==m||t[26]!==O||t[27]!==A||t[28]!==B||t[29]!==U||t[30]!==te||t[31]!==ie||t[32]!==H||t[33]!==R||t[34]!==V||t[35]!==ae||t[36]!==ne||t[37]!==fe||t[38]!==q?(pe={message:p,setMessage:m,attachments:w,selectedModel:S,onSend:n,isStreaming:u,selectedThreadId:fe,isListening:!1,stopListening:nn,resetTranscript:tn,dispatch:le,historyIndex:h,setHistoryIndex:g,draftMessage:_,setDraftMessage:v,cursorPosition:y,setCursorPosition:b,showSuggestions:R,setShowSuggestions:te,suggestionQuery:ne,setSuggestionQuery:ie,allFiles:I,setAllFiles:L,selectedIndex:z,setSelectedIndex:B,showCommandSuggestions:H,setShowCommandSuggestions:U,commandQuery:W,setCommandQuery:G,slashCommands:ae,skills:V,textareaRef:q,setAttachments:T,planMode:E,setPlanMode:O,ralphMode:k,setRalphMode:A,imageMode:j,setImageMode:M,selectedImageModel:F},t[2]=I,t[3]=w,t[4]=W,t[5]=y,t[6]=le,t[7]=_,t[8]=h,t[9]=j,t[10]=u,t[11]=p,t[12]=n,t[13]=E,t[14]=k,t[15]=F,t[16]=z,t[17]=S,t[18]=L,t[19]=T,t[20]=G,t[21]=b,t[22]=v,t[23]=g,t[24]=M,t[25]=m,t[26]=O,t[27]=A,t[28]=B,t[29]=U,t[30]=te,t[31]=ie,t[32]=H,t[33]=R,t[34]=V,t[35]=ae,t[36]=ne,t[37]=fe,t[38]=q,t[39]=pe):pe=t[39];let{handleSend:me,handleKeyDown:he,handleTextareaInput:ge,insertFileReference:_e,insertCommand:ve,insertSkill:ye,fileSuggestions:be}=Et(pe),xe;t[40]===m?xe=t[41]:(xe=e=>{m(t=>(t.endsWith(` `),t+e))},t[40]=m,t[41]=xe);let Se=xe,Ce;t[42]===T?Ce=t[43]:(Ce=e=>{let t=e.clipboardData?.items;if(!t)return;let n=Array.from(t).filter(en);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];T(n=>[...n,{fileName:t.name||`pasted-image.${t.type.split(`/`)[1]||`png`}`,content:e,mimeType:t.type}])},n.readAsDataURL(t)}}},t[42]=T,t[43]=Ce);let we=Ce,Te=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`,Ee=`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`}`,De;t[44]!==c||t[45]!==s?(De=(0,Q.jsx)(Zt,{queuedMessages:s,onRemoveQueuedMessage:c}),t[44]=c,t[45]=s,t[46]=De):De=t[46];let Oe=k?`Describe stories for Ralph to implement autonomously...`:E?`Describe what you want Tarsk to plan...`:j?`Describe the image you want to generate...`:`Ask Tarsk anything, # for files, / for commands & skills`,ke;t[47]!==a||t[48]!==he||t[49]!==we||t[50]!==ge||t[51]!==p||t[52]!==Oe||t[53]!==q?(ke=(0,Q.jsx)(`textarea`,{ref:q,value:p,onChange:ge,onKeyDown:he,onPaste:we,placeholder:Oe,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[47]=a,t[48]=he,t[49]=we,t[50]=ge,t[51]=p,t[52]=Oe,t[53]=q,t[54]=ke):ke=t[54];let Ae;t[55]!==W||t[56]!==se||t[57]!==ve||t[58]!==ye||t[59]!==z||t[60]!==B||t[61]!==H||t[62]!==V||t[63]!==ae?(Ae=(0,Q.jsx)(At,{visible:H,commands:ae,skills:V,query:W,selectedIndex:z,onSelectCommand:ve,onSelectSkill:ye,onMouseEnterSuggestion:B,containerRef:se}),t[55]=W,t[56]=se,t[57]=ve,t[58]=ye,t[59]=z,t[60]=B,t[61]=H,t[62]=V,t[63]=ae,t[64]=Ae):Ae=t[64];let je;t[65]!==be||t[66]!==_e||t[67]!==z||t[68]!==B||t[69]!==R||t[70]!==ne||t[71]!==oe?(je=(0,Q.jsx)(It,{showSuggestions:R,fileSuggestions:be,suggestionQuery:ne,selectedIndex:z,onSelectFile:_e,onMouseEnterSuggestion:B,containerRef:oe}),t[65]=be,t[66]=_e,t[67]=z,t[68]=B,t[69]=R,t[70]=ne,t[71]=oe,t[72]=je):je=t[72];let Me;t[73]!==w||t[74]!==S?.id||t[75]!==S?.name||t[76]!==S?.supportsImages||t[77]!==T?(Me=w.length>0&&(0,Q.jsxs)(`div`,{className:`px-4`,children:[(0,Q.jsx)(Pt,{attachments:w,onRemove:e=>T(t=>t.filter((t,n)=>n!==e))}),w.some($t)&&S?.supportsImages===!1&&(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs text-amber-500`,children:[(0,Q.jsx)(D,{className:`h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Images are not supported by `,S?.name||S?.id]})]})]}),t[73]=w,t[74]=S?.id,t[75]=S?.name,t[76]=S?.supportsImages,t[77]=T,t[78]=Me):Me=t[78];let Ne;t[79]===K?Ne=t[80]:(Ne=(0,Q.jsx)(Wt,{onFileAttach:()=>K.current?.click()}),t[79]=K,t[80]=Ne);let Pe;t[81]===Se?Pe=t[82]:(Pe=(0,Q.jsx)(Xt,{onTranscript:Se}),t[81]=Se,t[82]=Pe);let Fe=j?ee:C,Ie;t[83]!==de||t[84]!==ue||t[85]!==Fe?(Ie=(0,Q.jsx)(zt,{availableModels:de,selectedModel:ue,onModelSelect:Fe}),t[83]=de,t[84]=ue,t[85]=Fe,t[86]=Ie):Ie=t[86];let Le;t[87]!==Ne||t[88]!==Pe||t[89]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Ne,Pe,Ie]}),t[87]=Ne,t[88]=Pe,t[89]=Ie,t[90]=Le):Le=t[90];let Re;t[91]!==j||t[92]!==E||t[93]!==k||t[94]!==M||t[95]!==O||t[96]!==A?(Re=(0,Q.jsx)(Ut,{planMode:E,imageMode:j,ralphMode:k,setPlanMode:O,setImageMode:M,setRalphMode:A}),t[91]=j,t[92]=E,t[93]=k,t[94]=M,t[95]=O,t[96]=A,t[97]=Re):Re=t[97];let ze=u?r:me,Be;t[98]!==w.length||t[99]!==a||t[100]!==ue||t[101]!==u||t[102]!==p?(Be=!u&&((a??!1)||!p.trim()&&w.length===0||!ue),t[98]=w.length,t[99]=a,t[100]=ue,t[101]=u,t[102]=p,t[103]=Be):Be=t[103];let Ve;t[104]===u?Ve=t[105]:(Ve=u?(0,Q.jsx)(N,{className:`h-3 w-3 fill-current`}):(0,Q.jsx)(re,{className:`h-3 w-3`}),t[104]=u,t[105]=Ve);let He=u?`Stop generation`:`Send message`,Y;t[106]===He?Y=t[107]:(Y=(0,Q.jsx)(`span`,{className:`sr-only`,children:He}),t[106]=He,t[107]=Y);let Ue;t[108]!==ze||t[109]!==Be||t[110]!==Ve||t[111]!==Y?(Ue=(0,Q.jsxs)(J,{size:`icon`,className:`h-7 w-7 rounded-full`,onClick:ze,disabled:Be,children:[Ve,Y]}),t[108]=ze,t[109]=Be,t[110]=Ve,t[111]=Y,t[112]=Ue):Ue=t[112];let We;t[113]!==Re||t[114]!==Ue?(We=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Re,Ue]}),t[113]=Re,t[114]=Ue,t[115]=We):We=t[115];let Ge;t[116]!==Le||t[117]!==We?(Ge=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2`,children:[Le,We]}),t[116]=Le,t[117]=We,t[118]=Ge):Ge=t[118];let Ke;t[119]!==De||t[120]!==ke||t[121]!==Ae||t[122]!==je||t[123]!==Me||t[124]!==Ge||t[125]!==Ee?(Ke=(0,Q.jsxs)(`div`,{className:Ee,children:[De,ke,Ae,je,Me,Ge]}),t[119]=De,t[120]=ke,t[121]=Ae,t[122]=je,t[123]=Me,t[124]=Ge,t[125]=Ee,t[126]=Ke):Ke=t[126];let qe;t[127]===T?qe=t[128]:(qe=e=>Ft(e,e=>T(t=>[...t,...e])),t[127]=T,t[128]=qe);let Je;t[129]!==K||t[130]!==qe?(Je=(0,Q.jsx)(`input`,{ref:K,type:`file`,multiple:!0,className:`hidden`,onChange:qe}),t[129]=K,t[130]=qe,t[131]=Je):Je=t[131];let Ye;return t[132]!==Ke||t[133]!==Je||t[134]!==Te?(Ye=(0,Q.jsxs)(`div`,{className:Te,children:[Ke,Je]}),t[132]=Ke,t[133]=Je,t[134]=Te,t[135]=Ye):Ye=t[135],Ye}function $t(e){return e.mimeType.startsWith(`image/`)}function en(e){return e.type.startsWith(`image/`)}function tn(){}function nn(){}var rn=ke,an=Pe,on=be,sn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:i,inset:o,children:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c=o&&`pl-8`,l;n[5]!==i||n[6]!==c?(l=a(`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`,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,Q.jsx)(H,{className:`ml-auto`}),n[8]=u):u=n[8];let d;return n[9]!==r||n[10]!==s||n[11]!==t||n[12]!==l?(d=(0,Q.jsxs)(ze,{ref:t,className:l,...s,children:[r,u]}),n[9]=r,n[10]=s,n[11]=t,n[12]=l,n[13]=d):d=n[13],d});sn.displayName=ze.displayName;var cn=Z.forwardRef((e,t)=>{let n=(0,X.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 o;n[3]===r?o=n[4]:(o=a(`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]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,Q.jsx)(Me,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});cn.displayName=Me.displayName;var ln=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,sideOffset:o,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=o===void 0?4:o,c;n[4]===r?c=n[5]:(c=a(`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]=c);let l;return n[6]!==i||n[7]!==t||n[8]!==s||n[9]!==c?(l=(0,Q.jsx)(we,{children:(0,Q.jsx)(De,{ref:t,sideOffset:s,className:c,...i})}),n[6]=i,n[7]=t,n[8]=s,n[9]=c,n[10]=l):l=n[10],l});ln.displayName=De.displayName;var un=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=i&&`pl-8`,c;n[4]!==r||n[5]!==s?(c=a(`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`,s,r),n[4]=r,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,Q.jsx)(Se,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});un.displayName=Se.displayName;var dn=Z.forwardRef((e,t)=>{let n=(0,X.c)(14),r,i,o,s;n[0]===e?(r=n[1],i=n[2],o=n[3],s=n[4]):({className:o,children:i,checked:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o,n[4]=s);let c;n[5]===o?c=n[6]:(c=a(`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`,o),n[5]=o,n[6]=c);let l;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Te,{children:(0,Q.jsx)(pe,{className:`h-4 w-4`})})}),n[7]=l):l=n[7];let u;return n[8]!==r||n[9]!==i||n[10]!==s||n[11]!==t||n[12]!==c?(u=(0,Q.jsxs)(Ce,{ref:t,className:c,checked:r,...s,children:[l,i]}),n[8]=r,n[9]=i,n[10]=s,n[11]=t,n[12]=c,n[13]=u):u=n[13],u});dn.displayName=Ce.displayName;var fn=Z.forwardRef((e,n)=>{let r=(0,X.c)(12),i,o,s;r[0]===e?(i=r[1],o=r[2],s=r[3]):({className:o,children:i,...s}=e,r[0]=e,r[1]=i,r[2]=o,r[3]=s);let c;r[4]===o?c=r[5]:(c=a(`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`,o),r[4]=o,r[5]=c);let l;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(Te,{children:(0,Q.jsx)(t,{className:`h-2 w-2 fill-current`})})}),r[6]=l):l=r[6];let u;return r[7]!==i||r[8]!==s||r[9]!==n||r[10]!==c?(u=(0,Q.jsxs)(Oe,{ref:n,className:c,...s,children:[l,i]}),r[7]=i,r[8]=s,r[9]=n,r[10]=c,r[11]=u):u=r[11],u});fn.displayName=Oe.displayName;var pn=Z.forwardRef((e,t)=>{let n=(0,X.c)(11),r,i,o;n[0]===e?(r=n[1],i=n[2],o=n[3]):({className:r,inset:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=o);let s=i&&`pl-8`,c;n[4]!==r||n[5]!==s?(c=a(`px-2 py-1.5 text-sm font-semibold`,s,r),n[4]=r,n[5]=s,n[6]=c):c=n[6];let l;return n[7]!==o||n[8]!==t||n[9]!==c?(l=(0,Q.jsx)(Ie,{ref:t,className:c,...o}),n[7]=o,n[8]=t,n[9]=c,n[10]=l):l=n[10],l});pn.displayName=Ie.displayName;var mn=Z.forwardRef((e,t)=>{let n=(0,X.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 o;n[3]===r?o=n[4]:(o=a(`-mx-1 my-1 h-px bg-muted`,r),n[3]=r,n[4]=o);let s;return n[5]!==i||n[6]!==t||n[7]!==o?(s=(0,Q.jsx)(Ee,{ref:t,className:o,...i}),n[5]=i,n[6]=t,n[7]=o,n[8]=s):s=n[8],s});mn.displayName=Ee.displayName;var hn=e=>{let t=(0,X.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(`ml-auto text-xs tracking-widest opacity-60`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,Q.jsx)(`span`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};hn.displayName=`DropdownMenuShortcut`;function gn(e){let t=(0,X.c)(17),{currentBranch:n,availableBranches:i,isLoadingBranches:a,isCheckingOut:o,onLoadBranches:s,onCheckoutBranch:l}=e,u;t[0]===s?u=t[1]:(u=e=>{e&&s()},t[0]=s,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(c,{className:`h-3.5 w-3.5 shrink-0`}),t[2]=d):d=t[2];let f=n||`Unknown`,p;t[3]===f?p=t[4]:(p=(0,Q.jsx)(an,{asChild:!0,children:(0,Q.jsxs)(J,{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:[d,f]})}),t[3]=f,t[4]=p);let m;t[5]!==i||t[6]!==n||t[7]!==o||t[8]!==a||t[9]!==l?(m=a?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-3 w-3 animate-spin`}),`Loading branches...`]}):i.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`No branches found`}):i.map(e=>(0,Q.jsxs)(un,{disabled:e===n||o,onClick:()=>l(e),children:[(0,Q.jsx)(c,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:e===n?`font-semibold text-foreground`:``,children:e}),e===n&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`current`})]},e)),t[5]=i,t[6]=n,t[7]=o,t[8]=a,t[9]=l,t[10]=m):m=t[10];let h;t[11]===m?h=t[12]:(h=(0,Q.jsx)(ln,{align:`start`,children:m}),t[11]=m,t[12]=h);let g;return t[13]!==u||t[14]!==p||t[15]!==h?(g=(0,Q.jsxs)(rn,{onOpenChange:u,children:[p,h]}),t[13]=u,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}var _n=[{key:`systemPrompt`,label:`System prompt`,color:`#9CA3AF`},{key:`toolDefinitions`,label:`Tool definitions`,color:`#B088F0`},{key:`rules`,label:`Rules`,color:`#88D088`},{key:`skills`,label:`Skills`,color:`#D0A000`},{key:`subagentDefinitions`,label:`Subagent definitions`,color:`#2080D0`},{key:`conversation`,label:`Conversation`,color:`#E09030`}];function vn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function yn(e){return e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:e.toString()}function bn(e){let t=(0,X.c)(49),{breakdown:n,onClose:r}=e,{categories:i,totalTokens:a,contextWindow:o,percentageFull:s}=n,c,l,u,d,f,p;if(t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==s||t[4]!==a){let e;t[11]===i?e=t[12]:(e=e=>i[e.key]>0,t[11]=i,t[12]=e);let n=_n.filter(e);d=`w-72 space-y-3`;let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Context`}),t[13]=m):m=t[13];let h;t[14]===r?h=t[15]:(h=r&&(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:r,children:[(0,Q.jsx)(S,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[14]=r,t[15]=h),t[16]===h?f=t[17]:(f=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[m,h]}),t[16]=h,t[17]=f);let g;t[18]===s?g=t[19]:(g=(0,Q.jsxs)(`span`,{children:[s,`% Full`]}),t[18]=s,t[19]=g);let _;t[20]===a?_=t[21]:(_=vn(a),t[20]=a,t[21]=_);let v;t[22]===o?v=t[23]:(v=yn(o),t[22]=o,t[23]=v);let y;t[24]!==_||t[25]!==v?(y=(0,Q.jsxs)(`span`,{children:[`~`,_,` / `,v,` Tokens`]}),t[24]=_,t[25]=v,t[26]=y):y=t[26],t[27]!==g||t[28]!==y?(p=(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[g,y]}),t[27]=g,t[28]=y,t[29]=p):p=t[29],u=`h-2 w-full overflow-hidden rounded-full bg-muted/60`,c=`flex h-full w-full`;let b;t[30]!==i||t[31]!==o?(b=e=>{let t=i[e.key],n=o>0?t/o*100:0;return(0,Q.jsx)(`div`,{style:{width:`${Math.max(n,t>0?.5:0)}%`,backgroundColor:e.color}},e.key)},t[30]=i,t[31]=o,t[32]=b):b=t[32],l=n.map(b),t[0]=i,t[1]=o,t[2]=r,t[3]=s,t[4]=a,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];let m;t[33]!==c||t[34]!==l?(m=(0,Q.jsx)(`div`,{className:c,children:l}),t[33]=c,t[34]=l,t[35]=m):m=t[35];let h;t[36]!==u||t[37]!==m?(h=(0,Q.jsx)(`div`,{className:u,children:m}),t[36]=u,t[37]=m,t[38]=h):h=t[38];let g;t[39]===i?g=t[40]:(g=_n.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-sm`,style:{backgroundColor:e.color}}),(0,Q.jsx)(`span`,{children:e.label})]}),(0,Q.jsx)(`span`,{className:`tabular-nums`,children:vn(i[e.key])})]},e.key)),t[39]=i,t[40]=g);let _;t[41]===g?_=t[42]:(_=(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[41]=g,t[42]=_);let v;return t[43]!==_||t[44]!==d||t[45]!==f||t[46]!==p||t[47]!==h?(v=(0,Q.jsxs)(`div`,{className:d,children:[f,p,h,_]}),t[43]=_,t[44]=d,t[45]=f,t[46]=p,t[47]=h,t[48]=v):v=t[48],v}function xn({threadId:e,currentConversationId:t,refreshKey:n,children:r}){let[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{p(!1)},[n]),(0,Z.useEffect)(()=>{if(!u||!e||f&&!n)return;async function r(){s(!0),l(null);try{let n=(await y(e)).currentConversationId??t;if(!n){l(`No active conversation`);return}a(await G(e,n)),p(!0)}catch(e){console.error(`[TokenUsageTooltip] Failed to load context data:`,e),l(`Failed to load context data`)}finally{s(!1)}}r()},[u,e,t,n]),!e||e===``?(0,Q.jsx)(Q.Fragment,{children:r}):(0,Q.jsxs)(ut,{open:u,onOpenChange:e=>{d(e),!e&&f&&p(!1)},children:[(0,Q.jsx)(dt,{asChild:!0,children:r}),(0,Q.jsxs)(ft,{side:`top`,align:`end`,className:`w-auto p-4`,children:[o&&(0,Q.jsxs)(`div`,{className:`flex w-72 items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`h-3 w-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Loading context...`})]}),c&&!o&&(0,Q.jsxs)(`div`,{className:`flex w-72 items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:c})]}),!o&&!c&&i&&(0,Q.jsx)(bn,{breakdown:i,onClose:()=>d(!1)})]})]})}function Sn(e,t){return`${e.filter(e=>e.sender===`agent`).length}:${t?`streaming`:`idle`}`}function Cn(e){return e>75?`text-red-500`:e>50?`text-orange-500`:`text-muted-foreground`}function wn(e){let t=(0,X.c)(8),{percentage:n}=e,r=2*Math.PI*7,i=r*(1-Math.min(n,100)/100),a;t[0]===n?a=t[1]:(a=Cn(n),t[0]=n,t[1]=a);let o=`h-4 w-4 ${a}`,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`circle`,{className:`text-muted-foreground/25`,cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`}),t[2]=s):s=t[2];let c;t[3]===i?c=t[4]:(c=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:7,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:r,strokeDashoffset:i,transform:`rotate(-90 10 10)`}),t[3]=i,t[4]=c);let l;return t[5]!==o||t[6]!==c?(l=(0,Q.jsxs)(`svg`,{className:o,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[s,c]}),t[5]=o,t[6]=c,t[7]=l):l=t[7],l}function Tn(e){let t=(0,X.c)(21),{threadId:n,isStreaming:r,messages:i}=e,a=r===void 0?!1:r,o;t[0]===i?o=t[1]:(o=i===void 0?[]:i,t[0]=i,t[1]=o);let s=o,[c,l]=(0,Z.useState)(),[u,d]=(0,Z.useState)(),f;t[2]!==a||t[3]!==s?(f=Sn(s,a),t[2]=a,t[3]=s,t[4]=f):f=t[4];let p=f,m;t[5]===n?m=t[6]:(m=()=>{(async function(){if(!n){l(void 0),d(void 0);return}try{let e=(await y(n)).currentConversationId;if(l(e),!e){d(void 0);return}d((await G(n,e)).percentageFull)}catch(e){console.error(`Failed to fetch thread usage data:`,e),d(void 0)}})()},t[5]=n,t[6]=m);let h;if(t[7]!==n||t[8]!==p?(h=[n,p],t[7]=n,t[8]=p,t[9]=h):h=t[9],(0,Z.useEffect)(m,h),!n||n===``)return null;let g=typeof u==`number`&&u>25,_;t[10]!==u||t[11]!==g?(_=g?(0,Q.jsx)(wn,{percentage:u}):(0,Q.jsx)(A,{className:`h-4 w-4`}),t[10]=u,t[11]=g,t[12]=_):_=t[12];let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(`span`,{className:`sr-only`,children:`View token usage`}),t[13]=v):v=t[13];let b;t[14]===_?b=t[15]:(b=(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,children:[_,v]}),t[14]=_,t[15]=b);let x;return t[16]!==c||t[17]!==b||t[18]!==n||t[19]!==p?(x=(0,Q.jsx)(xn,{threadId:n,currentConversationId:c,refreshKey:p,children:b}),t[16]=c,t[17]=b,t[18]=n,t[19]=p,t[20]=x):x=t[20],x}var En=3e4,Dn=new Map;function On(e,t){let n=Dn.get(e);if(n)for(let e of n)e(t)}function kn(e,t){let n=Dn.get(e);return n||(n=new Set,Dn.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Dn.delete(e)}}function An(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(0),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(void 0),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`Up to date`),[x,S]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(void 0),[O,k]=(0,Z.useState)(void 0),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),P=(0,Z.useRef)(!0),F=(0,Z.useRef)(void 0),ee=(0,Z.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),T(e.prExists),D(e.prUrl),k(e.prState),j(e.commitsAheadOfDefault??!1)},[]),I=(0,Z.useRef)(ee);I.current=ee;let L=(0,Z.useCallback)(async(t=!1)=>{if(!e)return;let n=setTimeout(()=>N(!0),100);try{let n=`unified-git-status-${e}`;t&&W.invalidate(n);let r=await W.get(n,()=>C(e,t),En);ee(r),On(e,r)}catch(e){console.error(`Failed to fetch unified git status:`,e)}finally{clearTimeout(n),N(!1)}},[e,ee]);return(0,Z.useEffect)(()=>{if(e)return kn(e,e=>{I.current(e)})},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=F.current!==e;t&&(F.current=e,P.current=!0),(async()=>{if(P.current){let t=`unified-git-status-${e}`,n=W.getSync(t);n&&ee(n),P.current=!1}await L(t)})()},[e,L,ee]),{hasChanges:t,changedFilesCount:r,hasUnpushedCommits:a,hasRemoteBranch:_,currentBranch:s,isOnGitHub:l,remoteUrl:d,canCreateRepo:p,repoUrl:h,status:y,defaultBranch:x,prExists:w,prUrl:E,prState:O,commitsAheadOfDefault:A,isRefreshing:M,fetchUnifiedStatus:L}}function jn(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=An(e);async function c(){if(!(!e||r)){i(!0);try{n((await j(e)).branches)}catch{n([])}finally{i(!1)}}}async function l(t){if(!(!e||t===s.currentBranch)){o(!0);try{await ye(e,t),await s.fetchUnifiedStatus(!0),Je({title:`Switched to branch "${t}"`})}catch(e){Je({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 Mn(e){let t=(0,X.c)(8),{collapsed:n}=e,{theme:r,setTheme:i}=st();if(n)return null;let a;t[0]!==i||t[1]!==r?(a=()=>i(r===`dark`?`light`:`dark`),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o,s,c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(M,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),s=(0,Q.jsx)(z,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),c=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle theme`}),t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l;return t[6]===a?l=t[7]:(l=(0,Q.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:a,children:[o,s,c]}),t[6]=a,t[7]=l),l}function Nn({threadId:e,isStreaming:t=!1,messages:n=[]}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),s=jn(e);return(0,Z.useEffect)(()=>{e&&ge(e).then(o).catch(()=>{})},[e]),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-8 py-2 mt-[-1rem] min-h-[2.25rem]`,children:[e&&(0,Q.jsx)(gn,{currentBranch:s.currentBranch,availableBranches:s.availableBranches,isLoadingBranches:s.isLoadingBranches,isCheckingOut:s.isCheckingOut,onLoadBranches:s.loadBranches,onCheckoutBranch:s.checkoutBranch}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Mn,{collapsed:!1}),(0,Q.jsx)(Tn,{threadId:e,isStreaming:t,messages:n}),e&&(0,Q.jsxs)(Ge,{children:[(0,Q.jsx)(Ke,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground hover:text-background`,onClick:async()=>{if(!(!e||r)){i(!0);try{let t=await ge(e);await navigator.clipboard.writeText(t)}finally{i(!1)}}},disabled:r,"aria-label":`Copy repository folder path`,children:(0,Q.jsx)(x,{className:`h-4 w-4`})})}),(0,Q.jsxs)(We,{side:`top`,className:`bg-slate-900 text-white`,children:[(0,Q.jsx)(`div`,{children:`Copy repository folder path`}),a&&(0,Q.jsx)(`div`,{className:`opacity-70 text-xs`,children:a})]})]})]})]})}function Pn(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&&Ct(e.id,e.input.code,t)}catch{}}function Fn(){let{state:e,dispatch:t}=Be(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(null),l=(0,Z.useRef)(new Map),{selectedThreadId:u,selectedProjectId:d,messages:f,queuedChatMessages:m,isStreaming:h,processingThreadIds:g}=e;c.current=u;let v=(0,Z.useCallback)((e,n,r)=>{if(l.current.get(e)!==r||(l.current.delete(e),r.stopHandled))return;let i=He(r.segments)||`...`;if(r.error&&(r.segments.length===0||i===`...`)){let i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r.error}`,contentType:`text`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e});return}let a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:i,contentType:`markdown`,timestamp:new Date().toISOString(),model:n||`default`,isThinking:!1};t({type:Y.AddMessage,message:a,threadId:e}),t({type:Y.ResetStream,threadId:e}),t({type:Y.MarkThreadCompleted,threadId:e}),t({type:Y.RemoveProcessingThread,threadId:e})},[t]),y=(0,Z.useCallback)(()=>{if(!u)return;s(u);let n=l.current.get(u);n&&(n.stopHandled=!0,n.controller.abort(),n.cancel?.(),l.current.delete(u)),B(u);let r={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:Y.AddMessage,message:r,threadId:u}),t({type:Y.ResetStream,threadId:u}),t({type:Y.MarkThreadCompleted,threadId:u}),t({type:Y.RemoveProcessingThread,threadId:u})},[u,t,e.streamingModel]);(0,Z.useEffect)(()=>()=>{for(let e of l.current.values())e.controller.abort(),e.cancel?.();l.current.clear()},[]),(0,Z.useEffect)(()=>{if(!u)return;let e=!1;async function n(){try{let n=await te(u);e||t({type:Y.SetMessages,messages:n.messages})}catch(n){console.error(`Failed to load chat history:`,n),e||t({type:Y.SetMessages,messages:[]})}}return n(),()=>{e=!0}},[u,d,t]);let b=(0,Z.useCallback)((e,n,i)=>{let o=l.current.get(e);o&&(o.controller.abort(),o.cancel?.());let s=new AbortController,u={controller:s,cancel:null,segments:[],assistantMessage:``,assistantThinking:``,hasStructuredContent:!1,error:null,stopHandled:!1};return l.current.set(e,u),t({type:Y.ResetStream,threadId:e}),t({type:Y.SetStreaming,isStreaming:!0,threadId:e}),n(s.signal).then(n=>{if(!n||s.signal.aborted){v(e,i,u);return}u.cancel=oe(n,n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.type===`error`){let t=n.content||`Unknown error occurred`;u.error=t,e===c.current&&r(t);return}if(n.type!==`message`){if(n.type===`toolcall_delta`){n.partial?.content?.[0]?.id&&n.delta&&t({type:Y.UpdateToolCallProgress,toolCallId:n.partial.content[0].id,progress:{toolCallId:n.partial.content[0].id,toolName:n.partial.content[0].name,delta:n.delta,partial:n.partial}});return}if(n.model&&t({type:Y.SetStreamModel,model:n.model,threadId:e}),n.type===`thinking`||n.isThinking){let r=n.content??``;Pn(r,e),u.assistantThinking+=r,u.segments=Ve(u.segments,`thinking`,r),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:r,segments:u.segments,threadId:e})}else if(n.type===`result`)u.hasStructuredContent=!0,u.assistantMessage=n.content??``,u.segments=Ue(u.segments,n.content??``),t({type:Y.SetStreamContent,content:n.content??``,threadId:e});else{if(u.hasStructuredContent)return;let r=n.content??``;u.assistantMessage+=r,u.segments=Ve(u.segments,`content`,r),t({type:Y.AppendStreamChunk,chunkType:`content`,content:r,segments:u.segments,threadId:e})}}},()=>{v(e,i,u)},t=>{if(t.includes(`AbortError`)||t.includes(`canceled`)||t.includes(`BodyStreamBuffer was aborted`)){v(e,i,u);return}u.error=t,e===c.current&&r(t)},n=>{if(t({type:Y.IncrementStreamEventCount,threadId:e}),n.role===`assistant`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);if(n.isThinking??!1){u.assistantThinking+=i,u.segments=Ve(u.segments,`thinking`,i),t({type:Y.AppendStreamChunk,chunkType:`thinking`,content:i,segments:u.segments,threadId:e});return}let a=!1;if(typeof r==`object`&&Array.isArray(r)&&r.length>0)a=!0;else if(typeof i==`string`&&i.trim().startsWith(`[`))try{let e=JSON.parse(i);a=Array.isArray(e)&&e.length>0}catch{}a?(u.hasStructuredContent=!0,u.assistantMessage=i,u.segments=Ue(u.segments,i),t({type:Y.SetStreamContent,content:i,threadId:e})):(u.assistantMessage+=i,u.segments=Ve(u.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:e}))}else if(n.role===`tool`){let r=n.content??``,i=typeof r==`string`?r:JSON.stringify(r);i&&(u.assistantMessage+=i,u.segments=Ve(u.segments,`content`,i),t({type:Y.AppendStreamChunk,chunkType:`content`,content:i,segments:u.segments,threadId:e}))}})}).catch(n=>{if(l.current.delete(e),n instanceof Error&&n.name===`AbortError`){t({type:Y.ResetStream,threadId:e});return}if(n instanceof w){t({type:Y.ResetStream,threadId:e}),a(!0);return}if(n instanceof Error&&n.message.includes(`not currently processing`)){t({type:Y.ResetStream,threadId:e});return}let i=n instanceof Error?n.message:`Failed to send message. Please ensure the CLI server is running on localhost:641`;e===c.current&&r(i),console.error(`Failed to subscribe to chat stream:`,n),t({type:Y.ResetStream,threadId:e})}),s},[t,v]);(0,Z.useEffect)(()=>{for(let t of g)l.current.has(t)||e.threadStreamingStates[t]?.isStreaming||b(t,e=>ve(t,e),`default`)},[b,g,e.threadStreamingStates]);let x=(0,Z.useCallback)(async(e,n,i,a,o,c,l)=>{if(!u)return;let f=u;r(null),s(null);let m=`msg-${Date.now()}`,h;try{let e=await p(f,m);e.success&&e.stashed&&e.checkpointRef&&(h=e.checkpointRef)}catch{}let g={messageId:m,sender:`user`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,attachments:i.map(e=>({fileName:e.fileName,content:e.content,mimeType:e.mimeType})),checkpointRef:h};t({type:Y.AddMessage,message:g,threadId:f});let v=e.trim().replace(/\n/g,` `).slice(0,100);if(d&&(_(f,{title:v}).catch(e=>{console.error(`Failed to update thread title:`,e)}),t({type:Y.UpdateThreadTitle,projectId:d,threadId:f,title:v})),c){let r=a??void 0;if(!r&&typeof n==`string`){let e=n.split(/[:/]/)[0]?.trim();e&&(r=e)}if(!r){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:n,isThinking:!1};t({type:Y.AddMessage,message:e,threadId:f}),t({type:Y.ResetStream,threadId:f});return}t({type:Y.SetStreaming,isStreaming:!0,threadId:f});try{let i=await se(e,n,r,f),a={messageId:`msg-${Date.now()}-agent`,sender:`agent`,content:e,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1,generatedImageUrl:i.imageUrl,generatedImageData:i.imageData};t({type:Y.AddMessage,message:a,threadId:f})}catch(e){let r=e instanceof Error?e.message:`Image generation failed`,i={messageId:`msg-${Date.now()}-error`,sender:`agent`,content:`Error: ${r}`,contentType:`text`,timestamp:new Date().toISOString(),model:n,isThinking:!1};t({type:Y.AddMessage,message:i,threadId:f})}finally{t({type:Y.ResetStream,threadId:f})}return}b(f,t=>K(f,e,n,i,t,a,o,l),n)},[u,d,t,b]);(0,Z.useEffect)(()=>{let n=e.pendingChatMessage;if(!n||h||n.threadId!==u)return;let r=setTimeout(()=>{t({type:Y.ClearPendingChatMessage}),x(n.message,n.model,[],n.provider)},100);return()=>clearTimeout(r)},[e.pendingChatMessage,h,u,t,x]);let S=(0,Z.useMemo)(()=>u?m.filter(e=>e.threadId===u):[],[u,m]),C=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(h||!u||S.length===0||C.current)return;let[e]=S;C.current=!0,t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e.id});let n=setTimeout(()=>{x(e.message,e.model,e.attachments,e.provider,e.planMode,e.imageMode,e.ralphMode),C.current=!1},0);return()=>{clearTimeout(n),C.current=!1}},[t,x,h,S,u]),{error:n,setError:r,handleSend:x,handleStop:y,isStreaming:h,selectedThreadId:u,queuedMessagesForThread:S,handleRemoveQueuedMessage:(0,Z.useCallback)(e=>{let n=S.find(t=>t.id===e);t({type:Y.RemoveQueuedChatMessage,queuedMessageId:e}),!(!n||h||f.length>0||!u)&&x(n.message,n.model,n.attachments,n.provider,n.planMode,n.imageMode,n.ralphMode)},[t,x,h,f.length,S,u]),showEmptyBalanceDialog:i,setShowEmptyBalanceDialog:a}}function In(e){let t=(0,X.c)(10),{open:n,onClose:r}=e,i=xe(),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,Q.jsxs)($e,{children:[(0,Q.jsx)(Xe,{children:`Balance empty`}),(0,Q.jsx)(Ye,{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,Q.jsxs)(Ze,{children:[o,(0,Q.jsx)(Qe,{children:(0,Q.jsx)(J,{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,Q.jsx)(et,{open:n,onOpenChange:a,children:s}),t[6]=n,t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ln(e){let t=(0,X.c)(13),{todos:n}=e,r;t[0]===n?r=t[1]:(r=n.filter(zn),t[0]=n,t[1]=r);let i=r.length,a;t[2]===n.length?a=t[3]:(a=n.length===0&&(0,Q.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(Rn),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==n.length?(s=n.length>0&&(0,Q.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,Q.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 Rn(e){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.status===`done`?(0,Q.jsx)(he,{className:`h-4 w-4 shrink-0 mt-0.5 text-brand`}):e.status===`working`?(0,Q.jsx)(b,{className:`h-4 w-4 shrink-0 mt-0.5 text-yellow-500`}):(0,Q.jsx)(t,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:e.status===`done`?`line-through text-muted-foreground`:`text-foreground`,children:e.description})]},e.id)}function zn(e){return e.status===`done`}function Bn(){let e=(0,X.c)(16),{todos:t}=(0,Z.useContext)(pt),[n,r]=(0,Z.useState)(!1),i;e[0]===t?i=e[1]:(i=t.filter(Vn),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,Q.jsx)(_e,{className:`h-4 w-4 shrink-0`}),e[2]=o,e[3]=s):(o=e[2],s=e[3]);let c;e[4]!==a||e[5]!==t.length?(c=(0,Q.jsxs)(J,{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]=c):c=e[6];let u;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(le,{children:(0,Q.jsx)(l,{children:`Tasks`})}),e[7]=u):u=e[7];let d;e[8]===t?d=e[9]:(d=(0,Q.jsxs)(k,{className:`max-w-md`,children:[u,(0,Q.jsx)(Ln,{todos:t})]}),e[8]=t,e[9]=d);let f;e[10]!==n||e[11]!==d?(f=(0,Q.jsx)(E,{open:n,onOpenChange:r,children:d}),e[10]=n,e[11]=d,e[12]=f):f=e[12];let p;return e[13]!==c||e[14]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[c,f]}),e[13]=c,e[14]=f,e[15]=p):p=e[15],p}function Vn(e){return e.status===`done`}function Hn(e){let t=(0,X.c)(36),{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:o,dispatch:s}=Be(),{isCreatingProject:c,selectedThreadId:l}=o,{handleSend:u,handleStop:d,isStreaming:f,queuedMessagesForThread:p,handleRemoveQueuedMessage:m,showEmptyBalanceDialog:h,setShowEmptyBalanceDialog:g}=Fn(),_=o.pendingChatMessage?.threadId===l,y=f||_,b=a.length>0,{hasChanges:x,changedFilesCount:S}=An(l??void 0),{setActiveMainTab:C}=tt(),w;t[2]!==s||t[3]!==l?(w=async()=>{if(l)try{let e=await n(l);s({type:Y.ClearMessages}),console.log(`New conversation started:`,e);let t=await te(l);s({type:Y.SetMessages,messages:t.messages})}catch(e){console.error(`Failed to start new chat:`,e)}},t[2]=s,t[3]=l,t[4]=w):w=t[4];let T=w,E;t[5]===g?E=t[6]:(E=()=>g(!1),t[5]=g,t[6]=E);let D;t[7]!==h||t[8]!==E?(D=(0,Q.jsx)(In,{open:h,onClose:E}),t[7]=h,t[8]=E,t[9]=D):D=t[9];let O;t[10]!==S||t[11]!==T||t[12]!==x||t[13]!==b||t[14]!==C?(O=(b||x)&&(0,Q.jsxs)(`div`,{className:`absolute -top-12 left-0 z-10 ml-8 flex items-center gap-2`,children:[b&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:T,children:[(0,Q.jsx)(R,{className:`h-4 w-4 shrink-0`}),`New Chat`]}),x&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`gap-2`,onClick:()=>C(`review`),children:[(0,Q.jsx)(v,{className:`h-4 w-4 shrink-0`}),S,` `,S===1?`File`:`Files`,` Changed`]}),b&&(0,Q.jsx)(Bn,{})]}),t[10]=S,t[11]=T,t[12]=x,t[13]=b,t[14]=C,t[15]=O):O=t[15];let k=!l&&!c,A;t[16]!==y||t[17]!==m||t[18]!==u||t[19]!==d||t[20]!==p||t[21]!==k?(A=(0,Q.jsx)(Qt,{onSend:u,onStop:d,isStreaming:y,disabled:k,initialValue:``,queuedMessages:p,onRemoveQueuedMessage:m,isOverlay:!1}),t[16]=y,t[17]=m,t[18]=u,t[19]=d,t[20]=p,t[21]=k,t[22]=A):A=t[22];let j;t[23]!==O||t[24]!==A?(j=(0,Q.jsxs)(`div`,{className:`relative`,children:[O,A]}),t[23]=O,t[24]=A,t[25]=j):j=t[25];let M=l??void 0,N;t[26]!==y||t[27]!==a||t[28]!==M?(N=(0,Q.jsx)(Nn,{threadId:M,isStreaming:y,messages:a}),t[26]=y,t[27]=a,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==j?(P=(0,Q.jsxs)(`div`,{className:`relative mx-auto min-w-[400px] w-[90vw] max-w-3xl`,children:[j,N]}),t[30]=N,t[31]=j,t[32]=P):P=t[32];let F;return t[33]!==P||t[34]!==D?(F=(0,Q.jsxs)(Q.Fragment,{children:[D,P]}),t[33]=P,t[34]=D,t[35]=F):F=t[35],F}export{ut as _,un as a,lt as b,cn as c,Ct as d,yt as f,ht as g,mt as h,ln as i,sn as l,gt as m,An as n,mn as o,bt as p,rn as r,on as s,Hn as t,an as u,ft as v,dt as y};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{$i as t,Er as n,Nr as r,_a as i,ha as a,ia as o,sa as s}from"./dialogs-config-BXDglGdB.js";import{C as c,T as l,_ as u,b as d,d as f,f as p,g as m,h,m as g,w as _,x as v,y}from"./react-vendor-Bpg1hd5i.js";var b=a(),x=e(i(),1),S=r(),C=d,w=l,T=x.forwardRef((e,t)=>{let r=(0,b.c)(14),i,a,s,c;r[0]===e?(i=r[1],a=r[2],s=r[3],c=r[4]):({className:a,inset:s,children:i,...c}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=s,r[4]=c);let l=s&&`pl-8`,u;r[5]!==a||r[6]!==l?(u=n(`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,a),r[5]=a,r[6]=l,r[7]=u):u=r[7];let d;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,S.jsx)(o,{className:`ml-auto h-4 w-4`}),r[8]=d):d=r[8];let f;return r[9]!==i||r[10]!==c||r[11]!==t||r[12]!==u?(f=(0,S.jsxs)(_,{ref:t,className:u,...c,children:[i,d]}),r[9]=i,r[10]=c,r[11]=t,r[12]=u,r[13]=f):f=r[13],f});T.displayName=_.displayName;var E=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`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),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(c,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});E.displayName=c.displayName;var D=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`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),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(u,{children:(0,S.jsx)(p,{ref:t,className:o,...a})}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});D.displayName=p.displayName;var O=x.forwardRef((e,t)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=n(`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),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==t||r[9]!==c?(l=(0,S.jsx)(g,{ref:t,className:c,...o}),r[7]=o,r[8]=t,r[9]=c,r[10]=l):l=r[10],l});O.displayName=g.displayName;var k=x.forwardRef((e,t)=>{let r=(0,b.c)(14),i,a,o,c;r[0]===e?(i=r[1],a=r[2],o=r[3],c=r[4]):({className:o,children:a,checked:i,...c}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o,r[4]=c);let l;r[5]===o?l=r[6]:(l=n(`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),r[5]=o,r[6]=l);let u;r[7]===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)(h,{children:(0,S.jsx)(s,{className:`h-4 w-4`})})}),r[7]=u):u=r[7];let d;return r[8]!==i||r[9]!==a||r[10]!==c||r[11]!==t||r[12]!==l?(d=(0,S.jsxs)(f,{ref:t,className:l,checked:i,...c,children:[u,a]}),r[8]=i,r[9]=a,r[10]=c,r[11]=t,r[12]=l,r[13]=d):d=r[13],d});k.displayName=f.displayName;var A=x.forwardRef((e,r)=>{let i=(0,b.c)(12),a,o,s;i[0]===e?(a=i[1],o=i[2],s=i[3]):({className:o,children:a,...s}=e,i[0]=e,i[1]=a,i[2]=o,i[3]=s);let c;i[4]===o?c=i[5]:(c=n(`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),i[4]=o,i[5]=c);let l;i[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,S.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,S.jsx)(h,{children:(0,S.jsx)(t,{className:`h-2 w-2 fill-current`})})}),i[6]=l):l=i[6];let u;return i[7]!==a||i[8]!==s||i[9]!==r||i[10]!==c?(u=(0,S.jsxs)(y,{ref:r,className:c,...s,children:[l,a]}),i[7]=a,i[8]=s,i[9]=r,i[10]=c,i[11]=u):u=i[11],u});A.displayName=y.displayName;var j=x.forwardRef((e,t)=>{let r=(0,b.c)(11),i,a,o;r[0]===e?(i=r[1],a=r[2],o=r[3]):({className:i,inset:a,...o}=e,r[0]=e,r[1]=i,r[2]=a,r[3]=o);let s=a&&`pl-8`,c;r[4]!==i||r[5]!==s?(c=n(`px-2 py-1.5 text-sm font-semibold text-foreground`,s,i),r[4]=i,r[5]=s,r[6]=c):c=r[6];let l;return r[7]!==o||r[8]!==t||r[9]!==c?(l=(0,S.jsx)(m,{ref:t,className:c,...o}),r[7]=o,r[8]=t,r[9]=c,r[10]=l):l=r[10],l});j.displayName=m.displayName;var M=x.forwardRef((e,t)=>{let r=(0,b.c)(9),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===i?o=r[4]:(o=n(`-mx-1 my-1 h-px bg-border`,i),r[3]=i,r[4]=o);let s;return r[5]!==a||r[6]!==t||r[7]!==o?(s=(0,S.jsx)(v,{ref:t,className:o,...a}),r[5]=a,r[6]=t,r[7]=o,r[8]=s):s=r[8],s});M.displayName=v.displayName;var N=e=>{let t=(0,b.c)(8),r,i;t[0]===e?(r=t[1],i=t[2]):({className:r,...i}=e,t[0]=e,t[1]=r,t[2]=i);let a;t[3]===r?a=t[4]:(a=n(`ml-auto text-xs tracking-widest text-muted-foreground`,r),t[3]=r,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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./history-view-i7fGKCkc.js";export{e as ConversationHistoryView,e as default};
|