@algochad/archcoder 2.0.2 → 2.0.3

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.
@@ -1 +1 @@
1
- import{e as y,R as j,u as n,ak as R,a4 as C,ao as _,ap as N,am as k,al as M}from"./vendor-.bun-HTKwyaEM.js";import{c as O}from"./index-o_d2wtWC.js";import{M as S}from"./main-B6oiMU86.js";const E=v=>{const e=y.c(26),{open:h,onOpenChange:t,initialPrompt:b}=v,o=j.useId(),g=z;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(R,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=u):u=e[0];let f,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{g()&&w.preventDefault()},m=O("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=f,e[2]=m):(f=e[1],m=e[2]);let s;e[3]!==t?(s=()=>t(!1),e[3]=t,e[4]=s):s=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(C,{className:"h-5 w-5"}),e[5]=p):p=e[5];let l;e[6]!==s?(l=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"aria-label":"Close multi-run",className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p})}),e[6]=s,e[7]=l):l=e[7];let a;e[8]!==o?(a=n.jsx(_,{id:o,className:"sr-only",children:"ArchCoder Multi-Run window."}),e[8]=o,e[9]=a):a=e[9];let r,i;e[10]!==t?(r=()=>t(!1),i=()=>t(!1),e[10]=t,e[11]=r,e[12]=i):(r=e[11],i=e[12]);let c;e[13]!==b||e[14]!==r||e[15]!==i?(c=n.jsx(S,{initialPrompt:b,onCreated:r,onCancel:i,isWindowed:!0}),e[13]=b,e[14]=r,e[15]=i,e[16]=c):c=e[16];let d;e[17]!==o||e[18]!==c||e[19]!==l||e[20]!==a?(d=n.jsxs(N,{children:[u,n.jsxs(k,{"aria-describedby":o,onInteractOutside:f,className:m,children:[l,a,c]})]}),e[17]=o,e[18]=c,e[19]=l,e[20]=a,e[21]=d):d=e[21];let x;return e[22]!==t||e[23]!==h||e[24]!==d?(x=n.jsx(M,{open:h,onOpenChange:t,children:d}),e[22]=t,e[23]=h,e[24]=d,e[25]=x):x=e[25],x};function z(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{E as MultiRunWindow};
1
+ import{e as y,R as j,u as n,ak as R,a4 as C,ao as _,ap as N,am as k,al as M}from"./vendor-.bun-HTKwyaEM.js";import{c as O}from"./index-DKc7ZmSW.js";import{M as S}from"./main-CaAZH2Mv.js";const E=v=>{const e=y.c(26),{open:h,onOpenChange:t,initialPrompt:b}=v,o=j.useId(),g=z;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(R,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=u):u=e[0];let f,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{g()&&w.preventDefault()},m=O("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=f,e[2]=m):(f=e[1],m=e[2]);let s;e[3]!==t?(s=()=>t(!1),e[3]=t,e[4]=s):s=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(C,{className:"h-5 w-5"}),e[5]=p):p=e[5];let l;e[6]!==s?(l=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"aria-label":"Close multi-run",className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p})}),e[6]=s,e[7]=l):l=e[7];let a;e[8]!==o?(a=n.jsx(_,{id:o,className:"sr-only",children:"ArchCoder Multi-Run window."}),e[8]=o,e[9]=a):a=e[9];let r,i;e[10]!==t?(r=()=>t(!1),i=()=>t(!1),e[10]=t,e[11]=r,e[12]=i):(r=e[11],i=e[12]);let c;e[13]!==b||e[14]!==r||e[15]!==i?(c=n.jsx(S,{initialPrompt:b,onCreated:r,onCancel:i,isWindowed:!0}),e[13]=b,e[14]=r,e[15]=i,e[16]=c):c=e[16];let d;e[17]!==o||e[18]!==c||e[19]!==l||e[20]!==a?(d=n.jsxs(N,{children:[u,n.jsxs(k,{"aria-describedby":o,onInteractOutside:f,className:m,children:[l,a,c]})]}),e[17]=o,e[18]=c,e[19]=l,e[20]=a,e[21]=d):d=e[21];let x;return e[22]!==t||e[23]!==h||e[24]!==d?(x=n.jsx(M,{open:h,onOpenChange:t,children:d}),e[22]=t,e[23]=h,e[24]=d,e[25]=x):x=e[25],x};function z(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{E as MultiRunWindow};
@@ -1 +1 @@
1
- import{e as x,R as h,u as r,ak as b,ao as w,ap as g,am as y,al as j}from"./vendor-.bun-HTKwyaEM.js";import{c as S}from"./index-o_d2wtWC.js";import{S as v}from"./main-B6oiMU86.js";const O=f=>{const e=x.c(15),{open:m,onOpenChange:t}=f,n=h.useId(),p=R;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(b,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=l):l=e[0];let i,c;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=u=>{p()&&u.preventDefault()},c=S("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[960px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=i,e[2]=c):(i=e[1],c=e[2]);let s;e[3]!==n?(s=r.jsx(w,{id:n,className:"sr-only",children:"ArchCoder settings window."}),e[3]=n,e[4]=s):s=e[4];let o;e[5]!==t?(o=r.jsx(v,{onClose:()=>t(!1),isWindowed:!0}),e[5]=t,e[6]=o):o=e[6];let a;e[7]!==n||e[8]!==s||e[9]!==o?(a=r.jsxs(g,{children:[l,r.jsxs(y,{"aria-describedby":n,onInteractOutside:i,className:c,children:[s,o]})]}),e[7]=n,e[8]=s,e[9]=o,e[10]=a):a=e[10];let d;return e[11]!==t||e[12]!==m||e[13]!==a?(d=r.jsx(j,{open:m,onOpenChange:t,children:a}),e[11]=t,e[12]=m,e[13]=a,e[14]=d):d=e[14],d};function R(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{O as SettingsWindow};
1
+ import{e as x,R as h,u as r,ak as b,ao as w,ap as g,am as y,al as j}from"./vendor-.bun-HTKwyaEM.js";import{c as S}from"./index-DKc7ZmSW.js";import{S as v}from"./main-CaAZH2Mv.js";const O=f=>{const e=x.c(15),{open:m,onOpenChange:t}=f,n=h.useId(),p=R;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(b,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=l):l=e[0];let i,c;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=u=>{p()&&u.preventDefault()},c=S("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[960px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=i,e[2]=c):(i=e[1],c=e[2]);let s;e[3]!==n?(s=r.jsx(w,{id:n,className:"sr-only",children:"ArchCoder settings window."}),e[3]=n,e[4]=s):s=e[4];let o;e[5]!==t?(o=r.jsx(v,{onClose:()=>t(!1),isWindowed:!0}),e[5]=t,e[6]=o):o=e[6];let a;e[7]!==n||e[8]!==s||e[9]!==o?(a=r.jsxs(g,{children:[l,r.jsxs(y,{"aria-describedby":n,onInteractOutside:i,className:c,children:[s,o]})]}),e[7]=n,e[8]=s,e[9]=o,e[10]=a):a=e[10];let d;return e[11]!==t||e[12]!==m||e[13]!==a?(d=r.jsx(j,{open:m,onOpenChange:t,children:a}),e[11]=t,e[12]=m,e[13]=a,e[14]=d):d=e[14],d};function R(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{O as SettingsWindow};
@@ -1,3 +1,3 @@
1
- import{R as n,u as s,eU as Ne,aW as Qe,bL as Ze,dn as Xe,bM as Ye,bs as Ge,a4 as Je,aF as et}from"./vendor-.bun-HTKwyaEM.js";import{u as B,v as tt,b4 as nt,c as T}from"./index-o_d2wtWC.js";import{u as rt,a as st,b as ot,c as at,d as $,C as P,D as ce,e as it,B as C,T as ct,f as lt}from"./main-B6oiMU86.js";const ut={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},X={ctrl:"5",cmd:"3"},Re={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},dt={retry:{maxRetries:0,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},ft=(b,k)=>{if(k)switch(b){case"arrow-up":return`\x1B[1;${X[k]}A`;case"arrow-down":return`\x1B[1;${X[k]}B`;case"arrow-right":return`\x1B[1;${X[k]}C`;case"arrow-left":return`\x1B[1;${X[k]}D`}return ut[b]??null},xt=()=>{const{terminal:b,runtime:k}=rt(),{currentTheme:le}=st(),{monoFont:Y}=lt(),Ie=B(e=>e.terminalFontSize),ue=B(e=>e.bottomTerminalHeight),de=B(e=>e.isBottomTerminalExpanded),{isMobile:l,hasTouchInput:ze}=ot(),A=k.platform!=="vscode",De=B(e=>e.showTerminalQuickKeysOnDesktop),D=l||De,{currentSessionId:Fe,newSessionDraft:Me}=tt(),G=Fe!==null||Me?.open===!0,a=at()??null,S=$(),fe=S.sessions,V=S.hasHydrated,me=S.ensureDirectory,pe=S.createTab,L=S.setActiveTab,U=S.closeTab,O=S.setTabSessionId,N=S.setConnecting,J=S.appendToBuffer,w=n.useMemo(()=>{if(a)return fe.get(a)},[fe,a]),m=n.useMemo(()=>w?A?w.activeTabId??w.tabs[0]?.id??null:w.tabs[0]?.id??null:null,[w,A]),ee=n.useMemo(()=>{if(w)return m?w.tabs.find(e=>e.id===m)??w.tabs[0]:w.tabs[0]},[w,m]),h=ee?.terminalSessionId??null,Be=ee?.bufferChunks??[],Oe=ee?.isConnecting??!1,[he,x]=n.useState(null),[Ke,g]=n.useState(!1),[p,y]=n.useState(null),[H,be]=n.useState(!1),[we,xe]=n.useState(0),ye=n.useId(),te=n.useRef(null),F=n.useRef(null),ge=n.useRef(m),M=n.useRef(h),q=n.useRef(a),R=n.useRef(null),ve=n.useRef(null),Te=n.useRef(!1),ne=n.useRef(null),W=n.useRef(new Set),Ce=n.useRef(!1),I=n.useCallback(()=>{typeof document<"u"&&!document.hasFocus()||R.current?.focus()},[]);n.useEffect(()=>{if(!V||Ce.current)return;Ce.current=!0;const e=new Set;for(const[,r]of $.getState().sessions.entries())for(const t of r.tabs)t.terminalSessionId&&e.add(t.terminalSessionId);W.current=e},[V]);const _e=B(e=>e.activeMainTab),K=B(e=>e.isBottomTerminalOpen),d=_e==="terminal"||K,[re,$e]=n.useState(d);n.useEffect(()=>{!d||k.platform==="vscode"||nt()},[d,k.platform]),n.useEffect(()=>{d&&$e(!0)},[d]),n.useEffect(()=>{Te.current=d},[d]),n.useEffect(()=>{M.current=h},[h]),n.useEffect(()=>{ge.current=m},[m]),n.useEffect(()=>{q.current=a},[a]),n.useEffect(()=>{!D&&p!==null&&y(null)},[D,p,y]),n.useEffect(()=>{!h&&p!==null&&y(null)},[h,p,y]);const f=n.useCallback(()=>{te.current?.(),te.current=null,F.current=null},[]);n.useEffect(()=>()=>{f(),M.current=null},[f]);const ke=n.useCallback((e,r,t,u=Re)=>{if(F.current===t)return;f(),F.current=t;const o=b.connect(t,{onEvent:c=>{if(F.current===t)switch(c.type){case"connected":{N(e,r,!1),x(null),g(!1),I(),ne.current===t&&(ne.current=null,b.sendInput(t,"\r").catch(()=>{}));break}case"reconnecting":{const i=c.attempt??0,v=c.maxAttempts??3;x(`Reconnecting (${i}/${v})...`),g(!1);break}case"data":{c.data&&J(e,r,c.data);break}case"exit":{const i=typeof c.exitCode=="number"?c.exitCode:null,v=typeof c.signal=="number"?c.signal:null,ae=!!$.getState().getDirectoryState(e)?.tabs.find(Z=>Z.id===r)?.label?.startsWith("Action:");J(e,r,`\r
1
+ import{R as n,u as s,eU as Ne,aW as Qe,bL as Ze,dn as Xe,bM as Ye,bs as Ge,a4 as Je,aF as et}from"./vendor-.bun-HTKwyaEM.js";import{u as B,v as tt,b4 as nt,c as T}from"./index-DKc7ZmSW.js";import{u as rt,a as st,b as ot,c as at,d as $,C as P,D as ce,e as it,B as C,T as ct,f as lt}from"./main-CaAZH2Mv.js";const ut={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},X={ctrl:"5",cmd:"3"},Re={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},dt={retry:{maxRetries:0,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},ft=(b,k)=>{if(k)switch(b){case"arrow-up":return`\x1B[1;${X[k]}A`;case"arrow-down":return`\x1B[1;${X[k]}B`;case"arrow-right":return`\x1B[1;${X[k]}C`;case"arrow-left":return`\x1B[1;${X[k]}D`}return ut[b]??null},xt=()=>{const{terminal:b,runtime:k}=rt(),{currentTheme:le}=st(),{monoFont:Y}=lt(),Ie=B(e=>e.terminalFontSize),ue=B(e=>e.bottomTerminalHeight),de=B(e=>e.isBottomTerminalExpanded),{isMobile:l,hasTouchInput:ze}=ot(),A=k.platform!=="vscode",De=B(e=>e.showTerminalQuickKeysOnDesktop),D=l||De,{currentSessionId:Fe,newSessionDraft:Me}=tt(),G=Fe!==null||Me?.open===!0,a=at()??null,S=$(),fe=S.sessions,V=S.hasHydrated,me=S.ensureDirectory,pe=S.createTab,L=S.setActiveTab,U=S.closeTab,O=S.setTabSessionId,N=S.setConnecting,J=S.appendToBuffer,w=n.useMemo(()=>{if(a)return fe.get(a)},[fe,a]),m=n.useMemo(()=>w?A?w.activeTabId??w.tabs[0]?.id??null:w.tabs[0]?.id??null:null,[w,A]),ee=n.useMemo(()=>{if(w)return m?w.tabs.find(e=>e.id===m)??w.tabs[0]:w.tabs[0]},[w,m]),h=ee?.terminalSessionId??null,Be=ee?.bufferChunks??[],Oe=ee?.isConnecting??!1,[he,x]=n.useState(null),[Ke,g]=n.useState(!1),[p,y]=n.useState(null),[H,be]=n.useState(!1),[we,xe]=n.useState(0),ye=n.useId(),te=n.useRef(null),F=n.useRef(null),ge=n.useRef(m),M=n.useRef(h),q=n.useRef(a),R=n.useRef(null),ve=n.useRef(null),Te=n.useRef(!1),ne=n.useRef(null),W=n.useRef(new Set),Ce=n.useRef(!1),I=n.useCallback(()=>{typeof document<"u"&&!document.hasFocus()||R.current?.focus()},[]);n.useEffect(()=>{if(!V||Ce.current)return;Ce.current=!0;const e=new Set;for(const[,r]of $.getState().sessions.entries())for(const t of r.tabs)t.terminalSessionId&&e.add(t.terminalSessionId);W.current=e},[V]);const _e=B(e=>e.activeMainTab),K=B(e=>e.isBottomTerminalOpen),d=_e==="terminal"||K,[re,$e]=n.useState(d);n.useEffect(()=>{!d||k.platform==="vscode"||nt()},[d,k.platform]),n.useEffect(()=>{d&&$e(!0)},[d]),n.useEffect(()=>{Te.current=d},[d]),n.useEffect(()=>{M.current=h},[h]),n.useEffect(()=>{ge.current=m},[m]),n.useEffect(()=>{q.current=a},[a]),n.useEffect(()=>{!D&&p!==null&&y(null)},[D,p,y]),n.useEffect(()=>{!h&&p!==null&&y(null)},[h,p,y]);const f=n.useCallback(()=>{te.current?.(),te.current=null,F.current=null},[]);n.useEffect(()=>()=>{f(),M.current=null},[f]);const ke=n.useCallback((e,r,t,u=Re)=>{if(F.current===t)return;f(),F.current=t;const o=b.connect(t,{onEvent:c=>{if(F.current===t)switch(c.type){case"connected":{N(e,r,!1),x(null),g(!1),I(),ne.current===t&&(ne.current=null,b.sendInput(t,"\r").catch(()=>{}));break}case"reconnecting":{const i=c.attempt??0,v=c.maxAttempts??3;x(`Reconnecting (${i}/${v})...`),g(!1);break}case"data":{c.data&&J(e,r,c.data);break}case"exit":{const i=typeof c.exitCode=="number"?c.exitCode:null,v=typeof c.signal=="number"?c.signal:null,ae=!!$.getState().getDirectoryState(e)?.tabs.find(Z=>Z.id===r)?.label?.startsWith("Action:");J(e,r,`\r
2
2
  [Process exited${i!==null?` with code ${i}`:""}${v!==null?` (signal ${v})`:""}]\r
3
3
  `),O(e,r,null),N(e,r,!1),x(ae?null:"Terminal session ended"),g(!1),f();break}}},onError:(c,i)=>{if(F.current!==t)return;const v=i?`Connection failed: ${c.message}`:c.message||"Terminal stream connection error";x(v),g(!!i),i&&(N(e,r,!1),O(e,r,null),f())}},u);te.current=()=>{o.close(),F.current=null}},[J,f,I,N,O,b]);n.useEffect(()=>{let e=!1;if(!V||!re)return;if(!a){x(G?"No working directory available for terminal.":"Select a session to open the terminal."),f();return}return(async()=>{const t=a;if(!q.current||q.current!==t)return;me(t);const u=$.getState().getDirectoryState(t);if(!u||u.tabs.length===0)return;const o=A?u.activeTabId??u.tabs[0]?.id??null:u.tabs[0]?.id??null;if(!o)return;const c=u.tabs.find(z=>z.id===o)??u.tabs[0];let i=c?.terminalSessionId??null;const v=!!c?.label?.startsWith("Action:"),Q=(c?.bufferLength??0)>0||(c?.bufferChunks?.length??0)>0,ae=!!i&&W.current.has(i)&&(c?.bufferLength??0)===0&&(c?.bufferChunks?.length??0)===0,Z=!!i&&W.current.has(i);if(!i){if(v&&Q){N(t,o,!1);return}x(null),g(!1),N(t,o,!0);try{const z=ve.current,ie=await b.createSession({cwd:t,cols:z?.cols,rows:z?.rows});if(!(!e&&q.current===t&&ge.current===o)){try{await b.close(ie.sessionId)}catch{}return}O(t,o,ie.sessionId),i=ie.sessionId}catch(z){e||(x(z instanceof Error?z.message:"Failed to start terminal session"),g(!0),N(t,o,!1));return}}!i||e||(M.current=i,Z&&W.current.delete(i),ae&&(ne.current=i),ke(t,o,i,Z?dt:Re))})(),()=>{e=!0,M.current=null,f()}},[G,a,h,m,re,A,V,me,N,O,ke,f,b]),n.useEffect(()=>{if(!d)return;if(typeof window>"u"){I();return}const e=window.requestAnimationFrame(()=>{I()});return()=>{window.cancelAnimationFrame(e)}},[m,I,d]);const se=n.useCallback(async()=>{if(!a||H)return;const e=$.getState().getDirectoryState(a),r=A?m??e?.activeTabId??e?.tabs[0]?.id??null:e?.tabs[0]?.id??null;if(r){be(!0),x(null),g(!1),f();try{await U(a,r)}catch(t){x(t instanceof Error?t.message:"Failed to restart terminal"),g(!0)}finally{be(!1)}}},[m,U,f,a,A,H]),Pe=n.useCallback(async()=>{await se()},[se]),Ve=n.useCallback(()=>{if(!a)return;const e=pe(a);L(a,e),x(null),g(!1),f()},[pe,f,a,L]),Le=n.useCallback(e=>{a&&(L(a,e),x(null),g(!1),f())},[f,a,L]),Ue=n.useCallback(e=>{a&&(e===m&&f(),x(null),g(!1),U(a,e))},[m,U,f,a]),_=n.useCallback(e=>{if(!e)return;let r=e,t=!1;if(p&&e.length>0){const o=e[0];if(o.length===1&&/[a-zA-Z]/.test(o)){const c=o.toUpperCase();(p==="ctrl"||p==="cmd")&&(r=String.fromCharCode(c.charCodeAt(0)&31),t=!0)}t||(t=!0)}const u=M.current;u&&(b.sendInput(u,r).catch(o=>{x(o instanceof Error?o.message:"Failed to send input")}),t&&(y(null),R.current?.focus()))},[p,y,b]),He=n.useCallback((e,r)=>{if(ve.current={cols:e,rows:r},!Te.current)return;const t=M.current;t&&b.resize({sessionId:t,cols:e,rows:r}).catch(()=>{})},[b]),Se=n.useCallback(e=>{y(r=>r===e?null:e),R.current?.focus()},[y]),j=n.useCallback(e=>{const r=ft(e,p);r&&(_(r),y(null),R.current?.focus())},[p,_,y]);n.useEffect(()=>{if(!D||!p||!h)return;const e=r=>{if(r.repeat)return;const t=r.key;if(!t||t==="Control"||t==="Meta"||t==="Alt"||t==="Shift")return;const u=t.length===1?t.toLowerCase():t,o=r.code??"",c=o.startsWith("Key")&&o.length===4?o.slice(3).toUpperCase():null,i=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():c,v={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(u in v){r.preventDefault(),r.stopPropagation(),j(v[u]);return}if(p==="ctrl"&&i&&i.length===1&&i>="A"&&i<="Z"){const Q=String.fromCharCode(i.charCodeAt(0)&31);r.preventDefault(),r.stopPropagation(),_(Q),y(null),R.current?.focus()}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[p,j,_,D,y,h]);const qe=n.useMemo(()=>{const e=P[ce].stack;if(typeof window>"u")return(P[Y]??P[ce]).stack;const t=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return t&&t.trim().length>0?t.trim():(P[Y]??P[ce]).stack??e},[Y]),je=n.useMemo(()=>it(le),[le]),oe=n.useMemo(()=>{const e=a??"no-dir",r=m??"no-tab",t=h??`pending-${r}`;return`${e}::${r}::${t}`},[a,m,h]),Ee=n.useMemo(()=>`${h??oe}::layout-${we}`,[h,oe,we]);if(n.useEffect(()=>{if(l||!K||!d)return;if(typeof window>"u"){xe(r=>r+1);return}const e=window.setTimeout(()=>{xe(r=>r+1)},140);return()=>{window.clearTimeout(e)}},[ue,de,K,l,d]),n.useEffect(()=>{if(!d)return;const e=R.current;if(!e)return;const r=()=>{e.fit()};if(typeof window<"u"){const t=window.requestAnimationFrame(()=>{r(),I()}),u=[220,400].map(o=>window.setTimeout(r,o));return()=>{window.cancelAnimationFrame(t),u.forEach(o=>window.clearTimeout(o))}}r()},[I,d,oe,h]),n.useEffect(()=>{if(l||!d||!K)return;const e=R.current;if(!e)return;const r=()=>{e.fit()};if(typeof window<"u"){const t=window.requestAnimationFrame(()=>{r()}),u=[0,80,180,320].map(o=>window.setTimeout(r,o));return()=>{window.cancelAnimationFrame(t),u.forEach(o=>window.clearTimeout(o))}}r()},[ue,de,K,l,d]),!G)return s.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:"Select a session to open the terminal"});if(!a)return s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[s.jsx("p",{children:"No working directory available for this session."}),s.jsx("button",{onClick:se,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Retry"})]});const E=!h||Oe||H,We=l?d:re,Ae=s.jsxs(s.Fragment,{children:[s.jsx(C,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>j("esc"),disabled:E,children:"Esc"}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("tab"),disabled:E,children:[s.jsx(Ne,{size:16}),s.jsx("span",{className:"sr-only",children:"Tab"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:T("h-6 w-9 p-0",p==="ctrl"?"border-[var(--primary-base)] text-[var(--primary-base)] bg-[var(--primary-base)]/10 hover:text-[var(--primary-base)]":void 0),onClick:()=>Se("ctrl"),disabled:E,children:[s.jsx("span",{className:"text-xs font-medium",children:"Ctrl"}),s.jsx("span",{className:"sr-only",children:"Control modifier"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:T("h-6 w-9 p-0",p==="cmd"?"border-[var(--primary-base)] text-[var(--primary-base)] bg-[var(--primary-base)]/10 hover:text-[var(--primary-base)]":void 0),onClick:()=>Se("cmd"),disabled:E,children:[s.jsx(Qe,{size:16}),s.jsx("span",{className:"sr-only",children:"Command modifier"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-up"),disabled:E,children:[s.jsx(Ze,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow up"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-left"),disabled:E,children:[s.jsx(Xe,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow left"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-down"),disabled:E,children:[s.jsx(Ye,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow down"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-right"),disabled:E,children:[s.jsx(Ne,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow right"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("enter"),disabled:E,children:[s.jsx(Ge,{size:16}),s.jsx("span",{className:"sr-only",children:"Enter"})]})]});return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[s.jsxs("div",{className:T("sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",l?"px-4 py-1.5":"px-5 py-2"),children:[A&&w?s.jsxs("div",{className:T("pl-1 pr-1 flex items-center gap-2",l?"mt-1":"mt-2"),children:[s.jsx("div",{className:T("min-w-0 flex-1 overflow-x-auto",l?"pb-0.5":"pb-1"),children:s.jsxs("div",{className:T("flex w-max items-center pr-1","gap-1"),children:[w.tabs.map(e=>{const r=e.id===m;return s.jsxs("div",{className:T("group flex items-center rounded-md border whitespace-nowrap",l?"h-8 gap-0.5 pl-2 pr-1.5 text-sm leading-none":"gap-1 pl-2 pr-1 py-1 text-xs",r?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx("button",{type:"button",onClick:()=>Le(e.id),className:T("truncate text-left",l?"!min-h-0 !min-w-0 max-w-[9.5rem]":"max-w-[10rem]"),title:e.label,children:e.label}),s.jsx("button",{type:"button",className:T("flex items-center justify-center rounded-sm text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",l?"!min-h-0 !min-w-0 h-3.5 w-3.5 p-0 leading-none":"h-4 w-4 p-0 leading-none",!l&&!r&&"opacity-0 group-hover:opacity-100"),onClick:t=>{t.stopPropagation(),Ue(e.id)},title:"Close tab",children:l?s.jsx("span",{"aria-hidden":!0,children:"×"}):s.jsx(Je,{size:12})})]},e.id)}),s.jsx("button",{type:"button",onClick:Ve,className:T("ml-1 flex items-center justify-center rounded-md border border-[var(--interactive-border)] bg-transparent text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",l?"!min-h-0 !min-w-0 h-8 w-8":"h-6.5 w-6.5"),title:"New tab",children:s.jsx(et,{size:l?18:16})})]})}),!l&&D?s.jsx("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto pb-1",children:Ae}):null]}):null,D&&(l||!A||!w)?s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Ae}):null]}),s.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:je.background},id:ye,"data-keyboard-avoid":"true",children:[s.jsx("div",{className:"h-full w-full box-border pl-7 pr-5 pt-3 pb-4",children:We?s.jsx(ct,{ref:e=>{R.current=e},sessionKey:Ee,chunks:Be,onInput:_,onResize:He,theme:je,fontFamily:qe,fontSize:Ie,enableTouchScroll:ze,autoFocus:d,keyboardAvoidTargetId:ye},Ee):null}),he&&s.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[s.jsx("span",{children:he}),Ke&&l&&s.jsx(C,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Pe,disabled:H,title:"Force kill and create fresh session",type:"button",children:"Hard Restart"})]})]})]})};export{xt as TerminalView};
@@ -1 +1 @@
1
- import{R as x,u as e,bq as I,aS as P,bs as v,aA as L,aR as N}from"./vendor-.bun-HTKwyaEM.js";import{g as $,h as q,i as A,j as H,k as Q,I as U,l as w,m as y,n as k}from"./main-B6oiMU86.js";import{v as m,$ as B}from"./index-o_d2wtWC.js";function E(a){const n=Date.now()-a,f=Math.floor(n/1e3),i=Math.floor(f/60),r=Math.floor(i/60),l=Math.floor(r/24);return f<60?"just now":i<60?`${i}m ago`:r<24?`${r}h ago`:l<7?`${l}d ago`:new Date(a).toLocaleDateString()}const J=({open:a,onOpenChange:t,onScrollToMessage:n,onScrollByTurnOffset:f,onResumeToLatest:i})=>{const r=m(s=>s.currentSessionId),l=B(s=>r?s.messages.get(r)||[]:[]),M=m(s=>s.revertToMessage),S=m(s=>s.forkFromMessage),D=m(s=>s.loadSessions),[h,p]=x.useState(null),[c,T]=x.useState(""),d=x.useMemo(()=>l.filter(o=>o.info.role==="user").reverse(),[l]),g=x.useMemo(()=>{if(!c.trim())return d;const s=c.toLowerCase();return d.filter(o=>b(o.parts).toLowerCase().includes(s))},[d,c]),C=async s=>{if(r){p(s);try{await S(r,s),await D(),t(!1)}finally{p(null)}}};return r?e.jsx($,{open:a,onOpenChange:t,children:e.jsxs(q,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(A,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-5 w-5"}),"Conversation Timeline"]}),e.jsx(Q,{children:"Navigate to any point in the conversation or fork a new session"})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Search messages...",value:c,onChange:s=>T(s.target.value),className:"pl-9 w-full"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:g.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:c?"No messages found":"No messages in this session yet"}):g.map(s=>{const o=b(s.parts),j=s.info.time.created,R=E(j),F=d.length-d.indexOf(s);return e.jsxs("div",{className:"group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:async()=>{await n?.(s.info.id)!==!1&&t(!1)},children:[e.jsxs("span",{className:"typography-meta text-muted-foreground w-5 text-right flex-shrink-0",children:[F,"."]}),e.jsxs("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:[o||"[No text content]",o&&o.length>=80&&"…"]}),e.jsxs("div",{className:"flex-shrink-0 h-5 flex items-center mr-2",children:[e.jsx("span",{className:"typography-meta text-muted-foreground whitespace-nowrap group-hover:hidden",children:R}),e.jsxs("div",{className:"hidden group-hover:flex gap-1",children:[e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:async u=>{u.stopPropagation(),await M(r,s.info.id),t(!1)},children:e.jsx(v,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Revert from here"})]}),e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",onClick:u=>{u.stopPropagation(),C(s.info.id)},disabled:h===s.info.id,children:h===s.info.id?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx(N,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Fork from here"})]})]})]})]},s.info.id)})}),e.jsxs("div",{className:"mt-4 p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"typography-meta text-muted-foreground font-medium mb-2",children:"Actions"}),e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{f?.(-1),t(!1)},children:"Previous turn"}),e.jsx("span",{className:"text-muted-foreground/50",children:"/"}),e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{i?.(),t(!1)},children:"Latest"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 typography-meta text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:"Click on a message to scroll to it in the conversation"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Undo to this point (message text will populate input)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Create a new session starting from here"})]})]})]})]})}):null};function b(a){const t=a.find(n=>n.type==="text");return!t||typeof t.text!="string"?"":t.text.replace(/\n/g," ").slice(0,80)}export{J as TimelineDialog};
1
+ import{R as x,u as e,bq as I,aS as P,bs as v,aA as L,aR as N}from"./vendor-.bun-HTKwyaEM.js";import{g as $,h as q,i as A,j as H,k as Q,I as U,l as w,m as y,n as k}from"./main-CaAZH2Mv.js";import{v as m,$ as B}from"./index-DKc7ZmSW.js";function E(a){const n=Date.now()-a,f=Math.floor(n/1e3),i=Math.floor(f/60),r=Math.floor(i/60),l=Math.floor(r/24);return f<60?"just now":i<60?`${i}m ago`:r<24?`${r}h ago`:l<7?`${l}d ago`:new Date(a).toLocaleDateString()}const J=({open:a,onOpenChange:t,onScrollToMessage:n,onScrollByTurnOffset:f,onResumeToLatest:i})=>{const r=m(s=>s.currentSessionId),l=B(s=>r?s.messages.get(r)||[]:[]),M=m(s=>s.revertToMessage),S=m(s=>s.forkFromMessage),D=m(s=>s.loadSessions),[h,p]=x.useState(null),[c,T]=x.useState(""),d=x.useMemo(()=>l.filter(o=>o.info.role==="user").reverse(),[l]),g=x.useMemo(()=>{if(!c.trim())return d;const s=c.toLowerCase();return d.filter(o=>b(o.parts).toLowerCase().includes(s))},[d,c]),C=async s=>{if(r){p(s);try{await S(r,s),await D(),t(!1)}finally{p(null)}}};return r?e.jsx($,{open:a,onOpenChange:t,children:e.jsxs(q,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(A,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-5 w-5"}),"Conversation Timeline"]}),e.jsx(Q,{children:"Navigate to any point in the conversation or fork a new session"})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Search messages...",value:c,onChange:s=>T(s.target.value),className:"pl-9 w-full"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:g.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:c?"No messages found":"No messages in this session yet"}):g.map(s=>{const o=b(s.parts),j=s.info.time.created,R=E(j),F=d.length-d.indexOf(s);return e.jsxs("div",{className:"group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:async()=>{await n?.(s.info.id)!==!1&&t(!1)},children:[e.jsxs("span",{className:"typography-meta text-muted-foreground w-5 text-right flex-shrink-0",children:[F,"."]}),e.jsxs("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:[o||"[No text content]",o&&o.length>=80&&"…"]}),e.jsxs("div",{className:"flex-shrink-0 h-5 flex items-center mr-2",children:[e.jsx("span",{className:"typography-meta text-muted-foreground whitespace-nowrap group-hover:hidden",children:R}),e.jsxs("div",{className:"hidden group-hover:flex gap-1",children:[e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:async u=>{u.stopPropagation(),await M(r,s.info.id),t(!1)},children:e.jsx(v,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Revert from here"})]}),e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",onClick:u=>{u.stopPropagation(),C(s.info.id)},disabled:h===s.info.id,children:h===s.info.id?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx(N,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Fork from here"})]})]})]})]},s.info.id)})}),e.jsxs("div",{className:"mt-4 p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"typography-meta text-muted-foreground font-medium mb-2",children:"Actions"}),e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{f?.(-1),t(!1)},children:"Previous turn"}),e.jsx("span",{className:"text-muted-foreground/50",children:"/"}),e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{i?.(),t(!1)},children:"Latest"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 typography-meta text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:"Click on a message to scroll to it in the conversation"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Undo to this point (message text will populate input)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Create a new session starting from here"})]})]})]})]})}):null};function b(a){const t=a.find(n=>n.type==="text");return!t||typeof t.text!="string"?"":t.text.replace(/\n/g," ").slice(0,80)}export{J as TimelineDialog};
@@ -1,4 +1,4 @@
1
- import{fC as Se,_ as tt,R as T,e as ee,u as s,em as nt,aO as Ve,d6 as Te,d5 as Ue,aT as st,bl as it,d2 as Ce,bv as rt,bj as ze,K as ot,a_ as at,aS as De,cZ as lt,i as ct,c_ as dt,d3 as ut,aR as ft,d4 as mt,aa as We,b3 as pt,Z as ht,a4 as Be,aA as gt}from"./vendor-.bun-HTKwyaEM.js";import{o as xt,p as Ge,q as wt,r as bt,s as yt,t as vt,v as jt,w as qe,x as Nt,y as kt,z as Ae,A as Tt,E as $e,h as St,g as _t}from"./main-B6oiMU86.js";import{c as fe,a5 as ve}from"./index-o_d2wtWC.js";const Lt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},Pe=new Set(["plain"]),Re=new Map,Rt={typescript:["javascript"],tsx:["typescript","jsx","javascript"],jsx:["javascript"],cpp:["c"],csharp:["c"],scss:["css"],kotlin:["java"],toml:[],docker:["bash"]},Ee=n=>{const e=n.toLowerCase();return Lt[e]??e},Ie=n=>Pe.has(n)||!!Se.languages[n],Ke=async n=>{if(Ie(n)){Pe.add(n);return}const e=Re.get(n);if(e)return e;const t=(async()=>{const o=Rt[n]??[];for(const a of o)await Ke(a);try{await tt(()=>import(`prismjs/components/prism-${n}.min.js`),[]),Pe.add(n)}catch{console.warn(`[Prism] Failed to load language: ${n}`)}})();Re.set(n,t),await t,Re.delete(n)},Pt=async n=>{const e=Ee(n);return e==="plain"||e==="text"||Ie(e)?!0:(await Ke(e),Ie(e))},It=80,Mt=20,Et=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Ct=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${Et(e)}:${String(t)};`).join(""),zt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),Dt=n=>{const e=[];return Object.entries(n).forEach(([t,o])=>{const a=zt(t);if(a.length===0)return;const l=Ct(o);l&&e.push(`${a.join(",")}{${l}}`)}),e.join(`
1
+ import{fC as Se,_ as tt,R as T,e as ee,u as s,em as nt,aO as Ve,d6 as Te,d5 as Ue,aT as st,bl as it,d2 as Ce,bv as rt,bj as ze,K as ot,a_ as at,aS as De,cZ as lt,i as ct,c_ as dt,d3 as ut,aR as ft,d4 as mt,aa as We,b3 as pt,Z as ht,a4 as Be,aA as gt}from"./vendor-.bun-HTKwyaEM.js";import{o as xt,p as Ge,q as wt,r as bt,s as yt,t as vt,v as jt,w as qe,x as Nt,y as kt,z as Ae,A as Tt,E as $e,h as St,g as _t}from"./main-CaAZH2Mv.js";import{c as fe,a5 as ve}from"./index-DKc7ZmSW.js";const Lt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},Pe=new Set(["plain"]),Re=new Map,Rt={typescript:["javascript"],tsx:["typescript","jsx","javascript"],jsx:["javascript"],cpp:["c"],csharp:["c"],scss:["css"],kotlin:["java"],toml:[],docker:["bash"]},Ee=n=>{const e=n.toLowerCase();return Lt[e]??e},Ie=n=>Pe.has(n)||!!Se.languages[n],Ke=async n=>{if(Ie(n)){Pe.add(n);return}const e=Re.get(n);if(e)return e;const t=(async()=>{const o=Rt[n]??[];for(const a of o)await Ke(a);try{await tt(()=>import(`prismjs/components/prism-${n}.min.js`),[]),Pe.add(n)}catch{console.warn(`[Prism] Failed to load language: ${n}`)}})();Re.set(n,t),await t,Re.delete(n)},Pt=async n=>{const e=Ee(n);return e==="plain"||e==="text"||Ie(e)?!0:(await Ke(e),Ie(e))},It=80,Mt=20,Et=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Ct=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${Et(e)}:${String(t)};`).join(""),zt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),Dt=n=>{const e=[];return Object.entries(n).forEach(([t,o])=>{const a=zt(t);if(a.length===0)return;const l=Ct(o);l&&e.push(`${a.join(",")}{${l}}`)}),e.join(`
2
2
  `)},At=5e3,xe=new Map,$t=(n,e)=>{const t=Ee(e),o=`${t}
3
3
  ${n}`,a=xe.get(o);if(a!==void 0)return a;const l=Se.languages[t]??Se.languages.text;if(!l){const i=Me(n);return xe.set(o,i),i}try{const i=Se.highlight(n,l,t);if(xe.size>=At){const r=xe.keys().next().value;typeof r=="string"&&xe.delete(r)}return xe.set(o,i),i}catch{const i=Me(n);return xe.set(o,i),i}};function Me(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Ht=n=>{const e=ee.c(5),[t,o]=T.useState(!1);let a;e[0]!==n?(a=Ee(n),e[0]=n,e[1]=a):a=e[1];const l=a;let i,r;return e[2]!==l?(i=()=>{let c=!1;return o(!1),Pt(l).then(()=>{c||o(!0)}),()=>{c=!0}},r=[l],e[2]=l,e[3]=i,e[4]=r):(i=e[3],r=e[4]),T.useEffect(i,r),t},Ze=T.memo(n=>{const e=ee.c(41),{lines:t,language:o,syntaxTheme:a,maxHeight:l,showLineNumbers:i,lineStyles:r}=n,c=l===void 0?"60vh":l,d=i===void 0?!0:i;let p;e[0]!==a?(p=Dt(a),e[0]=a,e[1]=p):p=e[1];const k=p,L=Ht(o),E=t.length>It;if(!L){let g;e[2]!==c?(g={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=g):g=e[3];let h;e[4]!==k?(h=k?s.jsx("style",{children:k}):null,e[4]=k,e[5]=h):h=e[5];let b;if(e[6]!==r||e[7]!==t||e[8]!==d){let v;e[10]!==r||e[11]!==d?(v=(j,x)=>s.jsx(_e,{line:{...j,text:Me(j.text)},language:"plain",showLineNumbers:d,style:r?.(j)},x),e[10]=r,e[11]=d,e[12]=v):v=e[12],b=t.map(v),e[6]=r,e[7]=t,e[8]=d,e[9]=b}else b=e[9];let m;return e[13]!==g||e[14]!==h||e[15]!==b?(m=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism opacity-50",style:g,children:[h,b]}),e[13]=g,e[14]=h,e[15]=b,e[16]=m):m=e[16],m}if(!E){let g;e[17]!==c?(g={maxHeight:c,overflow:"auto"},e[17]=c,e[18]=g):g=e[18];let h;e[19]!==k?(h=k?s.jsx("style",{children:k}):null,e[19]=k,e[20]=h):h=e[20];let b;if(e[21]!==o||e[22]!==r||e[23]!==t||e[24]!==d){let v;e[26]!==o||e[27]!==r||e[28]!==d?(v=(j,x)=>s.jsx(_e,{line:j,language:o,showLineNumbers:d,style:r?.(j)},x),e[26]=o,e[27]=r,e[28]=d,e[29]=v):v=e[29],b=t.map(v),e[21]=o,e[22]=r,e[23]=t,e[24]=d,e[25]=b}else b=e[25];let m;return e[30]!==g||e[31]!==h||e[32]!==b?(m=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:g,children:[h,b]}),e[30]=g,e[31]=h,e[32]=b,e[33]=m):m=e[33],m}let N;return e[34]!==o||e[35]!==r||e[36]!==t||e[37]!==c||e[38]!==k||e[39]!==d?(N=s.jsx(Ye,{lines:t,language:o,prismThemeCss:k,maxHeight:c,showLineNumbers:d,lineStyles:r}),e[34]=o,e[35]=r,e[36]=t,e[37]=c,e[38]=k,e[39]=d,e[40]=N):N=e[40],N});Ze.displayName="VirtualizedCodeBlock";const Ye=T.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:o,showLineNumbers:a,lineStyles:l})=>{const i=T.useRef(null),r=nt({count:n.length,getScrollElement:()=>i.current,estimateSize:()=>Mt,overscan:20});return s.jsxs("div",{ref:i,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:o,overflow:"auto"},children:[t?s.jsx("style",{children:t}):null,s.jsx("div",{style:{height:`${r.getTotalSize()}px`,width:"100%",position:"relative"},children:r.getVirtualItems().map(c=>{const d=n[c.index];return s.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:s.jsx(_e,{line:d,language:e,showLineNumbers:a,style:l?.(d)})},c.index)})})]})});Ye.displayName="VirtualizedRows";const _e=T.memo(n=>{const e=ee.c(15),{line:t,language:o,showLineNumbers:a,style:l}=n;let i;e[0]!==o||e[1]!==t.text?(i=$t(t.text,o),e[0]=o,e[1]=t.text,e[2]=i):i=e[2];const r=i;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==a?(c=a&&s.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==r||e[8]!==t.isInfo||e[9]!==t.text?(d=s.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?s.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):s.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:r}})}),e[7]=r,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let p;return e[11]!==l||e[12]!==c||e[13]!==d?(p=s.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:l,children:[c,d]}),e[11]=l,e[12]=c,e[13]=d,e[14]=p):p=e[14],p});_e.displayName="VirtualizedCodeBlock.Row";const Ot=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?s.jsx(st,{className:e}):t==="image-preview"?s.jsx(it,{className:e}):t==="mermaid-preview"?s.jsx(Ce,{className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?s.jsx(rt,{className:e}):t==="write"||t==="create"||t==="file_write"?s.jsx(ze,{className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?s.jsx(ze,{className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?s.jsx(ot,{className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?s.jsx(at,{className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?s.jsx(De,{className:e}):t==="glob"?s.jsx(lt,{className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?s.jsx(ct,{className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?s.jsx(De,{className:e}):t==="todowrite"||t==="todoread"?s.jsx(dt,{className:e}):t==="plan_enter"?s.jsx(Ce,{className:e}):t==="plan_exit"?s.jsx(ut,{className:e}):t.startsWith("git")?s.jsx(ft,{className:e}):s.jsx(Ve,{className:e})},He=150,Ft=40,Vt=120,Ut=3,Wt=`
4
4
  [data-diff-header],