@hienlh/ppm 0.20.3 → 0.20.4
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/.release-node-shim.sh +10 -0
- package/CHANGELOG.md +8 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/cli-reference.md +4 -4
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{accounts-settings-section-DzDmIsPe.js → accounts-settings-section-BcI3ithh.js} +1 -1
- package/dist/web/assets/{ai-resource-editor-D7C9wmwA.js → ai-resource-editor-C3i7VkUS.js} +1 -1
- package/dist/web/assets/{ai-settings-section-DZuwllLy.js → ai-settings-section-COdsN_5h.js} +1 -1
- package/dist/web/assets/{ai-settings-section-BW5a07-Z.js → ai-settings-section-DIqSLISN.js} +1 -1
- package/dist/web/assets/{appearance-settings-section-RfH2N1rj.js → appearance-settings-section-B9n42QPH.js} +1 -1
- package/dist/web/assets/{chat-tab-Bz0pk0_E.js → chat-tab-D9sk38e8.js} +3 -3
- package/dist/web/assets/{code-editor-C4o1SyuO.js → code-editor-iTD62P14.js} +2 -2
- package/dist/web/assets/{conflict-editor-Dk65mBIe.js → conflict-editor-idh_kBSa.js} +1 -1
- package/dist/web/assets/{csv-preview-DENi3CFz.js → csv-preview-B2PR7z0o.js} +1 -1
- package/dist/web/assets/{database-viewer-BiBC7ulB.js → database-viewer-DSv_pvEq.js} +1 -1
- package/dist/web/assets/{diff-viewer-CSvZJHak.js → diff-viewer-6X5S1lw3.js} +1 -1
- package/dist/web/assets/{explorer-body-QXS0h4AF.js → explorer-body-CrtXpmZM.js} +1 -1
- package/dist/web/assets/{explorer-window-content-CQgqoRsj.js → explorer-window-content-D11FZUgq.js} +1 -1
- package/dist/web/assets/{extension-manager-section-CyC7wX35.js → extension-manager-section-Cz8fvK1u.js} +1 -1
- package/dist/web/assets/{extension-webview-Da8SIlRa.js → extension-webview-DzZeXQsO.js} +1 -1
- package/dist/web/assets/{files-settings-section-D8cebM51.js → files-settings-section-pc4jOun8.js} +1 -1
- package/dist/web/assets/{general-settings-section-1HVTvlIw.js → general-settings-section-DIZIA54q.js} +1 -1
- package/dist/web/assets/{git-log-panel-C7a4rp8f.js → git-log-panel-BkcIfZIE.js} +1 -1
- package/dist/web/assets/{glide-data-grid-BT9p_4AN.js → glide-data-grid-nA5LsoJK.js} +1 -1
- package/dist/web/assets/{group-chat-tab-BUHGnUyW.js → group-chat-tab-DyzfaPol.js} +1 -1
- package/dist/web/assets/{index-kGmcC9cb.js → index-DJM59ogE.js} +4 -4
- package/dist/web/assets/{jira-watcher-section-BxzwW4uQ.js → jira-watcher-section-UEtpcxM9.js} +1 -1
- package/dist/web/assets/{keybindings-store-DjJum4OS.js → keybindings-store-BV0MMt1c.js} +1 -1
- package/dist/web/assets/{keyboard-shortcuts-section-DDKG3BU1.js → keyboard-shortcuts-section-sY56ThaI.js} +1 -1
- package/dist/web/assets/{markdown-renderer-dHeak2mE.js → markdown-renderer-Bkrk39pO.js} +1 -1
- package/dist/web/assets/{markdown-renderer-iBw1fCI_.js → markdown-renderer-Bthd7hxl.js} +1 -1
- package/dist/web/assets/{mobile-explorer-sheet-CzL8SLtz.js → mobile-explorer-sheet--NKsnNJn.js} +1 -1
- package/dist/web/assets/{notification-store-DVi6Ds71.js → notification-store-Bv4fnyvR.js} +1 -1
- package/dist/web/assets/{notifications-settings-section-shQ-ugKh.js → notifications-settings-section-BGSLkMuE.js} +1 -1
- package/dist/web/assets/{pdf-preview-DB26KSzm.js → pdf-preview-DE0wVfyM.js} +1 -1
- package/dist/web/assets/{postgres-viewer-CJe2meyF.js → postgres-viewer-C0S8dCbA.js} +1 -1
- package/dist/web/assets/{ppmbot-settings-section-Ba4c9AI9.js → ppmbot-settings-section-B2AZ8whe.js} +1 -1
- package/dist/web/assets/{process-table-PXwLsMuG.js → process-table-BmT34-_s.js} +1 -1
- package/dist/web/assets/{proxy-settings-section-BHBhK6HC.js → proxy-settings-section-BYwWFWvn.js} +1 -1
- package/dist/web/assets/{query-audit-section-BD5ZVqDz.js → query-audit-section-Dj1-npew.js} +1 -1
- package/dist/web/assets/{remote-desktop-mobile-sheet-Di4QG8VX.js → remote-desktop-mobile-sheet-bFIYIQIj.js} +2 -2
- package/dist/web/assets/{remote-desktop-mobile-view-DzoZvAqc.js → remote-desktop-mobile-view-BbrHPmPU.js} +1 -1
- package/dist/web/assets/{remote-desktop-readiness-gate-CHO-KJ9Z.js → remote-desktop-readiness-gate-Dme8r7Jp.js} +1 -1
- package/dist/web/assets/{remote-desktop-window-content-X324gYbW.js → remote-desktop-window-content-BdbszoSx.js} +1 -1
- package/dist/web/assets/{schedules-settings-section-a4-h6THc.js → schedules-settings-section-rczhjkeM.js} +1 -1
- package/dist/web/assets/{settings-body-Fq7BVDw2.js → settings-body-CwaQg_uc.js} +2 -2
- package/dist/web/assets/{settings-tab-CVLQy-ie.js → settings-tab-C8l9-_9E.js} +1 -1
- package/dist/web/assets/{settings-window-content-Bi7M0iaZ.js → settings-window-content-EA1489gi.js} +1 -1
- package/dist/web/assets/{sql-query-editor-D1r265fl.js → sql-query-editor-BQsKZVtz.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-DHkIotRl.js → sqlite-viewer-Di8s3Z1m.js} +1 -1
- package/dist/web/assets/{system-monitor-body-y6VUkYTL.js → system-monitor-body-Dlknm4Uo.js} +2 -2
- package/dist/web/assets/{system-monitor-tab-DRAOejhk.js → system-monitor-tab-LZRO6_DP.js} +1 -1
- package/dist/web/assets/{system-monitor-window-content-B5i57xHD.js → system-monitor-window-content-BFDfhqDd.js} +1 -1
- package/dist/web/assets/{tab-host-window-content-SkyPFFlc.js → tab-host-window-content-Bh7064Yw.js} +1 -1
- package/dist/web/assets/{team-member-sheet-BB63u-Lf.js → team-member-sheet-CU68IqU0.js} +2 -2
- package/dist/web/assets/{team-member-window-content-D6tVTXuV.js → team-member-window-content-BYtro89j.js} +1 -1
- package/dist/web/assets/{terminal-tab-BYaHAkI5.js → terminal-tab-qfSPxRtZ.js} +1 -1
- package/dist/web/assets/{tool-cards-DRJu20sL.js → tool-cards-CY9J4ux4.js} +2 -2
- package/dist/web/assets/{use-accounts-data-Ba1_uvEE.js → use-accounts-data-pAQw6nCa.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-Uakgj3hJ.js → use-monaco-theme-DT5Q8kuf.js} +1 -1
- package/dist/web/assets/{use-remote-desktop-display-choice-Cd3Xalca.js → use-remote-desktop-display-choice-CYQsrOMC.js} +1 -1
- package/dist/web/assets/{use-websocket-BC_EGf5q.js → use-websocket-mkNA1M8U.js} +1 -1
- package/dist/web/assets/{video-preview-BUb43zWb.js → video-preview-B2dk48oQ.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/providers/codex-app-server/codex-event-mapper.ts +4 -0
- package/src/providers/codex-app-server/codex-history.ts +4 -2
- package/src/providers/codex-app-server/codex-protocol.ts +4 -0
- package/src/providers/codex-app-server/codex-provider.ts +69 -5
- package/src/server/routes/chat.ts +22 -3
- package/src/server/ws/chat.ts +5 -0
- package/src/services/edge-forwarder.ts +191 -191
- package/src/services/windows-process-tree.ts +351 -351
- package/src/web/hooks/use-chat.ts +22 -11
- package/packages/vscode-compat/node_modules/.bin/tsc.bunx +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsc.exe +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsserver.bunx +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsserver.exe +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/edit-diff-preview-xdDQvPhs.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-markdown-Ls5AcU91.js","assets/libesm-CdttTIAd.js","assets/markdown-renderer-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{t as i}from"./bot-D6sx11y0.js";import{t as a}from"./brain-KDa9jFRq.js";import{t as o}from"./check-DN75Ucvz.js";import{t as s}from"./chevron-down-Dp0rpHb8.js";import{t as c}from"./chevron-right-De-Wz5Lz.js";import{t as l}from"./chevron-up-8PbsNiJp.js";import{a as u,i as d,n as f,o as p,r as m}from"./tool-cards-DRJu20sL.js";import{t as h}from"./circle-BCy0AUCo.js";import{t as g}from"./clock-C1CQUQPZ.js";import{t as _}from"./code-DJgYrFzm.js";import{t as v}from"./sparkles-Dh-_J2Rd.js";import{t as y}from"./copy-BewHj66E.js";import{n as b,r as x}from"./use-coarse-long-press-BmI_GVW5.js";import{t as S}from"./eye-gWwaF4Lg.js";import{t as C}from"./hand-x0ejq3fS.js";import{t as w}from"./loader-circle-DPMrnLQ2.js";import{t as ee}from"./shield-off-7jKWpJBD.js";import{t as te}from"./x-CxoBA0po.js";import{i as T,n as E,r as D,s as ne}from"./api-client-CEYCBt_0.js";import{q as re}from"./vendor-mermaid-CfY1-PkA.js";import{t as O}from"./settings-store-CzLnTR8p.js";import{n as k,r as A,t as ie}from"./utils-IrnQujwR.js";import"./portal-container-context-DKymYOY-.js";import{t as j}from"./panel-store-BmdcSBNb.js";import"./window-store-D0HbQ1pM.js";import{i as M}from"./project-store-wWZ6bjwq.js";import{t as ae}from"./tab-store-1xYJb0gM.js";import"./context-menu-CJL8L98s.js";import{n as oe}from"./use-is-mobile-D1weanbj.js";import{n as N}from"./streaming-store-9XVmAMfV.js";import{t as P}from"./button-DX32ffge.js";import{t as F}from"./mobile-bottom-sheet-CmySDB6I.js";import"./use-visual-viewport-Bfl3Bxxb.js";import"./ws-auth-D111jj32.js";import{Ar as se,Bn as I,Br as ce,Cr as L,Dn as R,Dr as z,En as le,Fr as ue,Hn as de,In as B,Ir as V,Kn as fe,Ln as pe,Lt as me,M as he,Mr as H,N as ge,Nn as _e,Nr as ve,On as U,P as W,Pn as ye,Pr as G,Rn as K,Rt as be,Tn as xe,Un as Se,Wn as Ce,Xn as q,Xt as J,Yn as Y,Yt as we,_n as Te,ar as Ee,bn as De,cn as Oe,cr as ke,en as Ae,er as je,gn as Me,hr as Ne,jn as Pe,kn as Fe,nn as X,nr as Ie,or as Le,pr as Re,qn as Z,qt as ze,r as Be,t as Ve,tr as He,v as Ue,vn as We,wn as Ge,xr as Ke,yr as qe,zn as Je,zr as Ye,zt as Xe}from"./index-kGmcC9cb.js";import{t as Ze}from"./use-websocket-BC_EGf5q.js";import{getAISettings as Qe,pickAccountForTab as $e}from"./api-settings-D18Q4Ocp.js";import"./use-blob-url-CrwoZJUJ.js";import{n as et,r as tt,t as nt}from"./image-gallery-J8h8IY0c.js";import{t as rt}from"./libesm-CdttTIAd.js";import{t as it}from"./use-open-team-member-CSUU7Z8N.js";import{n as at,t as ot}from"./send-to-chat-BI7-fFpG.js";import{t as st}from"./ai-settings-section-DZuwllLy.js";import{i as ct,l as lt,n as ut,s as dt,t as ft,u as pt}from"./use-accounts-data-Ba1_uvEE.js";var mt=r(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ht=r(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),gt=r(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),_t=r(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),vt=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),yt=r(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),bt=r(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),xt=r(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Q=e(t(),1),St={maxImages:4,maxBase64PerImage:5e6,maxBase64Total:1e7};function Ct(e){let t=[],n=0;for(let r of e)if(r.imageData){if(t.length>=St.maxImages)break;r.imageData.data.length>St.maxBase64PerImage||n+r.imageData.data.length>St.maxBase64Total||(n+=r.imageData.data.length,t.push(r.imageData))}return t}function wt(e,t){let n=new Set(t),r=[],i=[];for(let t of e)t.serverPath&&(t.imageData&&n.has(t.imageData)?r.push(t.serverPath):i.push(t.serverPath));return{inlineImagePaths:r,pathOnlyPaths:i}}function Tt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function Et(e,t){let n=`pc-${Tt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function Dt(e,t){if(t.size===0)return e;let n=[];for(let r of e){let e=r.id?t.get(r.id):void 0;e&&e.length>0&&n.push(...e),n.push(r)}return n}var Ot=null;function kt(){return Ot||=new AudioContext,Ot}function At(e,t,n,r,i=`sine`){let a=kt(),o=a.createOscillator(),s=a.createGain();o.type=i,o.frequency.value=e,s.gain.setValueAtTime(r,n),s.gain.exponentialRampToValueAtTime(.001,n+t),o.connect(s),s.connect(a.destination),o.start(n),o.stop(n+t)}function jt(){let e=kt().currentTime;At(523,.15,e,.15),At(659,.2,e+.12,.15)}function Mt(){let e=kt().currentTime;At(880,.12,e,.18,`square`),At(698,.12,e+.15,.18,`square`),At(880,.15,e+.3,.15,`square`)}function Nt(){let e=kt().currentTime;At(440,.12,e,.12),At(523,.12,e+.1,.12),At(659,.18,e+.2,.12)}var Pt={done:jt,approval_request:Mt,question:Nt};function Ft(e){try{Pt[e]?.()}catch{}}var It={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function Lt(e){if(document.hidden)return!1;let{panels:t}=j.getState();for(let n of Object.values(t)){let t=n.tabs.find(e=>e.id===n.activeTabId);if(t?.type===`chat`&&t.metadata?.sessionId===e)return!0}return!1}function Rt(e,t=`claude`,n=``,r){let[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(new Map),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,ee]=(0,Q.useState)([]),te=(0,Q.useRef)([]),[re,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[ie,M]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),se=(0,Q.useRef)(null),I=(0,Q.useRef)(null),[ce,L]=(0,Q.useState)(null),R=(0,Q.useRef)(null),[z,le]=(0,Q.useState)(!0),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null),B=(0,Q.useRef)(``),V=(0,Q.useRef)([]),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(null),H=(0,Q.useRef)(`idle`),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(()=>{}),ve=(0,Q.useRef)(null),U=(0,Q.useRef)(!1),W=(0,Q.useRef)(new Set),ye=(0,Q.useRef)(0),G=(0,Q.useRef)(null),K=(0,Q.useRef)(0),be=(0,Q.useRef)(e);be.current=e;let xe=(0,Q.useRef)(r);xe.current=r;let Se=(0,Q.useRef)([]);Se.current=i;let Ce=(0,Q.useRef)(n);Ce.current=n;let q=(0,Q.useRef)(null),J=(0,Q.useRef)(0),Y=(0,Q.useRef)({teamNames:new Set,messages:[]}),we=(0,Q.useRef)(0),[Te,Ee]=(0,Q.useState)(It),[De,Oe]=(0,Q.useState)([]),ke=(0,Q.useCallback)(()=>{let e=Y.current;Ee({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:we.current}),Oe([...e.messages])},[]),Ae=(0,Q.useCallback)(()=>{we.current=0,ke()},[ke]),je=(0,Q.useCallback)(async e=>{try{let t=await E.get(`/api/teams/${encodeURIComponent(e)}`);if(!t?.messages)return;let n=Y.current.messages,r=t.messages.filter(e=>!n.some(t=>t.timestamp===e.timestamp&&t.from===e.from));n.push(...r),n.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),n.length>500&&n.splice(0,n.length-500),ke()}catch{}},[ke]),Me=f!==`idle`;(0,Q.useEffect)(()=>{if(e)return N.getState().setStreaming(e,f!==`idle`,n),()=>{N.getState().setStreaming(e,!1)}},[e,f,n]);let Ne=(0,Q.useCallback)((e,t)=>{let n=V.current.findIndex(e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t);if(n===-1)return!1;let r=V.current[n];if(r.type!==`tool_use`)return!1;let i=[...r.children??[],e];return V.current[n]={...r,children:i},!0},[]),Pe=(0,Q.useCallback)((e,t)=>{let n=e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t,r=Se.current,i=-1;for(let e=r.length-1;e>=0;e--)if(r[e].events?.some(n)){i=e;break}return i===-1?!1:(a(t=>{let r=-1;for(let e=t.length-1;e>=0;e--)if(t[e].events?.some(n)){r=e;break}if(r===-1)return t;let i=t[r],a=i.events.map(t=>{if(!n(t)||t.type!==`tool_use`)return t;let r=[...t.children??[]],i=e.toolUseId,a=i?r.findIndex(t=>t.type===e.type&&t.toolUseId===i):-1;return a===-1?r.push(e):r[a]=e,{...t,children:r}});return[...t.slice(0,r),{...i,events:a},...t.slice(r+1)]}),!0)},[]),Fe=(0,Q.useCallback)(()=>{J.current=0;let e=B.current,t=[...V.current],n=pe.current;(0,Q.startTransition)(()=>{a(r=>{let i=r[r.length-1];return i?.role===`assistant`&&!i.id.startsWith(`final-`)?[...r.slice(0,-1),{...i,content:e,events:t,...n}]:[...r,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:t,timestamp:new Date().toISOString(),...n}]})})},[]),X=(0,Q.useCallback)(()=>{J.current||=window.setTimeout(Fe,100)},[Fe]),Ie=(0,Q.useCallback)((e,t)=>{let n=t=>t.type===`tool_use`&&(t.tool===`Agent`||t.tool===`Task`)&&t.toolUseId===e,r=V.current.findIndex(n);if(r!==-1){V.current[r]={...V.current[r],bgStatus:t},X();return}a(e=>{let r=-1;for(let t=e.length-1;t>=0;t--)if(e[t].events?.some(n)){r=t;break}if(r===-1)return e;let i=e[r],a=i.events.map(e=>n(e)?{...e,bgStatus:t}:e);return[...e.slice(0,r),{...i,events:a},...e.slice(r+1)]})},[X]),Le=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=V.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:pe.current={accountId:t.accountId,accountLabel:t.accountLabel},he({id:t.accountId,label:t.accountLabel??null}),O(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(pe.current={accountId:t.accountId,accountLabel:t.accountLabel},he({id:t.accountId,label:t.accountLabel})),V.current=[t],X();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;O(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}B.current+=t.content,V.current.push(t),X();break}case`thinking`:{let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}V.current.push(t),X();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&W.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),X();break}case`tool_result`:{let e=t.toolUseId;if(e&&fe.current.delete(e),e&&W.current.has(e))break;let n=t.parentToolUseId;if(n&&Ne(t,n)){X();break}if(n){Pe(t,n);break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),X();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`),r=n&&n.input;r&&typeof r==`object`&&(r.answers=t.answers,a(e=>[...e]))}y(t=>t&&t.requestId===e?null:t),q.current!=null&&(ne.dismiss(q.current),q.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),U.current)break;if(y({requestId:t.requestId,tool:t.tool,input:t.input}),be.current&&!Lt(be.current)){Ft(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=be.current,n=t.tool===`AskUserQuestion`;q.current=ne[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:Ce.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=j.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){j.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:a(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=V.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return V.current=a,[...e.slice(0,-1),{...n,events:a}]}return n?.role===`system`&&n.content===t.message?e:[...e,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]});break;case`team_detected`:{let e=t.teamName;e&&(Y.current.teamNames.add(e),ke(),je(e));break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=Y.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),we.current+=e.length,ke()}break}case`team_updated`:ke();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=fe.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):fe.current.set(e,{content:t.content,lineCount:t.lineCount}),X()}break}case`subagent_status`:{let e=t.toolUseId,n=t.status;e&&n&&Ie(e,n);break}case`background_registry`:{let e=t.shells??[];te.current=e,ee(e);break}case`done`:{if(H.current===`idle`)break;t.contextWindowPct!=null&&x(t.contextWindowPct),be.current&&!Lt(be.current)&&Ft(`done`),J.current&&=(clearTimeout(J.current),0);let e=B.current,n=[...V.current],r=pe.current,i=t.lastMessageUuid,o=t.usage;a(t=>{let a=t[t.length-1];return a?.role===`assistant`?[...t.slice(0,-1),{...a,id:`final-${Date.now()}`,content:e||a.content,events:n.length>0?n:a.events,...i&&{sdkUuid:i},...o&&{usage:o}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...i&&{sdkUuid:i},...o&&{usage:o},...r}]:t}),B.current=``,V.current=[],pe.current=null,G.current=null,fe.current.clear(),O(null);break}}},[Ne,Pe,X,Ie,ke,je]),Re=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`user_message`){let e=t.content;a(n=>{let r=n[n.length-1];return r?.role===`user`&&r.content===e?n:[...n,{id:`user-remote-${Date.now()}`,role:`user`,content:e,timestamp:t.timestamp??new Date().toISOString()}]});return}if(t.type===`title_updated`){A(t.title??null);return}if(t.type===`session_migrated`){let e=t.newSessionId;e&&e!==be.current&&xe.current?.(e);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?C(`compacting`):e===`done`&&C(null);return}if(t.type===`phase_changed`){let e=t.phase;p(e),H.current=e,_(e===`connecting`?t.elapsed??0:0),e===`idle`&&C(null);return}if(t.type===`session_state`){M(!0),oe(t.sessionId??be.current);let e=t,n=e.phase,r=H.current===`idle`;if(p(n),H.current=n,e.sessionTitle&&A(e.sessionTitle),e.model&&(I.current&&e.model!==I.current||(e.model===I.current&&(I.current=null),F(e.model),se.current=e.model)),typeof e.effort==`string`&&(L(e.effort),R.current=e.effort),typeof e.thinking==`boolean`&&le(e.thinking),e.pendingApproval&&y({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),C(e.compactStatus===`compacting`?`compacting`:null),n===`idle`){let e=Date.now()-K.current<5e3;r&&e||ve.current?.(),h(!1)}return}if(t.type===`turn_events`){let e=t.events,n=t.userMessage;if(!e?.length&&!n){h(!1);return}ye.current&&=(cancelAnimationFrame(ye.current),0),G.current=n,a(e=>{let t=[...e],r=t.length;for(;r>0&&t[r-1].role===`assistant`;)r--;if(n!=null&&r>0&&t[r-1].role===`user`&&t[r-1].content===n)t=t.slice(0,r-1);else{let e=t[t.length-1];e?.role===`assistant`&&e.id.startsWith(`streaming-`)&&(t=t.slice(0,-1))}if(n){let e=t[t.length-1];(e?.role!==`user`||e.content!==n)&&(t=[...t,{id:`user-replay-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}])}return t}),B.current=``,V.current=[],pe.current=null,U.current=!0;let r=0,i=()=>{let t=Math.min(r+100,e.length);for(let n=r;n<t;n++)Le(e[n]);r=t,r<e.length?ye.current=requestAnimationFrame(i):(ye.current=0,U.current=!1,h(!1))};ye.current=requestAnimationFrame(i);return}Le(t)}},[Le]),{send:Z,connect:ze}=Ze({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Re,autoConnect:!!e&&!!n});_e.current=Z,(0,Q.useEffect)(()=>{let r=!1;de.current&&de.current!==e&&(I.current=null,ue.current=null,he(null)),de.current=e??null,p(`idle`),H.current=`idle`,y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null),C(null),s(new Map),d({}),B.current=``,V.current=[],G.current=null,K.current=0,fe.current.clear(),J.current&&=(clearTimeout(J.current),0),M(!1),oe(null),Y.current={teamNames:new Set,messages:[]},we.current=0,Ee(It),Oe([]),e&&E.get(`/api/teams`).then(t=>{r||!Array.isArray(t)||t.filter(t=>(t?.name??t?.team_name)===e).length!==0&&(Y.current.teamNames.add(e),ke(),je(e))}).catch(()=>{});let i=new Set(Se.current.map(e=>e.id));return e&&n?(l(!0),E.get(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`).then(e=>{if(r)return;let t=Array.isArray(e)?{messages:e,versionMap:{}}:e,n=Array.isArray(t?.messages)?t.messages:[];t?.versionMap&&d(t.versionMap),t?.canonicalSessionId&&t.canonicalSessionId!==be.current&&xe.current?.(t.canonicalSessionId);let o=G.current;if(o!=null){for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`&&n[e].content===o){n=n.slice(0,e);break}}a(e=>{let t=e.filter(e=>!i.has(e.id));return[...n,...t]}),K.current=Date.now()}).catch(()=>{r||a(e=>e.filter(e=>!i.has(e.id)))}).finally(()=>{r||l(!1)})):a([]),()=>{r=!0}},[e,t,n,ke,je]);let Be=(0,Q.useCallback)((e,t)=>{if(!e.trim()&&!t?.images?.length)return;let n=H.current!==`idle`;if(n){J.current&&=(clearTimeout(J.current),0);let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n})}a(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),B.current=``,V.current=[],ge.current=null,n?(p(`thinking`),H.current=`thinking`):(p(`initializing`),H.current=`initializing`),y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null),Z(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,imagePaths:t?.imagePaths,...se.current&&{model:se.current},...R.current&&{effort:R.current},...ue.current!==null&&{thinking:ue.current}}))},[Z]),He=(0,Q.useCallback)(e=>{F(e),se.current=e,I.current=e,Z(JSON.stringify({type:`set_model`,model:e}))},[Z]),Ue=(0,Q.useCallback)(e=>{L(e),R.current=e,Z(JSON.stringify({type:`set_effort`,effort:e}))},[Z]),We=(0,Q.useCallback)(e=>{le(e),ue.current=e,Z(JSON.stringify({type:`set_thinking`,enabled:e}))},[Z]),Ge=(0,Q.useCallback)((e,t,n)=>{if(Z(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}a(e=>[...e])}y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null)},[Z]),Ke=(0,Q.useCallback)(()=>{if(H.current===`idle`)return;Z(JSON.stringify({type:`cancel`}));let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),B.current=``,V.current=[],fe.current.clear(),ge.current=null,p(`idle`),H.current=`idle`,y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null)},[Z]),qe=(0,Q.useCallback)(e=>{e&&Z(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Z]),Je=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return te.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&Ve.getState().setSessionShells(e,w)},[e,w]),(0,Q.useEffect)(()=>{if(e)return Ve.getState().retainSession(e),()=>{Ve.getState().releaseSession(e)}},[e]);let Ye=(0,Q.useCallback)(()=>{M(!1),h(!0),ze()},[ze]),Xe=(0,Q.useCallback)(()=>{!e||!n||fetch(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${D()}`}}).then(e=>e.json()).then(e=>{if(H.current!==`idle`)return;let t=e.ok?Array.isArray(e.data)?{messages:e.data,versionMap:void 0}:e.data:null;t?.versionMap&&d(t.versionMap),Array.isArray(t?.messages)&&t.messages.length>0&&(a(t.messages),B.current=``,V.current=[]),K.current=Date.now()}).catch(()=>{})},[e,t,n]);ve.current=Xe;let Qe=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${T(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=Et(await E.get(i),t);return s(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),$e=(0,Q.useCallback)(e=>o.has(e),[o]),et=(0,Q.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),tt=(0,Q.useCallback)(()=>{a(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:i,renderedMessages:(0,Q.useMemo)(()=>Dt(i,o),[i,o]),expandCompact:Qe,isCompactExpanded:$e,dismissMessage:et,clearErrors:tt,messagesLoading:c,versionMap:u,isStreaming:Me,phase:f,isReconnecting:m,connectingElapsed:g,pendingApproval:v,contextWindowPct:b,compactStatus:S,statusMessage:re,sessionTitle:k,liveAccount:me,model:P,setModel:He,effort:ce,setEffort:Ue,thinking:z,setThinking:We,teamActivity:Te,teamMessages:De,markTeamRead:Ae,bashPartialOutput:fe,backgroundShells:w,killBackgroundShell:qe,findBackgroundShellByOutput:Je,sendMessage:Be,respondToApproval:Ge,cancelStreaming:Ke,reconnect:Ye,refetchMessages:Xe,isConnected:ie&&ae===e}}var zt=12e4;function Bt(e,t=`claude`,n){let r=JSON.stringify([e,t,n]),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useCallback)((i=!1)=>{if(!e)return Promise.resolve();let o=++l.current;s(!0);let c=i?`&refresh=1`:``,u=n?`&session=${encodeURIComponent(n)}`:``;return E.get(`${T(e)}/chat/usage?providerId=${t}${u}${c}`).then(e=>{o===l.current&&a({scope:r,usage:e??{},fetchedAt:e?.lastFetchedAt??null})}).catch(()=>{}).finally(()=>{o===l.current&&s(!1)})},[e,t,n,r]);(0,Q.useEffect)(()=>(a(null),s(!1),u(),c.current=setInterval(()=>u(),zt),()=>{++l.current,c.current&&clearInterval(c.current)}),[u]);let d=(0,Q.useCallback)(()=>u(!0),[u]),f=(0,Q.useCallback)(()=>u(),[u]),p=i?.scope===r?i:null;return{usageInfo:p?.usage??{},usageLoading:o,lastFetchedAt:p?.fetchedAt??null,refreshUsage:d,reloadUsage:f}}var Vt={damping:.7,stiffness:.05,mass:1.25},Ht=70,Ut=1e3/60,Wt=350,Gt=!1;globalThis.document?.addEventListener(`mousedown`,()=>{Gt=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{Gt=!1}),globalThis.document?.addEventListener(`click`,()=>{Gt=!1});var Kt=(e={})=>{let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(e.initial!==!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);s.current=e;let c=(0,Q.useCallback)(()=>{if(!Gt)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,Q.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,Q.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,Q.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ht}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Yt(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Ut;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Yt(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,Q.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,Q.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,Q.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=qt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=qt(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Yt(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Wt})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function qt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Jt=new Map;function Yt(...e){let t={...Vt},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Jt.has(r)||Jt.set(r,Object.freeze(t)),n?`instant`:Jt.get(r)}var Xt=60,Zt=8,Qt=1400;function $t(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function en(e,t){let n=[],r=e.parentElement;for(;r&&r!==t;)$t(r)&&n.push(r),r=r.parentElement;return n}function tn(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function nn(e,t){let n=e.querySelector(`[data-edit-ref="${CSS.escape(t)}"]`);if(n)return{el:n,level:`edit`};let r=t.replace(/-\d+$/,``),i=e.querySelector(`[data-tool-ref="${CSS.escape(r)}"]`);return i?{el:i,level:`card`}:null}function rn(e,t,n,r){let i=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-n;e.scrollTo({top:i,behavior:r?`smooth`:`auto`})}function an(e,t){let n=nn(e,t);if(!n)return()=>{};let{el:r,level:i}=n;for(let t of en(r,e))rn(t,r,Zt,!1);rn(e,r,Xt,!tn()),r.dataset.flash=i;let a=setTimeout(()=>{delete r.dataset.flash},Qt);return()=>{clearTimeout(a),delete r.dataset.flash}}var on=new Set([`Write`,`Edit`,`MultiEdit`,`NotebookEdit`]),sn={create:3,write:2,notebook:2,edit:1};function cn(e){return typeof e==`string`?e:``}function ln(e,t){let n=0,r=0;for(let i of rt(e,t))i.added?n+=i.count??0:i.removed&&(r+=i.count??0);return{added:n,removed:r}}function un(e){return e&&/created successfully/i.test(e)?`create`:`write`}function dn(e,t,n){switch(e){case`Write`:{let e=cn(t.file_path);return e?{filePath:e,op:un(n),fragments:[{oldStr:``,newStr:cn(t.content)}]}:null}case`Edit`:{let e=cn(t.file_path);return e?{filePath:e,op:`edit`,fragments:[{oldStr:cn(t.old_string),newStr:cn(t.new_string)}]}:null}case`MultiEdit`:{let e=cn(t.file_path);if(!e||!Array.isArray(t.edits))return null;let n=t.edits.filter(e=>!!e&&typeof e==`object`).map(e=>({oldStr:cn(e.old_string),newStr:cn(e.new_string)}));return n.length===0?null:{filePath:e,op:`edit`,fragments:n}}case`NotebookEdit`:{let e=cn(t.notebook_path)||cn(t.file_path);return e?{filePath:e,op:`notebook`,fragments:[{oldStr:``,newStr:cn(t.new_source)}]}:null}default:return null}}function fn(e,t){if(e){for(let n of e)if(n.type===`tool_result`&&n.toolUseId&&t.set(n.toolUseId,n.output??``),n.type===`tool_use`){let e=n.result;n.toolUseId&&e?.output!=null&&!t.has(n.toolUseId)&&t.set(n.toolUseId,e.output),fn(n.children,t)}}}function pn(e,t,n,r){if(e)for(let i of e){if(i.type!==`tool_use`||(i.children?.length&&pn(i.children,!0,n,r),!on.has(i.tool)))continue;let e=i.input&&typeof i.input==`object`?i.input:null;if(!e)continue;let a=dn(i.tool,e,i.toolUseId?r.get(i.toolUseId):void 0);if(!a)continue;let o=n.get(a.filePath);o||(o={filePath:a.filePath,op:a.op,editCount:0,linesAdded:0,linesRemoved:0,edits:[],viaSubagent:!1},n.set(a.filePath,o)),sn[a.op]>sn[o.op]&&(o.op=a.op),t&&(o.viaSubagent=!0),a.fragments.forEach((e,n)=>{let{added:r,removed:a}=ln(e.oldStr,e.newStr);o.linesAdded+=r,o.linesRemoved+=a,o.editCount+=1,o.edits.push({...e,toolUseId:i.toolUseId,editIndex:n,editRef:i.toolUseId?`${i.toolUseId}-${n}`:void 0,viaSubagent:t})})}}function mn(e){let t=new Map;for(let n of e)fn(n.events,t);let n=new Map;for(let r of e)pn(r.events,!1,n,t);return[...n.values()]}function hn(e,t){let n=[];for(let r=t;r>=0&&e[r]?.role===`assistant`;r--)n.unshift(e[r]);return n}var $=n();function gn(e){try{return new Date(e).toLocaleString()}catch{return``}}function _n({icon:e,label:t,title:n,onClick:r}){return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:n,"aria-label":t,className:`inline-flex items-center justify-center gap-1 rounded-md px-1.5 py-1 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors`,children:[e,(0,$.jsx)(`span`,{children:t})]})}function vn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(_n,{icon:t?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{X(e),n(!0),setTimeout(()=>n(!1),1500)}})}function yn({timestamp:e,content:t,className:n,children:r}){return(0,$.jsxs)(`div`,{className:k(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,n),children:[(0,$.jsx)(`time`,{title:gn(e),className:`pr-1 tabular-nums`,children:le(e)}),(0,$.jsx)(vn,{content:t}),r]})}function bn(e){let t=0,n=0;for(let r of e)t+=r.linesAdded,n+=r.linesRemoved;return{added:t,removed:n}}function xn({count:e,totals:t,open:n,onToggle:r,ref:i}){let a=`${e} file${e===1?``:`s`}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mx-1.5 h-3.5 w-px bg-border-soft`}),(0,$.jsxs)(`button`,{ref:i,type:`button`,onClick:r,"aria-expanded":n,"aria-label":`${a} changed this turn, ${t.added} added, ${t.removed} removed`,className:k(`inline-flex items-center gap-[7px] rounded-full font-mono text-[11.5px]`,`px-3 min-h-11 md:min-h-0 md:px-[9px] md:py-[5px]`,`text-text-secondary transition-colors hover:bg-surface hover:text-text-primary`),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-[5px] shrink-0 rounded-full bg-primary`}),(0,$.jsx)(`span`,{children:a}),(0,$.jsxs)(`span`,{className:`flex items-center gap-[5px] tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t.removed]})]})]})]})}function Sn(e){if(!e)return!1;let t=e.closest(`[data-tab-pool-id]`)?.dataset.tabPoolId;if(!t)return e.offsetParent!==null;let{panels:n,focusedPanelId:r}=j.getState();return n[r]?.activeTabId===t}var Cn={create:{glyph:`A`,cls:`text-success`,label:`created`},write:{glyph:`W`,cls:`text-warning`,label:`overwritten`},notebook:{glyph:`N`,cls:`text-accent-2`,label:`notebook edited`},edit:{glyph:`·`,cls:`text-text-subtle`,label:`edited`}};function wn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}function Tn({added:e,removed:t,editCount:n,className:r}){return(0,$.jsxs)(`span`,{className:k(`flex items-center gap-[5px] tabular-nums`,r),children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t]}),n!=null&&n>1&&(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[`×`,n]})]})}function En({change:e,dense:t,selected:n,onClick:r}){let i=Cn[e.op],{base:a,dir:o}=wn(e.filePath),s=e.viaSubagent?`${i.label} · changed by a sub-agent`:i.label;return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:e.filePath,className:k(`grid w-full grid-cols-[16px_1fr_auto_10px] items-center gap-[10px] text-left font-mono`,`border-b border-border-soft hover:bg-surface transition-colors`,t?`min-h-[38px] px-2.5 py-[5px] text-xs`:`min-h-[52px] px-3 py-[7px] text-[12.5px]`,n&&`bg-surface shadow-[inset_2px_0_0_var(--accent)]`),children:[(0,$.jsx)(`span`,{"aria-label":s,title:s,className:k(`inline-flex size-4 items-center justify-center rounded bg-white/5 text-[9px] font-semibold`,i.cls,e.viaSubagent&&`bg-accent-2/20 ring-1 ring-inset ring-accent-2/35`),children:i.glyph}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-text-primary`,children:a}),o&&(0,$.jsx)(`span`,{className:`block overflow-hidden text-ellipsis whitespace-nowrap text-[10px] text-text-subtle [direction:rtl] text-left`,children:o})]}),(0,$.jsx)(Tn,{added:e.linesAdded,removed:e.linesRemoved,editCount:e.editCount,className:`text-[11px]`}),(0,$.jsx)(c,{className:`size-[11px] text-text-subtle`})]})}var Dn=(0,Q.lazy)(()=>re(()=>import(`./edit-diff-preview-xdDQvPhs.js`),__vite__mapDeps([0,1,2,3])));function On({change:e,onJump:t}){return(0,$.jsx)(`div`,{children:e.edits.map((n,r)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!n.editRef,onClick:()=>n.editRef&&t(n.editRef),className:`group flex min-h-11 w-full items-center gap-2 px-3 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface disabled:hover:bg-transparent`,children:[(0,$.jsxs)(`span`,{children:[`edit `,r+1,` of `,e.editCount]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border-soft`}),n.editRef&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 group-hover:text-primary`,children:[(0,$.jsx)(ce,{className:`size-3`}),`jump`]})]}),(0,$.jsx)(`div`,{className:`mx-3 mb-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-4`}),children:(0,$.jsx)(Dn,{oldStr:n.oldStr,newStr:n.newStr,filePath:e.filePath})})})]},n.editRef??r))})}function kn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}var An=null;function jn(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function Mn({changes:e,onJump:t,onClose:n}){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useId)();(0,Q.useEffect)(()=>(An=s,o.current?.querySelector(`button`)?.focus(),()=>{An===s&&(An=null)}),[s]),(0,Q.useEffect)(()=>{let o=o=>{if(An===s&&Sn(a.current)&&!jn(document.activeElement)){if(o.key===`Escape`)o.preventDefault(),n();else if(o.key===`j`)o.preventDefault(),i(t=>Math.min(t+1,e.length-1));else if(o.key===`k`)o.preventDefault(),i(e=>Math.max(e-1,0));else if(o.key===`Enter`){let n=e[r]?.edits[0]?.editRef;n&&(o.preventDefault(),t(n))}}};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[s,e,r,t,n]);let c=e[Math.min(r,e.length-1)];if(!c)return null;let{base:l,dir:u}=kn(c.filePath);return(0,$.jsx)(`div`,{ref:a,className:`mt-0.5 overflow-hidden rounded-[10px] border border-border-soft bg-bg`,children:(0,$.jsxs)(`div`,{className:`grid h-[356px] grid-cols-[294px_1fr] grid-rows-[minmax(0,1fr)] bg-surface-elevated`,children:[(0,$.jsxs)(`div`,{ref:o,className:`min-h-0 overflow-y-auto border-r border-border-soft`,children:[e.map((e,t)=>(0,$.jsx)(En,{change:e,dense:!0,selected:t===r,onClick:()=>i(t)},e.filePath)),(0,$.jsx)(`p`,{className:`px-2.5 pt-2 pb-2.5 font-mono text-[10px] text-text-subtle`,children:`j / k to move · enter to jump`})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border-soft bg-surface-elevated py-[5px] pl-2.5 pr-2`,children:[(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-text-primary`,children:l}),u&&(0,$.jsx)(`span`,{title:c.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:u}),(0,$.jsx)(Tn,{added:c.linesAdded,removed:c.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void X(c.filePath),className:`shrink-0 rounded-md px-1.5 py-1 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy path`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close change tray`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:(0,$.jsx)(te,{className:`size-3.5`})})]}),(0,$.jsx)(On,{change:c,onJump:t})]})]})})}function Nn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?e:e.slice(t+1)}function Pn({label:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:n})}function Fn({changes:e,totals:t,open:n,onClose:r,onJump:i}){let[a,o]=(0,Q.useState)(null),s=a==null?null:e[a],c=(0,Q.useRef)(null),l=()=>{o(null),r()},u=e=>{l(),i(e)};return(0,Q.useEffect)(()=>{if(!n)return;let e=c.current,t=()=>Array.from(e?.querySelectorAll(`button:not([disabled])`)??[]);t()[0]?.focus();let r=e=>{if(e.key===`Escape`){e.preventDefault(),l();return}if(e.key!==`Tab`)return;let n=t();if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[n,a]),(0,$.jsx)(F,{open:n,onClose:l,className:`flex max-h-[85%] flex-col rounded-t-[14px] motion-reduce:animate-none`,children:(0,$.jsx)(`div`,{ref:c,className:`flex min-h-0 flex-1 flex-col`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft px-1 pb-1`,children:[(0,$.jsx)(Pn,{label:`Back to file list`,onClick:()=>o(null),children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:Nn(s.filePath)}),(0,$.jsx)(Tn,{added:s.linesAdded,removed:s.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Pn,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft py-1.5 pl-3 pr-2`,children:[(0,$.jsx)(`span`,{title:s.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:s.filePath}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void X(s.filePath),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy`}),s.edits[0]?.editRef&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(s.edits[0].editRef),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-primary`,children:[(0,$.jsx)(ce,{className:`size-3`}),`card`]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(On,{change:s,onJump:u})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border-soft px-3 pb-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:[`Changed this turn · `,e.length,` file`,e.length===1?``:`s`]}),(0,$.jsx)(Tn,{added:t.added,removed:t.removed,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Pn,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.map((e,t)=>(0,$.jsx)(En,{change:e,onClick:()=>o(t)},e.filePath))})]})})})}function In({timestamp:e,content:t,changes:n,onJumpToEdit:r}){let[i,a]=(0,Q.useState)(!1),o=oe(),s=(0,Q.useRef)(null),c=()=>{a(!1),s.current?.focus()},l=(0,$.jsx)(yn,{timestamp:e,content:t,className:`-mt-1.5`,children:n&&n.length>0&&(0,$.jsx)(xn,{ref:s,count:n.length,totals:bn(n),open:i,onToggle:()=>i?c():a(!0)})});return!n||n.length===0?l:(0,$.jsxs)($.Fragment,{children:[l,o?(0,$.jsx)(Fn,{changes:n,totals:bn(n),open:i,onClose:c,onJump:r??(()=>{})}):i&&(0,$.jsx)(Mn,{changes:n,onJump:e=>{a(!1),r?.(e)},onClose:c})]})}function Ln(e){return e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens}function Rn(e){return e.inputTokens+e.cacheWriteTokens}var zn=.5,Bn=.9,Vn={cache_expired:`the session's prompt cache had already lapsed, so PPM released its subprocess`,idle_timeout:`the session sat idle with no tab open long enough for PPM to release its subprocess`,warm_idle_cap:`too many idle sessions were holding a subprocess, so this one was released early`,tab_closed:`PPM shut the session's subprocess down when the last tab disconnected`,set_model:`the model was changed, which restarts the session`,stream_ended:`the session's subprocess had already exited`,resume:`the session was resumed on a new subprocess`};function Hn(e){let t=Rn(e),n=Ln(e);if(!e.coldStart||n<2e4)return{level:`ok`,wastedTokens:t,reason:``};let r=e.cacheHitRate<zn?`bad`:e.cacheHitRate<Bn?`warn`:`ok`;if(r===`ok`)return{level:r,wastedTokens:t,reason:``};let i=e.coldReason?Vn[e.coldReason]??`the session restarted (${e.coldReason})`:null;return{level:r,wastedTokens:t,reason:i?`${Kn(t)} of this session's transcript was re-sent uncached because ${i}.`:`${Kn(t)} of this session's transcript was re-sent uncached.`}}var Un=.1,Wn=1.25;function Gn(e){let t=Ln(e);if(t===0)return 1;let n=e.inputTokens+e.cacheWriteTokens*Wn+e.cacheReadTokens*Un,r=t*Un;return r>0?Math.max(1,n/r):1}function Kn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function qn({usage:e}){let[t,n]=(0,Q.useState)(!1),r=Hn(e);if(r.level===`ok`)return null;let i=Gn(e),a=Ln(e),o=Math.round(e.cacheHitRate*100),c=r.level===`bad`;return(0,$.jsxs)(`div`,{className:`rounded-md border px-2.5 py-2 text-[11px] ${c?`border-warning/40 bg-warning/10`:`border-border bg-surface`}`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full items-start gap-2 py-1 text-left text-text-secondary transition-colors hover:text-text-primary`,children:[(0,$.jsx)(B,{className:`mt-px size-3.5 shrink-0 ${c?`text-warning`:`text-text-subtle`}`}),(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Costly turn — `,o,`% of a `,Kn(a),`-token transcript came from cache, so it cost about`,` `,(0,$.jsxs)(`strong`,{className:`font-semibold`,children:[i.toFixed(1),`x`]}),` a fully cached turn.`]}),(0,$.jsx)(s,{className:`mt-px size-3.5 shrink-0 transition-transform ${t?`rotate-180`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 border-t border-border pt-2`,children:[r.reason&&(0,$.jsx)(`p`,{className:`text-text-secondary`,children:r.reason}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 font-mono text-[10.5px] text-text-subtle`,children:[(0,$.jsx)(Jn,{label:`From cache`,value:`${Kn(e.cacheReadTokens)} (${o}%)`}),(0,$.jsx)(Jn,{label:`Written to cache`,value:Kn(e.cacheWriteTokens)}),(0,$.jsx)(Jn,{label:`Fresh input`,value:Kn(e.inputTokens)}),(0,$.jsx)(Jn,{label:`Output`,value:Kn(e.outputTokens)}),(0,$.jsx)(Jn,{label:`Model`,value:e.model||`unknown`}),(0,$.jsx)(Jn,{label:`Cost`,value:`$${e.costUsd.toFixed(4)}`})]}),(0,$.jsx)(`p`,{className:`text-text-subtle`,children:`A turn stays cached while the session keeps running. Closing the last tab of an idle session, switching model, or a retry all restart it, and the next turn re-sends the transcript at full price.`})]})]})}function Jn({label:e,value:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`truncate`,children:e}),(0,$.jsx)(`dd`,{className:`truncate text-right text-text-secondary`,children:t})]})}function Yn(e,t,n,r){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!n||!e||!t){a([]);return}let r=!1;return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{E.get(`/api/project/${encodeURIComponent(e)}/chat/sessions/${encodeURIComponent(t)}/tasks`).then(e=>{r||a(e)}).catch(()=>{})},300),()=>{r=!0,o.current&&clearTimeout(o.current)}},[e,t,n,r]),i}var Xn=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function Zn(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&Xn.has(e.tool)&&t++;return t}var Qn={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function $n({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>Zn(n),[n]),i=Yn(e,t,r>0,r),[a,o]=(0,Q.useState)(!0);if(i.length===0||i.every(e=>e.status===`completed`||e.status===`stopped`))return null;let l=i.filter(e=>e.status===`completed`).length,u=i.length,f=u?Math.round(l/u*100):0;return(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-surface/60 backdrop-blur-sm`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 w-full px-3 min-h-11 text-left text-xs hover:bg-surface transition-colors`,children:[a?(0,$.jsx)(c,{className:`size-3.5 shrink-0`}):(0,$.jsx)(s,{className:`size-3.5 shrink-0`}),(0,$.jsx)(d,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`text-text-primary font-medium`,children:`Tasks`}),(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[l,`/`,u,` done`]}),(0,$.jsx)(`span`,{className:`ml-auto h-1 w-16 rounded-full bg-border overflow-hidden shrink-0`,children:(0,$.jsx)(`span`,{className:`block h-full bg-success/70`,style:{width:`${f}%`}})})]}),!a&&(0,$.jsx)(`ul`,{className:`px-3 pb-2 space-y-0.5 max-h-48 overflow-y-auto`,children:i.map(e=>(0,$.jsx)(er,{task:e},e.id))})]})}function er({task:e}){let t=Qn[e.status]??Qn.pending,n=e.status===`in_progress`;return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs rounded px-1 ${n?`bg-warning/10`:``}`,children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5 ${t.cls}`,children:t.icon}),(0,$.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:n?`text-text-primary font-medium`:`text-text-secondary`,children:e.subject||(0,$.jsxs)(`span`,{className:`text-text-subtle italic`,children:[`#`,e.id,` (no title)`]})})]})}var tr=/read the full transcript at:\s*(\S+\.jsonl)/i;function nr(e){return e.match(tr)?.[1]?.trim()??null}var rr=class extends Q.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:this.props.fallbackContent?(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-text-primary opacity-80`,children:this.props.fallbackContent}):null:this.props.children}};function ir({projectName:e,onSelectSession:t}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(i,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Send a message to start a new conversation`})]}),(0,$.jsx)(Te,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}var ar=3200,or=1e3,sr={hasAbove:!1,atBottom:!0,idx:0,total:0};function cr({scrollElement:e,userIndices:t,scrollToBottom:n}){let r=oe(),[i,a]=(0,Q.useState)(sr),[o,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0),f=(0,Q.useRef)(ar),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(!1),_=(e,t,n)=>t.getBoundingClientRect().top-n+e.scrollTop,v=(0,Q.useCallback)(e=>Array.from(e.querySelectorAll(`[data-msg-index]`)).filter(e=>t.includes(Number(e.dataset.msgIndex))),[t]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=0,r=()=>{let e=t.scrollTop,n=t.getBoundingClientRect().top,r=v(t).map(e=>_(t,e,n)),i=0;for(let t=0;t<r.length;t++)r[t]<=e+12&&(i=t+1);let o={hasAbove:r.some(t=>t<e-4),atBottom:t.scrollHeight-e-t.clientHeight<8,idx:i,total:r.length};a(e=>e.hasAbove===o.hasAbove&&e.atBottom===o.atBottom&&e.idx===o.idx&&e.total===o.total?e:o)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};r(),t.addEventListener(`scroll`,i,{passive:!0});let o=new ResizeObserver(i);return o.observe(t),()=>{n&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,i),o.disconnect()}},[e,v]),(0,Q.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>c(!1),f.current);return()=>clearTimeout(e)},[o,i.idx,u]),(0,Q.useEffect)(()=>{if(!o||!g.current)return;g.current=!1;let e=p.current;(e?.querySelector(`button:not(:disabled)`)??e)?.focus()},[o]),(0,Q.useEffect)(()=>{o||!h.current||(h.current=!1,m.current?.focus())},[o]);let y=(0,Q.useCallback)(()=>{f.current=ar,d(e=>e+1)},[]),b=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let n=t.scrollTop,r=t.getBoundingClientRect().top,i;for(let e of v(t)){let a=_(t,e,r);if(a<n-4)i=a;else break}i!=null&&t.scrollTo({top:i,behavior:`auto`}),y()},[e,v,y]),x=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let r=t.scrollTop,i=t.getBoundingClientRect().top,a=v(t).map(e=>_(t,e,i)).find(e=>e>r+4);a==null?n({animation:`instant`}):t.scrollTo({top:a,behavior:`auto`}),y()},[e,v,n,y]),S=(0,Q.useCallback)(()=>{n({animation:`instant`}),y()},[n,y]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=e=>()=>{Sn(t)&&(e(),f.current=or,c(!0))},r=n(b),i=n(x);return window.addEventListener(`chat-nav-prev`,r),window.addEventListener(`chat-nav-next`,i),()=>{window.removeEventListener(`chat-nav-prev`,r),window.removeEventListener(`chat-nav-next`,i)}},[e,b,x]);let C=k(`w-[34px] flex items-center justify-center rounded-[9px] text-text-secondary`,`motion-safe:transition-colors hover:bg-surface-elevated hover:text-foreground`,`disabled:opacity-30 disabled:cursor-default disabled:hover:bg-transparent disabled:hover:text-text-secondary`,r?`h-9`:`h-[30px]`);return(0,$.jsx)(`div`,{className:`absolute bottom-3 right-2.5 z-10 flex flex-col items-end gap-1.5`,children:o?(0,$.jsxs)(`div`,{ref:p,tabIndex:-1,className:`flex flex-col p-[3px] rounded-xl border border-border bg-surface-elevated/95 backdrop-blur-[8px] shadow-lg outline-none`,onFocus:()=>{h.current=!0},onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,$.jsx)(`button`,{type:`button`,onClick:b,disabled:!i.hasAbove,"aria-label":`Jump to previous message`,className:C,children:(0,$.jsx)(l,{className:`size-[15px]`})}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-medium text-text-subtle text-center py-px`,"aria-label":`Message ${i.idx||1} of ${i.total}`,children:i.total?`${i.idx||1}/${i.total}`:`0/0`}),(0,$.jsx)(`button`,{type:`button`,onClick:x,disabled:i.atBottom,"aria-label":`Jump to next message`,className:C,children:(0,$.jsx)(s,{className:`size-[15px]`})}),(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:i.atBottom,"aria-label":`Jump to latest`,className:C,children:(0,$.jsx)(ht,{className:`size-[13px]`})})]}):(0,$.jsx)(`button`,{ref:m,type:`button`,onClick:()=>{f.current=ar,g.current=!0,c(!0)},"aria-label":`Navigate messages`,"aria-expanded":!1,title:`Navigate messages`,className:k(`group flex items-center justify-center`,r?`size-11`:`size-[30px]`),children:(0,$.jsx)(`span`,{className:k(`flex items-center justify-center rounded-full border border-border bg-surface-elevated/55 backdrop-blur-[6px] text-text-subtle`,`motion-safe:transition-colors group-hover:bg-surface-elevated group-hover:text-foreground`,r?`size-9`:`size-[30px]`),children:(0,$.jsx)(ve,{className:`size-[15px]`})})})})}function lr({group:e,onNavigate:t,disabled:n}){if(!e||e.ids.length<2)return null;let{ids:r,currentIndex:i}=e,a=e=>{let i=r[e];i&&!n&&t(i)};return(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-xs text-text-subtle select-none`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i-1),disabled:n||i<=0,"aria-label":`Previous version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(G,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[i+1,`/`,r.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i+1),disabled:n||i>=r.length-1,"aria-label":`Next version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})}function ur(e){let[t,n]=(0,Q.useState)({}),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(0),s=(0,Q.useCallback)((e,t)=>{n(n=>({...n,[e]:[t]})),i(t=>({...t,[e]:``}))},[]),c=(0,Q.useCallback)((e,t)=>{n(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),l=(0,Q.useCallback)((e,t)=>{i(n=>({...n,[e]:t})),t&&n(t=>({...t,[e]:[]}))},[]),u=(0,Q.useCallback)(e=>(t[e]?.length??0)>0||(r[e]?.trim().length??0)>0,[t,r]);return{answers:t,customInputs:r,activeTab:a,setActiveTab:o,handleSingleSelect:s,handleMultiSelect:c,handleCustomInput:l,hasAnswer:u,allAnswered:(0,Q.useMemo)(()=>e.every((e,t)=>u(t)),[e,u]),getFinalAnswer:(0,Q.useCallback)(e=>r[e]?.trim()||(t[e]??[]).join(`, `),[t,r]),goToNextTab:(0,Q.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),goToPrevTab:(0,Q.useCallback)(()=>o(e=>Math.max(e-1,0)),[])}}function dr(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>n(0),[e.activeTab]),(0,Q.useEffect)(()=>{if(!e.enabled)return;let i=r=>{let i=e.customInputRef.current,a=!!i&&i.ownerDocument.activeElement===i;if(!a&&r.key>=`1`&&r.key<=`9`){r.preventDefault();let t=parseInt(r.key)-1;t<e.totalOptions-1&&(n(t),e.onSelectOption(t));return}if(!a&&(r.key===`o`||r.key===`O`||r.key===`0`)){r.preventDefault(),e.customInputRef.current?.focus(),n(e.totalOptions-1);return}if(r.key===`Tab`&&e.questions.length>1){r.preventDefault(),r.shiftKey?e.goToPrevTab():e.goToNextTab();return}if(!a){if(r.key===`ArrowLeft`){r.preventDefault(),e.goToPrevTab();return}if(r.key===`ArrowRight`){r.preventDefault(),e.goToNextTab();return}if(r.key===`ArrowUp`){r.preventDefault(),n(e=>Math.max(0,e-1));return}if(r.key===`ArrowDown`){r.preventDefault(),n(t=>Math.min(e.totalOptions-1,t+1));return}if(r.key===` `){r.preventDefault(),e.onSelectOption(t);return}}if(r.key===`Enter`){r.preventDefault(),e.allAnswered?e.onSubmit():e.hasAnswer(e.activeTab)&&e.goToNextTab();return}r.key===`Escape`&&a&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(a.ownerDocument.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function fr({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ur(e),a=e[i.activeTab],o=a?a.options.length+1:0,s=e.length>1,c=(0,Q.useCallback)(()=>{if(!i.allAnswered)return;let n={};e.forEach((e,t)=>{n[e.question]=i.getFinalAnswer(t)}),t(n)},[i.allAnswered,i.getFinalAnswer,e,t]),l=(0,Q.useCallback)(e=>{if(!(!a||e<0))if(e<a.options.length){let t=a.options[e]?.label;if(!t)return;a.multiSelect?i.handleMultiSelect(i.activeTab,t):i.handleSingleSelect(i.activeTab,t)}else e===a.options.length&&r.current?.focus()},[a,i]),u=dr({questions:e,activeTab:i.activeTab,totalOptions:o,allAnswered:i.allAnswered,hasAnswer:i.hasAnswer,onSelectOption:l,goToNextTab:i.goToNextTab,goToPrevTab:i.goToPrevTab,onSubmit:c,customInputRef:r,enabled:!0}),d=(0,Q.useCallback)(e=>{l(e),u.setFocusedOption(e)},[l,u.setFocusedOption]);return(0,$.jsxs)(`div`,{ref:u.containerRef,className:`rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-3 outline-none animate-in slide-in-from-bottom-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm font-medium text-text-primary`,children:[(0,$.jsxs)(`span`,{children:[`AI has `,s?`${e.length} questions`:`a question`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-text-secondary font-normal`,children:[s?`←→ tabs · `:``,`↑↓ options · 1-`,Math.min(o-1,9),` select · Enter submit`]})]}),s&&(0,$.jsx)(`div`,{className:`flex gap-1 p-1 bg-background rounded-md overflow-x-auto border border-border`,children:e.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs whitespace-nowrap transition-all ${i.activeTab===t?`bg-primary text-primary-foreground`:i.hasAnswer(t)?`text-primary bg-transparent`:`text-text-secondary hover:bg-surface-elevated`}`,onClick:()=>{i.setActiveTab(t),u.setFocusedOption(0)},tabIndex:-1,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold ${i.activeTab===t?`bg-white/20`:i.hasAnswer(t)?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:i.hasAnswer(t)?`✓`:t+1}),(0,$.jsx)(`span`,{className:`max-w-[100px] overflow-hidden text-ellipsis`,children:e.header||`Q${t+1}`})]},t))}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[!s&&a.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-text-secondary`,children:a.header}),(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:a.question}),a.multiSelect&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-secondary`,children:`Select multiple`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.options.map((e,t)=>{let n=(i.answers[i.activeTab]||[]).includes(e.label),r=u.focusedOption===t;return(0,$.jsxs)(`div`,{role:`button`,onClick:()=>d(t),className:`text-left flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border transition-all cursor-pointer select-text ${n?`border-primary bg-primary/10 text-text-primary`:`border-border bg-background text-text-secondary hover:border-primary/40 hover:bg-primary/5`} ${r?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded text-[10px] font-semibold shrink-0 mt-px ${n?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:t+1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-text-secondary`,children:e.description})]})]},t)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border border-dashed transition-all border-border bg-transparent ${u.focusedOption===o-1?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded bg-surface-elevated text-text-secondary text-[10px] font-semibold shrink-0 mt-px`,children:`O`}),(0,$.jsx)(`input`,{ref:r,type:`text`,className:`flex-1 px-2 py-1 text-xs bg-surface border border-border rounded text-text-primary outline-none placeholder:text-text-subtle focus:border-primary`,placeholder:`Other (press O to type)...`,value:i.customInputs[i.activeTab]||``,onChange:e=>i.handleCustomInput(i.activeTab,e.target.value),onFocus:()=>u.setFocusedOption(o-1)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToPrevTab,disabled:i.activeTab===0,tabIndex:-1,children:`← Prev`}),(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToNextTab,disabled:i.activeTab===e.length-1,tabIndex:-1,children:`Next →`})]}),(0,$.jsx)(`button`,{onClick:n,className:`px-4 py-1.5 rounded border border-border bg-background text-text-secondary text-xs hover:bg-surface-elevated transition-colors`,tabIndex:-1,children:`Skip`}),(0,$.jsxs)(`button`,{onClick:c,disabled:!i.allAnswered,className:`px-4 py-1.5 rounded bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,tabIndex:-1,children:[`Submit `,i.allAnswered?`✓`:`(${e.filter((e,t)=>i.hasAnswer(t)).length}/${e.length})`]})]})]})}var pr={"system-reminder":`Context`,claudeMd:`CLAUDE.md`,gitStatus:`Git Status`,currentDate:`Date`,fast_mode_info:`Fast Mode`,"available-deferred-tools":`Tools`,"task-notification":`Task Result`,environment_details:`Environment`,"local-command-caveat":`System`};function mr(e){let t=[],n=/<(system-reminder|available-deferred-tools|antml:[\w-]+|fast_mode_info|claudeMd|gitStatus|currentDate|task-notification|environment_details|local-command-caveat)[^>]*>([\s\S]*?)<\/\1>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({name:e,label:pr[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function hr(e){let t=e.match(/<command-name>([\s\S]*?)<\/command-name>/);if(!t)return{command:null,cleanText:e};let n=t[1].trim(),r=e.match(/<command-args>([\s\S]*?)<\/command-args>/)?.[1]?.trim()||void 0,i=e.replace(/<command-name>[\s\S]*?<\/command-name>/g,``).replace(/<command-message>[\s\S]*?<\/command-message>/g,``).replace(/<command-args>[\s\S]*?<\/command-args>/g,``).trim();return{command:{name:n,args:r},cleanText:i}}function gr(e){let t=e.match(/^Use the (\S+) agent to\s?/);return t?{agent:t[1],cleanText:e.slice(t[0].length)}:{agent:null,cleanText:e}}function _r(e){let t=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g.exec(e);return t?{idePath:t[1].match(/opened the file (.+?) in the IDE/)?.[1]?.trim()??null,cleanText:e.replace(/<ide_opened_file>[\s\S]*?<\/ide_opened_file>/g,``).trim()}:{idePath:null,cleanText:e}}function vr(e){let t=[],n=e;for(;;){let e=n.match(/^\[Attached image \(contents included in this message\): (.+?)\]\n*/);if(e){t.push(e[1]),n=n.slice(e[0].length);continue}break}if(t.length>0){let e=vr(n);return{files:[...t,...e.files],text:e.text}}let r=n.match(/^\[Attached file: (.+?)\]\n*/);if(r)return{files:[r[1]],text:n.slice(r[0].length)};let i=n.match(/^\[Attached files:\n([\s\S]+?)\]\n*/);return i?{files:i[1].split(`
|
|
3
|
-
`).map(e=>e.trim()).filter(Boolean),text:n.slice(i[0].length)}:{files:[],text:n}}function yr(e){let t=[],n=e,r=/^```(?:bash|sh|shell|zsh)\n([\s\S]*?)\n```\s*(?:\n\n?)?/,i;for(;(i=n.match(r))!==null;)t.push(i[1]),n=n.slice(i[0].length);return{blocks:t,remainingText:n.trim()}}function br(e){let{idePath:t,cleanText:n}=_r(e),{blocks:r,remainingText:i}=yr(n),a=vr(i),{cleanText:o,tags:s}=mr(a.text.replace(/<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>/g,`$1`)),{command:c,cleanText:l}=hr(o),{agent:u,cleanText:d}=gr(l),f=c?.args?d?`${c.args}\n\n${d}`:c.args:d;return{files:a.files,text:f,body:d,tags:s,command:c,terminalBlocks:r,idePath:t,agent:u}}function xr(e){let{agent:t,body:n,command:r}=br(e);if(!r)return{agent:t,text:n};let i=`/${r.name.replace(/^\/+/,``)}${r.args?` ${r.args}`:``}`;return{agent:t,text:n?`${i}\n\n${n}`:i}}var Sr=re(()=>import(`./markdown-renderer-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/edit-diff-preview-xdDQvPhs.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-markdown-Ls5AcU91.js","assets/libesm-CdttTIAd.js","assets/markdown-renderer-Bthd7hxl.js","assets/vendor-mermaid-CfY1-PkA.js","assets/vendor-ui-CaeeFO0B.js","assets/markdown-renderer-Bkrk39pO.js","assets/index-DJM59ogE.js","assets/button-DX32ffge.js","assets/utils-IrnQujwR.js","assets/createLucideIcon-D8pyde1A.js","assets/arrow-left-CyFcsyzD.js","assets/bot-D6sx11y0.js","assets/check-DN75Ucvz.js","assets/chevron-down-Dp0rpHb8.js","assets/chevron-right-De-Wz5Lz.js","assets/chevron-up-8PbsNiJp.js","assets/circle-BCy0AUCo.js","assets/clock-C1CQUQPZ.js","assets/sparkles-Dh-_J2Rd.js","assets/copy-BewHj66E.js","assets/database-Y3ESDK4-.js","assets/download-DG3_9xXy.js","assets/use-coarse-long-press-BmI_GVW5.js","assets/eye-off-GjXVuAOn.js","assets/eye-gWwaF4Lg.js","assets/loader-circle-DPMrnLQ2.js","assets/monitor-C835ucWH.js","assets/x-CxoBA0po.js","assets/api-client-CEYCBt_0.js","assets/react-D1Yg256j.js","assets/window-store-D0HbQ1pM.js","assets/window-pip-registry-CrCYYTTf.js","assets/panel-store-BmdcSBNb.js","assets/context-menu-CJL8L98s.js","assets/portal-container-context-DKymYOY-.js","assets/mobile-bottom-sheet-CmySDB6I.js","assets/use-visual-viewport-Bfl3Bxxb.js","assets/use-is-mobile-D1weanbj.js","assets/project-store-wWZ6bjwq.js","assets/ws-auth-D111jj32.js","assets/settings-store-CzLnTR8p.js","assets/streaming-store-9XVmAMfV.js","assets/tab-store-1xYJb0gM.js","assets/apply-theme-BVXAUYoN.js","assets/resolve-theme-CMp5xxCW.js","assets/index-CuYtJ5xF.css","assets/image-gallery-J8h8IY0c.js","assets/run-in-terminal-wHKwAnWP.js","assets/api-client-QfreGirP.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{t as i}from"./bot-D6sx11y0.js";import{t as a}from"./brain-KDa9jFRq.js";import{t as o}from"./check-DN75Ucvz.js";import{t as s}from"./chevron-down-Dp0rpHb8.js";import{t as c}from"./chevron-right-De-Wz5Lz.js";import{t as l}from"./chevron-up-8PbsNiJp.js";import{a as u,i as d,n as f,o as p,r as m}from"./tool-cards-CY9J4ux4.js";import{t as h}from"./circle-BCy0AUCo.js";import{t as g}from"./clock-C1CQUQPZ.js";import{t as _}from"./code-DJgYrFzm.js";import{t as v}from"./sparkles-Dh-_J2Rd.js";import{t as y}from"./copy-BewHj66E.js";import{n as b,r as x}from"./use-coarse-long-press-BmI_GVW5.js";import{t as S}from"./eye-gWwaF4Lg.js";import{t as C}from"./hand-x0ejq3fS.js";import{t as w}from"./loader-circle-DPMrnLQ2.js";import{t as ee}from"./shield-off-7jKWpJBD.js";import{t as te}from"./x-CxoBA0po.js";import{i as T,n as E,r as D,s as ne}from"./api-client-CEYCBt_0.js";import{q as re}from"./vendor-mermaid-CfY1-PkA.js";import{t as O}from"./settings-store-CzLnTR8p.js";import{n as k,r as A,t as ie}from"./utils-IrnQujwR.js";import"./portal-container-context-DKymYOY-.js";import{t as j}from"./panel-store-BmdcSBNb.js";import"./window-store-D0HbQ1pM.js";import{i as M}from"./project-store-wWZ6bjwq.js";import{t as ae}from"./tab-store-1xYJb0gM.js";import"./context-menu-CJL8L98s.js";import{n as oe}from"./use-is-mobile-D1weanbj.js";import{n as N}from"./streaming-store-9XVmAMfV.js";import{t as P}from"./button-DX32ffge.js";import{t as F}from"./mobile-bottom-sheet-CmySDB6I.js";import"./use-visual-viewport-Bfl3Bxxb.js";import"./ws-auth-D111jj32.js";import{Ar as se,Bn as I,Br as ce,Cr as L,Dn as R,Dr as z,En as le,Fr as ue,Hn as de,In as B,Ir as V,Kn as fe,Ln as pe,Lt as me,M as he,Mr as H,N as ge,Nn as _e,Nr as ve,On as U,P as W,Pn as ye,Pr as G,Rn as K,Rt as be,Tn as xe,Un as Se,Wn as Ce,Xn as q,Xt as J,Yn as Y,Yt as we,_n as Te,ar as Ee,bn as De,cn as Oe,cr as ke,en as Ae,er as je,gn as Me,hr as Ne,jn as Pe,kn as Fe,nn as X,nr as Ie,or as Le,pr as Re,qn as Z,qt as ze,r as Be,t as Ve,tr as He,v as Ue,vn as We,wn as Ge,xr as Ke,yr as qe,zn as Je,zr as Ye,zt as Xe}from"./index-DJM59ogE.js";import{t as Ze}from"./use-websocket-mkNA1M8U.js";import{getAISettings as Qe,pickAccountForTab as $e}from"./api-settings-D18Q4Ocp.js";import"./use-blob-url-CrwoZJUJ.js";import{n as et,r as tt,t as nt}from"./image-gallery-J8h8IY0c.js";import{t as rt}from"./libesm-CdttTIAd.js";import{t as it}from"./use-open-team-member-CSUU7Z8N.js";import{n as at,t as ot}from"./send-to-chat-BI7-fFpG.js";import{t as st}from"./ai-settings-section-COdsN_5h.js";import{i as ct,l as lt,n as ut,s as dt,t as ft,u as pt}from"./use-accounts-data-pAQw6nCa.js";var mt=r(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ht=r(`chevrons-down`,[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]),gt=r(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),_t=r(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),vt=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),yt=r(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),bt=r(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),xt=r(`slash`,[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]),Q=e(t(),1),St={maxImages:4,maxBase64PerImage:5e6,maxBase64Total:1e7};function Ct(e){let t=[],n=0;for(let r of e)if(r.imageData){if(t.length>=St.maxImages)break;r.imageData.data.length>St.maxBase64PerImage||n+r.imageData.data.length>St.maxBase64Total||(n+=r.imageData.data.length,t.push(r.imageData))}return t}function wt(e,t){let n=new Set(t),r=[],i=[];for(let t of e)t.serverPath&&(t.imageData&&n.has(t.imageData)?r.push(t.serverPath):i.push(t.serverPath));return{inlineImagePaths:r,pathOnlyPaths:i}}function Tt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function Et(e,t){let n=`pc-${Tt(t)}-`;return e.map(e=>e.id?{...e,id:`${n}${e.id}`}:e)}function Dt(e,t){if(t.size===0)return e;let n=[];for(let r of e){let e=r.id?t.get(r.id):void 0;e&&e.length>0&&n.push(...e),n.push(r)}return n}var Ot=null;function kt(){return Ot||=new AudioContext,Ot}function At(e,t,n,r,i=`sine`){let a=kt(),o=a.createOscillator(),s=a.createGain();o.type=i,o.frequency.value=e,s.gain.setValueAtTime(r,n),s.gain.exponentialRampToValueAtTime(.001,n+t),o.connect(s),s.connect(a.destination),o.start(n),o.stop(n+t)}function jt(){let e=kt().currentTime;At(523,.15,e,.15),At(659,.2,e+.12,.15)}function Mt(){let e=kt().currentTime;At(880,.12,e,.18,`square`),At(698,.12,e+.15,.18,`square`),At(880,.15,e+.3,.15,`square`)}function Nt(){let e=kt().currentTime;At(440,.12,e,.12),At(523,.12,e+.1,.12),At(659,.18,e+.2,.12)}var Pt={done:jt,approval_request:Mt,question:Nt};function Ft(e){try{Pt[e]?.()}catch{}}var It={hasTeams:!1,teamNames:[],messageCount:0,unreadCount:0};function Lt(e){if(document.hidden)return!1;let{panels:t}=j.getState();for(let n of Object.values(t)){let t=n.tabs.find(e=>e.id===n.activeTabId);if(t?.type===`chat`&&t.metadata?.sessionId===e)return!0}return!1}function Rt(e,t=`claude`,n=``,r){let[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(new Map),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(0),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,ee]=(0,Q.useState)([]),te=(0,Q.useRef)([]),[re,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(null),[ie,M]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),se=(0,Q.useRef)(null),I=(0,Q.useRef)(null),[ce,L]=(0,Q.useState)(null),R=(0,Q.useRef)(null),[z,le]=(0,Q.useState)(!0),ue=(0,Q.useRef)(null),de=(0,Q.useRef)(null),B=(0,Q.useRef)(``),V=(0,Q.useRef)([]),fe=(0,Q.useRef)(new Map),pe=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(null),H=(0,Q.useRef)(`idle`),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(()=>{}),ve=(0,Q.useRef)(null),U=(0,Q.useRef)(!1),W=(0,Q.useRef)(new Set),ye=(0,Q.useRef)(0),G=(0,Q.useRef)(null),K=(0,Q.useRef)(0),be=(0,Q.useRef)(e);be.current=e;let xe=(0,Q.useRef)(r);xe.current=r;let Se=(0,Q.useRef)([]);Se.current=i;let Ce=(0,Q.useRef)(n);Ce.current=n;let q=(0,Q.useRef)(null),J=(0,Q.useRef)(0),Y=(0,Q.useRef)({teamNames:new Set,messages:[]}),we=(0,Q.useRef)(0),[Te,Ee]=(0,Q.useState)(It),[De,Oe]=(0,Q.useState)([]),ke=(0,Q.useCallback)(()=>{let e=Y.current;Ee({hasTeams:e.teamNames.size>0,teamNames:Array.from(e.teamNames),messageCount:e.messages.length,unreadCount:we.current}),Oe([...e.messages])},[]),Ae=(0,Q.useCallback)(()=>{we.current=0,ke()},[ke]),je=(0,Q.useCallback)(async e=>{try{let t=await E.get(`/api/teams/${encodeURIComponent(e)}`);if(!t?.messages)return;let n=Y.current.messages,r=t.messages.filter(e=>!n.some(t=>t.timestamp===e.timestamp&&t.from===e.from));n.push(...r),n.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),n.length>500&&n.splice(0,n.length-500),ke()}catch{}},[ke]),Me=f!==`idle`;(0,Q.useEffect)(()=>{if(e)return N.getState().setStreaming(e,f!==`idle`,n),()=>{N.getState().setStreaming(e,!1)}},[e,f,n]);let Ne=(0,Q.useCallback)((e,t)=>{let n=r=>{for(let i=0;i<r.length;i++){let a=r[i];if(a.type===`tool_use`){if((a.tool===`Agent`||a.tool===`Task`)&&a.toolUseId===t){let t=[...a.children??[]],n=e.toolUseId,o=n?t.findIndex(t=>t.type===e.type&&t.toolUseId===n):-1;return o===-1?t.push(e):t[o]=e,[[...r.slice(0,i),{...a,children:t},...r.slice(i+1)],!0]}if(a.children?.length){let[e,t]=n(a.children);if(t)return[[...r.slice(0,i),{...a,children:e},...r.slice(i+1)],!0]}}}return[r,!1]},[r,i]=n(V.current);return i&&(V.current=r),i},[]),Pe=(0,Q.useCallback)((e,t)=>{let n=e=>e.type===`tool_use`&&(e.tool===`Agent`||e.tool===`Task`)&&e.toolUseId===t,r=Se.current,i=-1;for(let e=r.length-1;e>=0;e--)if(r[e].events?.some(n)){i=e;break}return i===-1?!1:(a(t=>{let r=-1;for(let e=t.length-1;e>=0;e--)if(t[e].events?.some(n)){r=e;break}if(r===-1)return t;let i=t[r],a=i.events.map(t=>{if(!n(t)||t.type!==`tool_use`)return t;let r=[...t.children??[]],i=e.toolUseId,a=i?r.findIndex(t=>t.type===e.type&&t.toolUseId===i):-1;return a===-1?r.push(e):r[a]=e,{...t,children:r}});return[...t.slice(0,r),{...i,events:a},...t.slice(r+1)]}),!0)},[]),Fe=(0,Q.useCallback)(()=>{J.current=0;let e=B.current,t=[...V.current],n=pe.current;(0,Q.startTransition)(()=>{a(r=>{let i=r[r.length-1];return i?.role===`assistant`&&!i.id.startsWith(`final-`)?[...r.slice(0,-1),{...i,content:e,events:t,...n}]:[...r,{id:`streaming-${Date.now()}`,role:`assistant`,content:e,events:t,timestamp:new Date().toISOString(),...n}]})})},[]),X=(0,Q.useCallback)(()=>{J.current||=window.setTimeout(Fe,100)},[Fe]),Ie=(0,Q.useCallback)((e,t)=>{let n=t=>t.type===`tool_use`&&(t.tool===`Agent`||t.tool===`Task`)&&t.toolUseId===e,r=V.current.findIndex(n);if(r!==-1){V.current[r]={...V.current[r],bgStatus:t},X();return}a(e=>{let r=-1;for(let t=e.length-1;t>=0;t--)if(e[t].events?.some(n)){r=t;break}if(r===-1)return e;let i=e[r],a=i.events.map(e=>n(e)?{...e,bgStatus:t}:e);return[...e.slice(0,r),{...i,events:a},...e.slice(r+1)]})},[X]),Le=(0,Q.useCallback)(e=>{let t=e,n=t?.type;if(!n)return;let r=e=>{let n=V.current,r=n.findIndex(e);r===-1?n.push(t):n[r]=t};switch(n){case`account_info`:pe.current={accountId:t.accountId,accountLabel:t.accountLabel},he({id:t.accountId,label:t.accountLabel??null}),O(null);break;case`account_retry`:t.accountId&&t.accountLabel&&(pe.current={accountId:t.accountId,accountLabel:t.accountLabel},he({id:t.accountId,label:t.accountLabel})),V.current=[t],X();break;case`status_update`:{let e=t.accountLabel?` (${t.accountLabel})`:``;O(`${t.message}${e}`);break}case`text`:{let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}B.current+=t.content,V.current.push(t),X();break}case`thinking`:{let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}V.current.push(t),X();break}case`tool_use`:{if(t.tool===`AskUserQuestion`){t.toolUseId&&W.current.add(t.toolUseId);break}let e=t.parentToolUseId;if(e&&Ne(t,e)){X();break}if(e){Pe(t,e);break}let n=t.toolUseId;r(e=>!!n&&e.type===`tool_use`&&e.toolUseId===n),X();break}case`tool_result`:{let e=t.toolUseId;if(e&&fe.current.delete(e),e&&W.current.has(e))break;let n=t.parentToolUseId;if(n&&Ne(t,n)){X();break}if(n){Pe(t,n);break}r(t=>!!e&&t.type===`tool_result`&&t.toolUseId===e),X();break}case`approval_resolved`:{let e=t.requestId;if(t.approved&&t.answers){let n=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`),r=n&&n.input;r&&typeof r==`object`&&(r.answers=t.answers,a(e=>[...e]))}y(t=>t&&t.requestId===e?null:t),q.current!=null&&(ne.dismiss(q.current),q.current=null);break}case`approval_request`:if(r(e=>e.type===`approval_request`&&e.requestId===t.requestId),U.current)break;if(y({requestId:t.requestId,tool:t.tool,input:t.input}),be.current&&!Lt(be.current)){Ft(t.tool===`AskUserQuestion`?`question`:`approval_request`);let e=be.current,n=t.tool===`AskUserQuestion`;q.current=ne[n?`info`:`warning`](n?`AI has a question`:`${t.tool} needs permission`,{description:Ce.current||`Session ${e.slice(0,8)}`,duration:1/0,action:{label:`Go to session`,onClick:()=>{let{panels:t}=j.getState();for(let[n,r]of Object.entries(t)){let t=r.tabs.find(t=>t.metadata?.sessionId===e);if(t){j.getState().setActiveTab(t.id,n);break}}}}})}break;case`error`:a(e=>{let n=e[e.length-1];if(n?.role===`assistant`){let r=V.current,i=r[r.length-1],a=i?.type===`error`&&i.message===t.message?r:[...r,t];return V.current=a,[...e.slice(0,-1),{...n,events:a}]}return n?.role===`system`&&n.content===t.message?e:[...e,{id:`error-${Date.now()}`,role:`system`,content:t.message,events:[t],timestamp:new Date().toISOString()}]});break;case`team_detected`:{let e=t.teamName;e&&(Y.current.teamNames.add(e),ke(),je(e));break}case`team_inbox`:{let e=t.messages;if(Array.isArray(e)){let t=Y.current.messages;t.push(...e),t.length>500&&t.splice(0,t.length-500),we.current+=e.length,ke()}break}case`team_updated`:ke();break;case`bash_output`:{let e=t.toolUseId;if(e){let n=fe.current.get(e);n?(n.content+=t.content,n.content.length>5e5&&(n.content=n.content.slice(-5e5)),n.lineCount=t.lineCount):fe.current.set(e,{content:t.content,lineCount:t.lineCount}),X()}break}case`subagent_status`:{let e=t.toolUseId,n=t.status;e&&n&&Ie(e,n);break}case`background_registry`:{let e=t.shells??[];te.current=e,ee(e);break}case`done`:{if(H.current===`idle`)break;t.contextWindowPct!=null&&x(t.contextWindowPct),be.current&&!Lt(be.current)&&Ft(`done`),J.current&&=(clearTimeout(J.current),0);let e=B.current,n=[...V.current],r=pe.current,i=t.lastMessageUuid,o=t.usage;a(t=>{let a=t[t.length-1];return a?.role===`assistant`?[...t.slice(0,-1),{...a,id:`final-${Date.now()}`,content:e||a.content,events:n.length>0?n:a.events,...i&&{sdkUuid:i},...o&&{usage:o}}]:e||n.length>0?[...t,{id:`final-${Date.now()}`,role:`assistant`,content:e,events:n,timestamp:new Date().toISOString(),...i&&{sdkUuid:i},...o&&{usage:o},...r}]:t}),B.current=``,V.current=[],pe.current=null,G.current=null,fe.current.clear(),O(null);break}}},[Ne,Pe,X,Ie,ke,je]),Re=(0,Q.useCallback)(e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(t.type!==`ping`){if(t.type===`user_message`){let e=t.content;a(n=>{let r=n[n.length-1];return r?.role===`user`&&r.content===e?n:[...n,{id:`user-remote-${Date.now()}`,role:`user`,content:e,timestamp:t.timestamp??new Date().toISOString()}]});return}if(t.type===`title_updated`){A(t.title??null);return}if(t.type===`session_migrated`){let e=t.newSessionId;e&&e!==be.current&&xe.current?.(e);return}if(t.type===`compact_status`){let e=t.status;e===`compacting`?C(`compacting`):e===`done`&&C(null);return}if(t.type===`phase_changed`){let e=t.phase;p(e),H.current=e,_(e===`connecting`?t.elapsed??0:0),e===`idle`&&C(null);return}if(t.type===`session_state`){M(!0),oe(t.sessionId??be.current);let e=t,n=e.phase,r=H.current===`idle`;if(p(n),H.current=n,e.sessionTitle&&A(e.sessionTitle),e.model&&(I.current&&e.model!==I.current||(e.model===I.current&&(I.current=null),F(e.model),se.current=e.model)),typeof e.effort==`string`&&(L(e.effort),R.current=e.effort),typeof e.thinking==`boolean`&&le(e.thinking),e.pendingApproval&&y({requestId:e.pendingApproval.requestId,tool:e.pendingApproval.tool,input:e.pendingApproval.input}),C(e.compactStatus===`compacting`?`compacting`:null),n===`idle`){let e=Date.now()-K.current<5e3;r&&e||ve.current?.(),h(!1)}return}if(t.type===`turn_events`){let e=t.events,n=t.userMessage;if(!e?.length&&!n){h(!1);return}ye.current&&=(cancelAnimationFrame(ye.current),0),G.current=n,a(e=>{let t=[...e],r=t.length;for(;r>0&&t[r-1].role===`assistant`;)r--;if(n!=null&&r>0&&t[r-1].role===`user`&&t[r-1].content===n)t=t.slice(0,r-1);else{let e=t[t.length-1];e?.role===`assistant`&&e.id.startsWith(`streaming-`)&&(t=t.slice(0,-1))}if(n){let e=t[t.length-1];(e?.role!==`user`||e.content!==n)&&(t=[...t,{id:`user-replay-${Date.now()}`,role:`user`,content:n,timestamp:new Date().toISOString()}])}return t}),B.current=``,V.current=[],pe.current=null,U.current=!0;let r=0,i=()=>{let t=Math.min(r+100,e.length);for(let n=r;n<t;n++)Le(e[n]);r=t,r<e.length?ye.current=requestAnimationFrame(i):(ye.current=0,U.current=!1,h(!1))};ye.current=requestAnimationFrame(i);return}Le(t)}},[Le]),{send:Z,connect:ze}=Ze({url:e&&n?`/ws/project/${encodeURIComponent(n)}/chat/${e}`:``,onMessage:Re,autoConnect:!!e&&!!n});_e.current=Z,(0,Q.useEffect)(()=>{let r=!1;de.current&&de.current!==e&&(I.current=null,ue.current=null,he(null)),de.current=e??null,p(`idle`),H.current=`idle`,y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null),C(null),s(new Map),d({}),B.current=``,V.current=[],G.current=null,K.current=0,fe.current.clear(),J.current&&=(clearTimeout(J.current),0),M(!1),oe(null),Y.current={teamNames:new Set,messages:[]},we.current=0,Ee(It),Oe([]),e&&E.get(`/api/teams`).then(t=>{r||!Array.isArray(t)||t.filter(t=>(t?.name??t?.team_name)===e).length!==0&&(Y.current.teamNames.add(e),ke(),je(e))}).catch(()=>{});let i=new Set(Se.current.map(e=>e.id));return e&&n?(l(!0),E.get(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`).then(e=>{if(r)return;let t=Array.isArray(e)?{messages:e,versionMap:{}}:e,n=Array.isArray(t?.messages)?t.messages:[];t?.versionMap&&d(t.versionMap),t?.canonicalSessionId&&t.canonicalSessionId!==be.current&&xe.current?.(t.canonicalSessionId);let o=G.current;if(o!=null){for(let e=n.length-1;e>=0;e--)if(n[e].role===`user`&&n[e].content===o){n=n.slice(0,e);break}}a(e=>{let t=e.filter(e=>!i.has(e.id));return[...n,...t]}),K.current=Date.now()}).catch(()=>{r||a(e=>e.filter(e=>!i.has(e.id)))}).finally(()=>{r||l(!1)})):a([]),()=>{r=!0}},[e,t,n,ke,je]);let Be=(0,Q.useCallback)((e,t)=>{if(!e.trim()&&!t?.images?.length)return;let n=H.current!==`idle`;if(n){J.current&&=(clearTimeout(J.current),0);let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n})}a(t=>[...t,{id:`user-${Date.now()}`,role:`user`,content:e,timestamp:new Date().toISOString()}]),B.current=``,V.current=[],ge.current=null,n?(p(`thinking`),H.current=`thinking`):(p(`initializing`),H.current=`initializing`),y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null),Z(JSON.stringify({type:`message`,content:e,permissionMode:t?.permissionMode,priority:t?.priority,images:t?.images,imagePaths:t?.imagePaths,...se.current&&{model:se.current},...R.current&&{effort:R.current},...ue.current!==null&&{thinking:ue.current}}))},[Z]),He=(0,Q.useCallback)(e=>{F(e),se.current=e,I.current=e,Z(JSON.stringify({type:`set_model`,model:e}))},[Z]),Ue=(0,Q.useCallback)(e=>{L(e),R.current=e,Z(JSON.stringify({type:`set_effort`,effort:e}))},[Z]),We=(0,Q.useCallback)(e=>{le(e),ue.current=e,Z(JSON.stringify({type:`set_thinking`,enabled:e}))},[Z]),Ge=(0,Q.useCallback)((e,t,n)=>{if(Z(JSON.stringify({type:`approval_response`,requestId:e,approved:t,data:n})),t&&n){let t=V.current.find(t=>t.type===`approval_request`&&t.requestId===e&&t.tool===`AskUserQuestion`);if(t){let e=t.input;e&&typeof e==`object`&&(e.answers=n)}a(e=>[...e])}y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null)},[Z]),Ke=(0,Q.useCallback)(()=>{if(H.current===`idle`)return;Z(JSON.stringify({type:`cancel`}));let e=B.current,t=[...V.current];a(n=>{let r=n[n.length-1];return r?.role===`assistant`?[...n.slice(0,-1),{...r,id:`final-${Date.now()}`,content:e||r.content,events:t.length>0?t:r.events}]:n}),B.current=``,V.current=[],fe.current.clear(),ge.current=null,p(`idle`),H.current=`idle`,y(null),q.current!=null&&(ne.dismiss(q.current),q.current=null)},[Z]),qe=(0,Q.useCallback)(e=>{e&&Z(JSON.stringify({type:`kill_background_shell`,shellId:e}))},[Z]),Je=(0,Q.useCallback)(e=>{if(!e)return;let t=e.replace(/\.output$/,``);return te.current.find(n=>n.shellId===t||n.outputPath.endsWith(e)||n.outputPath.endsWith(`${t}.output`))},[]);(0,Q.useEffect)(()=>{e&&Ve.getState().setSessionShells(e,w)},[e,w]),(0,Q.useEffect)(()=>{if(e)return Ve.getState().retainSession(e),()=>{Ve.getState().releaseSession(e)}},[e]);let Ye=(0,Q.useCallback)(()=>{M(!1),h(!0),ze()},[ze]),Xe=(0,Q.useCallback)(()=>{!e||!n||fetch(`${T(n)}/chat/sessions/${e}/messages?providerId=${t}`,{headers:{Authorization:`Bearer ${D()}`}}).then(e=>e.json()).then(e=>{if(H.current!==`idle`)return;let t=e.ok?Array.isArray(e.data)?{messages:e.data,versionMap:void 0}:e.data:null;t?.versionMap&&d(t.versionMap),Array.isArray(t?.messages)&&t.messages.length>0&&(a(t.messages),B.current=``,V.current=[]),K.current=Date.now()}).catch(()=>{})},[e,t,n]);ve.current=Xe;let Qe=(0,Q.useCallback)(async(e,t)=>{if(!n)throw Error(`No project context available`);let r=e.replace(/^pc-[^-]+-/,``),i=`${T(n)}/chat/pre-compact-messages?jsonlPath=${encodeURIComponent(t)}&before=${encodeURIComponent(r)}`,a=Et(await E.get(i),t);return s(t=>{let n=new Map(t);return n.set(e,a),n}),a.length},[n]),$e=(0,Q.useCallback)(e=>o.has(e),[o]),et=(0,Q.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e))},[]),tt=(0,Q.useCallback)(()=>{a(e=>e.filter(e=>e.role!==`system`))},[]);return{messages:i,renderedMessages:(0,Q.useMemo)(()=>Dt(i,o),[i,o]),expandCompact:Qe,isCompactExpanded:$e,dismissMessage:et,clearErrors:tt,messagesLoading:c,versionMap:u,isStreaming:Me,phase:f,isReconnecting:m,connectingElapsed:g,pendingApproval:v,contextWindowPct:b,compactStatus:S,statusMessage:re,sessionTitle:k,liveAccount:me,model:P,setModel:He,effort:ce,setEffort:Ue,thinking:z,setThinking:We,teamActivity:Te,teamMessages:De,markTeamRead:Ae,bashPartialOutput:fe,backgroundShells:w,killBackgroundShell:qe,findBackgroundShellByOutput:Je,sendMessage:Be,respondToApproval:Ge,cancelStreaming:Ke,reconnect:Ye,refetchMessages:Xe,isConnected:ie&&ae===e}}var zt=12e4;function Bt(e,t=`claude`,n){let r=JSON.stringify([e,t,n]),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),l=(0,Q.useRef)(0),u=(0,Q.useCallback)((i=!1)=>{if(!e)return Promise.resolve();let o=++l.current;s(!0);let c=i?`&refresh=1`:``,u=n?`&session=${encodeURIComponent(n)}`:``;return E.get(`${T(e)}/chat/usage?providerId=${t}${u}${c}`).then(e=>{o===l.current&&a({scope:r,usage:e??{},fetchedAt:e?.lastFetchedAt??null})}).catch(()=>{}).finally(()=>{o===l.current&&s(!1)})},[e,t,n,r]);(0,Q.useEffect)(()=>(a(null),s(!1),u(),c.current=setInterval(()=>u(),zt),()=>{++l.current,c.current&&clearInterval(c.current)}),[u]);let d=(0,Q.useCallback)(()=>u(!0),[u]),f=(0,Q.useCallback)(()=>u(),[u]),p=i?.scope===r?i:null;return{usageInfo:p?.usage??{},usageLoading:o,lastFetchedAt:p?.fetchedAt??null,refreshUsage:d,reloadUsage:f}}var Vt={damping:.7,stiffness:.05,mass:1.25},Ht=70,Ut=1e3/60,Wt=350,Gt=!1;globalThis.document?.addEventListener(`mousedown`,()=>{Gt=!0}),globalThis.document?.addEventListener(`mouseup`,()=>{Gt=!1}),globalThis.document?.addEventListener(`click`,()=>{Gt=!1});var Kt=(e={})=>{let[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(e.initial!==!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);s.current=e;let c=(0,Q.useCallback)(()=>{if(!Gt)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let t=e.getRangeAt(0);return t.commonAncestorContainer.contains(g.current)||g.current?.contains(t.commonAncestorContainer)},[]),l=(0,Q.useCallback)(e=>{d.isAtBottom=e,i(e)},[]),u=(0,Q.useCallback)(e=>{d.escapedFromLock=e,n(e)},[]),d=(0,Q.useMemo)(()=>{let n;return{escapedFromLock:t,isAtBottom:r,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return g.current?.scrollTop??0},set scrollTop(e){if(g.current){let{scrollBehavior:t}=getComputedStyle(g.current);t!==`auto`&&(g.current.style.scrollBehavior=`auto`),g.current.scrollTop=e,d.ignoreScrollToTop=g.current.scrollTop,t!==`auto`&&(g.current.style.scrollBehavior=t)}},get targetScrollTop(){return!g.current||!_.current?0:g.current.scrollHeight-1-g.current.clientHeight},get calculatedTargetScrollTop(){if(!g.current||!_.current)return 0;let{targetScrollTop:t}=this;if(!e.targetScrollTop)return t;if(n?.targetScrollTop===t)return n.calculatedScrollTop;let r=Math.max(Math.min(e.targetScrollTop(t,{scrollElement:g.current,contentElement:_.current}),t),0);return n={targetScrollTop:t,calculatedScrollTop:r},requestAnimationFrame(()=>{n=void 0}),r},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Ht}}},[]),f=(0,Q.useCallback)((e={})=>{typeof e==`string`&&(e={animation:e}),e.preserveScrollPosition||l(!0);let t=Date.now()+(Number(e.wait)||0),n=Yt(s.current,e.animation),{ignoreEscapes:r=!1}=e,i,a=d.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{i=Date.now()}):i=t+(e.duration??0);let o=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:l}=d,u=performance.now(),p=(u-(d.lastTick??u))/Ut;if(d.animation||={behavior:n,promise:e,ignoreEscapes:r},d.animation.behavior===n&&(d.lastTick=u),c()||t>Date.now())return o();if(l<Math.min(a,d.calculatedTargetScrollTop)){if(d.animation?.behavior===n){if(n===`instant`)return d.scrollTop=d.calculatedTargetScrollTop,o();d.velocity=(n.damping*d.velocity+n.stiffness*d.scrollDifference)/n.mass,d.accumulated+=d.velocity*p,d.scrollTop+=d.accumulated,d.scrollTop!==l&&(d.accumulated=0)}return o()}return i>Date.now()?(a=d.calculatedTargetScrollTop,o()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?f({animation:Yt(s.current,s.current.resize),ignoreEscapes:r,duration:Math.max(0,i-Date.now())||void 0}):d.isAtBottom)});return e.then(e=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),e))};return e.wait!==!0&&(d.animation=void 0),d.animation?.behavior===n?d.animation.promise:o()},[l,c,d]),p=(0,Q.useCallback)(()=>{u(!0),l(!1)},[u,l]),m=(0,Q.useCallback)(({target:e})=>{if(e!==g.current)return;let{scrollTop:t,ignoreScrollToTop:n}=d,{lastScrollTop:r=t}=d;d.lastScrollTop=t,d.ignoreScrollToTop=void 0,n&&n>t&&(r=n),o(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||t===n)return;if(c()){u(!0),l(!1);return}let e=t>r,i=t<r;if(d.animation?.ignoreEscapes){d.scrollTop=r;return}i&&(u(!0),l(!1)),e&&u(!1),!d.escapedFromLock&&d.isNearBottom&&l(!0)},1)},[u,l,c,d]),h=(0,Q.useCallback)(({target:e,deltaY:t})=>{let n=e;for(;![`scroll`,`auto`].includes(getComputedStyle(n).overflow);){if(!n.parentElement)return;n=n.parentElement}n===g.current&&t<0&&g.current.scrollHeight>g.current.clientHeight&&!d.animation?.ignoreEscapes&&(u(!0),l(!1))},[u,l,d]),g=qt(e=>{g.current?.removeEventListener(`scroll`,m),g.current?.removeEventListener(`wheel`,h),e?.addEventListener(`scroll`,m,{passive:!0}),e?.addEventListener(`wheel`,h,{passive:!0})},[]),_=qt(e=>{if(d.resizeObserver?.disconnect(),d.resizeObserver=void 0,!e)return;let t;d.resizeObserver=new ResizeObserver(([e])=>{let{height:n}=e.contentRect,r=n-(t??n);if(d.resizeDifference=r,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),o(d.isNearBottom),r>=0){let e=Yt(s.current,t?s.current.resize:s.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:e===`instant`?void 0:Wt})}else d.isNearBottom&&(u(!1),l(!0));t=n,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===r&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(e)},[]);return{contentRef:_,scrollRef:g,scrollToBottom:f,stopScroll:p,isAtBottom:r||a,isNearBottom:a,escapedFromLock:t,state:d}};function qt(e,t){let n=(0,Q.useCallback)(t=>(n.current=t,e(t)),t);return n}var Jt=new Map;function Yt(...e){let t={...Vt},n=!1;for(let r of e){if(r===`instant`){n=!0;continue}typeof r==`object`&&(n=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let r=JSON.stringify(t);return Jt.has(r)||Jt.set(r,Object.freeze(t)),n?`instant`:Jt.get(r)}var Xt=60,Zt=8,Qt=1400;function $t(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function en(e,t){let n=[],r=e.parentElement;for(;r&&r!==t;)$t(r)&&n.push(r),r=r.parentElement;return n}function tn(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function nn(e,t){let n=e.querySelector(`[data-edit-ref="${CSS.escape(t)}"]`);if(n)return{el:n,level:`edit`};let r=t.replace(/-\d+$/,``),i=e.querySelector(`[data-tool-ref="${CSS.escape(r)}"]`);return i?{el:i,level:`card`}:null}function rn(e,t,n,r){let i=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-n;e.scrollTo({top:i,behavior:r?`smooth`:`auto`})}function an(e,t){let n=nn(e,t);if(!n)return()=>{};let{el:r,level:i}=n;for(let t of en(r,e))rn(t,r,Zt,!1);rn(e,r,Xt,!tn()),r.dataset.flash=i;let a=setTimeout(()=>{delete r.dataset.flash},Qt);return()=>{clearTimeout(a),delete r.dataset.flash}}var on=new Set([`Write`,`Edit`,`MultiEdit`,`NotebookEdit`]),sn={create:3,write:2,notebook:2,edit:1};function cn(e){return typeof e==`string`?e:``}function ln(e,t){let n=0,r=0;for(let i of rt(e,t))i.added?n+=i.count??0:i.removed&&(r+=i.count??0);return{added:n,removed:r}}function un(e){return e&&/created successfully/i.test(e)?`create`:`write`}function dn(e,t,n){switch(e){case`Write`:{let e=cn(t.file_path);return e?{filePath:e,op:un(n),fragments:[{oldStr:``,newStr:cn(t.content)}]}:null}case`Edit`:{let e=cn(t.file_path);return e?{filePath:e,op:`edit`,fragments:[{oldStr:cn(t.old_string),newStr:cn(t.new_string)}]}:null}case`MultiEdit`:{let e=cn(t.file_path);if(!e||!Array.isArray(t.edits))return null;let n=t.edits.filter(e=>!!e&&typeof e==`object`).map(e=>({oldStr:cn(e.old_string),newStr:cn(e.new_string)}));return n.length===0?null:{filePath:e,op:`edit`,fragments:n}}case`NotebookEdit`:{let e=cn(t.notebook_path)||cn(t.file_path);return e?{filePath:e,op:`notebook`,fragments:[{oldStr:``,newStr:cn(t.new_source)}]}:null}default:return null}}function fn(e,t){if(e){for(let n of e)if(n.type===`tool_result`&&n.toolUseId&&t.set(n.toolUseId,n.output??``),n.type===`tool_use`){let e=n.result;n.toolUseId&&e?.output!=null&&!t.has(n.toolUseId)&&t.set(n.toolUseId,e.output),fn(n.children,t)}}}function pn(e,t,n,r){if(e)for(let i of e){if(i.type!==`tool_use`||(i.children?.length&&pn(i.children,!0,n,r),!on.has(i.tool)))continue;let e=i.input&&typeof i.input==`object`?i.input:null;if(!e)continue;let a=dn(i.tool,e,i.toolUseId?r.get(i.toolUseId):void 0);if(!a)continue;let o=n.get(a.filePath);o||(o={filePath:a.filePath,op:a.op,editCount:0,linesAdded:0,linesRemoved:0,edits:[],viaSubagent:!1},n.set(a.filePath,o)),sn[a.op]>sn[o.op]&&(o.op=a.op),t&&(o.viaSubagent=!0),a.fragments.forEach((e,n)=>{let{added:r,removed:a}=ln(e.oldStr,e.newStr);o.linesAdded+=r,o.linesRemoved+=a,o.editCount+=1,o.edits.push({...e,toolUseId:i.toolUseId,editIndex:n,editRef:i.toolUseId?`${i.toolUseId}-${n}`:void 0,viaSubagent:t})})}}function mn(e){let t=new Map;for(let n of e)fn(n.events,t);let n=new Map;for(let r of e)pn(r.events,!1,n,t);return[...n.values()]}function hn(e,t){let n=[];for(let r=t;r>=0&&e[r]?.role===`assistant`;r--)n.unshift(e[r]);return n}var $=n();function gn(e){try{return new Date(e).toLocaleString()}catch{return``}}function _n({icon:e,label:t,title:n,onClick:r}){return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:n,"aria-label":t,className:`inline-flex items-center justify-center gap-1 rounded-md px-1.5 py-1 text-text-subtle hover:text-text-primary hover:bg-surface transition-colors`,children:[e,(0,$.jsx)(`span`,{children:t})]})}function vn({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsx)(_n,{icon:t?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(y,{className:`size-3.5`}),label:t?`Copied`:`Copy`,title:`Copy message to clipboard`,onClick:()=>{X(e),n(!0),setTimeout(()=>n(!1),1500)}})}function yn({timestamp:e,content:t,className:n,children:r}){return(0,$.jsxs)(`div`,{className:k(`flex items-center gap-0.5 flex-wrap text-xs text-text-subtle select-none`,n),children:[(0,$.jsx)(`time`,{title:gn(e),className:`pr-1 tabular-nums`,children:le(e)}),(0,$.jsx)(vn,{content:t}),r]})}function bn(e){let t=0,n=0;for(let r of e)t+=r.linesAdded,n+=r.linesRemoved;return{added:t,removed:n}}function xn({count:e,totals:t,open:n,onToggle:r,ref:i}){let a=`${e} file${e===1?``:`s`}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`mx-1.5 h-3.5 w-px bg-border-soft`}),(0,$.jsxs)(`button`,{ref:i,type:`button`,onClick:r,"aria-expanded":n,"aria-label":`${a} changed this turn, ${t.added} added, ${t.removed} removed`,className:k(`inline-flex items-center gap-[7px] rounded-full font-mono text-[11.5px]`,`px-3 min-h-11 md:min-h-0 md:px-[9px] md:py-[5px]`,`text-text-secondary transition-colors hover:bg-surface hover:text-text-primary`),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-[5px] shrink-0 rounded-full bg-primary`}),(0,$.jsx)(`span`,{children:a}),(0,$.jsxs)(`span`,{className:`flex items-center gap-[5px] tabular-nums`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,t.added]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t.removed]})]})]})]})}function Sn(e){if(!e)return!1;let t=e.closest(`[data-tab-pool-id]`)?.dataset.tabPoolId;if(!t)return e.offsetParent!==null;let{panels:n,focusedPanelId:r}=j.getState();return n[r]?.activeTabId===t}var Cn={create:{glyph:`A`,cls:`text-success`,label:`created`},write:{glyph:`W`,cls:`text-warning`,label:`overwritten`},notebook:{glyph:`N`,cls:`text-accent-2`,label:`notebook edited`},edit:{glyph:`·`,cls:`text-text-subtle`,label:`edited`}};function wn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}function Tn({added:e,removed:t,editCount:n,className:r}){return(0,$.jsxs)(`span`,{className:k(`flex items-center gap-[5px] tabular-nums`,r),children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),(0,$.jsxs)(`span`,{className:`text-error`,children:[`−`,t]}),n!=null&&n>1&&(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[`×`,n]})]})}function En({change:e,dense:t,selected:n,onClick:r}){let i=Cn[e.op],{base:a,dir:o}=wn(e.filePath),s=e.viaSubagent?`${i.label} · changed by a sub-agent`:i.label;return(0,$.jsxs)(`button`,{type:`button`,onClick:r,title:e.filePath,className:k(`grid w-full grid-cols-[16px_1fr_auto_10px] items-center gap-[10px] text-left font-mono`,`border-b border-border-soft hover:bg-surface transition-colors`,t?`min-h-[38px] px-2.5 py-[5px] text-xs`:`min-h-[52px] px-3 py-[7px] text-[12.5px]`,n&&`bg-surface shadow-[inset_2px_0_0_var(--accent)]`),children:[(0,$.jsx)(`span`,{"aria-label":s,title:s,className:k(`inline-flex size-4 items-center justify-center rounded bg-white/5 text-[9px] font-semibold`,i.cls,e.viaSubagent&&`bg-accent-2/20 ring-1 ring-inset ring-accent-2/35`),children:i.glyph}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-text-primary`,children:a}),o&&(0,$.jsx)(`span`,{className:`block overflow-hidden text-ellipsis whitespace-nowrap text-[10px] text-text-subtle [direction:rtl] text-left`,children:o})]}),(0,$.jsx)(Tn,{added:e.linesAdded,removed:e.linesRemoved,editCount:e.editCount,className:`text-[11px]`}),(0,$.jsx)(c,{className:`size-[11px] text-text-subtle`})]})}var Dn=(0,Q.lazy)(()=>re(()=>import(`./edit-diff-preview-xdDQvPhs.js`),__vite__mapDeps([0,1,2,3])));function On({change:e,onJump:t}){return(0,$.jsx)(`div`,{children:e.edits.map((n,r)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!n.editRef,onClick:()=>n.editRef&&t(n.editRef),className:`group flex min-h-11 w-full items-center gap-2 px-3 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface disabled:hover:bg-transparent`,children:[(0,$.jsxs)(`span`,{children:[`edit `,r+1,` of `,e.editCount]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border-soft`}),n.editRef&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 group-hover:text-primary`,children:[(0,$.jsx)(ce,{className:`size-3`}),`jump`]})]}),(0,$.jsx)(`div`,{className:`mx-3 mb-1`,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-4`}),children:(0,$.jsx)(Dn,{oldStr:n.oldStr,newStr:n.newStr,filePath:e.filePath})})})]},n.editRef??r))})}function kn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{base:e,dir:``}:{base:e.slice(t+1),dir:e.slice(0,t)}}var An=null;function jn(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function Mn({changes:e,onJump:t,onClose:n}){let[r,i]=(0,Q.useState)(0),a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useId)();(0,Q.useEffect)(()=>(An=s,o.current?.querySelector(`button`)?.focus(),()=>{An===s&&(An=null)}),[s]),(0,Q.useEffect)(()=>{let o=o=>{if(An===s&&Sn(a.current)&&!jn(document.activeElement)){if(o.key===`Escape`)o.preventDefault(),n();else if(o.key===`j`)o.preventDefault(),i(t=>Math.min(t+1,e.length-1));else if(o.key===`k`)o.preventDefault(),i(e=>Math.max(e-1,0));else if(o.key===`Enter`){let n=e[r]?.edits[0]?.editRef;n&&(o.preventDefault(),t(n))}}};return window.addEventListener(`keydown`,o),()=>window.removeEventListener(`keydown`,o)},[s,e,r,t,n]);let c=e[Math.min(r,e.length-1)];if(!c)return null;let{base:l,dir:u}=kn(c.filePath);return(0,$.jsx)(`div`,{ref:a,className:`mt-0.5 overflow-hidden rounded-[10px] border border-border-soft bg-bg`,children:(0,$.jsxs)(`div`,{className:`grid h-[356px] grid-cols-[294px_1fr] grid-rows-[minmax(0,1fr)] bg-surface-elevated`,children:[(0,$.jsxs)(`div`,{ref:o,className:`min-h-0 overflow-y-auto border-r border-border-soft`,children:[e.map((e,t)=>(0,$.jsx)(En,{change:e,dense:!0,selected:t===r,onClick:()=>i(t)},e.filePath)),(0,$.jsx)(`p`,{className:`px-2.5 pt-2 pb-2.5 font-mono text-[10px] text-text-subtle`,children:`j / k to move · enter to jump`})]}),(0,$.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border-soft bg-surface-elevated py-[5px] pl-2.5 pr-2`,children:[(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-text-primary`,children:l}),u&&(0,$.jsx)(`span`,{title:c.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:u}),(0,$.jsx)(Tn,{added:c.linesAdded,removed:c.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void X(c.filePath),className:`shrink-0 rounded-md px-1.5 py-1 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy path`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close change tray`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:(0,$.jsx)(te,{className:`size-3.5`})})]}),(0,$.jsx)(On,{change:c,onJump:t})]})]})})}function Nn(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?e:e.slice(t+1)}function Pn({label:e,onClick:t,children:n}){return(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:n})}function Fn({changes:e,totals:t,open:n,onClose:r,onJump:i}){let[a,o]=(0,Q.useState)(null),s=a==null?null:e[a],c=(0,Q.useRef)(null),l=()=>{o(null),r()},u=e=>{l(),i(e)};return(0,Q.useEffect)(()=>{if(!n)return;let e=c.current,t=()=>Array.from(e?.querySelectorAll(`button:not([disabled])`)??[]);t()[0]?.focus();let r=e=>{if(e.key===`Escape`){e.preventDefault(),l();return}if(e.key!==`Tab`)return;let n=t();if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[n,a]),(0,$.jsx)(F,{open:n,onClose:l,className:`flex max-h-[85%] flex-col rounded-t-[14px] motion-reduce:animate-none`,children:(0,$.jsx)(`div`,{ref:c,className:`flex min-h-0 flex-1 flex-col`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft px-1 pb-1`,children:[(0,$.jsx)(Pn,{label:`Back to file list`,onClick:()=>o(null),children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:Nn(s.filePath)}),(0,$.jsx)(Tn,{added:s.linesAdded,removed:s.linesRemoved,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Pn,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border-soft py-1.5 pl-3 pr-2`,children:[(0,$.jsx)(`span`,{title:s.filePath,className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[10.5px] text-text-subtle [direction:rtl] text-left`,children:s.filePath}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>void X(s.filePath),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-text-primary`,children:`copy`}),s.edits[0]?.editRef&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(s.edits[0].editRef),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2.5 font-mono text-[10px] text-text-subtle transition-colors hover:bg-surface hover:text-primary`,children:[(0,$.jsx)(ce,{className:`size-3`}),`card`]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(On,{change:s,onJump:u})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border-soft px-3 pb-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-text-primary`,children:[`Changed this turn · `,e.length,` file`,e.length===1?``:`s`]}),(0,$.jsx)(Tn,{added:t.added,removed:t.removed,className:`shrink-0 font-mono text-[11px]`}),(0,$.jsx)(Pn,{label:`Close`,onClick:l,children:(0,$.jsx)(te,{className:`size-4`})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:e.map((e,t)=>(0,$.jsx)(En,{change:e,onClick:()=>o(t)},e.filePath))})]})})})}function In({timestamp:e,content:t,changes:n,onJumpToEdit:r}){let[i,a]=(0,Q.useState)(!1),o=oe(),s=(0,Q.useRef)(null),c=()=>{a(!1),s.current?.focus()},l=(0,$.jsx)(yn,{timestamp:e,content:t,className:`-mt-1.5`,children:n&&n.length>0&&(0,$.jsx)(xn,{ref:s,count:n.length,totals:bn(n),open:i,onToggle:()=>i?c():a(!0)})});return!n||n.length===0?l:(0,$.jsxs)($.Fragment,{children:[l,o?(0,$.jsx)(Fn,{changes:n,totals:bn(n),open:i,onClose:c,onJump:r??(()=>{})}):i&&(0,$.jsx)(Mn,{changes:n,onJump:e=>{a(!1),r?.(e)},onClose:c})]})}function Ln(e){return e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens}function Rn(e){return e.inputTokens+e.cacheWriteTokens}var zn=.5,Bn=.9,Vn={cache_expired:`the session's prompt cache had already lapsed, so PPM released its subprocess`,idle_timeout:`the session sat idle with no tab open long enough for PPM to release its subprocess`,warm_idle_cap:`too many idle sessions were holding a subprocess, so this one was released early`,tab_closed:`PPM shut the session's subprocess down when the last tab disconnected`,set_model:`the model was changed, which restarts the session`,stream_ended:`the session's subprocess had already exited`,resume:`the session was resumed on a new subprocess`};function Hn(e){let t=Rn(e),n=Ln(e);if(!e.coldStart||n<2e4)return{level:`ok`,wastedTokens:t,reason:``};let r=e.cacheHitRate<zn?`bad`:e.cacheHitRate<Bn?`warn`:`ok`;if(r===`ok`)return{level:r,wastedTokens:t,reason:``};let i=e.coldReason?Vn[e.coldReason]??`the session restarted (${e.coldReason})`:null;return{level:r,wastedTokens:t,reason:i?`${Kn(t)} of this session's transcript was re-sent uncached because ${i}.`:`${Kn(t)} of this session's transcript was re-sent uncached.`}}var Un=.1,Wn=1.25;function Gn(e){let t=Ln(e);if(t===0)return 1;let n=e.inputTokens+e.cacheWriteTokens*Wn+e.cacheReadTokens*Un,r=t*Un;return r>0?Math.max(1,n/r):1}function Kn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function qn({usage:e}){let[t,n]=(0,Q.useState)(!1),r=Hn(e);if(r.level===`ok`)return null;let i=Gn(e),a=Ln(e),o=Math.round(e.cacheHitRate*100),c=r.level===`bad`;return(0,$.jsxs)(`div`,{className:`rounded-md border px-2.5 py-2 text-[11px] ${c?`border-warning/40 bg-warning/10`:`border-border bg-surface`}`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex w-full items-start gap-2 py-1 text-left text-text-secondary transition-colors hover:text-text-primary`,children:[(0,$.jsx)(B,{className:`mt-px size-3.5 shrink-0 ${c?`text-warning`:`text-text-subtle`}`}),(0,$.jsxs)(`span`,{className:`flex-1`,children:[`Costly turn — `,o,`% of a `,Kn(a),`-token transcript came from cache, so it cost about`,` `,(0,$.jsxs)(`strong`,{className:`font-semibold`,children:[i.toFixed(1),`x`]}),` a fully cached turn.`]}),(0,$.jsx)(s,{className:`mt-px size-3.5 shrink-0 transition-transform ${t?`rotate-180`:``}`})]}),t&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 border-t border-border pt-2`,children:[r.reason&&(0,$.jsx)(`p`,{className:`text-text-secondary`,children:r.reason}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 font-mono text-[10.5px] text-text-subtle`,children:[(0,$.jsx)(Jn,{label:`From cache`,value:`${Kn(e.cacheReadTokens)} (${o}%)`}),(0,$.jsx)(Jn,{label:`Written to cache`,value:Kn(e.cacheWriteTokens)}),(0,$.jsx)(Jn,{label:`Fresh input`,value:Kn(e.inputTokens)}),(0,$.jsx)(Jn,{label:`Output`,value:Kn(e.outputTokens)}),(0,$.jsx)(Jn,{label:`Model`,value:e.model||`unknown`}),(0,$.jsx)(Jn,{label:`Cost`,value:`$${e.costUsd.toFixed(4)}`})]}),(0,$.jsx)(`p`,{className:`text-text-subtle`,children:`A turn stays cached while the session keeps running. Closing the last tab of an idle session, switching model, or a retry all restart it, and the next turn re-sends the transcript at full price.`})]})]})}function Jn({label:e,value:t}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`dt`,{className:`truncate`,children:e}),(0,$.jsx)(`dd`,{className:`truncate text-right text-text-secondary`,children:t})]})}function Yn(e,t,n,r){let[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{if(!n||!e||!t){a([]);return}let r=!1;return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{E.get(`/api/project/${encodeURIComponent(e)}/chat/sessions/${encodeURIComponent(t)}/tasks`).then(e=>{r||a(e)}).catch(()=>{})},300),()=>{r=!0,o.current&&clearTimeout(o.current)}},[e,t,n,r]),i}var Xn=new Set([`TaskCreate`,`TaskUpdate`,`TaskStop`]);function Zn(e){let t=0;for(let n of e)if(n.events)for(let e of n.events)e.type===`tool_use`&&Xn.has(e.tool)&&t++;return t}var Qn={completed:{icon:`✓`,cls:`text-success`},in_progress:{icon:`▶`,cls:`text-warning`},stopped:{icon:`■`,cls:`text-text-subtle`},pending:{icon:`○`,cls:`text-text-subtle`}};function $n({projectName:e,sessionId:t,messages:n}){let r=(0,Q.useMemo)(()=>Zn(n),[n]),i=Yn(e,t,r>0,r),[a,o]=(0,Q.useState)(!0);if(i.length===0||i.every(e=>e.status===`completed`||e.status===`stopped`))return null;let l=i.filter(e=>e.status===`completed`).length,u=i.length,f=u?Math.round(l/u*100):0;return(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-surface/60 backdrop-blur-sm`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex items-center gap-2 w-full px-3 min-h-11 text-left text-xs hover:bg-surface transition-colors`,children:[a?(0,$.jsx)(c,{className:`size-3.5 shrink-0`}):(0,$.jsx)(s,{className:`size-3.5 shrink-0`}),(0,$.jsx)(d,{className:`size-3.5 shrink-0 text-text-secondary`}),(0,$.jsx)(`span`,{className:`text-text-primary font-medium`,children:`Tasks`}),(0,$.jsxs)(`span`,{className:`text-text-subtle`,children:[l,`/`,u,` done`]}),(0,$.jsx)(`span`,{className:`ml-auto h-1 w-16 rounded-full bg-border overflow-hidden shrink-0`,children:(0,$.jsx)(`span`,{className:`block h-full bg-success/70`,style:{width:`${f}%`}})})]}),!a&&(0,$.jsx)(`ul`,{className:`px-3 pb-2 space-y-0.5 max-h-48 overflow-y-auto`,children:i.map(e=>(0,$.jsx)(er,{task:e},e.id))})]})}function er({task:e}){let t=Qn[e.status]??Qn.pending,n=e.status===`in_progress`;return(0,$.jsxs)(`li`,{className:`flex items-start gap-1.5 text-xs rounded px-1 ${n?`bg-warning/10`:``}`,children:[(0,$.jsx)(`span`,{className:`shrink-0 mt-0.5 ${t.cls}`,children:t.icon}),(0,$.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:n?`text-text-primary font-medium`:`text-text-secondary`,children:e.subject||(0,$.jsxs)(`span`,{className:`text-text-subtle italic`,children:[`#`,e.id,` (no title)`]})})]})}var tr=/read the full transcript at:\s*(\S+\.jsonl)/i;function nr(e){return e.match(tr)?.[1]?.trim()??null}var rr=class extends Q.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:this.props.fallbackContent?(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap break-words text-text-primary opacity-80`,children:this.props.fallbackContent}):null:this.props.children}};function ir({projectName:e,onSelectSession:t}){return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(i,{className:`size-10 text-text-subtle`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Send a message to start a new conversation`})]}),(0,$.jsx)(Te,{projectName:e,onSelectSession:t,className:`w-full px-4`})]})}var ar=3200,or=1e3,sr={hasAbove:!1,atBottom:!0,idx:0,total:0};function cr({scrollElement:e,userIndices:t,scrollToBottom:n}){let r=oe(),[i,a]=(0,Q.useState)(sr),[o,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0),f=(0,Q.useRef)(ar),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(!1),_=(e,t,n)=>t.getBoundingClientRect().top-n+e.scrollTop,v=(0,Q.useCallback)(e=>Array.from(e.querySelectorAll(`[data-msg-index]`)).filter(e=>t.includes(Number(e.dataset.msgIndex))),[t]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=0,r=()=>{let e=t.scrollTop,n=t.getBoundingClientRect().top,r=v(t).map(e=>_(t,e,n)),i=0;for(let t=0;t<r.length;t++)r[t]<=e+12&&(i=t+1);let o={hasAbove:r.some(t=>t<e-4),atBottom:t.scrollHeight-e-t.clientHeight<8,idx:i,total:r.length};a(e=>e.hasAbove===o.hasAbove&&e.atBottom===o.atBottom&&e.idx===o.idx&&e.total===o.total?e:o)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};r(),t.addEventListener(`scroll`,i,{passive:!0});let o=new ResizeObserver(i);return o.observe(t),()=>{n&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,i),o.disconnect()}},[e,v]),(0,Q.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>c(!1),f.current);return()=>clearTimeout(e)},[o,i.idx,u]),(0,Q.useEffect)(()=>{if(!o||!g.current)return;g.current=!1;let e=p.current;(e?.querySelector(`button:not(:disabled)`)??e)?.focus()},[o]),(0,Q.useEffect)(()=>{o||!h.current||(h.current=!1,m.current?.focus())},[o]);let y=(0,Q.useCallback)(()=>{f.current=ar,d(e=>e+1)},[]),b=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let n=t.scrollTop,r=t.getBoundingClientRect().top,i;for(let e of v(t)){let a=_(t,e,r);if(a<n-4)i=a;else break}i!=null&&t.scrollTo({top:i,behavior:`auto`}),y()},[e,v,y]),x=(0,Q.useCallback)(()=>{let t=e;if(!t)return;let r=t.scrollTop,i=t.getBoundingClientRect().top,a=v(t).map(e=>_(t,e,i)).find(e=>e>r+4);a==null?n({animation:`instant`}):t.scrollTo({top:a,behavior:`auto`}),y()},[e,v,n,y]),S=(0,Q.useCallback)(()=>{n({animation:`instant`}),y()},[n,y]);(0,Q.useEffect)(()=>{let t=e;if(!t)return;let n=e=>()=>{Sn(t)&&(e(),f.current=or,c(!0))},r=n(b),i=n(x);return window.addEventListener(`chat-nav-prev`,r),window.addEventListener(`chat-nav-next`,i),()=>{window.removeEventListener(`chat-nav-prev`,r),window.removeEventListener(`chat-nav-next`,i)}},[e,b,x]);let C=k(`w-[34px] flex items-center justify-center rounded-[9px] text-text-secondary`,`motion-safe:transition-colors hover:bg-surface-elevated hover:text-foreground`,`disabled:opacity-30 disabled:cursor-default disabled:hover:bg-transparent disabled:hover:text-text-secondary`,r?`h-9`:`h-[30px]`);return(0,$.jsx)(`div`,{className:`absolute bottom-3 right-2.5 z-10 flex flex-col items-end gap-1.5`,children:o?(0,$.jsxs)(`div`,{ref:p,tabIndex:-1,className:`flex flex-col p-[3px] rounded-xl border border-border bg-surface-elevated/95 backdrop-blur-[8px] shadow-lg outline-none`,onFocus:()=>{h.current=!0},onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,$.jsx)(`button`,{type:`button`,onClick:b,disabled:!i.hasAbove,"aria-label":`Jump to previous message`,className:C,children:(0,$.jsx)(l,{className:`size-[15px]`})}),(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-medium text-text-subtle text-center py-px`,"aria-label":`Message ${i.idx||1} of ${i.total}`,children:i.total?`${i.idx||1}/${i.total}`:`0/0`}),(0,$.jsx)(`button`,{type:`button`,onClick:x,disabled:i.atBottom,"aria-label":`Jump to next message`,className:C,children:(0,$.jsx)(s,{className:`size-[15px]`})}),(0,$.jsx)(`button`,{type:`button`,onClick:S,disabled:i.atBottom,"aria-label":`Jump to latest`,className:C,children:(0,$.jsx)(ht,{className:`size-[13px]`})})]}):(0,$.jsx)(`button`,{ref:m,type:`button`,onClick:()=>{f.current=ar,g.current=!0,c(!0)},"aria-label":`Navigate messages`,"aria-expanded":!1,title:`Navigate messages`,className:k(`group flex items-center justify-center`,r?`size-11`:`size-[30px]`),children:(0,$.jsx)(`span`,{className:k(`flex items-center justify-center rounded-full border border-border bg-surface-elevated/55 backdrop-blur-[6px] text-text-subtle`,`motion-safe:transition-colors group-hover:bg-surface-elevated group-hover:text-foreground`,r?`size-9`:`size-[30px]`),children:(0,$.jsx)(ve,{className:`size-[15px]`})})})})}function lr({group:e,onNavigate:t,disabled:n}){if(!e||e.ids.length<2)return null;let{ids:r,currentIndex:i}=e,a=e=>{let i=r[e];i&&!n&&t(i)};return(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-xs text-text-subtle select-none`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i-1),disabled:n||i<=0,"aria-label":`Previous version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(G,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[i+1,`/`,r.length]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>a(i+1),disabled:n||i>=r.length-1,"aria-label":`Next version`,className:`flex items-center justify-center rounded p-0.5 hover:text-text-primary disabled:opacity-30 disabled:cursor-default`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})}function ur(e){let[t,n]=(0,Q.useState)({}),[r,i]=(0,Q.useState)({}),[a,o]=(0,Q.useState)(0),s=(0,Q.useCallback)((e,t)=>{n(n=>({...n,[e]:[t]})),i(t=>({...t,[e]:``}))},[]),c=(0,Q.useCallback)((e,t)=>{n(n=>{let r=n[e]||[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},[]),l=(0,Q.useCallback)((e,t)=>{i(n=>({...n,[e]:t})),t&&n(t=>({...t,[e]:[]}))},[]),u=(0,Q.useCallback)(e=>(t[e]?.length??0)>0||(r[e]?.trim().length??0)>0,[t,r]);return{answers:t,customInputs:r,activeTab:a,setActiveTab:o,handleSingleSelect:s,handleMultiSelect:c,handleCustomInput:l,hasAnswer:u,allAnswered:(0,Q.useMemo)(()=>e.every((e,t)=>u(t)),[e,u]),getFinalAnswer:(0,Q.useCallback)(e=>r[e]?.trim()||(t[e]??[]).join(`, `),[t,r]),goToNextTab:(0,Q.useCallback)(()=>o(t=>Math.min(t+1,e.length-1)),[e.length]),goToPrevTab:(0,Q.useCallback)(()=>o(e=>Math.max(e-1,0)),[])}}function dr(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>n(0),[e.activeTab]),(0,Q.useEffect)(()=>{if(!e.enabled)return;let i=r=>{let i=e.customInputRef.current,a=!!i&&i.ownerDocument.activeElement===i;if(!a&&r.key>=`1`&&r.key<=`9`){r.preventDefault();let t=parseInt(r.key)-1;t<e.totalOptions-1&&(n(t),e.onSelectOption(t));return}if(!a&&(r.key===`o`||r.key===`O`||r.key===`0`)){r.preventDefault(),e.customInputRef.current?.focus(),n(e.totalOptions-1);return}if(r.key===`Tab`&&e.questions.length>1){r.preventDefault(),r.shiftKey?e.goToPrevTab():e.goToNextTab();return}if(!a){if(r.key===`ArrowLeft`){r.preventDefault(),e.goToPrevTab();return}if(r.key===`ArrowRight`){r.preventDefault(),e.goToNextTab();return}if(r.key===`ArrowUp`){r.preventDefault(),n(e=>Math.max(0,e-1));return}if(r.key===`ArrowDown`){r.preventDefault(),n(t=>Math.min(e.totalOptions-1,t+1));return}if(r.key===` `){r.preventDefault(),e.onSelectOption(t);return}}if(r.key===`Enter`){r.preventDefault(),e.allAnswered?e.onSubmit():e.hasAnswer(e.activeTab)&&e.goToNextTab();return}r.key===`Escape`&&a&&e.customInputRef.current?.blur()},a=r.current;return a&&(a.addEventListener(`keydown`,i),a.setAttribute(`tabindex`,`0`),a.contains(a.ownerDocument.activeElement)||a.focus()),()=>{a?.removeEventListener(`keydown`,i)}},[e,t]),{focusedOption:t,setFocusedOption:n,containerRef:r}}function fr({questions:e,onSubmit:t,onSkip:n}){let r=(0,Q.useRef)(null),i=ur(e),a=e[i.activeTab],o=a?a.options.length+1:0,s=e.length>1,c=(0,Q.useCallback)(()=>{if(!i.allAnswered)return;let n={};e.forEach((e,t)=>{n[e.question]=i.getFinalAnswer(t)}),t(n)},[i.allAnswered,i.getFinalAnswer,e,t]),l=(0,Q.useCallback)(e=>{if(!(!a||e<0))if(e<a.options.length){let t=a.options[e]?.label;if(!t)return;a.multiSelect?i.handleMultiSelect(i.activeTab,t):i.handleSingleSelect(i.activeTab,t)}else e===a.options.length&&r.current?.focus()},[a,i]),u=dr({questions:e,activeTab:i.activeTab,totalOptions:o,allAnswered:i.allAnswered,hasAnswer:i.hasAnswer,onSelectOption:l,goToNextTab:i.goToNextTab,goToPrevTab:i.goToPrevTab,onSubmit:c,customInputRef:r,enabled:!0}),d=(0,Q.useCallback)(e=>{l(e),u.setFocusedOption(e)},[l,u.setFocusedOption]);return(0,$.jsxs)(`div`,{ref:u.containerRef,className:`rounded-lg border-2 border-primary/30 bg-primary/5 p-3 space-y-3 outline-none animate-in slide-in-from-bottom-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm font-medium text-text-primary`,children:[(0,$.jsxs)(`span`,{children:[`AI has `,s?`${e.length} questions`:`a question`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-text-secondary font-normal`,children:[s?`←→ tabs · `:``,`↑↓ options · 1-`,Math.min(o-1,9),` select · Enter submit`]})]}),s&&(0,$.jsx)(`div`,{className:`flex gap-1 p-1 bg-background rounded-md overflow-x-auto border border-border`,children:e.map((e,t)=>(0,$.jsxs)(`button`,{className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs whitespace-nowrap transition-all ${i.activeTab===t?`bg-primary text-primary-foreground`:i.hasAnswer(t)?`text-primary bg-transparent`:`text-text-secondary hover:bg-surface-elevated`}`,onClick:()=>{i.setActiveTab(t),u.setFocusedOption(0)},tabIndex:-1,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4 h-4 rounded-full text-[10px] font-semibold ${i.activeTab===t?`bg-white/20`:i.hasAnswer(t)?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:i.hasAnswer(t)?`✓`:t+1}),(0,$.jsx)(`span`,{className:`max-w-[100px] overflow-hidden text-ellipsis`,children:e.header||`Q${t+1}`})]},t))}),a&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[!s&&a.header&&(0,$.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-text-secondary`,children:a.header}),(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:a.question}),a.multiSelect&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-secondary`,children:`Select multiple`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a.options.map((e,t)=>{let n=(i.answers[i.activeTab]||[]).includes(e.label),r=u.focusedOption===t;return(0,$.jsxs)(`div`,{role:`button`,onClick:()=>d(t),className:`text-left flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border transition-all cursor-pointer select-text ${n?`border-primary bg-primary/10 text-text-primary`:`border-border bg-background text-text-secondary hover:border-primary/40 hover:bg-primary/5`} ${r?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded text-[10px] font-semibold shrink-0 mt-px ${n?`bg-primary/20 text-primary`:`bg-surface-elevated text-text-secondary`}`,children:t+1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 flex-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.label}),e.description&&(0,$.jsx)(`span`,{className:`text-[11px] text-text-secondary`,children:e.description})]})]},t)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded px-2.5 py-2 text-xs border border-dashed transition-all border-border bg-transparent ${u.focusedOption===o-1?`ring-2 ring-primary/40 ring-offset-1 ring-offset-background`:``}`,children:[(0,$.jsx)(`span`,{className:`flex items-center justify-center w-4.5 h-4.5 rounded bg-surface-elevated text-text-secondary text-[10px] font-semibold shrink-0 mt-px`,children:`O`}),(0,$.jsx)(`input`,{ref:r,type:`text`,className:`flex-1 px-2 py-1 text-xs bg-surface border border-border rounded text-text-primary outline-none placeholder:text-text-subtle focus:border-primary`,placeholder:`Other (press O to type)...`,value:i.customInputs[i.activeTab]||``,onChange:e=>i.handleCustomInput(i.activeTab,e.target.value),onFocus:()=>u.setFocusedOption(o-1)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToPrevTab,disabled:i.activeTab===0,tabIndex:-1,children:`← Prev`}),(0,$.jsx)(`button`,{className:`px-3 py-1.5 text-xs rounded border border-border bg-background text-text-primary hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,onClick:i.goToNextTab,disabled:i.activeTab===e.length-1,tabIndex:-1,children:`Next →`})]}),(0,$.jsx)(`button`,{onClick:n,className:`px-4 py-1.5 rounded border border-border bg-background text-text-secondary text-xs hover:bg-surface-elevated transition-colors`,tabIndex:-1,children:`Skip`}),(0,$.jsxs)(`button`,{onClick:c,disabled:!i.allAnswered,className:`px-4 py-1.5 rounded bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,tabIndex:-1,children:[`Submit `,i.allAnswered?`✓`:`(${e.filter((e,t)=>i.hasAnswer(t)).length}/${e.length})`]})]})]})}var pr={"system-reminder":`Context`,claudeMd:`CLAUDE.md`,gitStatus:`Git Status`,currentDate:`Date`,fast_mode_info:`Fast Mode`,"available-deferred-tools":`Tools`,"task-notification":`Task Result`,environment_details:`Environment`,"local-command-caveat":`System`};function mr(e){let t=[],n=/<(system-reminder|available-deferred-tools|antml:[\w-]+|fast_mode_info|claudeMd|gitStatus|currentDate|task-notification|environment_details|local-command-caveat)[^>]*>([\s\S]*?)<\/\1>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1];t.push({name:e,label:pr[e]??e.replace(/^antml:/,``).replace(/-/g,` `),content:r[2].trim()})}return{cleanText:e.replace(n,``).trim(),tags:t}}function hr(e){let t=e.match(/<command-name>([\s\S]*?)<\/command-name>/);if(!t)return{command:null,cleanText:e};let n=t[1].trim(),r=e.match(/<command-args>([\s\S]*?)<\/command-args>/)?.[1]?.trim()||void 0,i=e.replace(/<command-name>[\s\S]*?<\/command-name>/g,``).replace(/<command-message>[\s\S]*?<\/command-message>/g,``).replace(/<command-args>[\s\S]*?<\/command-args>/g,``).trim();return{command:{name:n,args:r},cleanText:i}}function gr(e){let t=e.match(/^Use the (\S+) agent to\s?/);return t?{agent:t[1],cleanText:e.slice(t[0].length)}:{agent:null,cleanText:e}}function _r(e){let t=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g.exec(e);return t?{idePath:t[1].match(/opened the file (.+?) in the IDE/)?.[1]?.trim()??null,cleanText:e.replace(/<ide_opened_file>[\s\S]*?<\/ide_opened_file>/g,``).trim()}:{idePath:null,cleanText:e}}function vr(e){let t=[],n=e;for(;;){let e=n.match(/^\[Attached image \(contents included in this message\): (.+?)\]\n*/);if(e){t.push(e[1]),n=n.slice(e[0].length);continue}break}if(t.length>0){let e=vr(n);return{files:[...t,...e.files],text:e.text}}let r=n.match(/^\[Attached file: (.+?)\]\n*/);if(r)return{files:[r[1]],text:n.slice(r[0].length)};let i=n.match(/^\[Attached files:\n([\s\S]+?)\]\n*/);return i?{files:i[1].split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean),text:n.slice(i[0].length)}:{files:[],text:n}}function yr(e){let t=[],n=e,r=/^```(?:bash|sh|shell|zsh)\n([\s\S]*?)\n```\s*(?:\n\n?)?/,i;for(;(i=n.match(r))!==null;)t.push(i[1]),n=n.slice(i[0].length);return{blocks:t,remainingText:n.trim()}}function br(e){let{idePath:t,cleanText:n}=_r(e),{blocks:r,remainingText:i}=yr(n),a=vr(i),{cleanText:o,tags:s}=mr(a.text.replace(/<local-command-(?:stdout|stderr)>([\s\S]*?)<\/local-command-(?:stdout|stderr)>/g,`$1`)),{command:c,cleanText:l}=hr(o),{agent:u,cleanText:d}=gr(l),f=c?.args?d?`${c.args}\n\n${d}`:c.args:d;return{files:a.files,text:f,body:d,tags:s,command:c,terminalBlocks:r,idePath:t,agent:u}}function xr(e){let{agent:t,body:n,command:r}=br(e);if(!r)return{agent:t,text:n};let i=`/${r.name.replace(/^\/+/,``)}${r.args?` ${r.args}`:``}`;return{agent:t,text:n?`${i}\n\n${n}`:i}}var Sr=re(()=>import(`./markdown-renderer-Bthd7hxl.js`),__vite__mapDeps([4,5,1,6,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49])),Cr=(0,Q.lazy)(()=>Sr.then(e=>({default:e.MarkdownRenderer})));function wr({messages:e,messagesLoading:t,keepStaleWhileLoading:n,pendingApproval:r,onApprovalResponse:a,isStreaming:o,phase:s,onSelectSession:c,connectingElapsed:l,statusMessage:u,compactStatus:d,projectName:f,onFork:m,onEdit:h,editingMsgId:g,sessionId:_,providerId:v,onNavigateVersion:y,versionMap:b,bashPartialOutput:x,onExpandCompact:S,isCompactExpanded:C,onDismissMessage:ee,onClearErrors:te}){let{scrollRef:T,contentRef:E,scrollToBottom:D,stopScroll:ne,isAtBottom:re}=Kt({initial:`instant`,resize:`instant`}),O=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.content&&e.content.trim().length>0,n=e.events&&e.events.length>0;return e.role===`user`?t:t||n}),[e]),k=!!r||o,[A,ie]=(0,Q.useState)(null),j=(0,Q.useCallback)(e=>{T(e),ie(e)},[T]),M=(0,Q.useRef)(new Map),ae=(0,Q.useMemo)(()=>{let e=M.current,t=new Map;for(let n=0;n<O.length;n++){let r=O[n];if(r.role!==`assistant`||O[n+1]?.role===`assistant`)continue;let i=`${r.id}:${r.events?.length??0}`,a=e.get(i);a||(a=mn(hn(O,n)),e.set(i,a)),a.length>0&&t.set(n,a)}return t},[O]),oe=(0,Q.useRef)(null),N=(0,Q.useCallback)(e=>{A&&(oe.current?.(),oe.current=an(A,e))},[A]);(0,Q.useEffect)(()=>()=>oe.current?.(),[]);let P=(0,Q.useRef)(null);(0,Q.useLayoutEffect)(()=>{let e=A;e&&P.current!=null&&(e.scrollTop=e.scrollHeight-P.current,P.current=null)},[O.length,A]),(0,Q.useLayoutEffect)(()=>{A&&D({animation:`instant`})},[_,A]);let F=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{A&&A.clientHeight>0&&(F.current=re)},[re,A]),(0,Q.useEffect)(()=>{let e=A;if(!e)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=t===0&&n>0;t=n,r&&!F.current&&ne()});return n.observe(e),()=>n.disconnect()},[A,ne]);let se=(0,Q.useCallback)((e,t)=>{m?.(e,t)},[m]),I=(0,Q.useCallback)((e,t,n)=>{h?.(e,t,n)},[h]),ce=(0,Q.useCallback)(e=>{ee?.(e)},[ee]),L=(0,Q.useMemo)(()=>O.reduce((e,t)=>t.role===`system`?e+1:e,0),[O]),R=(0,Q.useMemo)(()=>O.reduce((e,t,n)=>(t.role===`user`&&e.push(n),e),[]),[O]),z=(0,Q.useCallback)(()=>{if(!S||!C)return null;for(let e of O){if(C(e.id))continue;let t=nr(e.content||``);if(t)return{id:e.id,jsonlPath:t};if(e.events){for(let t of e.events)if(t.type===`text`){let n=nr(t.content||``);if(n)return{id:e.id,jsonlPath:n}}}}return null},[O,S,C])(),le=!!z,[ue,de]=(0,Q.useState)(!1),B=(0,Q.useCallback)(async()=>{if(!z||!S||ue)return;let e=A;P.current=e?e.scrollHeight-e.scrollTop:null,de(!0);try{await S(z.id,z.jsonlPath)}finally{de(!1)}},[z,S,ue,A]);return(0,Q.useEffect)(()=>{let e=A;if(!e||!le)return;let t=()=>{e.scrollTop<200&&!ue&&B()};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[A,le,ue,B]),t&&(!n||e.length===0)?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,$.jsx)(i,{className:`size-10 text-text-subtle animate-pulse`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Loading messages...`})]}):e.length===0&&!o?(0,$.jsx)(ir,{projectName:f||``,onSelectSession:c||(()=>{})}):(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,$.jsx)($n,{projectName:f,sessionId:_,messages:e}),L>1&&te&&(0,$.jsx)(`div`,{className:`absolute top-2 left-0 right-0 z-20 flex justify-center pointer-events-none`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:te,className:`pointer-events-auto flex items-center gap-1.5 rounded-full bg-error/15 border border-error/25 px-3 py-1 text-xs text-error hover:bg-error/25 shadow-md backdrop-blur-sm`,children:[(0,$.jsx)(p,{className:`size-3.5`}),`Clear all errors (`,L,`)`]})}),ue&&(0,$.jsxs)(`div`,{className:`absolute top-2 left-0 right-0 z-10 flex items-center justify-center gap-1.5 text-xs text-text-secondary pointer-events-none`,children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),`Loading previous conversation...`]}),(0,$.jsx)(`div`,{ref:j,[et]:``,className:`flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none]`,style:{WebkitOverflowScrolling:`touch`,overscrollBehavior:`contain`},children:(0,$.jsxs)(`div`,{ref:E,className:`w-full`,children:[O.map((e,t)=>{let n=t>0?O[t-1]:void 0,r=e.role===`user`?O.slice(0,t+1).reduce((e,t)=>e+(t.role===`user`?1:0),0):0,i=r?b?.[r]:void 0,a=e.role===`user`&&g!=null&&e.id===g,s=O[t+1],c=e.role===`assistant`&&s?.role!==`assistant`,l;if(c){let e=[];for(let n=t;n>=0&&O[n].role===`assistant`;n--){let t=Tr(O[n]);t&&e.unshift(t)}l=e.join(`
|
|
4
4
|
|
|
5
5
|
`)}return(0,$.jsx)(`div`,{"data-msg-index":t,className:`px-4 pt-4 select-none`,children:(0,$.jsx)(rr,{fallbackContent:e.content,children:(0,$.jsx)(Er,{message:e,isStreaming:o&&e.id.startsWith(`streaming-`),isLastAssistantInTurn:c,turnCopyText:l,turnChanges:c?ae.get(t):void 0,onJumpToEdit:N,projectName:f,onFork:e.role===`user`&&m?se:void 0,onEdit:e.role===`user`&&h?I:void 0,isEditing:a,onDismiss:e.role===`system`&&ee?ce:void 0,prevMsgId:n?.sdkUuid??n?.id,sessionId:_,providerId:v,versionGroup:i,onNavigateVersion:y,versionNavDisabled:o,bashPartialOutput:x})})},e.id)}),k&&(0,$.jsxs)(`div`,{className:`px-4 pt-4 pb-4 space-y-4 select-none`,children:[r&&(r.tool===`AskUserQuestion`?(0,$.jsx)(Zr,{approval:r,onRespond:a}):(0,$.jsx)(Xr,{approval:r,onRespond:a})),o&&(0,$.jsx)(Kr,{lastMessage:e[e.length-1],phase:s,elapsed:l,statusMessage:d===`compacting`?`Compacting messages...`:u})]})]})}),(0,$.jsx)(cr,{scrollElement:A,userIndices:R,scrollToBottom:D})]})}function Tr(e){return e.events?.length?e.events.filter(e=>e.type===`text`).map(e=>e.content).join(``):e.content}var Er=(0,Q.memo)(function({message:e,isStreaming:t,isLastAssistantInTurn:n,turnCopyText:r,turnChanges:i,onJumpToEdit:a,projectName:o,onFork:s,onEdit:c,isEditing:l,onDismiss:u,prevMsgId:d,sessionId:f,providerId:m,versionGroup:h,onNavigateVersion:g,versionNavDisabled:_,bashPartialOutput:v}){if(e.role===`user`){let t=s?()=>s(e.content,d):void 0,n=c?()=>c(e.content,d,e.id):void 0;return(0,$.jsx)(jr,{content:e.content,messageId:e.id,timestamp:e.timestamp,projectName:o,onFork:t,onEdit:n,isEditing:l,sessionId:f,providerId:m,versionGroup:h,onNavigateVersion:g,versionNavDisabled:_})}return e.role===`system`?(0,$.jsxs)(`div`,{className:`group flex items-center gap-2 rounded-lg bg-error/10 border border-error/20 px-3 py-2 text-sm text-error`,children:[(0,$.jsx)(H,{className:`size-4 shrink-0`}),(0,$.jsx)(`p`,{className:`flex-1`,children:e.content}),u&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),"aria-label":`Dismiss`,title:`Dismiss`,className:`shrink-0 rounded p-1 text-error/70 hover:text-error hover:bg-error/15 md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(p,{className:`size-4`})})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.events&&e.events.length>0?(0,$.jsx)(Ur,{events:e.events,isStreaming:t,projectName:o,bashPartialOutput:v}):e.content&&(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(Yr,{content:e.content,projectName:o})}),!t&&n&&e.usage&&(0,$.jsx)(qn,{usage:e.usage}),!t&&n&&(0,$.jsx)(In,{timestamp:e.timestamp,content:r??Tr(e),changes:i,onJumpToEdit:a})]})}),Dr=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`]);function Or(e,t){let n=ie(e);return`/api/project/${encodeURIComponent(t??`_`)}/chat/uploads/${encodeURIComponent(n)}`}function kr(e){let t=e.lastIndexOf(`.`);return t===-1?!1:Dr.has(e.slice(t).toLowerCase())}var Ar=new Set([`task-notification`,`environment_details`,`local-command-caveat`]);function jr({content:e,messageId:t,timestamp:n,projectName:r,onFork:a,onEdit:o,isEditing:c,sessionId:u,providerId:d,versionGroup:f,onNavigateVersion:p,versionNavDisabled:m}){let{files:h,text:g,tags:_,command:v,terminalBlocks:y,idePath:b,agent:x}=(0,Q.useMemo)(()=>br(e),[e]),S=_.some(e=>Ar.has(e.name)),[C,w]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1),T=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{let e=T.current;if(!e)return;let t=()=>te(e.scrollHeight>e.clientHeight+2);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[g]),(0,$.jsxs)(`div`,{className:k(`flex flex-col gap-1`,!S&&`items-end`),children:[(0,$.jsxs)(`div`,{"data-user-message":S?void 0:`true`,style:S?void 0:{borderRadius:`var(--rad) var(--rad) 4px var(--rad)`},className:k(`group/user relative px-3 py-2 text-sm border shadow-sm transition-all`,S?`rounded-lg bg-surface/40 border-border/40 text-text-secondary`:`max-w-[80%] bg-accent-wash border-accent-wash-border text-text`,c&&`ring-2 ring-primary/60 border-primary/40`),children:[_.length>0&&(0,$.jsx)(Nr,{tags:_}),x&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-sky-500/15 border border-sky-500/25 px-2 py-0.5 text-xs font-medium text-sky-600 dark:text-sky-400`,children:[(0,$.jsx)(i,{className:`size-3 shrink-0`}),x]})}),v&&(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-0.5`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/15 border border-primary/20 px-2 py-0.5 text-xs font-medium text-primary`,children:[(0,$.jsx)(xt,{className:`size-3 shrink-0`}),v.name]})}),b&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1 text-[11px] text-text-subtle`,children:[(0,$.jsx)(`span`,{className:`shrink-0`,children:`Opened in IDE:`}),(0,$.jsx)(Lr,{path:b,projectName:r})]}),h.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:h.map((e,t)=>kr(e)?(0,$.jsx)(Hr,{filePath:e,projectName:r},t):(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary`,children:[(0,$.jsx)(L,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:ie(e)})]},t))}),y.length>0&&(0,$.jsx)(`div`,{className:`space-y-1.5`,children:y.map((e,t)=>(0,$.jsx)(Mr,{content:e},t))}),g&&(0,$.jsx)(`div`,{ref:T,className:k(`whitespace-pre-wrap break-words transition-all duration-200 select-text`,!C&&`line-clamp-2`,C&&`max-h-[50vh] overflow-y-auto`),children:S?(0,$.jsx)(zr,{text:g,projectName:r}):(0,$.jsx)(Rr,{text:g})}),(ee||C)&&(0,$.jsx)(`button`,{onClick:()=>w(!C),className:k(`flex items-center gap-1 text-xs mt-1 transition-colors`,S?`text-text-subtle hover:text-text-secondary`:`text-primary/70 hover:text-primary`),children:C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(l,{className:`size-3`}),`Show less`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(s,{className:`size-3`}),`Show more`]})}),!S&&p&&(0,$.jsx)(lr,{group:f,onNavigate:p,disabled:m})]}),!S&&(0,$.jsxs)(yn,{timestamp:n,content:e,children:[o&&(0,$.jsx)(_n,{icon:(0,$.jsx)(Ie,{className:`size-3.5`}),label:`Edit`,title:`Edit this message (continue in the same tab)`,onClick:o}),a&&(0,$.jsx)(_n,{icon:(0,$.jsx)(Y,{className:`size-3.5`}),label:`Fork`,title:`Retry from this message (fork into a new tab)`,onClick:a})]})]})}function Mr({content:e}){let[t,n]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:k(`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs transition-colors`,t?`border-primary/50 bg-surface-elevated text-text-primary`:`border-border/60 bg-background/40 text-text-secondary hover:bg-surface`),children:[(0,$.jsx)(Se,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:`Terminal output`}),(0,$.jsx)(s,{className:k(`size-3 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-md border border-border bg-background p-2 text-xs text-text-primary font-mono whitespace-pre-wrap break-words`,children:e})]})}function Nr({tags:e}){return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map((e,t)=>(0,$.jsx)(Pr,{tag:e},t))})}function Pr({tag:e}){let[t,n]=(0,Q.useState)(!1);return e.name===`task-notification`?(0,$.jsx)(Ir,{content:e.content}):(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[(0,$.jsx)(I,{className:`size-2.5`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(c,{className:k(`size-2.5 transition-transform`,t&&`rotate-90`)})]}),t&&(0,$.jsx)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 text-[11px] text-text-subtle/80 whitespace-pre-wrap max-h-40 overflow-y-auto leading-relaxed`,children:e.content})]})}function Fr(e,t){return e.match(RegExp(`<${t}>([\\s\\S]*?)</${t}>`))?.[1]?.trim()||void 0}function Ir({content:e}){let[t,n]=(0,Q.useState)(!1),r=Fr(e,`status`),i=Fr(e,`summary`),a=Fr(e,`output-file`),o=Fr(e,`result`);return(0,$.jsxs)(`div`,{className:`text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1.5 rounded-full border border-border/60 bg-surface/50 px-2 py-0.5 text-text-subtle hover:text-text-secondary hover:bg-surface transition-colors`,children:[r===`completed`?(0,$.jsx)(se,{className:`size-2.5 text-success`}):(0,$.jsx)(p,{className:`size-2.5 text-warning`}),(0,$.jsx)(`span`,{className:`truncate max-w-80`,children:i??`Task notification`}),(0,$.jsx)(c,{className:k(`size-2.5 transition-transform shrink-0`,t&&`rotate-90`)})]}),t&&(0,$.jsxs)(`div`,{className:`mt-1 rounded border border-border/40 bg-surface/30 px-2 py-1.5 space-y-1.5`,children:[i&&(0,$.jsx)(`p`,{className:`text-[11px] text-text-secondary`,children:i}),a&&(0,$.jsx)(Lr,{path:a}),o&&(0,$.jsx)(`div`,{className:`text-[11px] text-text-subtle/80 max-h-60 overflow-y-auto leading-relaxed`,children:(0,$.jsx)(Yr,{content:o})})]})]})}function Lr({path:e,projectName:t}){return(0,$.jsxs)(`button`,{type:`button`,onClick:(0,Q.useCallback)(()=>{let n=ae.getState().openTab,r=t??M.getState().activeProject?.name,i=ie(e),a={filePath:e};r&&(a.projectName=r),E.get(`/api/fs/read?path=${encodeURIComponent(e)}`).then(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})}).catch(()=>{n({type:`editor`,title:i,metadata:a,projectId:null,closable:!0})})},[e,t]),className:`inline-flex items-center gap-1 rounded border border-border/50 bg-surface/50 px-1.5 py-0.5 font-mono text-[10px] text-text-secondary hover:text-text-primary hover:bg-surface transition-colors cursor-pointer`,children:[(0,$.jsx)(L,{className:`size-2.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-60`,children:ie(e)}),(0,$.jsx)(z,{className:`size-2 shrink-0 opacity-50`})]})}function Rr({text:e}){let t=(0,Q.useMemo)(()=>{let t=/(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`url`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]);return t.every(e=>e.kind===`text`)?(0,$.jsx)($.Fragment,{children:e}):(0,$.jsx)($.Fragment,{children:t.map((e,t)=>e.kind===`url`?(0,$.jsx)(`a`,{href:e.value,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary underline underline-offset-2 hover:text-primary/80 break-all`,onClick:e=>e.stopPropagation(),children:e.value},t):(0,$.jsx)(`span`,{children:e.value},t))})}function zr({text:e,projectName:t}){return(0,$.jsx)($.Fragment,{children:(0,Q.useMemo)(()=>{let t=/(\/(?:[\w.\-]+\/)+[\w.\-]+)/g,n=[],r=0,i;for(;(i=t.exec(e))!==null;)i.index>r&&n.push({kind:`text`,value:e.slice(r,i.index)}),n.push({kind:`path`,value:i[1]}),r=i.index+i[0].length;return r<e.length&&n.push({kind:`text`,value:e.slice(r)}),n},[e]).map((e,n)=>e.kind===`path`?(0,$.jsx)(Lr,{path:e.value,projectName:t},n):(0,$.jsx)(`span`,{children:e.value},n))})}var Br=new Map;function Vr(e){let[t,n]=(0,Q.useState)(()=>Br.get(e)?.url??null),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=Br.get(e);if(t){n(t.url);return}let r=!1,a=D();return fetch(e,{headers:a?{Authorization:`Bearer ${a}`}:{}}).then(e=>{if(!e.ok)throw Error(`Failed`);return e.blob()}).then(t=>{if(r)return;let i=URL.createObjectURL(t);Br.set(e,{url:i}),n(i)}).catch(()=>{r||i(!0)}),()=>{r=!0}},[e]),{blobUrl:t,error:r}}function Hr({filePath:e,projectName:t}){let{blobUrl:n,error:r}=Vr(Or(e,t)),i=Be(e=>e.open),a=ie(e);return(0,$.jsxs)(`button`,{type:`button`,onClick:e=>n&&i(n,a,tt(e.currentTarget)),className:`flex items-center gap-1 rounded-md border border-border/60 bg-background/40 px-1.5 py-0.5 text-[11px] text-text-secondary hover:bg-surface transition-colors cursor-pointer`,children:[n?(0,$.jsx)(`img`,{src:n,alt:a,[nt]:``,className:`size-4 rounded-sm object-cover shrink-0`}):r?(0,$.jsx)(Re,{className:`size-3 shrink-0`}):(0,$.jsx)(`div`,{className:`size-4 rounded-sm bg-surface animate-pulse shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-32`,children:a})]})}function Ur({events:e,isStreaming:t,projectName:n,bashPartialOutput:r}){let i=[],a=``,o=``;for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`thinking`){a&&=(i.push({kind:`text`,content:a}),``),o+=n.content;continue}if(o&&=(i.push({kind:`thinking`,content:o}),``),n.type===`account_retry`){a&&=(i.push({kind:`text`,content:a}),``);let e=n.accountLabel??`another account`,t=n.reason??`Auth failed`;i.push({kind:`text`,content:`\n\n> ↻ ${t} — retrying with **${e}**...\n\n`});continue}if(n.type===`text`)a+=n.content;else if(n.type===`tool_use`){let e=n.toolUseId,t=e?i.find(t=>t.kind===`tool`&&t.tool.type===`tool_use`&&t.tool.toolUseId===e):void 0;if(t){t.tool=n;continue}a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n})}else n.type===`tool_result`||(a&&=(i.push({kind:`text`,content:a}),``),i.push({kind:`tool`,tool:n}))}o&&i.push({kind:`thinking`,content:o}),a&&i.push({kind:`text`,content:a});let s=e.filter(e=>e.type===`tool_result`);for(let e of s){let t=e.toolUseId;if(t){let n=i.find(e=>e.kind===`tool`&&e.tool.type===`tool_use`&&e.tool.toolUseId===t);if(n){n.result=e;continue}}let n=i.find(e=>e.kind===`tool`&&!e.result);n&&(n.result=e)}for(let e of i)if(e.kind===`tool`&&!e.result&&e.tool.type===`tool_use`){let t=e.tool.result;t&&(e.result={type:`tool_result`,output:t.output,isError:t.isError})}for(let e=0;e<i.length;e++){let n=i[e];if(n.kind===`tool`&&!n.result){let r=!1;if(n.tool.type===`tool_use`&&n.tool.tool===`Read`){let t=n.tool.input?.file_path;t&&(r=i.slice(e+1).some(e=>e.kind===`tool`&&e.result&&e.tool.type===`tool_use`&&e.tool.tool===`Edit`&&e.tool.input?.file_path===t))}n.completed=r||!t}}return(0,$.jsx)($.Fragment,{children:i.map((e,a)=>{if(e.kind===`thinking`)return(0,$.jsx)(Wr,{content:e.content,isStreaming:t&&a===i.length-1},`think-${a}`);if(e.kind===`text`){let r=t&&a===i.length-1;return(0,$.jsx)(`div`,{className:`text-sm text-text-primary select-text`,children:(0,$.jsx)(Gr,{content:e.content,animate:r,projectName:n})},`text-${a}`)}return(0,$.jsx)(f,{tool:e.tool,result:e.result,completed:e.completed,projectName:n,bashPartialOutput:r},`tool-${a}`)})})}function Wr({content:e,isStreaming:t}){let[n,r]=(0,Q.useState)(t),i=(0,Q.useRef)(null);return(0,Q.useEffect)(()=>{!t&&e.length>0&&r(!1)},[t,e.length]),(0,Q.useEffect)(()=>{t&&n&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t,n]),(0,$.jsxs)(`div`,{className:`rounded border border-border/50 bg-surface/30 text-xs`,children:[(0,$.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-2 px-2 py-1.5 w-full text-left hover:bg-surface transition-colors text-text-subtle`,children:[t?(0,$.jsx)(w,{className:`size-3 animate-spin`}):(0,$.jsx)(c,{className:`size-3 transition-transform ${n?`rotate-90`:``}`}),(0,$.jsxs)(`span`,{children:[`Thinking`,t?`...`:``]}),!t&&(0,$.jsx)(`span`,{className:`text-text-subtle/50 ml-auto`,children:e.length>100?`${Math.round(e.length/4)} tokens`:``})]}),n&&(0,$.jsx)(`div`,{ref:i,className:`max-h-60 overflow-y-auto`,children:(0,$.jsx)(`div`,{className:`px-2 pb-2 text-text-subtle/80 whitespace-pre-wrap text-[11px] leading-relaxed`,children:e})})]})}function Gr({content:e,animate:t,projectName:n}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yr,{content:e,projectName:n,isStreaming:t}),t&&(0,$.jsx)(`span`,{className:`text-text-subtle text-sm animate-pulse`,children:`Thinking...`})]})}function Kr({lastMessage:e,phase:t,elapsed:n,statusMessage:r}){let i=!e||e.role!==`assistant`,a=e?.events?.length?e.events[e.events.length-1].type===`tool_result`:!1;return!r&&!i&&!a?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-text-subtle`,children:[(0,$.jsx)(w,{className:`size-3 animate-spin`}),(0,$.jsxs)(`span`,{children:[r||(t===`initializing`?`Initializing`:t===`connecting`?`Connecting`:t===`thinking`?`Thinking`:`Processing`),i&&(n??0)>0&&(0,$.jsxs)(`span`,{className:`text-text-subtle/60`,children:[`... (`,n,`s)`]})]})]}),t===`connecting`&&(n??0)>=30&&(0,$.jsx)(`p`,{className:`text-xs text-warning/80 ml-5`,children:`Taking longer than usual — may be rate-limited or API slow. Try sending a new message to retry.`})]})}var qr=/<teammate-message[^>]*>[\s\S]*?<\/teammate-message>/g;function Jr(e){return e.replace(qr,``).replace(/\n{3,}/g,`
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{t as i}from"./chevron-right-De-Wz5Lz.js";import{t as a}from"./code-DJgYrFzm.js";import{t as o}from"./database-Y3ESDK4-.js";import{t as s}from"./download-DG3_9xXy.js";import{t as c}from"./eye-gWwaF4Lg.js";import{t as l}from"./file-exclamation-point-JzhTU2TX.js";import{a as u,i as d,o as f,r as p,t as m}from"./glide-data-grid-BT9p_4AN.js";import{t as h}from"./loader-circle-DPMrnLQ2.js";import{t as ee}from"./shield-check-BsG3LV8i.js";import{t as te}from"./shield-off-7jKWpJBD.js";import{t as ne}from"./table-CRJsmfeg.js";import{t as re}from"./text-wrap-oiekm5SB.js";import{n as g,t as ie}from"./use-inline-blame-C1G-_NjC.js";import{t as _}from"./x-CxoBA0po.js";import{i as ae,n as v}from"./api-client-CEYCBt_0.js";import{q as y}from"./vendor-mermaid-CfY1-PkA.js";import{t as b}from"./settings-store-CzLnTR8p.js";import{t as x}from"./utils-IrnQujwR.js";import"./portal-container-context-DKymYOY-.js";import{t as oe}from"./panel-store-BmdcSBNb.js";import"./window-store-D0HbQ1pM.js";import{i as S}from"./project-store-wWZ6bjwq.js";import{t as se}from"./tab-store-1xYJb0gM.js";import{t as C}from"./button-DX32ffge.js";import{$n as ce,$t as w,Cr as T,Dr as E,Er as le,Fn as ue,Gt as de,It as fe,K as pe,Kt as D,Lt as O,Qt as me,Rt as k,Sr as he,Tr as A,Wt as j,X as ge,Xn as _e,Xt as ve,Yt as ye,an as be,en as M,gn as N,gr as xe,kr as Se,q as Ce,qt as we,rn as Te,s as Ee,xr as De,yr as Oe,zt as P}from"./index-kGmcC9cb.js";import"./data-grid-types-DeY60CLU.js";import{t as ke}from"./use-monaco-theme-Uakgj3hJ.js";import{i as Ae,n as je,r as Me,t as Ne}from"./can-open-in-ppm-_yqa69dV.js";var F=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),I=e(t(),1),L=n();function R(e){let t=e.startsWith(`/`),n=e.split(/[/\\]/).filter(Boolean),r=e=>{let r=(t?`/`:``)+n.slice(0,e+1).join(`/`);return/^[A-Za-z]:$/.test(r)?r+`/`:r},i=t?`/`:(n[0]??``)+`/`;return n.map((e,t)=>({name:e,absPath:r(t),parentDir:t>0?r(t-1):i}))}async function Pe(e){return(await v.get(`/api/fs/browse?path=${encodeURIComponent(e)}`)).entries}function Fe({filePath:e,projectName:t,tabId:n,className:r}){let{updateTab:a,openTab:o}=se(fe(e=>({updateTab:e.updateTab,openTab:e.openTab}))),s=(0,I.useRef)(null),c=(0,I.useMemo)(()=>R(e),[e]);(0,I.useEffect)(()=>{s.current&&(s.current.scrollLeft=s.current.scrollWidth)},[c]);let l=(0,I.useCallback)((e,r)=>{let i=x(e),s={filePath:e,projectName:t};r.metaKey||r.ctrlKey?o({type:`editor`,title:i,metadata:s,projectId:t,closable:!0}):a(n,{title:i,metadata:s})},[t,n,o,a]);return(0,L.jsx)(`div`,{ref:s,className:r,children:c.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(Ie,{segment:e,isLast:t===c.length-1,onFileClick:l})]},e.absPath))})}function Ie({segment:e,isLast:t,onFileClick:n}){let[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(null);function s(t){t&&r===null&&Pe(e.parentDir).then(i).catch(e=>{o(e.message||`Failed to browse`),i([])})}return(0,L.jsxs)(O,{onOpenChange:s,children:[(0,L.jsx)(we,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,L.jsx)(k,{align:`start`,className:`max-h-[300px] overflow-y-auto p-1`,children:r===null?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-destructive`,children:a}):r.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):r.map(t=>(0,L.jsx)(Le,{entry:t,activePath:e.absPath,onFileClick:n},t.path))})]})}function Le({entry:e,activePath:t,onFileClick:n}){let r=ze(e.name,e.type===`directory`),i=e.path===t,[a,o]=(0,I.useState)(null);if(e.type===`directory`){function s(t){t&&a===null&&Pe(e.path).then(o).catch(()=>o([]))}return(0,L.jsxs)(j,{onOpenChange:s,children:[(0,L.jsxs)(D,{className:`text-xs gap-1.5 ${i?`bg-muted`:``}`,children:[(0,L.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,L.jsx)(de,{className:`max-h-[300px] overflow-y-auto p-1`,children:a===null?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):a.map(e=>(0,L.jsx)(Le,{entry:e,activePath:t,onFileClick:n},e.path))})]})}return(0,L.jsxs)(P,{className:`text-xs gap-1.5 cursor-pointer ${i?`bg-muted`:``}`,onClick:t=>n(e.path,t),children:[(0,L.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})}var Re={ts:A,tsx:A,js:A,jsx:A,py:A,rs:A,go:A,html:A,css:A,scss:A,json:le,md:T,txt:T,yaml:he,yml:he};function ze(e,t){return t?Oe:Re[e.split(`.`).pop()?.toLowerCase()??``]??De}function Be(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function Ve(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function He({filePath:e,projectName:t,tabId:n,className:r}){let a=N(e=>e.tree),{updateTab:o,openTab:s}=se(fe(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=S(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,I.useRef)(null),{prefixParts:u,relativePath:d,isExternal:f}=(0,I.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e,isExternal:!1}}return{prefixParts:[],relativePath:t,isExternal:/^(\/|[A-Za-z]:[/\\])/.test(e)}},[e,c]),p=(0,I.useMemo)(()=>Be(a,d.split(`/`).filter(Boolean)),[a,d]);(0,I.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[p]);function m(e,r){let i=x(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return f?(0,L.jsx)(Fe,{filePath:e,projectName:t,tabId:n,className:r}):(0,L.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),p.map((e,n)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(z,{segment:e,isLast:n===p.length-1,projectName:t,onFileClick:m})]},e.fullPath))]})}function z({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=N(e=>e.loadChildren),a=N(e=>e.loadedPaths),o=(0,I.useMemo)(()=>Ve(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,L.jsxs)(O,{onOpenChange:c,children:[(0,L.jsx)(we,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,L.jsx)(k,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,L.jsx)(B,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function B({node:e,projectName:t,activePath:n,onFileClick:r}){let i=ze(e.name,e.type===`directory`),a=e.path===n,o=N(e=>e.loadChildren),s=N(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,L.jsxs)(j,{onOpenChange:u,children:[(0,L.jsxs)(D,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,L.jsx)(de,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):Ve(c).map(e=>(0,L.jsx)(B,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,L.jsxs)(P,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})}function V({active:e,onClick:t,icon:n,label:r,title:i}){return(0,L.jsxs)(`button`,{type:`button`,title:i,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,L.jsx)(n,{className:`size-3`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ue({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:o,onToggleWordWrap:l,inlineBlame:u,onToggleInlineBlame:d,blameStale:f,onRefresh:p,refreshing:m,filePath:h,projectName:ee,className:te}){return(0,L.jsxs)(`div`,{className:te,children:[(e===`md`||e===`mdx`)&&n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(V,{active:t===`edit`,onClick:()=>n(`edit`),icon:a,label:`Edit`}),(0,L.jsx)(V,{active:t===`preview`,onClick:()=>n(`preview`),icon:c,label:`Preview`})]}),e===`csv`&&i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(V,{active:r===`table`,onClick:()=>i(`table`),icon:ne,label:`Table`}),(0,L.jsx)(V,{active:r===`raw`,onClick:()=>i(`raw`),icon:a,label:`Raw`})]}),(0,L.jsx)(V,{active:o,onClick:l,icon:re,label:`Wrap`}),d&&(0,L.jsx)(V,{active:u===!0,onClick:d,icon:g,label:`Blame`,title:u&&f?`Blame is hidden until this file is saved — the line numbers have moved`:`Inline blame (Alt+B)`}),p&&(0,L.jsxs)(`button`,{type:`button`,onClick:p,disabled:m,title:`Reload file from disk`,className:`flex items-center gap-1 px-2 py-1 rounded text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:[(0,L.jsx)(_e,{className:`size-3 ${m?`animate-spin`:``}`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),h&&ee&&(0,L.jsx)(V,{active:!1,onClick:()=>Te(ee,h),icon:s,label:`Download`})]})}var H=[{id:`plaintext`,label:`Plain Text`},{id:`javascript`,label:`JavaScript`},{id:`typescript`,label:`TypeScript`},{id:`sql`,label:`SQL`},{id:`json`,label:`JSON`},{id:`xml`,label:`XML`},{id:`html`,label:`HTML`},{id:`css`,label:`CSS`},{id:`python`,label:`Python`},{id:`markdown`,label:`Markdown`},{id:`yaml`,label:`YAML`},{id:`shell`,label:`Shell`}];function We({value:e,onChange:t}){return(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,L.jsx)(A,{className:`size-3 text-muted-foreground`}),(0,L.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[120px]`,title:`Select editor language`,children:H.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}function Ge({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,o]=(0,I.useState)(t),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=S(e=>e.activeProject),f=(0,I.useCallback)(()=>{let e=a.trim();if(!e){u(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){u(`Filename cannot contain / or \\`);return}u(``),c(!0)},[a]),p=(0,I.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return s?(0,L.jsx)(Ce,{open:!0,mode:`folder`,root:d?.path,title:`Save "${a.trim()}" to...`,onSelect:p,onCancel:()=>c(!1)}):(0,L.jsx)(ye,{open:e,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(ve,{className:`sm:max-w-md`,children:[(0,L.jsx)(w,{children:(0,L.jsx)(M,{children:`Save As`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,L.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,L.jsx)(ge,{value:a,onChange:e=>{o(e.target.value),u(``)},onKeyDown:e=>{e.key===`Enter`&&f()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),l&&(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:l})]}),(0,L.jsxs)(me,{children:[(0,L.jsx)(C,{variant:`outline`,onClick:i,children:`Cancel`}),(0,L.jsx)(C,{onClick:f,children:`Choose Folder...`})]})]})})}var U=typeof window<`u`&&window.isSecureContext,W=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],Ke=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,G=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,K=`w-px h-5 bg-border mx-0.5 shrink-0`;function qe({editorRef:e,readOnly:t}){let n=(0,I.useCallback)(()=>e.current,[e]),r=(0,I.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=(0,I.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,I.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,I.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!U&&i&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,L.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,L.jsx)(_,{size:14})})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:U?s:c,className:Ke,title:`Paste`,children:(0,L.jsx)(Se,{size:14})}),(0,L.jsx)(`button`,{type:`button`,onClick:u,className:Ke,title:`Undo`,children:(0,L.jsx)(ue,{size:14})}),(0,L.jsx)(`button`,{type:`button`,onClick:d,className:Ke,title:`Redo`,children:(0,L.jsx)(F,{size:14})}),(0,L.jsx)(`div`,{className:K}),(0,L.jsx)(`button`,{type:`button`,onClick:f,className:G,children:`Tab`}),(0,L.jsx)(`div`,{className:K}),W.map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:G,children:e},e))]})]})}var Je=(0,I.lazy)(()=>y(()=>import(`./markdown-renderer-iBw1fCI_.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]))),Ye=(0,I.lazy)(()=>y(()=>import(`./csv-preview-DENi3CFz.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([48,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,49,50]))),Xe=(0,I.lazy)(()=>y(()=>import(`./image-preview-fuU4h2nr.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([51,3,2,4,52,9,25,28,53]))),Ze=(0,I.lazy)(()=>y(()=>import(`./pdf-preview-DB26KSzm.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([54,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,52]))),Qe=(0,I.lazy)(()=>y(()=>import(`./video-preview-BUb43zWb.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([55,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,52,56,57]))),$e=(0,I.lazy)(()=>y(()=>import(`./audio-preview-B4E5_7TW.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([58,2,3,4,8,9,52,28,57]))),et=(0,I.lazy)(()=>y(()=>import(`./docx-preview-Xy7SZ7Vf.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([59,2,3,4,52,9,25,28])));function tt(e){return e.split(`.`).pop()?.toLowerCase()??``}function nt(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[tt(e)]??`plaintext`}var rt=(0,I.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[s,c]=(0,I.useState)(i??null),[m,ne]=(0,I.useState)(`utf-8`),[re,g]=(0,I.useState)(!0),[_,y]=(0,I.useState)(null),[S,C]=(0,I.useState)(!1),w=(0,I.useRef)(null),T=(0,I.useRef)(``),E=(0,I.useRef)(null),[le,ue]=(0,I.useState)(null),{tabs:de,updateTab:D}=se(fe(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:O,toggleWordWrap:me}=b(fe(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),k=b(e=>e.inlineBlame),he=b(e=>e.toggleInlineBlame),A=ke(),j=e?.isUntitled===!0,ge=e?.unsavedContent,[_e,ve]=(0,I.useState)(!1),ye=de.find(e=>e.id===t),M=n?tt(n):``,N=je.has(M),xe=M===`pdf`,Se=M===`docx`,Ce=Ae.has(M),we=Ne.has(M),Te=Me.has(M),De=M===`md`||M===`mdx`,Oe=M===`csv`,P=e?.language,F=a??P??nt(n??``),R=F===`sql`,[Pe,Fe]=(0,I.useState)(`preview`),[Ie,Le]=(0,I.useState)(`table`),{connections:Re,cachedTables:ze,refreshTables:Be,updateConnection:Ve}=pe(),z=n?`ppm:sql-conn:${n}`:t?`ppm:sql-conn:tab:${t}`:null,[B,V]=(0,I.useState)(()=>{if(!z)return null;let e=localStorage.getItem(z);return e?Number(e):null}),H=(0,I.useRef)(null),U=(0,I.useRef)(null),W=(0,I.useMemo)(()=>Re.find(e=>e.id===B)??null,[Re,B]),Ke=i!=null&&(a===`json`||a===`xml`),[G,K]=(0,I.useState)(!1),Je=(0,I.useCallback)(()=>{if(i)if(G)c(i),K(!1);else{let e=i.trimStart();if(a===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),K(!0)}catch{}else if(a===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-Bthd7hxl.js","assets/vendor-mermaid-CfY1-PkA.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-ui-CaeeFO0B.js","assets/vendor-markdown-Ls5AcU91.js","assets/markdown-renderer-Bkrk39pO.js","assets/index-DJM59ogE.js","assets/button-DX32ffge.js","assets/utils-IrnQujwR.js","assets/createLucideIcon-D8pyde1A.js","assets/arrow-left-CyFcsyzD.js","assets/bot-D6sx11y0.js","assets/check-DN75Ucvz.js","assets/chevron-down-Dp0rpHb8.js","assets/chevron-right-De-Wz5Lz.js","assets/chevron-up-8PbsNiJp.js","assets/circle-BCy0AUCo.js","assets/clock-C1CQUQPZ.js","assets/sparkles-Dh-_J2Rd.js","assets/copy-BewHj66E.js","assets/database-Y3ESDK4-.js","assets/download-DG3_9xXy.js","assets/use-coarse-long-press-BmI_GVW5.js","assets/eye-off-GjXVuAOn.js","assets/eye-gWwaF4Lg.js","assets/loader-circle-DPMrnLQ2.js","assets/monitor-C835ucWH.js","assets/x-CxoBA0po.js","assets/api-client-CEYCBt_0.js","assets/react-D1Yg256j.js","assets/window-store-D0HbQ1pM.js","assets/window-pip-registry-CrCYYTTf.js","assets/panel-store-BmdcSBNb.js","assets/context-menu-CJL8L98s.js","assets/portal-container-context-DKymYOY-.js","assets/mobile-bottom-sheet-CmySDB6I.js","assets/use-visual-viewport-Bfl3Bxxb.js","assets/use-is-mobile-D1weanbj.js","assets/project-store-wWZ6bjwq.js","assets/ws-auth-D111jj32.js","assets/settings-store-CzLnTR8p.js","assets/streaming-store-9XVmAMfV.js","assets/tab-store-1xYJb0gM.js","assets/apply-theme-BVXAUYoN.js","assets/resolve-theme-CMp5xxCW.js","assets/index-CuYtJ5xF.css","assets/image-gallery-J8h8IY0c.js","assets/run-in-terminal-wHKwAnWP.js","assets/csv-preview-B2PR7z0o.js","assets/lib-el9rA30D.js","assets/csv-parser-DbxGKdMG.js","assets/image-preview-fuU4h2nr.js","assets/file-exclamation-point-JzhTU2TX.js","assets/use-blob-url-CrwoZJUJ.js","assets/pdf-preview-DE0wVfyM.js","assets/video-preview-B2dk48oQ.js","assets/can-open-in-ppm-_yqa69dV.js","assets/media-url-BMeBaB0q.js","assets/audio-preview-B4E5_7TW.js","assets/docx-preview-Xy7SZ7Vf.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{t as i}from"./chevron-right-De-Wz5Lz.js";import{t as a}from"./code-DJgYrFzm.js";import{t as o}from"./database-Y3ESDK4-.js";import{t as s}from"./download-DG3_9xXy.js";import{t as c}from"./eye-gWwaF4Lg.js";import{t as l}from"./file-exclamation-point-JzhTU2TX.js";import{a as u,i as d,o as f,r as p,t as m}from"./glide-data-grid-nA5LsoJK.js";import{t as h}from"./loader-circle-DPMrnLQ2.js";import{t as ee}from"./shield-check-BsG3LV8i.js";import{t as te}from"./shield-off-7jKWpJBD.js";import{t as ne}from"./table-CRJsmfeg.js";import{t as re}from"./text-wrap-oiekm5SB.js";import{n as g,t as ie}from"./use-inline-blame-C1G-_NjC.js";import{t as _}from"./x-CxoBA0po.js";import{i as ae,n as v}from"./api-client-CEYCBt_0.js";import{q as y}from"./vendor-mermaid-CfY1-PkA.js";import{t as b}from"./settings-store-CzLnTR8p.js";import{t as x}from"./utils-IrnQujwR.js";import"./portal-container-context-DKymYOY-.js";import{t as oe}from"./panel-store-BmdcSBNb.js";import"./window-store-D0HbQ1pM.js";import{i as S}from"./project-store-wWZ6bjwq.js";import{t as se}from"./tab-store-1xYJb0gM.js";import{t as C}from"./button-DX32ffge.js";import{$n as ce,$t as w,Cr as T,Dr as E,Er as le,Fn as ue,Gt as de,It as fe,K as pe,Kt as D,Lt as O,Qt as me,Rt as k,Sr as he,Tr as A,Wt as j,X as ge,Xn as _e,Xt as ve,Yt as ye,an as be,en as M,gn as N,gr as xe,kr as Se,q as Ce,qt as we,rn as Te,s as Ee,xr as De,yr as Oe,zt as P}from"./index-DJM59ogE.js";import"./data-grid-types-DeY60CLU.js";import{t as ke}from"./use-monaco-theme-DT5Q8kuf.js";import{i as Ae,n as je,r as Me,t as Ne}from"./can-open-in-ppm-_yqa69dV.js";var F=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),I=e(t(),1),L=n();function R(e){let t=e.startsWith(`/`),n=e.split(/[/\\]/).filter(Boolean),r=e=>{let r=(t?`/`:``)+n.slice(0,e+1).join(`/`);return/^[A-Za-z]:$/.test(r)?r+`/`:r},i=t?`/`:(n[0]??``)+`/`;return n.map((e,t)=>({name:e,absPath:r(t),parentDir:t>0?r(t-1):i}))}async function Pe(e){return(await v.get(`/api/fs/browse?path=${encodeURIComponent(e)}`)).entries}function Fe({filePath:e,projectName:t,tabId:n,className:r}){let{updateTab:a,openTab:o}=se(fe(e=>({updateTab:e.updateTab,openTab:e.openTab}))),s=(0,I.useRef)(null),c=(0,I.useMemo)(()=>R(e),[e]);(0,I.useEffect)(()=>{s.current&&(s.current.scrollLeft=s.current.scrollWidth)},[c]);let l=(0,I.useCallback)((e,r)=>{let i=x(e),s={filePath:e,projectName:t};r.metaKey||r.ctrlKey?o({type:`editor`,title:i,metadata:s,projectId:t,closable:!0}):a(n,{title:i,metadata:s})},[t,n,o,a]);return(0,L.jsx)(`div`,{ref:s,className:r,children:c.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(Ie,{segment:e,isLast:t===c.length-1,onFileClick:l})]},e.absPath))})}function Ie({segment:e,isLast:t,onFileClick:n}){let[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(null);function s(t){t&&r===null&&Pe(e.parentDir).then(i).catch(e=>{o(e.message||`Failed to browse`),i([])})}return(0,L.jsxs)(O,{onOpenChange:s,children:[(0,L.jsx)(we,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,L.jsx)(k,{align:`start`,className:`max-h-[300px] overflow-y-auto p-1`,children:r===null?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-destructive`,children:a}):r.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):r.map(t=>(0,L.jsx)(Le,{entry:t,activePath:e.absPath,onFileClick:n},t.path))})]})}function Le({entry:e,activePath:t,onFileClick:n}){let r=ze(e.name,e.type===`directory`),i=e.path===t,[a,o]=(0,I.useState)(null);if(e.type===`directory`){function s(t){t&&a===null&&Pe(e.path).then(o).catch(()=>o([]))}return(0,L.jsxs)(j,{onOpenChange:s,children:[(0,L.jsxs)(D,{className:`text-xs gap-1.5 ${i?`bg-muted`:``}`,children:[(0,L.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,L.jsx)(de,{className:`max-h-[300px] overflow-y-auto p-1`,children:a===null?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):a.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Empty`}):a.map(e=>(0,L.jsx)(Le,{entry:e,activePath:t,onFileClick:n},e.path))})]})}return(0,L.jsxs)(P,{className:`text-xs gap-1.5 cursor-pointer ${i?`bg-muted`:``}`,onClick:t=>n(e.path,t),children:[(0,L.jsx)(r,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})}var Re={ts:A,tsx:A,js:A,jsx:A,py:A,rs:A,go:A,html:A,css:A,scss:A,json:le,md:T,txt:T,yaml:he,yml:he};function ze(e,t){return t?Oe:Re[e.split(`.`).pop()?.toLowerCase()??``]??De}function Be(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function Ve(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function He({filePath:e,projectName:t,tabId:n,className:r}){let a=N(e=>e.tree),{updateTab:o,openTab:s}=se(fe(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=S(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,I.useRef)(null),{prefixParts:u,relativePath:d,isExternal:f}=(0,I.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e,isExternal:!1}}return{prefixParts:[],relativePath:t,isExternal:/^(\/|[A-Za-z]:[/\\])/.test(e)}},[e,c]),p=(0,I.useMemo)(()=>Be(a,d.split(`/`).filter(Boolean)),[a,d]);(0,I.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[p]);function m(e,r){let i=x(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return f?(0,L.jsx)(Fe,{filePath:e,projectName:t,tabId:n,className:r}):(0,L.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),p.map((e,n)=>(0,L.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,L.jsx)(i,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,L.jsx)(z,{segment:e,isLast:n===p.length-1,projectName:t,onFileClick:m})]},e.fullPath))]})}function z({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=N(e=>e.loadChildren),a=N(e=>e.loadedPaths),o=(0,I.useMemo)(()=>Ve(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,L.jsxs)(O,{onOpenChange:c,children:[(0,L.jsx)(we,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,L.jsx)(k,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,L.jsx)(B,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function B({node:e,projectName:t,activePath:n,onFileClick:r}){let i=ze(e.name,e.type===`directory`),a=e.path===n,o=N(e=>e.loadChildren),s=N(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,L.jsxs)(j,{onOpenChange:u,children:[(0,L.jsxs)(D,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,L.jsx)(de,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,L.jsx)(P,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):Ve(c).map(e=>(0,L.jsx)(B,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,L.jsxs)(P,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,L.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.name})]})}function V({active:e,onClick:t,icon:n,label:r,title:i}){return(0,L.jsxs)(`button`,{type:`button`,title:i,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,L.jsx)(n,{className:`size-3`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ue({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:o,onToggleWordWrap:l,inlineBlame:u,onToggleInlineBlame:d,blameStale:f,onRefresh:p,refreshing:m,filePath:h,projectName:ee,className:te}){return(0,L.jsxs)(`div`,{className:te,children:[(e===`md`||e===`mdx`)&&n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(V,{active:t===`edit`,onClick:()=>n(`edit`),icon:a,label:`Edit`}),(0,L.jsx)(V,{active:t===`preview`,onClick:()=>n(`preview`),icon:c,label:`Preview`})]}),e===`csv`&&i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(V,{active:r===`table`,onClick:()=>i(`table`),icon:ne,label:`Table`}),(0,L.jsx)(V,{active:r===`raw`,onClick:()=>i(`raw`),icon:a,label:`Raw`})]}),(0,L.jsx)(V,{active:o,onClick:l,icon:re,label:`Wrap`}),d&&(0,L.jsx)(V,{active:u===!0,onClick:d,icon:g,label:`Blame`,title:u&&f?`Blame is hidden until this file is saved — the line numbers have moved`:`Inline blame (Alt+B)`}),p&&(0,L.jsxs)(`button`,{type:`button`,onClick:p,disabled:m,title:`Reload file from disk`,className:`flex items-center gap-1 px-2 py-1 rounded text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,children:[(0,L.jsx)(_e,{className:`size-3 ${m?`animate-spin`:``}`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),h&&ee&&(0,L.jsx)(V,{active:!1,onClick:()=>Te(ee,h),icon:s,label:`Download`})]})}var H=[{id:`plaintext`,label:`Plain Text`},{id:`javascript`,label:`JavaScript`},{id:`typescript`,label:`TypeScript`},{id:`sql`,label:`SQL`},{id:`json`,label:`JSON`},{id:`xml`,label:`XML`},{id:`html`,label:`HTML`},{id:`css`,label:`CSS`},{id:`python`,label:`Python`},{id:`markdown`,label:`Markdown`},{id:`yaml`,label:`YAML`},{id:`shell`,label:`Shell`}];function We({value:e,onChange:t}){return(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,L.jsx)(A,{className:`size-3 text-muted-foreground`}),(0,L.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[120px]`,title:`Select editor language`,children:H.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}function Ge({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,o]=(0,I.useState)(t),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=S(e=>e.activeProject),f=(0,I.useCallback)(()=>{let e=a.trim();if(!e){u(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){u(`Filename cannot contain / or \\`);return}u(``),c(!0)},[a]),p=(0,I.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return s?(0,L.jsx)(Ce,{open:!0,mode:`folder`,root:d?.path,title:`Save "${a.trim()}" to...`,onSelect:p,onCancel:()=>c(!1)}):(0,L.jsx)(ye,{open:e,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(ve,{className:`sm:max-w-md`,children:[(0,L.jsx)(w,{children:(0,L.jsx)(M,{children:`Save As`})}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,L.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,L.jsx)(ge,{value:a,onChange:e=>{o(e.target.value),u(``)},onKeyDown:e=>{e.key===`Enter`&&f()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),l&&(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:l})]}),(0,L.jsxs)(me,{children:[(0,L.jsx)(C,{variant:`outline`,onClick:i,children:`Cancel`}),(0,L.jsx)(C,{onClick:f,children:`Choose Folder...`})]})]})})}var U=typeof window<`u`&&window.isSecureContext,W=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],Ke=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,G=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,K=`w-px h-5 bg-border mx-0.5 shrink-0`;function qe({editorRef:e,readOnly:t}){let n=(0,I.useCallback)(()=>e.current,[e]),r=(0,I.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null),s=(0,I.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,I.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,I.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,I.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!U&&i&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,L.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,L.jsx)(_,{size:14})})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:U?s:c,className:Ke,title:`Paste`,children:(0,L.jsx)(Se,{size:14})}),(0,L.jsx)(`button`,{type:`button`,onClick:u,className:Ke,title:`Undo`,children:(0,L.jsx)(ue,{size:14})}),(0,L.jsx)(`button`,{type:`button`,onClick:d,className:Ke,title:`Redo`,children:(0,L.jsx)(F,{size:14})}),(0,L.jsx)(`div`,{className:K}),(0,L.jsx)(`button`,{type:`button`,onClick:f,className:G,children:`Tab`}),(0,L.jsx)(`div`,{className:K}),W.map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:G,children:e},e))]})]})}var Je=(0,I.lazy)(()=>y(()=>import(`./markdown-renderer-Bthd7hxl.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]))),Ye=(0,I.lazy)(()=>y(()=>import(`./csv-preview-B2PR7z0o.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([48,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,49,50]))),Xe=(0,I.lazy)(()=>y(()=>import(`./image-preview-fuU4h2nr.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([51,3,2,4,52,9,25,28,53]))),Ze=(0,I.lazy)(()=>y(()=>import(`./pdf-preview-DE0wVfyM.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([54,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,52]))),Qe=(0,I.lazy)(()=>y(()=>import(`./video-preview-B2dk48oQ.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([55,2,6,1,3,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,52,56,57]))),$e=(0,I.lazy)(()=>y(()=>import(`./audio-preview-B4E5_7TW.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([58,2,3,4,8,9,52,28,57]))),et=(0,I.lazy)(()=>y(()=>import(`./docx-preview-Xy7SZ7Vf.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([59,2,3,4,52,9,25,28])));function tt(e){return e.split(`.`).pop()?.toLowerCase()??``}function nt(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[tt(e)]??`plaintext`}var rt=(0,I.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,i=e?.inlineContent,a=e?.inlineLanguage,[s,c]=(0,I.useState)(i??null),[m,ne]=(0,I.useState)(`utf-8`),[re,g]=(0,I.useState)(!0),[_,y]=(0,I.useState)(null),[S,C]=(0,I.useState)(!1),w=(0,I.useRef)(null),T=(0,I.useRef)(``),E=(0,I.useRef)(null),[le,ue]=(0,I.useState)(null),{tabs:de,updateTab:D}=se(fe(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:O,toggleWordWrap:me}=b(fe(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),k=b(e=>e.inlineBlame),he=b(e=>e.toggleInlineBlame),A=ke(),j=e?.isUntitled===!0,ge=e?.unsavedContent,[_e,ve]=(0,I.useState)(!1),ye=de.find(e=>e.id===t),M=n?tt(n):``,N=je.has(M),xe=M===`pdf`,Se=M===`docx`,Ce=Ae.has(M),we=Ne.has(M),Te=Me.has(M),De=M===`md`||M===`mdx`,Oe=M===`csv`,P=e?.language,F=a??P??nt(n??``),R=F===`sql`,[Pe,Fe]=(0,I.useState)(`preview`),[Ie,Le]=(0,I.useState)(`table`),{connections:Re,cachedTables:ze,refreshTables:Be,updateConnection:Ve}=pe(),z=n?`ppm:sql-conn:${n}`:t?`ppm:sql-conn:tab:${t}`:null,[B,V]=(0,I.useState)(()=>{if(!z)return null;let e=localStorage.getItem(z);return e?Number(e):null}),H=(0,I.useRef)(null),U=(0,I.useRef)(null),W=(0,I.useMemo)(()=>Re.find(e=>e.id===B)??null,[Re,B]),Ke=i!=null&&(a===`json`||a===`xml`),[G,K]=(0,I.useState)(!1),Je=(0,I.useCallback)(()=>{if(i)if(G)c(i),K(!1);else{let e=i.trimStart();if(a===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),K(!0)}catch{}else if(a===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
|
|
3
3
|
$2$3`).split(`
|
|
4
4
|
`).map(e=>{let n=e.trim();n.startsWith(`</`)&&(t=Math.max(0,t-1));let r=` `.repeat(t)+n;return n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.endsWith(`/>`)&&!n.includes(`</`)&&t++,r}).join(`
|
|
5
5
|
`)),K(!0)}}},[i,a,G]),rt=(0,I.useCallback)(e=>{V(e),z&&localStorage.setItem(z,String(e)),Be(e).catch(()=>{})},[z,Be]),q=(0,I.useCallback)(n=>{t&&D(t,{metadata:{...e,language:n}})},[t,e,D]),Y=(0,I.useMemo)(()=>{if(!R||!B)return;let e=(ze.get(B)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>v.get(`/api/db/connections/${B}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[R,B,ze]);(0,I.useEffect)(()=>{if(!(!H.current||!Y))return U.current?.dispose(),p(),U.current=H.current.languages.registerCompletionItemProvider(`sql`,d(H.current,Y)),()=>{U.current?.dispose()}},[Y]);let ot=se(e=>e.openTab),[st,ct]=(0,I.useState)(null),[lt,ut]=(0,I.useState)(null),[dt,ft]=(0,I.useState)(!1),[pt,mt]=(0,I.useState)(``),ht=(0,I.useCallback)(async e=>{if(W){ft(!0),ut(null),mt(e);try{ct(await v.post(`/api/db/connections/${W.id}/query`,{sql:e}))}catch(e){ut(e.message),ct(null)}finally{ft(!1)}}},[W]),gt=(0,I.useCallback)(()=>{!W||!pt||ot({type:`database`,title:`${W.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:W.id,connectionName:W.name,dbType:W.type,initialSql:pt}})},[W,ot,pt]),_t=(0,I.useCallback)(()=>{if(!E.current||!W)return;let e=E.current,t=e.getSelection();ht(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[W,ht]),vt=typeof window<`u`&&`ontouchstart`in window,yt=(0,I.useRef)(null),[bt,xt]=(0,I.useState)(null);(0,I.useEffect)(()=>{if(!vt)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=yt.current;if(!t)return;let n=t.getBoundingClientRect().top;xt(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[vt]),(0,I.useEffect)(()=>be(yt.current,()=>E.current?.layout()),[re,_]);let X=(0,I.useRef)([]),St=(0,I.useRef)(ht);St.current=ht,(0,I.useEffect)(()=>()=>{X.current.forEach(e=>e.dispose()),X.current=[]},[]),(0,I.useEffect)(()=>{Te&&t&&D(t,{type:`sqlite`})},[Te,t,D]);let Z=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,I.useEffect)(()=>{if(i!=null){g(!1);return}if(j){c(ge??``),T.current=ge??``,g(!1),ge&&C(!0);return}if(!n||!Z&&!r)return;if(N||xe||Se||Ce||we){g(!1);return}g(!0),y(null);let e=Z?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;return v.get(e).then(e=>{c(e.content),e.encoding&&ne(e.encoding),T.current=e.content,g(!1)}).catch(e=>{y(e instanceof Error?e.message:`Failed to load file`),g(!1)}),()=>{w.current&&clearTimeout(w.current)}},[n,r,N,xe,Se,Z,j]);let[Ct,wt]=(0,I.useState)(!1),Tt=(0,I.useCallback)(()=>{if(!n||i!=null||j||!Z&&!r)return;let e=Z?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;wt(!0),v.get(e).then(e=>{c(e.content),T.current=e.content,e.encoding&&ne(e.encoding),C(!1),y(null)}).catch(e=>y(e instanceof Error?e.message:`Failed to reload file`)).finally(()=>wt(!1))},[n,r,Z,i,j]),Et=(0,I.useRef)(S);Et.current=S,(0,I.useEffect)(()=>{if(!n||!r||i!=null||j)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||Et.current)return;let i=Z?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ae(r)}/files/read?path=${encodeURIComponent(n)}`;v.get(i).then(e=>{e.content!==T.current&&(c(e.content),T.current=e.content,e.encoding&&ne(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,Z,i,j]),(0,I.useEffect)(()=>{if(!ye||i!=null)return;let t=j?`Untitled-${e?.untitledNumber??1}`:n?x(n):`Untitled`,r=S?`${t} \u25CF`:t;ye.title!==r&&D(ye.id,{title:r})},[S]);let Dt=!j&&i==null&&!!n&&!!r,Ot=ie({editor:le?.editor??null,monaco:le?.monaco??null,projectName:r,filePath:Dt?n:void 0,enabled:k&&Dt}),kt=(0,I.useCallback)(async e=>{if(n&&!(!Z&&!r))try{Z?await v.put(`/api/fs/write`,{path:n,content:e}):await v.put(`${ae(r)}/files/write`,{path:n,content:e}),C(!1),Ot.refresh()}catch{}},[n,r,Z,Ot.refresh]);function At(n){let r=n??``;c(r),T.current=r,C(!0),w.current&&clearTimeout(w.current),j?w.current=setTimeout(()=>{t&&D(t,{metadata:{...e,unsavedContent:T.current}})},2e3):w.current=setTimeout(()=>kt(T.current),1e3)}let jt=(0,I.useCallback)(async(e,n)=>{try{if(w.current&&clearTimeout(w.current),await v.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=oe.getState();n(t),r({type:`editor`,title:x(e),projectId:null,metadata:{filePath:e},closable:!0})}C(!1),ve(!1)}catch{}},[t]),Q=e?.lineNumber,$=e?.endLine,Mt=e?.revealAt,Nt=(0,I.useCallback)(()=>{let e=E.current;if(!(!e||!Q||Q<=0)){if(e.revealLineInCenter(Q),e.setPosition({lineNumber:Q,column:1}),$&&$>=Q){let t=e.getModel(),n=t?.getLineCount()??Q,r=Math.min($,n),i=t?.getLineMaxColumn(r)??1;e.setSelection({startLineNumber:Q,startColumn:1,endLineNumber:r,endColumn:i})}e.focus()}},[Q,$]);(0,I.useEffect)(()=>{Mt!=null&&Nt()},[Mt,Nt]);let Pt=(0,I.useCallback)((e,t)=>{if(E.current=e,H.current=t,ue({editor:e,monaco:t}),Q&&Q>0&&setTimeout(()=>Nt(),100),j&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>ve(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>b.getState().toggleWordWrap()),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyB,()=>b.getState().toggleInlineBlame()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),Y&&(U.current?.dispose(),U.current=t.languages.registerCompletionItemProvider(`sql`,d(t,Y))),R){e.addAction({id:`run-sql-at-cursor`,label:`Run Statement at Cursor`,keybindings:[t.KeyMod.CtrlCmd|t.KeyCode.Enter],run:e=>{let t=e.getPosition();if(!t)return;let n=u(e.getValue(),t.lineNumber);n&&St.current(n)}}),X.current.forEach(e=>e.dispose()),X.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&St.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=(e,n,i=`▷ Run`)=>{let a=n.trim();a&&t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:i,arguments:[a]}})},a=/^(BEGIN|COMMIT|ROLLBACK|END)(;|\s|$)/i,o=-1,s=[];for(let{sql:t,startLine:n}of f(e.getValue())){let e=/^BEGIN(;|\s|$)/i.test(t),r=/^(COMMIT|ROLLBACK|END)(;|\s|$)/i.test(t);o===-1&&e?(o=n,s=[t]):o>-1?(s.push(t),!r&&!a.test(t)&&i(n,t),r&&(i(o,s.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./loader-circle-DPMrnLQ2.js";import{i,n as a}from"./api-client-CEYCBt_0.js";import"./vendor-mermaid-CfY1-PkA.js";import{t as o}from"./settings-store-CzLnTR8p.js";import{It as s,an as c,s as l}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{t as r}from"./loader-circle-DPMrnLQ2.js";import{i,n as a}from"./api-client-CEYCBt_0.js";import"./vendor-mermaid-CfY1-PkA.js";import{t as o}from"./settings-store-CzLnTR8p.js";import{It as s,an as c,s as l}from"./index-DJM59ogE.js";import{t as u}from"./use-monaco-theme-DT5Q8kuf.js";var d=e(t(),1),f=n();function p(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function m(e){let t=e.split(`
|
|
2
2
|
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r];if(e.startsWith(`<<<<<<<`)){let a=r,o=e.substring(7).trim(),s=[];for(r++;r<t.length&&!t[r].startsWith(`=======`);)s.push(t[r]),r++;if(r>=t.length)break;let c=r,l=[];for(r++;r<t.length&&!t[r].startsWith(`>>>>>>>`);)l.push(t[r]),r++;if(r>=t.length)break;let u=t[r].substring(7).trim();n.push({id:i++,startLine:a+1,separatorLine:c+1,endLine:r+1,currentContent:s.join(`
|
|
3
3
|
`),incomingContent:l.join(`
|
|
4
4
|
`),currentLabel:o,incomingLabel:u})}r++}return n}function h({metadata:e}){let t=e?.filePath,n=e?.projectName,[h,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!0),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(0),w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)([]),D=(0,d.useRef)(null),{wordWrap:O}=o(s(e=>({wordWrap:e.wordWrap}))),k=u(),A=(0,d.useRef)(null),[j,M]=(0,d.useState)();(0,d.useEffect)(()=>{let e=A.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&M(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,d.useEffect)(()=>c(A.current,()=>w.current?.layout()),[v,b]),(0,d.useEffect)(()=>{!t||!n||(y(!0),a.get(`${i(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{_(e.content),y(!1)}).catch(e=>{x(e.message||`Failed to load file`),y(!1)}))},[t,n]);let N=(0,d.useCallback)(()=>{let e=w.current,t=T.current;if(!e||!t)return;let n=m(e.getModel()?.getValue()||``);C(n.length);for(let t of E.current)e.removeContentWidget(t);if(E.current=[],D.current&&D.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});D.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${g(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);P(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),E.current.push(a)}},[]),P=(0,d.useCallback)((e,t)=>{let n=w.current,r=T.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=m(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{Br as r,Ft as i,Vr as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import"./vendor-ui-CaeeFO0B.js";import{Br as r,Ft as i,Vr as a}from"./index-DJM59ogE.js";import{n as o,t as s}from"./csv-parser-DbxGKdMG.js";import{i as c,n as l,r as u,t as d}from"./lib-el9rA30D.js";var f=e(t(),1),p=n();function m({content:e,onContentChange:t,wordWrap:n}){let m=(0,f.useMemo)(()=>s(e),[e]),[g,_]=(0,f.useState)(()=>m.rows),[v,y]=(0,f.useState)([]),b=(0,f.useRef)(null),x=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(x.current){x.current=!1;return}_(m.rows)},[m.rows]);let S=m.headers,C=(0,f.useCallback)((e,n,r)=>{_(i=>{let a=i.map((t,n)=>n===e?[...t]:t);return a[e][n]=r,x.current=!0,t(o(S,a)),a})},[S,t]),w=l({data:g,columns:(0,f.useMemo)(()=>S.map((e,t)=>({id:`col-${t}`,header:e||`Column ${t+1}`,accessorFn:e=>e[t]??``,cell:({row:e,getValue:r})=>(0,p.jsx)(h,{value:r(),onSave:n=>C(e.index,t,n),wordWrap:n}),size:150,minSize:80})),[S,C,n]),state:{sorting:v},onSortingChange:y,getCoreRowModel:u(),getSortedRowModel:c(),enableColumnResizing:!0,columnResizeMode:`onChange`}),{rows:T}=w.getRowModel(),E=i({count:T.length,getScrollElement:()=>b.current,estimateSize:()=>32,overscan:20});return S.length===0?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`Empty CSV file`}):(0,p.jsx)(`div`,{ref:b,className:`flex-1 overflow-auto`,children:(0,p.jsxs)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:[(0,p.jsx)(`thead`,{className:`sticky top-0 bg-background z-10 border-b border-border block`,children:w.getHeaderGroups().map(e=>(0,p.jsx)(`tr`,{className:`flex w-full`,children:e.headers.map(e=>(0,p.jsxs)(`th`,{className:`relative text-left px-2 py-1.5 font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/50 border-r border-border last:border-r-0`,style:{width:e.getSize(),minWidth:e.getSize()},onClick:e.column.getToggleSortingHandler(),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`truncate`,children:d(e.column.columnDef.header,e.getContext())}),e.column.getIsSorted()===`asc`&&(0,p.jsx)(r,{className:`size-3 shrink-0`}),e.column.getIsSorted()===`desc`&&(0,p.jsx)(a,{className:`size-3 shrink-0`})]}),(0,p.jsx)(`div`,{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-0 h-full w-1 cursor-col-resize hover:bg-primary/50 active:bg-primary`})]},e.id))},e.id))}),(0,p.jsx)(`tbody`,{style:{height:E.getTotalSize(),position:`relative`,display:`block`},children:E.getVirtualItems().map(e=>{let t=T[e.index];return(0,p.jsx)(`tr`,{"data-index":e.index,ref:e=>E.measureElement(e),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`,display:`flex`},children:t.getVisibleCells().map(e=>(0,p.jsx)(`td`,{className:`px-2 py-1 border-b border-border/50 border-r border-r-border/30 last:border-r-0 ${n?`whitespace-pre-wrap break-words`:`truncate`}`,style:{width:e.column.getSize(),minWidth:e.column.getSize()},children:d(e.column.columnDef.cell,e.getContext())},e.id))},t.id)})})]})})}function h({value:e,onSave:t,wordWrap:n}){let[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(e),s=(0,f.useRef)(null),c=(0,f.useCallback)(e=>{e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[]);return(0,f.useEffect)(()=>{r&&s.current&&(s.current.focus(),c(s.current))},[r,c]),r?(0,p.jsx)(`textarea`,{ref:s,className:`w-full bg-transparent outline-none border border-primary/50 rounded text-xs font-mono resize-none p-0.5`,style:{minHeight:a.includes(`
|
|
2
2
|
`)?48:20},rows:1,value:a,onChange:e=>{o(e.target.value),c(e.target)},onBlur:()=>{i(!1),a!==e&&t(a)},onKeyDown:n=>{n.key===`Enter`&&!n.shiftKey?(n.preventDefault(),i(!1),a!==e&&t(a)):n.key===`Escape`&&(i(!1),o(e))}}):(0,p.jsx)(`span`,{className:`block cursor-text ${n?`whitespace-pre-wrap break-words`:`truncate`}`,onClick:()=>{o(e),i(!0)},children:e||`\xA0`})}export{m as CsvPreview};
|